Fix capwap protocol and optional wireless information header.
Complete IEEE802.11 frames tunnel WTP side. Now WTP can send data packets to the AC.
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
#include "capwap.h"
|
||||
#include "wtp.h"
|
||||
#include "capwap_list.h"
|
||||
#include "capwap_element.h"
|
||||
#include "capwap_network.h"
|
||||
#include "wifi_drivers.h"
|
||||
#include "wtp.h"
|
||||
#include "wtp_radio.h"
|
||||
|
||||
/* Declare enable wifi driver */
|
||||
@ -316,7 +314,7 @@ static void wifi_wlan_send_mgmt_deauthentication(struct wifi_wlan* wlan, const u
|
||||
capwap_logging_info("Sent IEEE802.11 Deuthentication to %s station", stationaddress);
|
||||
|
||||
/* Forwards the station deauthentication also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, (struct ieee80211_header_mgmt*)g_bufferIEEE80211, responselength);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)g_bufferIEEE80211, responselength, 1, 0, 0, 0);
|
||||
} else {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Deuthentication to %s station", stationaddress);
|
||||
}
|
||||
@ -421,7 +419,7 @@ static void wifi_wlan_receive_station_mgmt_probe_request(struct wifi_wlan* wlan,
|
||||
if (!wlan->device->instance->ops->wlan_sendframe(wlan, g_bufferIEEE80211, responselength, wlan->device->currentfrequency.frequency, 0, 0, 0, nowaitack)) {
|
||||
/* If enable Split Mac send the probe request message to AC */
|
||||
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, frame, length);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, 1, rssi, snr, rate);
|
||||
}
|
||||
} else {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Probe Response");
|
||||
@ -585,10 +583,10 @@ static void wifi_wlan_receive_station_mgmt_authentication(struct wifi_wlan* wlan
|
||||
capwap_logging_info("Sent IEEE802.11 Authentication Response to %s station with %d status code", stationaddress, (int)responsestatuscode);
|
||||
|
||||
/* Notify authentication request message also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, frame, length);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, 1, rssi, snr, rate);
|
||||
|
||||
/* Forwards the authentication response message also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, (struct ieee80211_header_mgmt*)g_bufferIEEE80211, responselength);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)g_bufferIEEE80211, responselength, 1, 0, 0, 0);
|
||||
} else if (station) {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Authentication Response to %s station", stationaddress);
|
||||
wifi_station_delete(station);
|
||||
@ -598,7 +596,7 @@ static void wifi_wlan_receive_station_mgmt_authentication(struct wifi_wlan* wlan
|
||||
wifi_station_delete(station);
|
||||
}
|
||||
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, frame, length);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, 1, rssi, snr, rate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -684,10 +682,10 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
capwap_logging_info("Sent IEEE802.11 Association Response to %s station with %d status code", station->addrtext, (int)resultstatuscode);
|
||||
|
||||
/* Notify association request message also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, frame, length);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, 1, rssi, snr, rate);
|
||||
|
||||
/* Forwards the association response message also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, (struct ieee80211_header_mgmt*)g_bufferIEEE80211, responselength);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)g_bufferIEEE80211, responselength, 1, 0, 0, 0);
|
||||
} else {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Association Response to %s station", station->addrtext);
|
||||
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
@ -697,7 +695,7 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
}
|
||||
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, frame, length);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, 1, rssi, snr, rate);
|
||||
|
||||
/* Station information */
|
||||
station->capability = __le16_to_cpu(frame->associationresponse.capability);
|
||||
@ -731,7 +729,7 @@ static void wifi_wlan_receive_station_mgmt_disassociation(struct wifi_wlan* wlan
|
||||
/* TODO */
|
||||
|
||||
/* Notify disassociation message also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, frame, length);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, 1, rssi, snr, rate);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -752,7 +750,7 @@ static void wifi_wlan_receive_station_mgmt_deauthentication(struct wifi_wlan* wl
|
||||
}
|
||||
|
||||
/* Notify deauthentication message also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, frame, length);
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, 1, rssi, snr, rate);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -1580,6 +1578,9 @@ void wifi_wlan_receive_station_frame(struct wifi_wlan* wlan, const struct ieee80
|
||||
uint16_t framecontrol_type;
|
||||
uint16_t framecontrol_subtype;
|
||||
|
||||
ASSERT(wlan != NULL);
|
||||
ASSERT(wlan->handle != NULL);
|
||||
|
||||
/* Check frame */
|
||||
if (!frame || (length < sizeof(struct ieee80211_header))) {
|
||||
return;
|
||||
@ -1602,6 +1603,9 @@ void wifi_wlan_receive_station_ackframe(struct wifi_wlan* wlan, const struct iee
|
||||
uint16_t framecontrol_type;
|
||||
uint16_t framecontrol_subtype;
|
||||
|
||||
ASSERT(wlan != NULL);
|
||||
ASSERT(wlan->handle != NULL);
|
||||
|
||||
/* Check frame */
|
||||
if (!frame || (length < sizeof(struct ieee80211_header))) {
|
||||
return;
|
||||
@ -1625,6 +1629,9 @@ void wifi_wlan_receive_ac_frame(struct wifi_wlan* wlan, struct ieee80211_header*
|
||||
uint16_t framecontrol_type;
|
||||
uint16_t framecontrol_subtype;
|
||||
|
||||
ASSERT(wlan != NULL);
|
||||
ASSERT(wlan->handle != NULL);
|
||||
|
||||
/* Check frame */
|
||||
if (!frame || (length < sizeof(struct ieee80211_header))) {
|
||||
return;
|
||||
@ -1647,6 +1654,19 @@ void wifi_wlan_receive_ac_frame(struct wifi_wlan* wlan, struct ieee80211_header*
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
int wifi_wlan_send_frame(struct wifi_wlan* wlan, const uint8_t* data, int length, int nativeframe, uint8_t rssi, uint8_t snr, uint16_t rate) {
|
||||
ASSERT(wlan != NULL);
|
||||
ASSERT(wlan->handle != NULL);
|
||||
|
||||
if (!data || (length <= 0) || !wlan->send_frame) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* */
|
||||
return wlan->send_frame(wlan->send_frame_to_ac_cbparam, data, length, nativeframe, rssi, snr, rate, wlan->address, MACADDRESS_EUI48_LENGTH);
|
||||
}
|
||||
|
||||
/* */
|
||||
int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* params) {
|
||||
int result;
|
||||
|
@ -87,7 +87,7 @@ struct device_setconfiguration_params {
|
||||
};
|
||||
|
||||
/* */
|
||||
typedef void (*send_frame_to_ac)(void* param, const struct ieee80211_header_mgmt* mgmt, int mgmtlength);
|
||||
typedef int (*send_frame_to_ac)(void* param, const uint8_t* frame, int length, int nativeframe, uint8_t rssi, uint8_t snr, uint16_t rate, uint8_t* bssaddress, int bssaddresstype);
|
||||
|
||||
struct wlan_startap_params {
|
||||
send_frame_to_ac send_frame;
|
||||
@ -409,6 +409,7 @@ int wifi_wlan_startap(struct wifi_wlan* wlan, struct wlan_startap_params* params
|
||||
void wifi_wlan_stopap(struct wifi_wlan* wlan);
|
||||
int wifi_wlan_getbssid(struct wifi_wlan* wlan, uint8_t* bssid);
|
||||
uint16_t wifi_wlan_check_capability(struct wifi_wlan* wlan, uint16_t capability);
|
||||
int wifi_wlan_send_frame(struct wifi_wlan* wlan, const uint8_t* data, int length, int nativeframe, uint8_t rssi, uint8_t snr, uint16_t rate);
|
||||
void wifi_wlan_destroy(struct wifi_wlan* wlan);
|
||||
|
||||
/* WLAN packet management */
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include "capwap.h"
|
||||
#include "wtp.h"
|
||||
#include "capwap_array.h"
|
||||
#include "capwap_list.h"
|
||||
#include "capwap_element.h"
|
||||
#include "capwap_network.h"
|
||||
#include <netlink/genl/genl.h>
|
||||
#include <netlink/genl/family.h>
|
||||
#include <netlink/genl/ctrl.h>
|
||||
@ -371,11 +370,9 @@ static int nl80211_wlan_event(struct wifi_wlan* wlan, struct genlmsghdr* gnlh, s
|
||||
if (tb_msg[NL80211_ATTR_FRAME]) {
|
||||
uint32_t frequency = (tb_msg[NL80211_ATTR_WIPHY_FREQ] ? nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FREQ]) : 0);
|
||||
uint8_t rssi = (tb_msg[NL80211_ATTR_RX_SIGNAL_DBM] ? (uint8_t)nla_get_u32(tb_msg[NL80211_ATTR_RX_SIGNAL_DBM]) : 0);
|
||||
uint8_t snr = 0;
|
||||
uint16_t rate = 0;
|
||||
|
||||
/* */
|
||||
wifi_wlan_receive_station_frame(wlan, (struct ieee80211_header*)nla_data(tb_msg[NL80211_ATTR_FRAME]), nla_len(tb_msg[NL80211_ATTR_FRAME]), frequency, rssi, snr, rate);
|
||||
wifi_wlan_receive_station_frame(wlan, (struct ieee80211_header*)nla_data(tb_msg[NL80211_ATTR_FRAME]), nla_len(tb_msg[NL80211_ATTR_FRAME]), frequency, rssi, 0, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -799,15 +796,26 @@ static int nl80211_wlan_startap(struct wifi_wlan* wlan) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* */
|
||||
if (wlan->tunnelmode != CAPWAP_ADD_WLAN_TUNNELMODE_LOCAL) {
|
||||
/* Join interface to kernel module */
|
||||
if ((g_wtp.tunneldataframe == WTP_TUNNEL_DATA_FRAME_KERNELMODE) || (g_wtp.tunneldataframe == WTP_TUNNEL_DATA_FRAME_USERMODE)) {
|
||||
uint32_t mode = ((g_wtp.tunneldataframe == WTP_TUNNEL_DATA_FRAME_KERNELMODE) ? WTP_KMOD_MODE_TUNNEL_KERNELMODE : WTP_KMOD_MODE_TUNNEL_USERMODE);
|
||||
uint32_t flags = ((wlan->tunnelmode == CAPWAP_ADD_WLAN_TUNNELMODE_80211) ? WTP_KMOD_FLAGS_TUNNEL_NATIVE : WTP_KMOD_FLAGS_TUNNEL_8023);
|
||||
|
||||
if (!wtp_kmod_join_mac80211_device(wlan, mode, flags)) {
|
||||
capwap_logging_info("Joined in kernel mode the interface %d", wlan->virtindex);
|
||||
}
|
||||
} else {
|
||||
capwap_logging_warning("Tunneling is not supported for interface %d", wlan->virtindex);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable operation status */
|
||||
wlan->flags |= WIFI_WLAN_OPERSTATE_RUNNING;
|
||||
netlink_set_link_status(wlanhandle->devicehandle->globalhandle->netlinkhandle, wlan->virtindex, -1, IF_OPER_UP);
|
||||
|
||||
/* */
|
||||
if (!wtp_kmod_join_mac80211_device(wlan->virtindex)) {
|
||||
capwap_logging_info("Joined in kernel mode the interface %d", wlan->virtindex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -822,6 +830,14 @@ static void nl80211_wlan_stopap(struct wifi_wlan* wlan) {
|
||||
/* */
|
||||
wlanhandle = (struct nl80211_wlan_handle*)wlan->handle;
|
||||
|
||||
/* */
|
||||
if (wlan->tunnelmode != CAPWAP_ADD_WLAN_TUNNELMODE_LOCAL) {
|
||||
/* Leave interface from kernel module */
|
||||
if ((g_wtp.tunneldataframe == WTP_TUNNEL_DATA_FRAME_KERNELMODE) || (g_wtp.tunneldataframe == WTP_TUNNEL_DATA_FRAME_USERMODE)) {
|
||||
wtp_kmod_leave_mac80211_device(wlan);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
if (wlan->flags & WIFI_WLAN_SET_BEACON) {
|
||||
msg = nlmsg_alloc();
|
||||
|
Reference in New Issue
Block a user