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 ether_addr_equal(mac_addr, ap->mac_addr))) 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_memdup(&s->ap_settings, sizeof(*ap->ap_settings)); in wps_er_ap_use_cached_settings()
326 if (ap->ap_settings == NULL) in wps_er_ap_use_cached_settings()
334 static void wps_er_ap_remove_entry(struct wps_er *er, struct wps_er_ap *ap) in wps_er_ap_remove_entry() argument
337 inet_ntoa(ap->addr), ap->location); in wps_er_ap_remove_entry()
338 eloop_cancel_timeout(wps_er_ap_timeout, er, ap); in wps_er_ap_remove_entry()
339 wps_er_sta_remove_all(ap); in wps_er_ap_remove_entry()
340 wps_er_ap_event(er->wps, ap, WPS_EV_ER_AP_REMOVE); in wps_er_ap_remove_entry()
341 http_client_free(ap->http); in wps_er_ap_remove_entry()
342 ap->http = NULL; in wps_er_ap_remove_entry()
343 if (ap->wps) { in wps_er_ap_remove_entry()
344 wps_deinit(ap->wps); in wps_er_ap_remove_entry()
345 ap->wps = NULL; in wps_er_ap_remove_entry()
348 dl_list_del(&ap->list); in wps_er_ap_remove_entry()
349 if (ap->subscribed) { in wps_er_ap_remove_entry()
350 dl_list_add(&er->ap_unsubscribing, &ap->list); in wps_er_ap_remove_entry()
351 wps_er_ap_unsubscribe(er, ap); in wps_er_ap_remove_entry()
353 wps_er_ap_free(ap); in wps_er_ap_remove_entry()
360 struct wps_er_ap *ap = user_ctx; in wps_er_ap_timeout() local
362 wps_er_ap_remove_entry(er, ap); in wps_er_ap_timeout()
366 static int wps_er_get_sid(struct wps_er_ap *ap, char *sid) in wps_er_get_sid() argument
373 inet_ntoa(ap->addr), ap->location); in wps_er_get_sid()
380 "%s (%s): '%s'", inet_ntoa(ap->addr), ap->location, in wps_er_get_sid()
386 if (uuid_str2bin(pos, ap->sid) < 0) { in wps_er_get_sid()
388 "%s (%s): '%s'", inet_ntoa(ap->addr), ap->location, in wps_er_get_sid()
393 uuid_bin2str(ap->sid, txt, sizeof(txt)); in wps_er_get_sid()
395 inet_ntoa(ap->addr), ap->location, txt); in wps_er_get_sid()
404 struct wps_er_ap *ap = ctx; in wps_er_http_subscribe_cb() local
409 ap->subscribed = 1; in wps_er_http_subscribe_cb()
410 wps_er_get_sid(ap, http_client_get_hdr_line(c, "SID")); in wps_er_http_subscribe_cb()
411 wps_er_ap_use_cached_settings(ap->er, ap); in wps_er_http_subscribe_cb()
412 wps_er_ap_event(ap->er->wps, ap, WPS_EV_ER_AP_ADD); in wps_er_http_subscribe_cb()
420 http_client_free(ap->http); in wps_er_http_subscribe_cb()
421 ap->http = NULL; in wps_er_http_subscribe_cb()
425 static void wps_er_subscribe(struct wps_er_ap *ap) in wps_er_subscribe() argument
431 if (ap->event_sub_url == NULL) { in wps_er_subscribe()
436 if (ap->http) { in wps_er_subscribe()
442 url = http_client_url_parse(ap->event_sub_url, &dst, &path); in wps_er_subscribe()
448 req = wpabuf_alloc(os_strlen(ap->event_sub_url) + 1000); in wps_er_subscribe()
461 ap->er->ip_addr_text, ap->er->http_port, in wps_er_subscribe()
462 ap->er->event_id, ap->id, 1800); in wps_er_subscribe()
467 ap->http = http_client_addr(&dst, req, 1000, wps_er_http_subscribe_cb, in wps_er_subscribe()
468 ap); in wps_er_subscribe()
469 if (ap->http == NULL) in wps_er_subscribe()
474 static void wps_er_ap_get_m1(struct wps_er_ap *ap, struct wpabuf *m1) in wps_er_ap_get_m1() argument
483 os_memcpy(ap->pri_dev_type, attr.primary_dev_type, 8); in wps_er_ap_get_m1()
485 ap->wps_state = *attr.wps_state; in wps_er_ap_get_m1()
487 os_memcpy(ap->mac_addr, attr.mac_addr, ETH_ALEN); in wps_er_ap_get_m1()
489 wps_er_subscribe(ap); in wps_er_ap_get_m1()
493 static void wps_er_get_device_info(struct wps_er_ap *ap) in wps_er_get_device_info() argument
495 wps_er_send_get_device_info(ap, wps_er_ap_get_m1); in wps_er_get_device_info()
532 static void wps_er_parse_device_description(struct wps_er_ap *ap, in wps_er_parse_device_description() argument
554 ap->friendly_name = xml_get_first_item(data, "friendlyName"); in wps_er_parse_device_description()
555 wpa_printf(MSG_DEBUG, "WPS ER: friendlyName='%s'", ap->friendly_name); in wps_er_parse_device_description()
557 ap->manufacturer = xml_get_first_item(data, "manufacturer"); in wps_er_parse_device_description()
558 wpa_printf(MSG_DEBUG, "WPS ER: manufacturer='%s'", ap->manufacturer); in wps_er_parse_device_description()
560 ap->manufacturer_url = xml_get_first_item(data, "manufacturerURL"); in wps_er_parse_device_description()
562 ap->manufacturer_url); in wps_er_parse_device_description()
564 ap->model_description = xml_get_first_item(data, "modelDescription"); in wps_er_parse_device_description()
566 ap->model_description); in wps_er_parse_device_description()
568 ap->model_name = xml_get_first_item(data, "modelName"); in wps_er_parse_device_description()
569 wpa_printf(MSG_DEBUG, "WPS ER: modelName='%s'", ap->model_name); in wps_er_parse_device_description()
571 ap->model_number = xml_get_first_item(data, "modelNumber"); in wps_er_parse_device_description()
572 wpa_printf(MSG_DEBUG, "WPS ER: modelNumber='%s'", ap->model_number); in wps_er_parse_device_description()
574 ap->model_url = xml_get_first_item(data, "modelURL"); in wps_er_parse_device_description()
575 wpa_printf(MSG_DEBUG, "WPS ER: modelURL='%s'", ap->model_url); in wps_er_parse_device_description()
577 ap->serial_number = xml_get_first_item(data, "serialNumber"); in wps_er_parse_device_description()
578 wpa_printf(MSG_DEBUG, "WPS ER: serialNumber='%s'", ap->serial_number); in wps_er_parse_device_description()
580 ap->udn = xml_get_first_item(data, "UDN"); in wps_er_parse_device_description()
581 if (ap->udn) { in wps_er_parse_device_description()
582 wpa_printf(MSG_DEBUG, "WPS ER: UDN='%s'", ap->udn); in wps_er_parse_device_description()
583 pos = os_strstr(ap->udn, "uuid:"); in wps_er_parse_device_description()
586 if (uuid_str2bin(pos, ap->uuid) < 0) in wps_er_parse_device_description()
592 ap->upc = xml_get_first_item(data, "UPC"); in wps_er_parse_device_description()
593 wpa_printf(MSG_DEBUG, "WPS ER: UPC='%s'", ap->upc); in wps_er_parse_device_description()
595 ap->scpd_url = http_link_update( in wps_er_parse_device_description()
596 xml_get_first_item(data, "SCPDURL"), ap->location); in wps_er_parse_device_description()
597 wpa_printf(MSG_DEBUG, "WPS ER: SCPDURL='%s'", ap->scpd_url); in wps_er_parse_device_description()
599 ap->control_url = http_link_update( in wps_er_parse_device_description()
600 xml_get_first_item(data, "controlURL"), ap->location); in wps_er_parse_device_description()
601 wpa_printf(MSG_DEBUG, "WPS ER: controlURL='%s'", ap->control_url); in wps_er_parse_device_description()
603 ap->event_sub_url = http_link_update( in wps_er_parse_device_description()
604 xml_get_first_item(data, "eventSubURL"), ap->location); in wps_er_parse_device_description()
605 wpa_printf(MSG_DEBUG, "WPS ER: eventSubURL='%s'", ap->event_sub_url); in wps_er_parse_device_description()
612 struct wps_er_ap *ap = ctx; in wps_er_http_dev_desc_cb() local
621 wps_er_parse_device_description(ap, reply); in wps_er_http_dev_desc_cb()
630 http_client_free(ap->http); in wps_er_http_dev_desc_cb()
631 ap->http = NULL; in wps_er_http_dev_desc_cb()
633 wps_er_get_device_info(ap); in wps_er_http_dev_desc_cb()
640 struct wps_er_ap *ap; in wps_er_ap_add() local
642 ap = wps_er_ap_get(er, addr, uuid, NULL); in wps_er_ap_add()
643 if (ap) { in wps_er_ap_add()
645 eloop_cancel_timeout(wps_er_ap_timeout, er, ap); in wps_er_ap_add()
646 eloop_register_timeout(max_age, 0, wps_er_ap_timeout, er, ap); in wps_er_ap_add()
650 ap = os_zalloc(sizeof(*ap)); in wps_er_ap_add()
651 if (ap == NULL) in wps_er_ap_add()
653 dl_list_init(&ap->sta); in wps_er_ap_add()
654 ap->er = er; in wps_er_ap_add()
655 ap->id = ++er->next_ap_id; in wps_er_ap_add()
656 ap->location = os_strdup(location); in wps_er_ap_add()
657 if (ap->location == NULL) { in wps_er_ap_add()
658 os_free(ap); in wps_er_ap_add()
661 dl_list_add(&er->ap, &ap->list); in wps_er_ap_add()
663 ap->addr.s_addr = addr->s_addr; in wps_er_ap_add()
664 os_memcpy(ap->uuid, uuid, WPS_UUID_LEN); in wps_er_ap_add()
665 eloop_register_timeout(max_age, 0, wps_er_ap_timeout, er, ap); in wps_er_ap_add()
668 inet_ntoa(ap->addr), ap->location); in wps_er_ap_add()
671 ap->http = http_client_url(ap->location, NULL, 10000, in wps_er_ap_add()
672 wps_er_http_dev_desc_cb, ap); in wps_er_ap_add()
678 struct wps_er_ap *ap; in wps_er_ap_remove() local
679 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_ap_remove()
680 if (ap->addr.s_addr == addr->s_addr) { in wps_er_ap_remove()
681 wps_er_ap_remove_entry(er, ap); in wps_er_ap_remove()
690 struct wps_er_ap *prev, *ap; in wps_er_ap_remove_all() local
692 dl_list_for_each_safe(ap, prev, &er->ap, struct wps_er_ap, list) in wps_er_ap_remove_all()
693 wps_er_ap_remove_entry(er, ap); in wps_er_ap_remove_all()
756 static struct wps_er_sta * wps_er_add_sta_data(struct wps_er_ap *ap, in wps_er_add_sta_data() argument
761 struct wps_er_sta *sta = wps_er_sta_get(ap, addr, NULL); in wps_er_add_sta_data()
780 sta->ap = ap; in wps_er_add_sta_data()
781 dl_list_add(&ap->sta, &sta->list); in wps_er_add_sta_data()
830 wps_er_sta_event(ap->er->wps, sta, WPS_EV_ER_ENROLLEE_ADD); in wps_er_add_sta_data()
836 static void wps_er_process_wlanevent_probe_req(struct wps_er_ap *ap, in wps_er_process_wlanevent_probe_req() argument
859 wps_er_add_sta_data(ap, addr, &attr, 1); in wps_er_process_wlanevent_probe_req()
860 wps_registrar_probe_req_rx(ap->er->wps->registrar, addr, msg, 0); in wps_er_process_wlanevent_probe_req()
976 if (sta->ap->control_url == NULL) { in wps_er_sta_send_msg()
982 url = http_client_url_parse(sta->ap->control_url, &dst, &path); in wps_er_sta_send_msg()
1043 cfg.wps = sta->ap->er->wps; in wps_er_sta_start()
1051 sta->wps->use_cred = sta->ap->ap_settings; in wps_er_sta_start()
1052 if (sta->ap->ap_settings) { in wps_er_sta_start()
1056 os_memcpy(sta->cred, sta->ap->ap_settings, in wps_er_sta_start()
1068 static void wps_er_process_wlanevent_eap(struct wps_er_ap *ap, const u8 *addr, in wps_er_process_wlanevent_eap() argument
1085 sta = wps_er_add_sta_data(ap, addr, &attr, 0); in wps_er_process_wlanevent_eap()
1111 static void wps_er_process_wlanevent(struct wps_er_ap *ap, in wps_er_process_wlanevent() argument
1138 wps_er_process_wlanevent_probe_req(ap, wlan_event_mac, &msg); in wps_er_process_wlanevent()
1141 wps_er_process_wlanevent_eap(ap, wlan_event_mac, &msg); in wps_er_process_wlanevent()
1154 struct wps_er_ap *ap = wps_er_ap_get_id(er, ap_id); in wps_er_http_event() local
1158 if (ap == NULL) { in wps_er_http_event()
1180 wps_er_process_wlanevent(ap, event); in wps_er_http_event()
1257 dl_list_init(&er->ap); in wps_er_init()
1332 struct wps_er_ap *ap; in wps_er_refresh() local
1335 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_refresh()
1336 wps_er_ap_event(er->wps, ap, WPS_EV_ER_AP_ADD); in wps_er_refresh()
1337 dl_list_for_each(sta, &ap->sta, struct wps_er_sta, list) in wps_er_refresh()
1350 struct wps_er_ap *ap, *tmp; in wps_er_deinit_finish() local
1354 dl_list_for_each_safe(ap, tmp, &er->ap_unsubscribing, struct wps_er_ap, in wps_er_deinit_finish()
1357 inet_ntoa(ap->addr), ap->location); in wps_er_deinit_finish()
1358 dl_list_del(&ap->list); in wps_er_deinit_finish()
1359 wps_er_ap_free(ap); in wps_er_deinit_finish()
1392 struct wps_er_ap *ap = ctx; in wps_er_http_set_sel_reg_cb() local
1401 data.set_sel_reg.uuid = ap->uuid; in wps_er_http_set_sel_reg_cb()
1408 data.set_sel_reg.uuid = ap->uuid; in wps_er_http_set_sel_reg_cb()
1411 http_client_free(ap->http); in wps_er_http_set_sel_reg_cb()
1412 ap->http = NULL; in wps_er_http_set_sel_reg_cb()
1415 ap->er->wps->event_cb(ap->er->wps->cb_ctx, in wps_er_http_set_sel_reg_cb()
1420 static void wps_er_send_set_sel_reg(struct wps_er_ap *ap, struct wpabuf *msg) in wps_er_send_set_sel_reg() argument
1427 if (ap->control_url == NULL) { in wps_er_send_set_sel_reg()
1432 if (ap->http) { in wps_er_send_set_sel_reg()
1438 if (ap->wps) { in wps_er_send_set_sel_reg()
1444 url = http_client_url_parse(ap->control_url, &dst, &path); in wps_er_send_set_sel_reg()
1458 ap->http = http_client_addr(&dst, buf, 1000, in wps_er_send_set_sel_reg()
1459 wps_er_http_set_sel_reg_cb, ap); in wps_er_send_set_sel_reg()
1460 if (ap->http == NULL) in wps_er_send_set_sel_reg()
1506 struct wps_er_ap *ap; in wps_er_set_sel_reg() local
1545 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_set_sel_reg()
1547 os_memcmp(ap->uuid, er->set_sel_reg_uuid_filter, in wps_er_set_sel_reg()
1550 data.set_sel_reg.uuid = ap->uuid; in wps_er_set_sel_reg()
1553 wps_er_send_set_sel_reg(ap, msg); in wps_er_set_sel_reg()
1563 struct wps_er_ap *ap; in wps_er_pbc() local
1575 ap = wps_er_ap_get(er, NULL, uuid, NULL); in wps_er_pbc()
1577 ap = NULL; in wps_er_pbc()
1578 if (ap == NULL) { in wps_er_pbc()
1580 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_pbc()
1581 sta = wps_er_sta_get(ap, addr, uuid); in wps_er_pbc()
1583 uuid = ap->uuid; in wps_er_pbc()
1591 if (ap->ap_settings == NULL) { in wps_er_pbc()
1608 struct wps_er_ap *ap = ctx; in wps_er_ap_settings_cb() local
1612 os_free(ap->ap_settings); in wps_er_ap_settings_cb()
1613 ap->ap_settings = os_malloc(sizeof(*cred)); in wps_er_ap_settings_cb()
1614 if (ap->ap_settings) { in wps_er_ap_settings_cb()
1615 os_memcpy(ap->ap_settings, cred, sizeof(*cred)); in wps_er_ap_settings_cb()
1616 ap->ap_settings->cred_attr = NULL; in wps_er_ap_settings_cb()
1620 data.ap_settings.uuid = ap->uuid; in wps_er_ap_settings_cb()
1622 ap->er->wps->event_cb(ap->er->wps->cb_ctx, WPS_EV_ER_AP_SETTINGS, in wps_er_ap_settings_cb()
1629 struct wps_er_ap *ap; in wps_er_get_sta_uuid() local
1630 dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) { in wps_er_get_sta_uuid()
1632 sta = wps_er_sta_get(ap, addr, NULL); in wps_er_get_sta_uuid()
1643 struct wps_er_ap *ap = ctx; in wps_er_http_put_message_cb() local
1654 if (ap->wps) { in wps_er_http_put_message_cb()
1655 wps_deinit(ap->wps); in wps_er_http_put_message_cb()
1656 ap->wps = NULL; in wps_er_http_put_message_cb()
1666 if (ap->wps) { in wps_er_http_put_message_cb()
1667 wps_deinit(ap->wps); in wps_er_http_put_message_cb()
1668 ap->wps = NULL; in wps_er_http_put_message_cb()
1672 http_client_free(ap->http); in wps_er_http_put_message_cb()
1673 ap->http = NULL; in wps_er_http_put_message_cb()
1683 wps_deinit(ap->wps); in wps_er_http_put_message_cb()
1684 ap->wps = NULL; in wps_er_http_put_message_cb()
1687 wps_er_ap_process(ap, buf); in wps_er_http_put_message_cb()
1693 static void wps_er_ap_put_message(struct wps_er_ap *ap, in wps_er_ap_put_message() argument
1701 if (ap->http) { in wps_er_ap_put_message()
1707 if (ap->control_url == NULL) { in wps_er_ap_put_message()
1712 url = http_client_url_parse(ap->control_url, &dst, &path); in wps_er_ap_put_message()
1726 ap->http = http_client_addr(&dst, buf, 10000, in wps_er_ap_put_message()
1727 wps_er_http_put_message_cb, ap); in wps_er_ap_put_message()
1728 if (ap->http == NULL) { in wps_er_ap_put_message()
1735 if (ap->wps) { in wps_er_ap_put_message()
1736 wps_deinit(ap->wps); in wps_er_ap_put_message()
1737 ap->wps = NULL; in wps_er_ap_put_message()
1742 static void wps_er_ap_process(struct wps_er_ap *ap, struct wpabuf *msg) in wps_er_ap_process() argument
1763 res = wps_process_msg(ap->wps, op_code, msg); in wps_er_ap_process()
1765 struct wpabuf *next = wps_get_msg(ap->wps, &op_code); in wps_er_ap_process()
1767 wps_er_ap_put_message(ap, next); in wps_er_ap_process()
1772 wps_deinit(ap->wps); in wps_er_ap_process()
1773 ap->wps = NULL; in wps_er_ap_process()
1777 wps_deinit(ap->wps); in wps_er_ap_process()
1778 ap->wps = NULL; in wps_er_ap_process()
1782 wps_deinit(ap->wps); in wps_er_ap_process()
1783 ap->wps = NULL; in wps_er_ap_process()
1788 static void wps_er_ap_learn_m1(struct wps_er_ap *ap, struct wpabuf *m1) in wps_er_ap_learn_m1() argument
1792 if (ap->wps) { in wps_er_ap_learn_m1()
1799 cfg.wps = ap->er->wps; in wps_er_ap_learn_m1()
1801 ap->wps = wps_init(&cfg); in wps_er_ap_learn_m1()
1802 if (ap->wps == NULL) in wps_er_ap_learn_m1()
1804 ap->wps->ap_settings_cb = wps_er_ap_settings_cb; in wps_er_ap_learn_m1()
1805 ap->wps->ap_settings_cb_ctx = ap; in wps_er_ap_learn_m1()
1807 wps_er_ap_process(ap, m1); in wps_er_ap_learn_m1()
1811 static void wps_er_ap_learn(struct wps_er_ap *ap, const char *dev_info) in wps_er_ap_learn() argument
1825 ap->m1_handler(ap, info); in wps_er_ap_learn()
1833 struct wps_er_ap *ap = ctx; in wps_er_http_get_dev_info_cb() local
1854 http_client_free(ap->http); in wps_er_http_get_dev_info_cb()
1855 ap->http = NULL; in wps_er_http_get_dev_info_cb()
1858 wps_er_ap_learn(ap, dev_info); in wps_er_http_get_dev_info_cb()
1864 static int wps_er_send_get_device_info(struct wps_er_ap *ap, in wps_er_send_get_device_info() argument
1865 void (*m1_handler)(struct wps_er_ap *ap, in wps_er_send_get_device_info() argument
1873 if (ap->http) { in wps_er_send_get_device_info()
1879 if (ap->control_url == NULL) { in wps_er_send_get_device_info()
1884 url = http_client_url_parse(ap->control_url, &dst, &path); in wps_er_send_get_device_info()
1898 ap->http = http_client_addr(&dst, buf, 10000, in wps_er_send_get_device_info()
1899 wps_er_http_get_dev_info_cb, ap); in wps_er_send_get_device_info()
1900 if (ap->http == NULL) { in wps_er_send_get_device_info()
1905 ap->m1_handler = m1_handler; in wps_er_send_get_device_info()
1914 struct wps_er_ap *ap; in wps_er_learn() local
1919 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_learn()
1920 if (ap == NULL) { in wps_er_learn()
1926 uuid = ap->uuid; in wps_er_learn()
1927 if (ap->wps) { in wps_er_learn()
1933 if (wps_er_send_get_device_info(ap, wps_er_ap_learn_m1) < 0) in wps_er_learn()
1947 struct wps_er_ap *ap; in wps_er_set_config() local
1952 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_set_config()
1953 if (ap == NULL) { in wps_er_set_config()
1959 os_free(ap->ap_settings); in wps_er_set_config()
1960 ap->ap_settings = os_memdup(cred, sizeof(*cred)); in wps_er_set_config()
1961 if (ap->ap_settings == NULL) in wps_er_set_config()
1963 ap->ap_settings->cred_attr = NULL; in wps_er_set_config()
1971 static void wps_er_ap_config_m1(struct wps_er_ap *ap, struct wpabuf *m1) in wps_er_ap_config_m1() argument
1975 if (ap->wps) { in wps_er_ap_config_m1()
1982 cfg.wps = ap->er->wps; in wps_er_ap_config_m1()
1984 cfg.new_ap_settings = ap->ap_settings; in wps_er_ap_config_m1()
1985 ap->wps = wps_init(&cfg); in wps_er_ap_config_m1()
1986 if (ap->wps == NULL) in wps_er_ap_config_m1()
1988 ap->wps->ap_settings_cb = NULL; in wps_er_ap_config_m1()
1989 ap->wps->ap_settings_cb_ctx = NULL; in wps_er_ap_config_m1()
1991 wps_er_ap_process(ap, m1); in wps_er_ap_config_m1()
1999 struct wps_er_ap *ap; in wps_er_config() local
2004 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_config()
2005 if (ap == NULL) { in wps_er_config()
2011 uuid = ap->uuid; in wps_er_config()
2012 if (ap->wps) { in wps_er_config()
2018 os_free(ap->ap_settings); in wps_er_config()
2019 ap->ap_settings = os_memdup(cred, sizeof(*cred)); in wps_er_config()
2020 if (ap->ap_settings == NULL) in wps_er_config()
2022 ap->ap_settings->cred_attr = NULL; in wps_er_config()
2024 if (wps_er_send_get_device_info(ap, wps_er_ap_config_m1) < 0) in wps_er_config()
2063 struct wps_er_ap *ap; in wps_er_nfc_config_token() local
2068 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_nfc_config_token()
2069 if (ap == NULL) in wps_er_nfc_config_token()
2071 if (ap->ap_settings == NULL) { in wps_er_nfc_config_token()
2077 return wps_er_config_token_from_cred(er->wps, ap->ap_settings); in wps_er_nfc_config_token()
2085 struct wps_er_ap *ap; in wps_er_nfc_handover_sel() local
2090 ap = wps_er_ap_get(er, NULL, uuid, addr); in wps_er_nfc_handover_sel()
2091 if (ap == NULL) in wps_er_nfc_handover_sel()
2093 if (ap->ap_settings == NULL) { in wps_er_nfc_handover_sel()
2099 os_memcpy(wps->ssid, ap->ap_settings->ssid, ap->ap_settings->ssid_len); in wps_er_nfc_handover_sel()
2100 wps->ssid_len = ap->ap_settings->ssid_len; in wps_er_nfc_handover_sel()