Lines 77-83
static void l2_packet_receive(int sock, void *eloop_ctx, void *sock_ctx)
Link Here
|
77 |
{ |
77 |
{ |
78 |
struct l2_packet_data *l2 = eloop_ctx; |
78 |
struct l2_packet_data *l2 = eloop_ctx; |
79 |
pcap_t *pcap = sock_ctx; |
79 |
pcap_t *pcap = sock_ctx; |
80 |
struct pcap_pkthdr hdr; |
80 |
struct pcap_pkthdr *hdr; |
81 |
const u_char *packet; |
81 |
const u_char *packet; |
82 |
struct l2_ethhdr *ethhdr; |
82 |
struct l2_ethhdr *ethhdr; |
83 |
unsigned char *buf; |
83 |
unsigned char *buf; |
Lines 88-103
static void l2_packet_receive(int sock, void *eloop_ctx, void *sock_ctx)
Link Here
|
88 |
eloop_terminate(); |
88 |
eloop_terminate(); |
89 |
} |
89 |
} |
90 |
|
90 |
|
91 |
if (!l2->rx_callback || !packet || hdr.caplen < sizeof(*ethhdr)) |
91 |
if (!l2->rx_callback || !packet || hdr->caplen < sizeof(*ethhdr)) |
92 |
return; |
92 |
return; |
93 |
|
93 |
|
94 |
ethhdr = (struct l2_ethhdr *) packet; |
94 |
ethhdr = (struct l2_ethhdr *) packet; |
95 |
if (l2->l2_hdr) { |
95 |
if (l2->l2_hdr) { |
96 |
buf = (unsigned char *) ethhdr; |
96 |
buf = (unsigned char *) ethhdr; |
97 |
len = hdr.caplen; |
97 |
len = hdr->caplen; |
98 |
} else { |
98 |
} else { |
99 |
buf = (unsigned char *) (ethhdr + 1); |
99 |
buf = (unsigned char *) (ethhdr + 1); |
100 |
len = hdr.caplen - sizeof(*ethhdr); |
100 |
len = hdr->caplen - sizeof(*ethhdr); |
101 |
} |
101 |
} |
102 |
l2->rx_callback(l2->rx_callback_ctx, ethhdr->h_source, buf, len); |
102 |
l2->rx_callback(l2->rx_callback_ctx, ethhdr->h_source, buf, len); |
103 |
} |
103 |
} |
104 |
- |
|
|