5 Commits

Author SHA1 Message Date
25da5ad965 Wrong option for ./configure in README.md 2016-03-29 16:53:25 +02:00
04b1f205c5 rework bssid handling and stop all used bssids when leaving RUN
(this has been backported from master)
Instead of haing a pool of unsused BSS Id's and a list of active
BSS's (wlans), use a single array and only mark the BSS Id as used
or unused.

When leaving RUN state, release (stop) all used BSS.

Conflicts:
	src/wtp/wtp.c
	src/wtp/wtp_radio.c
2016-03-29 16:49:45 +02:00
c2a07804db reset WTP state when going into DTLS TD 2016-03-29 10:10:25 +02:00
a96bb07868 Merge remote-tracking branch 'nm-mrt/dns-support' into v1.1.x 2016-03-25 13:13:02 +01:00
9ee69a6778 fix libnl-genl detection for libnl3 2016-03-23 12:36:59 +01:00
412 changed files with 26700 additions and 14709 deletions

View File

@ -1,4 +1,4 @@
This is a GPLv2 only fork of SmartCAPWAP. The original project
This is a GPLv2 only fork of SmartCAWAP. The original project
can be found here: https://bitbucket.org/vemax78/smartcapwap
All changes and contribution to this fork are GPL licensed only.

View File

@ -1,7 +1,6 @@
# FreeWTP -- An Open Source CAPWAP WTP
# SmartCAPWAP -- An Open Source CAPWAP WTP / AC
#
# Copyright SmartCAPWAP (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
# Copyright FreeWTP (C) 2016 Travelping GmbH <info@travelping.com>
# Copyright (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -24,24 +23,20 @@ ACLOCAL_AMFLAGS = -I m4
MAINTAINERCLEANFILES = $(srcdir)/config.log \
$(srcdir)/config.status \
$(srcdir)/Makefile.in \
$(srcdir)/lib/Makefile.in \
$(srcdir)/src/Makefile.in \
$(srcdir)/lib/config.h.in \
$(srcdir)/lib/config.h.in~ \
$(srcdir)/config.h.in \
$(srcdir)/config.h.in~ \
$(srcdir)/configure \
$(srcdir)/config/install-sh \
$(srcdir)/config/ltmain.sh \
$(srcdir)/config/compile \
$(srcdir)/config/missing \
$(srcdir)/config/ar-lib \
$(srcdir)/config/depcomp \
$(srcdir)/config/config.guess \
$(srcdir)/config/config.sub \
$(srcdir)/build/install-sh \
$(srcdir)/ltmain.sh \
$(srcdir)/build/missing \
$(srcdir)/m4/libtool.m4 \
$(srcdir)/m4/lt~obsolete.m4 \
$(srcdir)/m4/ltoptions.m4 \
$(srcdir)/m4/ltsugar.m4 \
$(srcdir)/m4/ltversion.m4 \
$(srcdir)/m4/lt~obsolete.m4 \
$(srcdir)/aclocal.m4
$(srcdir)/depcomp \
$(srcdir)/aclocal.m4 \
$(srcdir)/build/config.guess \
$(srcdir)/build/config.sub
SUBDIRS = lib src
SUBDIRS = build

42
NEWS.md
View File

@ -1,42 +0,0 @@
FreeWTP
=======
Open Source CAPWAP WTP implementation
Version 1.4.0 - 22 Aug 2016
---------------------------
* renamed to FreeWTP
* RFC-7494 support
* fix DTLS handshake failure handling
Version 1.3.2 - 15 Aug 2016
---------------------------
* support management frame protection
Version 1.3.1 - 11 Aug 2016
---------------------------
* fix hw queue selection for 802.11 raw frame injection
* initial Linux ftrace support
Version 1.3.0 - 08 Aug 2016
---------------------------
* forward PAE (IEEE 802.1X Authentication) frames as raw 802.11 frames to AC
* implement encryption support for group and peer temporal keys (CCMP only)
Version 1.2.1 - 06 May 2016
---------------------------
* fix Add WLAN's capability field
* fix mssing IEEE 802.11 Assigned WTP BSSID IE in Add WLAN response
Version 1.2.0 - 29 Apr 2016
---------------------------
* 802.11n support
* WMM/WME support
* ported to libev
* ported to Linux 4.4

View File

@ -1,34 +1,27 @@
# README
[RFC-5415](https://tools.ietf.org/html/rfc5415) and [RFC-5416](https://tools.ietf.org/html/rfc5416) compliant CAPWAP WTP implementation.
[RFC-5415](https://tools.ietf.org/html/rfc5415) and [RFC-5416](https://tools.ietf.org/html/rfc5416) compliant CAPWAP WTP (and AC) implementation.
This project started as a fork of SmartCAPWAP, but has since dropped the AC part on focuses on WTP functionality only (hence the new name).
This fork is currently focusing on the WTP side only.
## STATUS
NOTE: The WTP implementation has been ported to libev
### WTP tested and working features:
* 802.11b
* 802.11g
* 802.11a
* WMM/WME (mostly)
* Local MAC
* single radio, single WLAN mode
* 802.11n ([draft-ietf-opsawg-capwap-extension-06](https://tools.ietf.org/html/draft-ietf-opsawg-capwap-extension-06))
* WPA2-PSK
Only cards with cfg80211 netlink API are supported. The following devices
have been tested:
* Atheros AR9280 (Compex WLE200NX)
* Mediatek MT7602E, MT7612E (ZBT WG2626, ALL-WR1200AC_WRT)
Only cards with cfg80211 netlink API are supported and only
ath9k cards (in particular Qualcomm Atheros AR5418) have
been tested.
### Planned WTP features:
* WPA2 Enterprise
* 802.11r - BSS fast transition
* 802.11n ([draft-ietf-opsawg-capwap-extension-06](https://tools.ietf.org/html/draft-ietf-opsawg-capwap-extension-06))
* encryption (WPA2)
* Hybrid-MAC ([RFC-7494](https://tools.ietf.org/html/rfc7494))
## INSTALLATION
@ -44,51 +37,25 @@ NOTE: To run WTP you must have a wireless card that has Linux driver based on th
* libconfig-dev
* libjson0-dev
* libnl-dev
* libev-dev
* libtool
* libxml2-dev
* wolfssl 3.8 or newer
### Build
WolfSSL:
./configure --enable-dtls --enable-ipv6 --enable-aesgcm \
--enable-aesccm --enable-aesni --enable-poly1305 \
--enable-ecc --enable-ecc25519 --enable-chacha \
--enable-supportedcurves --enable-dh --enable-psk \
--disable-des3 --disable-arc4 --prefix=/usr/
--enable-ecc --enable-ecc25519 --enable-chacha \
--enable-supportedcurves --enable-dh --enable-psk \
--disable-des3 --disable-arc4 --prefix=/usr/
make
make install
FreeWTP:
SmartCAPWAP:
autoreconf -f -i
./configure --disable-ac
make
make install
### Debugging / Tracing
The smartcapwap kernel module defines a number of static ftrace events. For a detailed
guide on how to use those, see: https://www.kernel.org/doc/Documentation/trace/ftrace.txt
A sample trace session might lock like this:
# echo 1 > /sys/kernel/debug/tracing/events/capwap/enable
# echo 1 > /sys/kernel/debug/tracing/tracing_on
# cat /sys/kernel/debug/tracing/trace_pipe
<...>-890 [000] ...1 12030.725012: sc_capwap_create: session:9e04b10c75b3c6537da18d38da5bc70d
<...>-890 [000] ...1 12030.725048: sc_capwap_sendkeepalive: session:9e04b10c75b3c6537da18d38da5bc70d
<...>-890 [000] ...1 12030.725052: sc_capwap_createkeepalive: session:9e04b10c75b3c6537da18d38da5bc70d
<...>-890 [000] ...1 12030.725053: sc_capwap_send: session:9e04b10c75b3c6537da18d38da5bc70d
ksoftirqd/0-3 [000] ..s1 12030.727270: sc_capwap_parsingpacket: session:9e04b10c75b3c6537da18d38da5bc70d skb:ffff8802306c8900
wtp-890 [001] ...1 12060.764008: sc_capwap_sendkeepalive: session:9e04b10c75b3c6537da18d38da5bc70d
wtp-890 [001] ...1 12060.764530: sc_capwap_createkeepalive: session:9e04b10c75b3c6537da18d38da5bc70d
wtp-890 [001] ...1 12060.764637: sc_capwap_send: session:9e04b10c75b3c6537da18d38da5bc70d
<idle>-0 [000] ..s2 12060.787527: sc_capwap_parsingpacket: session:9e04b10c75b3c6537da18d38da5bc70d skb:ffff8800b8a85900
wtp-890 [001] ...1 12082.953847: sc_capwap_resetsession: session:9e04b10c75b3c6537da18d38da5bc70d
wtp-890 [001] ...1 12082.954005: sc_capwap_close: session:9e04b10c75b3c6537da18d38da5bc70d
wtp-890 [001] ...1 12082.954130: sc_capwap_freesession: session:9e04b10c75b3c6537da18d38da5bc70d
# echo 0 > /sys/kernel/debug/tracing/tracing_on

30
build/Makefile.am Executable file
View File

@ -0,0 +1,30 @@
# SmartCAPWAP -- An Open Source CAPWAP WTP / AC
#
# Copyright (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING included with this
# distribution); if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
SUBDIRS =
if BUILD_AC
SUBDIRS += ac
endif
if BUILD_WTP
SUBDIRS += wtp
endif

107
build/Makefile_common.am Executable file
View File

@ -0,0 +1,107 @@
# SmartCAPWAP -- An Open Source CAPWAP WTP / AC
#
# Copyright (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING included with this
# distribution); if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
capwap_SOURCES = $(top_srcdir)/src/common/capwap.c \
$(top_srcdir)/src/common/capwap_timeout.c \
$(top_srcdir)/src/common/capwap_network.c \
$(top_srcdir)/src/common/capwap_protocol.c \
$(top_srcdir)/src/common/capwap_logging.c \
$(top_srcdir)/src/common/capwap_list.c \
$(top_srcdir)/src/common/capwap_array.c \
$(top_srcdir)/src/common/capwap_hash.c \
$(top_srcdir)/src/common/capwap_dtls.c \
$(top_srcdir)/src/common/capwap_dfa.c \
$(top_srcdir)/src/common/capwap_element.c \
$(top_srcdir)/src/common/capwap_element_acdescriptor.c \
$(top_srcdir)/src/common/capwap_element_actimestamp.c \
$(top_srcdir)/src/common/capwap_element_addmacacl.c \
$(top_srcdir)/src/common/capwap_element_deletemacacl.c \
$(top_srcdir)/src/common/capwap_element_addstation.c \
$(top_srcdir)/src/common/capwap_element_deletestation.c \
$(top_srcdir)/src/common/capwap_element_discoverytype.c \
$(top_srcdir)/src/common/capwap_element_duplicateipv4.c \
$(top_srcdir)/src/common/capwap_element_duplicateipv6.c \
$(top_srcdir)/src/common/capwap_element_datatransferdata.c \
$(top_srcdir)/src/common/capwap_element_datatransfermode.c \
$(top_srcdir)/src/common/capwap_element_decrypterrorreport.c \
$(top_srcdir)/src/common/capwap_element_imagedata.c \
$(top_srcdir)/src/common/capwap_element_imageinfo.c \
$(top_srcdir)/src/common/capwap_element_initdownload.c \
$(top_srcdir)/src/common/capwap_element_wtpboarddata.c \
$(top_srcdir)/src/common/capwap_element_wtpdescriptor.c \
$(top_srcdir)/src/common/capwap_element_wtpframetunnelmode.c \
$(top_srcdir)/src/common/capwap_element_wtpmactype.c \
$(top_srcdir)/src/common/capwap_element_acname.c \
$(top_srcdir)/src/common/capwap_element_controlipv4.c \
$(top_srcdir)/src/common/capwap_element_controlipv6.c \
$(top_srcdir)/src/common/capwap_element_location.c \
$(top_srcdir)/src/common/capwap_element_wtpname.c \
$(top_srcdir)/src/common/capwap_element_sessionid.c \
$(top_srcdir)/src/common/capwap_element_ecnsupport.c \
$(top_srcdir)/src/common/capwap_element_localipv4.c \
$(top_srcdir)/src/common/capwap_element_localipv6.c \
$(top_srcdir)/src/common/capwap_element_transport.c \
$(top_srcdir)/src/common/capwap_element_mtudiscovery.c \
$(top_srcdir)/src/common/capwap_element_vendorpayload.c \
$(top_srcdir)/src/common/capwap_element_maximumlength.c \
$(top_srcdir)/src/common/capwap_element_wtprebootstat.c \
$(top_srcdir)/src/common/capwap_element_wtpradiostat.c \
$(top_srcdir)/src/common/capwap_element_resultcode.c \
$(top_srcdir)/src/common/capwap_element_returnedmessage.c \
$(top_srcdir)/src/common/capwap_element_acipv4list.c \
$(top_srcdir)/src/common/capwap_element_acipv6list.c \
$(top_srcdir)/src/common/capwap_element_imageidentifier.c \
$(top_srcdir)/src/common/capwap_element_radioadmstate.c \
$(top_srcdir)/src/common/capwap_element_statisticstimer.c \
$(top_srcdir)/src/common/capwap_element_acnamepriority.c \
$(top_srcdir)/src/common/capwap_element_wtpstaticipaddress.c \
$(top_srcdir)/src/common/capwap_element_timers.c \
$(top_srcdir)/src/common/capwap_element_decrypterrorreportperiod.c \
$(top_srcdir)/src/common/capwap_element_idletimeout.c \
$(top_srcdir)/src/common/capwap_element_wtpfallback.c \
$(top_srcdir)/src/common/capwap_element_radiooprstate.c \
$(top_srcdir)/src/common/capwap_element_80211_addwlan.c \
$(top_srcdir)/src/common/capwap_element_80211_antenna.c \
$(top_srcdir)/src/common/capwap_element_80211_assignbssid.c \
$(top_srcdir)/src/common/capwap_element_80211_deletewlan.c \
$(top_srcdir)/src/common/capwap_element_80211_directsequencecontrol.c \
$(top_srcdir)/src/common/capwap_element_80211_ie.c \
$(top_srcdir)/src/common/capwap_element_80211_macoperation.c \
$(top_srcdir)/src/common/capwap_element_80211_miccountermeasures.c \
$(top_srcdir)/src/common/capwap_element_80211_multidomaincapability.c \
$(top_srcdir)/src/common/capwap_element_80211_ofdmcontrol.c \
$(top_srcdir)/src/common/capwap_element_80211_rateset.c \
$(top_srcdir)/src/common/capwap_element_80211_rsnaerrorreport.c \
$(top_srcdir)/src/common/capwap_element_80211_station.c \
$(top_srcdir)/src/common/capwap_element_80211_stationqos.c \
$(top_srcdir)/src/common/capwap_element_80211_stationkey.c \
$(top_srcdir)/src/common/capwap_element_80211_statistics.c \
$(top_srcdir)/src/common/capwap_element_80211_supportedrates.c \
$(top_srcdir)/src/common/capwap_element_80211_txpower.c \
$(top_srcdir)/src/common/capwap_element_80211_txpowerlevel.c \
$(top_srcdir)/src/common/capwap_element_80211_updatestationqos.c \
$(top_srcdir)/src/common/capwap_element_80211_updatewlan.c \
$(top_srcdir)/src/common/capwap_element_80211_wtpqos.c \
$(top_srcdir)/src/common/capwap_element_80211_wtpradioconf.c \
$(top_srcdir)/src/common/capwap_element_80211_wtpradiofailalarm.c \
$(top_srcdir)/src/common/capwap_element_80211_wtpradioinformation.c
if DEBUG_BUILD
capwap_SOURCES += $(top_srcdir)/src/common/capwap_debug.c
endif

90
build/ac/Makefile.am Executable file
View File

@ -0,0 +1,90 @@
# SmartCAPWAP -- An Open Source CAPWAP WTP / AC
#
# Copyright (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING included with this
# distribution); if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
bin_PROGRAMS = ac
AM_CFLAGS = -DCAPWAP_MULTITHREADING_ENABLE \
-D_REENTRANT \
-D_GNU_SOURCE \
${LIBNL_CFLAGS} \
$(LIBXML2_CFLAGS) \
$(WOLFSSL_CFLAGS)
AM_CFLAGS += -I$(top_srcdir)/build \
-I$(top_srcdir)/src/common \
-I$(top_srcdir)/src/ac \
-I$(top_srcdir)/src/ac/kmod \
-I$(top_srcdir)/src/common/binding/ieee80211
include $(top_srcdir)/build/Makefile_common.am
ac_SOURCES = $(capwap_SOURCES) \
$(top_srcdir)/src/common/capwap_event.c \
$(top_srcdir)/src/common/capwap_lock.c \
$(top_srcdir)/src/common/capwap_rwlock.c \
$(top_srcdir)/src/common/capwap_socket.c \
$(top_srcdir)/src/ac/ac.c \
$(top_srcdir)/src/ac/ac_backend.c \
$(top_srcdir)/src/ac/ac_execute.c \
$(top_srcdir)/src/ac/ac_session.c \
$(top_srcdir)/src/ac/ac_wlans.c \
$(top_srcdir)/src/ac/ac_kmod.c \
$(top_srcdir)/src/ac/ac_ieee80211_data.c \
$(top_srcdir)/src/ac/ac_discovery.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_antenna.c \
$(top_srcdir)/src/ac/ac_80211_json_assignbssid.c \
$(top_srcdir)/src/ac/ac_80211_json_deletewlan.c \
$(top_srcdir)/src/ac/ac_80211_json_directsequencecontrol.c \
$(top_srcdir)/src/ac/ac_80211_json_ie.c \
$(top_srcdir)/src/ac/ac_80211_json_macoperation.c \
$(top_srcdir)/src/ac/ac_80211_json_miccountermeasures.c \
$(top_srcdir)/src/ac/ac_80211_json_multidomaincapability.c \
$(top_srcdir)/src/ac/ac_80211_json_ofdmcontrol.c \
$(top_srcdir)/src/ac/ac_80211_json_rateset.c \
$(top_srcdir)/src/ac/ac_80211_json_rsnaerrorreport.c \
$(top_srcdir)/src/ac/ac_80211_json_statistics.c \
$(top_srcdir)/src/ac/ac_80211_json_supportedrates.c \
$(top_srcdir)/src/ac/ac_80211_json_txpower.c \
$(top_srcdir)/src/ac/ac_80211_json_txpowerlevel.c \
$(top_srcdir)/src/ac/ac_80211_json_updatewlan.c \
$(top_srcdir)/src/ac/ac_80211_json_wtpqos.c \
$(top_srcdir)/src/ac/ac_80211_json_wtpradioconf.c \
$(top_srcdir)/src/ac/ac_80211_json_wtpradiofailalarm.c \
$(top_srcdir)/src/ac/ac_80211_json_wtpradioinformation.c \
$(top_srcdir)/src/ac/ac_dfa_join.c \
$(top_srcdir)/src/ac/ac_dfa_configure.c \
$(top_srcdir)/src/ac/ac_dfa_imagedata.c \
$(top_srcdir)/src/ac/ac_dfa_datacheck.c \
$(top_srcdir)/src/ac/ac_dfa_dtls.c \
$(top_srcdir)/src/ac/ac_dfa_run.c \
$(top_srcdir)/src/ac/ac_dfa_reset.c \
$(top_srcdir)/src/ac/ac_dfa_teardown.c \
$(top_srcdir)/src/ac/ac_soap.c \
$(top_srcdir)/src/common/binding/ieee80211/ieee80211.c
ac_LDADD = $(CONFIG_LIBS) \
$(PTHREAD_LIBS) \
$(LIBXML2_LIBS) \
$(LIBJSON_LIBS) \
$(WOLFSSL_LIBS) \
$(LIBNL_LIBS)

70
build/wtp/Makefile.am Executable file
View File

@ -0,0 +1,70 @@
# SmartCAPWAP -- An Open Source CAPWAP WTP / AC
#
# Copyright (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING included with this
# distribution); if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
bin_PROGRAMS = wtp
AM_CFLAGS = -D_REENTRANT \
-D_GNU_SOURCE \
${LIBNL_CFLAGS}
if DTLS_ENABLED
AM_CFLAGS += $(WOLFSSL_CFLAGS)
endif
AM_CFLAGS += -I$(top_srcdir)/build \
-I$(top_srcdir)/src/common \
-I$(top_srcdir)/src/wtp \
-I$(top_srcdir)/src/wtp/kmod \
-I$(top_srcdir)/src/common/binding/ieee80211 \
-I$(top_srcdir)/src/wtp/binding/ieee80211
include $(top_srcdir)/build/Makefile_common.am
wtp_SOURCES = $(capwap_SOURCES) \
$(top_srcdir)/src/wtp/wtp.c \
$(top_srcdir)/src/wtp/wtp_kmod.c \
$(top_srcdir)/src/wtp/wtp_element_helper.c \
$(top_srcdir)/src/wtp/wtp_dfa.c \
$(top_srcdir)/src/wtp/wtp_dfa_idle.c \
$(top_srcdir)/src/wtp/wtp_dfa_discovery.c \
$(top_srcdir)/src/wtp/wtp_dfa_sulking.c \
$(top_srcdir)/src/wtp/wtp_dfa_dtls.c \
$(top_srcdir)/src/wtp/wtp_dfa_join.c \
$(top_srcdir)/src/wtp/wtp_dfa_configure.c \
$(top_srcdir)/src/wtp/wtp_dfa_datacheck.c \
$(top_srcdir)/src/wtp/wtp_dfa_run.c \
$(top_srcdir)/src/wtp/wtp_dfa_reset.c \
$(top_srcdir)/src/wtp/wtp_dfa_imagedata.c \
$(top_srcdir)/src/wtp/wtp_radio.c \
$(top_srcdir)/src/common/binding/ieee80211/ieee80211.c \
$(top_srcdir)/src/wtp/binding/ieee80211/netlink_link.c \
$(top_srcdir)/src/wtp/binding/ieee80211/wifi_drivers.c
wtp_LDADD = $(CONFIG_LIBS) \
$(LIBNL_LIBS)
if DTLS_ENABLED
wtp_LDADD += $(WOLFSSL_LIBS)
endif
if BUILD_WTP_WIFI_DRIVERS_NL80211
wtp_SOURCES += $(top_srcdir)/src/wtp/binding/ieee80211/wifi_nl80211.c
endif

View File

@ -12,9 +12,9 @@ application: {
binding = "802.11";
tunnelmode: {
nativeframe = true;
ethframe = true;
localbridging = false;
nativeframe = false;
ethframe = false;
localbridging = true;
};
mactype = "localmac";
@ -49,7 +49,6 @@ application: {
timer: {
statistics = 120;
inactivity = 300;
};
dtls: {
@ -150,17 +149,6 @@ application: {
dscp = 0; # not used yet
};
};
ieee80211n = {
a-msdu = true;
a-mpdu = true;
require-ht = false;
short-gi = true;
ht40 = false;
max-sup-mcs = 15;
max-mand-mcs = 7;
tx-antenna = 0;
rx-antenna = 0;
};
}
);

View File

@ -1,7 +1,6 @@
# FreeWTP -- An Open Source CAPWAP AC
# SmartCAPWAP -- An Open Source CAPWAP WTP / AC
#
# Copyright (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
# Copyright (C) 2016 Travelping GmbH <info@travelping.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -20,26 +19,20 @@
AC_PREREQ(2.63)
AC_INIT([freewtp], [1.3.0], [https://github.com/travelping/freewtp], [freewtp])
AC_CONFIG_AUX_DIR([config])
AC_INIT([SmartCAPWAP], [1.1.0], [https://github.com/travelping/smartcapwap], [smartcapwap])
AC_CONFIG_AUX_DIR([build])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 -Wall foreign subdir-objects silent-rules])
AM_INIT_AUTOMAKE([1.11 -Wall])
AC_USE_SYSTEM_EXTENSIONS
AM_SILENT_RULES([yes])
# cross-compile macros
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
#
AC_COPYRIGHT("SmartCapwap by Massimo Vellucci <vemax78@gmail.com>")
AC_COPYRIGHT("FreeWTP by Travelping <info@travelping.com>")
AC_REVISION($Revision: 1.0 $)
#
AM_MAINTAINER_MODE
#
AC_PROG_INSTALL
AC_LANG(C)
@ -67,6 +60,20 @@ AC_ARG_ENABLE(
[enable_logging="yes"]
)
AC_ARG_ENABLE(
[ac],
[AS_HELP_STRING([--disable-ac], [disable ac support])],
,
[enable_ac="yes"]
)
AC_ARG_ENABLE(
[wtp],
[AS_HELP_STRING([--disable-wtp], [disable wtp support])],
,
[enable_wtp="yes"]
)
AC_ARG_WITH(
[mem-check],
[AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|internal|valgrind])],
@ -79,7 +86,7 @@ AC_ARG_WITH(
[with_mem_check="internal"]
)
# WTP drivers wifi binding
# WTP drivers wifi binding
AC_ARG_ENABLE(
[wifi-drivers-nl80211],
[AS_HELP_STRING([--disable-wifi-drivers-nl80211], [disable WTP support for nl80211 wifi binding])],
@ -88,18 +95,15 @@ AC_ARG_ENABLE(
)
# specify output header file
AM_CONFIG_HEADER(lib/config.h)
AM_CONFIG_HEADER(build/config.h)
#
old_CFLAGS="${CFLAGS}"
AC_PROG_CC([gcc])
AC_PROG_CC_C99
AC_PROG_CPP
AM_PROG_CC_C_O
AM_PROG_AR
AM_PROG_LIBTOOL
CFLAGS="${old_CFLAGS}"
#
AM_CONDITIONAL([DEBUG_BUILD], [test "$enable_debug" = yes])
AM_CONDITIONAL([DEBUG_BUILD], [test "$enable_debug" = yes])
if test "${enable_debug}" = "yes"; then
CFLAGS="${CFLAGS} -DDEBUG -Wall -Werror -g -O0"
@ -171,11 +175,36 @@ LDFLAGS="$saved_LDFLAGS"
AC_DEFINE_UNQUOTED([LIBCONFIG_LOOKUP_INT_ARG], [$LIBCONFIG_LOOKUP_INT_ARG], [config_lookup_int() argument type])
AC_CHECK_LIB([ev], [ev_run],, [AC_MSG_ERROR(Required library ev missing)])
# Check PTHREAD library
AC_CHECK_HEADER([pthread.h], [], [AC_MSG_ERROR(You need the pthread headers)])
AC_CHECK_LIB([pthread], [pthread_create], [PTHREAD_LIBS="-lpthread"], [AC_MSG_ERROR(You need the pthread library)])
# Check SSL library
PKG_CHECK_MODULES([WOLFSSL], [wolfssl >= 3.8.0], [have_wolfssl_ssl="yes"], [have_wolfssl_ssl="no"])
# Check JSON library
if test "${enable_ac}" = "yes"; then
test "x${have_wolfssl_ssl}" != "xyes" && AC_MSG_ERROR(You need the wolfssl library)
PKG_CHECK_MODULES(
[LIBJSON],
[json-c >= 0.11],
[],
[PKG_CHECK_MODULES(
[LIBJSON],
[json >= 0.9],
[],
[AC_MSG_ERROR(You need the libjson)]
)]
)
# Check XML2 library
PKG_CHECK_MODULES(
[LIBXML2],
[libxml-2.0 >= 2.6]
)
fi
# Check Netlink library
PKG_CHECK_MODULES(
[LIBNL3],
@ -235,6 +264,10 @@ case "${with_mem_check}" in
;;
esac
#
AM_CONDITIONAL([BUILD_AC], [test "${enable_ac}" = "yes"])
AM_CONDITIONAL([BUILD_WTP], [test "${enable_wtp}" = "yes"])
#
test "${enable_logging}" = "yes" && AC_DEFINE([ENABLE_LOGGING], [1], [Enable logging])
@ -246,12 +279,14 @@ AM_CONDITIONAL([DTLS_ENABLED], [test "${enable_dtls}" = "yes"])
AC_SUBST([SSL_CFLAGS])
AC_SUBST([SSL_LIBS])
AC_SUBST([CONFIG_LIBS])
AC_SUBST([PTHREAD_LIBS])
#
AC_CONFIG_FILES([
Makefile
lib/Makefile
src/Makefile
build/Makefile
build/ac/Makefile
build/wtp/Makefile
])
AC_OUTPUT

View File

@ -1,35 +0,0 @@
FROM ubuntu:16.04
# we would love to use alpine as the build-image
# but unfortunately lede-build still fails with
# it when build some host-utils.
ARG LEDE_REVISION=e9c517772cee8af63b4ef173a28152645a4e1b05
ARG FREEWTP_REVISION=a4fed97ebafbfb07ded50e102be4a46fc9ac7cf3
RUN apt-get -y update && apt-get -y install \
build-essential \
python unzip gawk wget openssl git-core subversion \
libssl-dev ncurses-dev
RUN mkdir /build
WORKDIR /build
RUN cd /build ; \
git clone https://git.lede-project.org/source.git lede ; \
cd lede ; git checkout -b docker_build $LEDE_REVISION
RUN cd /build ; \
git clone https://github.com/travelping/freewtp ; \
cd freewtp ; git checkout -b docker_build $FREEWTP_REVISION
RUN cp /build/lede/feeds.conf.default /build/lede/feeds.conf ; echo "src-link freewtp /build/freewtp/openwrt" >> /build/lede/feeds.conf
RUN cd /build/lede ; ./scripts/feeds update -a && ./scripts/feeds install -a && ./scripts/feeds list -r freewtp
RUN cp -v /build/freewtp/openwrt/mac80211_patches/922-mac80211_packet_tunnel-linux-4.8.patch /build/lede/package/kernel/mac80211/patches/
RUN cd /build/lede ; patch -p1 -i /build/freewtp/openwrt/mac80211_patches/package-config-option.patch
ADD ./dot-lede-config /build/lede/.config
RUN cd /build/lede ; make defconfig
RUN cd /build/lede ; make -j10 BUILD_LOG=1 FORCE_UNSAFE_CONFIGURE=1 ; rm -rf staging_dir build_dir

View File

@ -1,46 +0,0 @@
CONFIG_IB=y
CONFIG_SDK=y
CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt7621=y
CONFIG_TARGET_ramips_mt7621_DEVICE_zbt-wg2626=y
CONFIG_PACKAGE_comgt=y
CONFIG_PACKAGE_comgt-directip=y
CONFIG_PACKAGE_comgt-ncm=y
CONFIG_PACKAGE_freewtp=y
CONFIG_PACKAGE_kmod-usb-acm=y
CONFIG_PACKAGE_kmod-usb-net=y
CONFIG_PACKAGE_kmod-usb-net-cdc-eem=y
CONFIG_PACKAGE_kmod-usb-net-cdc-ether=y
CONFIG_PACKAGE_kmod-usb-net-cdc-mbim=y
CONFIG_PACKAGE_kmod-usb-net-cdc-ncm=y
CONFIG_PACKAGE_kmod-usb-net-hso=y
CONFIG_PACKAGE_kmod-usb-net-huawei-cdc-ncm=y
CONFIG_PACKAGE_kmod-usb-net-qmi-wwan=y
CONFIG_PACKAGE_kmod-usb-net-sierrawireless=y
CONFIG_PACKAGE_kmod-usb-serial=y
CONFIG_PACKAGE_kmod-usb-serial-ipw=y
CONFIG_PACKAGE_kmod-usb-serial-option=y
CONFIG_PACKAGE_kmod-usb-serial-qualcomm=y
CONFIG_PACKAGE_kmod-usb-serial-sierrawireless=y
CONFIG_PACKAGE_kmod-usb-serial-wwan=y
CONFIG_PACKAGE_kmod-usb-wdm=y
CONFIG_PACKAGE_libustream-cyassl=y
CONFIG_PACKAGE_luci-app-freewtp=y
CONFIG_PACKAGE_luci-app-firewall=y
CONFIG_PACKAGE_luci-mod-admin-full=y
CONFIG_PACKAGE_luci-proto-3g=y
CONFIG_PACKAGE_luci-proto-ppp=y
CONFIG_PACKAGE_luci-theme-bootstrap=y
CONFIG_PACKAGE_libiwinfo-lua=y
CONFIG_PACKAGE_px5g-standalone=y
CONFIG_PACKAGE_smstools3=y
CONFIG_PACKAGE_uhttpd=y
CONFIG_PACKAGE_uhttpd-mod-lua=y
CONFIG_PACKAGE_uhttpd-mod-tls=y
CONFIG_PACKAGE_uhttpd-mod-tls_cyassl=y
CONFIG_PACKAGE_umbim=y
CONFIG_PACKAGE_uqmi=y
CONFIG_PACKAGE_usb-modeswitch=y
CONFIG_PACKAGE_usbreset=y
CONFIG_PACKAGE_usbutils=y
CONFIG_PACKAGE_wwan=y

View File

@ -1,10 +0,0 @@
#!/bin/sh
lede=$(git ls-remote https://git.lede-project.org/source.git | grep 'refs/heads/master$' | cut -f1)
freewtp=$(git ls-remote https://github.com/travelping/freewtp | grep 'refs/heads/master$' | cut -f1)
echo "found upstream ref to lede master: $lede"
echo "found upstream ref to freewtp master: $freewtp"
sed -i "s/^ARG LEDE_REVISION=.*$/ARG LEDE_REVISION=$lede/" Dockerfile
sed -i "s/^ARG FREEWTP_REVISION=.*$/ARG FREEWTP_REVISION=$freewtp/" Dockerfile

View File

@ -1,486 +0,0 @@
#if !defined(__CAPWAP_DRIVER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define __CAPWAP_DRIVER_TRACE_H
#include <linux/tracepoint.h>
#include <net/mac80211.h>
#include "capwap.h"
#undef TRACE_SYSTEM
#define TRACE_SYSTEM capwap
#define SESSION_ENTRY __array(char, sessionid, 16)
#define SESSION_ASSIGN ((session) ? memcpy(__entry->sessionid, &session->sessionid, 16) : memset(__entry->sessionid, 0, 16))
#define SESSION_PR_FMT " session:%16phN"
#define SESSION_PR_ARG __entry->sessionid
#define SESSIONID_ENTRY __array(char, sessionid, 16)
#define SESSIONID_ASSIGN ((sessionid) ? memcpy(__entry->sessionid, sessionid, 16) : memset(__entry->sessionid, 0, 16))
#define SESSIONID_PR_FMT " session:%16phN"
#define SESSIONID_PR_ARG __entry->sessionid
#define SKB_ENTRY __field(struct sk_buff *, skb)
#define SKB_ASSIGN __entry->skb = skb
#define SKB_PR_FMT " skb:%p"
#define SKB_PR_ARG __entry->skb
#define FRAGMENT_ENTRY __field(struct sc_capwap_fragment *, fragment)
#define FRAGMENT_ASSIGN __entry->fragment = fragment
#define FRAGMENT_PR_FMT " frag:%p"
#define FRAGMENT_PR_ARG __entry->fragment
#define BSSID_ENTRY __array(char, bssid, ETH_ALEN)
#define BSSID_ASSIGN (bssid ? memcpy(__entry->bssid, bssid, ETH_ALEN) : memset(__entry->bssid, 0, ETH_ALEN))
#define BSSID_PR_FMT " BSS:%pM"
#define BSSID_PR_ARG __entry->bssid
/* capwap.c */
TRACE_EVENT(sc_capwap_fragment_free,
TP_PROTO(struct sc_capwap_fragment *fragment),
TP_ARGS(fragment),
TP_STRUCT__entry(
FRAGMENT_ENTRY
),
TP_fast_assign(
FRAGMENT_ASSIGN;
),
TP_printk(FRAGMENT_PR_FMT, FRAGMENT_PR_ARG)
);
TRACE_EVENT(sc_capwap_freesession,
TP_PROTO(struct sc_capwap_session *session),
TP_ARGS(session),
TP_STRUCT__entry(
SESSION_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
),
TP_printk(SESSION_PR_FMT, SESSION_PR_ARG)
);
TRACE_EVENT(sc_capwap_defrag_evictor,
TP_PROTO(struct sc_capwap_session *session),
TP_ARGS(session),
TP_STRUCT__entry(
SESSION_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
),
TP_printk(SESSION_PR_FMT, SESSION_PR_ARG)
);
TRACE_EVENT(sc_capwap_defrag_evictor_fragment_expired,
TP_PROTO(struct sc_capwap_session *session,
struct sc_capwap_fragment *fragment,
ktime_t now),
TP_ARGS(session,
fragment,
now),
TP_STRUCT__entry(
SESSION_ENTRY
FRAGMENT_ENTRY
__field(u64, now)
__field(u64, tstamp)
),
TP_fast_assign(
SESSION_ASSIGN;
FRAGMENT_ASSIGN;
__entry->now = now.tv64;
__entry->tstamp = fragment->tstamp.tv64;
),
TP_printk(SESSION_PR_FMT FRAGMENT_PR_FMT " (%llu %llu)",
SESSION_PR_ARG, FRAGMENT_PR_ARG,
__entry->now,
__entry->tstamp
)
);
TRACE_EVENT(sc_capwap_reasm,
TP_PROTO(struct sc_capwap_fragment *fragment),
TP_ARGS(fragment),
TP_STRUCT__entry(
FRAGMENT_ENTRY
),
TP_fast_assign(
FRAGMENT_ASSIGN;
),
TP_printk(FRAGMENT_PR_FMT, FRAGMENT_PR_ARG)
);
TRACE_EVENT(sc_capwap_defrag,
TP_PROTO(struct sc_capwap_session *session,
uint16_t id,
uint16_t offset,
uint16_t length),
TP_ARGS(session, id, offset, length),
TP_STRUCT__entry(
SESSION_ENTRY
__field(u16, id)
__field(u16, offset)
__field(u16, length)
),
TP_fast_assign(
SESSION_ASSIGN;
__entry->id = id;
__entry->offset = offset;
__entry->length = length;
),
TP_printk(
SESSION_PR_FMT " fragment id:%hu offset:%hu length:%hu",
SESSION_PR_ARG, __entry->id, __entry->offset, __entry->length
)
);
// TRACEKMOD("** *Fragment info: id %hu offset %hu length %hu\n", frag_id, cb->frag_offset, cb->frag_length);
TRACE_EVENT(sc_capwap_8023_to_80211,
TP_PROTO(struct sk_buff *skb, const uint8_t *bssid),
TP_ARGS(skb, bssid),
TP_STRUCT__entry(
SKB_ENTRY
BSSID_ENTRY
),
TP_fast_assign(
SKB_ASSIGN;
BSSID_ASSIGN;
),
TP_printk(
SKB_PR_FMT BSSID_PR_FMT,
SKB_PR_ARG, BSSID_PR_ARG
)
);
TRACE_EVENT(sc_capwap_80211_to_8023,
TP_PROTO(struct sk_buff *skb),
TP_ARGS(skb),
TP_STRUCT__entry(
SKB_ENTRY
),
TP_fast_assign(
SKB_ASSIGN;
),
TP_printk(SKB_PR_FMT, SKB_PR_ARG)
);
TRACE_EVENT(sc_capwap_create,
TP_PROTO(struct sc_capwap_session *session),
TP_ARGS(session),
TP_STRUCT__entry(
SESSION_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
),
TP_printk(SESSION_PR_FMT, SESSION_PR_ARG)
);
TRACE_EVENT(sc_capwap_close,
TP_PROTO(struct sc_capwap_session *session),
TP_ARGS(session),
TP_STRUCT__entry(
SESSION_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
),
TP_printk(SESSION_PR_FMT, SESSION_PR_ARG)
);
TRACE_EVENT(sc_capwap_newfragmentid,
TP_PROTO(struct sc_capwap_session *session),
TP_ARGS(session),
TP_STRUCT__entry(
SESSION_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
),
TP_printk(SESSION_PR_FMT, SESSION_PR_ARG)
);
TRACE_EVENT(sc_capwap_createkeepalive,
TP_PROTO(struct sc_capwap_sessionid_element *sessionid),
TP_ARGS(sessionid),
TP_STRUCT__entry(
SESSIONID_ENTRY
),
TP_fast_assign(
SESSIONID_ASSIGN;
),
TP_printk(SESSIONID_PR_FMT, SESSIONID_PR_ARG)
);
TRACE_EVENT(sc_capwap_parsingpacket,
TP_PROTO(struct sc_capwap_session *session,
struct sk_buff *skb),
TP_ARGS(session, skb),
TP_STRUCT__entry(
SESSION_ENTRY
SKB_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
SKB_ASSIGN;
),
TP_printk(
SESSION_PR_FMT SKB_PR_FMT,
SESSION_PR_ARG, SKB_PR_ARG
)
);
TRACE_EVENT(sc_capwap_forwarddata,
TP_PROTO(struct sc_capwap_session *session,
uint8_t radioid,
uint8_t binding,
struct sk_buff *skb,
uint32_t flags,
struct sc_capwap_radio_addr *radioaddr,
int radioaddrlength,
struct sc_capwap_wireless_information *winfo),
TP_ARGS(session, radioid, binding, skb, flags, radioaddr, radioaddrlength, winfo),
TP_STRUCT__entry(
SESSION_ENTRY
__field(u8, radioid)
__field(u8, binding)
SKB_ENTRY
__field(u32, flags)
__field(int, radioaddrlength)
__array(char, radioaddr, 8)
__field(u8, rssi)
__field(u8, snr)
__field(u16, rate)
),
TP_fast_assign(
SESSION_ASSIGN;
__entry->radioid = radioid;
__entry->binding = binding;
SKB_ASSIGN;
__entry->binding = flags;
__entry->radioaddrlength = radioaddrlength;
((radioaddrlength != 0 && radioaddr) ? memcpy(__entry->radioaddr, radioaddr, min(radioaddrlength, 8)) : memset(__entry->radioaddr, 0, 8));
__entry->rssi = (winfo) ? ((struct sc_capwap_ieee80211_frame_info *)(winfo))->rssi : 0;
__entry->snr = (winfo) ? ((struct sc_capwap_ieee80211_frame_info *)(winfo))->snr : 0;
__entry->rate = (winfo) ? ((struct sc_capwap_ieee80211_frame_info *)(winfo))->rate : 0;
),
TP_printk(
SESSION_PR_FMT " radio:%d binding:%d" SKB_PR_FMT
"radioaddr:%*phC rssid:%d snr:%d rate:%d",
SESSION_PR_ARG, __entry->radioid, __entry->binding, SKB_PR_ARG,
min(__entry->radioaddrlength, 8), __entry->radioaddr,
__entry->rssi, __entry->snr, __entry->rate
)
);
TRACE_EVENT(sc_capwap_setradiomacaddress,
TP_PROTO(uint8_t *bssid),
TP_ARGS(bssid),
TP_STRUCT__entry(
BSSID_ENTRY
),
TP_fast_assign(
BSSID_ASSIGN;
),
TP_printk(BSSID_PR_FMT, BSSID_PR_ARG)
);
TRACE_EVENT(sc_capwap_setwinfo_frameinfo,
TP_PROTO(uint8_t rssi,
uint8_t snr,
uint16_t rate),
TP_ARGS(rssi, snr, rate),
TP_STRUCT__entry(
__field(u8, rssi)
__field(u8, snr)
__field(u16, rate)
),
TP_fast_assign(
__entry->rssi = rssi;
__entry->snr = snr;
__entry->rate = rate;
),
TP_printk(
" rssid:%d snr:%d rate:%d",
__entry->rssi, __entry->snr, __entry->rate
)
);
TRACE_EVENT(sc_capwap_setwinfo_destwlans,
TP_PROTO(uint16_t wlanidbitmap),
TP_ARGS(wlanidbitmap),
TP_STRUCT__entry(
__field(u16, wlanidbitmap)
),
TP_fast_assign(
__entry->wlanidbitmap = wlanidbitmap;
),
TP_printk(" id:%04x", __entry->wlanidbitmap)
);
/* capwap_private.c */
TRACE_EVENT(sc_capwap_resetsession,
TP_PROTO(struct sc_capwap_session *session),
TP_ARGS(session),
TP_STRUCT__entry(
SESSION_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
),
TP_printk(SESSION_PR_FMT, SESSION_PR_ARG)
);
TRACE_EVENT(sc_capwap_sendkeepalive,
TP_PROTO(struct sc_capwap_session *session),
TP_ARGS(session),
TP_STRUCT__entry(
SESSION_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
),
TP_printk(SESSION_PR_FMT, SESSION_PR_ARG)
);
TRACE_EVENT(sc_capwap_send,
TP_PROTO(struct sc_capwap_session *session),
TP_ARGS(session),
TP_STRUCT__entry(
SESSION_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
),
TP_printk(SESSION_PR_FMT, SESSION_PR_ARG)
);
TRACE_EVENT(sc_send_80211,
TP_PROTO(struct sk_buff *skb, struct net_device *dev),
TP_ARGS(skb, dev),
TP_STRUCT__entry(
SKB_ENTRY
__array(char, dev_name, 32)
),
TP_fast_assign(
SKB_ASSIGN;
strlcpy(__entry->dev_name, dev->name, 32);
),
TP_printk(" %s" SKB_PR_FMT, __entry->dev_name, SKB_PR_ARG)
);
TRACE_EVENT(sc_capwap_parsingdatapacket,
TP_PROTO(struct sc_capwap_session *session,
struct sk_buff *skb),
TP_ARGS(session, skb),
TP_STRUCT__entry(
SESSION_ENTRY
SKB_ENTRY
),
TP_fast_assign(
SESSION_ASSIGN;
SKB_ASSIGN;
),
TP_printk(
SESSION_PR_FMT SKB_PR_FMT,
SESSION_PR_ARG, SKB_PR_ARG
)
);
#endif /* !__CAPWAP_DRIVER_TRACE_H || TRACE_HEADER_MULTI_READ */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE capwap-trace
#include <trace/define_trace.h>

View File

@ -1,222 +0,0 @@
# FreeWTP -- An Open Source CAPWAP WTP
#
# Copyright SmartCAPWAP (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
# Copyright FreeCAPWAP (C) 2016 Travelping GmbH <info@travelping.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING included with this
# distribution); if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
AM_CFLAGS = -std=gnu99 -D_GNU_SOURCE
if DTLS_ENABLED
AM_CFLAGS += $(WOLFSSL_CFLAGS)
endif
noinst_LTLIBRARIES = libcapwap.la
libcapwap_la_LIBADD = $(WOLFSSL_LDFLAGS)
libcapwap_la_SOURCES = \
capwap.c \
network.c \
protocol.c \
logging.c \
list.c \
array.c \
hash.c \
dtls.c \
dfa.c \
binding/ieee80211/ieee80211.c \
element.c \
element_acdescriptor.c \
element_acipv4list.c \
element_acipv6list.c \
element_acname.c \
element_acnamepriority.c \
element_actimestamp.c \
element_addmacacl.c \
element_addstation.c \
element_controlipv4.c \
element_controlipv6.c \
element_datatransferdata.c \
element_datatransfermode.c \
element_decrypterrorreport.c \
element_decrypterrorreportperiod.c \
element_deletemacacl.c \
element_deletestation.c \
element_discoverytype.c \
element_duplicateipv4.c \
element_duplicateipv6.c \
element_ecnsupport.c \
element_idletimeout.c \
element_imagedata.c \
element_imageidentifier.c \
element_imageinfo.c \
element_initdownload.c \
element_localipv4.c \
element_localipv6.c \
element_location.c \
element_maximumlength.c \
element_mtudiscovery.c \
element_radioadmstate.c \
element_radiooprstate.c \
element_resultcode.c \
element_returnedmessage.c \
element_sessionid.c \
element_statisticstimer.c \
element_timers.c \
element_transport.c \
element_vendorpayload.c \
element_wtpboarddata.c \
element_wtpdescriptor.c \
element_wtpfallback.c \
element_wtpframetunnelmode.c \
element_wtpmactype.c \
element_wtpname.c \
element_wtpradiostat.c \
element_wtprebootstat.c \
element_wtpstaticipaddress.c \
element_80211_addwlan.c \
element_80211_antenna.c \
element_80211_assignbssid.c \
element_80211_deletewlan.c \
element_80211_directsequencecontrol.c \
element_80211_ie.c \
element_80211_mac_profile.c \
element_80211_macoperation.c \
element_80211_miccountermeasures.c \
element_80211_multidomaincapability.c \
element_80211_ofdmcontrol.c \
element_80211_rateset.c \
element_80211_rsnaerrorreport.c \
element_80211_station.c \
element_80211_stationkey.c \
element_80211_stationqos.c \
element_80211_statistics.c \
element_80211_supported_mac_profiles.c \
element_80211_supportedrates.c \
element_80211_txpower.c \
element_80211_txpowerlevel.c \
element_80211_updatestationqos.c \
element_80211_updatewlan.c \
element_80211_wtpqos.c \
element_80211_wtpradioconf.c \
element_80211_wtpradiofailalarm.c \
element_80211_wtpradioinformation.c \
element_80211n_radioconf.c \
element_80211n_station_information.c \
element_vendor_travelping_wtp_timestamp.c \
element_vendor_travelping_80211_encryption_capability.c \
element_vendor_travelping_80211_update_key.c
noinst_HEADERS = \
error.h \
rfc.h \
capwap.h \
network.h \
protocol.h \
logging.h \
list.h \
array.h \
hash.h \
dtls.h \
capwap_dfa.h \
binding/ieee80211/ieee80211.c \
element.h \
element_acdescriptor.h \
element_acipv4list.h \
element_acipv6list.h \
element_acname.h \
element_acnamepriority.h \
element_actimestamp.h \
element_addmacacl.h \
element_addstation.h \
element_controlipv4.h \
element_controlipv6.h \
element_datatransferdata.h \
element_datatransfermode.h \
element_decrypterrorreport.h \
element_decrypterrorreportperiod.h \
element_deletemacacl.h \
element_deletestation.h \
element_discoverytype.h \
element_duplicateipv4.h \
element_duplicateipv6.h \
element_ecnsupport.h \
element_idletimeout.h \
element_imagedata.h \
element_imageidentifier.h \
element_imageinfo.h \
element_initdownload.h \
element_localipv4.h \
element_localipv6.h \
element_location.h \
element_maximumlength.h \
element_mtudiscovery.h \
element_radioadmstate.h \
element_radiooprstate.h \
element_resultcode.h \
element_returnedmessage.h \
element_sessionid.h \
element_statisticstimer.h \
element_timers.h \
element_transport.h \
element_vendorpayload.h \
element_wtpboarddata.h \
element_wtpdescriptor.h \
element_wtpfallback.h \
element_wtpframetunnelmode.h \
element_wtpmactype.h \
element_wtpname.h \
element_wtpradiostat.h \
element_wtprebootstat.h \
element_wtpstaticipaddress.h \
element_80211_addwlan.h \
element_80211_antenna.h \
element_80211_assignbssid.h \
element_80211_deletewlan.h \
element_80211_directsequencecontrol.h \
element_80211_ie.h \
element_80211_macoperation.h \
element_80211_mac_profile.h \
element_80211_miccountermeasures.h \
element_80211_multidomaincapability.h \
element_80211_ofdmcontrol.h \
element_80211_rateset.h \
element_80211_rsnaerrorreport.h \
element_80211_station.h \
element_80211_stationkey.h \
element_80211_stationqos.h \
element_80211_statistics.h \
element_80211_supported_mac_profiles.h \
element_80211_supportedrates.h \
element_80211_txpower.h \
element_80211_txpowerlevel.h \
element_80211_updatestationqos.h \
element_80211_updatewlan.h \
element_80211_wtpqos.h \
element_80211_wtpradioconf.h \
element_80211_wtpradiofailalarm.h \
element_80211_wtpradioinformation.h \
element_80211n_radioconf.h \
element_80211n_station_information.h \
element_vendor_travelping_wtp_timestamp.h \
element_vendor_travelping_80211_encryption_capability.h \
element_vendor_travelping_80211_update_key.h \
vendor_travelping.h
if DEBUG_BUILD
libcapwap_la_SOURCES += debug.c
noinst_HEADERS += debug.h
endif

View File

@ -1,169 +0,0 @@
#ifndef __CAPWAP_ELEMENT_HEADER__
#define __CAPWAP_ELEMENT_HEADER__
#include "array.h"
#include "list.h"
struct capwap_message_element_id
{
uint32_t vendor;
uint16_t type;
};
#define message_element_id_eq(a, b) \
(((a).vendor == (b).vendor) && ((a).type == (b).type))
/* */
typedef void* capwap_message_elements_handle;
struct capwap_write_message_elements_ops {
int (*write_u8)(capwap_message_elements_handle handle, uint8_t data);
int (*write_u16)(capwap_message_elements_handle handle, uint16_t data);
int (*write_u32)(capwap_message_elements_handle handle, uint32_t data);
int (*write_block)(capwap_message_elements_handle handle, const uint8_t* data, unsigned short length);
};
struct capwap_read_message_elements_ops {
unsigned short (*read_ready)(capwap_message_elements_handle handle);
int (*read_u8)(capwap_message_elements_handle handle, uint8_t* data);
int (*read_u16)(capwap_message_elements_handle handle, uint16_t* data);
int (*read_u32)(capwap_message_elements_handle handle, uint32_t* data);
int (*read_block)(capwap_message_elements_handle handle, uint8_t* data, unsigned short length);
};
struct capwap_message_elements_ops
{
int category;
/* Build message element */
void (*create)(void* data, capwap_message_elements_handle handle, struct capwap_write_message_elements_ops* func);
/* Parsing message element */
void* (*parse)(capwap_message_elements_handle handle, struct capwap_read_message_elements_ops* func);
/* Memory management */
void* (*clone)(void*);
void (*free)(void*);
};
const struct capwap_message_elements_ops *capwap_get_message_element_ops(const struct capwap_message_element_id id);
/*********************************************************************************************************************/
/* Standard message elements */
#include "element_acdescriptor.h" /* 00001 */
#include "element_acipv4list.h" /* 00002 */
#include "element_acipv6list.h" /* 00003 */
#include "element_acname.h" /* 00004 */
#include "element_acnamepriority.h" /* 00005 */
#include "element_actimestamp.h" /* 00006 */
#include "element_addmacacl.h" /* 00007 */
#include "element_addstation.h" /* 00008 */
/* Reserved */ /* 00009 */
#include "element_controlipv4.h" /* 00010 */
#include "element_controlipv6.h" /* 00011 */
#include "element_timers.h" /* 00012 */
#include "element_datatransferdata.h" /* 00013 */
#include "element_datatransfermode.h" /* 00014 */
#include "element_decrypterrorreport.h" /* 00015 */
#include "element_decrypterrorreportperiod.h" /* 00016 */
#include "element_deletemacacl.h" /* 00017 */
#include "element_deletestation.h" /* 00018 */
/* Reserved */ /* 00019 */
#include "element_discoverytype.h" /* 00020 */
#include "element_duplicateipv4.h" /* 00021 */
#include "element_duplicateipv6.h" /* 00022 */
#include "element_idletimeout.h" /* 00023 */
#include "element_imagedata.h" /* 00024 */
#include "element_imageidentifier.h" /* 00025 */
#include "element_imageinfo.h" /* 00026 */
#include "element_initdownload.h" /* 00027 */
#include "element_location.h" /* 00028 */
#include "element_maximumlength.h" /* 00029 */
#include "element_localipv4.h" /* 00030 */
#include "element_radioadmstate.h" /* 00031 */
#include "element_radiooprstate.h" /* 00032 */
#include "element_resultcode.h" /* 00033 */
#include "element_returnedmessage.h" /* 00034 */
#include "element_sessionid.h" /* 00035 */
#include "element_statisticstimer.h" /* 00036 */
#include "element_vendorpayload.h" /* 00037 */
#include "element_wtpboarddata.h" /* 00038 */
#include "element_wtpdescriptor.h" /* 00039 */
#include "element_wtpfallback.h" /* 00040 */
#include "element_wtpframetunnelmode.h" /* 00041 */
/* Reserved */ /* 00042 */
/* Reserved */ /* 00043 */
#include "element_wtpmactype.h" /* 00044 */
#include "element_wtpname.h" /* 00045 */
/* Reserved */ /* 00046 */
#include "element_wtpradiostat.h" /* 00047 */
#include "element_wtprebootstat.h" /* 00048 */
#include "element_wtpstaticipaddress.h" /* 00049 */
#include "element_localipv6.h" /* 00050 */
#include "element_transport.h" /* 00051 */
#include "element_mtudiscovery.h" /* 00052 */
#include "element_ecnsupport.h" /* 00053 */
/* IEEE 802.11 message elements */
#include "element_80211_addwlan.h" /* 01024 */
#include "element_80211_antenna.h" /* 01025 */
#include "element_80211_assignbssid.h" /* 01026 */
#include "element_80211_deletewlan.h" /* 01027 */
#include "element_80211_directsequencecontrol.h" /* 01028 */
#include "element_80211_ie.h" /* 01029 */
#include "element_80211_macoperation.h" /* 01030 */
#include "element_80211_miccountermeasures.h" /* 01031 */
#include "element_80211_multidomaincapability.h" /* 01032 */
#include "element_80211_ofdmcontrol.h" /* 01033 */
#include "element_80211_rateset.h" /* 01034 */
#include "element_80211_rsnaerrorreport.h" /* 01035 */
#include "element_80211_station.h" /* 01036 */
#include "element_80211_stationqos.h" /* 01037 */
#include "element_80211_stationkey.h" /* 01038 */
#include "element_80211_statistics.h" /* 01039 */
#include "element_80211_supportedrates.h" /* 01040 */
#include "element_80211_txpower.h" /* 01041 */
#include "element_80211_txpowerlevel.h" /* 01042 */
#include "element_80211_updatestationqos.h" /* 01043 */
#include "element_80211_updatewlan.h" /* 01044 */
#include "element_80211_wtpqos.h" /* 01045 */
#include "element_80211_wtpradioconf.h" /* 01046 */
#include "element_80211_wtpradiofailalarm.h" /* 01047 */
#include "element_80211_wtpradioinformation.h" /* 01048 */
#include "element_80211_supported_mac_profiles.h" /* 01060 */
#include "element_80211_mac_profile.h" /* 01061 */
#include "vendor_travelping.h"
/*********************************************************************************************************************/
#define CAPWAP_MESSAGE_ELEMENT_SINGLE 0
#define CAPWAP_MESSAGE_ELEMENT_ARRAY 1
int capwap_get_message_element_category(uint16_t type);
struct capwap_message_element_itemlist
{
struct capwap_message_element_id id;
int category;
void* data;
};
struct capwap_parsed_packet {
struct capwap_packet_rxmng* rxmngpacket;
struct capwap_list* messages;
};
/* */
#define PARSING_COMPLETE 0
#define UNRECOGNIZED_MESSAGE_ELEMENT 1
#define INVALID_MESSAGE_ELEMENT 2
int capwap_parsing_packet(struct capwap_packet_rxmng* rxmngpacket, struct capwap_parsed_packet* packet);
int capwap_validate_parsed_packet(struct capwap_parsed_packet* packet, struct capwap_array* returnedmessage);
void capwap_free_parsed_packet(struct capwap_parsed_packet* packet);
struct capwap_list_item *capwap_get_message_element(struct capwap_parsed_packet *packet,
const struct capwap_message_element_id id);
void *capwap_get_message_element_data(struct capwap_parsed_packet *packet,
const struct capwap_message_element_id id);
#endif /* __CAPWAP_ELEMENT_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_ASSIGN_BSSID_HEADER__
#define __CAPWAP_ELEMENT_80211_ASSIGN_BSSID_HEADER__
#define CAPWAP_ELEMENT_80211_ASSIGN_BSSID_VENDOR 0
#define CAPWAP_ELEMENT_80211_ASSIGN_BSSID_TYPE 1026
#define CAPWAP_ELEMENT_80211_ASSIGN_BSSID (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_ASSIGN_BSSID_VENDOR, .type = CAPWAP_ELEMENT_80211_ASSIGN_BSSID_TYPE }
struct capwap_80211_assignbssid_element {
uint8_t radioid;
uint8_t wlanid;
uint8_t bssid[MACADDRESS_EUI48_LENGTH];
};
extern const struct capwap_message_elements_ops capwap_element_80211_assignbssid_ops;
#endif /* __CAPWAP_ELEMENT_80211_ASSIGN_BSSID_HEADER__ */

View File

@ -1,16 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_DELETE_WLAN_HEADER__
#define __CAPWAP_ELEMENT_80211_DELETE_WLAN_HEADER__
#define CAPWAP_ELEMENT_80211_DELETE_WLAN_VENDOR 0
#define CAPWAP_ELEMENT_80211_DELETE_WLAN_TYPE 1027
#define CAPWAP_ELEMENT_80211_DELETE_WLAN (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_DELETE_WLAN_VENDOR, .type = CAPWAP_ELEMENT_80211_DELETE_WLAN_TYPE }
struct capwap_80211_deletewlan_element {
uint8_t radioid;
uint8_t wlanid;
};
extern const struct capwap_message_elements_ops capwap_element_80211_deletewlan_ops;
#endif /* __CAPWAP_ELEMENT_80211_DELETE_WLAN_HEADER__ */

View File

@ -1,89 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
* The IEEE 802.11 MAC Profile message element allows the AC to select a
* profile. This message element may be provided along with the IEEE
* 802.11 ADD WLAN message element while configuring a WLAN on the WTP.
*
* 0 1 2 3 4 5 6 7
* +=+-+-+-+-+-+-+-+
* | Profile |
* +-+-+-+-+-+-+-+-+
*
* o Type: 1061 for IEEE 802.11 MAC Profile
*
* o Profile: The profile is identified by a value as given below
*
* * 0: This refers to the IEEE 802.11 Split MAC Profile with WTP
* encryption
*
* * 1: This refers to the IEEE 802.11 Split MAC Profile with AC
* encryption
*/
/* */
static void
capwap_80211_mac_profile_element_create(void *data, capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops *func)
{
struct capwap_80211_mac_profile_element *element =
(struct capwap_80211_mac_profile_element*)data;
ASSERT(data != NULL);
func->write_u8(handle, element->mac_profile);
}
/* */
static void *
capwap_80211_mac_profile_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
unsigned short length;
struct capwap_80211_mac_profile_element *data;
ASSERT(handle != NULL);
ASSERT(func != NULL);
length = func->read_ready(handle);
if (length != 1) {
log_printf(LOG_DEBUG, "Invalid IEEE 802.11 Supported MAC Profiles element");
return NULL;
}
/* */
data = (struct capwap_80211_mac_profile_element *)
capwap_alloc(sizeof(struct capwap_80211_mac_profile_element));
memset(data, 0, sizeof(struct capwap_80211_mac_profile_element));
/* Retrieve data */
func->read_u8(handle, &data->mac_profile);
return data;
}
/* */
static void *capwap_80211_mac_profile_element_clone(void *data)
{
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_80211_mac_profile_element));
}
/* */
static void capwap_80211_mac_profile_element_free(void *data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
const struct capwap_message_elements_ops capwap_element_80211_mac_profile_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_SINGLE,
.create = capwap_80211_mac_profile_element_create,
.parse = capwap_80211_mac_profile_element_parsing,
.clone = capwap_80211_mac_profile_element_clone,
.free = capwap_80211_mac_profile_element_free
};

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_MAC_PROFILE_HEADER__
#define __CAPWAP_ELEMENT_80211_MAC_PROFILE_HEADER__
#define CAPWAP_ELEMENT_80211_MAC_PROFILE_VENDOR 0
#define CAPWAP_ELEMENT_80211_MAC_PROFILE_TYPE 1061
#define CAPWAP_ELEMENT_80211_MAC_PROFILE \
(struct capwap_message_element_id) { \
.vendor = CAPWAP_ELEMENT_80211_MAC_PROFILE_VENDOR, \
.type = CAPWAP_ELEMENT_80211_MAC_PROFILE_TYPE \
}
struct capwap_80211_mac_profile_element {
uint8_t mac_profile;
};
extern const struct capwap_message_elements_ops capwap_element_80211_mac_profile_ops;
#endif /* __CAPWAP_ELEMENT_80211_MAC_PROFILE_HEADER__ */

View File

@ -1,21 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_MACOPERATION_HEADER__
#define __CAPWAP_ELEMENT_80211_MACOPERATION_HEADER__
#define CAPWAP_ELEMENT_80211_MACOPERATION_VENDOR 0
#define CAPWAP_ELEMENT_80211_MACOPERATION_TYPE 1030
#define CAPWAP_ELEMENT_80211_MACOPERATION (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_MACOPERATION_VENDOR, .type = CAPWAP_ELEMENT_80211_MACOPERATION_TYPE }
struct capwap_80211_macoperation_element {
uint8_t radioid;
uint16_t rtsthreshold;
uint8_t shortretry;
uint8_t longretry;
uint16_t fragthreshold;
uint32_t txmsdulifetime;
uint32_t rxmsdulifetime;
};
extern const struct capwap_message_elements_ops capwap_element_80211_macoperation_ops;
#endif /* __CAPWAP_ELEMENT_80211_MACOPERATION_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES_HEADER__
#define __CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES_HEADER__
#define CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES_VENDOR 0
#define CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES_TYPE 1031
#define CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES_VENDOR, .type = CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES_TYPE }
struct capwap_80211_miccountermeasures_element {
uint8_t radioid;
uint8_t wlanid;
uint8_t address[MACADDRESS_EUI48_LENGTH];
};
extern const struct capwap_message_elements_ops capwap_element_80211_miccountermeasures_ops;
#endif /* __CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY_HEADER__
#define __CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY_HEADER__
#define CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY_VENDOR 0
#define CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY_TYPE 1032
#define CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY_VENDOR, .type = CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY_TYPE }
struct capwap_80211_multidomaincapability_element {
uint8_t radioid;
uint16_t firstchannel;
uint16_t numberchannels;
uint16_t maxtxpowerlevel;
};
extern const struct capwap_message_elements_ops capwap_element_80211_multidomaincapability_ops;
#endif /* __CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY_HEADER__ */

View File

@ -1,16 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE_HEADER__
#define __CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE_HEADER__
#define CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE_VENDOR 0
#define CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE_TYPE 1037
#define CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE_VENDOR, .type = CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE_TYPE }
struct capwap_80211_stationqos_element {
uint8_t address[MACADDRESS_EUI48_LENGTH];
uint8_t priority;
};
extern const struct capwap_message_elements_ops capwap_element_80211_stationqos_ops;
#endif /* __CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE_HEADER__ */

View File

@ -1,102 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
* The IEEE 802.11 Supported MAC Profile message element allows the WTP
* to communicate the profiles it supports. The Discovery Request
* message, Primary Discovery Request message, and Join Request message
* may include one such message element.
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0
* +=+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
* | Num_Profiles | Profile_1 | Profile_[2..N]..
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
*
* o Type: 1060 for IEEE 802.11 Supported MAC Profiles
*
* o Num_Profiles >=1: This refers to the number of profiles present in
* this message element. There must be at least one profile.
*
* o Profile: Each profile is identified by a value specified in
* Section 3.2.
*/
/* */
static void
capwap_80211_supported_mac_profiles_element_create(void *data, capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops *func)
{
struct capwap_80211_supported_mac_profiles_element *element =
(struct capwap_80211_supported_mac_profiles_element*)data;
ASSERT(data != NULL);
func->write_u8(handle, element->supported_mac_profilescount);
func->write_block(handle, element->supported_mac_profiles, element->supported_mac_profilescount);
}
/* */
static void *
capwap_80211_supported_mac_profiles_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
unsigned short length;
struct capwap_80211_supported_mac_profiles_element *data;
ASSERT(handle != NULL);
ASSERT(func != NULL);
length = func->read_ready(handle);
if (length < 1 || length > 255) {
log_printf(LOG_DEBUG, "Invalid IEEE 802.11 Supported MAC Profiles element");
return NULL;
}
length -= 1;
/* */
data = (struct capwap_80211_supported_mac_profiles_element *)
capwap_alloc(sizeof(struct capwap_80211_supported_mac_profiles_element) + length);
memset(data, 0, sizeof(struct capwap_80211_supported_mac_profiles_element) + length);
/* Retrieve data */
func->read_u8(handle, &data->supported_mac_profilescount);
if (data->supported_mac_profilescount != length) {
log_printf(LOG_DEBUG, "Invalid IEEE 802.11 Supported MAC Profiles element");
capwap_free(data);
return NULL;
}
func->read_block(handle, data->supported_mac_profiles, length);
return data;
}
/* */
static void *capwap_80211_supported_mac_profiles_element_clone(void *data)
{
struct capwap_80211_supported_mac_profiles_element *element =
(struct capwap_80211_supported_mac_profiles_element*)data;
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_80211_supported_mac_profiles_element)
+ element->supported_mac_profilescount);
}
/* */
static void capwap_80211_supported_mac_profiles_element_free(void *data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
const struct capwap_message_elements_ops capwap_element_80211_supported_mac_profiles_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_SINGLE,
.create = capwap_80211_supported_mac_profiles_element_create,
.parse = capwap_80211_supported_mac_profiles_element_parsing,
.clone = capwap_80211_supported_mac_profiles_element_clone,
.free = capwap_80211_supported_mac_profiles_element_free
};

View File

@ -1,20 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_SUPPORTED_MAC_PROFILES_HEADER__
#define __CAPWAP_ELEMENT_80211_SUPPORTED_MAC_PROFILES_HEADER__
#define CAPWAP_ELEMENT_80211_SUPPORTED_MAC_PROFILES_VENDOR 0
#define CAPWAP_ELEMENT_80211_SUPPORTED_MAC_PROFILES_TYPE 1060
#define CAPWAP_ELEMENT_80211_SUPPORTED_MAC_PROFILES \
(struct capwap_message_element_id) { \
.vendor = CAPWAP_ELEMENT_80211_SUPPORTED_MAC_PROFILES_VENDOR, \
.type = CAPWAP_ELEMENT_80211_SUPPORTED_MAC_PROFILES_TYPE \
}
struct capwap_80211_supported_mac_profiles_element {
uint8_t supported_mac_profilescount;
uint8_t supported_mac_profiles[];
};
extern const struct capwap_message_elements_ops capwap_element_80211_supported_mac_profiles_ops;
#endif /* __CAPWAP_ELEMENT_80211_SUPPORTED_MAC_PROFILES_HEADER__ */

View File

@ -1,16 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_TXPOWER_HEADER__
#define __CAPWAP_ELEMENT_80211_TXPOWER_HEADER__
#define CAPWAP_ELEMENT_80211_TXPOWER_VENDOR 0
#define CAPWAP_ELEMENT_80211_TXPOWER_TYPE 1041
#define CAPWAP_ELEMENT_80211_TXPOWER (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_TXPOWER_VENDOR, .type = CAPWAP_ELEMENT_80211_TXPOWER_TYPE }
struct capwap_80211_txpower_element {
uint8_t radioid;
uint16_t currenttxpower;
};
extern const struct capwap_message_elements_ops capwap_element_80211_txpower_ops;
#endif /* __CAPWAP_ELEMENT_80211_TXPOWER_HEADER__ */

View File

@ -1,19 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_TXPOWERLEVEL_HEADER__
#define __CAPWAP_ELEMENT_80211_TXPOWERLEVEL_HEADER__
#define CAPWAP_ELEMENT_80211_TXPOWERLEVEL_VENDOR 0
#define CAPWAP_ELEMENT_80211_TXPOWERLEVEL_TYPE 1042
#define CAPWAP_ELEMENT_80211_TXPOWERLEVEL (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_TXPOWERLEVEL_VENDOR, .type = CAPWAP_ELEMENT_80211_TXPOWERLEVEL_TYPE }
#define CAPWAP_TXPOWERLEVEL_MAXLENGTH 8
struct capwap_80211_txpowerlevel_element {
uint8_t radioid;
uint8_t numlevels;
uint16_t powerlevel[CAPWAP_TXPOWERLEVEL_MAXLENGTH];
};
extern const struct capwap_message_elements_ops capwap_element_80211_txpowerlevel_ops;
#endif /* __CAPWAP_ELEMENT_80211_TXPOWERLEVEL_HEADER__ */

View File

@ -1,21 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM_HEADER__
#define __CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM_HEADER__
#define CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM_VENDOR 0
#define CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM_TYPE 1047
#define CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM_VENDOR, .type = CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM_TYPE }
#define CAPWAP_WTP_RADIO_FAIL_ALARM_TYPE_RECEIVER 1
#define CAPWAP_WTP_RADIO_FAIL_ALARM_TYPE_TRANSMITTER 2
struct capwap_80211_wtpradiofailalarm_element {
uint8_t radioid;
uint8_t type;
uint8_t status;
uint8_t pad;
};
extern const struct capwap_message_elements_ops capwap_element_80211_wtpradiofailalarm_ops;
#endif /* __CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM_HEADER__ */

View File

@ -1,93 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Radio ID |S|P|N|G|B| | MaxSup MCS | Max MandMCS |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | TxAntenna | RxAntenna | Reserved |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Type: TBD1 for IEEE 802.11n WLAN Radio Configuration
*
*/
/* */
static void
capwap_80211n_radioconf_element_create(void *data,
capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops *func)
{
struct capwap_80211n_radioconf_element *element = (struct capwap_80211n_radioconf_element *)data;
ASSERT(data != NULL);
func->write_u8(handle, element->radioid);
func->write_u8(handle, element->flags & CAPWAP_80211N_RADIO_CONF_MASK);
func->write_u8(handle, element->maxsupmcs);
func->write_u8(handle, element->maxmandmcs);
func->write_u8(handle, element->txant);
func->write_u8(handle, element->rxant);
func->write_u16(handle, 0);
}
/* */
static void *
capwap_80211n_radioconf_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
struct capwap_80211n_radioconf_element *data;
uint16_t reserved;
ASSERT(handle != NULL);
ASSERT(func != NULL);
if (func->read_ready(handle) != 8) {
log_printf(LOG_DEBUG, "Invalid IEEE 802.11n Radio Configuration element");
return NULL;
}
/* */
data = (struct capwap_80211n_radioconf_element*)capwap_alloc(sizeof(struct capwap_80211n_radioconf_element));
memset(data, 0, sizeof(struct capwap_80211n_radioconf_element));
/* Retrieve data */
func->read_u8(handle, &data->radioid);
func->read_u8(handle, &data->flags);
func->read_u8(handle, &data->maxsupmcs);
func->read_u8(handle, &data->maxmandmcs);
func->read_u8(handle, &data->txant);
func->read_u8(handle, &data->rxant);
func->read_u16(handle, &reserved);
return data;
}
/* */
static void *
capwap_80211n_radioconf_element_clone(void *data)
{
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_80211n_radioconf_element));
}
/* */
static void
capwap_80211n_radioconf_element_free(void* data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
const struct capwap_message_elements_ops capwap_element_80211n_radioconf_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_ARRAY,
.create = capwap_80211n_radioconf_element_create,
.parse = capwap_80211n_radioconf_element_parsing,
.clone = capwap_80211n_radioconf_element_clone,
.free = capwap_80211n_radioconf_element_free
};

View File

@ -1,28 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211N_RADIO_CONF_HEADER__
#define __CAPWAP_ELEMENT_80211N_RADIO_CONF_HEADER__
#define CAPWAP_ELEMENT_80211N_RADIO_CONF_VENDOR CAPWAP_VENDOR_TRAVELPING_ID
#define CAPWAP_ELEMENT_80211N_RADIO_CONF_TYPE 16
#define CAPWAP_ELEMENT_80211N_RADIO_CONF (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211N_RADIO_CONF_VENDOR, .type = CAPWAP_ELEMENT_80211N_RADIO_CONF_TYPE }
#define CAPWAP_80211N_RADIO_CONF_A_MSDU (1 << 7)
#define CAPWAP_80211N_RADIO_CONF_A_MPDU (1 << 6)
#define CAPWAP_80211N_RADIO_CONF_11N_ONLY (1 << 5)
#define CAPWAP_80211N_RADIO_CONF_SHORT_GUARD_INTERVAL (1 << 4)
#define CAPWAP_80211N_RADIO_CONF_20MHZ_BANDWITH (1 << 3)
#define CAPWAP_80211N_RADIO_CONF_MASK 0xF8
struct capwap_80211n_radioconf_element {
uint8_t radioid;
uint8_t flags;
uint8_t maxsupmcs;
uint8_t maxmandmcs;
uint8_t txant;
uint8_t rxant;
};
extern const struct capwap_message_elements_ops capwap_element_80211n_radioconf_ops;
#endif /* __CAPWAP_ELEMENT_80211N_RADIO_CONF_HEADER__ */

View File

@ -1,102 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | MAC Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | MAC Address |S| P |T|F|H|M| | Max RxFactor |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Min StaSpacing| HiSuppDataRate | AMPDUBufSize |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | AMPDUBufSize | HtcSupp | MCS Set |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | MCS Set |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | MCS Set |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Type: TBD2 for IEEE 802.11n Station Information
*
*/
/* */
static void
capwap_80211n_station_info_element_create(void *data,
capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops *func)
{
struct capwap_80211n_station_info_element *element = (struct capwap_80211n_station_info_element *)data;
ASSERT(data != NULL);
func->write_block(handle, element->address, MACADDRESS_EUI48_LENGTH);
func->write_u8(handle, element->flags);
func->write_u8(handle, element->maxrxfactor);
func->write_u8(handle, element->minstaspaceing);
func->write_u16(handle, element->hisuppdatarate);
func->write_u16(handle, element->ampdubufsize);
func->write_u8(handle, element->htcsupp);
func->write_block(handle, element->mcsset, MCS_SET_LENGTH);
}
/* */
static void *
capwap_80211n_station_info_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
struct capwap_80211n_station_info_element *data;
ASSERT(handle != NULL);
ASSERT(func != NULL);
if (func->read_ready(handle) != 24) {
log_printf(LOG_DEBUG, "Invalid IEEE 802.11n Station Information");
return NULL;
}
/* */
data = (struct capwap_80211n_station_info_element*)capwap_alloc(sizeof(struct capwap_80211n_station_info_element));
memset(data, 0, sizeof(struct capwap_80211n_station_info_element));
/* Retrieve data */
func->read_block(handle, data->address, MACADDRESS_EUI48_LENGTH);
func->read_u8(handle, &data->flags);
func->read_u8(handle, &data->maxrxfactor);
func->read_u8(handle, &data->minstaspaceing);
func->read_u16(handle, &data->hisuppdatarate);
func->read_u16(handle, &data->ampdubufsize);
func->read_u8(handle, &data->htcsupp);
func->read_block(handle, data->mcsset, MCS_SET_LENGTH);
return data;
}
/* */
static void *
capwap_80211n_station_info_element_clone(void *data)
{
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_80211n_station_info_element));
}
/* */
static void
capwap_80211n_station_info_element_free(void* data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
const struct capwap_message_elements_ops capwap_element_80211n_station_info_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_SINGLE,
.create = capwap_80211n_station_info_element_create,
.parse = capwap_80211n_station_info_element_parsing,
.clone = capwap_80211n_station_info_element_clone,
.free = capwap_80211n_station_info_element_free
};

View File

@ -1,32 +0,0 @@
#ifndef __CAPWAP_ELEMENT_80211N_STATION_INFO_HEADER__
#define __CAPWAP_ELEMENT_80211N_STATION_INFO_HEADER__
#define CAPWAP_ELEMENT_80211N_STATION_INFO_VENDOR CAPWAP_VENDOR_TRAVELPING_ID
#define CAPWAP_ELEMENT_80211N_STATION_INFO_TYPE 17
#define CAPWAP_ELEMENT_80211N_STATION_INFO (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_80211N_STATION_INFO_VENDOR, .type = CAPWAP_ELEMENT_80211N_STATION_INFO_TYPE }
#define CAPWAP_80211N_STATION_INFO_40MHZ_BANDWITH (1 << 7)
#define CAPWAP_80211N_STATION_INFO_POWER_SAVE_MODE ((1 << 6) | (1 << 5))
#define CAPWAP_80211N_STATION_INFO_POWER_SAVE_MODE_SHIFT 5
#define CAPWAP_80211N_STATION_INFO_SHORT_GUARD_INTERVAL_AT_20MHZ (1 << 4)
#define CAPWAP_80211N_STATION_INFO_SHORT_GUARD_INTERVAL_AT_40MHZ (1 << 3)
#define CAPWAP_80211N_STATION_INFO_BLOCK_ACK_DELAY_MODE (1 << 2)
#define CAPWAP_80211N_STATION_INFO_MAX_AMSDU_LENGTH_7935 (1 << 1)
#define MCS_SET_LENGTH 10
struct capwap_80211n_station_info_element {
uint8_t address[MACADDRESS_EUI48_LENGTH];
uint8_t flags;
uint8_t maxrxfactor;
uint8_t minstaspaceing;
uint16_t hisuppdatarate;
uint16_t ampdubufsize;
uint8_t htcsupp;
uint8_t mcsset[MCS_SET_LENGTH];
};
extern const struct capwap_message_elements_ops capwap_element_80211n_station_info_ops;
#endif /* __CAPWAP_ELEMENT_80211N_STATION_INFO_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_ACIPV4LIST_HEADER__
#define __CAPWAP_ELEMENT_ACIPV4LIST_HEADER__
#define CAPWAP_ELEMENT_ACIPV4LIST_VENDOR 0
#define CAPWAP_ELEMENT_ACIPV4LIST_TYPE 2
#define CAPWAP_ELEMENT_ACIPV4LIST (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_ACIPV4LIST_VENDOR, .type = CAPWAP_ELEMENT_ACIPV4LIST_TYPE }
#define CAPWAP_ACIPV4LIST_MAX_ELEMENTS 1024
struct capwap_acipv4list_element {
struct capwap_array* addresses;
};
extern const struct capwap_message_elements_ops capwap_element_acipv4list_ops;
#endif /* __CAPWAP_ELEMENT_ACIPV4LIST_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_ACIPV6LIST_HEADER__
#define __CAPWAP_ELEMENT_ACIPV6LIST_HEADER__
#define CAPWAP_ELEMENT_ACIPV6LIST_VENDOR 0
#define CAPWAP_ELEMENT_ACIPV6LIST_TYPE 3
#define CAPWAP_ELEMENT_ACIPV6LIST (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_ACIPV6LIST_VENDOR, .type = CAPWAP_ELEMENT_ACIPV6LIST_TYPE }
#define CAPWAP_ACIPV6LIST_MAX_ELEMENTS 1024
struct capwap_acipv6list_element {
struct capwap_array* addresses;
};
extern const struct capwap_message_elements_ops capwap_element_acipv6list_ops;
#endif /* __CAPWAP_ELEMENT_ACIPV6LIST_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_ACNAME_HEADER__
#define __CAPWAP_ELEMENT_ACNAME_HEADER__
#define CAPWAP_ELEMENT_ACNAME_VENDOR 0
#define CAPWAP_ELEMENT_ACNAME_TYPE 4
#define CAPWAP_ELEMENT_ACNAME (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_ACNAME_VENDOR, .type = CAPWAP_ELEMENT_ACNAME_TYPE }
#define CAPWAP_ACNAME_MAXLENGTH 512
struct capwap_acname_element {
uint8_t* name;
};
extern const struct capwap_message_elements_ops capwap_element_acname_ops;
#endif /* __CAPWAP_ELEMENT_ACNAME_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_ACNAMEPRIORITY_HEADER__
#define __CAPWAP_ELEMENT_ACNAMEPRIORITY_HEADER__
#define CAPWAP_ELEMENT_ACNAMEPRIORITY_VENDOR 0
#define CAPWAP_ELEMENT_ACNAMEPRIORITY_TYPE 5
#define CAPWAP_ELEMENT_ACNAMEPRIORITY (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_ACNAMEPRIORITY_VENDOR, .type = CAPWAP_ELEMENT_ACNAMEPRIORITY_TYPE }
#define CAPWAP_ACNAMEPRIORITY_MAXLENGTH 512
struct capwap_acnamepriority_element {
uint8_t priority;
uint8_t* name;
};
extern const struct capwap_message_elements_ops capwap_element_acnamepriority_ops;
#endif /* __CAPWAP_ELEMENT_ACNAMEPRIORITY_HEADER__ */

View File

@ -1,16 +0,0 @@
#ifndef __CAPWAP_ELEMENT_AC_TIMESTAMP_HEADER__
#define __CAPWAP_ELEMENT_AC_TIMESTAMP_HEADER__
#define CAPWAP_ELEMENT_ACTIMESTAMP_VENDOR 0
#define CAPWAP_ELEMENT_ACTIMESTAMP_TYPE 6
#define CAPWAP_ELEMENT_ACTIMESTAMP (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_ACTIMESTAMP_VENDOR, .type = CAPWAP_ELEMENT_ACTIMESTAMP_TYPE }
struct capwap_actimestamp_element {
uint32_t timestamp;
};
extern const struct capwap_message_elements_ops capwap_element_actimestamp_ops;
#endif /* __CAPWAP_ELEMENT_AC_TIMESTAMP_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_ADD_MAC_ACL__HEADER__
#define __CAPWAP_ELEMENT_ADD_MAC_ACL__HEADER__
#define CAPWAP_ELEMENT_ADDMACACL_VENDOR 0
#define CAPWAP_ELEMENT_ADDMACACL_TYPE 7
#define CAPWAP_ELEMENT_ADDMACACL (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_ADDMACACL_VENDOR, .type = CAPWAP_ELEMENT_ADDMACACL_TYPE }
struct capwap_addmacacl_element {
uint8_t entry;
uint8_t length;
uint8_t* address;
};
extern const struct capwap_message_elements_ops capwap_element_addmacacl_ops;
#endif /* __CAPWAP_ELEMENT_ADD_MAC_ACL__HEADER__ */

View File

@ -1,20 +0,0 @@
#ifndef __CAPWAP_ELEMENT_ADD_STATION__HEADER__
#define __CAPWAP_ELEMENT_ADD_STATION__HEADER__
#define CAPWAP_ELEMENT_ADDSTATION_VENDOR 0
#define CAPWAP_ELEMENT_ADDSTATION_TYPE 8
#define CAPWAP_ELEMENT_ADDSTATION (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_ADDSTATION_VENDOR, .type = CAPWAP_ELEMENT_ADDSTATION_TYPE }
#define CAPWAP_ADDSTATION_VLAN_MAX_LENGTH 512
struct capwap_addstation_element {
uint8_t radioid;
uint8_t length;
uint8_t* address;
uint8_t* vlan;
};
extern const struct capwap_message_elements_ops capwap_element_addstation_ops;
#endif /* __CAPWAP_ELEMENT_ADD_STATION__HEADER__ */

View File

@ -1,16 +0,0 @@
#ifndef __CAPWAP_ELEMENT_CONTROLIPV4_HEADER__
#define __CAPWAP_ELEMENT_CONTROLIPV4_HEADER__
#define CAPWAP_ELEMENT_CONTROLIPV4_VENDOR 0
#define CAPWAP_ELEMENT_CONTROLIPV4_TYPE 10
#define CAPWAP_ELEMENT_CONTROLIPV4 (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_CONTROLIPV4_VENDOR, .type = CAPWAP_ELEMENT_CONTROLIPV4_TYPE }
struct capwap_controlipv4_element {
struct in_addr address;
uint16_t wtpcount;
};
extern const struct capwap_message_elements_ops capwap_element_controlipv4_ops;
#endif /* __CAPWAP_ELEMENT_CONTROLIPV4_HEADER__ */

View File

@ -1,16 +0,0 @@
#ifndef __CAPWAP_ELEMENT_CONTROLIPV6_HEADER__
#define __CAPWAP_ELEMENT_CONTROLIPV6_HEADER__
#define CAPWAP_ELEMENT_CONTROLIPV6_VENDOR 0
#define CAPWAP_ELEMENT_CONTROLIPV6_TYPE 11
#define CAPWAP_ELEMENT_CONTROLIPV6 (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_CONTROLIPV6_VENDOR, .type = CAPWAP_ELEMENT_CONTROLIPV6_TYPE }
struct capwap_controlipv6_element {
struct in6_addr address;
unsigned short wtpcount;
};
extern const struct capwap_message_elements_ops capwap_element_controlipv6_ops;
#endif /* __CAPWAP_ELEMENT_CONTROLIPV4_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_DATA_TRANSFER_MODE_HEADER__
#define __CAPWAP_ELEMENT_DATA_TRANSFER_MODE_HEADER__
#define CAPWAP_ELEMENT_DATATRANSFERMODE_VENDOR 0
#define CAPWAP_ELEMENT_DATATRANSFERMODE_TYPE 14
#define CAPWAP_ELEMENT_DATATRANSFERMODE (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_DATATRANSFERMODE_VENDOR, .type = CAPWAP_ELEMENT_DATATRANSFERMODE_TYPE }
#define CAPWAP_DATATRANSFERMODE_MODE_CRASH_DUMP 1
#define CAPWAP_DATATRANSFERMODE_MODE_MEMORY_DUMP 2
struct capwap_datatransfermode_element {
uint8_t mode;
};
extern const struct capwap_message_elements_ops capwap_element_datatransfermode_ops;
#endif /* __CAPWAP_ELEMENT_DATA_TRANSFER_MODE_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_DECRYPT_ERROR_REPORT__HEADER__
#define __CAPWAP_ELEMENT_DECRYPT_ERROR_REPORT__HEADER__
#define CAPWAP_ELEMENT_DECRYPTERRORREPORT_VENDOR 0
#define CAPWAP_ELEMENT_DECRYPTERRORREPORT_TYPE 15
#define CAPWAP_ELEMENT_DECRYPTERRORREPORT (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_DECRYPTERRORREPORT_VENDOR, .type = CAPWAP_ELEMENT_DECRYPTERRORREPORT_TYPE }
struct capwap_decrypterrorreport_element {
uint8_t radioid;
uint8_t entry;
uint8_t length;
uint8_t* address;
};
extern const struct capwap_message_elements_ops capwap_element_decrypterrorreport_ops;
#endif /* __CAPWAP_ELEMENT_DECRYPT_ERROR_REPORT__HEADER__ */

View File

@ -1,16 +0,0 @@
#ifndef __CAPWAP_ELEMENT_DECRYPTERRORREPORTPERIOD_HEADER__
#define __CAPWAP_ELEMENT_DECRYPTERRORREPORTPERIOD_HEADER__
#define CAPWAP_ELEMENT_DECRYPTERRORREPORTPERIOD_VENDOR 0
#define CAPWAP_ELEMENT_DECRYPTERRORREPORTPERIOD_TYPE 16
#define CAPWAP_ELEMENT_DECRYPTERRORREPORTPERIOD (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_DECRYPTERRORREPORTPERIOD_VENDOR, .type = CAPWAP_ELEMENT_DECRYPTERRORREPORTPERIOD_TYPE }
struct capwap_decrypterrorreportperiod_element {
uint8_t radioid;
uint16_t interval;
};
extern const struct capwap_message_elements_ops capwap_element_decrypterrorreportperiod_ops;
#endif /* __CAPWAP_ELEMENT_DECRYPTERRORREPORTPERIOD_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_DELETE_MAC_ACL__HEADER__
#define __CAPWAP_ELEMENT_DELETE_MAC_ACL__HEADER__
#define CAPWAP_ELEMENT_DELETEMACACL_VENDOR 0
#define CAPWAP_ELEMENT_DELETEMACACL_TYPE 17
#define CAPWAP_ELEMENT_DELETEMACACL (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_DELETEMACACL_VENDOR, .type = CAPWAP_ELEMENT_DELETEMACACL_TYPE }
struct capwap_deletemacacl_element {
uint8_t entry;
uint8_t length;
uint8_t* address;
};
extern const struct capwap_message_elements_ops capwap_element_deletemacacl_ops;
#endif /* __CAPWAP_ELEMENT_DELETE_MAC_ACL__HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_DELETE_STATION__HEADER__
#define __CAPWAP_ELEMENT_DELETE_STATION__HEADER__
#define CAPWAP_ELEMENT_DELETESTATION_VENDOR 0
#define CAPWAP_ELEMENT_DELETESTATION_TYPE 18
#define CAPWAP_ELEMENT_DELETESTATION (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_DELETESTATION_VENDOR, .type = CAPWAP_ELEMENT_DELETESTATION_TYPE }
struct capwap_deletestation_element {
uint8_t radioid;
uint8_t length;
uint8_t* address;
};
extern const struct capwap_message_elements_ops capwap_element_deletestation_ops;
#endif /* __CAPWAP_ELEMENT_DELETE_STATION__HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_ECNSUPPORT_HEADER__
#define __CAPWAP_ELEMENT_ECNSUPPORT_HEADER__
#define CAPWAP_ELEMENT_ECNSUPPORT_VENDOR 0
#define CAPWAP_ELEMENT_ECNSUPPORT_TYPE 53
#define CAPWAP_ELEMENT_ECNSUPPORT (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_ECNSUPPORT_VENDOR, .type = CAPWAP_ELEMENT_ECNSUPPORT_TYPE }
#define CAPWAP_LIMITED_ECN_SUPPORT 0
#define CAPWAP_FULL_ECN_SUPPORT 1
struct capwap_ecnsupport_element {
uint8_t flag;
};
extern const struct capwap_message_elements_ops capwap_element_ecnsupport_ops;
#endif /* __CAPWAP_ELEMENT_ECNSUPPORT_HEADER__ */

View File

@ -1,15 +0,0 @@
#ifndef __CAPWAP_ELEMENT_IDLETIMEOUT_HEADER__
#define __CAPWAP_ELEMENT_IDLETIMEOUT_HEADER__
#define CAPWAP_ELEMENT_IDLETIMEOUT_VENDOR 0
#define CAPWAP_ELEMENT_IDLETIMEOUT_TYPE 23
#define CAPWAP_ELEMENT_IDLETIMEOUT (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_IDLETIMEOUT_VENDOR, .type = CAPWAP_ELEMENT_IDLETIMEOUT_TYPE }
struct capwap_idletimeout_element {
uint32_t timeout;
};
extern const struct capwap_message_elements_ops capwap_element_idletimeout_ops;
#endif /* __CAPWAP_ELEMENT_IDLETIMEOUT_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_IMAGEIDENTIFIER_HEADER__
#define __CAPWAP_ELEMENT_IMAGEIDENTIFIER_HEADER__
#define CAPWAP_ELEMENT_IMAGEIDENTIFIER_VENDOR 0
#define CAPWAP_ELEMENT_IMAGEIDENTIFIER_TYPE 25
#define CAPWAP_ELEMENT_IMAGEIDENTIFIER (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_IMAGEIDENTIFIER_VENDOR, .type = CAPWAP_ELEMENT_IMAGEIDENTIFIER_TYPE }
#define CAPWAP_IMAGEIDENTIFIER_MAXLENGTH 1024
struct capwap_imageidentifier_element {
uint32_t vendor;
uint8_t* name;
};
extern const struct capwap_message_elements_ops capwap_element_imageidentifier_ops;
#endif /* __CAPWAP_ELEMENT_IMAGEIDENTIFIER_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_IMAGE_INFO_HEADER__
#define __CAPWAP_ELEMENT_IMAGE_INFO_HEADER__
#define CAPWAP_ELEMENT_IMAGEINFO_VENDOR 0
#define CAPWAP_ELEMENT_IMAGEINFO_TYPE 26
#define CAPWAP_ELEMENT_IMAGEINFO (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_IMAGEINFO_VENDOR, .type = CAPWAP_ELEMENT_IMAGEINFO_TYPE }
#define CAPWAP_IMAGEINFO_HASH_LENGTH 16
struct capwap_imageinfo_element {
uint32_t length;
uint8_t hash[CAPWAP_IMAGEINFO_HASH_LENGTH];
};
extern const struct capwap_message_elements_ops capwap_element_imageinfo_ops;
#endif /* __CAPWAP_ELEMENT_IMAGE_INFO_HEADER__ */

View File

@ -1,15 +0,0 @@
#ifndef __CAPWAP_ELEMENT_INIT_DOWNLOAD_HEADER__
#define __CAPWAP_ELEMENT_INIT_DOWNLOAD_HEADER__
#define CAPWAP_ELEMENT_INITIATEDOWNLOAD_VENDOR 0
#define CAPWAP_ELEMENT_INITIATEDOWNLOAD_TYPE 27
#define CAPWAP_ELEMENT_INITIATEDOWNLOAD (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_INITIATEDOWNLOAD_VENDOR, .type = CAPWAP_ELEMENT_INITIATEDOWNLOAD_TYPE }
struct capwap_initdownload_element {
uint8_t dummy;
};
extern const struct capwap_message_elements_ops capwap_element_initdownload_ops;
#endif /* __CAPWAP_ELEMENT_INIT_DOWNLOAD_HEADER__ */

View File

@ -1,15 +0,0 @@
#ifndef __CAPWAP_ELEMENT_LOCALIPV4_HEADER__
#define __CAPWAP_ELEMENT_LOCALIPV4_HEADER__
#define CAPWAP_ELEMENT_LOCALIPV4_VENDOR 0
#define CAPWAP_ELEMENT_LOCALIPV4_TYPE 30
#define CAPWAP_ELEMENT_LOCALIPV4 (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_LOCALIPV4_VENDOR, .type = CAPWAP_ELEMENT_LOCALIPV4_TYPE }
struct capwap_localipv4_element {
struct in_addr address;
};
extern const struct capwap_message_elements_ops capwap_element_localipv4_ops;
#endif /* __CAPWAP_ELEMENT_LOCALIPV4_HEADER__ */

View File

@ -1,15 +0,0 @@
#ifndef __CAPWAP_ELEMENT_LOCALIPV6_HEADER__
#define __CAPWAP_ELEMENT_LOCALIPV6_HEADER__
#define CAPWAP_ELEMENT_LOCALIPV6_VENDOR 0
#define CAPWAP_ELEMENT_LOCALIPV6_TYPE 50
#define CAPWAP_ELEMENT_LOCALIPV6 (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_LOCALIPV6_VENDOR, .type = CAPWAP_ELEMENT_LOCALIPV6_TYPE }
struct capwap_localipv6_element {
struct in6_addr address;
};
extern const struct capwap_message_elements_ops capwap_element_localipv6_ops;
#endif /* __CAPWAP_ELEMENT_CONTROLIPV4_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_LOCATION_HEADER__
#define __CAPWAP_ELEMENT_LOCATION_HEADER__
#define CAPWAP_ELEMENT_LOCATION_VENDOR 0
#define CAPWAP_ELEMENT_LOCATION_TYPE 28
#define CAPWAP_ELEMENT_LOCATION (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_LOCATION_VENDOR, .type = CAPWAP_ELEMENT_LOCATION_TYPE }
#define CAPWAP_LOCATION_MAXLENGTH 1024
struct capwap_location_element {
uint8_t* value;
};
extern const struct capwap_message_elements_ops capwap_element_location_ops;
#endif /* __CAPWAP_ELEMENT_LOCATION_HEADER__ */

View File

@ -1,15 +0,0 @@
#ifndef __CAPWAP_ELEMENT_MAXIMUMLENGTH_HEADER__
#define __CAPWAP_ELEMENT_MAXIMUMLENGTH_HEADER__
#define CAPWAP_ELEMENT_MAXIMUMLENGTH_VENDOR 0
#define CAPWAP_ELEMENT_MAXIMUMLENGTH_TYPE 29
#define CAPWAP_ELEMENT_MAXIMUMLENGTH (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_MAXIMUMLENGTH_VENDOR, .type = CAPWAP_ELEMENT_MAXIMUMLENGTH_TYPE }
struct capwap_maximumlength_element {
uint16_t length;
};
extern const struct capwap_message_elements_ops capwap_element_maximumlength_ops;
#endif /* __CAPWAP_ELEMENT_MAXIMUMLENGTH_HEADER__ */

View File

@ -1,15 +0,0 @@
#ifndef __CAPWAP_ELEMENT_MTUDISCOVERY_HEADER__
#define __CAPWAP_ELEMENT_MTUDISCOVERY_HEADER__
#define CAPWAP_ELEMENT_MTUDISCOVERY_VENDOR 0
#define CAPWAP_ELEMENT_MTUDISCOVERY_TYPE 52
#define CAPWAP_ELEMENT_MTUDISCOVERY (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_MTUDISCOVERY_VENDOR, .type = CAPWAP_ELEMENT_MTUDISCOVERY_TYPE }
struct capwap_mtudiscovery_element {
uint16_t length;
};
extern const struct capwap_message_elements_ops capwap_element_mtudiscovery_ops;
#endif /* __CAPWAP_ELEMENT_MTUDISCOVERY_HEADER__ */

View File

@ -1,19 +0,0 @@
#ifndef __CAPWAP_ELEMENT_RADIOADMSTATE_HEADER__
#define __CAPWAP_ELEMENT_RADIOADMSTATE_HEADER__
#define CAPWAP_ELEMENT_RADIOADMSTATE_VENDOR 0
#define CAPWAP_ELEMENT_RADIOADMSTATE_TYPE 31
#define CAPWAP_ELEMENT_RADIOADMSTATE (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_RADIOADMSTATE_VENDOR, .type = CAPWAP_ELEMENT_RADIOADMSTATE_TYPE }
#define CAPWAP_RADIO_ADMIN_STATE_ENABLED 1
#define CAPWAP_RADIO_ADMIN_STATE_DISABLED 2
struct capwap_radioadmstate_element {
uint8_t radioid;
uint8_t state;
};
extern const struct capwap_message_elements_ops capwap_element_radioadmstate_ops;
#endif /* __CAPWAP_ELEMENT_RADIOADMSTATE_HEADER__ */

View File

@ -1,15 +0,0 @@
#ifndef __CAPWAP_ELEMENT_STATISTICSTIMER_HEADER__
#define __CAPWAP_ELEMENT_STATISTICSTIMER_HEADER__
#define CAPWAP_ELEMENT_STATISTICSTIMER_VENDOR 0
#define CAPWAP_ELEMENT_STATISTICSTIMER_TYPE 36
#define CAPWAP_ELEMENT_STATISTICSTIMER (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_STATISTICSTIMER_VENDOR, .type = CAPWAP_ELEMENT_STATISTICSTIMER_TYPE }
struct capwap_statisticstimer_element {
uint16_t timer;
};
extern const struct capwap_message_elements_ops capwap_element_statisticstimer_ops;
#endif /* __CAPWAP_ELEMENT_STATISTICSTIMER_HEADER__ */

View File

@ -1,16 +0,0 @@
#ifndef __CAPWAP_ELEMENT_TIMERS_HEADER__
#define __CAPWAP_ELEMENT_TIMERS_HEADER__
#define CAPWAP_ELEMENT_TIMERS_VENDOR 0
#define CAPWAP_ELEMENT_TIMERS_TYPE 12
#define CAPWAP_ELEMENT_TIMERS (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_TIMERS_VENDOR, .type = CAPWAP_ELEMENT_TIMERS_TYPE }
struct capwap_timers_element {
uint8_t discovery;
uint8_t echorequest;
};
extern const struct capwap_message_elements_ops capwap_element_timers_ops;
#endif /* __CAPWAP_ELEMENT_TIMERS_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_TRANSPORT_HEADER__
#define __CAPWAP_ELEMENT_TRANSPORT_HEADER__
#define CAPWAP_ELEMENT_TRANSPORT_VENDOR 0
#define CAPWAP_ELEMENT_TRANSPORT_TYPE 51
#define CAPWAP_ELEMENT_TRANSPORT (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_TRANSPORT_VENDOR, .type = CAPWAP_ELEMENT_TRANSPORT_TYPE }
#define CAPWAP_UDPLITE_TRANSPORT 1
#define CAPWAP_UDP_TRANSPORT 2
struct capwap_transport_element {
uint8_t type;
};
extern const struct capwap_message_elements_ops capwap_element_transport_ops;
#endif /* __CAPWAP_ELEMENT_TRANSPORT_HEADER__ */

View File

@ -1,103 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
* The IEEE 802.11 Encryption Capability message element is used by
* the WTP to inform the AC of the support cipher suites. It contains
* a list of suites as defined by IEEE 802.11 Sect. 8.4.2.27.2.
* The message element contains the following fields.
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Radio ID | Cipher Suites... |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* IEEE 802.11 Encryption Capability
*
* Vendor Id: 18681 (Travelping GmbH)
* Type: 18
*
*/
/* */
static void
capwap_vendor_travelping_80211_encryption_capability_element_create(void *data,
capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops *func)
{
int i;
struct capwap_vendor_travelping_80211_encryption_capability_element *element =
(struct capwap_vendor_travelping_80211_encryption_capability_element *)data;
ASSERT(data != NULL);
func->write_u8(handle, element->radioid);
for (i = 0; i < element->suites_count; i++)
func->write_u32(handle, element->suites[i]);
}
/* */
static void *
capwap_vendor_travelping_80211_encryption_capability_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
struct capwap_vendor_travelping_80211_encryption_capability_element *data;
int suites_length, i;
ASSERT(handle != NULL);
ASSERT(func != NULL);
if (func->read_ready(handle) < 1) {
log_printf(LOG_DEBUG, "Invalid Vendor Travelping WTP 802.11 Encryption Capability element");
return NULL;
}
suites_length = func->read_ready(handle) - 1;
if ((suites_length % sizeof(uint32_t)) != 0) {
log_printf(LOG_DEBUG, "Invalid Vendor Travelping WTP 802.11 Encryption Capability element");
return NULL;
}
/* */
data = (struct capwap_vendor_travelping_80211_encryption_capability_element *)
capwap_alloc(sizeof(struct capwap_vendor_travelping_80211_encryption_capability_element) + suites_length);
/* Retrieve data */
func->read_u8(handle, &data->radioid);
data->suites_count = suites_length / sizeof(uint32_t);
for (i = 0; i < data->suites_count; i++)
func->read_u32(handle, &data->suites[i]);
return data;
}
/* */
static void *
capwap_vendor_travelping_80211_encryption_capability_element_clone(void *data)
{
struct capwap_vendor_travelping_80211_encryption_capability_element *element =
(struct capwap_vendor_travelping_80211_encryption_capability_element *)data;
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_vendor_travelping_80211_encryption_capability_element)
+ element->suites_count * sizeof(uint32_t));
}
/* */
static void
capwap_vendor_travelping_80211_encryption_capability_element_free(void* data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
const struct capwap_message_elements_ops capwap_element_vendor_travelping_80211_encryption_capability_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_ARRAY,
.create = capwap_vendor_travelping_80211_encryption_capability_element_create,
.parse = capwap_vendor_travelping_80211_encryption_capability_element_parsing,
.clone = capwap_vendor_travelping_80211_encryption_capability_element_clone,
.free = capwap_vendor_travelping_80211_encryption_capability_element_free
};

View File

@ -1,21 +0,0 @@
#ifndef __CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_ENCRYPTION_CAPABILITY_HEADER__
#define __CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_ENCRYPTION_CAPABILITY_HEADER__
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_ENCRYPTION_CAPABILITY_VENDOR CAPWAP_VENDOR_TRAVELPING_ID
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_ENCRYPTION_CAPABILITY_TYPE 18
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_ENCRYPTION_CAPABILITY \
(struct capwap_message_element_id){ \
.vendor = CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_ENCRYPTION_CAPABILITY_VENDOR, \
.type = CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_ENCRYPTION_CAPABILITY_TYPE \
}
struct capwap_vendor_travelping_80211_encryption_capability_element {
uint8_t radioid;
size_t suites_count;
uint32_t suites[];
};
extern const struct capwap_message_elements_ops capwap_element_vendor_travelping_80211_encryption_capability_ops;
#endif /* __CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_ENCRYPTION_CAPABILITY_HEADER__ */

View File

@ -1,108 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Radio ID | WLAN ID | Key Index | Key Status |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cipher Suite |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Key... |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* IEEE 802.11 Update Key
*
* Vendor Id: 18681 (Travelping GmbH)
* Type: 19
*
* Length: >= 6
*
*/
/* */
static void
capwap_vendor_travelping_80211_update_key_element_create(void *data,
capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops *func)
{
struct capwap_vendor_travelping_80211_update_key_element *element =
(struct capwap_vendor_travelping_80211_update_key_element*)data;
ASSERT(data != NULL);
func->write_u8(handle, element->radioid);
func->write_u8(handle, element->wlanid);
func->write_u8(handle, element->keyindex);
func->write_u8(handle, element->keystatus);
func->write_u32(handle, element->ciphersuite);
if (element->keylength > 0)
func->write_block(handle, element->key, element->keylength);
}
/* */
static void *
capwap_vendor_travelping_80211_update_key_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
unsigned short length;
struct capwap_vendor_travelping_80211_update_key_element *data;
ASSERT(handle != NULL);
ASSERT(func != NULL);
length = func->read_ready(handle);
if (length < 8) {
log_printf(LOG_DEBUG, "Invalid Vendor Travelping IEEE 802.11 Update Key element");
return NULL;
}
length -= 8;
/* */
data = (struct capwap_vendor_travelping_80211_update_key_element *)
capwap_alloc(sizeof(struct capwap_vendor_travelping_80211_update_key_element) + length);
memset(data, 0, sizeof(struct capwap_vendor_travelping_80211_update_key_element) + length);
/* Retrieve data */
func->read_u8(handle, &data->radioid);
func->read_u8(handle, &data->wlanid);
func->read_u8(handle, &data->keyindex);
func->read_u8(handle, &data->keystatus);
func->read_u32(handle, &data->ciphersuite);
data->keylength = length;
func->read_block(handle, data->key, data->keylength);
return data;
}
/* */
static void *capwap_vendor_travelping_80211_update_key_element_clone(void *data)
{
struct capwap_vendor_travelping_80211_update_key_element *element =
(struct capwap_vendor_travelping_80211_update_key_element*)data;
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_vendor_travelping_80211_update_key_element) +
element->keylength);
}
/* */
static void capwap_vendor_travelping_80211_update_key_element_free(void *data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
const struct capwap_message_elements_ops capwap_element_vendor_travelping_80211_update_key_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_ARRAY,
.create = capwap_vendor_travelping_80211_update_key_element_create,
.parse = capwap_vendor_travelping_80211_update_key_element_parsing,
.clone = capwap_vendor_travelping_80211_update_key_element_clone,
.free = capwap_vendor_travelping_80211_update_key_element_free
};

View File

@ -1,27 +0,0 @@
#ifndef __CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_UPDATE_KEY_HEADER__
#define __CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_UPDATE_KEY_HEADER__
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_UPDATE_KEY_VENDOR CAPWAP_VENDOR_TRAVELPING_ID
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_UPDATE_KEY_TYPE 19
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_UPDATE_KEY \
(struct capwap_message_element_id){ \
.vendor = CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_UPDATE_KEY_VENDOR, \
.type = CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_UPDATE_KEY_TYPE \
}
#define CAPWAP_UPDATE_WLAN_KEY_STATUS_REKEYING 2
#define CAPWAP_UPDATE_WLAN_KEY_STATUS_COMPLETE 3
struct capwap_vendor_travelping_80211_update_key_element {
uint8_t radioid;
uint8_t wlanid;
uint8_t keyindex;
uint8_t keystatus;
uint32_t ciphersuite;
uint16_t keylength;
uint8_t key[];
};
extern const struct capwap_message_elements_ops capwap_element_vendor_travelping_80211_update_key_ops;
#endif /* __CAPWAP_ELEMENT_VENDOR_TRAVELPING_80211_UPDATE_KEY_HEADER__ */

View File

@ -1,109 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Second |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Fraction |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* WTP Timestamp
*
* Vendor Id: 18681 (Travelping GmbH)
* Type: 2
*
*/
struct ntp_time_t {
uint32_t second;
uint32_t fraction;
};
static inline void convert_ntp_time_into_unix_time(struct ntp_time_t *ntp, struct timeval *tv)
{
tv->tv_sec = ntp->second - 0x83AA7E80; // the seconds from Jan 1, 1900 to Jan 1, 1970
tv->tv_usec = (uint32_t)( (double)ntp->fraction * 1.0e6 / (double)(1LL<<32) );
}
static inline void convert_unix_time_into_ntp_time(struct timeval *tv, struct ntp_time_t *ntp)
{
ntp->second = tv->tv_sec + 0x83AA7E80;
ntp->fraction = (uint32_t)( (double)(tv->tv_usec+1) * (double)(1LL<<32) * 1.0e-6 );
}
/* */
static void
capwap_vendor_travelping_wtp_timestamp_element_create(void *data,
capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops *func)
{
struct capwap_vendor_travelping_wtp_timestamp_element *element =
(struct capwap_vendor_travelping_wtp_timestamp_element *)data;
struct ntp_time_t ntp;
ASSERT(data != NULL);
convert_unix_time_into_ntp_time(&element->tv, &ntp);
func->write_u32(handle, ntp.second);
func->write_u32(handle, ntp.fraction);
}
/* */
static void *
capwap_vendor_travelping_wtp_timestamp_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
struct capwap_vendor_travelping_wtp_timestamp_element *data;
struct ntp_time_t ntp;
ASSERT(handle != NULL);
ASSERT(func != NULL);
if (func->read_ready(handle) != 8) {
log_printf(LOG_DEBUG, "Invalid Vendor Travelping WTP Timestamp element");
return NULL;
}
/* */
data = (struct capwap_vendor_travelping_wtp_timestamp_element *)
capwap_alloc(sizeof(struct capwap_vendor_travelping_wtp_timestamp_element));
/* Retrieve data */
func->read_u32(handle, &ntp.second);
func->read_u32(handle, &ntp.fraction);
convert_ntp_time_into_unix_time(&ntp, &data->tv);
return data;
}
/* */
static void *
capwap_vendor_travelping_wtp_timestamp_element_clone(void *data)
{
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_vendor_travelping_wtp_timestamp_element));
}
/* */
static void
capwap_vendor_travelping_wtp_timestamp_element_free(void* data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
const struct capwap_message_elements_ops capwap_element_vendor_travelping_wtp_timestamp_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_SINGLE,
.create = capwap_vendor_travelping_wtp_timestamp_element_create,
.parse = capwap_vendor_travelping_wtp_timestamp_element_parsing,
.clone = capwap_vendor_travelping_wtp_timestamp_element_clone,
.free = capwap_vendor_travelping_wtp_timestamp_element_free
};

View File

@ -1,19 +0,0 @@
#ifndef __CAPWAP_ELEMENT_VENDOR_TRAVELPING_WTP_TIMESTAMP_HEADER__
#define __CAPWAP_ELEMENT_VENDOR_TRAVELPING_WTP_TIMESTAMP_HEADER__
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_WTP_TIMESTAMP_VENDOR CAPWAP_VENDOR_TRAVELPING_ID
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_WTP_TIMESTAMP_TYPE 2
#define CAPWAP_ELEMENT_VENDOR_TRAVELPING_WTP_TIMESTAMP \
(struct capwap_message_element_id){ \
.vendor = CAPWAP_ELEMENT_VENDOR_TRAVELPING_WTP_TIMESTAMP_VENDOR, \
.type = CAPWAP_ELEMENT_VENDOR_TRAVELPING_WTP_TIMESTAMP_TYPE \
}
struct capwap_vendor_travelping_wtp_timestamp_element {
struct timeval tv;
};
extern const struct capwap_message_elements_ops capwap_element_vendor_travelping_wtp_timestamp_ops;
#endif /* __CAPWAP_ELEMENT_VENDOR_TRAVELPING_WTP_TIMESTAMP_HEADER__ */

View File

@ -1,111 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Vendor Identifier |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Element ID | Data...
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Type: 37 for Vendor Specific Payload
*
* Length: >= 7
*
*/
/* */
static void capwap_vendorpayload_element_create(void* data,
capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops* func)
{
struct capwap_vendorpayload_element* element = (struct capwap_vendorpayload_element *)data;
ASSERT(data != NULL);
ASSERT(element->datalength > 0);
func->write_u32(handle, element->vendorid);
func->write_u16(handle, element->elementid);
func->write_block(handle, element->data, element->datalength);
}
/* */
static void* capwap_vendorpayload_element_clone(void *data)
{
struct capwap_vendorpayload_element* element = (struct capwap_vendorpayload_element *)data;
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_vendorpayload_element) + element->datalength);
}
/* */
static void capwap_vendorpayload_element_free(void *data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
void *
capwap_unknown_vendorpayload_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func,
unsigned short length,
const struct capwap_message_element_id vendor_id)
{
struct capwap_vendorpayload_element* data;
/* Retrieve data */
data = (struct capwap_vendorpayload_element *)capwap_alloc(sizeof(struct capwap_vendorpayload_element)
+ length);
data->vendorid = vendor_id.vendor;
data->elementid = vendor_id.type;
data->datalength = length;
func->read_block(handle, data->data, length);
return data;
}
/* */
static void *
capwap_vendorpayload_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
unsigned short length;
struct capwap_message_element_id vendor_id;
ASSERT(handle != NULL);
ASSERT(func != NULL);
length = func->read_ready(handle);
if (length < 7) {
log_printf(LOG_DEBUG, "Invalid Vendor Specific Payload element: underbuffer");
return NULL;
}
length -= 6;
if (length > CAPWAP_VENDORPAYLOAD_MAXLENGTH) {
log_printf(LOG_DEBUG, "Invalid Vendor Specific Payload element: overbuffer");
return NULL;
}
/* Retrieve data */
func->read_u32(handle, &vendor_id.vendor);
func->read_u16(handle, &vendor_id.type);
return capwap_unknown_vendorpayload_element_parsing(handle, func, length, vendor_id);
}
/* */
const struct capwap_message_elements_ops capwap_element_vendorpayload_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_ARRAY,
.create = capwap_vendorpayload_element_create,
.parse = capwap_vendorpayload_element_parsing,
.clone = capwap_vendorpayload_element_clone,
.free = capwap_vendorpayload_element_free
};

View File

@ -1,26 +0,0 @@
#ifndef __CAPWAP_ELEMENT_VENDORPAYLOAD_HEADER__
#define __CAPWAP_ELEMENT_VENDORPAYLOAD_HEADER__
#define CAPWAP_ELEMENT_VENDORPAYLOAD_VENDOR 0
#define CAPWAP_ELEMENT_VENDORPAYLOAD_TYPE 37
#define CAPWAP_ELEMENT_VENDORPAYLOAD (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_VENDORPAYLOAD_VENDOR, .type = CAPWAP_ELEMENT_VENDORPAYLOAD_TYPE }
#define CAPWAP_VENDORPAYLOAD_MAXLENGTH 2048
struct capwap_vendorpayload_element {
uint32_t vendorid;
uint16_t elementid;
uint16_t datalength;
uint8_t data[];
};
void *
capwap_unknown_vendorpayload_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func,
unsigned short length,
const struct capwap_message_element_id vendor_id);
extern const struct capwap_message_elements_ops capwap_element_vendorpayload_ops;
#endif /* __CAPWAP_ELEMENT_VENDORPAYLOAD_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_WTPFALLBACK_HEADER__
#define __CAPWAP_ELEMENT_WTPFALLBACK_HEADER__
#define CAPWAP_ELEMENT_WTPFALLBACK_VENDOR 0
#define CAPWAP_ELEMENT_WTPFALLBACK_TYPE 40
#define CAPWAP_ELEMENT_WTPFALLBACK (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_WTPFALLBACK_VENDOR, .type = CAPWAP_ELEMENT_WTPFALLBACK_TYPE }
#define CAPWAP_WTP_FALLBACK_ENABLED 1
#define CAPWAP_WTP_FALLBACK_DISABLED 2
struct capwap_wtpfallback_element {
uint8_t mode;
};
extern const struct capwap_message_elements_ops capwap_element_wtpfallback_ops;
#endif /* __CAPWAP_ELEMENT_WTPFALLBACK_HEADER__ */

View File

@ -1,90 +0,0 @@
#include "capwap.h"
#include "element.h"
/*
*
* 0
* 0 1 2 3 4 5 6 7
* +-+-+-+-+-+-+-+-+
* | MAC Type |
* +-+-+-+-+-+-+-+-+
*
* Type: 44 for WTP MAC Type
*
* Length: 1
*
*/
/* */
static void
capwap_wtpmactype_element_create(void *data, capwap_message_elements_handle handle,
struct capwap_write_message_elements_ops *func)
{
struct capwap_wtpmactype_element *element =
(struct capwap_wtpmactype_element*)data;
ASSERT(data != NULL);
ASSERT((element->type == CAPWAP_LOCALMAC) ||
(element->type == CAPWAP_SPLITMAC) ||
(element->type == CAPWAP_LOCALANDSPLITMAC));
/* */
func->write_u8(handle, element->type);
}
/* */
static void *capwap_wtpmactype_element_clone(void *data)
{
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_wtpmactype_element));
}
/* */
static void capwap_wtpmactype_element_free(void *data)
{
ASSERT(data != NULL);
capwap_free(data);
}
/* */
static void *
capwap_wtpmactype_element_parsing(capwap_message_elements_handle handle,
struct capwap_read_message_elements_ops *func)
{
struct capwap_wtpmactype_element *data;
ASSERT(handle != NULL);
ASSERT(func != NULL);
if (func->read_ready(handle) != 1) {
log_printf(LOG_DEBUG, "Invalid WTP MAC Type element: underbuffer");
return NULL;
}
/* Retrieve data */
data = (struct capwap_wtpmactype_element *)
capwap_alloc(sizeof(struct capwap_wtpmactype_element));
func->read_u8(handle, &data->type);
if ((data->type != CAPWAP_LOCALMAC) &&
(data->type != CAPWAP_SPLITMAC) &&
(data->type != CAPWAP_LOCALANDSPLITMAC))
{
capwap_wtpmactype_element_free((void*)data);
log_printf(LOG_DEBUG, "Invalid WTP MAC Type element: invalid type");
return NULL;
}
return data;
}
/* */
const struct capwap_message_elements_ops capwap_element_wtpmactype_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_SINGLE,
.create = capwap_wtpmactype_element_create,
.parse = capwap_wtpmactype_element_parsing,
.clone = capwap_wtpmactype_element_clone,
.free = capwap_wtpmactype_element_free
};

View File

@ -1,23 +0,0 @@
#ifndef __CAPWAP_ELEMENT_WTPMACTYPE_HEADER__
#define __CAPWAP_ELEMENT_WTPMACTYPE_HEADER__
#define CAPWAP_ELEMENT_WTPMACTYPE_VENDOR 0
#define CAPWAP_ELEMENT_WTPMACTYPE_TYPE 44
#define CAPWAP_ELEMENT_WTPMACTYPE \
(struct capwap_message_element_id) { \
.vendor = CAPWAP_ELEMENT_WTPMACTYPE_VENDOR, \
.type = CAPWAP_ELEMENT_WTPMACTYPE_TYPE \
}
#define CAPWAP_LOCALMAC 0
#define CAPWAP_SPLITMAC 1
#define CAPWAP_LOCALANDSPLITMAC 2
struct capwap_wtpmactype_element {
uint8_t type;
};
extern const struct capwap_message_elements_ops capwap_element_wtpmactype_ops;
#endif /* __CAPWAP_ELEMENT_WTPMACTYPE_HEADER__ */

View File

@ -1,17 +0,0 @@
#ifndef __CAPWAP_ELEMENT_WTPNAME_HEADER__
#define __CAPWAP_ELEMENT_WTPNAME_HEADER__
#define CAPWAP_ELEMENT_WTPNAME_VENDOR 0
#define CAPWAP_ELEMENT_WTPNAME_TYPE 45
#define CAPWAP_ELEMENT_WTPNAME (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_WTPNAME_VENDOR, .type = CAPWAP_ELEMENT_WTPNAME_TYPE }
#define CAPWAP_WTPNAME_MAXLENGTH 512
struct capwap_wtpname_element {
uint8_t* name;
};
extern const struct capwap_message_elements_ops capwap_element_wtpname_ops;
#endif /* __CAPWAP_ELEMENT_WTPNAME_HEADER__ */

View File

@ -1,18 +0,0 @@
#ifndef __CAPWAP_ELEMENT_WTPSTATICIPADDRESS_HEADER__
#define __CAPWAP_ELEMENT_WTPSTATICIPADDRESS_HEADER__
#define CAPWAP_ELEMENT_WTPSTATICIPADDRESS_VENDOR 0
#define CAPWAP_ELEMENT_WTPSTATICIPADDRESS_TYPE 49
#define CAPWAP_ELEMENT_WTPSTATICIPADDRESS (struct capwap_message_element_id){ .vendor = CAPWAP_ELEMENT_WTPSTATICIPADDRESS_VENDOR, .type = CAPWAP_ELEMENT_WTPSTATICIPADDRESS_TYPE }
struct capwap_wtpstaticipaddress_element {
struct in_addr address;
struct in_addr netmask;
struct in_addr gateway;
uint8_t staticip;
};
extern const struct capwap_message_elements_ops capwap_element_wtpstaticipaddress_ops;
#endif /* __CAPWAP_ELEMENT_WTPSTATICIPADDRESS_HEADER__ */

View File

@ -1,64 +0,0 @@
#ifndef __CAPWAP_LOGGING_HEADER__
#define __CAPWAP_LOGGING_HEADER__
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#include <syslog.h>
#define LOG_TO_SYSLOG
/* Logging level */
#define LOG_NONE -1
/* Logging initialize function */
void capwap_logging_init();
void capwap_logging_close();
/* */
void capwap_logging_verboselevel(int level);
/* */
void capwap_logging_disable_allinterface();
void capwap_logging_enable_console(int error);
void capwap_logging_disable_console(void);
/* */
#ifdef ENABLE_LOGGING
void __log_printf(int level, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
void __log_hexdump(int level, const char *title, const unsigned char *data, size_t len);
void __log_syslog(int level, const char* format, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
#ifdef DISABLE_LOGGING_DEBUG
#define log_printf(level, f, args...) \
do { \
if ((level) != LOG_DEBUG) \
__log_printf((level), (f), ##args); \
} while (0)
#define log_hexdump(level, title, data, len) \
do { \
if ((level) != LOG_DEBUG) \
__log_hexdump((level), (title), (data), (len)); \
} while (0)
#else
#ifdef LOG_TO_SYSLOG
#define log_printf(level, f, args...) \
__log_syslog((level), (f), ##args)
#else
#define log_printf(level, f, args...) \
__log_printf((level), (f), ##args)
#endif
#define log_hexdump(level, title, data, len) \
__log_hexdump((level), (title), (data), (len))
#endif
#else
#define log_printf(l, f, args...) do { } while (0)
#define log_hexdump(l, t, d, len) do { } while (0)
#endif
#endif /* __CAPWAP_LOGGING_HEADER__ */

View File

@ -1,14 +0,0 @@
#ifndef __CAPWAP_VENDOR_TRAVELPING_HEADER__
#define __CAPWAP_VENDOR_TRAVELPING_HEADER__
#define CAPWAP_VENDOR_TRAVELPING_ID 18681
#include "element_vendor_travelping_wtp_timestamp.h"
#include "element_vendor_travelping_80211_encryption_capability.h"
#include "element_vendor_travelping_80211_update_key.h"
/* draft-ietf-opsawg-capwap-extension-06 */
#include "element_80211n_radioconf.h"
#include "element_80211n_station_information.h"
#endif /* __CAPWAP_VENDOR_TRAVELPING_HEADER__ */

111
openwrt/Makefile Normal file
View File

@ -0,0 +1,111 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=smartcapwap
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_FIXUP:=autoreconf
include $(INCLUDE_DIR)/package.mk
ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
SMARTCAPWAP_MAKE_VERBOSE := V=1
else
SMARTCAPWAP_MAKE_VERBOSE :=
endif
define Package/smartcapwap
SECTION:=net
CATEGORY:=Network
TITLE:=SmartCAPWAP WTP
MAINTAINER:=Massimo Vellucci <vemax78@gmail.com>
DEPENDS:=+libnl-tiny +libconfig +libwolfssl +kmod-smartcapwap
endef
define Package/smartcapwap/description
This package contains the SmartCAPWAP WTP daemon.
endef
define KernelPackage/smartcapwap
SUBMENU:=Network Support
TITLE:=SmartCAPWAP Data Channel Module
MAINTAINER:=Massimo Vellucci <vemax78@gmail.com>
DEPENDS:=+kmod-mac80211 +kmod-ipv6
FILES:=$(PKG_BUILD_DIR)/src/wtp/kmod/smartcapwap.ko
AUTOLOAD:=$(call AutoLoad,70,smartcapwap)
endef
define KernelPackage/smartcapwap/description
This package contains the SmartCAPWAP Data Transport kernel module.
endef
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
SRC_SMARTCAPWAP := /mnt/hgfs/shared/smartcapwap
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) -r $(SRC_SMARTCAPWAP)/* $(PKG_BUILD_DIR)/
endef
define Build/Configure
$(call Build/Configure/Default, --disable-ac)
endef
define Build/Compile/wtp
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
all
endef
define Build/Compile/kmod
$(MAKE) -C "$(LINUX_DIR)" \
CROSS_COMPILE="$(KERNEL_CROSS)" \
ARCH="$(LINUX_KARCH)" \
SUBDIRS="$(PKG_BUILD_DIR)/src/wtp/kmod" \
KLIB_BUILD="$(LINUX_DIR)" \
KLIB="$(TARGET_MODULES_DIR)" \
KBUILD_EXTRA_SYMBOLS="$(LINUX_DIR)/../compat-wireless-2014-11-04/Module.symvers" \
LINUXINCLUDE="-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
-I$(STAGING_DIR)/usr/include/mac80211-backport \
-I$(STAGING_DIR)/usr/include/mac80211/uapi \
-I$(STAGING_DIR)/usr/include/mac80211 \
-I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include \
-Iarch/$(LINUX_KARCH)/include/generated \
-Iinclude \
-I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include/uapi \
-Iarch/$(LINUX_KARCH)/include/generated/uapi \
-I$(LINUX_DIR)/include/uapi \
-Iinclude/generated/uapi \
-include $(LINUX_DIR)/include/linux/kconfig.h \
-include $(STAGING_DIR)/usr/include/mac80211-backport/backport/backport.h" \
$(SMARTCAPWAP_MAKE_VERBOSE) \
modules
endef
define Build/Compile
$(Build/Compile/wtp)
$(Build/Compile/kmod)
endef
define Package/smartcapwap/install
$(INSTALL_DIR) $(1)/etc/capwap
$(INSTALL_CONF) ./files/wtp.conf $(1)/etc/capwap/wtp.conf
$(INSTALL_CONF) ./files/ca.crt $(1)/etc/capwap/ca.crt
$(INSTALL_CONF) ./files/wtp.crt $(1)/etc/capwap/wtp.crt
$(INSTALL_CONF) ./files/wtp.key $(1)/etc/capwap/wtp.key
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build/wtp/wtp $(1)/usr/bin
endef
$(eval $(call BuildPackage,smartcapwap))
$(eval $(call KernelPackage,smartcapwap))

23
openwrt/files/ca.crt Normal file
View File

@ -0,0 +1,23 @@
-----BEGIN CERTIFICATE-----
MIID3TCCA0agAwIBAgIJAJpqxrKqMyLFMA0GCSqGSIb3DQEBBQUAMIGmMQswCQYD
VQQGEwJJVDELMAkGA1UECBMCSVQxDTALBgNVBAcTBFJvbWUxFDASBgNVBAoTC1Nt
YXJ0Q0FQV0FQMRQwEgYDVQQLEwtTbWFydENBUFdBUDEXMBUGA1UEAxMOU21hcnRD
QVBXQVAgQ0ExFDASBgNVBCkTC1NtYXJ0Q0FQV0FQMSAwHgYJKoZIhvcNAQkBFhF2
ZW1heDc4QGdtYWlsLmNvbTAeFw0xNDA1MTUxODAxNDNaFw0yNDA1MTIxODAxNDNa
MIGmMQswCQYDVQQGEwJJVDELMAkGA1UECBMCSVQxDTALBgNVBAcTBFJvbWUxFDAS
BgNVBAoTC1NtYXJ0Q0FQV0FQMRQwEgYDVQQLEwtTbWFydENBUFdBUDEXMBUGA1UE
AxMOU21hcnRDQVBXQVAgQ0ExFDASBgNVBCkTC1NtYXJ0Q0FQV0FQMSAwHgYJKoZI
hvcNAQkBFhF2ZW1heDc4QGdtYWlsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
gYkCgYEA72PBMR4HQ+rA+ifXJdMtUujlUQX1yrtXZ0HMdKbHbAbfoY3Rvyfdwo2i
TMaZYomyCASawZRzkZJvPchu/q9au/UdLuTmeaUCDpvIkibMK5tahTgP5x90IMGu
+uzdgZQaPbv+fjYkAmMGkZYYTha8GhH+vNloSb6n8oUh2eGf1kUCAwEAAaOCAQ8w
ggELMB0GA1UdDgQWBBS4vrLLxmi9CrvlvN6uVv4l5uSzHDCB2wYDVR0jBIHTMIHQ
gBS4vrLLxmi9CrvlvN6uVv4l5uSzHKGBrKSBqTCBpjELMAkGA1UEBhMCSVQxCzAJ
BgNVBAgTAklUMQ0wCwYDVQQHEwRSb21lMRQwEgYDVQQKEwtTbWFydENBUFdBUDEU
MBIGA1UECxMLU21hcnRDQVBXQVAxFzAVBgNVBAMTDlNtYXJ0Q0FQV0FQIENBMRQw
EgYDVQQpEwtTbWFydENBUFdBUDEgMB4GCSqGSIb3DQEJARYRdmVtYXg3OEBnbWFp
bC5jb22CCQCaasayqjMixTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GB
ANZuFab2/jLSakpGc0nZjCWAlXm29TCkL1i0yxmpjgbg/tqZrSAb1tuK5IANI7Tz
deOObRRxjjRGgSHnFLcKXmJeGjTmIdX7DLALWQALmc0GG+A1T1vHqVKc3YqjmUP3
4X/JgFqJnF1KkKmcDLiLBmA8W4+rLPe3kKhNloKQ9G1m
-----END CERTIFICATE-----

150
openwrt/files/wtp.conf Normal file
View File

@ -0,0 +1,150 @@
# WTP configuration file
version = "1.0";
application: {
standalone = true;
name = "wtp 1";
location = "Ufficio";
binding = "802.11";
tunnelmode: {
nativeframe = false;
ethframe = false;
localbridging = true;
};
mactype = "localmac";
boardinfo: {
idvendor = 123456;
element = (
{ name = "model"; value = "1.0"; },
{ name = "serial"; value = "2.0"; },
{ name = "id"; value = "3.0"; },
{ name = "revision"; value = "4.0"; },
{ name = "macaddress"; type = "interface"; value = "eth0"; }
);
};
descriptor: {
encryption = [
"802.11_AES",
"802.11_TKIP"
];
info = (
{ idvendor = 23456; type = "hardware"; value = "abcde"; },
{ idvendor = 33457; type = "software"; value = "fghil"; },
{ idvendor = 43458; type = "boot"; value = "mnopq"; },
{ idvendor = 53459; type = "other"; value = "qwert"; }
);
};
ecn = "limited";
timer: {
statistics = 120;
};
dtls: {
enable = true;
dtlspolicy: {
cleardatachannel = true;
dtlsdatachannel = true;
};
type = "x509";
presharedkey: {
identity = "prova";
pskkey = "123456";
};
x509: {
calist = "/etc/capwap/ca.crt";
certificate = "/etc/capwap/wtp.crt";
privatekey = "/etc/capwap/wtp.key";
};
};
wlan: {
prefix = "ap";
};
radio = (
{
device = "phy0";
enabled = true;
driver = "nl80211";
mode = "bg";
country = "IT";
outdoor = false;
rtsthreshold = 2347;
shortretry = 7;
longretry = 4;
shortpreamble = true;
fragmentationthreshold = 2346;
txmsdulifetime = 512;
rxmsdulifetime = 512;
maxbssid = 1;
bssprefixname = "ap";
dtimperiod = 2;
beaconperiod = 100;
antenna = {
diversity = false;
combiner = "omni";
selection = [ "internal" ];
};
multidomaincapability = {
firstchannel = 1;
numberchannels = 11;
maxtxpower = 100;
};
supportedrates = [
12, 18, 24, 36, 48, 72, 96, 108
];
txpower = {
current = 100;
supported = [ 100 ];
};
}
);
network: {
#binding = "eth1";
mtu = 1400;
transport = "udp";
ipv4 = true;
ipv6 = false;
ipdualstack = true;
};
acdiscovery: {
search = false;
host = [
"192.168.1.101"
];
};
acprefered: {
host = [
"192.168.1.101"
];
};
};
logging: {
enable = true;
level = "debug";
output = (
{ mode = "stdout"; }
);
};

73
openwrt/files/wtp.crt Normal file
View File

@ -0,0 +1,73 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 2 (0x2)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=IT, ST=IT, L=Rome, O=SmartCAPWAP, OU=SmartCAPWAP, CN=SmartCAPWAP CA/name=SmartCAPWAP/emailAddress=vemax78@gmail.com
Validity
Not Before: May 15 18:02:22 2014 GMT
Not After : May 12 18:02:22 2024 GMT
Subject: C=IT, ST=IT, L=Rome, O=SmartCAPWAP, OU=SmartCAPWAP, CN=wtp1/name=SmartCAPWAP/emailAddress=vemax78@gmail.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (1024 bit)
Modulus:
00:b2:b1:a5:56:a7:ef:4d:76:76:0c:09:0f:5e:c3:
4b:cd:9c:80:ae:1b:fa:8a:63:6b:3e:5d:df:18:e5:
30:25:4a:bf:02:90:a0:1a:db:d9:7b:d3:c0:f2:5b:
82:de:07:bd:4c:43:66:4d:39:6c:fe:88:d5:1a:ac:
47:d0:4c:2d:e0:05:4d:95:80:b5:61:df:84:03:cb:
26:f7:b3:77:8c:e5:28:9e:71:5e:4b:01:42:64:64:
d4:1f:8b:e2:c6:12:af:9f:64:de:63:f0:b2:ff:fb:
0e:82:d8:ba:cf:a9:21:7f:43:4f:c9:19:e0:50:e1:
90:ac:ce:d2:ab:dc:87:b9:9f
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Key Usage:
Digital Signature, Non Repudiation, Key Encipherment, Data Encipherment
Netscape Comment:
Easy-RSA Generated Certificate
X509v3 Subject Key Identifier:
5D:1C:43:55:79:96:EC:CD:9F:81:47:7F:23:F2:88:C4:80:EF:7A:C6
X509v3 Authority Key Identifier:
keyid:B8:BE:B2:CB:C6:68:BD:0A:BB:E5:BC:DE:AE:56:FE:25:E6:E4:B3:1C
DirName:/C=IT/ST=IT/L=Rome/O=SmartCAPWAP/OU=SmartCAPWAP/CN=SmartCAPWAP CA/name=SmartCAPWAP/emailAddress=vemax78@gmail.com
serial:9A:6A:C6:B2:AA:33:22:C5
X509v3 Extended Key Usage:
TLS Web Client Authentication
Signature Algorithm: sha1WithRSAEncryption
2e:1b:fb:12:36:08:97:f4:93:2d:5e:5a:94:e0:67:a9:69:9c:
d3:24:8b:51:87:b4:fd:02:cd:29:9c:54:5f:5c:27:4c:02:08:
6a:64:79:84:a9:dd:df:f4:9d:7d:b7:19:e9:26:a6:01:af:a7:
b4:00:50:51:9d:64:be:f6:38:6b:1d:04:e7:2d:34:16:26:75:
88:01:98:d8:4e:db:3f:a2:f1:9d:d7:9d:cd:8a:07:8a:82:b1:
9f:59:be:4c:e1:0f:8e:2f:ea:cc:98:0a:e1:54:6c:f4:00:a9:
21:fa:9d:ed:81:4d:c6:1f:cd:20:bb:4a:ed:4d:61:50:be:af:
02:f0
-----BEGIN CERTIFICATE-----
MIIEGTCCA4KgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBpjELMAkGA1UEBhMCSVQx
CzAJBgNVBAgTAklUMQ0wCwYDVQQHEwRSb21lMRQwEgYDVQQKEwtTbWFydENBUFdB
UDEUMBIGA1UECxMLU21hcnRDQVBXQVAxFzAVBgNVBAMTDlNtYXJ0Q0FQV0FQIENB
MRQwEgYDVQQpEwtTbWFydENBUFdBUDEgMB4GCSqGSIb3DQEJARYRdmVtYXg3OEBn
bWFpbC5jb20wHhcNMTQwNTE1MTgwMjIyWhcNMjQwNTEyMTgwMjIyWjCBnDELMAkG
A1UEBhMCSVQxCzAJBgNVBAgTAklUMQ0wCwYDVQQHEwRSb21lMRQwEgYDVQQKEwtT
bWFydENBUFdBUDEUMBIGA1UECxMLU21hcnRDQVBXQVAxDTALBgNVBAMTBHd0cDEx
FDASBgNVBCkTC1NtYXJ0Q0FQV0FQMSAwHgYJKoZIhvcNAQkBFhF2ZW1heDc4QGdt
YWlsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsrGlVqfvTXZ2DAkP
XsNLzZyArhv6imNrPl3fGOUwJUq/ApCgGtvZe9PA8luC3ge9TENmTTls/ojVGqxH
0Ewt4AVNlYC1Yd+EA8sm97N3jOUonnFeSwFCZGTUH4vixhKvn2TeY/Cy//sOgti6
z6khf0NPyRngUOGQrM7Sq9yHuZ8CAwEAAaOCAV0wggFZMAkGA1UdEwQCMAAwCwYD
VR0PBAQDAgTwMC0GCWCGSAGG+EIBDQQgFh5FYXN5LVJTQSBHZW5lcmF0ZWQgQ2Vy
dGlmaWNhdGUwHQYDVR0OBBYEFF0cQ1V5luzNn4FHfyPyiMSA73rGMIHbBgNVHSME
gdMwgdCAFLi+ssvGaL0Ku+W83q5W/iXm5LMcoYGspIGpMIGmMQswCQYDVQQGEwJJ
VDELMAkGA1UECBMCSVQxDTALBgNVBAcTBFJvbWUxFDASBgNVBAoTC1NtYXJ0Q0FQ
V0FQMRQwEgYDVQQLEwtTbWFydENBUFdBUDEXMBUGA1UEAxMOU21hcnRDQVBXQVAg
Q0ExFDASBgNVBCkTC1NtYXJ0Q0FQV0FQMSAwHgYJKoZIhvcNAQkBFhF2ZW1heDc4
QGdtYWlsLmNvbYIJAJpqxrKqMyLFMBMGA1UdJQQMMAoGCCsGAQUFBwMCMA0GCSqG
SIb3DQEBBQUAA4GBAC4b+xI2CJf0ky1eWpTgZ6lpnNMki1GHtP0CzSmcVF9cJ0wC
CGpkeYSp3d/0nX23GekmpgGvp7QAUFGdZL72OGsdBOctNBYmdYgBmNhO2z+i8Z3X
nc2KB4qCsZ9ZvkzhD44v6syYCuFUbPQAqSH6ne2BTcYfzSC7Su1NYVC+rwLw
-----END CERTIFICATE-----

16
openwrt/files/wtp.key Normal file
View File

@ -0,0 +1,16 @@
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALKxpVan7012dgwJ
D17DS82cgK4b+opjaz5d3xjlMCVKvwKQoBrb2XvTwPJbgt4HvUxDZk05bP6I1Rqs
R9BMLeAFTZWAtWHfhAPLJvezd4zlKJ5xXksBQmRk1B+L4sYSr59k3mPwsv/7DoLY
us+pIX9DT8kZ4FDhkKzO0qvch7mfAgMBAAECgYB3oUyChi1EG9GN3ybmFzMRdPwF
FAAYU9TBTREF1rHz1WWpLu+w64xfRPWAi1lCkcXeX6UGgDKC+VJJ6BqvzcBLgkjh
GBaWBCN/F782Ss4svt1dyRrixixUw+RfJLakKSdFPsrdIHctdSLIKsSl4wxj+9ek
NmGbOBm/2ZJazSzgEQJBAN5abmR53pRdGKgfFKeqUo+ygWSi1IDFqn0niw7DS4TU
3h/QuI9qWZQlTIK8ibguvpc7wHUK4IZ0pk7TwmN1H6cCQQDNu+4vw2Xe2CFjEkLI
X1stba8tsdqP04BGFectrxoeUhLMZtG2Y0ZCx+BjAACXTqfchsSjv+G9Fj/QHJLg
TxVJAkB8VQjBejvxrhTpfWepUV4VJ/WedkZpMx5gGUpymNWTkwwZsjZhS1CHvEuK
Fy7TJKBCJJE7YTenN3b/QP3Da2ylAkEAwVzMdR/Vcyj32EGleuYEsCHS78OlhGBo
w3Z6nTlh9vV0raBFooKT2tg5UVMDOzK2GlKgJreF104+E7+HXEN34QJAYF76xuMm
bKi3V1bI7/t8hXs87LLHjR90PHNzLdy61lWxMvb8oWe8KjDyaE253h24a6tEPzT1
a8lIpqpuuuvTbg==
-----END PRIVATE KEY-----

View File

@ -1,109 +0,0 @@
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=freewtp
PKG_VERSION:=1.4.0
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/travelping/freewtp.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=a631f89729604f77a4907e5597bf15dd916f1e33
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_MAINTAINER:=Travelping GmbH <info@travelping.com>
PKG_LICENSE:=GPL-v2
PKG_LICENSE_FILES:=LICENSE
PKG_FIXUP:=autoreconf
PKG_BUILD_DEPENDS:=mac80211
STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk
define Package/freewtp
SECTION:=net
CATEGORY:=Network
TITLE:=Freewtp WTP
MAINTAINER:=Travelping GmbH <info@travelping.com>
DEPENDS:=+libnl +libev +libconfig +libcyassl +kmod-freewtp \
+@CYASSL_HAS_DTLS +@CYASSL_HAS_AES_CCM +@CYASSL_HAS_AES_GCM \
+@CYASSL_HAS_CHACHA +@CYASSL_HAS_ECC +@CYASSL_HAS_DH \
+@CYASSL_HAS_PSK +@CYASSL_HAS_ECC25519 +@CYASSL_HAS_POLY_1305
endef
define Package/freewtp/description
This package contains the Freewtp WTP daemon.
endef
define KernelPackage/freewtp
SUBMENU:=Network Support
TITLE:=Freewtp Data Channel Module
MAINTAINER:=Travelping GmbH <info@travelping.com>
DEPENDS:=+kmod-mac80211 +kmod-iptunnel +kmod-udptunnel4 +IPV6:kmod-udptunnel6 \
+@PACKAGE_MAC80211_CAPWAP_WTP
FILES:=$(PKG_BUILD_DIR)/kmod/wtp.ko
AUTOLOAD:=$(call AutoLoad,70,wtp)
endef
define KernelPackage/freewtp/description
This package contains the Freewtp Data Transport kernel module.
endef
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/libnl3
define Build/Compile/wtp
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
all
endef
NOSTDINC_FLAGS = \
-I$(PKG_BUILD_DIR)/kmod \
-I$(STAGING_DIR)/usr/include/mac80211-backport \
-I$(STAGING_DIR)/usr/include/mac80211/uapi \
-I$(STAGING_DIR)/usr/include/mac80211 \
-include backport/autoconf.h \
-include backport/backport.h \
-DCPTCFG_MAC80211_CAPWAP_WTP
define Build/Compile/kmod
+$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(KERNEL_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)/kmod" \
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
modules
endef
define Build/Compile
$(Build/Compile/wtp)
$(Build/Compile/kmod)
endef
define Package/freewtp/conffiles
/etc/wtp/
endef
define Package/freewtp/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/wtp.config $(1)/etc/config/wtp
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/wtp.init $(1)/etc/init.d/wtp
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/wtp $(1)/usr/bin
$(INSTALL_DIR) $(1)/etc/wtp
endef
$(eval $(call BuildPackage,freewtp))
$(eval $(call KernelPackage,freewtp))

View File

@ -1,6 +0,0 @@
config wtp
option country 'DE'
option location 'Magdeburg'
option name 'wtp-ap'
option host '127.0.0.1'
option dtlsmode 'off'

View File

@ -1,296 +0,0 @@
#!/bin/sh /etc/rc.common
START=80
USE_PROCD=1
PROG=/usr/bin/wtp
wtp_conf_header() {
. /etc/openwrt_release
model="$(cat /tmp/sysinfo/model)"
bootver="$(strings /dev/mtd0 | grep '^U-Boot.*\..*\(.* .*\)$' | head -n1)"
[ -z "$bootver" ] && bootver="unknown"
linuxver="$(cat /proc/version)"
cat <<EOF
# WTP configuration file
version = "1.0";
application: {
standalone = true;
name = "${name}";
location = "${location}";
binding = "802.11";
tunnelmode: {
nativeframe = true;
ethframe = true;
localbridging = false;
};
mactype = "localmac";
boardinfo: {
idvendor = 123456;
element = (
{ name = "model"; value = "${model}"; },
{ name = "serial"; value = "${uuid}"; },
{ name = "id"; value = "1.0"; },
{ name = "revision"; value = "1.0"; },
{ name = "macaddress"; type = "interface"; value = "eth0"; }
);
};
descriptor: {
encryption = [
"802.11_AES",
"802.11_TKIP"
];
info = (
{ idvendor = 23456; type = "hardware"; value = "${DISTRIB_TARGET}"; },
{ idvendor = 33457; type = "software"; value = "${DISTRIB_DESCRIPTION}"; },
{ idvendor = 43458; type = "boot"; value = "${bootver}"; },
{ idvendor = 53459; type = "other"; value = "${linuxver}"; }
);
};
ecn = "limited";
timer: {
statistics = 120;
inactivity = 300;
};
EOF
}
wtp_conf_x509() {
echo " dtls: {"
if [ "$dtlsmode" = "off" ]; then
echo " enable = false;"
echo " };"
echo
return
fi
echo " enable = true;"
echo
echo " dtlspolicy: {"
echo " cleardatachannel = true;"
echo " dtlsdatachannel = false;"
echo " };"
echo
if [ "$dtlsmode" = "psk" ]; then
echo " type = \"presharedkey\";"
echo
echo " presharedkey: {"
echo " identity = \"${identity}\";"
echo " pskkey = \"${psk}\";"
echo " };"
elif [ "$dtlsmode" = "x509" ]; then
echo " type = \"x509\";"
echo
echo " x509: {"
echo " calist = \"${ca}\";"
echo " certificate = \"${cert}\";"
echo " privatekey = \"${key}\";"
echo " };"
fi
echo " };"
echo
}
wtp_conf_wlan() {
apx=0
cat <<EOF
wlan: {
prefix = "ap";
};
radio = (
EOF
for phy in /sys/class/ieee80211/*; do
phy="$(basename $phy)"
if [ "$( iw phy $phy info | grep "* 24.. MHz" )" ]; then
mode="g"
else
mode="a"
fi
[ 1 -eq $apx ] && echo ","
cat <<EOF
{
device = "${phy}";
enabled = true;
driver = "nl80211";
mode = "${mode}";
country = "${country}";
outdoor = false;
rtsthreshold = 2347;
shortretry = 7;
longretry = 4;
shortpreamble = true;
fragmentationthreshold = 2346;
txmsdulifetime = 512;
rxmsdulifetime = 512;
maxbssid = 1;
bssprefixname = "ap";
dtimperiod = 1;
beaconperiod = 100;
antenna = {
diversity = false;
combiner = "omni";
selection = [ "internal" ];
};
multidomaincapability = {
firstchannel = 1;
numberchannels = 11;
maxtxpower = 100;
};
supportedrates = (
6, 9, 12, 18, 24, 36, 48, 54
);
txpower = {
current = 100;
supported = [ 100 ];
};
qos = {
taggingpolicy = 0; # not used yet
voice = {
queuedepth = 1; # not used yet
cwmin = 2;
cwmax = 3;
aifs = 2;
priority8021p = 0; # not used yet
dscp = 0; # not used yet
};
video = {
queuedepth = 1; # not used yet
cwmin = 3;
cwmax = 4;
aifs = 2;
priority8021p = 0; # not used yet
dscp = 0; # not used yet
};
besteffort = {
queuedepth = 1; # not used yet
cwmin = 4;
cwmax = 10;
aifs = 3;
priority8021p = 0; # not used yet
dscp = 0; # not used yet
};
background = {
queuedepth = 1; # not used yet
cwmin = 4;
cwmax = 10;
aifs = 7;
priority8021p = 0; # not used yet
dscp = 0; # not used yet
};
};
ieee80211n = {
a-msdu = true;
a-mpdu = true;
require-ht = false;
short-gi = true;
ht40 = false;
max-sup-mcs = 15;
max-mand-mcs = 7;
tx-antenna = 0;
rx-antenna = 0;
};
}
EOF
apx=1
done
echo " );"
echo
}
wtp_conf_net() {
cat <<EOF
network: {
transport = "udp";
mtu = 1400;
};
acdiscovery: {
search = true;
host = [
"${host}"
];
};
acprefered: {
host = [
"${host}"
];
};
};
EOF
}
wtp_conf_logging() {
cat <<EOF
logging: {
enable = true;
level = "debug";
output = (
{ mode = "stdout"; }
);
};
EOF
}
wtp_gen_conf() {
wtp_conf_header
wtp_conf_x509
wtp_conf_wlan
wtp_conf_net
wtp_conf_logging
}
wtp_uci_conf() {
[ -e /tmp/etc/wtp.conf ] && return
config_get location "$1" location
config_get country "$1" country
config_get name "$1" name
config_get dtlsmode "$1" dtlsmode
config_get ca "$1" ca
config_get cert "$1" cert
config_get key "$1" key
config_get host "$1" host
config_get uuid "$1" uuid
[ -z "$uuid" ] && {
uuid="$(cat /proc/sys/kernel/random/uuid)"
uci set wtp.@wtp[0].uuid=$uuid
uci commit wtp
}
mkdir -p /tmp/etc
wtp_gen_conf > /tmp/etc/wtp.conf
}
service_triggers() {
procd_add_reload_trigger wtp
}
start_service() {
[ -e /tmp/etc/wtp.conf ] && rm /tmp/etc/wtp.conf
config_load wtp
config_foreach wtp_uci_conf wtp
procd_open_instance
procd_set_param command $PROG -c /tmp/etc/wtp.conf
procd_set_param respawn
procd_close_instance
}

View File

@ -1,39 +0,0 @@
#
# Copyright (C) 2016 Travelping GmbH
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-freewtp
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0
include $(INCLUDE_DIR)/package.mk
define Package/luci-app-freewtp
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=FreeWTP CAPWAP WTP
URL:=https://github.com/travelping/freewtp
MAINTAINER:=Travelping GmbH <info@travelping.com>
DEPENDS:=+freewtp +luci-base
endef
define Package/luci-app-freewtp/description
This package allows you to configure the FreeWTP CAPWAP WTP
endef
define Build/Compile
endef
define Package/luci-app-freewtp/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
$(CP) ./luasrc/* $(1)/usr/lib/lua/luci
endef
$(eval $(call BuildPackage,luci-app-freewtp))

View File

@ -1,13 +0,0 @@
-- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2010-2015 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.freewtp", package.seeall)
function index()
if not nixio.fs.access("/etc/config/wtp") then
return
end
entry( {"admin", "services", "freewtp"}, cbi("freewtp/freewtp"), _("FreeWTP"), 90).leaf=true
end

View File

@ -1,67 +0,0 @@
-- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2010-2015 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
m = Map("wtp", translate("FreeWTP"),
translate("FreeWTP CAPWAP WTP"))
s = m:section(TypedSection, "wtp", nil, translate("Settings"))
s.addremove = false
s.anonymous = true
s:tab("general", translate("General Settings"))
s:tab("ac", translate("Access Controller"))
s:tab("security", translate("Security"))
name = s:taboption("general", Value, "name", translate("Name"),
translate("Name of the WTP instance."))
name.datatype = "string"
uuid = s:taboption("general", Value, "uuid", translate("ID"),
translate("Unique Identifier"))
uuid.datatype = "string"
uuid.readonly = true
country = s:taboption("general", Value, "country", translate("Country"),
translate("ISO/IEC 3166 alpha2 country code"))
country.datatype = "string"
location = s:taboption("general", Value, "location", translate("Location"),
translate("Geographic location"))
location.datatype = "string"
ac = s:taboption("ac", Value, "host", translate("Access Controller"),
translate("Hostname of the Access Controller"))
location.datatype = "hostname"
encr = s:taboption("security", ListValue, "dtlsmode", translate("DTLS Security Mode"))
encr:value("off", translate("Disabled"))
encr:value("psk", translate("Pre-shared Key"))
encr:value("x509", translate("X.509"))
ident = s:taboption("security", Value, "identifier", translate("Identifier"),
translate("Identifier"))
ident:depends("dtlsmode", "psk")
ident.datatype = "string"
ident.rmempty = true
psk = s:taboption("security", Value, "psk", translate("Pre-shared Key"),
translate("Passphrase"))
psk:depends("dtlsmode", "psk")
psk.datatype = "string"
psk.rmempty = true
psk.password = true
ca = s:taboption("security", FileUpload, "ca", translate("Certification Authority File"))
ca:depends("dtlsmode", "x509")
ca.rmempty = true
cert = s:taboption("security", FileUpload, "cert", translate("Certificate File"))
cert:depends("dtlsmode", "x509")
cert.rmempty = true
key = s:taboption("security", FileUpload, "key", translate("Private Key File"))
key:depends("dtlsmode", "x509")
key.rmempty = true
return m

View File

@ -1,698 +0,0 @@
From 0829e230256d8f18c2d482923d16d3582311221f Mon Sep 17 00:00:00 2001
From: Andreas Schultz <aschultz@tpip.net>
Date: Thu, 4 Feb 2016 15:57:11 +0100
Subject: [PATCH] support patch for FreeWTP
Allows for kernel side interception and injection of IEEE 802.11 frames.
---
include/net/mac80211.h | 31 +++++
net/mac80211/Kconfig | 7 ++
net/mac80211/ieee80211_i.h | 12 ++
net/mac80211/iface.c | 63 ++++++++++
net/mac80211/rx.c | 96 ++++++++++++---
net/mac80211/tx.c | 286 +++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 481 insertions(+), 14 deletions(-)
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2323,6 +2323,37 @@ ieee80211_get_alt_retry_rate(const struc
*/
void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+
+extern struct static_key mac80211_capwap_wtp;
+
+/**
+ *
+ */
+struct ieee80211_pcktunnel {
+ u16 subtype_mask[3]; /* 0: MGMT, 1: CTLR, 2: DATA */
+
+ int (*handler)(u32 ifindex, struct sk_buff *skb, int sig_dbm, unsigned char rate, void *data);
+ void *data;
+};
+
+/**
+ *
+ */
+int ieee80211_pcktunnel_register(struct net_device *dev, struct ieee80211_pcktunnel *handler);
+
+/**
+ *
+ */
+int ieee80211_pcktunnel_deregister(struct net_device *dev, struct ieee80211_pcktunnel *handler);
+
+/**
+ *
+ */
+netdev_tx_t ieee80211_inject_xmit(struct sk_buff* skb, struct net_device* dev);
+
+#endif
+
/**
* DOC: Hardware crypto acceleration
*
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -317,3 +317,10 @@ config MAC80211_STA_HASH_MAX_SIZE
connect more stations than the number selected here.)
If unsure, leave the default of 0.
+
+config MAC80211_CAPWAP_WTP
+ bool "Enable support functions for out-of-tree CAPWAP WTP module"
+ depends on MAC80211
+ ---help---
+ Select this to build support hooks for out-of-tree CAPWAP FreeWTP
+ module.
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -182,6 +182,9 @@ typedef unsigned __bitwise__ ieee80211_r
#define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
#define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
#define RX_QUEUED ((__force ieee80211_rx_result) 3u)
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+#define RX_IGNORE_MONITOR ((__force ieee80211_rx_result) 4u)
+#endif
/**
* enum ieee80211_packet_rx_flags - packet RX flags
@@ -847,6 +850,11 @@ struct ieee80211_sub_if_data {
char name[IFNAMSIZ];
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+ /* Packet tunnel handlers */
+ struct ieee80211_pcktunnel __rcu *pcktunnel_handlers;
+#endif
+
/* Fragment table for host-based reassembly */
struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
unsigned int fragment_next;
@@ -1696,6 +1704,10 @@ netdev_tx_t ieee80211_subif_start_xmit(s
void __ieee80211_subif_start_xmit(struct sk_buff *skb,
struct net_device *dev,
u32 info_flags);
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+netdev_tx_t ieee80211_capwap_subif_start_xmit(struct sk_buff *skb,
+ struct net_device *dev);
+#endif
void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
struct sk_buff_head *skbs);
struct sk_buff *
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -2001,3 +2001,66 @@ void ieee80211_iface_exit(void)
{
unregister_netdevice_notifier(&mac80211_netdev_notifier);
}
+
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+
+struct static_key mac80211_capwap_wtp __read_mostly;
+
+static const struct net_device_ops ieee80211_capwapif_ops = {
+ .ndo_open = ieee80211_open,
+ .ndo_stop = ieee80211_stop,
+ .ndo_uninit = ieee80211_uninit,
+ .ndo_start_xmit = ieee80211_capwap_subif_start_xmit,
+ .ndo_set_rx_mode = ieee80211_set_multicast_list,
+ .ndo_change_mtu = ieee80211_change_mtu,
+ .ndo_set_mac_address = ieee80211_change_mac,
+ .ndo_select_queue = ieee80211_netdev_select_queue,
+ .ndo_get_stats64 = ieee80211_get_stats64,
+};
+
+int ieee80211_pcktunnel_register(struct net_device *dev, struct ieee80211_pcktunnel *handler)
+{
+ int ret = 0;
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ dev->netdev_ops = &ieee80211_capwapif_ops;
+
+ mutex_lock(&sdata->local->iflist_mtx);
+
+ if (rcu_dereference_protected(sdata->pcktunnel_handlers, lockdep_is_held(&sdata->local->iflist_mtx))) {
+ ret = -EBUSY;
+ } else {
+ rcu_assign_pointer(sdata->pcktunnel_handlers, handler);
+ static_key_slow_inc(&mac80211_capwap_wtp);
+ }
+
+ mutex_unlock(&sdata->local->iflist_mtx);
+ synchronize_net();
+
+ return ret;
+}
+EXPORT_SYMBOL(ieee80211_pcktunnel_register);
+
+int ieee80211_pcktunnel_deregister(struct net_device *dev, struct ieee80211_pcktunnel *handler)
+{
+ int ret = -ENODEV;
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ieee80211_pcktunnel *h;
+
+ mutex_lock(&sdata->local->iflist_mtx);
+
+ h = rcu_dereference_protected(sdata->pcktunnel_handlers, lockdep_is_held(&sdata->local->iflist_mtx));
+ if (h == handler) {
+ ret = 0;
+ static_key_slow_dec(&mac80211_capwap_wtp);
+ rcu_assign_pointer(sdata->pcktunnel_handlers, NULL);
+ }
+
+ mutex_unlock(&sdata->local->iflist_mtx);
+ synchronize_net();
+
+ return ret;
+}
+EXPORT_SYMBOL(ieee80211_pcktunnel_deregister);
+
+#endif
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -3097,6 +3097,56 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
return RX_QUEUED;
}
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+
+static ieee80211_rx_result debug_noinline
+ieee80211_rx_h_pcktunnel(struct ieee80211_rx_data *rx, struct ieee80211_rate *rate)
+{
+ struct ieee80211_pcktunnel *handler;
+
+ handler = rcu_dereference(rx->sdata->pcktunnel_handlers);
+ if (handler) {
+ u16 fc;
+ u16 fc_type;
+ int sig_dbm = 0;
+ unsigned char pckrate = 0;
+ struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
+
+ if (ieee80211_hw_check(&rx->local->hw, SIGNAL_DBM))
+ sig_dbm = status->signal;
+
+ if (rate && !(status->flag & (RX_FLAG_HT | RX_FLAG_VHT))) {
+ int shift = 0;
+ if (status->flag & RX_FLAG_10MHZ)
+ shift = 1;
+ else if (status->flag & RX_FLAG_5MHZ)
+ shift = 2;
+ pckrate = DIV_ROUND_UP(rate->bitrate, 5 * (1 << shift));
+ }
+
+ /* Retrieve type and subtype packet */
+ fc = le16_to_cpu(hdr->frame_control);
+ fc_type = ((fc & IEEE80211_FCTL_FTYPE) >> 2);
+ if (fc_type < 3) {
+ u16 bitmask = 1 << ((fc & IEEE80211_FCTL_STYPE) >> 4);
+
+ /* Delegate packet to external handler */
+ if (handler->subtype_mask[fc_type] & bitmask) {
+ if (handler->handler(rx->sdata->dev->ifindex, rx->skb, sig_dbm, pckrate, handler->data)) {
+ return RX_IGNORE_MONITOR;
+ }
+ }
+ }
+ }
+
+ return RX_CONTINUE;
+}
+
+/* TODO: use IEEE80211_RX_FRAGMENTED */
+
+#endif
+
static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
struct ieee80211_rate *rate)
{
@@ -3176,6 +3226,9 @@ static void ieee80211_rx_handlers_result
if (rx->sta)
rx->sta->rx_stats.dropped++;
/* fall through */
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+ case RX_IGNORE_MONITOR:
+#endif
case RX_CONTINUE: {
struct ieee80211_rate *rate = NULL;
struct ieee80211_supported_band *sband;
@@ -3204,7 +3257,9 @@ static void ieee80211_rx_handlers_result
}
static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx,
- struct sk_buff_head *frames)
+ struct sk_buff_head *frames,
+ struct ieee80211_rate *rate)
+
{
ieee80211_rx_result res = RX_DROP_MONITOR;
struct sk_buff *skb;
@@ -3243,6 +3298,15 @@ static void ieee80211_rx_handlers(struct
if (ieee80211_vif_is_mesh(&rx->sdata->vif))
CALL_RXH(ieee80211_rx_h_mesh_fwding);
#endif
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+ if (static_key_false(&mac80211_capwap_wtp)) {
+ /* special treatment */
+ res = ieee80211_rx_h_pcktunnel(rx, rate);
+ if (res != RX_CONTINUE)
+ goto rxh_next;
+ }
+#endif
+
CALL_RXH(ieee80211_rx_h_amsdu);
CALL_RXH(ieee80211_rx_h_data);
@@ -3266,7 +3330,8 @@ static void ieee80211_rx_handlers(struct
spin_unlock_bh(&rx->local->rx_path_lock);
}
-static void ieee80211_invoke_rx_handlers(struct ieee80211_rx_data *rx)
+static void ieee80211_invoke_rx_handlers(struct ieee80211_rx_data *rx,
+ struct ieee80211_rate *rate)
{
struct sk_buff_head reorder_release;
ieee80211_rx_result res = RX_DROP_MONITOR;
@@ -3285,7 +3350,7 @@ static void ieee80211_invoke_rx_handlers
ieee80211_rx_reorder_ampdu(rx, &reorder_release);
- ieee80211_rx_handlers(rx, &reorder_release);
+ ieee80211_rx_handlers(rx, &reorder_release, rate);
return;
rxh_next:
@@ -3331,7 +3396,7 @@ void ieee80211_release_reorder_timeout(s
drv_event_callback(rx.local, rx.sdata, &event);
}
- ieee80211_rx_handlers(&rx, &frames);
+ ieee80211_rx_handlers(&rx, &frames, NULL);
}
void ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *pubsta, u8 tid,
@@ -3406,7 +3471,7 @@ void ieee80211_mark_rx_ba_filtered_frame
release:
spin_unlock_bh(&tid_agg_rx->reorder_lock);
- ieee80211_rx_handlers(&rx, &frames);
+ ieee80211_rx_handlers(&rx, &frames, NULL);
out:
rcu_read_unlock();
@@ -3878,7 +3943,9 @@ static bool ieee80211_invoke_fast_rx(str
* or not the skb was consumed.
*/
static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
- struct sk_buff *skb, bool consume)
+ struct sk_buff *skb,
+ struct ieee80211_rate *rate,
+ bool consume)
{
struct ieee80211_local *local = rx->local;
struct ieee80211_sub_if_data *sdata = rx->sdata;
@@ -3916,7 +3983,7 @@ static bool ieee80211_prepare_and_rx_han
rx->skb = skb;
}
- ieee80211_invoke_rx_handlers(rx);
+ ieee80211_invoke_rx_handlers(rx, rate);
return true;
}
@@ -3927,7 +3994,8 @@ static bool ieee80211_prepare_and_rx_han
static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
struct ieee80211_sta *pubsta,
struct sk_buff *skb,
- struct napi_struct *napi)
+ struct napi_struct *napi,
+ struct ieee80211_rate *rate)
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_sub_if_data *sdata;
@@ -3973,7 +4041,7 @@ static void __ieee80211_rx_handle_packet
if (pubsta) {
rx.sta = container_of(pubsta, struct sta_info, sta);
rx.sdata = rx.sta->sdata;
- if (ieee80211_prepare_and_rx_handle(&rx, skb, true))
+ if (ieee80211_prepare_and_rx_handle(&rx, skb, rate, true))
return;
goto out;
} else if (ieee80211_is_data(fc)) {
@@ -3992,7 +4060,7 @@ static void __ieee80211_rx_handle_packet
rx.sta = prev_sta;
rx.sdata = prev_sta->sdata;
- ieee80211_prepare_and_rx_handle(&rx, skb, false);
+ ieee80211_prepare_and_rx_handle(&rx, skb, rate, false);
prev_sta = sta;
}
@@ -4001,7 +4069,7 @@ static void __ieee80211_rx_handle_packet
rx.sta = prev_sta;
rx.sdata = prev_sta->sdata;
- if (ieee80211_prepare_and_rx_handle(&rx, skb, true))
+ if (ieee80211_prepare_and_rx_handle(&rx, skb, rate, true))
return;
goto out;
}
@@ -4030,7 +4098,7 @@ static void __ieee80211_rx_handle_packet
rx.sta = sta_info_get_bss(prev, hdr->addr2);
rx.sdata = prev;
- ieee80211_prepare_and_rx_handle(&rx, skb, false);
+ ieee80211_prepare_and_rx_handle(&rx, skb, rate, false);
prev = sdata;
}
@@ -4039,7 +4107,7 @@ static void __ieee80211_rx_handle_packet
rx.sta = sta_info_get_bss(prev, hdr->addr2);
rx.sdata = prev;
- if (ieee80211_prepare_and_rx_handle(&rx, skb, true))
+ if (ieee80211_prepare_and_rx_handle(&rx, skb, rate, true))
return;
}
@@ -4152,7 +4220,7 @@ void ieee80211_rx_napi(struct ieee80211_
((struct ieee80211_hdr *)skb->data)->frame_control,
skb->len);
- __ieee80211_rx_handle_packet(hw, pubsta, skb, napi);
+ __ieee80211_rx_handle_packet(hw, pubsta, skb, napi, rate);
rcu_read_unlock();
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3434,6 +3434,115 @@ netdev_tx_t ieee80211_subif_start_xmit(s
return NETDEV_TX_OK;
}
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+
+/*
+ * inject raw 802.11 frame, processing is mostly identical
+ * to ieee80211_monitor_start_xmit, except for the different
+ * headers
+ */
+static void __ieee80211_capwap_inject_start_xmit(struct sk_buff *skb,
+ struct net_device *dev)
+{
+ struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+ struct ieee80211_chanctx_conf *chanctx_conf;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct ieee80211_sub_if_data *sdata;
+ struct cfg80211_chan_def *chandef;
+ int tid;
+ int hdrlen;
+
+ /* check for not even having the fixed 802.11 header */
+ if (unlikely(skb->len < sizeof(struct ieee80211_hdr)))
+ goto fail; /* too short to be possibly valid */
+
+ hdrlen = ieee80211_hdrlen(hdr->frame_control);
+
+ /* does the skb contain enough to deliver on the alleged length? */
+ if (unlikely(skb->len < hdrlen))
+ goto fail; /* skb too short for claimed header length */
+
+ skb_set_mac_header(skb, 0);
+ /*
+ * these are just fixed to the end of the rt area since we
+ * don't have any better information and at this point, nobody cares
+ */
+ skb_set_network_header(skb, hdrlen);
+ skb_set_transport_header(skb, hdrlen);
+
+ /*
+ * Initialize skb->protocol if the injected frame is a data frame
+ * carrying a rfc1042 header
+ */
+ if (ieee80211_is_data(hdr->frame_control) &&
+ skb->len >= hdrlen + sizeof(rfc1042_header) + 2) {
+ u8 *payload = (u8 *)hdr + hdrlen;
+
+ if (ether_addr_equal(payload, rfc1042_header))
+ skb->protocol = cpu_to_be16((payload[6] << 8) |
+ payload[7]);
+ }
+
+ if (ieee80211_is_data_qos(hdr->frame_control)) {
+ u8 *p = ieee80211_get_qos_ctl(hdr);
+
+ skb->priority = *p & IEEE80211_QOS_CTL_TAG1D_MASK;
+ }
+ skb_set_queue_mapping(skb, ieee802_1d_to_ac[skb->priority]);
+
+ memset(info, 0, sizeof(*info));
+ info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS |
+ IEEE80211_TX_CTL_INJECTED;
+
+ /*
+ * we might have set these flags later.....
+ * info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT;
+ * info->flags &= ~IEEE80211_TX_CTL_DONTFRAG;
+ */
+
+ rcu_read_lock();
+
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+ if (!chanctx_conf)
+ goto fail_rcu;
+
+ info->band = chanctx_conf->def.chan->band;
+
+ ieee80211_tx_stats(dev, skb->len);
+
+ ieee80211_xmit(sdata, NULL, skb);
+ rcu_read_unlock();
+
+ return;
+fail_rcu:
+ rcu_read_unlock();
+fail:
+ dev_kfree_skb(skb);
+}
+
+/**
+ * ieee80211_capwap_subif_start_xmit - netif start_xmit function for 802.3 vifs
+ * @skb: packet to be sent
+ * @dev: incoming interface
+ *
+ * On failure skb will be freed.
+ */
+netdev_tx_t ieee80211_capwap_subif_start_xmit(struct sk_buff *skb,
+ struct net_device *dev)
+{
+ if (skb->protocol == htons(ETH_P_CONTROL)) {
+ __ieee80211_capwap_inject_start_xmit(skb, dev);
+ } else
+ __ieee80211_subif_start_xmit(skb, dev, 0);
+
+ return NETDEV_TX_OK;
+}
+
+#endif
+
struct sk_buff *
ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb, u32 info_flags)
@@ -4409,3 +4518,180 @@ void __ieee80211_tx_skb_tid_band(struct
ieee80211_xmit(sdata, NULL, skb);
local_bh_enable();
}
+
+#ifdef CPTCFG_MAC80211_CAPWAP_WTP
+
+netdev_tx_t ieee80211_inject_xmit(struct sk_buff* skb, struct net_device* dev) {
+ int multicast;
+ struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+ struct ieee80211_chanctx_conf *chanctx_conf;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ struct ieee80211_sub_if_data *sdata;
+ struct cfg80211_chan_def *chandef;
+ struct ieee80211_hdr *hdr;
+ int hdrlen;
+ int queue_index;
+
+ /* */
+ if (skb->len < hdrlen) {
+ goto error;
+ }
+
+ /* */
+ skb->dev = dev;
+ skb_reset_mac_header(skb);
+ skb_reset_network_header(skb);
+ skb_reset_transport_header(skb);
+
+ hdr = (struct ieee80211_hdr *)skb->data;
+ hdrlen = ieee80211_hdrlen(hdr->frame_control);
+
+ if (skb->len < hdrlen) {
+ printk(KERN_WARNING, "droping packet for TO SMALL");
+ goto error;
+ }
+
+ /*
+ * Initialize skb->protocol if the injected frame is a data frame
+ * carrying a rfc1042 header
+ */
+ if (ieee80211_is_data(hdr->frame_control) &&
+ skb->len >= hdrlen + sizeof(rfc1042_header) + 2) {
+ u8 *payload = (u8 *)hdr + hdrlen;
+
+ if (ether_addr_equal(payload, rfc1042_header))
+ skb->protocol = cpu_to_be16((payload[6] << 8) |
+ payload[7]);
+ }
+
+ memset(info, 0, sizeof(struct ieee80211_tx_info));
+
+ rcu_read_lock();
+
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ if (sdata->vif.type != NL80211_IFTYPE_AP) {
+ printk(KERN_WARNING, "droping packet for NOT AP");
+ goto error_rcu;
+ }
+
+ chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+ if (!chanctx_conf) {
+ printk(KERN_WARNING, "droping packet for NO CHANTX");
+ goto error_rcu;
+ }
+
+ chandef = &chanctx_conf->def;
+
+ queue_index = ieee80211_select_queue_80211(sdata, skb, hdr);
+ skb_set_queue_mapping(skb, queue_index);
+
+ info->band = chandef->chan->band;
+ info->hw_queue =
+ sdata->vif.hw_queue[queue_index];
+
+ /*
+ * Frame injection is not allowed if beaconing is not allowed
+ * or if we need radar detection. Beaconing is usually not allowed when
+ * the mode or operation (Adhoc, AP, Mesh) does not support DFS.
+ * Passive scan is also used in world regulatory domains where
+ * your country is not known and as such it should be treated as
+ * NO TX unless the channel is explicitly allowed in which case
+ * your current regulatory domain would not have the passive scan
+ * flag.
+ *
+ * Since AP mode uses monitor interfaces to inject/TX management
+ * frames we can make AP mode the exception to this rule once it
+ * supports radar detection as its implementation can deal with
+ * radar detection by itself. We can do that later by adding a
+ * monitor flag interfaces used for AP support.
+ */
+ if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef,
+ sdata->vif.type)) {
+ printk(KERN_WARNING, "droping packet for CAN NOT BEACON");
+ goto error_rcu;
+ }
+ /* */
+ multicast = is_multicast_ether_addr(hdr->addr1);
+ if (!multicast) {
+ struct sta_info* sta = sta_info_get(sdata, hdr->addr1);
+ if (sta && test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
+ skb->pkt_type = PACKET_OTHERHOST;
+ } else {
+ printk(KERN_WARNING, "droping packet for STA not AUTHORIZED");
+ goto error_rcu;
+ }
+ } else {
+ if (ether_addr_equal_64bits(hdr->addr1, dev->broadcast)) {
+ skb->pkt_type = PACKET_BROADCAST;
+ } else {
+ skb->pkt_type = PACKET_MULTICAST;
+ }
+ }
+
+ /* */
+ if (unlikely(!multicast && skb->sk &&
+ skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) {
+ struct sk_buff *ack_skb = skb_clone_sk(skb);
+
+ if (ack_skb) {
+ unsigned long flags;
+ int id;
+ struct ieee80211_local* local = sdata->local;
+
+ spin_lock_irqsave(&local->ack_status_lock, flags);
+ id = idr_alloc(&local->ack_status_frames, ack_skb,
+ 1, 0x10000, GFP_ATOMIC);
+ spin_unlock_irqrestore(&local->ack_status_lock, flags);
+
+ if (id >= 0) {
+ info->ack_frame_id = id;
+ info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
+ } else {
+ kfree_skb(ack_skb);
+ }
+ }
+ }
+
+#if 0
+ /* If the skb is shared we need to obtain our own copy. */
+ if (skb_shared(skb)) {
+ struct sk_buff *tmp_skb = skb;
+
+ /* can't happen -- skb is a clone if info_id != 0 */
+ WARN_ON(info->ack_frame_id);
+
+ skb = skb_clone(skb, GFP_ATOMIC);
+ kfree_skb(tmp_skb);
+
+ if (!skb)
+ goto error_rcu;
+ }
+#endif
+
+ /* */
+ hdr->duration_id = 0;
+ hdr->seq_ctrl = 0;
+
+ /* */
+ ieee80211_tx_stats(dev, skb->len);
+
+ /* */
+/* dev->trans_start = jiffies; */
+
+ /* */
+ ieee80211_xmit(sdata, NULL, skb);
+ rcu_read_unlock();
+
+ return NETDEV_TX_OK;
+
+error_rcu:
+ rcu_read_unlock();
+
+error:
+ dev_kfree_skb(skb);
+ return NETDEV_TX_OK;
+}
+EXPORT_SYMBOL(ieee80211_inject_xmit);
+
+#endif
--- a/.local-symbols
+++ b/.local-symbols
@@ -42,6 +42,7 @@ LIB80211_CRYPT_CCMP=
LIB80211_CRYPT_TKIP=
LIB80211_DEBUG=
MAC80211=
+MAC80211_CAPWAP_WTP=
MAC80211_HAS_RC=
MAC80211_RC_MINSTREL=
MAC80211_RC_MINSTREL_HT=

View File

@ -1,23 +0,0 @@
diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
index 5c0ca3f..736f0bd 100644
--- a/package/kernel/mac80211/Makefile
+++ b/package/kernel/mac80211/Makefile
@@ -130,6 +130,10 @@ define KernelPackage/mac80211/config
bool "Enable 802.11s mesh support"
default y
+ config PACKAGE_MAC80211_CAPWAP_WTP
+ bool "Enabled CAPWAP support"
+ default n
+
endif
endef
@@ -1468,6 +1472,7 @@ config-$(call config_package,cfg80211) += CFG80211
config-$(call config_package,mac80211) += MAC80211
config-$(CONFIG_PACKAGE_MAC80211_MESH) += MAC80211_MESH
+config-$(CONFIG_PACKAGE_MAC80211_CAPWAP_WTP) += MAC80211_CAPWAP_WTP
ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS
config-y += \
CFG80211_DEBUGFS \

View File

@ -1,31 +1,25 @@
From abc84789bd6d42fdbfe598d72177ed41d54c7bcf Mon Sep 17 00:00:00 2001
From 03b6aa026d60cd49931934338d8ca82d05acc818 Mon Sep 17 00:00:00 2001
From: Andreas Schultz <aschultz@tpip.net>
Date: Thu, 4 Feb 2016 15:57:11 +0100
Subject: [PATCH] support patch for FreeWTP
Subject: [PATCH] support patch for smartcapwap
Allows for kernel side interception and injection of IEEE 802.11 frames.
---
include/net/mac80211.h | 31 +++++
net/mac80211/Kconfig | 7 ++
net/mac80211/ieee80211_i.h | 12 ++
net/mac80211/iface.c | 63 ++++++++++
net/mac80211/rx.c | 92 +++++++++++++--
net/mac80211/tx.c | 286 +++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 479 insertions(+), 12 deletions(-)
include/net/mac80211.h | 25 ++++
net/mac80211/ieee80211_i.h | 6 +
net/mac80211/iface.c | 56 +++++++++
net/mac80211/rx.c | 81 ++++++++++--
net/mac80211/tx.c | 306 +++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 462 insertions(+), 12 deletions(-)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 760bc4d..bf60d9d 100644
index 760bc4d..6722da6 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2199,6 +2199,37 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
*/
@@ -2200,6 +2200,31 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+
+extern struct static_key mac80211_capwap_wtp;
+
+/**
/**
+ *
+ */
+struct ieee80211_pcktunnel {
@ -50,76 +44,50 @@ index 760bc4d..bf60d9d 100644
+ */
+netdev_tx_t ieee80211_inject_xmit(struct sk_buff* skb, struct net_device* dev);
+
+#endif
+
/**
+/**
* DOC: Hardware crypto acceleration
*
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index 3891cbd..4ff4461 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -318,3 +318,10 @@ config MAC80211_STA_HASH_MAX_SIZE
connect more stations than the number selected here.)
If unsure, leave the default of 0.
+
+config MAC80211_CAPWAP_WTP
+ bool "Enable support functions for out-of-tree CAPWAP WTP module"
+ depends on MAC80211
+ ---help---
+ Select this to build support hooks for out-of-tree CAPWAP FreeWTP
+ module.
* mac80211 is capable of taking advantage of many hardware
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 6837a46..e96cbff 100644
index 5322b4c..667c9ff 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -180,6 +180,9 @@ typedef unsigned __bitwise__ ieee80211_rx_result;
@@ -180,6 +180,7 @@ typedef unsigned __bitwise__ ieee80211_rx_result;
#define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
#define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
#define RX_QUEUED ((__force ieee80211_rx_result) 3u)
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+#define RX_IGNORE_MONITOR ((__force ieee80211_rx_result) 4u)
+#endif
/**
* enum ieee80211_packet_rx_flags - packet RX flags
@@ -835,6 +838,11 @@ struct ieee80211_sub_if_data {
@@ -835,6 +836,9 @@ struct ieee80211_sub_if_data {
char name[IFNAMSIZ];
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+ /* Packet tunnel handlers */
+ struct ieee80211_pcktunnel __rcu *pcktunnel_handlers;
+#endif
+
/* Fragment table for host-based reassembly */
struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
unsigned int fragment_next;
@@ -1632,6 +1640,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
@@ -1632,6 +1636,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
void __ieee80211_subif_start_xmit(struct sk_buff *skb,
struct net_device *dev,
u32 info_flags);
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+netdev_tx_t ieee80211_capwap_subif_start_xmit(struct sk_buff *skb,
+ struct net_device *dev);
+#endif
void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
struct sk_buff_head *skbs);
struct sk_buff *
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index bcb0a1b..8e2069f 100644
index c9e325d..15ce6e3 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1955,3 +1955,66 @@ void ieee80211_iface_exit(void)
@@ -1952,3 +1952,59 @@ void ieee80211_iface_exit(void)
{
unregister_netdevice_notifier(&mac80211_netdev_notifier);
}
+
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+
+struct static_key mac80211_capwap_wtp __read_mostly;
+
+static const struct net_device_ops ieee80211_capwapif_ops = {
+ .ndo_open = ieee80211_open,
+ .ndo_stop = ieee80211_stop,
@ -145,7 +113,6 @@ index bcb0a1b..8e2069f 100644
+ ret = -EBUSY;
+ } else {
+ rcu_assign_pointer(sdata->pcktunnel_handlers, handler);
+ static_key_slow_inc(&mac80211_capwap_wtp);
+ }
+
+ mutex_unlock(&sdata->local->iflist_mtx);
@ -166,7 +133,6 @@ index bcb0a1b..8e2069f 100644
+ h = rcu_dereference_protected(sdata->pcktunnel_handlers, lockdep_is_held(&sdata->local->iflist_mtx));
+ if (h == handler) {
+ ret = 0;
+ static_key_slow_dec(&mac80211_capwap_wtp);
+ rcu_assign_pointer(sdata->pcktunnel_handlers, NULL);
+ }
+
@ -177,17 +143,14 @@ index bcb0a1b..8e2069f 100644
+}
+EXPORT_SYMBOL(ieee80211_pcktunnel_deregister);
+
+#endif
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index a3bb8f7..cbe0642 100644
index 82af407..29cc59b 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -3058,6 +3058,56 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
@@ -3039,6 +3039,51 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
return RX_QUEUED;
}
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+
+static ieee80211_rx_result debug_noinline
+ieee80211_rx_h_pcktunnel(struct ieee80211_rx_data *rx, struct ieee80211_rate *rate)
+{
@ -233,23 +196,18 @@ index a3bb8f7..cbe0642 100644
+}
+
+/* TODO: use IEEE80211_RX_FRAGMENTED */
+
+#endif
+
static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
struct ieee80211_rate *rate)
{
@@ -3137,6 +3187,9 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
@@ -3118,6 +3163,7 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
if (rx->sta)
rx->sta->rx_stats.dropped++;
/* fall through */
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+ case RX_IGNORE_MONITOR:
+#endif
case RX_CONTINUE: {
struct ieee80211_rate *rate = NULL;
struct ieee80211_supported_band *sband;
@@ -3165,7 +3218,9 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
@@ -3146,7 +3192,9 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
}
static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx,
@ -260,23 +218,19 @@ index a3bb8f7..cbe0642 100644
{
ieee80211_rx_result res = RX_DROP_MONITOR;
struct sk_buff *skb;
@@ -3204,6 +3259,15 @@ static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx,
@@ -3185,6 +3233,11 @@ static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx,
if (ieee80211_vif_is_mesh(&rx->sdata->vif))
CALL_RXH(ieee80211_rx_h_mesh_fwding);
#endif
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+ if (static_key_false(&mac80211_capwap_wtp)) {
+ /* special treatment */
+ res = ieee80211_rx_h_pcktunnel(rx, rate);
+ if (res != RX_CONTINUE)
+ goto rxh_next;
+ }
+#endif
+ /* special treatment */
+ res = ieee80211_rx_h_pcktunnel(rx, rate);
+ if (res != RX_CONTINUE)
+ goto rxh_next;
+
CALL_RXH(ieee80211_rx_h_amsdu)
CALL_RXH(ieee80211_rx_h_data)
@@ -3227,7 +3291,8 @@ static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx,
@@ -3208,7 +3261,8 @@ static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx,
spin_unlock_bh(&rx->local->rx_path_lock);
}
@ -286,7 +240,7 @@ index a3bb8f7..cbe0642 100644
{
struct sk_buff_head reorder_release;
ieee80211_rx_result res = RX_DROP_MONITOR;
@@ -3246,7 +3311,7 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_rx_data *rx)
@@ -3227,7 +3281,7 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_rx_data *rx)
ieee80211_rx_reorder_ampdu(rx, &reorder_release);
@ -295,7 +249,7 @@ index a3bb8f7..cbe0642 100644
return;
rxh_next:
@@ -3292,7 +3357,7 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
@@ -3273,7 +3327,7 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
drv_event_callback(rx.local, rx.sdata, &event);
}
@ -304,7 +258,7 @@ index a3bb8f7..cbe0642 100644
}
/* main receive path */
@@ -3415,7 +3480,9 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
@@ -3395,7 +3449,9 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
* or not the skb was consumed.
*/
static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
@ -315,7 +269,7 @@ index a3bb8f7..cbe0642 100644
{
struct ieee80211_local *local = rx->local;
struct ieee80211_sub_if_data *sdata = rx->sdata;
@@ -3438,7 +3505,7 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
@@ -3418,7 +3474,7 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
rx->skb = skb;
}
@ -324,7 +278,7 @@ index a3bb8f7..cbe0642 100644
return true;
}
@@ -3448,7 +3515,8 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
@@ -3428,7 +3484,8 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
*/
static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
struct sk_buff *skb,
@ -334,7 +288,7 @@ index a3bb8f7..cbe0642 100644
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_sub_if_data *sdata;
@@ -3507,7 +3575,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
@@ -3487,7 +3544,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
rx.sta = prev_sta;
rx.sdata = prev_sta->sdata;
@ -343,7 +297,7 @@ index a3bb8f7..cbe0642 100644
prev_sta = sta;
}
@@ -3516,7 +3584,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
@@ -3496,7 +3553,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
rx.sta = prev_sta;
rx.sdata = prev_sta->sdata;
@ -352,7 +306,7 @@ index a3bb8f7..cbe0642 100644
return;
goto out;
}
@@ -3545,7 +3613,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
@@ -3525,7 +3582,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
rx.sta = sta_info_get_bss(prev, hdr->addr2);
rx.sdata = prev;
@ -361,7 +315,7 @@ index a3bb8f7..cbe0642 100644
prev = sdata;
}
@@ -3554,7 +3622,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
@@ -3534,7 +3591,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
rx.sta = sta_info_get_bss(prev, hdr->addr2);
rx.sdata = prev;
@ -370,7 +324,7 @@ index a3bb8f7..cbe0642 100644
return;
}
@@ -3666,7 +3734,7 @@ void ieee80211_rx_napi(struct ieee80211_hw *hw, struct sk_buff *skb,
@@ -3646,7 +3703,7 @@ void ieee80211_rx_napi(struct ieee80211_hw *hw, struct sk_buff *skb,
ieee80211_tpt_led_trig_rx(local,
((struct ieee80211_hdr *)skb->data)->frame_control,
skb->len);
@ -380,15 +334,13 @@ index a3bb8f7..cbe0642 100644
rcu_read_unlock();
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index bdc224d..5f1f424 100644
index bdc224d..3769c33 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2939,6 +2939,115 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
@@ -2939,6 +2939,138 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+
+/*
+ * inject raw 802.11 frame, processing is mostly identical
+ * to ieee80211_monitor_start_xmit, except for the different
@ -401,9 +353,8 @@ index bdc224d..5f1f424 100644
+ struct ieee80211_chanctx_conf *chanctx_conf;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_sub_if_data *tmp_sdata, *sdata;
+ struct cfg80211_chan_def *chandef;
+ int tid;
+ int hdrlen;
+
+ /* check for not even having the fixed 802.11 header */
@ -416,13 +367,13 @@ index bdc224d..5f1f424 100644
+ if (unlikely(skb->len < hdrlen))
+ goto fail; /* skb too short for claimed header length */
+
+ skb_set_mac_header(skb, 0);
+ skb_reset_mac_header(skb);
+ /*
+ * these are just fixed to the end of the rt area since we
+ * don't have any better information and at this point, nobody cares
+ */
+ skb_set_network_header(skb, hdrlen);
+ skb_set_transport_header(skb, hdrlen);
+ skb_reset_network_header(skb);
+ skb_reset_transport_header(skb);
+
+ /*
+ * Initialize skb->protocol if the injected frame is a data frame
@ -437,17 +388,12 @@ index bdc224d..5f1f424 100644
+ payload[7]);
+ }
+
+ if (ieee80211_is_data_qos(hdr->frame_control)) {
+ u8 *p = ieee80211_get_qos_ctl(hdr);
+
+ skb->priority = *p & IEEE80211_QOS_CTL_TAG1D_MASK;
+ }
+ skb_set_queue_mapping(skb, ieee802_1d_to_ac[skb->priority]);
+
+ memset(info, 0, sizeof(*info));
+
+ info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS |
+ IEEE80211_TX_CTL_INJECTED;
+
+
+ /*
+ * we might have set these flags later.....
+ * info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT;
@ -459,17 +405,46 @@ index bdc224d..5f1f424 100644
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+ if (!chanctx_conf)
+ if (!chanctx_conf) {
+ tmp_sdata = rcu_dereference(local->monitor_sdata);
+ if (tmp_sdata)
+ chanctx_conf =
+ rcu_dereference(tmp_sdata->vif.chanctx_conf);
+ }
+
+ if (chanctx_conf)
+ chandef = &chanctx_conf->def;
+ else if (!local->use_chanctx)
+ chandef = &local->_oper_chandef;
+ else
+ goto fail_rcu;
+
+ info->band = chanctx_conf->def.chan->band;
+
+ ieee80211_tx_stats(dev, skb->len);
+ /*
+ * Frame injection is not allowed if beaconing is not allowed
+ * or if we need radar detection. Beaconing is usually not allowed when
+ * the mode or operation (Adhoc, AP, Mesh) does not support DFS.
+ * Passive scan is also used in world regulatory domains where
+ * your country is not known and as such it should be treated as
+ * NO TX unless the channel is explicitly allowed in which case
+ * your current regulatory domain would not have the passive scan
+ * flag.
+ *
+ * Since AP mode uses monitor interfaces to inject/TX management
+ * frames we can make AP mode the exception to this rule once it
+ * supports radar detection as its implementation can deal with
+ * radar detection by itself. We can do that later by adding a
+ * monitor flag interfaces used for AP support.
+ */
+ if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef,
+ sdata->vif.type))
+ goto fail_rcu;
+
+ info->band = chandef->chan->band;
+ ieee80211_xmit(sdata, NULL, skb);
+ rcu_read_unlock();
+
+ return;
+
+fail_rcu:
+ rcu_read_unlock();
+fail:
@ -486,6 +461,10 @@ index bdc224d..5f1f424 100644
+netdev_tx_t ieee80211_capwap_subif_start_xmit(struct sk_buff *skb,
+ struct net_device *dev)
+{
+ if (skb->protocol != htons(ETH_P_IP))
+ printk(KERN_DEBUG "capwap xmit %s: protocol: %04X, data: %p, MAC: %p\n",
+ dev->name, ntohs(skb->protocol), skb->data, skb_mac_header(skb));
+
+ if (skb->protocol == htons(ETH_P_CONTROL)) {
+ __ieee80211_capwap_inject_start_xmit(skb, dev);
+ } else
@ -493,19 +472,15 @@ index bdc224d..5f1f424 100644
+
+ return NETDEV_TX_OK;
+}
+
+#endif
+
struct sk_buff *
ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb, u32 info_flags)
@@ -3914,3 +4023,180 @@ void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
@@ -3914,3 +4046,177 @@ void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
ieee80211_xmit(sdata, NULL, skb);
local_bh_enable();
}
+
+#ifdef CONFIG_MAC80211_CAPWAP_WTP
+
+netdev_tx_t ieee80211_inject_xmit(struct sk_buff* skb, struct net_device* dev) {
+ int multicast;
+ struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
@ -679,7 +654,6 @@ index bdc224d..5f1f424 100644
+}
+EXPORT_SYMBOL(ieee80211_inject_xmit);
+
+#endif
--
2.9.3
2.7.0

View File

@ -1,67 +0,0 @@
# FreeWTP -- An Open Source CAPWAP WTP
#
# Copyright SmartCAPWAP (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
# Copyright FreeCAPWAP (C) 2016 Travelping GmbH <info@travelping.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING included with this
# distribution); if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bin_PROGRAMS = wtp
AM_CFLAGS = -std=gnu99 -D_GNU_SOURCE \
-fno-strict-aliasing \
${LIBNL_CFLAGS}
if DTLS_ENABLED
AM_CFLAGS += $(WOLFSSL_CFLAGS)
endif
AM_CFLAGS += \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/src \
-I$(top_srcdir)/kmod \
-I$(top_srcdir)/lib/binding/ieee80211 \
-I$(top_srcdir)/src/binding/ieee80211
wtp_SOURCES = \
wtp.c \
kmod.c \
element_helper.c \
dfa.c \
dfa_idle.c \
dfa_discovery.c \
dfa_sulking.c \
dfa_dtls.c \
dfa_join.c \
dfa_configure.c \
dfa_datacheck.c \
dfa_run.c \
dfa_reset.c \
dfa_imagedata.c \
radio.c \
binding/ieee80211/netlink_link.c \
binding/ieee80211/wifi_drivers.c
if BUILD_WTP_WIFI_DRIVERS_NL80211
wtp_SOURCES += binding/ieee80211/wifi_nl80211.c
endif
wtp_LDADD = $(CONFIG_LIBS) \
$(LIBNL_LIBS) \
$(top_builddir)/lib/libcapwap.la
if DTLS_ENABLED
wtp_LDADD += $(WOLFSSL_LIBS)
endif

904
src/ac/ac.c Normal file
View File

@ -0,0 +1,904 @@
#include "ac.h"
#include "ac_soap.h"
#include "ac_session.h"
#include "capwap_dtls.h"
#include "capwap_socket.h"
#include "ac_wlans.h"
#include <libconfig.h>
#ifndef CAPWAP_MULTITHREADING_ENABLE
#error "AC request multithreading\n"
#endif
struct ac_t g_ac;
/* */
#define AC_STANDARD_NAME "Unknown AC"
#define AC_STATIONS_HASH_SIZE 65536
#define AC_IFDATACHANNEL_HASH_SIZE 16
/* Local param */
static char g_configurationfile[260] = AC_DEFAULT_CONFIGURATION_FILE;
/* */
static unsigned long ac_stations_item_gethash(const void* key, unsigned long hashsize) {
uint8_t* macaddress = (uint8_t*)key;
return (((((unsigned long)macaddress[4] << 8) | (unsigned long)macaddress[5]) ^ ((unsigned long)macaddress[3] << 4)) % AC_STATIONS_HASH_SIZE);
}
/* */
static const void* ac_stations_item_getkey(const void* data) {
return (const void*)((struct ac_station*)data)->address;
}
/* */
static int ac_stations_item_cmp(const void* key1, const void* key2) {
return memcmp(key1, key2, MACADDRESS_EUI48_LENGTH);
}
/* */
static unsigned long ac_ifdatachannel_item_gethash(const void* key, unsigned long hashsize) {
return ((*(unsigned long*)key) % AC_IFDATACHANNEL_HASH_SIZE);
}
/* */
static const void* ac_ifdatachannel_item_getkey(const void* data) {
return (const void*)&((struct ac_if_datachannel*)data)->index;
}
/* */
static int ac_ifdatachannel_item_cmp(const void* key1, const void* key2) {
unsigned long value1 = *(unsigned long*)key1;
unsigned long value2 = *(unsigned long*)key2;
return ((value1 == value2) ? 0 : ((value1 < value2) ? -1 : 1));
}
/* */
static void ac_ifdatachannel_item_free(void* data) {
struct ac_if_datachannel* datachannel = (struct ac_if_datachannel*)data;
/* */
if (datachannel->ifindex >= 0) {
ac_kmod_delete_iface(datachannel->ifindex);
}
capwap_free(data);
}
/* Alloc AC */
static int ac_init(void) {
g_ac.standalone = 1;
/* Sessions message queue */
if (!ac_msgqueue_init()) {
return 0;
}
/* Network */
capwap_network_init(&g_ac.net);
g_ac.addrlist = capwap_list_create();
g_ac.mtu = CAPWAP_MTU_DEFAULT;
g_ac.binding = capwap_array_create(sizeof(uint16_t), 0, 0);
/* Try to use IPv6 */
g_ac.net.localaddr.ss.ss_family = AF_INET6;
CAPWAP_SET_NETWORK_PORT(&g_ac.net.localaddr, CAPWAP_CONTROL_PORT);
/* Standard name */
g_ac.acname.name = (uint8_t*)capwap_duplicate_string(AC_STANDARD_NAME);
/* Descriptor */
g_ac.descriptor.stationlimit = AC_DEFAULT_MAXSTATION;
g_ac.descriptor.maxwtp = AC_DEFAULT_MAXSESSIONS;
g_ac.descriptor.security = 0;
g_ac.descriptor.rmacfield = CAPWAP_ACDESC_RMACFIELD_NOTSUPPORTED;
g_ac.descriptor.dtlspolicy = CAPWAP_ACDESC_CLEAR_DATA_CHANNEL_ENABLED;
g_ac.descriptor.descsubelement = capwap_array_create(sizeof(struct capwap_acdescriptor_desc_subelement), 0, 1);
/* */
g_ac.dfa.ecn.flag = CAPWAP_LIMITED_ECN_SUPPORT;
g_ac.dfa.transport.type = CAPWAP_UDP_TRANSPORT;
/* */
g_ac.dfa.timers.discovery = AC_DISCOVERY_INTERVAL / 1000;
g_ac.dfa.timers.echorequest = AC_ECHO_INTERVAL / 1000;
g_ac.dfa.decrypterrorreport_interval = AC_DECRYPT_ERROR_PERIOD_INTERVAL / 1000;
g_ac.dfa.idletimeout.timeout = AC_IDLE_TIMEOUT_INTERVAL / 1000;
g_ac.dfa.wtpfallback.mode = AC_WTP_FALLBACK_MODE;
/* */
g_ac.dfa.acipv4list.addresses = capwap_array_create(sizeof(struct in_addr), 0, 0);
g_ac.dfa.acipv6list.addresses = capwap_array_create(sizeof(struct in6_addr), 0, 0);
/* Sessions */
g_ac.sessions = capwap_list_create();
g_ac.sessionsthread = capwap_list_create();
capwap_rwlock_init(&g_ac.sessionslock);
/* Stations */
g_ac.authstations = capwap_hash_create(AC_STATIONS_HASH_SIZE);
g_ac.authstations->item_gethash = ac_stations_item_gethash;
g_ac.authstations->item_getkey = ac_stations_item_getkey;
g_ac.authstations->item_cmp = ac_stations_item_cmp;
capwap_rwlock_init(&g_ac.authstationslock);
/* Data Channel Interfaces */
g_ac.ifdatachannel = capwap_hash_create(AC_IFDATACHANNEL_HASH_SIZE);
g_ac.ifdatachannel->item_gethash = ac_ifdatachannel_item_gethash;
g_ac.ifdatachannel->item_getkey = ac_ifdatachannel_item_getkey;
g_ac.ifdatachannel->item_cmp = ac_ifdatachannel_item_cmp;
g_ac.ifdatachannel->item_free = ac_ifdatachannel_item_free;
capwap_rwlock_init(&g_ac.ifdatachannellock);
/* Backend */
g_ac.availablebackends = capwap_array_create(sizeof(struct ac_http_soap_server*), 0, 0);
return 1;
}
/* Destroy AC */
static void ac_destroy(void) {
int i;
/* Dtls */
capwap_crypt_freecontext(&g_ac.dtlscontext);
/* */
for (i = 0; i < g_ac.descriptor.descsubelement->count; i++) {
struct capwap_acdescriptor_desc_subelement* desc = (struct capwap_acdescriptor_desc_subelement*)capwap_array_get_item_pointer(g_ac.descriptor.descsubelement, i);
if (desc->data) {
capwap_free(desc->data);
}
}
/* */
capwap_array_free(g_ac.descriptor.descsubelement);
capwap_array_free(g_ac.binding);
capwap_free(g_ac.acname.name);
/* */
capwap_array_free(g_ac.dfa.acipv4list.addresses);
capwap_array_free(g_ac.dfa.acipv6list.addresses);
/* Sessions */
capwap_list_free(g_ac.sessions);
capwap_list_free(g_ac.sessionsthread);
capwap_rwlock_destroy(&g_ac.sessionslock);
ac_msgqueue_free();
/* Data Channel Interfaces */
ASSERT(g_ac.ifdatachannel->count == 0);
capwap_hash_free(g_ac.ifdatachannel);
capwap_rwlock_destroy(&g_ac.ifdatachannellock);
/* Stations */
ASSERT(g_ac.authstations->count == 0);
capwap_hash_free(g_ac.authstations);
capwap_rwlock_destroy(&g_ac.authstationslock);
/* Backend */
if (g_ac.backendacid) {
capwap_free(g_ac.backendacid);
}
if (g_ac.backendversion) {
capwap_free(g_ac.backendversion);
}
for (i = 0; i < g_ac.availablebackends->count; i++) {
ac_soapclient_free_server(*(struct ac_http_soap_server**)capwap_array_get_item_pointer(g_ac.availablebackends, i));
}
capwap_array_free(g_ac.availablebackends);
capwap_list_free(g_ac.addrlist);
}
/* Help */
static void ac_print_usage(void) {
}
/* Parsing configuration */
static int ac_parsing_configuration_1_0(config_t* config) {
int i;
int configBool;
LIBCONFIG_LOOKUP_INT_ARG configInt;
const char* configString;
config_setting_t* configSetting;
/* Logging configuration */
if (config_lookup_bool(config, "logging.enable", &configBool) == CONFIG_TRUE) {
if (!configBool) {
capwap_logging_verboselevel(CAPWAP_LOGGING_NONE);
capwap_logging_disable_allinterface();
} else {
if (config_lookup_string(config, "logging.level", &configString) == CONFIG_TRUE) {
if (!strcmp(configString, "fatal")) {
capwap_logging_verboselevel(CAPWAP_LOGGING_FATAL);
} else if (!strcmp(configString, "error")) {
capwap_logging_verboselevel(CAPWAP_LOGGING_ERROR);
} else if (!strcmp(configString, "warning")) {
capwap_logging_verboselevel(CAPWAP_LOGGING_WARNING);
} else if (!strcmp(configString, "info")) {
capwap_logging_verboselevel(CAPWAP_LOGGING_INFO);
} else if (!strcmp(configString, "debug")) {
capwap_logging_verboselevel(CAPWAP_LOGGING_DEBUG);
} else {
capwap_logging_error("Invalid configuration file, unknown logging.level value");
return 0;
}
}
/* Logging output interface */
configSetting = config_lookup(config, "logging.output");
if (configSetting != NULL) {
int count = config_setting_length(configSetting);
/* Disable output interface */
capwap_logging_disable_allinterface();
/* Enable selected interface */
for (i = 0; i < count; i++) {
config_setting_t* configElement = config_setting_get_elem(configSetting, i);
if ((configElement != NULL) && (config_setting_lookup_string(configElement, "mode", &configString) == CONFIG_TRUE)) {
if (!strcmp(configString, "stdout")) {
capwap_logging_enable_console(0);
} else if (!strcmp(configString, "stderr")) {
capwap_logging_enable_console(1);
} else {
capwap_logging_error("Invalid configuration file, unknown logging.output value");
return 0;
}
}
}
}
}
}
/* Set running mode */
if (config_lookup_bool(config, "application.standalone", &configBool) == CONFIG_TRUE) {
g_ac.standalone = ((configBool != 0) ? 1 : 0);
}
/* Set name of AC */
if (config_lookup_string(config, "application.name", &configString) == CONFIG_TRUE) {
if (strlen(configString) > CAPWAP_ACNAME_MAXLENGTH) {
capwap_logging_error("Invalid configuration file, application.name string length exceeded");
return 0;
}
capwap_free(g_ac.acname.name);
g_ac.acname.name = (uint8_t*)capwap_duplicate_string(configString);
}
/* Set binding of AC */
configSetting = config_lookup(config, "application.binding");
if (configSetting != NULL) {
int count = config_setting_length(configSetting);
for (i = 0; i < count; i++) {
const char* bindingName = config_setting_get_string_elem(configSetting, i);
if (bindingName != NULL) {
unsigned short* binding = (unsigned short*)capwap_array_get_item_pointer(g_ac.binding, g_ac.binding->count);
if (!strcmp(bindingName, "802.11")) {
*binding = CAPWAP_WIRELESS_BINDING_IEEE80211;
} else if (!strcmp(bindingName, "EPCGlobal")) {
*binding = CAPWAP_WIRELESS_BINDING_EPCGLOBAL;
} else {
capwap_logging_error("Invalid configuration file, unknown application.binding value");
return 0;
}
}
}
}
/* Set max stations of AC */
if (config_lookup_int(config, "application.descriptor.maxstations", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65536)) {
g_ac.descriptor.stationlimit = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, unknown application.descriptor.maxstations value");
return 0;
}
}
/* Set max wtp of AC */
if (config_lookup_int(config, "application.descriptor.maxwtp", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65536)) {
g_ac.descriptor.maxwtp = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, unknown application.descriptor.maxwtp value");
return 0;
}
}
/* Set security of AC */
if (config_lookup(config, "application.descriptor.security") != NULL) {
g_ac.descriptor.security = 0;
if (config_lookup_bool(config, "application.descriptor.security.presharedkey", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
g_ac.descriptor.security |= CAPWAP_ACDESC_SECURITY_PRESHARED_KEY;
}
}
if (config_lookup_bool(config, "application.descriptor.security.x509", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
g_ac.descriptor.security |= CAPWAP_ACDESC_SECURITY_X509_CERT;
}
}
}
/* Set rmacfiled of AC */
if (config_lookup_bool(config, "application.descriptor.rmacfiled.supported", &configBool) == CONFIG_TRUE) {
g_ac.descriptor.rmacfield = ((configBool != 0) ? CAPWAP_ACDESC_RMACFIELD_SUPPORTED : CAPWAP_ACDESC_RMACFIELD_NOTSUPPORTED);
}
/* Set DTLS policy of AC */
if (config_lookup(config, "application.descriptor.dtlspolicy") != NULL) {
g_ac.descriptor.dtlspolicy = 0;
if (config_lookup_bool(config, "application.descriptor.dtlspolicy.cleardatachannel", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
g_ac.descriptor.dtlspolicy |= CAPWAP_ACDESC_CLEAR_DATA_CHANNEL_ENABLED;
}
}
if (config_lookup_bool(config, "application.descriptor.dtlspolicy.dtlsdatachannel", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
g_ac.descriptor.dtlspolicy |= CAPWAP_ACDESC_DTLS_DATA_CHANNEL_ENABLED;
}
}
}
/* Set info descriptor of AC */
configSetting = config_lookup(config, "application.descriptor.info");
if (configSetting != NULL) {
int count = config_setting_length(configSetting);
for (i = 0; i < count; i++) {
config_setting_t* configElement = config_setting_get_elem(configSetting, i);
if (configElement != NULL) {
LIBCONFIG_LOOKUP_INT_ARG configVendor;
if (config_setting_lookup_int(configElement, "idvendor", &configVendor) == CONFIG_TRUE) {
const char* configType;
if (config_setting_lookup_string(configElement, "type", &configType) == CONFIG_TRUE) {
const char* configValue;
if (config_setting_lookup_string(configElement, "value", &configValue) == CONFIG_TRUE) {
int lengthValue = strlen(configValue);
if (lengthValue < CAPWAP_ACDESC_SUBELEMENT_MAXDATA) {
unsigned short type;
struct capwap_acdescriptor_desc_subelement* desc;
if (!strcmp(configType, "hardware")) {
type = CAPWAP_ACDESC_SUBELEMENT_HARDWAREVERSION;
} else if (!strcmp(configType, "software")) {
type = CAPWAP_ACDESC_SUBELEMENT_SOFTWAREVERSION;
} else {
capwap_logging_error("Invalid configuration file, unknown application.descriptor.info.type value");
return 0;
}
desc = (struct capwap_acdescriptor_desc_subelement*)capwap_array_get_item_pointer(g_ac.descriptor.descsubelement, g_ac.descriptor.descsubelement->count);
desc->vendor = (unsigned long)configVendor;
desc->type = type;
desc->length = lengthValue;
desc->data = (uint8_t*)capwap_alloc(desc->length + 1);
strcpy((char*)desc->data, configValue);
desc->data[desc->length] = 0;
} else {
capwap_logging_error("Invalid configuration file, application.descriptor.info.value string length exceeded");
return 0;
}
} else {
capwap_logging_error("Invalid configuration file, element application.descriptor.info.value not found");
return 0;
}
} else {
capwap_logging_error("Invalid configuration file, element application.descriptor.info.type not found");
return 0;
}
} else {
capwap_logging_error("Invalid configuration file, element application.descriptor.info.idvendor not found");
return 0;
}
}
}
}
/* Set ECN of AC */
if (config_lookup_string(config, "application.ecn", &configString) == CONFIG_TRUE) {
if (!strcmp(configString, "full")) {
g_ac.dfa.ecn.flag = CAPWAP_FULL_ECN_SUPPORT;
} else if (!strcmp(configString, "limited")) {
g_ac.dfa.ecn.flag = CAPWAP_LIMITED_ECN_SUPPORT;
} else {
capwap_logging_error("Invalid configuration file, unknown application.ecn value");
return 0;
}
}
/* Set Timer of AC */
if (config_lookup_int(config, "application.timer.discovery", &configInt) == CONFIG_TRUE) {
configInt *= 1000; /* Set timeout in ms */
if ((configInt >= AC_MIN_DISCOVERY_INTERVAL) && (configInt <= AC_MAX_DISCOVERY_INTERVAL)) {
g_ac.dfa.timers.discovery = (unsigned char)(configInt / 1000);
} else {
capwap_logging_error("Invalid configuration file, invalid application.timer.discovery value");
return 0;
}
}
if (config_lookup_int(config, "application.timer.echorequest", &configInt) == CONFIG_TRUE) {
configInt *= 1000;
if ((configInt >= AC_MIN_ECHO_INTERVAL) && (configInt <= AC_MAX_ECHO_INTERVAL)) {
g_ac.dfa.timers.echorequest = (unsigned char)(configInt / 1000);
} else {
capwap_logging_error("Invalid configuration file, invalid application.timer.echorequest value");
return 0;
}
}
if (config_lookup_int(config, "application.timer.decrypterrorreport", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65536)) {
g_ac.dfa.decrypterrorreport_interval = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.timer.decrypterrorreport value");
return 0;
}
}
if (config_lookup_int(config, "application.timer.idletimeout", &configInt) == CONFIG_TRUE) {
if (configInt > 0) {
g_ac.dfa.idletimeout.timeout = (unsigned long)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.timer.idletimeout value");
return 0;
}
}
/* Set wtpfallback of AC */
if (config_lookup_bool(config, "application.wtpfallback", &configBool) == CONFIG_TRUE) {
g_ac.dfa.wtpfallback.mode = ((configBool != 0) ? CAPWAP_WTP_FALLBACK_ENABLED : CAPWAP_WTP_FALLBACK_DISABLED);
}
/* Set DTLS of WTP */
if (config_lookup_bool(config, "application.dtls.enable", &configBool) == CONFIG_TRUE) {
if (configBool != 0) {
struct capwap_dtls_param dtlsparam;
/* Init dtls param */
memset(&dtlsparam, 0, sizeof(struct capwap_dtls_param));
dtlsparam.type = CAPWAP_DTLS_SERVER;
/* Set DTLS type of AC */
if (config_lookup_string(config, "application.dtls.type", &configString) == CONFIG_TRUE) {
if (!strcmp(configString, "x509")) {
dtlsparam.mode = CAPWAP_DTLS_MODE_CERTIFICATE;
} else if (!strcmp(configString, "presharedkey")) {
dtlsparam.mode = CAPWAP_DTLS_MODE_PRESHAREDKEY;
} else {
capwap_logging_error("Invalid configuration file, unknown application.dtls.type value");
return 0;
}
}
/* Set DTLS configuration of AC */
if (dtlsparam.mode == CAPWAP_DTLS_MODE_CERTIFICATE) {
if (config_lookup_string(config, "application.dtls.x509.calist", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
dtlsparam.cert.fileca = capwap_duplicate_string(configString);
}
}
if (config_lookup_string(config, "application.dtls.x509.certificate", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
dtlsparam.cert.filecert = capwap_duplicate_string(configString);
}
}
if (config_lookup_string(config, "application.dtls.x509.privatekey", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
dtlsparam.cert.filekey = capwap_duplicate_string(configString);
}
}
if (dtlsparam.cert.fileca && dtlsparam.cert.filecert && dtlsparam.cert.filekey) {
if (capwap_crypt_createcontext(&g_ac.dtlscontext, &dtlsparam)) {
g_ac.enabledtls = 1;
}
}
/* Free dtls param */
if (dtlsparam.cert.fileca) {
capwap_free(dtlsparam.cert.fileca);
}
if (dtlsparam.cert.filecert) {
capwap_free(dtlsparam.cert.filecert);
}
if (dtlsparam.cert.filekey) {
capwap_free(dtlsparam.cert.filekey);
}
} else if (dtlsparam.mode == CAPWAP_DTLS_MODE_PRESHAREDKEY) {
if (config_lookup_string(config, "application.dtls.presharedkey.hint", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
dtlsparam.presharedkey.hint = capwap_duplicate_string(configString);
}
}
if (config_lookup_string(config, "application.dtls.presharedkey.identity", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
dtlsparam.presharedkey.identity = capwap_duplicate_string(configString);
}
}
if (config_lookup_string(config, "application.dtls.presharedkey.pskkey", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
/* TODO controllare se <20> un valore hex */
dtlsparam.presharedkey.pskkey = capwap_duplicate_string(configString);
}
}
/* */
if (dtlsparam.presharedkey.identity && dtlsparam.presharedkey.pskkey) {
if (capwap_crypt_createcontext(&g_ac.dtlscontext, &dtlsparam)) {
g_ac.enabledtls = 1;
}
}
/* Free dtls param */
if (dtlsparam.presharedkey.hint) {
capwap_free(dtlsparam.presharedkey.hint);
}
if (dtlsparam.presharedkey.identity) {
capwap_free(dtlsparam.presharedkey.identity);
}
if (dtlsparam.presharedkey.pskkey) {
capwap_free(dtlsparam.presharedkey.pskkey);
}
}
if (!g_ac.enabledtls) {
return 0;
}
}
}
/* Set interface binding of AC */
if (config_lookup_string(config, "application.network.binding", &configString) == CONFIG_TRUE) {
if (strlen(configString) > (IFNAMSIZ - 1)) {
capwap_logging_error("Invalid configuration file, application.network.binding string length exceeded");
return 0;
}
strcpy(g_ac.net.bindiface, configString);
}
/* Set mtu of AC */
if (config_lookup_int(config, "application.network.mtu", &configInt) == CONFIG_TRUE) {
if ((configInt > 0) && (configInt < 65536)) {
g_ac.mtu = (unsigned short)configInt;
} else {
capwap_logging_error("Invalid configuration file, invalid application.network.mtu value");
return 0;
}
}
/* Set transport of AC */
if (config_lookup_string(config, "application.network.transport", &configString) == CONFIG_TRUE) {
if (!strcmp(configString, "udp")) {
g_ac.dfa.transport.type = CAPWAP_UDP_TRANSPORT;
} else if (!strcmp(configString, "udplite")) {
g_ac.dfa.transport.type = CAPWAP_UDPLITE_TRANSPORT;
} else {
capwap_logging_error("Invalid configuration file, unknown application.network.transport value");
return 0;
}
}
/* Backend */
if (config_lookup_string(config, "backend.id", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
g_ac.backendacid = capwap_duplicate_string(configString);
}
}
if (config_lookup_string(config, "backend.version", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
g_ac.backendversion = capwap_duplicate_string(configString);
}
}
configSetting = config_lookup(config, "backend.server");
if (configSetting) {
int count = config_setting_length(configSetting);
/* Retrieve server */
for (i = 0; i < count; i++) {
config_setting_t* configServer = config_setting_get_elem(configSetting, i);
if (configServer != NULL) {
if (config_setting_lookup_string(configServer, "url", &configString) == CONFIG_TRUE) {
struct ac_http_soap_server* server;
struct ac_http_soap_server** itemserver;
/* */
server = ac_soapclient_create_server(configString);
if (!server) {
capwap_logging_error("Invalid configuration file, invalid backend.server value");
return 0;
}
/* HTTPS params */
if (server->protocol == SOAP_HTTPS_PROTOCOL) {
char* calist = NULL;
char* certificate = NULL;
char* privatekey = NULL;
config_setting_t* configSSL;
/* */
configSSL = config_setting_get_member(configServer, "x509");
if (!configSSL) {
capwap_logging_error("Invalid configuration file, invalid backend.server.x509 value");
return 0;
}
if (config_setting_lookup_string(configSSL, "calist", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
calist = capwap_duplicate_string(configString);
}
}
if (config_setting_lookup_string(configSSL, "certificate", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
certificate = capwap_duplicate_string(configString);
}
}
if (config_setting_lookup_string(configSSL, "privatekey", &configString) == CONFIG_TRUE) {
if (strlen(configString) > 0) {
privatekey = capwap_duplicate_string(configString);
}
}
/* */
if (calist && certificate && privatekey) {
server->sslcontext = capwap_socket_crypto_createcontext(calist, certificate, privatekey);
if (!server->sslcontext) {
capwap_logging_error("Invalid configuration file, unable to initialize crypto library");
return 0;
}
} else {
capwap_logging_error("Invalid configuration file, invalid backend.server.x509 value");
return 0;
}
/* Free SSL param */
capwap_free(calist);
capwap_free(certificate);
capwap_free(privatekey);
}
/* Add item */
itemserver = (struct ac_http_soap_server**)capwap_array_get_item_pointer(g_ac.availablebackends, g_ac.availablebackends->count);
*itemserver= server;
}
}
}
}
return 1;
}
/* Parsing configuration */
static int ac_parsing_configuration(config_t* config) {
const char* configString;
if (config_lookup_string(config, "version", &configString) == CONFIG_TRUE) {
if (strcmp(configString, "1.0") == 0) {
return ac_parsing_configuration_1_0(config);
}
capwap_logging_error("Invalid configuration file, '%s' is not supported", configString);
} else {
capwap_logging_error("Invalid configuration file, unable to found version tag");
}
return 0;
}
/* Load configuration */
static int ac_load_configuration(int argc, char** argv) {
int c;
int result = 0;
config_t config;
ASSERT(argc >= 0);
ASSERT(argv != NULL);
/* Parsing command line */
opterr = 0;
while ((c = getopt(argc, argv, "hc:")) != -1) {
switch (c) {
case 'h': {
ac_print_usage();
return 0;
}
case 'c': {
if (strlen(optarg) < sizeof(g_configurationfile)) {
strcpy(g_configurationfile, optarg);
} else {
capwap_logging_error("Invalid -%c argument", optopt);
return -1;
}
break;
}
case '?': {
if (optopt == 'c') {
capwap_logging_error("Option -%c requires an argument", optopt);
} else {
capwap_logging_error("Unknown option character `\\x%x'", optopt);
}
ac_print_usage();
return -1;
}
}
}
/* Init libconfig */
config_init(&config);
/* Load configuration */
if (config_read_file(&config, g_configurationfile) == CONFIG_TRUE) {
result = ac_parsing_configuration(&config);
} else {
result = -1;
capwap_logging_error("Unable load the configuration file '%s': %s (%d)", g_configurationfile, config_error_text(&config), config_error_line(&config));
}
/* Free libconfig */
config_destroy(&config);
return result;
}
/* Init AC */
static int ac_configure(void) {
/* Bind control channel to any address */
if (capwap_bind_sockets(&g_ac.net)) {
capwap_logging_fatal("Cannot bind address");
return AC_ERROR_NETWORK;
}
/* Detect local address */
capwap_interface_list(&g_ac.net, g_ac.addrlist);
return CAPWAP_SUCCESSFUL;
}
/* Close AC */
static void ac_close(void) {
ASSERT(g_ac.sessions->count == 0);
/* Close socket */
capwap_close_sockets(&g_ac.net);
}
/* Check is valid binding */
int ac_valid_binding(unsigned short binding) {
int i;
for (i = 0; i < g_ac.binding->count; i++) {
if (binding == *(unsigned short*)capwap_array_get_item_pointer(g_ac.binding, i)) {
return 1;
}
}
return 0;
}
/* Main*/
int main(int argc, char** argv) {
int value;
int result = CAPWAP_SUCCESSFUL;
/* Init logging */
capwap_logging_init();
capwap_logging_verboselevel(CAPWAP_LOGGING_ERROR);
capwap_logging_enable_console(1);
/* Init capwap */
if (geteuid() != 0) {
capwap_logging_fatal("Request root privileges");
return CAPWAP_REQUEST_ROOT;
}
/* Init random generator */
capwap_init_rand();
/* Init crypt */
if (capwap_crypt_init()) {
capwap_logging_fatal("Error to init crypt engine");
return CAPWAP_CRYPT_ERROR;
}
/* Init soap module */
ac_soapclient_init();
/* Alloc AC */
if (!ac_init()) {
return AC_ERROR_SYSTEM_FAILER;
}
/* Read configuration file */
value = ac_load_configuration(argc, argv);
if (value < 0) {
result = AC_ERROR_LOAD_CONFIGURATION;
} else if (value > 0) {
if (!g_ac.standalone) {
capwap_daemon();
/* Console logging is disabled in daemon mode */
capwap_logging_disable_console();
capwap_logging_info("Running AC in daemon mode");
}
/* Complete configuration AC */
result = ac_configure();
if (result == CAPWAP_SUCCESSFUL) {
/* Connect AC to kernel module */
if (!ac_kmod_init()) {
/* Bind data channel */
if (!ac_kmod_createdatachannel(g_ac.net.localaddr.ss.ss_family, CAPWAP_GET_NETWORK_PORT(&g_ac.net.localaddr) + 1)) {
capwap_logging_info("SmartCAPWAP kernel module connected");
/* Running AC */
result = ac_execute();
} else {
capwap_logging_fatal("Unable to create kernel data channel");
}
/* Disconnect kernel module */
ac_kmod_free();
} else {
capwap_logging_fatal("Unable to connect to kernel module");
}
/* Close connection */
ac_close();
}
}
/* Free memory */
ac_destroy();
/* Free soap */
ac_soapclient_free();
/* Free crypt */
capwap_crypt_free();
/* Check memory leak */
if (capwap_check_memory_leak(1)) {
if (result == CAPWAP_SUCCESSFUL)
result = AC_ERROR_MEMORY_LEAK;
}
/* Close logging */
capwap_logging_close();
return result;
}

189
src/ac/ac.h Normal file
View File

@ -0,0 +1,189 @@
#ifndef __CAPWAP_AC_HEADER__
#define __CAPWAP_AC_HEADER__
/* standard include */
#include "capwap.h"
#include "capwap_network.h"
#include "capwap_protocol.h"
#include "capwap_event.h"
#include "capwap_lock.h"
#include "capwap_rwlock.h"
#include "capwap_list.h"
#include "capwap_hash.h"
#include "capwap_element.h"
#include <pthread.h>
#include <linux/if_ether.h>
#include <json/json.h>
#include <ac_kmod.h>
/* AC Configuration */
#define AC_DEFAULT_CONFIGURATION_FILE "/etc/capwap/ac.conf"
#define AC_DEFAULT_MAXSTATION 128
#define AC_DEFAULT_MAXSESSIONS 128
#define VLAN_MAX 4096
/* AC runtime error return code */
#define AC_ERROR_SYSTEM_FAILER -1000
#define AC_ERROR_LOAD_CONFIGURATION -1001
#define AC_ERROR_NETWORK -1002
#define AC_ERROR_MEMORY_LEAK 1
/* Min and max dfa values */
#define AC_DTLS_INTERVAL 60000
#define AC_JOIN_INTERVAL 60000
#define AC_CHANGE_STATE_PENDING_INTERVAL 25000
#define AC_DATA_CHECK_INTERVAL 30000
#define AC_RETRANSMIT_INTERVAL 3000
#define AC_MAX_RETRANSMIT 5
#define AC_DTLS_SESSION_DELETE_INTERVAL 5000
#define AC_MIN_ECHO_INTERVAL 1000
#define AC_ECHO_INTERVAL 30000
#define AC_MAX_ECHO_INTERVAL 256000
#define AC_MAX_DATA_KEEPALIVE_INTERVAL 256000
#define AC_MIN_DISCOVERY_INTERVAL 2000
#define AC_DISCOVERY_INTERVAL 20000
#define AC_MAX_DISCOVERY_INTERVAL 180000
#define AC_DECRYPT_ERROR_PERIOD_INTERVAL 120000
#define AC_IDLE_TIMEOUT_INTERVAL 300000
#define AC_WTP_FALLBACK_MODE CAPWAP_WTP_FALLBACK_ENABLED
/* */
#define compat_json_object_object_get(obj, key) ({ \
json_bool error; struct json_object* result = NULL; \
error = json_object_object_get_ex(obj, key, &result); \
(error ? result : NULL); \
})
/* */
struct ac_if_datachannel {
unsigned long index;
int ifindex;
char ifname[IFNAMSIZ];
int mtu;
char bridge[IFNAMSIZ];
};
/* */
struct ac_state {
struct capwap_ecnsupport_element ecn;
struct capwap_transport_element transport;
struct capwap_timers_element timers;
unsigned short decrypterrorreport_interval;
struct capwap_idletimeout_element idletimeout;
struct capwap_wtpfallback_element wtpfallback;
/* */
struct capwap_acipv4list_element acipv4list;
struct capwap_acipv6list_element acipv6list;
};
/* */
struct ac_fds {
int fdstotalcount;
struct pollfd* fdspoll;
int fdsnetworkcount;
int msgqueuecount;
int msgqueuestartpos;
struct ac_kmod_event* kmodevents;
int kmodeventscount;
int kmodeventsstartpos;
};
/* AC */
struct ac_t {
int standalone;
int running;
/* */
struct ac_state dfa;
struct capwap_network net;
struct capwap_list* addrlist;
unsigned short mtu;
struct capwap_array* binding;
struct capwap_acname_element acname;
struct capwap_acdescriptor_element descriptor;
/* Sessions message queue */
int fdmsgsessions[2];
/* Kernel module */
struct ac_kmod_handle kmodhandle;
/* Sessions */
struct capwap_list* sessions;
struct capwap_list* sessionsthread;
capwap_rwlock_t sessionslock;
/* Authorative Stations */
struct capwap_hash* authstations;
capwap_rwlock_t authstationslock;
/* Data Channel Interfaces */
struct capwap_hash* ifdatachannel;
capwap_rwlock_t ifdatachannellock;
/* Dtls */
int enabledtls;
struct capwap_dtls_context dtlscontext;
/* Backend Management */
char* backendacid;
char* backendversion;
struct capwap_array* availablebackends;
};
/* AC session thread */
struct ac_session_thread_t {
pthread_t threadid;
};
/* AC session message queue item */
#define AC_MESSAGE_QUEUE_CLOSE_THREAD 1
#define AC_MESSAGE_QUEUE_CLOSE_ALLSESSIONS 2
#define AC_MESSAGE_QUEUE_UPDATE_CONFIGURATION 3
struct ac_session_msgqueue_item_t {
unsigned long message;
union {
struct {
pthread_t threadid;
} message_close_thread;
struct {
struct json_object* jsonroot;
} message_configuration;
};
};
extern struct ac_t g_ac;
/* Primary thread */
int ac_execute(void);
int ac_execute_update_fdspool(struct ac_fds* fds);
int ac_valid_binding(unsigned short binding);
void ac_update_statistics(void);
#endif /* __CAPWAP_AC_HEADER__ */

470
src/ac/ac_80211_json.c Normal file
View File

@ -0,0 +1,470 @@
#include "ac.h"
#include "ac_json.h"
/* */
static struct ac_json_ieee80211_ops* ac_json_80211_message_elements[] = {
/* CAPWAP_ELEMENT_80211_ADD_WLAN */ &ac_json_80211_addwlan_ops,
/* CAPWAP_ELEMENT_80211_ANTENNA */ &ac_json_80211_antenna_ops,
/* CAPWAP_ELEMENT_80211_ASSIGN_BSSID */ &ac_json_80211_assignbssid_ops,
/* CAPWAP_ELEMENT_80211_DELETE_WLAN */ &ac_json_80211_deletewlan_ops,
/* CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL */ &ac_json_80211_directsequencecontrol_ops,
/* CAPWAP_ELEMENT_80211_IE */ &ac_json_80211_ie_ops,
/* CAPWAP_ELEMENT_80211_MACOPERATION */ &ac_json_80211_macoperation_ops,
/* CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES */ &ac_json_80211_miccountermeasures_ops,
/* CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY */ &ac_json_80211_multidomaincapability_ops,
/* CAPWAP_ELEMENT_80211_OFDMCONTROL */ &ac_json_80211_ofdmcontrol_ops,
/* CAPWAP_ELEMENT_80211_RATESET */ &ac_json_80211_rateset_ops,
/* CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT */ &ac_json_80211_rsnaerrorreport_ops,
/* CAPWAP_ELEMENT_80211_STATION */ NULL,
/* CAPWAP_ELEMENT_80211_STATION_QOS_PROFILE */ NULL,
/* CAPWAP_ELEMENT_80211_STATION_SESSION_KEY_PROFILE */ NULL,
/* CAPWAP_ELEMENT_80211_STATISTICS */ &ac_json_80211_statistics_ops,
/* CAPWAP_ELEMENT_80211_SUPPORTEDRATES */ &ac_json_80211_supportedrates_ops,
/* CAPWAP_ELEMENT_80211_TXPOWER */ &ac_json_80211_txpower_ops,
/* CAPWAP_ELEMENT_80211_TXPOWERLEVEL */ &ac_json_80211_txpowerlevel_ops,
/* CAPWAP_ELEMENT_80211_UPDATE_STATION_QOS */ NULL,
/* CAPWAP_ELEMENT_80211_UPDATE_WLAN */ &ac_json_80211_updatewlan_ops,
/* CAPWAP_ELEMENT_80211_WTP_QOS */ &ac_json_80211_wtpqos_ops,
/* CAPWAP_ELEMENT_80211_WTP_RADIO_CONF */ &ac_json_80211_wtpradioconf_ops,
/* CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM */ &ac_json_80211_wtpradiofailalarm_ops,
/* CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION */ &ac_json_80211_wtpradioinformation_ops
};
/* */
static struct ac_json_ieee80211_ops* ac_json_80211_getops_by_capwaptype(uint16_t type) {
int i;
for (i = 0; i < CAPWAP_80211_MESSAGE_ELEMENTS_COUNT; i++) {
if (ac_json_80211_message_elements[i] && (ac_json_80211_message_elements[i]->type == type)) {
return ac_json_80211_message_elements[i];
}
}
return NULL;
}
/* */
static struct ac_json_ieee80211_ops* ac_json_80211_getops_by_jsontype(char* type) {
int i;
for (i = 0; i < CAPWAP_80211_MESSAGE_ELEMENTS_COUNT; i++) {
if (ac_json_80211_message_elements[i] && !strcmp(ac_json_80211_message_elements[i]->json_type, type)) {
return ac_json_80211_message_elements[i];
}
}
return NULL;
}
/* */
void ac_json_ieee80211_init(struct ac_json_ieee80211_wtpradio* wtpradio) {
ASSERT(wtpradio != NULL);
memset(wtpradio, 0, sizeof(struct ac_json_ieee80211_wtpradio));
}
/* */
void ac_json_ieee80211_free(struct ac_json_ieee80211_wtpradio* wtpradio) {
int i, j;
ASSERT(wtpradio != NULL);
for (i = 0; i < RADIOID_MAX_COUNT; i++) {
struct ac_json_ieee80211_item* item = &wtpradio->items[i];
if (item->valid) {
if (item->addwlan) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ADD_WLAN)->free_message_element(item->addwlan);
}
if (item->antenna) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ANTENNA)->free_message_element(item->antenna);
}
if (item->assignbssid) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_ASSIGN_BSSID)->free_message_element(item->assignbssid);
}
if (item->deletewlan) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_DELETE_WLAN)->free_message_element(item->deletewlan);
}
if (item->directsequencecontrol) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL)->free_message_element(item->directsequencecontrol);
}
if (item->iearray) {
struct capwap_message_elements_ops* ieops = capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_IE);
for (j = 0; j < item->iearray->count; j++) {
ieops->free_message_element(*(struct capwap_80211_ie_element**)capwap_array_get_item_pointer(item->iearray, j));
}
capwap_array_free(item->iearray);
}
if (item->macoperation) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MACOPERATION)->free_message_element(item->macoperation);
}
if (item->miccountermeasures) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES)->free_message_element(item->miccountermeasures);
}
if (item->multidomaincapability) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY)->free_message_element(item->multidomaincapability);
}
if (item->ofdmcontrol) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_OFDMCONTROL)->free_message_element(item->ofdmcontrol);
}
if (item->rateset) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_RATESET)->free_message_element(item->rateset);
}
if (item->rsnaerrorreport) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT)->free_message_element(item->rsnaerrorreport);
}
if (item->statistics) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_STATISTICS)->free_message_element(item->statistics);
}
if (item->supportedrates) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_SUPPORTEDRATES)->free_message_element(item->supportedrates);
}
if (item->txpower) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_TXPOWER)->free_message_element(item->txpower);
}
if (item->txpowerlevel) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_TXPOWERLEVEL)->free_message_element(item->txpowerlevel);
}
if (item->updatewlan) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_UPDATE_WLAN)->free_message_element(item->updatewlan);
}
if (item->wtpqos) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_QOS)->free_message_element(item->wtpqos);
}
if (item->wtpradioconf) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_RADIO_CONF)->free_message_element(item->wtpradioconf);
}
if (item->wtpradiofailalarm) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM)->free_message_element(item->wtpradiofailalarm);
}
if (item->wtpradioinformation) {
capwap_get_message_element_ops(CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION)->free_message_element(item->wtpradioinformation);
}
}
}
}
/* */
int ac_json_ieee80211_addmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, uint16_t type, void* data, int overwrite) {
struct ac_json_ieee80211_ops* ops;
ASSERT(wtpradio != NULL);
ASSERT(IS_80211_MESSAGE_ELEMENTS(type));
ASSERT(data != NULL);
/* */
ops = ac_json_80211_getops_by_capwaptype(type);
if (!ops) {
return 0;
}
return ops->add_message_element(wtpradio, data, overwrite);
}
/* */
int ac_json_ieee80211_parsingmessageelement(struct ac_json_ieee80211_wtpradio* wtpradio, struct capwap_message_element_itemlist* messageelement) {
int i;
ASSERT(wtpradio != NULL);
ASSERT(messageelement != NULL);
ASSERT(IS_80211_MESSAGE_ELEMENTS(messageelement->type));
if (messageelement->category == CAPWAP_MESSAGE_ELEMENT_SINGLE) {
if (!ac_json_ieee80211_addmessageelement(wtpradio, messageelement->type, messageelement->data, 0)) {
return 0;
}
} else if (messageelement->category == CAPWAP_MESSAGE_ELEMENT_ARRAY) {
struct capwap_array* items = (struct capwap_array*)messageelement->data;
for (i = 0; i < items->count; i++) {
if (!ac_json_ieee80211_addmessageelement(wtpradio, messageelement->type, *(void**)capwap_array_get_item_pointer(items, i), 0)) {
return 0;
}
}
} else {
return 0;
}
return 1;
}
/* */
int ac_json_ieee80211_parsingjson(struct ac_json_ieee80211_wtpradio* wtpradio, struct json_object* jsonroot) {
int i;
int length;
ASSERT(wtpradio != NULL);
ASSERT(jsonroot != NULL);
if (json_object_get_type(jsonroot) != json_type_array) {
return 0;
}
/* */
length = json_object_array_length(jsonroot);
for (i = 0; i < length; i++) {
struct json_object* jsonitem;
struct json_object* jsonradio = json_object_array_get_idx(jsonroot, i);
/* Get RadioID */
jsonitem = compat_json_object_object_get(jsonradio, "RadioID");
if (jsonitem && (json_object_get_type(jsonitem) == json_type_int)) {
int radioid = json_object_get_int(jsonitem);
if (IS_VALID_RADIOID(radioid)) {
struct lh_entry* entry;
/* Parsing every entry */
for(entry = json_object_get_object(jsonradio)->head; entry != NULL; entry = entry->next) {
struct ac_json_ieee80211_ops* ops = ac_json_80211_getops_by_jsontype((char*)entry->k); /* Retrieve JSON handler */
if (ops) {
void* data = ops->create_message_element((struct json_object*)entry->v, radioid);
if (data) {
/* Message element complete */
ac_json_ieee80211_addmessageelement(wtpradio, ops->type, data, 1);
/* Free resource */
capwap_get_message_element_ops(ops->type)->free_message_element(data);
}
}
}
}
}
}
return 1;
}
/* */
struct json_object* ac_json_ieee80211_getjson(struct ac_json_ieee80211_wtpradio* wtpradio) {
int i;
struct json_object* jsonarray;
struct json_object* jsonitems;
ASSERT(wtpradio != NULL);
jsonarray = json_object_new_array();
for (i = 0; i < RADIOID_MAX_COUNT; i++) {
struct ac_json_ieee80211_item* item = &wtpradio->items[i];
if (!item->valid) {
continue;
}
/* */
jsonitems = json_object_new_object();
/* Radio Id */
json_object_object_add(jsonitems, "RadioID", json_object_new_int(i + 1));
if (item->addwlan) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_ADD_WLAN)->create_json(jsonitems, item->addwlan);
}
if (item->antenna) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_ANTENNA)->create_json(jsonitems, item->antenna);
}
if (item->assignbssid) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_ASSIGN_BSSID)->create_json(jsonitems, item->assignbssid);
}
if (item->deletewlan) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_DELETE_WLAN)->create_json(jsonitems, item->deletewlan);
}
if (item->directsequencecontrol) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL)->create_json(jsonitems, item->directsequencecontrol);
}
if (item->iearray) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_IE)->create_json(jsonitems, item->iearray);
}
if (item->macoperation) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_MACOPERATION)->create_json(jsonitems, item->macoperation);
}
if (item->miccountermeasures) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES)->create_json(jsonitems, item->miccountermeasures);
}
if (item->multidomaincapability) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY)->create_json(jsonitems, item->multidomaincapability);
}
if (item->ofdmcontrol) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_OFDMCONTROL)->create_json(jsonitems, item->ofdmcontrol);
}
if (item->rateset) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_RATESET)->create_json(jsonitems, item->rateset);
}
if (item->rsnaerrorreport) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT)->create_json(jsonitems, item->rsnaerrorreport);
}
if (item->statistics) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_STATISTICS)->create_json(jsonitems, item->statistics);
}
if (item->supportedrates) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_SUPPORTEDRATES)->create_json(jsonitems, item->supportedrates);
}
if (item->txpower) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_TXPOWER)->create_json(jsonitems, item->txpower);
}
if (item->txpowerlevel) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_TXPOWERLEVEL)->create_json(jsonitems, item->txpowerlevel);
}
if (item->updatewlan) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_UPDATE_WLAN)->create_json(jsonitems, item->updatewlan);
}
if (item->wtpqos) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_WTP_QOS)->create_json(jsonitems, item->wtpqos);
}
if (item->wtpradioconf) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_WTP_RADIO_CONF)->create_json(jsonitems, item->wtpradioconf);
}
if (item->wtpradiofailalarm) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM)->create_json(jsonitems, item->wtpradiofailalarm);
}
if (item->wtpradioinformation) {
ac_json_80211_getops_by_capwaptype(CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION)->create_json(jsonitems, item->wtpradioinformation);
}
/* */
json_object_array_add(jsonarray, jsonitems);
}
return jsonarray;
}
/* */
void ac_json_ieee80211_buildpacket(struct ac_json_ieee80211_wtpradio* wtpradio, struct capwap_packet_txmng* txmngpacket) {
int i, j;
ASSERT(wtpradio != NULL);
ASSERT(txmngpacket != NULL);
for (i = 0; i < RADIOID_MAX_COUNT; i++) {
struct ac_json_ieee80211_item* item = &wtpradio->items[i];
if (item->valid) {
if (item->addwlan) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_ADD_WLAN, item->addwlan);
}
if (item->antenna) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_ANTENNA, item->antenna);
}
if (item->assignbssid) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_ASSIGN_BSSID, item->assignbssid);
}
if (item->deletewlan) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_DELETE_WLAN, item->deletewlan);
}
if (item->directsequencecontrol) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_DIRECTSEQUENCECONTROL, item->directsequencecontrol);
}
if (item->iearray) {
for (j = 0; j < item->iearray->count; j++) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_IE, *(struct capwap_80211_ie_element**)capwap_array_get_item_pointer(item->iearray, j));
}
}
if (item->macoperation) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_MACOPERATION, item->macoperation);
}
if (item->miccountermeasures) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_MIC_COUNTERMEASURES, item->miccountermeasures);
}
if (item->multidomaincapability) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_MULTIDOMAINCAPABILITY, item->multidomaincapability);
}
if (item->ofdmcontrol) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_OFDMCONTROL, item->ofdmcontrol);
}
if (item->rateset) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_RATESET, item->rateset);
}
if (item->rsnaerrorreport) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_RSNA_ERROR_REPORT, item->rsnaerrorreport);
}
if (item->statistics) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_STATISTICS, item->statistics);
}
if (item->supportedrates) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_SUPPORTEDRATES, item->supportedrates);
}
if (item->txpower) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_TXPOWER, item->txpower);
}
if (item->txpowerlevel) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_TXPOWERLEVEL, item->txpowerlevel);
}
if (item->updatewlan) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_UPDATE_WLAN, item->updatewlan);
}
if (item->wtpqos) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_WTP_QOS, item->wtpqos);
}
if (item->wtpradioconf) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_WTP_RADIO_CONF, item->wtpradioconf);
}
if (item->wtpradiofailalarm) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_WTP_RADIO_FAIL_ALARM, item->wtpradiofailalarm);
}
if (item->wtpradioinformation) {
capwap_packet_txmng_add_message_element(txmngpacket, CAPWAP_ELEMENT_80211_WTPRADIOINFORMATION, item->wtpradioinformation);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More