Lines Matching refs:drv
168 static int wired_init_sockets(struct wpa_driver_wired_data *drv, u8 *own_addr)
176 drv->common.sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_PAE));
177 if (drv->common.sock < 0) {
183 if (eloop_register_read_sock(drv->common.sock, handle_read,
184 drv->common.ctx, NULL)) {
190 os_strlcpy(ifr.ifr_name, drv->common.ifname, sizeof(ifr.ifr_name));
191 if (ioctl(drv->common.sock, SIOCGIFINDEX, &ifr) != 0) {
203 if (bind(drv->common.sock, (struct sockaddr *) &addr, sizeof(addr)) < 0)
210 if (wired_multicast_membership(drv->common.sock, ifr.ifr_ifindex,
218 os_strlcpy(ifr.ifr_name, drv->common.ifname, sizeof(ifr.ifr_name));
219 if (ioctl(drv->common.sock, SIOCGIFHWADDR, &ifr) != 0) {
233 if ((drv->dhcp_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
239 if (eloop_register_read_sock(drv->dhcp_sock, handle_dhcp,
240 drv->common.ctx, NULL)) {
250 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_REUSEADDR, (char *) &n,
256 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BROADCAST, (char *) &n,
264 os_strlcpy(ifr.ifr_ifrn.ifrn_name, drv->common.ifname, IFNAMSIZ);
265 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BINDTODEVICE,
273 if (bind(drv->dhcp_sock, (struct sockaddr *) &addr2,
290 struct wpa_driver_wired_data *drv = priv;
305 os_memcpy(hdr->dest, drv->use_pae_group_addr ? pae_group_addr : addr,
313 res = send(drv->common.sock, (u8 *) hdr, len, 0);
329 struct wpa_driver_wired_data *drv;
331 drv = os_zalloc(sizeof(struct wpa_driver_wired_data));
332 if (drv == NULL) {
338 drv->common.ctx = hapd;
339 os_strlcpy(drv->common.ifname, params->ifname,
340 sizeof(drv->common.ifname));
341 drv->use_pae_group_addr = params->use_pae_group_addr;
343 if (wired_init_sockets(drv, params->own_addr)) {
344 os_free(drv);
348 return drv;
354 struct wpa_driver_wired_data *drv = priv;
356 if (drv->common.sock >= 0) {
357 eloop_unregister_read_sock(drv->common.sock);
358 close(drv->common.sock);
361 if (drv->dhcp_sock >= 0) {
362 eloop_unregister_read_sock(drv->dhcp_sock);
363 close(drv->dhcp_sock);
366 os_free(drv);
372 struct wpa_driver_wired_data *drv;
374 drv = os_zalloc(sizeof(*drv));
375 if (drv == NULL)
378 if (driver_wired_init_common(&drv->common, ifname, ctx) < 0) {
379 os_free(drv);
383 return drv;
389 struct wpa_driver_wired_data *drv = priv;
391 driver_wired_deinit_common(&drv->common);
392 os_free(drv);