From ebc4e2cdf06a26e81ba8738e73e230ea1f1ec536 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 13 Mar 2018 15:27:20 -0500 Subject: [PATCH] netdev: React to CONTROL_PORT unicast --- src/netdev.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/netdev.c b/src/netdev.c index 305de85d..0215300e 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -3077,6 +3077,58 @@ static void netdev_mgmt_frame_event(struct l_genl_msg *msg, netdev, mpdu, body, info.body_len); } +static void netdev_control_port_frame_event(struct l_genl_msg *msg, + struct netdev *netdev) +{ + struct l_genl_attr attr; + uint16_t type; + uint16_t len; + const void *data; + const uint8_t *frame = NULL; + uint16_t frame_len = 0; + const uint8_t *src = NULL; + uint16_t proto = 0; + bool unencrypted = false; + + l_debug(""); + + if (!l_genl_attr_init(&attr, msg)) + return; + + while (l_genl_attr_next(&attr, &type, &len, &data)) { + switch (type) { + case NL80211_ATTR_FRAME: + if (frame) + return; + + frame = data; + frame_len = len; + break; + case NL80211_ATTR_MAC: + if (src) + return; + + src = data; + break; + case NL80211_ATTR_CONTROL_PORT_ETHERTYPE: + if (len != sizeof(proto)) + return; + + proto = *((const uint16_t *) data); + break; + case NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT: + unencrypted = true; + break; + } + } + + if (!src || !frame || !proto) + return; + + __eapol_rx_packet(netdev->index, src, proto, + frame, frame_len, unencrypted); +} + static void netdev_unicast_notify(struct l_genl_msg *msg, void *user_data) { struct netdev *netdev = NULL; @@ -3116,6 +3168,9 @@ static void netdev_unicast_notify(struct l_genl_msg *msg, void *user_data) case NL80211_CMD_FRAME: netdev_mgmt_frame_event(msg, netdev); break; + case NL80211_CMD_CONTROL_PORT_FRAME: + netdev_control_port_frame_event(msg, netdev); + break; } }