Preparations to parse IEEE802.11 management packets

This commit is contained in:
vemax78 2014-03-26 21:35:52 +01:00
parent 4c466d68be
commit 7fd2d4357a
6 changed files with 60 additions and 2 deletions

View File

@ -36,7 +36,8 @@ endif
INCLUDES = \ INCLUDES = \
-I$(top_srcdir)/build \ -I$(top_srcdir)/build \
-I$(top_srcdir)/src/common \ -I$(top_srcdir)/src/common \
-I$(top_srcdir)/src/ac -I$(top_srcdir)/src/ac \
-I$(top_srcdir)/src/binding/ieee80211
include $(top_srcdir)/build/Makefile_common.am include $(top_srcdir)/build/Makefile_common.am
@ -51,6 +52,7 @@ ac_SOURCES = \
$(top_srcdir)/src/ac/ac_execute.c \ $(top_srcdir)/src/ac/ac_execute.c \
$(top_srcdir)/src/ac/ac_session.c \ $(top_srcdir)/src/ac/ac_session.c \
$(top_srcdir)/src/ac/ac_session_data.c \ $(top_srcdir)/src/ac/ac_session_data.c \
$(top_srcdir)/src/ac/ac_ieee80211_data.c \
$(top_srcdir)/src/ac/ac_discovery.c \ $(top_srcdir)/src/ac/ac_discovery.c \
$(top_srcdir)/src/ac/ac_80211_json.c \ $(top_srcdir)/src/ac/ac_80211_json.c \
$(top_srcdir)/src/ac/ac_80211_json_addwlan.c \ $(top_srcdir)/src/ac/ac_80211_json_addwlan.c \

View File

@ -17,6 +17,20 @@ struct ac_t g_ac;
/* Local param */ /* Local param */
static char g_configurationfile[260] = AC_DEFAULT_CONFIGURATION_FILE; static char g_configurationfile[260] = AC_DEFAULT_CONFIGURATION_FILE;
/* */
static unsigned long ac_stations_item_gethash(const void* key, unsigned long keysize, unsigned long hashsize) {
uint8_t* macaddress = (uint8_t*)key;
ASSERT(keysize == ETH_ALEN);
return ((((unsigned long)macaddress[4] << 8) | (unsigned long)macaddress[5]) ^ ((unsigned long)macaddress[3] << 4));
}
/* */
static void ac_stations_item_free(const void* key, unsigned long keysize, void* data) {
/* TODO */
}
/* Alloc AC */ /* Alloc AC */
static int ac_init(void) { static int ac_init(void) {
g_ac.standalone = 1; g_ac.standalone = 1;
@ -64,6 +78,9 @@ static int ac_init(void) {
g_ac.sessionsthread = capwap_list_create(); g_ac.sessionsthread = capwap_list_create();
capwap_rwlock_init(&g_ac.sessionslock); capwap_rwlock_init(&g_ac.sessionslock);
/* Stations */
g_ac.stations = capwap_hash_create(AC_STATIONS_HASH_SIZE, AC_STATIONS_KEY_SIZE, ac_stations_item_gethash, NULL, ac_stations_item_free);
/* Backend */ /* Backend */
g_ac.availablebackends = capwap_array_create(sizeof(struct ac_http_soap_server*), 0, 0); g_ac.availablebackends = capwap_array_create(sizeof(struct ac_http_soap_server*), 0, 0);
@ -102,6 +119,9 @@ static void ac_destroy(void) {
capwap_rwlock_destroy(&g_ac.sessionslock); capwap_rwlock_destroy(&g_ac.sessionslock);
ac_msgqueue_free(); ac_msgqueue_free();
/* Stations */
capwap_hash_free(g_ac.stations);
/* Backend */ /* Backend */
if (g_ac.backendacid) { if (g_ac.backendacid) {
capwap_free(g_ac.backendacid); capwap_free(g_ac.backendacid);

View File

@ -9,9 +9,11 @@
#include "capwap_lock.h" #include "capwap_lock.h"
#include "capwap_rwlock.h" #include "capwap_rwlock.h"
#include "capwap_list.h" #include "capwap_list.h"
#include "capwap_hash.h"
#include "capwap_element.h" #include "capwap_element.h"
#include <pthread.h> #include <pthread.h>
#include <linux/if_ether.h>
/* AC Configuration */ /* AC Configuration */
#define AC_DEFAULT_CONFIGURATION_FILE "/etc/capwap/ac.conf" #define AC_DEFAULT_CONFIGURATION_FILE "/etc/capwap/ac.conf"
@ -53,6 +55,10 @@
#define AC_IDLE_TIMEOUT_INTERVAL 300000 #define AC_IDLE_TIMEOUT_INTERVAL 300000
#define AC_WTP_FALLBACK_MODE CAPWAP_WTP_FALLBACK_ENABLED #define AC_WTP_FALLBACK_MODE CAPWAP_WTP_FALLBACK_ENABLED
/* */
#define AC_STATIONS_HASH_SIZE 65536
#define AC_STATIONS_KEY_SIZE ETH_ALEN
/* */ /* */
struct ac_state { struct ac_state {
struct capwap_ecnsupport_element ecn; struct capwap_ecnsupport_element ecn;
@ -91,6 +97,9 @@ struct ac_t {
struct capwap_list* sessionsthread; struct capwap_list* sessionsthread;
capwap_rwlock_t sessionslock; capwap_rwlock_t sessionslock;
/* Stations */
struct capwap_hash* stations;
/* Dtls */ /* Dtls */
int enabledtls; int enabledtls;
struct capwap_dtls_context dtlscontext; struct capwap_dtls_context dtlscontext;

View File

@ -0,0 +1,10 @@
#include "ac.h"
#include "ac_session.h"
#include "ieee80211.h"
/* */
void ac_ieee80211_data(struct ac_session_data_t* sessiondata, uint8_t* buffer, int length) {
ASSERT(sessiondata != NULL);
ASSERT(buffer != NULL);
ASSERT(length > 0);
}

View File

@ -142,6 +142,9 @@ void ac_session_data_close(struct ac_session_data_t* sessiondata);
void ac_session_data_send_action(struct ac_session_data_t* sessiondata, long action, long param, void* data, long length); void ac_session_data_send_action(struct ac_session_data_t* sessiondata, long action, long param, void* data, long length);
void ac_session_data_release_reference(struct ac_session_data_t* sessiondata); void ac_session_data_release_reference(struct ac_session_data_t* sessiondata);
/* IEEE802.11 Data Packet */
void ac_ieee80211_data(struct ac_session_data_t* sessiondata, uint8_t* buffer, int length);
/* */ /* */
int ac_has_sessionid(struct capwap_sessionid_element* sessionid); int ac_has_sessionid(struct capwap_sessionid_element* sessionid);
int ac_has_wtpid(const char* wtpid); int ac_has_wtpid(const char* wtpid);

View File

@ -1,11 +1,14 @@
#include "ac.h" #include "ac.h"
#include "capwap_dfa.h" #include "capwap_dfa.h"
#include "ac_session.h" #include "ac_session.h"
#include "ieee80211.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#define AC_ERROR_TIMEOUT -1000 #define AC_ERROR_TIMEOUT -1000
#define AC_ERROR_ACTION_SESSION -1001 #define AC_ERROR_ACTION_SESSION -1001
#define AC_BODY_PACKET_MAX_SIZE 8192
/* */ /* */
static int ac_session_data_action_execute(struct ac_session_data_t* sessiondata, struct ac_session_action* action) { static int ac_session_data_action_execute(struct ac_session_data_t* sessiondata, struct ac_session_action* action) {
int result = AC_ERROR_ACTION_SESSION; int result = AC_ERROR_ACTION_SESSION;
@ -302,6 +305,9 @@ static void ac_session_data_run(struct ac_session_data_t* sessiondata) {
int length; int length;
struct capwap_connection connection; struct capwap_connection connection;
char buffer[CAPWAP_MAX_PACKET_SIZE]; char buffer[CAPWAP_MAX_PACKET_SIZE];
unsigned short binding;
int bodypacketlength;
uint8_t bodypacket[AC_BODY_PACKET_MAX_SIZE];
ASSERT(sessiondata != NULL); ASSERT(sessiondata != NULL);
@ -357,7 +363,15 @@ static void ac_session_data_run(struct ac_session_data_t* sessiondata) {
/* Update timeout */ /* Update timeout */
capwap_timeout_set(sessiondata->timeout, sessiondata->idtimerkeepalivedead, AC_MAX_DATA_KEEPALIVE_INTERVAL, NULL, NULL, NULL); capwap_timeout_set(sessiondata->timeout, sessiondata->idtimerkeepalivedead, AC_MAX_DATA_KEEPALIVE_INTERVAL, NULL, NULL, NULL);
} else { } else {
/* TODO */ bodypacketlength = capwap_packet_getdata(sessiondata->rxmngpacket, bodypacket, AC_BODY_PACKET_MAX_SIZE);
/* Parsing body packet */
if (bodypacketlength > 0) {
binding = GET_WBID_HEADER(sessiondata->rxmngpacket->header);
if (binding == CAPWAP_WIRELESS_BINDING_IEEE80211) {
ac_ieee80211_data(sessiondata, bodypacket, bodypacketlength);
}
}
} }
} else { } else {
capwap_logging_debug("Failed validation parsed data packet"); capwap_logging_debug("Failed validation parsed data packet");