1 /* 2 * Wired Ethernet driver interface 3 * Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi> 4 * Copyright (c) 2004, Gunter Burchardt <tira@isx.de> 5 * 6 * This software may be distributed under the terms of the BSD license. 7 * See README for more details. 8 */ 9 10 #include "includes.h" 11 #include <sys/ioctl.h> 12 #include <net/if.h> 13 #ifdef __linux__ 14 #include <netpacket/packet.h> 15 #include <net/if_arp.h> 16 #include <net/if.h> 17 #endif /* __linux__ */ 18 #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) 19 #include <net/if_dl.h> 20 #include <net/if_media.h> 21 #endif /* defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) */ 22 #ifdef __sun__ 23 #include <sys/sockio.h> 24 #endif /* __sun__ */ 25 26 #include "common.h" 27 #include "eloop.h" 28 #include "driver.h" 29 30 #ifdef _MSC_VER 31 #pragma pack(push, 1) 32 #endif /* _MSC_VER */ 33 34 struct ieee8023_hdr { 35 u8 dest[6]; 36 u8 src[6]; 37 u16 ethertype; 38 } STRUCT_PACKED; 39 40 #ifdef _MSC_VER 41 #pragma pack(pop) 42 #endif /* _MSC_VER */ 43 44 static const u8 pae_group_addr[ETH_ALEN] = 45 { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03 }; 46 47 48 struct wpa_driver_wired_data { 49 char ifname[IFNAMSIZ + 1]; 50 void *ctx; 51 52 int sock; /* raw packet socket for driver access */ 53 int dhcp_sock; /* socket for dhcp packets */ 54 int use_pae_group_addr; 55 56 int pf_sock; 57 int membership, multi, iff_allmulti, iff_up; 58 }; 59 60 61 /* TODO: detecting new devices should eventually be changed from using DHCP 62 * snooping to trigger on any packet from a new layer 2 MAC address, e.g., 63 * based on ebtables, etc. */ 64 65 struct dhcp_message { 66 u_int8_t op; 67 u_int8_t htype; 68 u_int8_t hlen; 69 u_int8_t hops; 70 u_int32_t xid; 71 u_int16_t secs; 72 u_int16_t flags; 73 u_int32_t ciaddr; 74 u_int32_t yiaddr; 75 u_int32_t siaddr; 76 u_int32_t giaddr; 77 u_int8_t chaddr[16]; 78 u_int8_t sname[64]; 79 u_int8_t file[128]; 80 u_int32_t cookie; 81 u_int8_t options[308]; /* 312 - cookie */ 82 }; 83 84 85 static int wired_multicast_membership(int sock, int ifindex, 86 const u8 *addr, int add) 87 { 88 #ifdef __linux__ 89 struct packet_mreq mreq; 90 91 if (sock < 0) 92 return -1; 93 94 os_memset(&mreq, 0, sizeof(mreq)); 95 mreq.mr_ifindex = ifindex; 96 mreq.mr_type = PACKET_MR_MULTICAST; 97 mreq.mr_alen = ETH_ALEN; 98 os_memcpy(mreq.mr_address, addr, ETH_ALEN); 99 100 if (setsockopt(sock, SOL_PACKET, 101 add ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP, 102 &mreq, sizeof(mreq)) < 0) { 103 wpa_printf(MSG_ERROR, "setsockopt: %s", strerror(errno)); 104 return -1; 105 } 106 return 0; 107 #else /* __linux__ */ 108 return -1; 109 #endif /* __linux__ */ 110 } 111 112 113 #ifdef __linux__ 114 static void handle_data(void *ctx, unsigned char *buf, size_t len) 115 { 116 #ifdef HOSTAPD 117 struct ieee8023_hdr *hdr; 118 u8 *pos, *sa; 119 size_t left; 120 union wpa_event_data event; 121 122 /* must contain at least ieee8023_hdr 6 byte source, 6 byte dest, 123 * 2 byte ethertype */ 124 if (len < 14) { 125 wpa_printf(MSG_MSGDUMP, "handle_data: too short (%lu)", 126 (unsigned long) len); 127 return; 128 } 129 130 hdr = (struct ieee8023_hdr *) buf; 131 132 switch (ntohs(hdr->ethertype)) { 133 case ETH_P_PAE: 134 wpa_printf(MSG_MSGDUMP, "Received EAPOL packet"); 135 sa = hdr->src; 136 os_memset(&event, 0, sizeof(event)); 137 event.new_sta.addr = sa; 138 wpa_supplicant_event(ctx, EVENT_NEW_STA, &event); 139 140 pos = (u8 *) (hdr + 1); 141 left = len - sizeof(*hdr); 142 drv_event_eapol_rx(ctx, sa, pos, left); 143 break; 144 145 default: 146 wpa_printf(MSG_DEBUG, "Unknown ethertype 0x%04x in data frame", 147 ntohs(hdr->ethertype)); 148 break; 149 } 150 #endif /* HOSTAPD */ 151 } 152 153 154 static void handle_read(int sock, void *eloop_ctx, void *sock_ctx) 155 { 156 int len; 157 unsigned char buf[3000]; 158 159 len = recv(sock, buf, sizeof(buf), 0); 160 if (len < 0) { 161 wpa_printf(MSG_ERROR, "recv: %s", strerror(errno)); 162 return; 163 } 164 165 handle_data(eloop_ctx, buf, len); 166 } 167 168 169 static void handle_dhcp(int sock, void *eloop_ctx, void *sock_ctx) 170 { 171 int len; 172 unsigned char buf[3000]; 173 struct dhcp_message *msg; 174 u8 *mac_address; 175 union wpa_event_data event; 176 177 len = recv(sock, buf, sizeof(buf), 0); 178 if (len < 0) { 179 wpa_printf(MSG_ERROR, "recv: %s", strerror(errno)); 180 return; 181 } 182 183 /* must contain at least dhcp_message->chaddr */ 184 if (len < 44) { 185 wpa_printf(MSG_MSGDUMP, "handle_dhcp: too short (%d)", len); 186 return; 187 } 188 189 msg = (struct dhcp_message *) buf; 190 mac_address = (u8 *) &(msg->chaddr); 191 192 wpa_printf(MSG_MSGDUMP, "Got DHCP broadcast packet from " MACSTR, 193 MAC2STR(mac_address)); 194 195 os_memset(&event, 0, sizeof(event)); 196 event.new_sta.addr = mac_address; 197 wpa_supplicant_event(eloop_ctx, EVENT_NEW_STA, &event); 198 } 199 #endif /* __linux__ */ 200 201 202 static int wired_init_sockets(struct wpa_driver_wired_data *drv, u8 *own_addr) 203 { 204 #ifdef __linux__ 205 struct ifreq ifr; 206 struct sockaddr_ll addr; 207 struct sockaddr_in addr2; 208 int n = 1; 209 210 drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_PAE)); 211 if (drv->sock < 0) { 212 wpa_printf(MSG_ERROR, "socket[PF_PACKET,SOCK_RAW]: %s", 213 strerror(errno)); 214 return -1; 215 } 216 217 if (eloop_register_read_sock(drv->sock, handle_read, drv->ctx, NULL)) { 218 wpa_printf(MSG_INFO, "Could not register read socket"); 219 return -1; 220 } 221 222 os_memset(&ifr, 0, sizeof(ifr)); 223 os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name)); 224 if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) { 225 wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s", 226 strerror(errno)); 227 return -1; 228 } 229 230 os_memset(&addr, 0, sizeof(addr)); 231 addr.sll_family = AF_PACKET; 232 addr.sll_ifindex = ifr.ifr_ifindex; 233 wpa_printf(MSG_DEBUG, "Opening raw packet socket for ifindex %d", 234 addr.sll_ifindex); 235 236 if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { 237 wpa_printf(MSG_ERROR, "bind: %s", strerror(errno)); 238 return -1; 239 } 240 241 /* filter multicast address */ 242 if (wired_multicast_membership(drv->sock, ifr.ifr_ifindex, 243 pae_group_addr, 1) < 0) { 244 wpa_printf(MSG_ERROR, "wired: Failed to add multicast group " 245 "membership"); 246 return -1; 247 } 248 249 os_memset(&ifr, 0, sizeof(ifr)); 250 os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name)); 251 if (ioctl(drv->sock, SIOCGIFHWADDR, &ifr) != 0) { 252 wpa_printf(MSG_ERROR, "ioctl(SIOCGIFHWADDR): %s", 253 strerror(errno)); 254 return -1; 255 } 256 257 if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) { 258 wpa_printf(MSG_INFO, "Invalid HW-addr family 0x%04x", 259 ifr.ifr_hwaddr.sa_family); 260 return -1; 261 } 262 os_memcpy(own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN); 263 264 /* setup dhcp listen socket for sta detection */ 265 if ((drv->dhcp_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { 266 wpa_printf(MSG_ERROR, "socket call failed for dhcp: %s", 267 strerror(errno)); 268 return -1; 269 } 270 271 if (eloop_register_read_sock(drv->dhcp_sock, handle_dhcp, drv->ctx, 272 NULL)) { 273 wpa_printf(MSG_INFO, "Could not register read socket"); 274 return -1; 275 } 276 277 os_memset(&addr2, 0, sizeof(addr2)); 278 addr2.sin_family = AF_INET; 279 addr2.sin_port = htons(67); 280 addr2.sin_addr.s_addr = INADDR_ANY; 281 282 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_REUSEADDR, (char *) &n, 283 sizeof(n)) == -1) { 284 wpa_printf(MSG_ERROR, "setsockopt[SOL_SOCKET,SO_REUSEADDR]: %s", 285 strerror(errno)); 286 return -1; 287 } 288 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BROADCAST, (char *) &n, 289 sizeof(n)) == -1) { 290 wpa_printf(MSG_ERROR, "setsockopt[SOL_SOCKET,SO_BROADCAST]: %s", 291 strerror(errno)); 292 return -1; 293 } 294 295 os_memset(&ifr, 0, sizeof(ifr)); 296 os_strlcpy(ifr.ifr_ifrn.ifrn_name, drv->ifname, IFNAMSIZ); 297 if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BINDTODEVICE, 298 (char *) &ifr, sizeof(ifr)) < 0) { 299 wpa_printf(MSG_ERROR, 300 "setsockopt[SOL_SOCKET,SO_BINDTODEVICE]: %s", 301 strerror(errno)); 302 return -1; 303 } 304 305 if (bind(drv->dhcp_sock, (struct sockaddr *) &addr2, 306 sizeof(struct sockaddr)) == -1) { 307 wpa_printf(MSG_ERROR, "bind: %s", strerror(errno)); 308 return -1; 309 } 310 311 return 0; 312 #else /* __linux__ */ 313 return -1; 314 #endif /* __linux__ */ 315 } 316 317 318 static int wired_send_eapol(void *priv, const u8 *addr, 319 const u8 *data, size_t data_len, int encrypt, 320 const u8 *own_addr, u32 flags) 321 { 322 struct wpa_driver_wired_data *drv = priv; 323 struct ieee8023_hdr *hdr; 324 size_t len; 325 u8 *pos; 326 int res; 327 328 len = sizeof(*hdr) + data_len; 329 hdr = os_zalloc(len); 330 if (hdr == NULL) { 331 wpa_printf(MSG_INFO, 332 "malloc() failed for wired_send_eapol(len=%lu)", 333 (unsigned long) len); 334 return -1; 335 } 336 337 os_memcpy(hdr->dest, drv->use_pae_group_addr ? pae_group_addr : addr, 338 ETH_ALEN); 339 os_memcpy(hdr->src, own_addr, ETH_ALEN); 340 hdr->ethertype = htons(ETH_P_PAE); 341 342 pos = (u8 *) (hdr + 1); 343 os_memcpy(pos, data, data_len); 344 345 res = send(drv->sock, (u8 *) hdr, len, 0); 346 os_free(hdr); 347 348 if (res < 0) { 349 wpa_printf(MSG_ERROR, 350 "wired_send_eapol - packet len: %lu - failed: send: %s", 351 (unsigned long) len, strerror(errno)); 352 } 353 354 return res; 355 } 356 357 358 static void * wired_driver_hapd_init(struct hostapd_data *hapd, 359 struct wpa_init_params *params) 360 { 361 struct wpa_driver_wired_data *drv; 362 363 drv = os_zalloc(sizeof(struct wpa_driver_wired_data)); 364 if (drv == NULL) { 365 wpa_printf(MSG_INFO, 366 "Could not allocate memory for wired driver data"); 367 return NULL; 368 } 369 370 drv->ctx = hapd; 371 os_strlcpy(drv->ifname, params->ifname, sizeof(drv->ifname)); 372 drv->use_pae_group_addr = params->use_pae_group_addr; 373 374 if (wired_init_sockets(drv, params->own_addr)) { 375 os_free(drv); 376 return NULL; 377 } 378 379 return drv; 380 } 381 382 383 static void wired_driver_hapd_deinit(void *priv) 384 { 385 struct wpa_driver_wired_data *drv = priv; 386 387 if (drv->sock >= 0) { 388 eloop_unregister_read_sock(drv->sock); 389 close(drv->sock); 390 } 391 392 if (drv->dhcp_sock >= 0) { 393 eloop_unregister_read_sock(drv->dhcp_sock); 394 close(drv->dhcp_sock); 395 } 396 397 os_free(drv); 398 } 399 400 401 static int wpa_driver_wired_get_ssid(void *priv, u8 *ssid) 402 { 403 ssid[0] = 0; 404 return 0; 405 } 406 407 408 static int wpa_driver_wired_get_bssid(void *priv, u8 *bssid) 409 { 410 /* Report PAE group address as the "BSSID" for wired connection. */ 411 os_memcpy(bssid, pae_group_addr, ETH_ALEN); 412 return 0; 413 } 414 415 416 static int wpa_driver_wired_get_capa(void *priv, struct wpa_driver_capa *capa) 417 { 418 os_memset(capa, 0, sizeof(*capa)); 419 capa->flags = WPA_DRIVER_FLAGS_WIRED; 420 return 0; 421 } 422 423 424 static int wpa_driver_wired_get_ifflags(const char *ifname, int *flags) 425 { 426 struct ifreq ifr; 427 int s; 428 429 s = socket(PF_INET, SOCK_DGRAM, 0); 430 if (s < 0) { 431 wpa_printf(MSG_ERROR, "socket: %s", strerror(errno)); 432 return -1; 433 } 434 435 os_memset(&ifr, 0, sizeof(ifr)); 436 os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); 437 if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { 438 wpa_printf(MSG_ERROR, "ioctl[SIOCGIFFLAGS]: %s", 439 strerror(errno)); 440 close(s); 441 return -1; 442 } 443 close(s); 444 *flags = ifr.ifr_flags & 0xffff; 445 return 0; 446 } 447 448 449 static int wpa_driver_wired_set_ifflags(const char *ifname, int flags) 450 { 451 struct ifreq ifr; 452 int s; 453 454 s = socket(PF_INET, SOCK_DGRAM, 0); 455 if (s < 0) { 456 wpa_printf(MSG_ERROR, "socket: %s", strerror(errno)); 457 return -1; 458 } 459 460 os_memset(&ifr, 0, sizeof(ifr)); 461 os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); 462 ifr.ifr_flags = flags & 0xffff; 463 if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) { 464 wpa_printf(MSG_ERROR, "ioctl[SIOCSIFFLAGS]: %s", 465 strerror(errno)); 466 close(s); 467 return -1; 468 } 469 close(s); 470 return 0; 471 } 472 473 #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) 474 static int wpa_driver_wired_get_ifstatus(const char *ifname, int *status) 475 { 476 struct ifmediareq ifmr; 477 int s; 478 479 s = socket(PF_INET, SOCK_DGRAM, 0); 480 if (s < 0) { 481 wpa_printf(MSG_ERROR, "socket: %s", strerror(errno)); 482 return -1; 483 } 484 485 os_memset(&ifmr, 0, sizeof(ifmr)); 486 os_strlcpy(ifmr.ifm_name, ifname, IFNAMSIZ); 487 if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) { 488 wpa_printf(MSG_ERROR, "ioctl[SIOCGIFMEDIA]: %s", 489 strerror(errno)); 490 close(s); 491 return -1; 492 } 493 close(s); 494 *status = (ifmr.ifm_status & (IFM_ACTIVE | IFM_AVALID)) == 495 (IFM_ACTIVE | IFM_AVALID); 496 497 return 0; 498 } 499 #endif /* defined(__FreeBSD__) || defined(__DragonFly__) || defined(FreeBSD_kernel__) */ 500 501 502 static int wpa_driver_wired_multi(const char *ifname, const u8 *addr, int add) 503 { 504 struct ifreq ifr; 505 int s; 506 507 #ifdef __sun__ 508 return -1; 509 #endif /* __sun__ */ 510 511 s = socket(PF_INET, SOCK_DGRAM, 0); 512 if (s < 0) { 513 wpa_printf(MSG_ERROR, "socket: %s", strerror(errno)); 514 return -1; 515 } 516 517 os_memset(&ifr, 0, sizeof(ifr)); 518 os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); 519 #ifdef __linux__ 520 ifr.ifr_hwaddr.sa_family = AF_UNSPEC; 521 os_memcpy(ifr.ifr_hwaddr.sa_data, addr, ETH_ALEN); 522 #endif /* __linux__ */ 523 #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) 524 { 525 struct sockaddr_dl *dlp; 526 dlp = (struct sockaddr_dl *) &ifr.ifr_addr; 527 dlp->sdl_len = sizeof(struct sockaddr_dl); 528 dlp->sdl_family = AF_LINK; 529 dlp->sdl_index = 0; 530 dlp->sdl_nlen = 0; 531 dlp->sdl_alen = ETH_ALEN; 532 dlp->sdl_slen = 0; 533 os_memcpy(LLADDR(dlp), addr, ETH_ALEN); 534 } 535 #endif /* defined(__FreeBSD__) || defined(__DragonFly__) || defined(FreeBSD_kernel__) */ 536 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) 537 { 538 struct sockaddr *sap; 539 sap = (struct sockaddr *) &ifr.ifr_addr; 540 sap->sa_len = sizeof(struct sockaddr); 541 sap->sa_family = AF_UNSPEC; 542 os_memcpy(sap->sa_data, addr, ETH_ALEN); 543 } 544 #endif /* defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) */ 545 546 if (ioctl(s, add ? SIOCADDMULTI : SIOCDELMULTI, (caddr_t) &ifr) < 0) { 547 wpa_printf(MSG_ERROR, "ioctl[SIOC{ADD/DEL}MULTI]: %s", 548 strerror(errno)); 549 close(s); 550 return -1; 551 } 552 close(s); 553 return 0; 554 } 555 556 557 static void * wpa_driver_wired_init(void *ctx, const char *ifname) 558 { 559 struct wpa_driver_wired_data *drv; 560 int flags, status; 561 562 drv = os_zalloc(sizeof(*drv)); 563 if (drv == NULL) 564 return NULL; 565 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname)); 566 drv->ctx = ctx; 567 568 #ifdef __linux__ 569 drv->pf_sock = socket(PF_PACKET, SOCK_DGRAM, 0); 570 if (drv->pf_sock < 0) 571 wpa_printf(MSG_ERROR, "socket(PF_PACKET): %s", strerror(errno)); 572 #else /* __linux__ */ 573 drv->pf_sock = -1; 574 #endif /* __linux__ */ 575 576 if (wpa_driver_wired_get_ifflags(ifname, &flags) == 0 && 577 !(flags & IFF_UP) && 578 wpa_driver_wired_set_ifflags(ifname, flags | IFF_UP) == 0) { 579 drv->iff_up = 1; 580 } 581 582 if (wired_multicast_membership(drv->pf_sock, 583 if_nametoindex(drv->ifname), 584 pae_group_addr, 1) == 0) { 585 wpa_printf(MSG_DEBUG, "%s: Added multicast membership with " 586 "packet socket", __func__); 587 drv->membership = 1; 588 } else if (wpa_driver_wired_multi(ifname, pae_group_addr, 1) == 0) { 589 wpa_printf(MSG_DEBUG, "%s: Added multicast membership with " 590 "SIOCADDMULTI", __func__); 591 drv->multi = 1; 592 } else if (wpa_driver_wired_get_ifflags(ifname, &flags) < 0) { 593 wpa_printf(MSG_INFO, "%s: Could not get interface " 594 "flags", __func__); 595 os_free(drv); 596 return NULL; 597 } else if (flags & IFF_ALLMULTI) { 598 wpa_printf(MSG_DEBUG, "%s: Interface is already configured " 599 "for multicast", __func__); 600 } else if (wpa_driver_wired_set_ifflags(ifname, 601 flags | IFF_ALLMULTI) < 0) { 602 wpa_printf(MSG_INFO, "%s: Failed to enable allmulti", 603 __func__); 604 os_free(drv); 605 return NULL; 606 } else { 607 wpa_printf(MSG_DEBUG, "%s: Enabled allmulti mode", 608 __func__); 609 drv->iff_allmulti = 1; 610 } 611 #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) 612 { 613 int status; 614 wpa_printf(MSG_DEBUG, "%s: waiting for link to become active", 615 __func__); 616 while (wpa_driver_wired_get_ifstatus(ifname, &status) == 0 && 617 status == 0) 618 sleep(1); 619 } 620 #endif /* defined(__FreeBSD__) || defined(__DragonFly__) || defined(FreeBSD_kernel__) */ 621 622 return drv; 623 } 624 625 626 static void wpa_driver_wired_deinit(void *priv) 627 { 628 struct wpa_driver_wired_data *drv = priv; 629 int flags; 630 631 if (drv->membership && 632 wired_multicast_membership(drv->pf_sock, 633 if_nametoindex(drv->ifname), 634 pae_group_addr, 0) < 0) { 635 wpa_printf(MSG_DEBUG, "%s: Failed to remove PAE multicast " 636 "group (PACKET)", __func__); 637 } 638 639 if (drv->multi && 640 wpa_driver_wired_multi(drv->ifname, pae_group_addr, 0) < 0) { 641 wpa_printf(MSG_DEBUG, "%s: Failed to remove PAE multicast " 642 "group (SIOCDELMULTI)", __func__); 643 } 644 645 if (drv->iff_allmulti && 646 (wpa_driver_wired_get_ifflags(drv->ifname, &flags) < 0 || 647 wpa_driver_wired_set_ifflags(drv->ifname, 648 flags & ~IFF_ALLMULTI) < 0)) { 649 wpa_printf(MSG_DEBUG, "%s: Failed to disable allmulti mode", 650 __func__); 651 } 652 653 if (drv->iff_up && 654 wpa_driver_wired_get_ifflags(drv->ifname, &flags) == 0 && 655 (flags & IFF_UP) && 656 wpa_driver_wired_set_ifflags(drv->ifname, flags & ~IFF_UP) < 0) { 657 wpa_printf(MSG_DEBUG, "%s: Failed to set the interface down", 658 __func__); 659 } 660 661 if (drv->pf_sock != -1) 662 close(drv->pf_sock); 663 664 os_free(drv); 665 } 666 667 668 const struct wpa_driver_ops wpa_driver_wired_ops = { 669 .name = "wired", 670 .desc = "Wired Ethernet driver", 671 .hapd_init = wired_driver_hapd_init, 672 .hapd_deinit = wired_driver_hapd_deinit, 673 .hapd_send_eapol = wired_send_eapol, 674 .get_ssid = wpa_driver_wired_get_ssid, 675 .get_bssid = wpa_driver_wired_get_bssid, 676 .get_capa = wpa_driver_wired_get_capa, 677 .init = wpa_driver_wired_init, 678 .deinit = wpa_driver_wired_deinit, 679 }; 680