Home | History | Annotate | Download | only in wpa_supplicant

Lines Matching refs:l2

47 int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr)
49 os_memcpy(addr, l2->own_addr, ETH_ALEN);
54 int l2_packet_send(struct l2_packet_data *l2, const u8 *dst_addr, u16 proto,
57 if (!l2->l2_hdr) {
63 os_memcpy(eth->h_source, l2->own_addr, ETH_ALEN);
66 ret = pcap_inject(l2->pcap, (u8 *) eth, len + sizeof(*eth));
70 return pcap_inject(l2->pcap, buf, len);
76 struct l2_packet_data *l2 = eloop_ctx;
90 if (l2->l2_hdr) {
97 l2->rx_callback(l2->rx_callback_ctx, ethhdr->h_source, buf, len);
101 static int l2_packet_init_libpcap(struct l2_packet_data *l2,
108 pcap_lookupnet(l2->ifname, &pcap_netp, &pcap_maskp, pcap_err);
109 l2->pcap = pcap_open_live(l2->ifname, 2500, 0, 10, pcap_err);
110 if (l2->pcap == NULL) {
112 fprintf(stderr, "ifname='%s'\n", l2->ifname);
115 if (pcap_datalink(l2->pcap) != DLT_EN10MB &&
116 pcap_set_datalink(l2->pcap, DLT_EN10MB) < 0) {
118 pcap_geterr(l2->pcap));
125 MAC2STR(l2->own_addr), /* do not receive own packets */
126 MAC2STR(l2->own_addr), MAC2STR(pae_group_addr),
128 if (pcap_compile(l2->pcap, &pcap_fp, pcap_filter, 1, pcap_netp) < 0) {
129 fprintf(stderr, "pcap_compile: %s\n", pcap_geterr(l2->pcap));
133 if (pcap_setfilter(l2->pcap, &pcap_fp) < 0) {
134 fprintf(stderr, "pcap_setfilter: %s\n", pcap_geterr(l2->pcap));
146 if (ioctl(pcap_fileno(l2->pcap), BIOCIMMEDIATE, &on) < 0) {
149 __func__, l2->ifname, strerror(errno));
154 eloop_register_read_sock(pcap_get_selectable_fd(l2->pcap),
155 l2_packet_receive, l2, l2->pcap);
205 struct l2_packet_data *l2;
207 l2 = os_zalloc(sizeof(struct l2_packet_data));
208 if (l2 == NULL)
210 os_strncpy(l2->ifname, ifname, sizeof(l2->ifname));
211 l2->rx_callback = rx_callback;
212 l2->rx_callback_ctx = rx_callback_ctx;
213 l2->l2_hdr = l2_hdr;
215 if (eth_get(l2->ifname, l2->own_addr) < 0) {
217 "interface '%s'.\n", l2->ifname);
218 os_free(l2);
222 if (l2_packet_init_libpcap(l2, protocol)) {
223 os_free(l2);
227 return l2;
231 void l2_packet_deinit(struct l2_packet_data *l2)
233 if (l2 != NULL) {
234 if (l2->pcap) {
236 pcap_get_selectable_fd(l2->pcap));
237 pcap_close(l2->pcap);
239 os_free(l2);
244 int l2_packet_get_ip_addr(struct l2_packet_data *l2, char *buf, size_t len)
258 if (os_strcmp(dev->name, l2->ifname) != 0)
280 void l2_packet_notify_auth_start(struct l2_packet_data *l2)