static int hostapd_wps_upnp_init(struct hostapd_data *hapd, struct wps_context *wps) { struct upnp_wps_device_ctx *ctx; if (!hapd->conf->upnp_iface) return 0; ctx = os_zalloc(sizeof(*ctx)); if (ctx == NULL) return -1; ctx->rx_req_put_wlan_response = hostapd_rx_req_put_wlan_response; if (hapd->conf->ap_pin) ctx->ap_pin = os_strdup(hapd->conf->ap_pin); hapd->wps_upnp = upnp_wps_device_init(ctx, wps, hapd); if (hapd->wps_upnp == NULL) { os_free(ctx); return -1; } wps->wps_upnp = hapd->wps_upnp; if (upnp_wps_device_start(hapd->wps_upnp, hapd->conf->upnp_iface)) { upnp_wps_device_deinit(hapd->wps_upnp); hapd->wps_upnp = NULL; return -1; } return 0; }
static int hostapd_wps_upnp_init(struct hostapd_data *hapd, struct wps_context *wps) { struct upnp_wps_device_ctx *ctx; if (!hapd->conf->upnp_iface) return 0; ctx = os_zalloc(sizeof(*ctx)); if (ctx == NULL) return -1; ctx->rx_req_get_device_info = hostapd_rx_req_get_device_info; ctx->rx_req_put_message = hostapd_rx_req_put_message; ctx->rx_req_get_ap_settings = hostapd_rx_req_get_ap_settings; ctx->rx_req_set_ap_settings = hostapd_rx_req_set_ap_settings; ctx->rx_req_del_ap_settings = hostapd_rx_req_del_ap_settings; ctx->rx_req_get_sta_settings = hostapd_rx_req_get_sta_settings; ctx->rx_req_set_sta_settings = hostapd_rx_req_set_sta_settings; ctx->rx_req_del_sta_settings = hostapd_rx_req_del_sta_settings; ctx->rx_req_put_wlan_response = hostapd_rx_req_put_wlan_response; ctx->rx_req_set_selected_registrar = hostapd_rx_req_set_selected_registrar; ctx->rx_req_reboot_ap = hostapd_rx_req_reboot_ap; ctx->rx_req_reset_ap = hostapd_rx_req_reset_ap; ctx->rx_req_reboot_sta = hostapd_rx_req_reboot_sta; ctx->rx_req_reset_sta = hostapd_rx_req_reset_sta; hapd->wps_upnp = upnp_wps_device_init(ctx, wps, hapd); if (hapd->wps_upnp == NULL) { os_free(ctx); return -1; } wps->wps_upnp = hapd->wps_upnp; if (upnp_wps_device_start(hapd->wps_upnp, hapd->conf->upnp_iface)) { upnp_wps_device_deinit(hapd->wps_upnp); hapd->wps_upnp = NULL; return -1; } return 0; }