Lines Matching refs:ap
28 static void wps_er_ap_process(struct wps_er_ap *ap, struct wpabuf *msg);
29 static int wps_er_send_get_device_info(struct wps_er_ap *ap,
30 void (*m1_handler)(struct wps_er_ap *ap,
59 static struct wps_er_sta * wps_er_sta_get(struct wps_er_ap *ap, const u8 *addr, in wps_er_sta_get() argument
63 dl_list_for_each(sta, &ap->sta, struct wps_er_sta, list) { in wps_er_sta_get()
76 wps_er_sta_event(sta->ap->er->wps, sta, WPS_EV_ER_ENROLLEE_REMOVE); in wps_er_sta_free()
91 static void wps_er_sta_remove_all(struct wps_er_ap *ap) in wps_er_sta_remove_all() argument
94 dl_list_for_each_safe(sta, prev, &ap->sta, struct wps_er_sta, list) in wps_er_sta_remove_all()
103 struct wps_er_ap *ap; in wps_er_ap_get() local
104 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_ap_get()
105 if ((addr == NULL || ap->addr.s_addr == addr->s_addr) && in wps_er_ap_get()
107 os_memcmp(uuid, ap->uuid, WPS_UUID_LEN) == 0) && in wps_er_ap_get()
109 os_memcmp(mac_addr, ap->mac_addr, ETH_ALEN) == 0)) in wps_er_ap_get()
110 return ap; in wps_er_ap_get()
118 struct wps_er_ap *ap; in wps_er_ap_get_id() local
119 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_ap_get_id()
120 if (ap->id == id) in wps_er_ap_get_id()
121 return ap; in wps_er_ap_get_id()
127 static void wps_er_ap_event(struct wps_context *wps, struct wps_er_ap *ap, in wps_er_ap_event() argument
131 struct wps_event_er_ap *evap = &data.ap; in wps_er_ap_event()
137 evap->uuid = ap->uuid; in wps_er_ap_event()
138 evap->friendly_name = ap->friendly_name; in wps_er_ap_event()
139 evap->manufacturer = ap->manufacturer; in wps_er_ap_event()
140 evap->manufacturer_url = ap->manufacturer_url; in wps_er_ap_event()
141 evap->model_description = ap->model_description; in wps_er_ap_event()
142 evap->model_name = ap->model_name; in wps_er_ap_event()
143 evap->model_number = ap->model_number; in wps_er_ap_event()
144 evap->model_url = ap->model_url; in wps_er_ap_event()
145 evap->serial_number = ap->serial_number; in wps_er_ap_event()
146 evap->upc = ap->upc; in wps_er_ap_event()
147 evap->pri_dev_type = ap->pri_dev_type; in wps_er_ap_event()
148 evap->wps_state = ap->wps_state; in wps_er_ap_event()
149 evap->mac_addr = ap->mac_addr; in wps_er_ap_event()
154 static void wps_er_ap_free(struct wps_er_ap *ap) in wps_er_ap_free() argument
156 http_client_free(ap->http); in wps_er_ap_free()
157 ap->http = NULL; in wps_er_ap_free()
159 os_free(ap->location); in wps_er_ap_free()
160 os_free(ap->friendly_name); in wps_er_ap_free()
161 os_free(ap->manufacturer); in wps_er_ap_free()
162 os_free(ap->manufacturer_url); in wps_er_ap_free()
163 os_free(ap->model_description); in wps_er_ap_free()
164 os_free(ap->model_name); in wps_er_ap_free()
165 os_free(ap->model_number); in wps_er_ap_free()
166 os_free(ap->model_url); in wps_er_ap_free()
167 os_free(ap->serial_number); in wps_er_ap_free()
168 os_free(ap->udn); in wps_er_ap_free()
169 os_free(ap->upc); in wps_er_ap_free()
171 os_free(ap->scpd_url); in wps_er_ap_free()
172 os_free(ap->control_url); in wps_er_ap_free()
173 os_free(ap->event_sub_url); in wps_er_ap_free()
175 os_free(ap->ap_settings); in wps_er_ap_free()
177 os_free(ap); in wps_er_ap_free()
181 static void wps_er_ap_unsubscribed(struct wps_er *er, struct wps_er_ap *ap) in wps_er_ap_unsubscribed() argument
184 inet_ntoa(ap->addr), ap->location); in wps_er_ap_unsubscribed()
185 dl_list_del(&ap->list); in wps_er_ap_unsubscribed()
186 wps_er_ap_free(ap); in wps_er_ap_unsubscribed()
196 struct wps_er_ap *ap = ctx; in wps_er_http_unsubscribe_cb() local
201 ap->subscribed = 0; in wps_er_http_unsubscribe_cb()
210 http_client_free(ap->http); in wps_er_http_unsubscribe_cb()
211 ap->http = NULL; in wps_er_http_unsubscribe_cb()
217 wps_er_ap_unsubscribed(ap->er, ap); in wps_er_http_unsubscribe_cb()
221 static void wps_er_ap_unsubscribe(struct wps_er *er, struct wps_er_ap *ap) in wps_er_ap_unsubscribe() argument
228 if (ap->event_sub_url == NULL) { in wps_er_ap_unsubscribe()
233 if (ap->http) { in wps_er_ap_unsubscribe()
239 url = http_client_url_parse(ap->event_sub_url, &dst, &path); in wps_er_ap_unsubscribe()
245 req = wpabuf_alloc(os_strlen(ap->event_sub_url) + 1000); in wps_er_ap_unsubscribe()
250 uuid_bin2str(ap->sid, sid, sizeof(sid)); in wps_er_ap_unsubscribe()
261 ap->http = http_client_addr(&dst, req, 1000, in wps_er_ap_unsubscribe()
262 wps_er_http_unsubscribe_cb, ap); in wps_er_ap_unsubscribe()
263 if (ap->http == NULL) { in wps_er_ap_unsubscribe()
274 wps_er_ap_unsubscribed(ap->er, ap); in wps_er_ap_unsubscribe()
291 struct wps_er_ap *ap; in wps_er_ap_cache_settings() local
294 ap = wps_er_ap_get(er, addr, NULL, NULL); in wps_er_ap_cache_settings()
295 if (ap == NULL || ap->ap_settings == NULL) in wps_er_ap_cache_settings()
298 settings = wps_er_ap_get_settings(er, ap->uuid); in wps_er_ap_cache_settings()
303 os_memcpy(settings->uuid, ap->uuid, WPS_UUID_LEN); in wps_er_ap_cache_settings()
306 os_memcpy(&settings->ap_settings, ap->ap_settings, in wps_er_ap_cache_settings()
314 struct wps_er_ap *ap) in wps_er_ap_use_cached_settings() argument
318 if (ap->ap_settings) in wps_er_ap_use_cached_settings()
321 s = wps_er_ap_get_settings(ap->er, ap->uuid); in wps_er_ap_use_cached_settings()
325 ap->ap_settings = os_malloc(sizeof(*ap->ap_settings)); in wps_er_ap_use_cached_settings()
326 if (ap->ap_settings == NULL) in wps_er_ap_use_cached_settings()
329 os_memcpy(ap->ap_settings, &s->ap_settings, sizeof(*ap->ap_settings)); in wps_er_ap_use_cached_settings()
335 static void wps_er_ap_remove_entry(struct wps_er *er, struct wps_er_ap *ap) in wps_er_ap_remove_entry() argument
338 inet_ntoa(ap->addr), ap->location); in wps_er_ap_remove_entry()
339 eloop_cancel_timeout(wps_er_ap_timeout, er, ap); in wps_er_ap_remove_entry()
340 wps_er_sta_remove_all(ap); in wps_er_ap_remove_entry()
341 wps_er_ap_event(er->wps, ap, WPS_EV_ER_AP_REMOVE); in wps_er_ap_remove_entry()
342 http_client_free(ap->http); in wps_er_ap_remove_entry()
343 ap->http = NULL; in wps_er_ap_remove_entry()
344 if (ap->wps) { in wps_er_ap_remove_entry()
345 wps_deinit(ap->wps); in wps_er_ap_remove_entry()
346 ap->wps = NULL; in wps_er_ap_remove_entry()
349 dl_list_del(&ap->list); in wps_er_ap_remove_entry()
350 if (ap->subscribed) { in wps_er_ap_remove_entry()
351 dl_list_add(&er->ap_unsubscribing, &ap->list); in wps_er_ap_remove_entry()
352 wps_er_ap_unsubscribe(er, ap); in wps_er_ap_remove_entry()
354 wps_er_ap_free(ap); in wps_er_ap_remove_entry()
361 struct wps_er_ap *ap = user_ctx; in wps_er_ap_timeout() local
363 wps_er_ap_remove_entry(er, ap); in wps_er_ap_timeout()
367 static int wps_er_get_sid(struct wps_er_ap *ap, char *sid) in wps_er_get_sid() argument
374 inet_ntoa(ap->addr), ap->location); in wps_er_get_sid()
381 "%s (%s): '%s'", inet_ntoa(ap->addr), ap->location, in wps_er_get_sid()
387 if (uuid_str2bin(pos, ap->sid) < 0) { in wps_er_get_sid()
389 "%s (%s): '%s'", inet_ntoa(ap->addr), ap->location, in wps_er_get_sid()
394 uuid_bin2str(ap->sid, txt, sizeof(txt)); in wps_er_get_sid()
396 inet_ntoa(ap->addr), ap->location, txt); in wps_er_get_sid()
405 struct wps_er_ap *ap = ctx; in wps_er_http_subscribe_cb() local
410 ap->subscribed = 1; in wps_er_http_subscribe_cb()
411 wps_er_get_sid(ap, http_client_get_hdr_line(c, "SID")); in wps_er_http_subscribe_cb()
412 wps_er_ap_use_cached_settings(ap->er, ap); in wps_er_http_subscribe_cb()
413 wps_er_ap_event(ap->er->wps, ap, WPS_EV_ER_AP_ADD); in wps_er_http_subscribe_cb()
421 http_client_free(ap->http); in wps_er_http_subscribe_cb()
422 ap->http = NULL; in wps_er_http_subscribe_cb()
426 static void wps_er_subscribe(struct wps_er_ap *ap) in wps_er_subscribe() argument
432 if (ap->event_sub_url == NULL) { in wps_er_subscribe()
437 if (ap->http) { in wps_er_subscribe()
443 url = http_client_url_parse(ap->event_sub_url, &dst, &path); in wps_er_subscribe()
449 req = wpabuf_alloc(os_strlen(ap->event_sub_url) + 1000); in wps_er_subscribe()
462 ap->er->ip_addr_text, ap->er->http_port, in wps_er_subscribe()
463 ap->er->event_id, ap->id, 1800); in wps_er_subscribe()
468 ap->http = http_client_addr(&dst, req, 1000, wps_er_http_subscribe_cb, in wps_er_subscribe()
469 ap); in wps_er_subscribe()
470 if (ap->http == NULL) in wps_er_subscribe()
475 static void wps_er_ap_get_m1(struct wps_er_ap *ap, struct wpabuf *m1) in wps_er_ap_get_m1() argument
484 os_memcpy(ap->pri_dev_type, attr.primary_dev_type, 8); in wps_er_ap_get_m1()
486 ap->wps_state = *attr.wps_state; in wps_er_ap_get_m1()
488 os_memcpy(ap->mac_addr, attr.mac_addr, ETH_ALEN); in wps_er_ap_get_m1()
490 wps_er_subscribe(ap); in wps_er_ap_get_m1()
494 static void wps_er_get_device_info(struct wps_er_ap *ap) in wps_er_get_device_info() argument
496 wps_er_send_get_device_info(ap, wps_er_ap_get_m1); in wps_er_get_device_info()
533 static void wps_er_parse_device_description(struct wps_er_ap *ap, in wps_er_parse_device_description() argument
555 ap->friendly_name = xml_get_first_item(data, "friendlyName"); in wps_er_parse_device_description()
556 wpa_printf(MSG_DEBUG, "WPS ER: friendlyName='%s'", ap->friendly_name); in wps_er_parse_device_description()
558 ap->manufacturer = xml_get_first_item(data, "manufacturer"); in wps_er_parse_device_description()
559 wpa_printf(MSG_DEBUG, "WPS ER: manufacturer='%s'", ap->manufacturer); in wps_er_parse_device_description()
561 ap->manufacturer_url = xml_get_first_item(data, "manufacturerURL"); in wps_er_parse_device_description()
563 ap->manufacturer_url); in wps_er_parse_device_description()
565 ap->model_description = xml_get_first_item(data, "modelDescription"); in wps_er_parse_device_description()
567 ap->model_description); in wps_er_parse_device_description()
569 ap->model_name = xml_get_first_item(data, "modelName"); in wps_er_parse_device_description()
570 wpa_printf(MSG_DEBUG, "WPS ER: modelName='%s'", ap->model_name); in wps_er_parse_device_description()
572 ap->model_number = xml_get_first_item(data, "modelNumber"); in wps_er_parse_device_description()
573 wpa_printf(MSG_DEBUG, "WPS ER: modelNumber='%s'", ap->model_number); in wps_er_parse_device_description()
575 ap->model_url = xml_get_first_item(data, "modelURL"); in wps_er_parse_device_description()
576 wpa_printf(MSG_DEBUG, "WPS ER: modelURL='%s'", ap->model_url); in wps_er_parse_device_description()
578 ap->serial_number = xml_get_first_item(data, "serialNumber"); in wps_er_parse_device_description()
579 wpa_printf(MSG_DEBUG, "WPS ER: serialNumber='%s'", ap->serial_number); in wps_er_parse_device_description()
581 ap->udn = xml_get_first_item(data, "UDN"); in wps_er_parse_device_description()
582 if (ap->udn) { in wps_er_parse_device_description()
583 wpa_printf(MSG_DEBUG, "WPS ER: UDN='%s'", ap->udn); in wps_er_parse_device_description()
584 pos = os_strstr(ap->udn, "uuid:"); in wps_er_parse_device_description()
587 if (uuid_str2bin(pos, ap->uuid) < 0) in wps_er_parse_device_description()
593 ap->upc = xml_get_first_item(data, "UPC"); in wps_er_parse_device_description()
594 wpa_printf(MSG_DEBUG, "WPS ER: UPC='%s'", ap->upc); in wps_er_parse_device_description()
596 ap->scpd_url = http_link_update( in wps_er_parse_device_description()
597 xml_get_first_item(data, "SCPDURL"), ap->location); in wps_er_parse_device_description()
598 wpa_printf(MSG_DEBUG, "WPS ER: SCPDURL='%s'", ap->scpd_url); in wps_er_parse_device_description()
600 ap->control_url = http_link_update( in wps_er_parse_device_description()
601 xml_get_first_item(data, "controlURL"), ap->location); in wps_er_parse_device_description()
602 wpa_printf(MSG_DEBUG, "WPS ER: controlURL='%s'", ap->control_url); in wps_er_parse_device_description()
604 ap->event_sub_url = http_link_update( in wps_er_parse_device_description()
605 xml_get_first_item(data, "eventSubURL"), ap->location); in wps_er_parse_device_description()
606 wpa_printf(MSG_DEBUG, "WPS ER: eventSubURL='%s'", ap->event_sub_url); in wps_er_parse_device_description()
613 struct wps_er_ap *ap = ctx; in wps_er_http_dev_desc_cb() local
622 wps_er_parse_device_description(ap, reply); in wps_er_http_dev_desc_cb()
631 http_client_free(ap->http); in wps_er_http_dev_desc_cb()
632 ap->http = NULL; in wps_er_http_dev_desc_cb()
634 wps_er_get_device_info(ap); in wps_er_http_dev_desc_cb()
641 struct wps_er_ap *ap; in wps_er_ap_add() local
643 ap = wps_er_ap_get(er, addr, uuid, NULL); in wps_er_ap_add()
644 if (ap) { in wps_er_ap_add()
646 eloop_cancel_timeout(wps_er_ap_timeout, er, ap); in wps_er_ap_add()
647 eloop_register_timeout(max_age, 0, wps_er_ap_timeout, er, ap); in wps_er_ap_add()
651 ap = os_zalloc(sizeof(*ap)); in wps_er_ap_add()
652 if (ap == NULL) in wps_er_ap_add()
654 dl_list_init(&ap->sta); in wps_er_ap_add()
655 ap->er = er; in wps_er_ap_add()
656 ap->id = ++er->next_ap_id; in wps_er_ap_add()
657 ap->location = os_strdup(location); in wps_er_ap_add()
658 if (ap->location == NULL) { in wps_er_ap_add()
659 os_free(ap); in wps_er_ap_add()
662 dl_list_add(&er->ap, &ap->list); in wps_er_ap_add()
664 ap->addr.s_addr = addr->s_addr; in wps_er_ap_add()
665 os_memcpy(ap->uuid, uuid, WPS_UUID_LEN); in wps_er_ap_add()
666 eloop_register_timeout(max_age, 0, wps_er_ap_timeout, er, ap); in wps_er_ap_add()
669 inet_ntoa(ap->addr), ap->location); in wps_er_ap_add()
672 ap->http = http_client_url(ap->location, NULL, 10000, in wps_er_ap_add()
673 wps_er_http_dev_desc_cb, ap); in wps_er_ap_add()
679 struct wps_er_ap *ap; in wps_er_ap_remove() local
680 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_ap_remove()
681 if (ap->addr.s_addr == addr->s_addr) { in wps_er_ap_remove()
682 wps_er_ap_remove_entry(er, ap); in wps_er_ap_remove()
691 struct wps_er_ap *prev, *ap; in wps_er_ap_remove_all() local
693 dl_list_for_each_safe(ap, prev, &er->ap, struct wps_er_ap, list) in wps_er_ap_remove_all()
694 wps_er_ap_remove_entry(er, ap); in wps_er_ap_remove_all()
757 static struct wps_er_sta * wps_er_add_sta_data(struct wps_er_ap *ap, in wps_er_add_sta_data() argument
762 struct wps_er_sta *sta = wps_er_sta_get(ap, addr, NULL); in wps_er_add_sta_data()
781 sta->ap = ap; in wps_er_add_sta_data()
782 dl_list_add(&ap->sta, &sta->list); in wps_er_add_sta_data()
831 wps_er_sta_event(ap->er->wps, sta, WPS_EV_ER_ENROLLEE_ADD); in wps_er_add_sta_data()
837 static void wps_er_process_wlanevent_probe_req(struct wps_er_ap *ap, in wps_er_process_wlanevent_probe_req() argument
860 wps_er_add_sta_data(ap, addr, &attr, 1); in wps_er_process_wlanevent_probe_req()
861 wps_registrar_probe_req_rx(ap->er->wps->registrar, addr, msg, 0); in wps_er_process_wlanevent_probe_req()
977 if (sta->ap->control_url == NULL) { in wps_er_sta_send_msg()
983 url = http_client_url_parse(sta->ap->control_url, &dst, &path); in wps_er_sta_send_msg()
1044 cfg.wps = sta->ap->er->wps; in wps_er_sta_start()
1052 sta->wps->use_cred = sta->ap->ap_settings; in wps_er_sta_start()
1053 if (sta->ap->ap_settings) { in wps_er_sta_start()
1057 os_memcpy(sta->cred, sta->ap->ap_settings, in wps_er_sta_start()
1069 static void wps_er_process_wlanevent_eap(struct wps_er_ap *ap, const u8 *addr, in wps_er_process_wlanevent_eap() argument
1086 sta = wps_er_add_sta_data(ap, addr, &attr, 0); in wps_er_process_wlanevent_eap()
1112 static void wps_er_process_wlanevent(struct wps_er_ap *ap, in wps_er_process_wlanevent() argument
1139 wps_er_process_wlanevent_probe_req(ap, wlan_event_mac, &msg); in wps_er_process_wlanevent()
1142 wps_er_process_wlanevent_eap(ap, wlan_event_mac, &msg); in wps_er_process_wlanevent()
1155 struct wps_er_ap *ap = wps_er_ap_get_id(er, ap_id); in wps_er_http_event() local
1159 if (ap == NULL) { in wps_er_http_event()
1181 wps_er_process_wlanevent(ap, event); in wps_er_http_event()
1258 dl_list_init(&er->ap); in wps_er_init()
1333 struct wps_er_ap *ap; in wps_er_refresh() local
1336 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_refresh()
1337 wps_er_ap_event(er->wps, ap, WPS_EV_ER_AP_ADD); in wps_er_refresh()
1338 dl_list_for_each(sta, &ap->sta, struct wps_er_sta, list) in wps_er_refresh()
1351 struct wps_er_ap *ap, *tmp; in wps_er_deinit_finish() local
1355 dl_list_for_each_safe(ap, tmp, &er->ap_unsubscribing, struct wps_er_ap, in wps_er_deinit_finish()
1358 inet_ntoa(ap->addr), ap->location); in wps_er_deinit_finish()
1359 dl_list_del(&ap->list); in wps_er_deinit_finish()
1360 wps_er_ap_free(ap); in wps_er_deinit_finish()
1393 struct wps_er_ap *ap = ctx; in wps_er_http_set_sel_reg_cb() local
1402 data.set_sel_reg.uuid = ap->uuid; in wps_er_http_set_sel_reg_cb()
1409 data.set_sel_reg.uuid = ap->uuid; in wps_er_http_set_sel_reg_cb()
1412 http_client_free(ap->http); in wps_er_http_set_sel_reg_cb()
1413 ap->http = NULL; in wps_er_http_set_sel_reg_cb()
1416 ap->er->wps->event_cb(ap->er->wps->cb_ctx, in wps_er_http_set_sel_reg_cb()
1421 static void wps_er_send_set_sel_reg(struct wps_er_ap *ap, struct wpabuf *msg) in wps_er_send_set_sel_reg() argument
1428 if (ap->control_url == NULL) { in wps_er_send_set_sel_reg()
1433 if (ap->http) { in wps_er_send_set_sel_reg()
1439 if (ap->wps) { in wps_er_send_set_sel_reg()
1445 url = http_client_url_parse(ap->control_url, &dst, &path); in wps_er_send_set_sel_reg()
1459 ap->http = http_client_addr(&dst, buf, 1000, in wps_er_send_set_sel_reg()
1460 wps_er_http_set_sel_reg_cb, ap); in wps_er_send_set_sel_reg()
1461 if (ap->http == NULL) in wps_er_send_set_sel_reg()
1507 struct wps_er_ap *ap; in wps_er_set_sel_reg() local
1546 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_set_sel_reg()
1548 os_memcmp(ap->uuid, er->set_sel_reg_uuid_filter, in wps_er_set_sel_reg()
1551 data.set_sel_reg.uuid = ap->uuid; in wps_er_set_sel_reg()
1554 wps_er_send_set_sel_reg(ap, msg); in wps_er_set_sel_reg()
1564 struct wps_er_ap *ap; in wps_er_pbc() local
1576 ap = wps_er_ap_get(er, NULL, uuid, NULL); in wps_er_pbc()
1578 ap = NULL; in wps_er_pbc()
1579 if (ap == NULL) { in wps_er_pbc()
1581 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_pbc()
1582 sta = wps_er_sta_get(ap, addr, uuid); in wps_er_pbc()
1584 uuid = ap->uuid; in wps_er_pbc()
1592 if (ap->ap_settings == NULL) { in wps_er_pbc()
1609 struct wps_er_ap *ap = ctx; in wps_er_ap_settings_cb() local
1613 os_free(ap->ap_settings); in wps_er_ap_settings_cb()
1614 ap->ap_settings = os_malloc(sizeof(*cred)); in wps_er_ap_settings_cb()
1615 if (ap->ap_settings) { in wps_er_ap_settings_cb()
1616 os_memcpy(ap->ap_settings, cred, sizeof(*cred)); in wps_er_ap_settings_cb()
1617 ap->ap_settings->cred_attr = NULL; in wps_er_ap_settings_cb()
1621 data.ap_settings.uuid = ap->uuid; in wps_er_ap_settings_cb()
1623 ap->er->wps->event_cb(ap->er->wps->cb_ctx, WPS_EV_ER_AP_SETTINGS, in wps_er_ap_settings_cb()
1630 struct wps_er_ap *ap; in wps_er_get_sta_uuid() local
1631 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_get_sta_uuid()
1633 sta = wps_er_sta_get(ap, addr, NULL); in wps_er_get_sta_uuid()
1644 struct wps_er_ap *ap = ctx; in wps_er_http_put_message_cb() local
1663 if (ap->wps) { in wps_er_http_put_message_cb()
1664 wps_deinit(ap->wps); in wps_er_http_put_message_cb()
1665 ap->wps = NULL; in wps_er_http_put_message_cb()
1669 http_client_free(ap->http); in wps_er_http_put_message_cb()
1670 ap->http = NULL; in wps_er_http_put_message_cb()
1680 wps_deinit(ap->wps); in wps_er_http_put_message_cb()
1681 ap->wps = NULL; in wps_er_http_put_message_cb()
1684 wps_er_ap_process(ap, buf); in wps_er_http_put_message_cb()
1690 static void wps_er_ap_put_message(struct wps_er_ap *ap, in wps_er_ap_put_message() argument
1698 if (ap->http) { in wps_er_ap_put_message()
1704 if (ap->control_url == NULL) { in wps_er_ap_put_message()
1709 url = http_client_url_parse(ap->control_url, &dst, &path); in wps_er_ap_put_message()
1723 ap->http = http_client_addr(&dst, buf, 10000, in wps_er_ap_put_message()
1724 wps_er_http_put_message_cb, ap); in wps_er_ap_put_message()
1725 if (ap->http == NULL) in wps_er_ap_put_message()
1730 static void wps_er_ap_process(struct wps_er_ap *ap, struct wpabuf *msg) in wps_er_ap_process() argument
1751 res = wps_process_msg(ap->wps, op_code, msg); in wps_er_ap_process()
1753 struct wpabuf *next = wps_get_msg(ap->wps, &op_code); in wps_er_ap_process()
1755 wps_er_ap_put_message(ap, next); in wps_er_ap_process()
1760 wps_deinit(ap->wps); in wps_er_ap_process()
1761 ap->wps = NULL; in wps_er_ap_process()
1765 wps_deinit(ap->wps); in wps_er_ap_process()
1766 ap->wps = NULL; in wps_er_ap_process()
1770 wps_deinit(ap->wps); in wps_er_ap_process()
1771 ap->wps = NULL; in wps_er_ap_process()
1776 static void wps_er_ap_learn_m1(struct wps_er_ap *ap, struct wpabuf *m1) in wps_er_ap_learn_m1() argument
1780 if (ap->wps) { in wps_er_ap_learn_m1()
1787 cfg.wps = ap->er->wps; in wps_er_ap_learn_m1()
1789 ap->wps = wps_init(&cfg); in wps_er_ap_learn_m1()
1790 if (ap->wps == NULL) in wps_er_ap_learn_m1()
1792 ap->wps->ap_settings_cb = wps_er_ap_settings_cb; in wps_er_ap_learn_m1()
1793 ap->wps->ap_settings_cb_ctx = ap; in wps_er_ap_learn_m1()
1795 wps_er_ap_process(ap, m1); in wps_er_ap_learn_m1()
1799 static void wps_er_ap_learn(struct wps_er_ap *ap, const char *dev_info) in wps_er_ap_learn() argument
1813 ap->m1_handler(ap, info); in wps_er_ap_learn()
1821 struct wps_er_ap *ap = ctx; in wps_er_http_get_dev_info_cb() local
1842 http_client_free(ap->http); in wps_er_http_get_dev_info_cb()
1843 ap->http = NULL; in wps_er_http_get_dev_info_cb()
1846 wps_er_ap_learn(ap, dev_info); in wps_er_http_get_dev_info_cb()
1852 static int wps_er_send_get_device_info(struct wps_er_ap *ap, in wps_er_send_get_device_info() argument
1853 void (*m1_handler)(struct wps_er_ap *ap, in wps_er_send_get_device_info() argument
1861 if (ap->http) { in wps_er_send_get_device_info()
1867 if (ap->control_url == NULL) { in wps_er_send_get_device_info()
1872 url = http_client_url_parse(ap->control_url, &dst, &path); in wps_er_send_get_device_info()
1886 ap->http = http_client_addr(&dst, buf, 10000, in wps_er_send_get_device_info()
1887 wps_er_http_get_dev_info_cb, ap); in wps_er_send_get_device_info()
1888 if (ap->http == NULL) { in wps_er_send_get_device_info()
1893 ap->m1_handler = m1_handler; in wps_er_send_get_device_info()
1902 struct wps_er_ap *ap; in wps_er_learn() local
1907 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_learn()
1908 if (ap == NULL) { in wps_er_learn()
1914 uuid = ap->uuid; in wps_er_learn()
1915 if (ap->wps) { in wps_er_learn()
1921 if (wps_er_send_get_device_info(ap, wps_er_ap_learn_m1) < 0) in wps_er_learn()
1935 struct wps_er_ap *ap; in wps_er_set_config() local
1940 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_set_config()
1941 if (ap == NULL) { in wps_er_set_config()
1947 os_free(ap->ap_settings); in wps_er_set_config()
1948 ap->ap_settings = os_malloc(sizeof(*cred)); in wps_er_set_config()
1949 if (ap->ap_settings == NULL) in wps_er_set_config()
1951 os_memcpy(ap->ap_settings, cred, sizeof(*cred)); in wps_er_set_config()
1952 ap->ap_settings->cred_attr = NULL; in wps_er_set_config()
1960 static void wps_er_ap_config_m1(struct wps_er_ap *ap, struct wpabuf *m1) in wps_er_ap_config_m1() argument
1964 if (ap->wps) { in wps_er_ap_config_m1()
1971 cfg.wps = ap->er->wps; in wps_er_ap_config_m1()
1973 cfg.new_ap_settings = ap->ap_settings; in wps_er_ap_config_m1()
1974 ap->wps = wps_init(&cfg); in wps_er_ap_config_m1()
1975 if (ap->wps == NULL) in wps_er_ap_config_m1()
1977 ap->wps->ap_settings_cb = NULL; in wps_er_ap_config_m1()
1978 ap->wps->ap_settings_cb_ctx = NULL; in wps_er_ap_config_m1()
1980 wps_er_ap_process(ap, m1); in wps_er_ap_config_m1()
1988 struct wps_er_ap *ap; in wps_er_config() local
1993 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_config()
1994 if (ap == NULL) { in wps_er_config()
2000 uuid = ap->uuid; in wps_er_config()
2001 if (ap->wps) { in wps_er_config()
2007 os_free(ap->ap_settings); in wps_er_config()
2008 ap->ap_settings = os_malloc(sizeof(*cred)); in wps_er_config()
2009 if (ap->ap_settings == NULL) in wps_er_config()
2011 os_memcpy(ap->ap_settings, cred, sizeof(*cred)); in wps_er_config()
2012 ap->ap_settings->cred_attr = NULL; in wps_er_config()
2014 if (wps_er_send_get_device_info(ap, wps_er_ap_config_m1) < 0) in wps_er_config()
2053 struct wps_er_ap *ap; in wps_er_nfc_config_token() local
2058 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_nfc_config_token()
2059 if (ap == NULL) in wps_er_nfc_config_token()
2061 if (ap->ap_settings == NULL) { in wps_er_nfc_config_token()
2067 return wps_er_config_token_from_cred(er->wps, ap->ap_settings); in wps_er_nfc_config_token()
2075 struct wps_er_ap *ap; in wps_er_nfc_handover_sel() local
2080 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_nfc_handover_sel()
2081 if (ap == NULL) in wps_er_nfc_handover_sel()
2083 if (ap->ap_settings == NULL) { in wps_er_nfc_handover_sel()
2089 os_memcpy(wps->ssid, ap->ap_settings->ssid, ap->ap_settings->ssid_len); in wps_er_nfc_handover_sel()
2090 wps->ssid_len = ap->ap_settings->ssid_len; in wps_er_nfc_handover_sel()