Home | History | Annotate | Download | only in wpa_supplicant

Lines Matching full:iface

50 static void wpa_priv_cmd_register(struct wpa_priv_interface *iface,
53 if (iface->drv_priv) {
55 if (iface->driver->deinit)
56 iface->driver->deinit(iface->drv_priv);
57 iface->drv_priv = NULL;
58 if (iface->drv_global_priv) {
59 iface->driver->global_deinit(iface->drv_global_priv);
60 iface->drv_global_priv = NULL;
62 iface->wpas_registered = 0;
65 if (iface->l2) {
68 l2_packet_deinit(iface->l2);
69 iface->l2 = NULL;
72 if (iface->driver->init2) {
73 if (iface->driver->global_init) {
74 iface->drv_global_priv =
75 iface->driver->global_init(iface->ctx);
76 if (!iface->drv_global_priv) {
82 iface->drv_global_priv = NULL;
84 iface->drv_priv = iface->driver->init2(iface, iface->ifname,
85 iface->drv_global_priv);
86 } else if (iface->driver->init) {
87 iface->drv_priv = iface->driver->init(iface, iface->ifname);
91 if (iface->drv_priv == NULL) {
97 "'%s'", iface->driver_name, iface->ifname);
99 os_memcpy(&iface->drv_addr, from, sizeof(iface->drv_addr));
100 iface->wpas_registered = 1;
102 if (iface->driver->set_param &&
103 iface->driver->set_param(iface->drv_priv, NULL) < 0) {
109 static void wpa_priv_cmd_unregister(struct wpa_priv_interface *iface,
112 if (iface->drv_priv) {
113 if (iface->driver->deinit)
114 iface->driver->deinit(iface->drv_priv);
115 iface->drv_priv = NULL;
116 if (iface->drv_global_priv) {
117 iface->driver->global_deinit(iface->drv_global_priv);
118 iface->drv_global_priv = NULL;
120 iface->wpas_registered = 0;
125 static void wpa_priv_cmd_scan(struct wpa_priv_interface *iface,
130 if (iface->drv_priv == NULL)
140 if (iface->driver->scan2)
141 iface->driver->scan2(iface->drv_priv, &params);
145 static void wpa_priv_get_scan_results2(struct wpa_priv_interface *iface,
153 res = iface->driver->get_scan_results2(iface->drv_priv);
177 sendto(iface->fd, buf, pos - buf, 0, (struct sockaddr *) from,
187 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, sizeof(*from));
191 static void wpa_priv_cmd_get_scan_results(struct wpa_priv_interface *iface,
194 if (iface->drv_priv == NULL)
197 if (iface->driver->get_scan_results2)
198 wpa_priv_get_scan_results2(iface, from);
200 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from,
205 static void wpa_priv_cmd_authenticate(struct wpa_priv_interface *iface,
212 if (iface->drv_priv == NULL || iface->driver->authenticate == NULL)
252 res = iface->driver->authenticate(iface->drv_priv, &params);
257 static void wpa_priv_cmd_associate(struct wpa_priv_interface *iface,
265 if (iface->drv_priv == NULL || iface->driver->associate == NULL)
300 res = iface->driver->associate(iface->drv_priv, &params);
305 static void wpa_priv_cmd_get_bssid(struct wpa_priv_interface *iface,
310 if (iface->drv_priv == NULL)
313 if (iface->driver->get_bssid == NULL ||
314 iface->driver->get_bssid(iface->drv_priv, bssid) < 0)
317 sendto(iface->fd, bssid, ETH_ALEN, 0, (struct sockaddr *) from,
322 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, sizeof(*from));
326 static void wpa_priv_cmd_get_ssid(struct wpa_priv_interface *iface,
332 if (iface->drv_priv == NULL)
335 if (iface->driver->get_ssid == NULL)
338 res = iface->driver->get_ssid(iface->drv_priv, &ssid[sizeof(int)]);
343 sendto(iface->fd, ssid, sizeof(ssid), 0, (struct sockaddr *) from,
348 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, sizeof(*from));
352 static void wpa_priv_cmd_set_key(struct wpa_priv_interface *iface,
358 if (iface->drv_priv == NULL || iface->driver->set_key == NULL)
368 res = iface->driver->set_key(iface->ifname, iface->drv_priv,
380 static void wpa_priv_cmd_get_capa(struct wpa_priv_interface *iface,
385 if (iface->drv_priv == NULL)
388 if (iface->driver->get_capa == NULL ||
389 iface->driver->get_capa(iface->drv_priv, &capa) < 0)
396 sendto(iface->fd, &capa, sizeof(capa), 0, (struct sockaddr *) from,
401 sendto(iface->fd, "", 0, 0, (struct sockaddr *) from, sizeof(*from));
408 struct wpa_priv_interface *iface = ctx;
420 msg.msg_name = &iface->l2_addr;
421 msg.msg_namelen = sizeof(iface->l2_addr);
423 if (sendmsg(iface->fd, &msg, 0) < 0) {
429 static void wpa_priv_cmd_l2_register(struct wpa_priv_interface *iface,
452 if (iface->l2) {
455 l2_packet_deinit(iface->l2);
456 iface->l2 = NULL;
459 os_memcpy(&iface->l2_addr, from, sizeof(iface->l2_addr));
461 iface->l2 = l2_packet_init(iface->ifname, NULL, proto,
462 wpa_priv_l2_rx, iface, reg_cmd[1]);
463 if (iface->l2 == NULL) {
469 if (l2_packet_get_own_addr(iface->l2, own_addr) < 0) {
472 l2_packet_deinit(iface->l2);
473 iface->l2 = NULL;
477 res = sendto(iface->fd, own_addr, ETH_ALEN, 0,
483 static void wpa_priv_cmd_l2_unregister(struct wpa_priv_interface *iface,
486 if (iface->l2) {
487 l2_packet_deinit(iface->l2);
488 iface->l2 = NULL;
493 static void wpa_priv_cmd_l2_notify_auth_start(struct wpa_priv_interface *iface,
496 if (iface->l2)
497 l2_packet_notify_auth_start(iface->l2);
501 static void wpa_priv_cmd_l2_send(struct wpa_priv_interface *iface,
509 if (iface->l2 == NULL)
527 res = l2_packet_send(iface->l2, dst_addr, proto, buf + ETH_ALEN + 2,
533 static void wpa_priv_cmd_set_country(struct wpa_priv_interface *iface,
536 if (iface->drv_priv == NULL || iface->driver->set_country == NULL ||
540 iface->driver->set_country(iface->drv_priv, buf);
546 struct wpa_priv_interface *iface = eloop_ctx;
568 cmd, iface->ifname);
574 wpa_priv_cmd_register(iface, &from);
577 wpa_priv_cmd_unregister(iface, &from);
580 wpa_priv_cmd_scan(iface, cmd_buf, cmd_len);
583 wpa_priv_cmd_get_scan_results(iface, &from);
586 wpa_priv_cmd_associate(iface, cmd_buf, cmd_len);
589 wpa_priv_cmd_get_bssid(iface, &from);
592 wpa_priv_cmd_get_ssid(iface, &from);
595 wpa_priv_cmd_set_key(iface, cmd_buf, cmd_len);
598 wpa_priv_cmd_get_capa(iface, &from);
601 wpa_priv_cmd_l2_register(iface, &from, cmd_buf, cmd_len);
604 wpa_priv_cmd_l2_unregister(iface, &from);
607 wpa_priv_cmd_l2_notify_auth_start(iface, &from);
610 wpa_priv_cmd_l2_send(iface, &from, cmd_buf, cmd_len);
617 wpa_priv_cmd_set_country(iface, pos);
620 wpa_priv_cmd_authenticate(iface, cmd_buf, cmd_len);
626 static void wpa_priv_interface_deinit(struct wpa_priv_interface *iface)
628 if (iface->drv_priv && iface->driver->deinit)
629 iface->driver->deinit(iface->drv_priv);
631 if (iface->fd >= 0) {
632 eloop_unregister_read_sock(iface->fd);
633 close(iface->fd);
634 unlink(iface->sock_name);
637 if (iface->l2)
638 l2_packet_deinit(iface->l2);
640 os_free(iface->ifname);
641 os_free(iface->driver_name);
642 os_free(iface->sock_name);
643 os_free(iface);
650 struct wpa_priv_interface *iface;
660 iface = os_zalloc(sizeof(*iface));
661 if (iface == NULL)
663 iface->fd = -1;
664 iface->ctx = ctx;
667 iface->driver_name = dup_binstr(params, len);
668 if (iface->driver_name == NULL) {
669 wpa_priv_interface_deinit(iface);
674 if (os_strcmp(iface->driver_name,
676 iface->driver = wpa_drivers[i];
680 if (iface->driver == NULL) {
682 iface
683 wpa_priv_interface_deinit(iface);
688 iface->ifname = os_strdup(pos);
689 if (iface->ifname == NULL) {
690 wpa_priv_interface_deinit(iface);
694 len = os_strlen(dir) + 1 + os_strlen(iface->ifname);
695 iface->sock_name = os_malloc(len + 1);
696 if (iface->sock_name == NULL) {
697 wpa_priv_interface_deinit(iface);
701 os_snprintf(iface->sock_name, len + 1, "%s/%s", dir, iface->ifname);
702 if (os_strlen(iface->sock_name) >= sizeof(addr.sun_path)) {
703 wpa_priv_interface_deinit(iface);
707 iface->fd = socket(PF_UNIX, SOCK_DGRAM, 0);
708 if (iface->fd < 0) {
710 wpa_priv_interface_deinit(iface);
716 os_strlcpy(addr.sun_path, iface->sock_name, sizeof(addr.sun_path));
718 if (bind(iface->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
721 if (connect(iface->fd, (struct sockaddr *) &addr,
726 if (unlink(iface->sock_name) < 0) {
729 iface->sock_name, strerror(errno));
732 if (bind(iface->fd, (struct sockaddr *) &addr,
735 "wpa-priv-iface-init: bind(PF_UNIX): %s",
740 "socket '%s'", iface->sock_name);
745 "not used anymore", iface->sock_name);
750 if (chmod(iface->sock_name, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
755 eloop_register_read_sock(iface->fd, wpa_priv_receive, iface, NULL);
757 return iface;
760 wpa_priv_interface_deinit(iface);
765 static int wpa_priv_send_event(struct wpa_priv_interface *iface, int event,
779 msg.msg_name = &iface->drv_addr;
780 msg.msg_namelen = sizeof(iface->drv_addr);
782 if (sendmsg(iface->fd, &msg, 0) < 0) {
792 static void wpa_priv_send_auth(struct wpa_priv_interface *iface,
816 wpa_priv_send_event(iface, PRIVSEP_EVENT_AUTH, buf, buflen);
822 static void wpa_priv_send_assoc(struct wpa_priv_interface *iface, int event,
877 wpa_priv_send_event(iface, event, buf, buflen);
883 static void wpa_priv_send_interface_status(struct wpa_priv_interface *iface,
907 wpa_priv_send_event(iface, PRIVSEP_EVENT_INTERFACE_STATUS,
915 static void wpa_priv_send_ft_response(struct wpa_priv_interface *iface,
936 wpa_priv_send_event(iface, PRIVSEP_EVENT_FT_RESPONSE, buf, len);
946 struct wpa_priv_interface *iface = ctx;
950 if (!iface->wpas_registered) {
958 wpa_priv_send_assoc(iface, PRIVSEP_EVENT_ASSOC, data);
961 wpa_priv_send_event(iface, PRIVSEP_EVENT_DISASSOC, NULL, 0);
966 wpa_priv_send_assoc(iface, PRIVSEP_EVENT_ASSOCINFO, data);
971 wpa_priv_send_event(iface, PRIVSEP_EVENT_MICHAEL_MIC_FAILURE,
976 wpa_priv_send_event(iface, PRIVSEP_EVENT_SCAN_STARTED, NULL,
980 wpa_priv_send_event(iface, PRIVSEP_EVENT_SCAN_RESULTS, NULL,
984 wpa_priv_send_interface_status(iface, data);
989 wpa_priv_send_event(iface, PRIVSEP_EVENT_PMKID_CANDIDATE,
996 wpa_priv_send_event(iface, PRIVSEP_EVENT_STKSTART,
1000 wpa_priv_send_ft_response(iface, data);
1003 wpa_priv_send_auth(iface, data);
1017 struct wpa_priv_interface *iface;
1022 for (iface = global->interfaces; iface; iface = iface->next) {
1023 if (os_strcmp(iface->ifname, data->interface_status.ifname) ==
1027 if (iface && iface->driver->get_ifindex) {
1030 ifindex = iface->driver->get_ifindex(iface->drv_priv);
1034 iface->ifname, ifindex,
1039 if (iface)
1040 wpa_supplicant_event(iface, event, data);
1047 struct wpa_priv_interface *iface = ctx;
1063 msg.msg_name = &iface->drv_addr;
1064 msg.msg_namelen = sizeof(iface->drv_addr);
1066 if (sendmsg(iface->fd, &msg, 0) < 0)
1120 struct wpa_priv_interface *iface;
1167 iface = wpa_priv_interface_init(&global, ctrl_dir, argv[i]);
1168 if (iface == NULL)
1170 iface->next = global.interfaces;
1171 global.interfaces = iface;
1183 iface = global.interfaces;
1184 while (iface) {
1185 struct wpa_priv_interface *prev = iface;
1186 iface = iface->next;