]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Report the fact we're wireless and our ssid
authorRoy Marples <roy@marples.name>
Thu, 22 Jan 2009 22:52:41 +0000 (22:52 +0000)
committerRoy Marples <roy@marples.name>
Thu, 22 Jan 2009 22:52:41 +0000 (22:52 +0000)
configure.c
dhcpcd.h
net.c

index 8e69a1d36efaa913ed05b25f7dfd08be3a0efb74..fbc8fafc7c3b9ef61fc4fb756d452956ce56f18a 100644 (file)
@@ -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) {
index b5968e26926abe893a1aeb914305650d6f6aa550..085550e8d7e22dd5304c812b264df3f3abc324f0 100644 (file)
--- 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 ed580cc55beb9b2ac8cf7f6a2a7a1c2ea16dde8d..18cf53bbf373915e687a4d9d4e15b24d6664dc07 100644 (file)
--- 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));