-/* $OpenBSD: ifconfig.c,v 1.369 2018/07/13 08:41:32 krw Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.370 2018/08/06 11:42:18 benno Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
int af = AF_INET;
int explicit_prefix = 0;
int Lflag = 1;
+int show_join = 0;
int showmediaflag;
int showcapsflag;
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 *);
int len;
if (val == NULL) {
- /* TODO: display the list of join'd networks */
+ show_join = 1;
return;
}
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 = 100;
+ 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 += 100;
+ 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)
{
-/* $OpenBSD: ieee80211_ioctl.c,v 1.62 2018/08/06 11:28:01 stsp Exp $ */
+/* $OpenBSD: ieee80211_ioctl.c,v 1.63 2018/08/06 11:42:18 benno Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */
/*-
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;
}
}
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(ja->ja_node[0]) >= ja->ja_size) {
+ error = E2BIG;
+ break;
+ }
+ memset(&join, 0, sizeof(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(ja->ja_node[0]));
+ if (error)
+ break;
+ len += sizeof(join);
+ ja->ja_nodes++;
+ }
+ break;
case SIOCS80211NWKEY:
if ((error = suser(curproc)) != 0)
break;
-/* $OpenBSD: ieee80211_ioctl.h,v 1.32 2018/07/11 20:18:09 phessler Exp $ */
+/* $OpenBSD: ieee80211_ioctl.h,v 1.33 2018/08/06 11:42:18 benno Exp $ */
/* $NetBSD: ieee80211_ioctl.h,v 1.7 2004/04/30 22:51:04 dyoung Exp $ */
/*-
#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)
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