diff --git a/src/wps/wps_er.c b/src/wps/wps_er.c index 3eed6e9f4..45de1618c 100644 --- a/src/wps/wps_er.c +++ b/src/wps/wps_er.c @@ -1156,9 +1156,8 @@ wps_er_init(struct wps_context *wps, const char *ifname) er->wps = wps; os_get_random((unsigned char *) &er->event_id, sizeof(er->event_id)); - if (get_netif_info(ifname, - &er->ip_addr, &er->ip_addr_text, - er->mac_addr, &er->mac_addr_text)) { + if (get_netif_info(ifname, &er->ip_addr, &er->ip_addr_text, + er->mac_addr)) { wpa_printf(MSG_INFO, "WPS UPnP: Could not get IP/MAC address " "for %s. Does it have IP address?", ifname); wps_er_deinit(er, NULL, NULL); @@ -1178,9 +1177,8 @@ wps_er_init(struct wps_context *wps, const char *ifname) } er->http_port = http_server_get_port(er->http_srv); - wpa_printf(MSG_DEBUG, "WPS ER: Start (ifname=%s ip_addr=%s " - "mac_addr=%s)", - er->ifname, er->ip_addr_text, er->mac_addr_text); + wpa_printf(MSG_DEBUG, "WPS ER: Start (ifname=%s ip_addr=%s)", + er->ifname, er->ip_addr_text); return er; } @@ -1212,7 +1210,6 @@ static void wps_er_deinit_finish(void *eloop_data, void *user_ctx) deinit_done_cb = er->deinit_done_cb; deinit_done_ctx = er->deinit_done_ctx; os_free(er->ip_addr_text); - os_free(er->mac_addr_text); os_free(er); if (deinit_done_cb) diff --git a/src/wps/wps_er.h b/src/wps/wps_er.h index 7719b7dad..f08af913b 100644 --- a/src/wps/wps_er.h +++ b/src/wps/wps_er.h @@ -75,7 +75,6 @@ struct wps_er_ap { struct wps_er { struct wps_context *wps; char ifname[17]; - char *mac_addr_text; /* mac addr of network i.f. we use */ u8 mac_addr[ETH_ALEN]; /* mac addr of network i.f. we use */ char *ip_addr_text; /* IP address of network i.f. we use */ unsigned ip_addr; /* IP address of network i.f. we use (host order) */ diff --git a/src/wps/wps_upnp.c b/src/wps/wps_upnp.c index 705e6aaa0..c6ca3fee6 100644 --- a/src/wps/wps_upnp.c +++ b/src/wps/wps_upnp.c @@ -844,11 +844,10 @@ static int eth_get(const char *device, u8 ea[ETH_ALEN]) * @ip_addr: Buffer for returning IP address in network byte order * @ip_addr_text: Buffer for returning a pointer to allocated IP address text * @mac: Buffer for returning MAC address - * @mac_addr_text: Buffer for returning allocated MAC address text * Returns: 0 on success, -1 on failure */ int get_netif_info(const char *net_if, unsigned *ip_addr, char **ip_addr_text, - u8 mac[ETH_ALEN], char **mac_addr_text) + u8 mac[ETH_ALEN]) { struct ifreq req; int sock = -1; @@ -856,8 +855,7 @@ int get_netif_info(const char *net_if, unsigned *ip_addr, char **ip_addr_text, struct in_addr in_addr; *ip_addr_text = os_zalloc(16); - *mac_addr_text = os_zalloc(18); - if (*ip_addr_text == NULL || *mac_addr_text == NULL) + if (*ip_addr_text == NULL) goto fail; sock = socket(AF_INET, SOCK_DGRAM, 0); @@ -891,7 +889,6 @@ int get_netif_info(const char *net_if, unsigned *ip_addr, char **ip_addr_text, #else #error MAC address fetch not implemented #endif - os_snprintf(*mac_addr_text, 18, MACSTR, MAC2STR(mac)); close(sock); return 0; @@ -901,8 +898,6 @@ fail: close(sock); os_free(*ip_addr_text); *ip_addr_text = NULL; - os_free(*mac_addr_text); - *mac_addr_text = NULL; return -1; } @@ -945,8 +940,6 @@ void upnp_wps_device_stop(struct upnp_wps_device_sm *sm) event_send_stop_all(sm); os_free(sm->wlanevent); sm->wlanevent = NULL; - os_free(sm->mac_addr_text); - sm->mac_addr_text = NULL; os_free(sm->ip_addr_text); sm->ip_addr_text = NULL; if (sm->multicast_sd >= 0) @@ -982,9 +975,8 @@ int upnp_wps_device_start(struct upnp_wps_device_sm *sm, char *net_if) goto fail; /* Determine which IP and mac address we're using */ - if (get_netif_info(net_if, - &sm->ip_addr, &sm->ip_addr_text, - sm->mac_addr, &sm->mac_addr_text)) { + if (get_netif_info(net_if, &sm->ip_addr, &sm->ip_addr_text, + sm->mac_addr)) { wpa_printf(MSG_INFO, "WPS UPnP: Could not get IP/MAC address " "for %s. Does it have IP address?", net_if); goto fail; diff --git a/src/wps/wps_upnp_i.h b/src/wps/wps_upnp_i.h index 904ff8a92..b31875ac9 100644 --- a/src/wps/wps_upnp_i.h +++ b/src/wps/wps_upnp_i.h @@ -113,7 +113,6 @@ struct upnp_wps_device_sm { char *root_dir; char *desc_url; int started; /* nonzero if we are active */ - char *mac_addr_text; /* mac addr of network i.f. we use */ u8 mac_addr[ETH_ALEN]; /* mac addr of network i.f. we use */ char *ip_addr_text; /* IP address of network i.f. we use */ unsigned ip_addr; /* IP address of network i.f. we use (host order) */ @@ -147,7 +146,7 @@ struct subscription * subscription_find(struct upnp_wps_device_sm *sm, const u8 uuid[UUID_LEN]); int send_wpabuf(int fd, struct wpabuf *buf); int get_netif_info(const char *net_if, unsigned *ip_addr, char **ip_addr_text, - u8 mac[ETH_ALEN], char **mac_addr_text); + u8 mac[ETH_ALEN]); /* wps_upnp_ssdp.c */ void msearchreply_state_machine_stop(struct advertisement_state_machine *a);