View | Details | Raw Unified | Return to bug 264238 | Differences between
and this patch

Collapse All | Expand All

(-)b/contrib/wpa/src/l2_packet/l2_packet_freebsd.c (-5 / +8 lines)
Lines 77-100 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;
84
	size_t len;
84
	size_t len;
85
85
86
	packet = pcap_next(pcap, &hdr);
86
	if (pcap_next_ex(pcap, &hdr, &packet) == -1) {
87
		wpa_printf(MSG_ERROR, "Error reading packet, has device disappeared?");
88
		eloop_terminate();
89
	}
87
90
88
	if (!l2->rx_callback || !packet || hdr.caplen < sizeof(*ethhdr))
91
	if (!l2->rx_callback || !packet || hdr->caplen < sizeof(*ethhdr))
89
		return;
92
		return;
90
93
91
	ethhdr = (struct l2_ethhdr *) packet;
94
	ethhdr = (struct l2_ethhdr *) packet;
92
	if (l2->l2_hdr) {
95
	if (l2->l2_hdr) {
93
		buf = (unsigned char *) ethhdr;
96
		buf = (unsigned char *) ethhdr;
94
		len = hdr.caplen;
97
		len = hdr->caplen;
95
	} else {
98
	} else {
96
		buf = (unsigned char *) (ethhdr + 1);
99
		buf = (unsigned char *) (ethhdr + 1);
97
		len = hdr.caplen - sizeof(*ethhdr);
100
		len = hdr->caplen - sizeof(*ethhdr);
98
	}
101
	}
99
	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);
100
}
103
}

Return to bug 264238