}
-static int str_starts(const char *str, const char *start)
-{
- return os_strncmp(str, start, os_strlen(start)) == 0;
-}
-
-
/***************************************************************************
* Advertisements.
* These are multicast to the world to tell them we are here.
*islast = 0;
iface = dl_list_first(&sm->interfaces,
struct upnp_wps_device_interface, list);
+ if (!iface)
+ return NULL;
uuid_bin2str(iface->wps->uuid, uuid_string, sizeof(uuid_string));
msg = wpabuf_alloc(800); /* more than big enough */
if (msg == NULL)
- goto fail;
+ return NULL;
switch (a->type) {
case ADVERTISE_UP:
case ADVERTISE_DOWN:
*islast = 1;
return msg;
-
-fail:
- wpabuf_free(msg);
- return NULL;
}
* (see notes above)
*/
next_timeout_msec = 0;
- os_get_random((void *) &r, sizeof(r));
+ if (os_get_random((void *) &r, sizeof(r)) < 0)
+ r = 32768;
next_timeout_sec = UPNP_CACHE_SEC / 4 +
(((UPNP_CACHE_SEC / 4) * r) >> 16);
sm->advertise_count++;
&sm->interfaces,
struct upnp_wps_device_interface,
list);
+ if (!iface)
+ continue;
data += os_strlen("uuid:");
uuid_bin2str(iface->wps->uuid, uuid_string,
sizeof(uuid_string));
int sd;
sd = socket(AF_INET, SOCK_DGRAM, 0);
- if (sd < 0)
- goto fail;
- if (fcntl(sd, F_SETFL, O_NONBLOCK) != 0)
- goto fail;
- if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
+ if (sd < 0 ||
+ fcntl(sd, F_SETFL, O_NONBLOCK) != 0 ||
+ setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
goto fail;
os_memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
mcast_addr.imr_interface.s_addr = htonl(INADDR_ANY);
mcast_addr.imr_multiaddr.s_addr = inet_addr(UPNP_MULTICAST_ADDRESS);
if (setsockopt(sd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
- (char *) &mcast_addr, sizeof(mcast_addr)))
- goto fail;
- if (setsockopt(sd, IPPROTO_IP, IP_MULTICAST_TTL,
+ (char *) &mcast_addr, sizeof(mcast_addr)) ||
+ setsockopt(sd, IPPROTO_IP, IP_MULTICAST_TTL,
&ttl, sizeof(ttl)))
goto fail;