Lines Matching refs:drv

203 static int wired_init_sockets(struct wpa_driver_wired_data *drv, u8 *own_addr)  in wired_init_sockets()  argument
211 drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_PAE)); in wired_init_sockets()
212 if (drv->sock < 0) { in wired_init_sockets()
218 if (eloop_register_read_sock(drv->sock, handle_read, drv->ctx, NULL)) { in wired_init_sockets()
224 os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name)); in wired_init_sockets()
225 if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) { in wired_init_sockets()
237 if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { in wired_init_sockets()
243 if (wired_multicast_membership(drv->sock, ifr.ifr_ifindex, in wired_init_sockets()
251 os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name)); in wired_init_sockets()
252 if (ioctl(drv->sock, SIOCGIFHWADDR, &ifr) != 0) { in wired_init_sockets()
266 if ((drv->dhcp_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { in wired_init_sockets()
272 if (eloop_register_read_sock(drv->dhcp_sock, handle_dhcp, drv->ctx, in wired_init_sockets()
283 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_REUSEADDR, (char *) &n, in wired_init_sockets()
289 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BROADCAST, (char *) &n, in wired_init_sockets()
297 os_strlcpy(ifr.ifr_ifrn.ifrn_name, drv->ifname, IFNAMSIZ); in wired_init_sockets()
298 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BINDTODEVICE, in wired_init_sockets()
306 if (bind(drv->dhcp_sock, (struct sockaddr *) &addr2, in wired_init_sockets()
323 struct wpa_driver_wired_data *drv = priv; in wired_send_eapol() local
338 os_memcpy(hdr->dest, drv->use_pae_group_addr ? pae_group_addr : addr, in wired_send_eapol()
346 res = send(drv->sock, (u8 *) hdr, len, 0); in wired_send_eapol()
362 struct wpa_driver_wired_data *drv; in wired_driver_hapd_init() local
364 drv = os_zalloc(sizeof(struct wpa_driver_wired_data)); in wired_driver_hapd_init()
365 if (drv == NULL) { in wired_driver_hapd_init()
371 drv->ctx = hapd; in wired_driver_hapd_init()
372 os_strlcpy(drv->ifname, params->ifname, sizeof(drv->ifname)); in wired_driver_hapd_init()
373 drv->use_pae_group_addr = params->use_pae_group_addr; in wired_driver_hapd_init()
375 if (wired_init_sockets(drv, params->own_addr)) { in wired_driver_hapd_init()
376 os_free(drv); in wired_driver_hapd_init()
380 return drv; in wired_driver_hapd_init()
386 struct wpa_driver_wired_data *drv = priv; in wired_driver_hapd_deinit() local
388 if (drv->sock >= 0) { in wired_driver_hapd_deinit()
389 eloop_unregister_read_sock(drv->sock); in wired_driver_hapd_deinit()
390 close(drv->sock); in wired_driver_hapd_deinit()
393 if (drv->dhcp_sock >= 0) { in wired_driver_hapd_deinit()
394 eloop_unregister_read_sock(drv->dhcp_sock); in wired_driver_hapd_deinit()
395 close(drv->dhcp_sock); in wired_driver_hapd_deinit()
398 os_free(drv); in wired_driver_hapd_deinit()
561 struct wpa_driver_wired_data *drv; in wpa_driver_wired_init() local
564 drv = os_zalloc(sizeof(*drv)); in wpa_driver_wired_init()
565 if (drv == NULL) in wpa_driver_wired_init()
567 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname)); in wpa_driver_wired_init()
568 drv->ctx = ctx; in wpa_driver_wired_init()
571 drv->pf_sock = socket(PF_PACKET, SOCK_DGRAM, 0); in wpa_driver_wired_init()
572 if (drv->pf_sock < 0) in wpa_driver_wired_init()
575 drv->pf_sock = -1; in wpa_driver_wired_init()
581 drv->iff_up = 1; in wpa_driver_wired_init()
584 if (wired_multicast_membership(drv->pf_sock, in wpa_driver_wired_init()
585 if_nametoindex(drv->ifname), in wpa_driver_wired_init()
589 drv->membership = 1; in wpa_driver_wired_init()
593 drv->multi = 1; in wpa_driver_wired_init()
597 os_free(drv); in wpa_driver_wired_init()
606 os_free(drv); in wpa_driver_wired_init()
611 drv->iff_allmulti = 1; in wpa_driver_wired_init()
624 return drv; in wpa_driver_wired_init()
630 struct wpa_driver_wired_data *drv = priv; in wpa_driver_wired_deinit() local
633 if (drv->membership && in wpa_driver_wired_deinit()
634 wired_multicast_membership(drv->pf_sock, in wpa_driver_wired_deinit()
635 if_nametoindex(drv->ifname), in wpa_driver_wired_deinit()
641 if (drv->multi && in wpa_driver_wired_deinit()
642 wpa_driver_wired_multi(drv->ifname, pae_group_addr, 0) < 0) { in wpa_driver_wired_deinit()
647 if (drv->iff_allmulti && in wpa_driver_wired_deinit()
648 (wpa_driver_wired_get_ifflags(drv->ifname, &flags) < 0 || in wpa_driver_wired_deinit()
649 wpa_driver_wired_set_ifflags(drv->ifname, in wpa_driver_wired_deinit()
655 if (drv->iff_up && in wpa_driver_wired_deinit()
656 wpa_driver_wired_get_ifflags(drv->ifname, &flags) == 0 && in wpa_driver_wired_deinit()
658 wpa_driver_wired_set_ifflags(drv->ifname, flags & ~IFF_UP) < 0) { in wpa_driver_wired_deinit()
663 if (drv->pf_sock != -1) in wpa_driver_wired_deinit()
664 close(drv->pf_sock); in wpa_driver_wired_deinit()
666 os_free(drv); in wpa_driver_wired_deinit()