|
|
@@ -116,10 +116,10 @@ do{ \
|
|
|
|
|
|
struct tcpdump_buf
|
|
|
{
|
|
|
- rt_uint16_t tot_len;
|
|
|
- rt_tick_t tick;
|
|
|
- void *buf;
|
|
|
-};
|
|
|
+ rt_uint16_t tot_len;
|
|
|
+ rt_tick_t tick;
|
|
|
+ void *buf;
|
|
|
+};
|
|
|
|
|
|
struct rt_pcap_file_header
|
|
|
{
|
|
|
@@ -210,16 +210,16 @@ static err_t _netif_linkoutput(struct netif *netif, struct pbuf *p)
|
|
|
RT_ASSERT(tbuf != RT_NULL);
|
|
|
RT_ASSERT(netif != RT_NULL);
|
|
|
|
|
|
- tbuf->tick = rt_tick_get();
|
|
|
- tbuf->buf = ((rt_uint8_t *)tbuf) + sizeof(struct tcpdump_buf);
|
|
|
- tbuf->tot_len = p->tot_len;
|
|
|
+ tbuf->tick = rt_tick_get();
|
|
|
+ tbuf->buf = ((rt_uint8_t *)tbuf) + sizeof(struct tcpdump_buf);
|
|
|
+ tbuf->tot_len = p->tot_len;
|
|
|
pbuf_copy_partial(p, tbuf->buf, p->tot_len, 0);
|
|
|
|
|
|
if (p != RT_NULL)
|
|
|
{
|
|
|
if (rt_mb_send(tcpdump_mb, (rt_uint32_t)tbuf) != RT_EOK)
|
|
|
{
|
|
|
- rt_free(tbuf);
|
|
|
+ rt_free(tbuf);
|
|
|
}
|
|
|
}
|
|
|
return link_output(netif, p);
|
|
|
@@ -234,16 +234,16 @@ static err_t _netif_input(struct pbuf *p, struct netif *inp)
|
|
|
RT_ASSERT(tbuf != RT_NULL);
|
|
|
RT_ASSERT(netif != RT_NULL);
|
|
|
|
|
|
- tbuf->tick = rt_tick_get();
|
|
|
- tbuf->buf = ((rt_uint8_t *)tbuf) + sizeof(struct tcpdump_buf);
|
|
|
- tbuf->tot_len = p->tot_len;
|
|
|
+ tbuf->tick = rt_tick_get();
|
|
|
+ tbuf->buf = ((rt_uint8_t *)tbuf) + sizeof(struct tcpdump_buf);
|
|
|
+ tbuf->tot_len = p->tot_len;
|
|
|
pbuf_copy_partial(p, tbuf->buf, p->tot_len, 0);
|
|
|
|
|
|
if (p != RT_NULL)
|
|
|
{
|
|
|
if (rt_mb_send(tcpdump_mb, (rt_uint32_t)tbuf) != RT_EOK)
|
|
|
{
|
|
|
- rt_free(tbuf);
|
|
|
+ rt_free(tbuf);
|
|
|
}
|
|
|
}
|
|
|
return input(p, inp);
|
|
|
@@ -299,7 +299,7 @@ static rt_err_t rt_tcpdump_pcap_file_save(const void *buf, int len)
|
|
|
/* write ip mess and print */
|
|
|
static void rt_tcpdump_ip_mess_write(struct tcpdump_buf *p)
|
|
|
{
|
|
|
- struct tcpdump_buf *tbuf = p;
|
|
|
+ struct tcpdump_buf *tbuf = p;
|
|
|
|
|
|
RT_ASSERT(tbuf != RT_NULL);
|
|
|
|
|
|
@@ -310,7 +310,7 @@ static void rt_tcpdump_ip_mess_write(struct tcpdump_buf *p)
|
|
|
/* write ip mess */
|
|
|
if (tcpdump_write != RT_NULL)
|
|
|
{
|
|
|
- // rt_kprintf("tbuf->tot_len = %d\n", tbuf->tot_len);
|
|
|
+ // rt_kprintf("tbuf->tot_len = %d\n", tbuf->tot_len);
|
|
|
tcpdump_write(tbuf->buf, tbuf->tot_len);
|
|
|
}
|
|
|
}
|
|
|
@@ -339,17 +339,17 @@ static rt_err_t rt_tcpdump_pcap_file_init(void)
|
|
|
PACP_FILE_HEADER_CREATE(&file_header);
|
|
|
res = tcpdump_write(&file_header, sizeof(file_header));
|
|
|
|
|
|
- /* Positioning at time zero */
|
|
|
- char pacp_zero[] =
|
|
|
+ /* Positioning at time zero */
|
|
|
+ char pacp_zero[] =
|
|
|
{
|
|
|
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
|
|
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
|
|
- 0x08, 0x00,
|
|
|
- ' ', ' ', 'R', 'T', 'T', 'H', 'R', 'E', 'A', 'D', ' ', 'Z', 'E', 'R', 'O'
|
|
|
- };
|
|
|
- PACP_ZERO_PKTHDR_CREATE(&pkthdr, sizeof(pacp_zero));
|
|
|
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
|
|
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
|
|
+ 0x08, 0x00,
|
|
|
+ ' ', ' ', 'R', 'T', 'T', 'H', 'R', 'E', 'A', 'D', ' ', 'Z', 'E', 'R', 'O'
|
|
|
+ };
|
|
|
+ PACP_ZERO_PKTHDR_CREATE(&pkthdr, sizeof(pacp_zero));
|
|
|
tcpdump_write(&pkthdr, sizeof(pkthdr));
|
|
|
- tcpdump_write(pacp_zero, sizeof(pacp_zero));
|
|
|
+ tcpdump_write(pacp_zero, sizeof(pacp_zero));
|
|
|
}
|
|
|
|
|
|
#ifdef PKG_NETUTILS_TCPDUMP_PRINT
|
|
|
@@ -365,7 +365,7 @@ static rt_err_t rt_tcpdump_pcap_file_init(void)
|
|
|
static void rt_tcpdump_thread_entry(void *param)
|
|
|
{
|
|
|
// struct pbuf *pbuf = RT_NULL;
|
|
|
- struct tcpdump_buf *tbuf = RT_NULL;
|
|
|
+ struct tcpdump_buf *tbuf = RT_NULL;
|
|
|
struct rt_pcap_pkthdr pkthdr;
|
|
|
rt_uint32_t mbval;
|
|
|
|
|
|
@@ -397,7 +397,7 @@ static void rt_tcpdump_thread_entry(void *param)
|
|
|
dbg_log(DBG_INFO, "tcpdump stop and tcpdump thread exit!\n");
|
|
|
close(fd);
|
|
|
fd = -1;
|
|
|
-
|
|
|
+
|
|
|
if (tcpdump_pipe != RT_NULL)
|
|
|
rt_device_close((rt_device_t)tcpdump_pipe);
|
|
|
|
|
|
@@ -524,7 +524,7 @@ static void rt_tcpdump_deinit(void)
|
|
|
{
|
|
|
rt_base_t level;
|
|
|
struct rt_mailbox *tcpdump_mb_tmp = RT_NULL;
|
|
|
-
|
|
|
+
|
|
|
if (netif == RT_NULL)
|
|
|
{
|
|
|
dbg_log(DBG_ERROR, "capture packet stopped, no repeat input required!\n");
|
|
|
@@ -533,7 +533,7 @@ static void rt_tcpdump_deinit(void)
|
|
|
|
|
|
/* linkoutput and input deinit */
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
- tcpdump_mb_tmp = tcpdump_mb;
|
|
|
+ tcpdump_mb_tmp = tcpdump_mb;
|
|
|
tcpdump_mb = RT_NULL;
|
|
|
netif->linkoutput = link_output;
|
|
|
netif->input = input;
|
|
|
@@ -541,9 +541,9 @@ static void rt_tcpdump_deinit(void)
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
/* linkoutput and input deinit */
|
|
|
|
|
|
- rt_thread_mdelay(10);
|
|
|
+ rt_thread_mdelay(10);
|
|
|
rt_mb_delete(tcpdump_mb_tmp);
|
|
|
- tcpdump_mb_tmp = RT_NULL;
|
|
|
+ tcpdump_mb_tmp = RT_NULL;
|
|
|
}
|
|
|
|
|
|
static void rt_tcpdump_help_info_print(void)
|