Hi,

with this diff,

  ifconfig <if> join

will print the list of networks that are configured for autojoin.

$ ifconfig iwm0 join 
iwm0: flags=208843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6> mtu 1500
        lladdr a4:7f:da:a4:d7:c1
        index 1 priority 4 llprio 3
        groups: wlan egress
        media: IEEE802.11 autoselect (HT-MCS12 mode 11n)
        status: active
        ieee80211: join fn0rd chan 6 bssid 62:62:b5:d3:56:a7 62% wpakey 
wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
        join:   gesamtkunstwerk
                fn0rd
                Gaeste
                WLAN


comments? oks?

(benno_join_list_5.diff)

diff --git sbin/ifconfig/ifconfig.c sbin/ifconfig/ifconfig.c
index 9bfb1751aab..de6aabf4fba 100644
--- sbin/ifconfig/ifconfig.c
+++ sbin/ifconfig/ifconfig.c
@@ -163,6 +163,7 @@ int newaddr = 0;
 int    af = AF_INET;
 int    explicit_prefix = 0;
 int    Lflag = 1;
+int    show_join = 0;
 
 int    showmediaflag;
 int    showcapsflag;
@@ -633,6 +634,7 @@ void        in6_status(int);
 void   in6_getaddr(const char *, int);
 void   in6_getprefix(const char *, int);
 void   ieee80211_status(void);
+void   join_status(void);
 void   ieee80211_listchans(void);
 void   ieee80211_listnodes(void);
 void   ieee80211_printnode(struct ieee80211_nodereq *);
@@ -1656,7 +1658,7 @@ setifjoin(const char *val, int d)
        int len;
 
        if (val == NULL) {
-               /* TODO: display the list of join'd networks */
+               show_join = 1;
                return;
        }
 
@@ -2292,14 +2294,68 @@ ieee80211_status(void)
                putchar(' ');
                printb_status(ifr.ifr_flags, IEEE80211_F_USERBITS);
        }
-
        putchar('\n');
+       if (show_join)
+               join_status();
        if (shownet80211chans)
                ieee80211_listchans();
        else if (shownet80211nodes)
                ieee80211_listnodes();
 }
 
+void
+join_status(void)
+{
+       struct ieee80211_joinreq_all ja;
+       struct ieee80211_join *jn = NULL;
+       int jsz = IEEE80211_CACHE_SIZE;
+       int ojsz;
+       int i;
+       int r;
+
+       bzero(&ja, sizeof(ja));
+       jn = recallocarray(NULL, 0, jsz, sizeof(*jn));
+       if (jn == NULL)
+               err(1, "recallocarray");
+       ojsz = jsz;
+       while (1) {
+               ja.ja_node = jn;
+               ja.ja_size = jsz * sizeof(*jn);
+               strlcpy(ja.ja_ifname, name, sizeof(ja.ja_ifname));
+               
+               if ((r = ioctl(s, SIOCG80211JOINALL, &ja)) != 0) {
+                       if (errno == E2BIG) {
+                               jsz += IEEE80211_CACHE_SIZE;
+                               if (jsz > 10*IEEE80211_CACHE_SIZE) {
+                                       warn("SIOCG80211JOINALL");
+                                       return;
+                               }
+                               jn = recallocarray(jn, ojsz, jsz, sizeof(*jn));
+                               if (jn == NULL)
+                                       err(1, "recallocarray");
+                               ojsz = jsz;
+                               continue;
+                       } else if (errno != ENOENT)
+                               warn("SIOCG80211JOINALL");
+                       return;
+               }
+               break;
+       }
+
+       if (!ja.ja_nodes)
+               return;
+
+       fputs("\tjoin:\t", stdout);
+       for (i = 0; i < ja.ja_nodes; i++) {
+               if (i > 0)
+                       printf("\t\t");
+               if (jn[i].i_len > IEEE80211_NWID_LEN)
+                       jn[i].i_len = IEEE80211_NWID_LEN;
+               print_string(jn[i].i_nwid, jn[i].i_len);
+               putchar('\n');
+       }
+}
+
 void
 ieee80211_listchans(void)
 {
diff --git sys/net80211/ieee80211.h sys/net80211/ieee80211.h
index d7be80a4562..b02cb7924d3 100644
--- sys/net80211/ieee80211.h
+++ sys/net80211/ieee80211.h
@@ -1023,4 +1023,6 @@ enum ieee80211_htprot {
        IEEE80211_HTPROT_NONHT_MIXED    /* non-HT STA associated to our BSS */
 };
 
+#define        IEEE80211_CACHE_SIZE    100
+
 #endif /* _NET80211_IEEE80211_H_ */
diff --git sys/net80211/ieee80211_ioctl.c sys/net80211/ieee80211_ioctl.c
index 4d6b7eb1b71..b41b4fe09d8 100644
--- sys/net80211/ieee80211_ioctl.c
+++ sys/net80211/ieee80211_ioctl.c
@@ -391,8 +391,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t 
data)
        struct ieee80211com *ic = (void *)ifp;
        struct ifreq *ifr = (struct ifreq *)data;
        int i, error = 0;
+       size_t len;
        struct ieee80211_nwid nwid;
        struct ieee80211_join join;
+       struct ieee80211_joinreq_all *ja;
        struct ieee80211_ess *ess;
        struct ieee80211_wpapsk *psk;
        struct ieee80211_keyavail *ka;
@@ -488,6 +490,26 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t 
data)
                        }
                }
                break;
+       case SIOCG80211JOINALL:
+               ja = (struct ieee80211_joinreq_all *)data;
+               ja->ja_nodes = len = 0;
+               TAILQ_FOREACH(ess, &ic->ic_ess, ess_next) {
+                       if (len + sizeof(struct ieee80211_nodereq) >=
+                           ja->ja_size) {
+                               error = E2BIG;
+                               break;
+                       }
+                       memset(&join, 0, sizeof(struct ieee80211_join));
+                       join.i_len = ess->esslen;
+                       memcpy(&join.i_nwid, ess->essid, join.i_len);
+                       error = copyout(&join, &ja->ja_node[ja->ja_nodes],
+                           sizeof(struct ieee80211_nodereq));
+                       if (error)
+                               break;
+                       len += sizeof(struct ieee80211_join);
+                       ja->ja_nodes++;
+               }
+               break;
        case SIOCS80211NWKEY:
                if ((error = suser(curproc)) != 0)
                        break;
diff --git sys/net80211/ieee80211_ioctl.h sys/net80211/ieee80211_ioctl.h
index 9ea74127b22..ea19d8a9550 100644
--- sys/net80211/ieee80211_ioctl.h
+++ sys/net80211/ieee80211_ioctl.h
@@ -275,6 +275,7 @@ struct ieee80211_keyrun {
 
 #define SIOCS80211SCAN          _IOW('i', 210, struct ifreq)
 
+#define        SIOCG80211JOINALL       _IOWR('i', 218, struct 
ieee80211_joinreq_all)
 #define        SIOCS80211JOIN          _IOWR('i', 255, struct ifreq)
 #define        SIOCG80211JOIN          _IOWR('i', 256, struct ifreq)
 
@@ -288,6 +289,14 @@ struct ieee80211_join {
        struct ieee80211_nwkey  i_nwkey;
 };
 
+struct ieee80211_joinreq_all {
+       char                     ja_ifname[IFNAMSIZ];
+       int                      ja_nodes; /* returned count */
+       size_t                   ja_size;  /* size of node buffer */
+       struct ieee80211_join   *ja_node;  /* allocated node buffer */
+};
+
+
 #define IEEE80211_JOIN_SHOW    0x01
 #define IEEE80211_JOIN_FOUND   0x02
 #define IEEE80211_JOIN_DEL     0x04
diff --git sys/net80211/ieee80211_node.h sys/net80211/ieee80211_node.h
index 882df583190..afd9b4ce438 100644
--- sys/net80211/ieee80211_node.h
+++ sys/net80211/ieee80211_node.h
@@ -39,7 +39,7 @@
 #define        IEEE80211_TRANS_WAIT    5               /* transition wait */
 #define        IEEE80211_INACT_WAIT    5               /* inactivity timer 
interval */
 #define        IEEE80211_INACT_MAX     (300/IEEE80211_INACT_WAIT)
-#define        IEEE80211_CACHE_SIZE    100
+
 #define        IEEE80211_CACHE_WAIT    30
 
 struct ieee80211_rateset {

Reply via email to