]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Allow SSIDs with non printable characters to be used in ssid selection in
authorRoy Marples <roy@marples.name>
Wed, 10 Sep 2014 10:00:08 +0000 (10:00 +0000)
committerRoy Marples <roy@marples.name>
Wed, 10 Sep 2014 10:00:08 +0000 (10:00 +0000)
dhcpcd.conf and generate more accurate stable private addresses.

dhcpcd.c
dhcpcd.h
if-bsd.c
if-linux-wext.c
if-linux.c
ipv6.c

index dd684147df432fe8c013477e92af8580d020f946..8dbebd7a4b08bd8f9a43b29d8bac0d8bbdbcb252 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -489,8 +489,18 @@ int
 dhcpcd_selectprofile(struct interface *ifp, const char *profile)
 {
        struct if_options *ifo;
-
-       ifo = read_config(ifp->ctx, ifp->name, ifp->ssid, profile);
+       char pssid[PROFILE_LEN];
+
+       if (ifp->ssid_len) {
+               ssize_t r;
+               r =print_string(pssid, sizeof(pssid), ifp->ssid, ifp->ssid_len);
+               if (r == -1) {
+                       syslog(LOG_ERR, "%s: %s: %m", ifp->name, __func__);
+                       pssid[0] = '\0';
+               }
+       } else
+               pssid[0] = '\0';
+       ifo = read_config(ifp->ctx, ifp->name, pssid, profile);
        if (ifo == NULL) {
                syslog(LOG_DEBUG, "%s: no profile %s", ifp->name, profile);
                return -1;
index cedab5fb480e285da47a94e912d620a5c7eddc53..4b6624b97c36ce05acb56c4f5565a828d945a89d 100644 (file)
--- a/dhcpcd.h
+++ b/dhcpcd.h
@@ -64,7 +64,7 @@ struct interface {
        unsigned int metric;
        int carrier;
        int wireless;
-       char ssid[IF_SSIDSIZE];
+       uint8_t ssid[IF_SSIDSIZE];
        unsigned int ssid_len;
 
        char profile[PROFILE_LEN];
index 455665fb40a9b5a54363676f9915a25c5576e7f5..6c16a5eb08528d42a3c00b4e6a8e76419dfc282f 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -138,7 +138,7 @@ if_openlinksocket(void)
 }
 
 static int
-if_getssid1(const char *ifname, char *ssid)
+if_getssid1(const char *ifname, uint8_t *ssid)
 {
        int s, retval = -1;
 #if defined(SIOCG80211NWID)
index 117eb1a571691c85005c401b3a03b022ab7d473f..d4050cb48585739996d02644f8ff2ce4804bb547 100644 (file)
 /* We can't include if.h or dhcpcd.h because
  * they would pull in net/if.h, which defeats the purpose of this hack. */
 #define IF_SSIDSIZE 33
-int if_getssid_wext(const char *ifname, char *ssid);
+int if_getssid_wext(const char *ifname, uint8_t *ssid);
 
 int
-if_getssid_wext(const char *ifname, char *ssid)
+if_getssid_wext(const char *ifname, uint8_t *ssid)
 {
 #ifdef SIOCGIWESSID
        int s, retval;
index 246f253296bc47d403d59d425819d245f49e88fc..f326ed11962a33271d857d10c7e9897b1dc46f5f 100644 (file)
@@ -87,7 +87,7 @@
 #include <linux/genetlink.h>
 #include <linux/nl80211.h>
 #else
-int if_getssid_wext(const char *ifname, char *ssid);
+int if_getssid_wext(const char *ifname, uint8_t *ssid);
 #endif
 
 #define bpf_insn               sock_filter
@@ -933,7 +933,7 @@ gnl_getfamily(struct dhcpcd_ctx *ctx, const char *name)
        nlm.ghdr.version = 1;
        if (nla_put_string(&nlm.hdr, sizeof(nlm), CTRL_ATTR_FAMILY_NAME, name)
            == -1)
-               return -1;
+               return -1;
        return send_netlink(ctx, NULL, NETLINK_GENERIC, &nlm.hdr,
            &_gnl_getfamily);
 }
@@ -977,7 +977,7 @@ if_getssid(struct interface *ifp)
        nlm.hdr.nlmsg_flags = NLM_F_REQUEST;
        nlm.ghdr.cmd = NL80211_CMD_GET_INTERFACE;
        nla_put_32(&nlm.hdr, sizeof(nlm), NL80211_ATTR_IFINDEX, ifp->index);
-       
+
        return send_netlink(ifp->ctx, ifp, NETLINK_GENERIC, &nlm.hdr,
            &_if_getssid);
 }
@@ -1453,7 +1453,7 @@ static struct rtattr *
 add_attr_nest(struct nlmsghdr *n, unsigned short maxlen, unsigned short type)
 {
        struct rtattr *nest;
-       
+
        nest = NLMSG_TAIL(n);
        add_attr_l(n, maxlen, type, NULL, 0);
        return nest;
@@ -1484,7 +1484,7 @@ if_disable_autolinklocal(struct dhcpcd_ctx *ctx, const char *ifname)
            IN6_ADDR_GEN_MODE_NONE);
        add_attr_nest_end(&nlm.hdr, afs6);
        add_attr_nest_end(&nlm.hdr, afs);
-       
+
        return send_netlink(ctx, NULL, NETLINK_ROUTE, &nlm.hdr, NULL);
 }
 
diff --git a/ipv6.c b/ipv6.c
index 3bf4bc05b4261d90a4c3bfcdc2b7ad418ad177fd..5986a18a84024fc35fb14d395a9e51066989cd5d 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -301,7 +301,7 @@ static int
 ipv6_makestableprivate1(struct in6_addr *addr,
     const struct in6_addr *prefix, int prefix_len,
     const unsigned char *netiface, size_t netiface_len,
-    const char *netid, size_t netid_len,
+    const unsigned char *netid, size_t netid_len,
     uint32_t *dad_counter,
     const unsigned char *secret, size_t secret_len)
 {
@@ -376,7 +376,7 @@ ipv6_makestableprivate(struct in6_addr *addr,
         * as the interface identifier */
        r = ipv6_makestableprivate1(addr, prefix, prefix_len,
            ifp->hwaddr, ifp->hwlen,
-           ifp->ssid, strlen(ifp->ssid),
+           ifp->ssid, ifp->ssid_len,
            &dad,
            ifp->ctx->secret, ifp->ctx->secret_len);