diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2018-11-12 16:36:55 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2018-11-12 16:36:55 +0000 |
commit | 587e788b0507cd998e5837c0ce96dcc64a3a85a7 (patch) | |
tree | 83e0b4b100c2ab293894ac7c2df3ec194b22f12b /sys | |
parent | 427fb677906e634c82163da5d7ccae2c3d749cc1 (diff) |
Add new routing socket message RTM_80211INFO to provide details of
802.11 interface state changes (e.g. SSID) to interested parties.
Original diff from phessler@. Many suggestions and tweaks from
claudio@, stsp@, anton@.
ok claudio@ stsp@ anton@ phessler@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.h | 23 | ||||
-rw-r--r-- | sys/net/route.h | 5 | ||||
-rw-r--r-- | sys/net/rtsock.c | 29 | ||||
-rw-r--r-- | sys/net80211/ieee80211_proto.c | 17 |
4 files changed, 70 insertions, 4 deletions
diff --git a/sys/net/if.h b/sys/net/if.h index 0d28a126605..c6f95de04ad 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.196 2018/11/11 05:55:10 dlg Exp $ */ +/* $OpenBSD: if.h,v 1.197 2018/11/12 16:36:54 krw Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -322,6 +322,27 @@ struct if_announcemsghdr { #define IFAN_ARRIVAL 0 /* interface arrival */ #define IFAN_DEPARTURE 1 /* interface departure */ +/* message format used to pass 80211 interface info */ +struct if_ieee80211_data { + uint8_t ifie_channel; /* IEEE80211_CHAN_MAX == 255 */ + uint8_t ifie_nwid_len; + uint32_t ifie_flags; /* ieee80211com.ic_flags */ + uint32_t ifie_xflags; /* ieee80211com.ic xflags */ + uint8_t ifie_nwid[32]; /* IEEE80211_NWID_LEN */ + uint8_t ifie_addr[6]; /* IEEE80211_ADDR_LEN */ +}; + +struct if_ieee80211_msghdr { + uint16_t ifim_msglen; + uint8_t ifim_version; + uint8_t ifim_type; + uint16_t ifim_hdrlen; + uint16_t ifim_index; + uint16_t ifim_tableid; + + struct if_ieee80211_data ifim_ifie; +}; + /* message format used to pass interface name to index mappings */ struct if_nameindex_msg { unsigned int if_index; diff --git a/sys/net/route.h b/sys/net/route.h index 6643dd71dfb..b145964dc55 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.172 2018/07/12 16:07:35 florian Exp $ */ +/* $OpenBSD: route.h,v 1.173 2018/11/12 16:36:54 krw Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -241,6 +241,7 @@ struct rt_msghdr { #define RTM_BFD 0x12 /* bidirectional forwarding detection */ #define RTM_PROPOSAL 0x13 /* proposal for netconfigd */ #define RTM_CHGADDRATTR 0x14 /* address attribute change */ +#define RTM_80211INFO 0x15 /* 80211 iface change */ #define RTV_MTU 0x1 /* init or lock _mtu */ #define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ @@ -417,12 +418,14 @@ struct mbuf; struct socket; struct ifnet; struct sockaddr_in6; +struct if_ieee80211_data; struct bfd_config; void route_init(void); void rtm_ifchg(struct ifnet *); void rtm_ifannounce(struct ifnet *, int); void rtm_bfd(struct bfd_config *); +void rtm_80211info(struct ifnet *, struct if_ieee80211_data *); void rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *); struct sockaddr *rt_plen2mask(struct rtentry *, struct sockaddr_in6 *); diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index cfd2856dc47..66f1c8c170b 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.279 2018/07/10 20:28:34 claudio Exp $ */ +/* $OpenBSD: rtsock.c,v 1.280 2018/11/12 16:36:54 krw Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -522,6 +522,7 @@ next: case RTM_NEWADDR: case RTM_DELADDR: case RTM_IFINFO: + case RTM_80211INFO: case RTM_BFD: /* check against rdomain id */ if (rop->rop_rtableid != RTABLE_ANY && @@ -1378,6 +1379,9 @@ rtm_msg1(int type, struct rt_addrinfo *rtinfo) len = sizeof(struct bfd_msghdr); break; #endif + case RTM_80211INFO: + len = sizeof(struct if_ieee80211_msghdr); + break; default: len = sizeof(struct rt_msghdr); break; @@ -1658,6 +1662,29 @@ rtm_bfd(struct bfd_config *bfd) #endif /* BFD */ /* + * This is used to generate routing socket messages indicating + * the state of an ieee80211 interface. + */ +void +rtm_80211info(struct ifnet *ifp, struct if_ieee80211_data *ifie) +{ + struct if_ieee80211_msghdr *ifim; + struct mbuf *m; + + if (rtptable.rtp_count == 0) + return; + m = rtm_msg1(RTM_80211INFO, NULL); + if (m == NULL) + return; + ifim = mtod(m, struct if_ieee80211_msghdr *); + ifim->ifim_index = ifp->if_index; + ifim->ifim_tableid = ifp->if_rdomain; + + memcpy(&ifim->ifim_ifie, ifie, sizeof(ifim->ifim_ifie)); + route_input(m, NULL, AF_UNSPEC); +} + +/* * This is used in dumping the kernel table via sysctl(). */ int diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index c6bea58320d..a3ed1a2c299 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_proto.c,v 1.90 2018/09/11 10:23:40 krw Exp $ */ +/* $OpenBSD: ieee80211_proto.c,v 1.91 2018/11/12 16:36:54 krw Exp $ */ /* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */ /*- @@ -48,6 +48,7 @@ #include <net/if_dl.h> #include <net/if_media.h> #include <net/if_llc.h> +#include <net/route.h> #include <netinet/in.h> #include <netinet/if_ether.h> @@ -1198,6 +1199,20 @@ ieee80211_set_link_state(struct ieee80211com *ic, int nstate) } if (nstate != ifp->if_link_state) { ifp->if_link_state = nstate; + if (LINK_STATE_IS_UP(nstate)) { + struct if_ieee80211_data ifie; + memset(&ifie, 0, sizeof(ifie)); + ifie.ifie_nwid_len = ic->ic_bss->ni_esslen; + memcpy(ifie.ifie_nwid, ic->ic_bss->ni_essid, + sizeof(ifie.ifie_nwid)); + memcpy(ifie.ifie_addr, ic->ic_bss->ni_bssid, + sizeof(ifie.ifie_addr)); + ifie.ifie_channel = ieee80211_chan2ieee(ic, + ic->ic_bss->ni_chan); + ifie.ifie_flags = ic->ic_flags; + ifie.ifie_xflags = ic->ic_xflags; + rtm_80211info(&ic->ic_if, &ifie); + } if_link_state_change(ifp); } } |