From: Roy Marples Date: Thu, 22 Jan 2009 22:52:41 +0000 (+0000) Subject: Report the fact we're wireless and our ssid X-Git-Tag: v5.0.0~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf91047e8fabb1fd4d9a756b1d95ab0cb96773a5;p=thirdparty%2Fdhcpcd.git Report the fact we're wireless and our ssid --- diff --git a/configure.c b/configure.c index 8e69a1d3..fbc8fafc 100644 --- a/configure.c +++ b/configure.c @@ -167,7 +167,9 @@ make_env(const struct interface *iface, char ***argv) const struct interface *ifp; /* Make our env */ - elen = 5; + elen = 6; + if (iface->wireless) + elen++; env = xmalloc(sizeof(char *) * (elen + 1)); e = strlen("interface") + strlen(iface->name) + 2; env[0] = xmalloc(e); @@ -180,10 +182,12 @@ make_env(const struct interface *iface, char ***argv) snprintf(env[2], e, "pid=%d", getpid()); env[3] = xmalloc(e); snprintf(env[3], e, "metric=%d", iface->metric); + env[4] = xmalloc(e); + snprintf(env[4], e, "wireless=%d", iface->wireless); l = e = strlen("interface_order="); for (ifp = ifaces; ifp; ifp = ifp->next) e += strlen(ifp->name) + 1; - p = env[4] = xmalloc(e); + p = env[5] = xmalloc(e); strlcpy(p, "interface_order=", e); e -= l; p += l; @@ -195,6 +199,11 @@ make_env(const struct interface *iface, char ***argv) e--; } *--p = '\0'; + if (iface->wireless) { + e = strlen("ssid=") + strlen(iface->ssid) + 2; + env[6] = xmalloc(e); + snprintf(env[6], e, "ssid=%s", iface->ssid); + } if (iface->state->old) { e = configure_env(NULL, NULL, iface->state->old, ifo); if (e > 0) { diff --git a/dhcpcd.h b/dhcpcd.h index b5968e26..085550e8 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -88,6 +88,7 @@ struct interface int metric; int carrier; int arpable; + int wireless; char ssid[IF_SSIDSIZE]; int raw_fd; diff --git a/net.c b/net.c index ed580cc5..18cf53bb 100644 --- a/net.c +++ b/net.c @@ -196,8 +196,10 @@ init_interface(const char *ifname) /* We reserve the 100 range for virtual interfaces, if and when * we can work them out. */ iface->metric = 200 + if_nametoindex(iface->name); - if (getifssid(ifname, iface->ssid) != -1) + if (getifssid(ifname, iface->ssid) != -1) { + iface->wireless = 1; iface->metric += 100; + } #ifdef SIOCGIFHWADDR strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));