├── .gitignore ├── AC.c ├── ACAppsProtocol.h ├── ACBinding.c ├── ACBinding.h ├── ACConfigFile.c ├── ACConfigureState.c ├── ACDataCheckState.c ├── ACDiscoveryState.c ├── ACInterface.c ├── ACInterface.h ├── ACJoinState.c ├── ACMainLoop.c ├── ACMultiHomedSocket.c ├── ACMultiHomedSocket.h ├── ACProtocol.c ├── ACProtocol.h ├── ACProtocol_User.c ├── ACRetransmission.c ├── ACRunState.c ├── ACSettingsFile.c ├── ACipcHostapd.c ├── ACipcHostapd.h ├── COPYING ├── CWAC.h ├── CWBinding.c ├── CWBinding.h ├── CWCommon.c ├── CWCommon.h ├── CWConfigFile.c ├── CWConfigFile.h ├── CWErrorHandling.c ├── CWErrorHandling.h ├── CWFreqPayloads.h ├── CWList.c ├── CWList.h ├── CWLog.c ├── CWLog.h ├── CWNetwork.c ├── CWNetwork.h ├── CWOpenSSLBio.c ├── CWProtocol.c ├── CWProtocol.h ├── CWRandom.c ├── CWRandom.h ├── CWSafeList.c ├── CWSafeList.h ├── CWSecurity.c ├── CWSecurity.h ├── CWStevens.c ├── CWStevens.h ├── CWThread.c ├── CWThread.h ├── CWTimer.h ├── CWVendorPayloads.h ├── CWVendorPayloadsAC.c ├── CWVendorPayloadsWTP.c ├── CWWTP.h ├── Doxyfile ├── INSTALL.rst ├── Makefile.am ├── Makefile.bcm ├── Makefile.glibc ├── Makefile.uclibc ├── MakefileMac ├── README.md ├── WTP.c ├── WTPBcmDriverInteraction.c ├── WTPBcmDriverInteraction.h ├── WTPBcmFrameReceive.c ├── WTPBcmFrameReceive.h ├── WTPBinding.c ├── WTPBinding.h ├── WTPConfigFile.c ├── WTPConfigureState.c ├── WTPDataCheckState.c ├── WTPDiscoveryState.c ├── WTPDriverInteraction.c ├── WTPFrameReceive.c ├── WTPFrameReceive.h ├── WTPFreqStatsReceive.c ├── WTPFreqStatsReceive.h ├── WTPJoinState.c ├── WTPProtocol.c ├── WTPProtocol.h ├── WTPProtocol_User.c ├── WTPRetransmission.c ├── WTPRunState.c ├── WTPRunStateCheck.c ├── WTPSettingsFile.c ├── WTPStatsReceive.c ├── WTPStatsReceive.h ├── WTPSulkingState.c ├── WTPipcHostapd.c ├── WTPipcHostapd.h ├── WTPmacDriverInteraction.c ├── WTPmacDriverInteraction.h ├── WTPmacFrameReceive.c ├── WTPmacFrameReceive.h ├── WUA.c ├── WUM.h ├── capwap_bugfix_0.01 ├── changeLog-0.92 ├── changeLog-0.93 ├── changeLog-0.93.3 ├── client.pem ├── common.h ├── config.ac ├── config.wtp ├── configure.ac ├── debian-install.sh ├── docs ├── OpenCapwap.pdf └── WTPUpdateSystem.pdf ├── hostapd_wrapper ├── README.rst ├── hostapd-capwap.patch ├── hostapd.conf-ac ├── hostapd.conf-wtp ├── hostapd2 │ ├── README.Debian │ ├── hostapd-20130302-linux.patch │ ├── hostapd-20130302.tar.bz2 │ ├── hostapd_linux.conf │ ├── hostapd_linux_ac.conf │ ├── linux-ac.sh │ └── nl-tiny.tar.gz ├── hostapd_ac.conf ├── hostapd_wtp.conf └── src │ ├── capwap │ ├── capwap_mgmt_frame_ac.c │ ├── capwap_mgmt_frame_ac.h │ ├── capwap_mgmt_frame_wtp.c │ ├── capwap_mgmt_frame_wtp.h │ ├── file_conf_ac.h │ ├── file_conf_wtp.h │ ├── ipc_capwap_ac.c │ ├── ipc_capwap_ac.h │ ├── ipc_capwap_wtp.c │ ├── ipc_capwap_wtp.h │ ├── smac_code.h │ ├── switch_8023_80211.c │ └── switch_8023_80211.h │ └── drivers │ ├── driver_capwap.c │ ├── driver_capwap_wtp.c │ ├── linux_ioctl_fake.c │ ├── linux_ioctl_fake.h │ ├── netlink_fake.c │ └── netlink_fake.h ├── ieee802_11_defs.h ├── m4 ├── .gitignore └── ax_check_openssl.m4 ├── modifiche_daniele.txt ├── modifiche_uci_frequency_2009.txt ├── os.h ├── packages ├── Debian-6 │ ├── hostapd-cw_2.0-1_all.deb │ ├── nltiny_2.0-1_all.deb │ └── opencapwap_0.99b-1_all.deb └── FC18 │ └── x86_64 │ ├── README.FC18 │ ├── capwap-ac-0.9b-3.fc18.x86_64.rpm │ ├── hostapd-capwap-20130302-3.fc18.x86_64.rpm │ └── libnl-tiny-2.0-1.fc18.x86_64.rpm ├── root.pem ├── server.pem ├── settings.ac.txt ├── settings.wtp.txt ├── smac_code.h ├── tap.c ├── tap.h ├── timerlib.c ├── timerlib.h ├── wireless_copy.h └── wum ├── Makefile ├── README ├── wum.c ├── wumLib.c └── wumLib.h /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.o 3 | *.lo 4 | *.la 5 | m4 6 | .deps 7 | .libs 8 | 9 | # 10 | # binaries 11 | # 12 | AC 13 | WTP 14 | WUA 15 | 16 | # 17 | # autoconf files 18 | # 19 | Makefile 20 | Makefile.in 21 | aclocal.m4 22 | autom4te.cache/ 23 | compile 24 | config.guess 25 | config.h 26 | config.h.in 27 | config.log 28 | config.status 29 | config.sub 30 | configure 31 | depcomp 32 | install-sh 33 | libtool 34 | ltmain.sh 35 | missing 36 | stamp-h1 37 | -------------------------------------------------------------------------------- /ACAppsProtocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * appsToAcProtocol.h 3 | * 4 | * 5 | * Created by Antonio Davoli on 03/03/09. 6 | * Copyright 2009 La Sapienza. All rights reserved. 7 | * 8 | */ 9 | 10 | /* Macro Definition */ 11 | 12 | /* AC Request Message */ 13 | 14 | /**************************************** 15 | * For LIST, QUIT (without argument) * 16 | * * 17 | * 0 7 * 18 | * +-+-+-+-+-+-+-+-+ * 19 | * | Cmd_msg | * 20 | * +-+-+-+-+-+-+-+-+ * 21 | * * 22 | ****************************************/ 23 | 24 | /* CMD_MSG Types */ 25 | 26 | #define FULL_CLIENT_CONNECTED -1 27 | #define CONNECTION_OK 1 28 | #define QUIT_MSG 0 29 | #define LIST_MSG 1 30 | #define CONF_UPDATE_MSG 2 31 | 32 | /******************************************************************************************************************************** 33 | * List Response Message: * 34 | * * 35 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 36 | * | Active# | WTP_ID 1 | NameLength 1 | WTP Name 1 | ... | WTP ID N | NameLength N | WTP Name N | * 37 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 38 | * * 39 | * where N is equal to Active# (Number of Active WTPs) * 40 | ********************************************************************************************************************************/ 41 | 42 | /******************************************************************************************************** 43 | * For CONF_UPDATE_MSG type: * 44 | * * 45 | * 0 7 15 23 X * 46 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 47 | * | cmd_msg | msg_elem | WPT Index | Message Specific Payload | * 48 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 49 | * * 50 | ********************************************************************************************************/ 51 | 52 | #define PAYLOAD_START ((sizeof(unsigned char)*2) + sizeof(int)) 53 | #define ALL_ACTIVE_WTPS -1 54 | 55 | #define MSG_ELEMENT_TYPE_OFDM 1 56 | #define MSG_ELEMENT_TYPE_VENDOR_UCI 2 57 | #define MSG_ELEMENT_TYPE_VENDOR_WUM 3 58 | 59 | /**************************************************************************************** 60 | * Message Specific Payload for MSG_ELEMENT_TYPE_OFDM TYPE (802.11 Binding Version) * 61 | * * 62 | * 0 1 2 3 * 63 | * 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 * 64 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 65 | * | Radio ID | Reserved | Current Chan | Band Support | * 66 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 67 | * | TI Threshold | * 68 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 69 | * * 70 | ****************************************************************************************/ 71 | 72 | /* Radio ID is filled in the creation message funcion (inside the AC) */ 73 | -------------------------------------------------------------------------------- /ACBinding.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************ 2 | * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * -------------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Authors : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | * Antonio Davoli (antonio.davoli@gmail.com) * 27 | ************************************************************************************************/ 28 | 29 | #ifndef __CAPWAP_ACBinding_HEADER__ 30 | #define __CAPWAP_ACBinding_HEADER__ 31 | 32 | CWBool CWACInitBinding(int i); 33 | CWBool CWBindingAssembleConfigureResponse(CWProtocolMessage ** msgElems, int *msgElemCountPtr); 34 | /**************************************************** 35 | * 2009 Update: * 36 | * The field BindingMsgElement has been added for * 37 | * the multiple type of Message Element. * 38 | ****************************************************/ 39 | CWBool CWBindingAssembleConfigurationUpdateRequest(CWProtocolMessage ** msgElems, int *msgElemCountPtr, 40 | int BindingMsgElement); 41 | CWBool CWBindingSaveConfigurationUpdateResponse(CWProtocolResultCode resultCode, int WTPIndex); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /ACInterface.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria * 3 | * Informatica Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Authors : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | * Daniele De Sanctis (danieledesanctis@gmail.com) * 27 | * Antonio Davoli (antonio.davoli@gmail.com) * 28 | * Donato Capitella (d.capitella@gmail.com) * 29 | *******************************************************************************************/ 30 | 31 | #ifndef __CAPWAP_ACInterface_HEADER__ 32 | #define __CAPWAP_ACInterface_HEADER__ 33 | 34 | //No Interface Command 35 | #define NO_CMD 0 36 | //Manual setting for QoS values 37 | #define QOS_CMD 1 38 | #define CLEAR_CONFIG_MSG_CMD 2 39 | /* 2009 Update: Manual setting for OFDM values*/ 40 | #define OFDM_CONTROL_CMD 3 41 | /*Update 2009: 42 | Manage UCI configuration command*/ 43 | #define UCI_CONTROL_CMD 4 44 | /* Manage WTP Update Command */ 45 | #define WTP_UPDATE_CMD 5 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /ACMultiHomedSocket.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWMultiHomedSocket_HEADER__ 29 | #define __CAPWAP_CWMultiHomedSocket_HEADER__ 30 | 31 | #include "CWNetwork.h" 32 | 33 | /*_____________________________________________________*/ 34 | /* *******************___TYPES___******************* */ 35 | 36 | typedef struct { 37 | CWNetworkLev4Address addr; 38 | CWNetworkLev4Address addrIPv4; 39 | CWSocket sock; 40 | enum { 41 | CW_PRIMARY, 42 | CW_BROADCAST_OR_ALIAS 43 | } kind; 44 | short systemIndex; // real interface index in the system 45 | 46 | CWNetworkLev4Address dataAddr; 47 | CWSocket dataSock; 48 | } CWMultiHomedInterface; 49 | 50 | typedef struct { 51 | int count; 52 | CWMultiHomedInterface *interfaces; 53 | } CWMultiHomedSocket; 54 | 55 | /*_____________________________________________________*/ 56 | /* *******************___MACRO___******************* */ 57 | 58 | #define CW_COPY_MH_INTERFACE_PTR(int1, int2) CW_COPY_NET_ADDR_PTR( &((int1)->addr), &((int2)->addr)); \ 59 | CW_COPY_NET_ADDR_PTR( &((int1)->addrIPv4), &((int2)->addrIPv4));\ 60 | (int1)->sock = (int2)->sock; \ 61 | (int1)->dataSock = (int2)->dataSock; \ 62 | (int1)->kind = (int2)->kind; \ 63 | (int1)->systemIndex = (int2)->systemIndex; 64 | 65 | /*__________________________________________________________*/ 66 | /* *******************___PROTOTYPES___******************* */ 67 | 68 | CWBool CWNetworkInitSocketServerMultiHomed(CWMultiHomedSocket * sockPtr, int port, char **multicastGroups, 69 | int multicastGroupsCount); 70 | void CWNetworkCloseMultiHomedSocket(CWMultiHomedSocket * sockPtr); 71 | CWBool CWNetworkUnsafeMultiHomed(CWMultiHomedSocket * sockPtr, 72 | void (*CWManageIncomingPacket) (CWSocket, unsigned char *, int, int, CWNetworkLev4Address *, 73 | CWBool), CWBool peekRead); 74 | int CWNetworkCountInterfaceAddresses(CWMultiHomedSocket * sockPtr); 75 | CWBool CWNetworkGetInterfaceAddresses(CWMultiHomedSocket * sockPtr, CWNetworkLev4Address ** addressesPtr, 76 | struct sockaddr_in **IPv4AddressesPtr); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /ACipcHostapd.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Sotiraq Sima (Sotiraq.Sima@gmail.com) * 22 | * * 23 | *******************************************************************************************/ 24 | 25 | #ifndef __CAPWAP_WTPFrameReceive_HEADER__ 26 | #define __CAPWAP_WTPFrameReceive_HEADER__ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "smac_code.h" 37 | #include "CWAC.h" 38 | 39 | void CWACsend_data_to_hostapd(int WTPIndex, unsigned char *buf, int len); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | # ******************************************************************************************* 2 | # * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | # * Universita' Campus BioMedico - Italy * 4 | # * * 5 | # * This program is free software; you can redistribute it and/or modify it under the terms * 6 | # * of the GNU General Public License as published by the Free Software Foundation; either * 7 | # * version 2 of the License, or (at your option) any later version. * 8 | # * * 9 | # * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | # * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | # * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | # * * 13 | # * You should have received a copy of the GNU General Public License along with this * 14 | # * program; if not, write to the: * 15 | # * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | # * MA 02111-1307, USA. * 17 | # * * 18 | # * --------------------------------------------------------------------------------------- * 19 | # * Project: Capwap * 20 | # * * 21 | # * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | # * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | # * Giovannini Federica (giovannini.federica@gmail.com) * 24 | # * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | # * Donato Capitella (d.capitella@gmail.com) * 26 | # ******************************************************************************************* 27 | -------------------------------------------------------------------------------- /CWCommon.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #include "CWCommon.h" 29 | 30 | #ifdef DMALLOC 31 | #include "../dmalloc-5.5.0/dmalloc.h" 32 | #endif 33 | 34 | int gCWForceMTU = 0; 35 | int gCWRetransmitTimer = CW_RETRANSMIT_INTERVAL_DEFAULT; //Default value for RetransmitInterval 36 | int gCWNeighborDeadInterval = CW_NEIGHBORDEAD_INTERVAL_DEFAULT; //Default value for NeighbourDeadInterval (no less than 2*EchoInterval and no greater than 240) 37 | int gCWMaxRetransmit = CW_MAX_RETRANSMIT_DEFAULT; //Default value for MaxRetransmit 38 | 39 | int CWTimevalSubtract(struct timeval *res, const struct timeval *x, const struct timeval *y) 40 | { 41 | int nsec; 42 | struct timeval z = *y; 43 | 44 | // Perform the carry for the later subtraction by updating Y 45 | if (x->tv_usec < z.tv_usec) { 46 | nsec = (z.tv_usec - x->tv_usec) / 1000000 + 1; 47 | z.tv_usec -= 1000000 * nsec; 48 | z.tv_sec += nsec; 49 | } 50 | if (x->tv_usec - z.tv_usec > 1000000) { 51 | nsec = (x->tv_usec - z.tv_usec) / 1000000; 52 | z.tv_usec += 1000000 * nsec; 53 | z.tv_sec -= nsec; 54 | } 55 | // Compute the time remaining to wait. `tv_usec' is certainly positive 56 | if (res != NULL) { 57 | res->tv_sec = x->tv_sec - z.tv_sec; 58 | res->tv_usec = x->tv_usec - z.tv_usec; 59 | } 60 | // Return 1 if result is negative (x < y) 61 | return ((x->tv_sec < z.tv_sec) || ((x->tv_sec == z.tv_sec) && (x->tv_usec < z.tv_usec))); 62 | } 63 | -------------------------------------------------------------------------------- /CWConfigFile.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWConfigFile_HEADER__ 29 | #define __CAPWAP_CWConfigFile_HEADER__ 30 | 31 | typedef char **CWStringArray; 32 | 33 | typedef struct { 34 | enum { 35 | CW_INTEGER, 36 | CW_STRING, 37 | CW_STRING_ARRAY 38 | } type; 39 | 40 | union { 41 | int int_value; 42 | char *str_value; 43 | char **str_array_value; 44 | } value; 45 | 46 | char *code; 47 | char *endCode; 48 | 49 | int count; 50 | } CWConfigValue; 51 | 52 | extern CWConfigValue *gConfigValues; 53 | extern int gConfigValuesCount; 54 | 55 | CWBool CWParseConfigFile(); 56 | char *CWGetCommand(FILE * configFile); 57 | CWBool CWConfigFileInitLib(void); 58 | CWBool CWConfigFileDestroyLib(void); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /CWErrorHandling.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWErrorHandling_HEADER__ 29 | #define __CAPWAP_CWErrorHandling_HEADER__ 30 | 31 | typedef enum { 32 | CW_ERROR_SUCCESS = 1, 33 | CW_ERROR_OUT_OF_MEMORY, 34 | CW_ERROR_WRONG_ARG, 35 | CW_ERROR_INTERRUPTED, 36 | CW_ERROR_NEED_RESOURCE, 37 | CW_ERROR_COMUNICATING, 38 | CW_ERROR_CREATING, 39 | CW_ERROR_GENERAL, 40 | CW_ERROR_OPERATION_ABORTED, 41 | CW_ERROR_SENDING, 42 | CW_ERROR_RECEIVING, 43 | CW_ERROR_INVALID_FORMAT, 44 | CW_ERROR_TIME_EXPIRED, 45 | CW_ERROR_NONE 46 | } CWErrorCode; 47 | 48 | typedef struct { 49 | CWErrorCode code; 50 | char message[256]; 51 | int line; 52 | char fileName[64]; 53 | } CWErrorHandlingInfo; 54 | 55 | #define CWErrorRaiseSystemError(error) { \ 56 | char buf[256]; \ 57 | strerror_r(errno, buf, 256); \ 58 | CWErrorRaise(error, buf); \ 59 | return CW_FALSE; \ 60 | } 61 | 62 | #define CWErrorRaise(code, msg) _CWErrorRaise(code, msg, __FILE__, __LINE__) 63 | #define CWErr(arg) ((arg) || _CWErrorHandleLast(__FILE__, __LINE__)) 64 | #define CWErrorHandleLast() _CWErrorHandleLast(__FILE__, __LINE__) 65 | 66 | CWBool _CWErrorRaise(CWErrorCode code, const char *msg, const char *fileName, int line); 67 | void CWErrorPrint(CWErrorHandlingInfo * infoPtr, const char *desc, const char *fileName, int line); 68 | CWErrorCode CWErrorGetLastErrorCode(void); 69 | CWBool _CWErrorHandleLast(const char *fileName, int line); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /CWFreqPayloads.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************ 2 | * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * -------------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Authors : Antonio Davoli (antonio.davoli@gmail.com) * 22 | ************************************************************************************************/ 23 | 24 | #ifndef __CAPWAP_Freq_Payloads__ 25 | #define __CAPWAP_Freq_Payloads__ 26 | 27 | #define CW_FREQ_CELL_INFO_PAYLOAD_SIZE 65 28 | #define CW_FREQ_ACK_SIZE 8 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /CWList.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWList_HEADER__ 29 | #define __CAPWAP_CWList_HEADER__ 30 | 31 | #define CW_LIST_INIT NULL 32 | 33 | typedef struct _s { 34 | void *data; 35 | struct _s *next; 36 | } CWListElement; 37 | 38 | typedef enum { 39 | CW_LIST_ITERATE_RESET, 40 | CW_LIST_ITERATE 41 | } CWListIterateMode; 42 | 43 | typedef CWListElement *CWList; 44 | 45 | CWBool CWAddElementToList(CWList * list, void *element); 46 | CWBool CWAddElementToListTail(CWList * list, void *element); 47 | CWList CWListGetFirstElem(CWList * list); 48 | void *CWListGetNext(CWList list, CWListIterateMode mode); 49 | void *CWSearchInList(CWList list, void *baseElement, CWBool(*compareFunc) (void *, void *)); 50 | void *CWDeleteInList(CWList * list, void *baseElement, CWBool(*compareFunc) (void *, void *)); 51 | void CWDeleteList(CWList * list, void (*deleteFunc) (void *)); 52 | int CWCountElementInList(CWList list); 53 | //CWList * FindLastElementInList (CWList list); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /CWLog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWLog_HEADER__ 29 | #define __CAPWAP_CWLog_HEADER__ 30 | 31 | extern char gLogFileName[]; 32 | 33 | void CWVLog(const char *format, va_list args); 34 | void CWLog(const char *format, ...); 35 | void CWDebugLog(const char *format, ...); 36 | void CWLogInitFile(char *fileName); 37 | void CWLogCloseFile(); 38 | #endif 39 | -------------------------------------------------------------------------------- /CWNetwork.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWNetwork_HEADER__ 29 | #define __CAPWAP_CWNetwork_HEADER__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "CWStevens.h" 39 | 40 | typedef int CWSocket; 41 | 42 | typedef struct sockaddr_storage CWNetworkLev4Address; 43 | 44 | typedef enum { 45 | CW_IPv6, 46 | CW_IPv4 47 | } CWNetworkLev3Service; 48 | 49 | extern CWNetworkLev3Service gNetworkPreferredFamily; 50 | 51 | #define CW_COPY_NET_ADDR_PTR(addr1, addr2) sock_cpy_addr_port(((struct sockaddr*)(addr1)), ((struct sockaddr*)(addr2))) 52 | #define CW_COPY_NET_ADDR(addr1, addr2) CW_COPY_NET_ADDR_PTR(&(addr1), &(addr2)) 53 | 54 | #define CWUseSockNtop(sa, block) { \ 55 | char __str[128]; \ 56 | char *str; str = sock_ntop_r(((struct sockaddr*)(sa)), __str);\ 57 | {block} \ 58 | } 59 | 60 | #define CWNetworkRaiseSystemError(error) { \ 61 | char buf[256]; \ 62 | if(strerror_r(errno, buf, 256) < 0) { \ 63 | CWErrorRaise(error, NULL); \ 64 | return CW_FALSE; \ 65 | } \ 66 | CWErrorRaise(error, NULL); \ 67 | return CW_FALSE; \ 68 | } 69 | 70 | #define CWNetworkCloseSocket(x) { shutdown(SHUT_RDWR, x); close(x); } 71 | 72 | int CWNetworkGetAddressSize(CWNetworkLev4Address * addrPtr); 73 | CWBool CWNetworkSendUnsafeConnected(CWSocket sock, unsigned char *buf, int len); 74 | CWBool CWNetworkSendUnsafeUnconnected(CWSocket sock, CWNetworkLev4Address * addrPtr, unsigned char *buf, int len); 75 | CWBool CWNetworkReceiveUnsafe(CWSocket sock, unsigned char *buf, int len, int flags, CWNetworkLev4Address * addrPtr, 76 | int *readBytesPtr); 77 | CWBool CWNetworkReceiveUnsafeConnected(CWSocket sock, unsigned char *buf, int len, int *readBytesPtr); 78 | CWBool CWNetworkInitSocketClient(CWSocket * sockPtr, CWNetworkLev4Address * addrPtr); 79 | CWBool CWNetworkInitSocketClientDataChannel(CWSocket * sockPtr, CWNetworkLev4Address * addrPtr); 80 | CWBool CWNetworkTimedPollRead(CWSocket sock, struct timeval *timeout); 81 | CWBool CWNetworkGetAddressForHost(char *host, CWNetworkLev4Address * addrPtr); 82 | 83 | //CWBool CWNetworkInitLib(void); 84 | //CWBool CWNetworkInitSocketServer(CWSocket *sockPtr, int port); 85 | //CWBool CWNetworkSendUnsafeConnected(CWSocket sock, const char *buf, int len); 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /CWRandom.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #include "CWCommon.h" 29 | 30 | #ifdef DMALLOC 31 | #include "../dmalloc-5.5.0/dmalloc.h" 32 | #endif 33 | 34 | __inline__ void CWRandomInitLib() 35 | { 36 | // set seed 37 | srand((unsigned)time(NULL)); 38 | } 39 | 40 | __inline__ int CWRandomIntInRange(int min, int max) 41 | { 42 | return min + (rand() % (max - min)); 43 | } 44 | -------------------------------------------------------------------------------- /CWRandom.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWRandom_HEADER__ 29 | #define __CAPWAP_CWRandom_HEADER__ 30 | 31 | void CWRandomInitLib(); 32 | int CWRandomIntInRange(int min, int max); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /CWSafeList.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWSafeList_HEADER__ 29 | #define __CAPWAP_CWSafeList_HEADER__ 30 | 31 | #include "CWThread.h" 32 | 33 | typedef void *CWSafeList; 34 | 35 | typedef struct _CWPrivateSafeElement { 36 | void *pData; 37 | int nSize; 38 | CWBool dataFlag; 39 | struct _CWPrivateSafeElement *pPrev; 40 | struct _CWPrivateSafeElement *pNext; 41 | } CWPrivateSafeElement; 42 | 43 | typedef struct _CWPrivateSafeList { 44 | CWThreadMutex *pThreadMutex; 45 | CWThreadCondition *pThreadCond; 46 | 47 | unsigned long nCount; 48 | CWPrivateSafeElement *pFirstElement; 49 | CWPrivateSafeElement *pLastElement; 50 | } CWPrivateSafeList; 51 | 52 | CWBool CWCreateSafeList(CWSafeList * pSafeList); 53 | void CWDestroySafeList(CWSafeList safeList); 54 | 55 | void CWSetMutexSafeList(CWSafeList safeList, CWThreadMutex * pThreadMutex); 56 | void CWSetConditionSafeList(CWSafeList safeList, CWThreadCondition * pThreadCond); 57 | 58 | CWBool CWLockSafeList(CWSafeList safeList); 59 | void CWUnlockSafeList(CWSafeList safeList); 60 | CWBool CWWaitElementFromSafeList(CWSafeList safeList); 61 | CWBool CWSignalElementSafeList(CWSafeList safeList); 62 | 63 | unsigned long CWGetCountElementFromSafeList(CWSafeList safeList); 64 | CWBool CWAddElementToSafeListHead(CWSafeList safeList, void *pData, int nSize); 65 | void *CWGetHeadElementFromSafeList(CWSafeList safeList, int *pSize); 66 | void *CWRemoveHeadElementFromSafeList(CWSafeList safeList, int *pSize); 67 | void *CWRemoveHeadElementFromSafeListwithDataFlag(CWSafeList safeList, int *pSize, CWBool * dataFlag); 68 | CWBool CWAddElementToSafeListTail(CWSafeList safeList, void *pData, int nSize); 69 | CWBool CWAddElementToSafeListTailwitDataFlag(CWSafeList safeList, void *pData, int nSize, CWBool dataFlag); 70 | void *CWRemoveTailElementFromSafeList(CWSafeList safeList, int *pSize); 71 | void CWCleanSafeList(CWSafeList safeList, void (*deleteFunc) (void *)); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /CWSecurity.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWSecurity_HEADER__ 29 | #define __CAPWAP_CWSecurity_HEADER__ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | typedef SSL_CTX *CWSecurityContext; 36 | typedef SSL *CWSecuritySession; 37 | 38 | #define CWSecuritySetPeerForSession(session, addrPtr) BIO_ctrl((session)->rbio, BIO_CTRL_DGRAM_SET_PEER, 1, (addrPtr)) 39 | 40 | CWBool CWSecurityInitLib(void); 41 | CWBool CWSecurityInitSessionClient(CWSocket sock, 42 | CWNetworkLev4Address * addrPtr, 43 | CWSafeList packetReceiveList, 44 | CWSecurityContext ctx, CWSecuritySession * sessionPtr, int *PMTUPtr); 45 | 46 | CWBool CWSecuritySend(CWSecuritySession session, const char *buf, int len); 47 | CWBool CWSecurityReceive(CWSecuritySession session, char *buf, int len, int *readBytesPtr); 48 | 49 | CWBool CWSecurityInitContext(CWSecurityContext * ctxPtr, 50 | const char *caList, 51 | const char *keyfile, const char *passw, CWBool isClient, int (*hackPtr) (void *)); 52 | 53 | void CWSecurityDestroyContext(CWSecurityContext ctx); 54 | void CWSecurityDestroySession(CWSecuritySession s); 55 | 56 | BIO *BIO_new_memory(CWSocket sock, CWNetworkLev4Address * pSendAddress, CWSafeList * pRecvAddress); 57 | 58 | void CWSslCleanUp(); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /CWStevens.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_CWStevens_HEADER__ 29 | #define __CAPWAP_CWStevens_HEADER__ 30 | 31 | #include 32 | #include 33 | 34 | #define IFI_NAME 16 /* same as IFNAMSIZ in */ 35 | #define IFI_HADDR 8 /* allow for 64-bit EUI-64 in future */ 36 | 37 | struct ifi_info { 38 | char ifi_name[IFI_NAME]; /* interface name, null-terminated */ 39 | short ifi_index; /* interface index */ 40 | short ifi_flags; /* IFF_xxx constants from */ 41 | struct sockaddr *ifi_addr; /* primary address */ 42 | struct sockaddr *ifi_brdaddr; /* broadcast address */ 43 | struct ifi_info *ifi_next; /* next of these structures */ 44 | }; 45 | 46 | struct ifi_info *get_ifi_info(int, int); 47 | void free_ifi_info(struct ifi_info *); 48 | char *sock_ntop_r(const struct sockaddr *sa, char *str); 49 | int sock_cpy_addr_port(struct sockaddr *sa1, const struct sockaddr *sa2); 50 | void sock_set_port_cw(struct sockaddr *sa, int port); 51 | int sock_cmp_port(const struct sockaddr *sa1, const struct sockaddr *sa2, socklen_t salen); 52 | int sock_cmp_addr(const struct sockaddr *sa1, const struct sockaddr *sa2, socklen_t salen); 53 | int mcast_join(int sockfd, const struct sockaddr *grp, socklen_t grplen, const char *ifname, u_int ifindex); 54 | int Writen(int fd, void *ptr, size_t nbytes); 55 | 56 | #endif /* __CAPWAP_CWStevens_HEADER__ */ 57 | -------------------------------------------------------------------------------- /CWVendorPayloads.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************ 2 | * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * -------------------------------------------------------------------------------------------- * 19 | * Project: Capwap 20 | * Authors : Matteo Latini (mtylty@gmail.com) 21 | * Donato Capitella (d.capitella@gmail.com) * 22 | ************************************************************************************************/ 23 | 24 | #ifndef __CAPWAP_VendorPayloads__ 25 | #define __CAPWAP_VendorPayloads__ 26 | 27 | /*#include "CWCommon.h"*/ 28 | #include "CWAC.h" 29 | 30 | /*********************************************************************** 31 | * Vendor specific payloads types 32 | * *********************************************************************/ 33 | #define CW_MSG_ELEMENT_VENDOR_SPEC_PAYLOAD_UCI 1 34 | #define CW_MSG_ELEMENT_VENDOR_SPEC_PAYLOAD_WUM 2 35 | 36 | /*********************************************************************** 37 | * UCI Server Port 38 | * *********************************************************************/ 39 | #define UCI_SERVER_PORT 31337 40 | 41 | typedef struct { 42 | unsigned char command; 43 | char *commandArgs; 44 | char *response; 45 | } CWVendorUciValues; 46 | 47 | CWBool CWParseVendorPayload(CWProtocolMessage * msg, int len, CWProtocolVendorSpecificValues * valPtr); 48 | CWBool CWParseUCIPayload(CWProtocolMessage * msg, CWVendorUciValues ** payloadPtr); 49 | CWBool CWWTPSaveUCIValues(CWVendorUciValues * uciPayload, CWProtocolResultCode * resultCode); 50 | CWBool CWAssembleWTPVendorPayloadUCI(CWProtocolMessage * msgPtr); 51 | 52 | /************************************************************************* 53 | * WTP Update Messages 54 | *************************************************************************/ 55 | 56 | typedef struct { 57 | unsigned char major_v; 58 | unsigned char min_v; 59 | unsigned char revision; 60 | } mess_version_info; 61 | typedef struct { 62 | mess_version_info v_info; 63 | unsigned int pack_size; 64 | } mess_up_req; 65 | typedef struct { 66 | unsigned int seq_num; 67 | unsigned int size; 68 | unsigned char *buf; 69 | } mess_cup; 70 | 71 | typedef struct { 72 | unsigned char type; /* Message type */ 73 | union { 74 | mess_version_info v_resp; 75 | mess_up_req up_req; 76 | mess_cup cup; 77 | } args; 78 | } CWVendorWumValues; 79 | 80 | #define _major_v_ args.v_resp.major_v 81 | #define _minor_v_ args.v_resp.min_v 82 | #define _revision_v_ args.v_resp.revision 83 | #define _pack_size_ args.up_req.pack_size 84 | #define _seq_num_ args.cup.seq_num 85 | #define _cup_ args.cup.buf 86 | #define _cup_fragment_size_ args.cup.size 87 | 88 | #define CUP_FRAGMENT_SIZE 4000 89 | 90 | //CWBool CWParseWUMPayload(CWProtocolMessage *msg, CWVendorUciValues **payloadPtr); 91 | CWBool CWWTPSaveWUMValues(CWVendorWumValues * wumPayload, CWProtocolResultCode * resultCode); 92 | CWBool CWAssembleWTPVendorPayloadWUM(CWProtocolMessage * msgPtr); 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /INSTALL.rst: -------------------------------------------------------------------------------- 1 | ============================================= 2 | HOW TO BUILD AND RUN CAPWAP FOR LINUX SYSTEMS 3 | ============================================= 4 | 5 | NOTE: To run WTP you must have a wireless card that has Linux driver based on the 6 | Generic IEEE 802.11 Networking Stack (mac80211). 7 | 8 | 9 | HOW TO BUILD AC AND WTP 10 | ======================= 11 | 12 | Requirements 13 | ------------ 14 | 15 | * automake 1.9 or newer 16 | * autoconf 17 | * libtool 18 | * openssl 19 | 20 | Build 21 | ----- 22 | 23 | Run: 24 | 25 | autoreconf -f -i -s 26 | CFLAGS="-I/usr/include/openssl -DLOCALUDP" ./configure 27 | make 28 | make install 29 | 30 | Use the CFLAGS setting "-DLOCALUDP" to use local UNIX sockets for 31 | hostapd to AC/WTP communication. The openssl include path needs to 32 | be adjusted to your local openssl installation directory. 33 | 34 | HOW TO RUN WTP 35 | ============== 36 | 37 | * build hostapd with capwap support, see hostapd_wrapper/README.rst for instructions 38 | * make sure that your PCMCIA wireless card is working 39 | 40 | * create a wireless interfaces on the WiFi card in "ap" mode, 41 | /usr/sbin/iw phy phy0 interface add wlan0 type managed 42 | * adjust settings.wtp.txt and config.wtp 43 | * run WTP in superuser mode 44 | * run hostapd (see also hostapd_wrapper/README.rst) 45 | 46 | HOW TO RUN AC 47 | ============= 48 | 49 | * build hostapd with capwap support, see hostapd_wrapper/README.rst for instructions 50 | 51 | 52 | * adjust settings.ac.txt and config.ac 53 | * run AC in superuser mode 54 | * run hostapd (see also hostapd_wrapper/README.rst) 55 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS=-I m4 2 | 3 | AM_CPPFLAGS = -I$(srcdir)/include -D_REENTRANT 4 | AM_CPPFLAGS += -DOPENSSL_NO_KRB5 5 | 6 | # Capwap Debugging 7 | AM_CPPFLAGS += -DWRITE_STD_OUTPUT 8 | AM_CPPFLAGS += -DSOFTMAC 9 | AM_CPPFLAGS += -Wall 10 | 11 | bin_PROGRAMS = AC WTP WUA 12 | 13 | noinst_LTLIBRARIES = libcapwap.la 14 | libcapwap_la_SOURCES = \ 15 | CWLog.c \ 16 | CWCommon.c \ 17 | CWConfigFile.c \ 18 | CWErrorHandling.c \ 19 | CWList.c \ 20 | CWSafeList.c \ 21 | CWNetwork.c \ 22 | CWProtocol.c \ 23 | CWRandom.c \ 24 | CWStevens.c \ 25 | CWThread.c \ 26 | CWBinding.c \ 27 | CWVendorPayloadsAC.c \ 28 | CWVendorPayloadsWTP.c \ 29 | timerlib.c 30 | 31 | if USE_SSL 32 | libcapwap_la_SOURCES += \ 33 | CWSecurity.c \ 34 | CWOpenSSLBio.c 35 | endif 36 | 37 | libcapwap_la_CFLAGS = ${OPENSSL_INCLUDES} 38 | libcapwap_la_LIBADD = ${OPENSSL_LDFLAGS} ${OPENSSL_LIBS} 39 | 40 | AC_SOURCES = \ 41 | AC.c \ 42 | ACConfigFile.c \ 43 | ACMainLoop.c \ 44 | ACDiscoveryState.c \ 45 | ACJoinState.c \ 46 | ACConfigureState.c \ 47 | ACDataCheckState.c \ 48 | ACRunState.c \ 49 | ACProtocol_User.c \ 50 | ACRetransmission.c \ 51 | ACMultiHomedSocket.c \ 52 | ACProtocol.c \ 53 | ACBinding.c \ 54 | ACInterface.c \ 55 | ACSettingsFile.c \ 56 | tap.c \ 57 | ACipcHostapd.c 58 | AC_LDADD = libcapwap.la 59 | 60 | WTP_SOURCES = \ 61 | WTP.c \ 62 | WTPipcHostapd.c \ 63 | WTPmacFrameReceive.c \ 64 | WTPFreqStatsReceive.c \ 65 | WTPStatsReceive.c \ 66 | WTPConfigFile.c \ 67 | WTPProtocol.c \ 68 | WTPProtocol_User.c \ 69 | WTPDiscoveryState.c \ 70 | WTPJoinState.c \ 71 | WTPConfigureState.c \ 72 | WTPDataCheckState.c \ 73 | WTPRunState.c \ 74 | WTPRunStateCheck.c \ 75 | WTPRetransmission.c \ 76 | WTPSulkingState.c \ 77 | WTPBinding.c \ 78 | WTPmacDriverInteraction.c \ 79 | WTPSettingsFile.c 80 | WTP_LDADD = libcapwap.la 81 | 82 | WUA_SOURCES = WUA.c 83 | -------------------------------------------------------------------------------- /Makefile.bcm: -------------------------------------------------------------------------------- 1 | # ******************************************************************************************* 2 | # * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | # * Universita' Campus BioMedico - Italy * 4 | # * * 5 | # * This program is free software; you can redistribute it and/or modify it under the terms * 6 | # * of the GNU General Public License as published by the Free Software Foundation; either * 7 | # * version 2 of the License, or (at your option) any later version. * 8 | # * * 9 | # * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | # * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | # * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | # * * 13 | # * You should have received a copy of the GNU General Public License along with this * 14 | # * program; if not, write to the: * 15 | # * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | # * MA 02111-1307, USA. * 17 | # * * 18 | # * --------------------------------------------------------------------------------------- * 19 | # * Project: Capwap * 20 | # * * 21 | # * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | # * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | # * Giovannini Federica (giovannini.federica@gmail.com) * 24 | # * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | # * Mauro Bisson (mauro.bis@gmail.com) * 26 | # ******************************************************************************************* 27 | 28 | KAMIKAZEDIR=/home/daniele/Scrivania/kamikaze-SDK 29 | 30 | CC = $(KAMIKAZEDIR)/staging_dir_mipsel/bin/mipsel-linux-gcc 31 | 32 | LDFLAGS = $(KAMIKAZEDIR)/staging_dir_mipsel/usr/lib/libssl.a $(KAMIKAZEDIR)/staging_dir_mipsel/usr/lib/libcrypto.a $(KAMIKAZEDIR)/staging_dir_mipsel/lib/libpthread.a $(KAMIKAZEDIR)/staging_dir_mipsel/lib/libdl.a $(KAMIKAZEDIR)/staging_dir_mipsel/usr/lib/libpcap.a -D_REENTRANT 33 | 34 | CFLAGS = -Wall -g -O0 -D_REENTRANT -DBCM -I $(KAMIKAZEDIR)/staging_dir_mipsel/usr/include #-DCW_NO_DTLS 35 | 36 | # Memory leak 37 | #LDFLAGS += ../dmalloc-5.5.0/libdmallocth.a 38 | #CFLAGS += -DDMALLOC 39 | 40 | # Capwap Debugging 41 | CFLAGS += -DCW_DEBUGGING 42 | 43 | RM = /bin/rm -f 44 | 45 | # list of generated object files for WTP. 46 | WTP_OBJS = WTP.o WTPBcmFrameReceive.o WTPConfigFile.o WTPProtocol.o WTPProtocol_User.o WTPDiscoveryState.o WTPJoinState.o WTPConfigureState.o WTPDataCheckState.o WTPRunState.o WTPRunStateCheck.o WTPRetransmission.o WTPSulkingState.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWSafeList.o CWList.o CWLog.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o WTPBinding.o WTPBcmDriverInteraction.o WTPSettingsFile.o timerlib.o 47 | 48 | WTP_SRCS = $(WTP_OBJS:.o=.c) 49 | 50 | WTP_DEPS := $(WTP_OBJS:.o=.d) 51 | 52 | # program executables. 53 | WTP_NAME = WTP 54 | 55 | .PHONY: deps clean clean_libs libs 56 | 57 | # top-level rule, to compile everything. 58 | all: $(WTP_NAME) 59 | 60 | $(WTP_NAME): $(WTP_OBJS) 61 | $(CC) -DWRITE_STD_OUTPUT $(WTP_OBJS) $(CC_FLAGS) $(LDFLAGS) -o $(WTP_NAME) 62 | 63 | clean: 64 | $(RM) $(WTP_NAME) $(WTP_OBJS) $(WTP_DEPS) 65 | 66 | clean_deps: 67 | $(WTP_DEPS) 68 | 69 | deps: $(WTP_SRC) 70 | $(CC) -MD -E -DWRITE_STD_OUTPUT $(WTP_SRCS) $(CFLAGS) >/dev/null 71 | 72 | -include $(WTP_DEPS) 73 | -------------------------------------------------------------------------------- /Makefile.glibc: -------------------------------------------------------------------------------- 1 | # ******************************************************************************************* 2 | # * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | # * Universita' Campus BioMedico - Italy * 4 | # * * 5 | # * This program is free software; you can redistribute it and/or modify it under the terms * 6 | # * of the GNU General Public License as published by the Free Software Foundation; either * 7 | # * version 2 of the License, or (at your option) any later version. * 8 | # * * 9 | # * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | # * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | # * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | # * * 13 | # * You should have received a copy of the GNU General Public License along with this * 14 | # * program; if not, write to the: * 15 | # * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | # * MA 02111-1307, USA. * 17 | # * * 18 | # * --------------------------------------------------------------------------------------- * 19 | # * Project: Capwap * 20 | # * * 21 | # * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | # * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | # * Giovannini Federica (giovannini.federica@gmail.com) * 24 | # * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | # ******************************************************************************************* 26 | 27 | 28 | 29 | CC = gcc 30 | 31 | #LDFLAGS = -lssl -lcrypto -lpthread -ldl -D_REENTRANT 32 | #LDFLAGS = /usr/lib/libefence.a ./static/libssl.a ./static/libcrypto.a -lpthread -ldl -D_REENTRANT 33 | LDFLAGS = ./static/libssl.a ./static/libcrypto.a -lpthread -ldl -D_REENTRANT 34 | 35 | CFLAGS = -Wall -g -O0 -D_REENTRANT -I/usr/local/ssl/include/ #-DCW_NO_DTLS 36 | 37 | OPENSSL_INCLUDE = #-I/usr/local/ssl/include/ #Openssl include files 38 | 39 | # Memory leak 40 | #LDFLAGS += ../dmalloc-5.5.0/libdmallocth.a 41 | #CFLAGS += -DDMALLOC 42 | 43 | # Capwap Debugging 44 | CFLAGS += -DCW_DEBUGGING 45 | 46 | RM = /bin/rm -f 47 | 48 | # list of generated object files for AC. 49 | AC_OBJS = AC.o ACConfigFile.o ACMainLoop.o ACDiscoveryState.o ACJoinState.o ACConfigureState.o ACDataCheckState.o ACRunState.o ACProtocol_User.o ACRetransmission.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWList.o CWLog.o ACMultiHomedSocket.o ACProtocol.o CWSafeList.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o CWVendorPayloadsAC.o ACBinding.o ACInterface.o ACSettingsFile.o timerlib.o 50 | 51 | # list of generated object files for WTP. 52 | WTP_OBJS = WTP.o WTPFrameReceive.o WTPFreqStatsReceive.o WTPStatsReceive.o WTPConfigFile.o WTPProtocol.o WTPProtocol_User.o WTPDiscoveryState.o WTPJoinState.o WTPConfigureState.o WTPDataCheckState.o WTPRunState.o WTPRunStateCheck.o WTPRetransmission.o WTPSulkingState.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWSafeList.o CWList.o CWLog.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o CWVendorPayloadsWTP.o WTPBinding.o WTPDriverInteraction.o WTPSettingsFile.o timerlib.o 53 | 54 | AC_SRCS = $(AC_OBJS:.o=.c) 55 | WTP_SRCS = $(WTP_OBJS:.o=.c) 56 | 57 | AC_DEPS := $(AC_OBJS:.o=.d) 58 | WTP_DEPS := $(WTP_OBJS:.o=.d) 59 | 60 | # program executables. 61 | AC_NAME = AC 62 | WTP_NAME = WTP 63 | 64 | .PHONY: deps clean clean_libs libs 65 | 66 | # top-level rule, to compile everything. 67 | all: $(AC_NAME) $(WTP_NAME) 68 | 69 | $(AC_NAME): $(AC_OBJS) 70 | $(CC) $(AC_OBJS) $(CC_FLAGS) $(OPENSSL_INCLUDE) $(LDFLAGS) -o $(AC_NAME) 71 | 72 | $(WTP_NAME): $(WTP_OBJS) 73 | $(CC) -DWRITE_STD_OUTPUT $(WTP_OBJS) $(CC_FLAGS) $(LDFLAGS) -o $(WTP_NAME) 74 | 75 | clean: 76 | $(RM) $(AC_NAME) $(WTP_NAME) $(AC_OBJS) $(WTP_OBJS) $(AC_DEPS) $(WTP_DEPS) 77 | 78 | clean_deps: 79 | $(AC_DEPS) $(WTP_DEPS) 80 | 81 | deps: $(AC_SRC) $(WTP_SRC) 82 | $(CC) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null 83 | $(CC) -MD -E -DWRITE_STD_OUTPUT $(WTP_SRCS) $(CFLAGS) >/dev/null 84 | 85 | -include $(AC_DEPS) 86 | -include $(WTP_DEPS) 87 | -------------------------------------------------------------------------------- /Makefile.uclibc: -------------------------------------------------------------------------------- 1 | # ******************************************************************************************* 2 | # * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | # * Universita' Campus BioMedico - Italy * 4 | # * * 5 | # * This program is free software; you can redistribute it and/or modify it under the terms * 6 | # * of the GNU General Public License as published by the Free Software Foundation; either * 7 | # * version 2 of the License, or (at your option) any later version. * 8 | # * * 9 | # * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | # * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | # * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | # * * 13 | # * You should have received a copy of the GNU General Public License along with this * 14 | # * program; if not, write to the: * 15 | # * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | # * MA 02111-1307, USA. * 17 | # * * 18 | # * --------------------------------------------------------------------------------------- * 19 | # * Project: Capwap * 20 | # * * 21 | # * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | # * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | # * Giovannini Federica (giovannini.federica@gmail.com) * 24 | # * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | # ******************************************************************************************* 26 | 27 | 28 | 29 | CC = gcc-openwrt 30 | 31 | #LDFLAGS = -lssl -lcrypto -lpthread -ldl -D_REENTRANT 32 | #LDFLAGS = /usr/lib/libefence.a ./static/libssl.a ./static/libcrypto.a -lpthread -ldl -D_REENTRANT 33 | LDFLAGS = ./static/uclibc/libssl.a ./static/uclibc/libcrypto.a -lpthread -ldl -D_REENTRANT 34 | 35 | CFLAGS = -Wall -g -O0 -D_REENTRANT -I./include/ #-DCW_NO_DTLS 36 | 37 | OPENSSL_INCLUDE = #-I/usr/local/ssl/include/ #Openssl include files 38 | 39 | # Memory leak 40 | #LDFLAGS += ../dmalloc-5.5.0/libdmallocth.a 41 | #CFLAGS += -DDMALLOC 42 | 43 | # Capwap Debugging 44 | CFLAGS += -DCW_DEBUGGING 45 | CFLAGS += -DOPENSSL_NO_KRB5 46 | 47 | RM = /bin/rm -f 48 | 49 | # list of generated object files for AC. 50 | AC_OBJS = AC.o ACConfigFile.o ACMainLoop.o ACDiscoveryState.o ACJoinState.o ACConfigureState.o ACDataCheckState.o ACRunState.o ACProtocol_User.o ACRetransmission.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWList.o CWLog.o ACMultiHomedSocket.o ACProtocol.o CWSafeList.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o CWVendorPayloadsAC.o ACBinding.o ACInterface.o ACSettingsFile.o timerlib.o 51 | 52 | # list of generated object files for WTP. 53 | WTP_OBJS = WTP.o WTPFrameReceive.o WTPFreqStatsReceive.o WTPStatsReceive.o WTPConfigFile.o WTPProtocol.o WTPProtocol_User.o WTPDiscoveryState.o WTPJoinState.o WTPConfigureState.o WTPDataCheckState.o WTPRunState.o WTPRunStateCheck.o WTPRetransmission.o WTPSulkingState.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWSafeList.o CWList.o CWLog.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o CWVendorPayloadsWTP.o WTPBinding.o WTPDriverInteraction.o WTPSettingsFile.o timerlib.o 54 | 55 | WUA_OBJS = WUA.o 56 | 57 | AC_SRCS = $(AC_OBJS:.o=.c) 58 | WTP_SRCS = $(WTP_OBJS:.o=.c) 59 | WUA_SRCS = $(WUA:OBJS:.o=.c) 60 | 61 | AC_DEPS := $(AC_OBJS:.o=.d) 62 | WTP_DEPS := $(WTP_OBJS:.o=.d) 63 | WUA_DEPS := $(WUA_OBJS:.o=.d) 64 | 65 | # program executables. 66 | AC_NAME = AC 67 | WTP_NAME = WTP 68 | WUA_NAME = WUA 69 | 70 | .PHONY: deps clean clean_libs libs 71 | 72 | # top-level rule, to compile everything. 73 | all: $(AC_NAME) $(WTP_NAME) 74 | 75 | $(AC_NAME): $(AC_OBJS) 76 | $(CC) $(AC_OBJS) $(CC_FLAGS) $(OPENSSL_INCLUDE) $(LDFLAGS) -o $(AC_NAME) 77 | 78 | $(WTP_NAME): $(WTP_OBJS) 79 | $(CC) -DWRITE_STD_OUTPUT $(WTP_OBJS) $(CC_FLAGS) $(LDFLAGS) -o $(WTP_NAME) 80 | 81 | $(WUA_NAME): $(WUA_OBJS) 82 | $(CC) $(WUA_OBJS) $(CC_FLAGS) $(LDFLAGS) -o $(WUA_NAME) 83 | 84 | clean: 85 | $(RM) $(AC_NAME) $(WTP_NAME) $(WUA_NAME) $(AC_OBJS) $(WTP_OBJS) $(WUA_OBJS) $(AC_DEPS) $(WTP_DEPS) 86 | 87 | clean_deps: 88 | $(AC_DEPS) $(WTP_DEPS) 89 | 90 | deps: $(AC_SRC) $(WTP_SRC) 91 | $(CC) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null 92 | $(CC) -MD -E -DWRITE_STD_OUTPUT $(WTP_SRCS) $(CFLAGS) >/dev/null 93 | 94 | -include $(AC_DEPS) 95 | -include $(WTP_DEPS) 96 | -------------------------------------------------------------------------------- /MakefileMac: -------------------------------------------------------------------------------- 1 | # ******************************************************************************************* 2 | # * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | # * Universita' Campus BioMedico - Italy * 4 | # * * 5 | # * This program is free software; you can redistribute it and/or modify it under the terms * 6 | # * of the GNU General Public License as published by the Free Software Foundation; either * 7 | # * version 2 of the License, or (at your option) any later version. * 8 | # * * 9 | # * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | # * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | # * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | # * * 13 | # * You should have received a copy of the GNU General Public License along with this * 14 | # * program; if not, write to the: * 15 | # * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | # * MA 02111-1307, USA. * 17 | # * * 18 | # * --------------------------------------------------------------------------------------- * 19 | # * Project: Capwap * 20 | # * * 21 | # * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | # * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | # * Giovannini Federica (giovannini.federica@gmail.com) * 24 | # * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | # ******************************************************************************************* 26 | 27 | 28 | 29 | CC = gcc 30 | 31 | #LDFLAGS = -lssl -lcrypto -lpthread -ldl -D_REENTRANT 32 | #LDFLAGS = /usr/lib/libefence.a ./static/libssl.a ./static/libcrypto.a -lpthread -ldl -D_REENTRANT 33 | LDFLAGS = /opt/local/lib/libssl.a /opt/local/lib/libcrypto.a /opt/local/lib/libz.a -lpthread -ldl -D_REENTRANT 34 | 35 | CFLAGS = -Wall -g -O0 -D_REENTRANT -I/opt/local/include/ #-DCW_NO_DTLS 36 | 37 | OPENSSL_INCLUDE = #-I/opt/local/include/ #Openssl include files 38 | 39 | # Memory leak 40 | #LDFLAGS += ../dmalloc-5.5.0/libdmallocth.a 41 | #CFLAGS += -DDMALLOC 42 | 43 | # Capwap Debugging 44 | CFLAGS += -DCW_DEBUGGING -DMACOSX 45 | 46 | RM = /bin/rm -f 47 | 48 | # list of generated object files for AC. 49 | AC_OBJS = AC.o ACConfigFile.o ACMainLoop.o ACDiscoveryState.o ACJoinState.o ACConfigureState.o ACDataCheckState.o ACRunState.o ACProtocol_User.o ACRetransmission.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWList.o CWLog.o ACMultiHomedSocket.o ACProtocol.o CWSafeList.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o ACBinding.o ACInterface.o ACSettingsFile.o timerlib.o 50 | 51 | # list of generated object files for WTP. 52 | WTP_OBJS = WTP.o WTPFrameReceive.o WTPFreqStatsReceive.o WTPStatsReceive.o WTPConfigFile.o WTPProtocol.o WTPProtocol_User.o WTPDiscoveryState.o WTPJoinState.o WTPConfigureState.o WTPDataCheckState.o WTPRunState.o WTPRunStateCheck.o WTPRetransmission.o WTPSulkingState.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWSafeList.o CWList.o CWLog.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o WTPBinding.o WTPDriverInteraction.o WTPSettingsFile.o timerlib.o 53 | 54 | AC_SRCS = $(AC_OBJS:.o=.c) 55 | WTP_SRCS = $(WTP_OBJS:.o=.c) 56 | 57 | AC_DEPS := $(AC_OBJS:.o=.d) 58 | WTP_DEPS := $(WTP_OBJS:.o=.d) 59 | 60 | # program executables. 61 | AC_NAME = AC 62 | WTP_NAME = WTP 63 | 64 | .PHONY: deps clean clean_libs libs 65 | 66 | # top-level rule, to compile everything. 67 | all: $(AC_NAME) $(WTP_NAME) 68 | 69 | $(AC_NAME): $(AC_OBJS) 70 | $(CC) $(AC_OBJS) $(CC_FLAGS) $(OPENSSL_INCLUDE) $(LDFLAGS) -o $(AC_NAME) 71 | 72 | $(WTP_NAME): $(WTP_OBJS) 73 | $(CC) -DWRITE_STD_OUTPUT $(WTP_OBJS) $(CC_FLAGS) $(LDFLAGS) -o $(WTP_NAME) 74 | 75 | clean: 76 | $(RM) $(AC_NAME) $(WTP_NAME) $(AC_OBJS) $(WTP_OBJS) $(AC_DEPS) $(WTP_DEPS) 77 | 78 | clean_deps: 79 | $(AC_DEPS) $(WTP_DEPS) 80 | 81 | deps: $(AC_SRC) $(WTP_SRC) 82 | $(CC) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null 83 | $(CC) -MD -E -DWRITE_STD_OUTPUT $(WTP_SRCS) $(CFLAGS) >/dev/null 84 | 85 | -include $(AC_DEPS) 86 | -include $(WTP_DEPS) 87 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/README.md -------------------------------------------------------------------------------- /WTPBcmFrameReceive.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_WTPFrameReceive_HEADER__ 29 | #define __CAPWAP_WTPFrameReceive_HEADER__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "CWWTP.h" 39 | 40 | #define EXIT_THREAD CWLog("ERROR Handling Frames: application will be closed!"); \ 41 | exit(1); 42 | 43 | #define WL_DEVICE "wl0" 44 | #define MAC_ADDR_LEN 6 45 | 46 | /* check this magic number */ 47 | #define WLC_IOCTL_MAGIC 0x14e46c77 48 | 49 | #define WLC_GET_MAGIC 0 50 | #define WLC_GET_BSSID 23 51 | #define WLC_SET_BSSID 24 52 | #define WLC_GET_SSID 25 53 | #define WLC_SET_SSID 26 54 | #define WLC_GET_CHANNEL 29 55 | #define WLC_SET_CHANNEL 30 56 | #define WLC_GET_MONITOR 107 /* discovered by nbd */ 57 | #define WLC_SET_MONITOR 108 /* discovered by nbd */ 58 | #define WLC_GET_AP 117 59 | #define WLC_SET_AP 118 60 | #define WLC_GET_RSSI 127 61 | #define WLC_GET_ASSOCLIST 159 62 | 63 | #ifdef DEFINE_TYPES 64 | typedef unsigned short u_short; 65 | typedef unsigned char u_char; 66 | typedef unsigned int u_int; 67 | #endif 68 | 69 | typedef enum { 70 | mgt_assocRequest = 0, 71 | mgt_assocResponse = 1, 72 | mgt_reassocRequest = 2, 73 | mgt_reassocResponse = 3, 74 | mgt_probeRequest = 4, 75 | mgt_probeResponse = 5, 76 | mgt_beacon = 8, 77 | mgt_disassoc = 10, 78 | mgt_auth = 11, 79 | mgt_deauth = 12 80 | } wifi_frametype; 81 | 82 | typedef struct ieee802_11_hdr { 83 | u_char frame_control; 84 | u_char flags; 85 | #define IEEE80211_TO_DS 0x01 86 | #define IEEE80211_FROM_DS 0x02 87 | #define IEEE80211_MORE_FRAG 0x04 88 | #define IEEE80211_RETRY 0x08 89 | #define IEEE80211_PWR_MGT 0x10 90 | #define IEEE80211_MORE_DATA 0x20 91 | #define IEEE80211_WEP_FLAG 0x40 92 | #define IEEE80211_ORDER_FLAG 0x80 93 | u_short duration; 94 | u_char addr1[6]; 95 | u_char addr2[6]; 96 | u_char addr3[6]; 97 | u_short frag_and_seq; 98 | } ieee802_11_hdr; 99 | 100 | typedef struct { 101 | u_char timestamp[8]; 102 | u_short bcn_interval; 103 | u_short caps; 104 | #define MGT_CAPS_AP 0x1 105 | #define MGT_CAPS_IBSS 0x2 106 | #define MGT_CAPS_WEP 0x10 107 | } ieee_802_11_mgt_frame; 108 | 109 | typedef struct prism_hdr { 110 | u_int msg_code; 111 | u_int msg_length; 112 | char cap_device[16]; 113 | } prism_hdr; 114 | 115 | typedef struct prism_did { 116 | u_short did; 117 | u_short status1; 118 | u_short status2; 119 | u_short length; 120 | 121 | } prism_did; 122 | 123 | typedef enum prism_did_num { 124 | pdn_host_time = 0x1041, 125 | pdn_mac_time = 0x2041, 126 | pdn_rssi = 0x4041, 127 | pdn_sq = 0x5041, 128 | pdn_datarate = 0x8041, 129 | pdn_framelen = 0xa041 130 | } prism_did_num; 131 | 132 | void print_mac(u_char * mac, char *extra); 133 | void fprint_mac(FILE * outf, u_char * mac, char *extra); 134 | int macAddrCmp(unsigned char *addr1, unsigned char *addr2); 135 | int get_mac(u_char * buf); 136 | void dealWithPacket(struct pcap_pkthdr *header, const u_char * packet, u_char * wl0_mac_address); 137 | #endif 138 | -------------------------------------------------------------------------------- /WTPBinding.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************ 2 | * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * -------------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Authors : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | * Antonio Davoli (antonio.davoli@gmail.com) * 27 | ************************************************************************************************/ 28 | 29 | #ifndef __CAPWAP_WTPBinding_HEADER__ 30 | #define __CAPWAP_WTPBinding_HEADER__ 31 | 32 | typedef struct { 33 | unsigned char radioID; 34 | WTPQosValues qosValues[NUM_QOS_PROFILES]; 35 | } RadioQosValues; 36 | 37 | typedef struct { 38 | int qosCount; 39 | RadioQosValues *radioQosValues; 40 | } CWBindingConfigurationRequestValues; 41 | 42 | typedef struct { 43 | int qosCount; 44 | RadioQosValues *radioQosValues; 45 | } CWBindingConfigurationUpdateRequestValues; 46 | 47 | /**************************************************** 48 | * 2009 Updates: * 49 | * New Structure for mananagement of * 50 | * OFDM Message Element * 51 | ****************************************************/ 52 | 53 | typedef struct { 54 | unsigned char radioID; 55 | OFDMControlValues *radioOFDMValues; 56 | } CWBindingConfigurationUpdateRequestValuesOFDM; 57 | 58 | /**************************************************** 59 | * 2009 Updates: * 60 | * Definition of port number and type * 61 | * of commands of Frequency Server * 62 | * Manager (WTP side). * 63 | ****************************************************/ 64 | 65 | #define FREQ_SERVER_ADDR "127.0.0.1" 66 | #define FREQ_SERVER_PORT 1236 67 | 68 | CWBool CWWTPInitBinding(int radioIndex); 69 | CWBool CWBindingSaveConfigureResponse(void *bindingValuesPtr, CWProtocolResultCode * resultCode); 70 | CWBool CWBindingSetQosValues(int qosCount, RadioQosValues * radioQosValues, CWProtocolResultCode * resultCode); 71 | CWBool CWBindingParseConfigurationUpdateRequest(unsigned char *msg, int len, void **valuesPtr); 72 | CWBool CWBindingParseConfigureResponse(unsigned char *msg, int len, void **valuesPtr); 73 | /**************************************************** 74 | * 2009 Updates: (SaveConfiguration) * 75 | * Prototype Modification (int * added)* 76 | ****************************************************/ 77 | CWBool CWBindingSaveConfigurationUpdateRequest(void *bindingValuesPtr, CWProtocolResultCode * resultCode, 78 | int *updateRequestType); 79 | #endif 80 | -------------------------------------------------------------------------------- /WTPFrameReceive.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_WTPFrameReceive_HEADER__ 29 | #define __CAPWAP_WTPFrameReceive_HEADER__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "CWWTP.h" 39 | 40 | #ifndef B_ENDIAN 41 | #define CHECK_PRISM_HEADER (buffer[0]==MESSAGE_CODE_1) && \ 42 | (buffer[1]==MESSAGE_CODE_2) && \ 43 | (buffer[2]==MESSAGE_CODE_3) && \ 44 | (buffer[3]==MESSAGE_CODE_4) 45 | #else 46 | #define CHECK_PRISM_HEADER (buffer[3]==MESSAGE_CODE_1) && \ 47 | (buffer[2]==MESSAGE_CODE_2) && \ 48 | (buffer[1]==MESSAGE_CODE_3) && \ 49 | (buffer[0]==MESSAGE_CODE_4) 50 | #endif 51 | 52 | //#define PROMODE_ON 53 | //#define FILTER_ON 54 | #define PRISMH_LEN 144 55 | #define RSSI_BYTE 68 56 | #define SIGNAL_BYTE 92 57 | #define NOISE_BYTE 104 58 | #define DATARATE_BYTE 116 59 | #define DEST_ADDR_START 4 60 | #define SOURCE_ADDR_START 10 61 | #define MESSAGE_CODE_1 68 62 | #define MESSAGE_CODE_2 0 63 | #define MESSAGE_CODE_3 0 64 | #define MESSAGE_CODE_4 0 65 | #define MAC_ADDR_LEN 6 66 | #define ATHEROS_CONV_VALUE 95 67 | 68 | #define ASSOCIATION_REQUEST_SUBTYPE 0 69 | #define ASSOCIATION_RESPONSE_SUBTYPE 1 70 | #define REASSOCIATION_REQUEST_SUBTYPE 2 71 | #define REASSOCIATION_RESPONSE_SUBTYPE 3 72 | #define PROBE_REQUEST_SUBTYPE 4 73 | #define PROBE_RESPONSE_SUBTYPE 5 74 | #define RESERVED6_SUBTYPE 6 75 | #define RESERVED7_SUBTYPE 7 76 | #define BEACON_SUBTYPE 8 77 | #define ATIM_SUBTYPE 9 78 | #define DISASSOCIATION_SUBTYPE 10 79 | #define AUTHENTICATION_SUBTYPE 11 80 | #define DEAUTHENTICATION_SUBTYPE 12 81 | 82 | #define RESERVED0_SUBTYPE 0 83 | #define RESERVED9_SUBTYPE 9 84 | #define POWER_SAVE_SUBTYPE 10 85 | #define RTS_SUBTYPE 11 86 | #define CTS_SUBTYPE 12 87 | #define ACKNOLEDGEMENT_SUBTYPE 13 88 | #define CF_END_SUBTYPE 14 89 | #define CF_END_CF_ACK_SUBTYPE 15 90 | 91 | #define DATA_SUBTYPE 0 92 | #define DATA_CF_ACK_SUBTYPE 1 93 | #define DATA_CF_POLL_SUBTYPE 2 94 | #define DATA_CF_ACK_CF_POLL_SUBTYPE 3 95 | #define NO_DATA_SUBTYPE 4 96 | #define CF_ACK_SUBTYPE 5 97 | #define CF_POLL_SUBTYPE 6 98 | #define CF_ACK_CF_POLL_SUBTYPE 7 99 | #define RESERVED8_SUBTYPE 8 100 | #define RESERVED15_SUBTYPE 15 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /WTPFreqStatsReceive.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Antonio Davoli (antonio.davoli@gmail.com) * 22 | * * 23 | *******************************************************************************************/ 24 | 25 | #ifndef __CAPWAP_WTPFreqStatsReceive_HEADER__ 26 | #define __CAPWAP_WTPFreqStatsReceive_HEADER__ 27 | 28 | #include "CWWTP.h" 29 | #include 30 | #include 31 | #include 32 | 33 | #define SERVER_PORT 1237 34 | #define PACKET_SIZE 65536 35 | 36 | #define EXIT_THREAD CWLog("ERROR Handling Frequency Stats: application will be closed!"); \ 37 | close(recSock); \ 38 | exit(1); 39 | 40 | /* Structs for frequencies' informations */ 41 | 42 | typedef unsigned char uint8; 43 | 44 | #define MAX_FREQ_LENGTH 16 45 | #define MAX_ESSID_LENGTH 32 46 | #define MAX_MAC_ADDR_LENGTH 18 /* XX:XX:XX:XX:XX:XX */ 47 | 48 | typedef struct _quality { 49 | uint8 numerator; 50 | uint8 denominator; 51 | } quality; 52 | 53 | typedef struct _FreqQualityInfo { 54 | uint8 version; 55 | char ESSID[MAX_ESSID_LENGTH]; 56 | char Address[MAX_MAC_ADDR_LENGTH]; 57 | uint8 channel; 58 | uint8 assocStations; 59 | uint8 throughStations; 60 | quality qualityLevel; 61 | int signalLevel; 62 | int noiseLevel; 63 | } FreqQualityInfo; 64 | 65 | typedef struct _FREQ_MONITOR_DATA { 66 | int numberOfCells; 67 | FreqQualityInfo *qualityOfCells; 68 | } FREQ_MONITOR_DATA; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /WTPStatsReceive.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2008 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Daniele De Sanctis (danieledesanctis@gmail.com) * 22 | * * 23 | *******************************************************************************************/ 24 | 25 | #include "WTPStatsReceive.h" 26 | 27 | int create_data_Frame(CWProtocolMessage ** frame, char *buffer, int len) 28 | { 29 | 30 | CW_CREATE_OBJECT_ERR(*frame, CWProtocolMessage, return 0; 31 | ); 32 | CWProtocolMessage *auxPtr = *frame; 33 | CW_CREATE_PROTOCOL_MESSAGE(*auxPtr, len, return 0; 34 | ); 35 | memcpy(auxPtr->msg, buffer, len); 36 | auxPtr->offset = len; 37 | return 1; 38 | } 39 | 40 | CW_THREAD_RETURN_TYPE CWWTPReceiveStats(void *arg) 41 | { 42 | 43 | int sock, rlen, len, k, fragmentsNum = 0, fromlen; 44 | MM_MONITOR_DATA *pData; 45 | struct sockaddr_un servaddr; 46 | struct sockaddr_un from; 47 | static char buffer[PACKET_SIZE + 1]; 48 | CWProtocolMessage *completeMsgPtr = NULL; 49 | CWProtocolMessage *data = NULL; 50 | CWBindingTransportHeaderValues *bindingValuesPtr = NULL; 51 | 52 | CWThreadSetSignals(SIG_BLOCK, 1, SIGALRM); 53 | 54 | /* Create a UNIX datagram socket for this thread */ 55 | if ((sock = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) { 56 | CWDebugLog("THR STATS: Error creating socket"); 57 | CWExitThread(); 58 | } 59 | 60 | /* Set up address structure for server socket */ 61 | bzero(&servaddr, sizeof(servaddr)); 62 | bzero(&from, sizeof(from)); 63 | servaddr.sun_family = AF_UNIX; 64 | strcpy(servaddr.sun_path, SOCKET_PATH); 65 | 66 | unlink(SOCKET_PATH); 67 | 68 | len = sizeof(servaddr.sun_family) + strlen(servaddr.sun_path); 69 | 70 | if (bind(sock, (const struct sockaddr *)&servaddr, len) < 0) { 71 | CWDebugLog("THR STATS: Error binding socket"); 72 | CWExitThread(); 73 | } 74 | 75 | CW_CREATE_OBJECT_ERR(pData, MM_MONITOR_DATA, EXIT_THREAD); 76 | fromlen = sizeof(from); 77 | 78 | /* Receive data */ 79 | CW_REPEAT_FOREVER { 80 | rlen = recvfrom(sock, buffer, PACKET_SIZE, 0, (struct sockaddr *)&from, (socklen_t *) & fromlen); 81 | if (rlen == -1) { 82 | CWDebugLog("THR STATS: Error receiving from unix socket"); 83 | CWExitThread(); 84 | } else { 85 | completeMsgPtr = NULL; 86 | 87 | if (!create_data_Frame(&data, buffer, rlen)) { 88 | CWDebugLog("Error extracting a data stats frame"); 89 | CWExitThread(); 90 | }; 91 | 92 | pData = (MM_MONITOR_DATA *) data->msg; 93 | 94 | CW_CREATE_OBJECT_ERR(bindingValuesPtr, CWBindingTransportHeaderValues, EXIT_THREAD); 95 | bindingValuesPtr->dataRate = -1; //to distinguish between wireless frame e data message (Daniele) see CWBindig.c line 224 96 | 97 | if (CWAssembleDataMessage(&completeMsgPtr, &fragmentsNum, gWTPPathMTU, data, bindingValuesPtr, 98 | CW_PACKET_PLAIN, 0)) { 99 | for (k = 0; k < fragmentsNum; k++) { 100 | #ifdef CW_NO_DTLS 101 | if (!CWNetworkSendUnsafeConnected 102 | (gWTPSocket, completeMsgPtr[k].msg, completeMsgPtr[k].offset)) { 103 | #else 104 | if (!CWSecuritySend 105 | (gWTPSession, completeMsgPtr[k].msg, completeMsgPtr[k].offset)) { 106 | #endif 107 | CWDebugLog("Failure sending Request"); 108 | break; 109 | } 110 | } 111 | } 112 | 113 | for (k = 0; k < fragmentsNum; k++) { 114 | CW_FREE_PROTOCOL_MESSAGE(completeMsgPtr[k]); 115 | } 116 | 117 | CW_FREE_OBJECT(completeMsgPtr); 118 | CW_FREE_OBJECT(data); 119 | CW_FREE_OBJECT(bindingValuesPtr); 120 | } 121 | 122 | } 123 | 124 | close(sock); 125 | return (NULL); 126 | } 127 | -------------------------------------------------------------------------------- /WTPSulkingState.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #include "CWWTP.h" 29 | 30 | #ifdef DMALLOC 31 | #include "../dmalloc-5.5.0/dmalloc.h" 32 | #endif 33 | 34 | #ifdef CW_DEBUGGING 35 | int gCWSilentInterval = 5; 36 | #else 37 | int gCWSilentInterval = 30; 38 | #endif 39 | 40 | /* 41 | * WTP enters sulking when no AC is responding to Discovery Request. 42 | */ 43 | CWStateTransition CWWTPEnterSulking() 44 | { 45 | struct timeval timeout, before, after, delta, newTimeout; 46 | 47 | CWLog("\n"); 48 | CWLog("######### Sulking State #########"); 49 | /* 50 | * wait for Silent Interval and discard 51 | * all the packets that are coming 52 | */ 53 | timeout.tv_sec = newTimeout.tv_sec = gCWSilentInterval; 54 | timeout.tv_usec = newTimeout.tv_usec = 0; 55 | 56 | gettimeofday(&before, NULL); 57 | 58 | CW_REPEAT_FOREVER { 59 | 60 | /* check if something is available to read until newTimeout */ 61 | if (CWNetworkTimedPollRead(gWTPSocket, &newTimeout)) { 62 | /* 63 | * success 64 | * if there was no error, raise a "success error", so we can easily handle 65 | * all the cases in the switch 66 | */ 67 | CWErrorRaise(CW_ERROR_SUCCESS, NULL); 68 | } 69 | 70 | switch (CWErrorGetLastErrorCode()) { 71 | case CW_ERROR_TIME_EXPIRED: 72 | goto cw_sulk_time_over; 73 | break; 74 | case CW_ERROR_SUCCESS: 75 | /* there's something to read */ 76 | { 77 | CWNetworkLev4Address addr; 78 | unsigned char buf[CW_BUFFER_SIZE]; 79 | int readBytes; 80 | 81 | /* read and discard */ 82 | if (!CWErr 83 | (CWNetworkReceiveUnsafe(gWTPSocket, buf, CW_BUFFER_SIZE, 0, &addr, &readBytes))) { 84 | return CW_QUIT; 85 | } 86 | } 87 | case CW_ERROR_INTERRUPTED: 88 | /* 89 | * something to read OR interrupted by the 90 | * system 91 | * wait for the remaining time (NetworkPoll 92 | * will be recalled with the remaining time) 93 | */ 94 | gettimeofday(&after, NULL); 95 | 96 | CWTimevalSubtract(&delta, &after, &before); 97 | if (CWTimevalSubtract(&newTimeout, &timeout, &delta) == 1) { 98 | /* negative delta: time is over */ 99 | goto cw_sulk_time_over; 100 | } 101 | break; 102 | 103 | default: 104 | CWErrorHandleLast(); 105 | goto cw_error; 106 | break; 107 | } 108 | } 109 | cw_sulk_time_over: 110 | CWLog("End of Sulking Period"); 111 | cw_error: 112 | return CW_ENTER_DISCOVERY; 113 | } 114 | -------------------------------------------------------------------------------- /WTPipcHostapd.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Sotiraq Sima (Sotiraq.Sima@gmail.com) * 22 | * * 23 | *******************************************************************************************/ 24 | 25 | #ifndef __WTPipcHostapd_H 26 | #define __WTPipcHostapd_H 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "smac_code.h" 36 | 37 | #include "CWWTP.h" 38 | 39 | void CWWTPsend_data_to_hostapd(unsigned char *buf, int len); 40 | void CWWTPsend_command_to_hostapd_SET_TXQ(unsigned char *buf, int len); 41 | void CWWTPsend_command_to_hostapd_SET_ADDR(unsigned char *buf, int len); 42 | void CWWTPsend_command_to_hostapd_ADD_WLAN(unsigned char *buf, int len); 43 | void CWWTPsend_command_to_hostapd_DEL_WLAN(unsigned char *buf, int len); 44 | void CWWTPsend_command_to_hostapd_DEL_ADDR(unsigned char *buf, int len); 45 | void CWWTPsend_command_to_hostapd_CLOSE(unsigned char *buf, int len); 46 | void CWWTP_get_WTP_MDC(unsigned char *buf); 47 | void CWWTP_get_WTP_Rates(unsigned char *buf); 48 | unsigned char CWTP_get_WTP_Radio_Information(void); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /WTPmacDriverInteraction.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | /*prototipi da includere in CWWTP.h*/ 29 | #include "CWWTP.h" 30 | #include "WTPipcHostapd.h" 31 | 32 | int set_rts_threshold(int value); 33 | int get_rts_threshold(int *value); 34 | 35 | int set_frag_threshold(int value); 36 | int get_frag_threshold(int *value); 37 | 38 | /*--------------------------- RTS/CTS Threshold ---------------------------*/ 39 | int set_rts_threshold(int value) 40 | { 41 | 42 | printf("\nRTS/CTS threshold impostato a: %d\n", value); 43 | return 1; 44 | } 45 | 46 | int get_rts_threshold(int *value) 47 | { 48 | 49 | printf("\nRTS/CTS threshold: %d\n", *value); 50 | return 1; 51 | } 52 | 53 | /*--------------------------- Fragmentation Threshold ---------------------------*/ 54 | int set_frag_threshold(int value) 55 | { 56 | 57 | printf("\nFragmentation threshold impostato a: %d\n", value); 58 | return 1; 59 | } 60 | 61 | int get_frag_threshold(int *value) 62 | { 63 | 64 | printf("\nFragmentation threshold: %d\n", *value); 65 | return 1; 66 | } 67 | 68 | int set_txq(int code, int cwmin, int cwmax, int aifs, int burst_time) 69 | { 70 | char str[32]; 71 | sprintf(str, "X%d %d %d %d %d", code, cwmin, cwmax, aifs, burst_time); 72 | 73 | CWWTPsend_command_to_hostapd_SET_TXQ((unsigned char*)str, strlen(str)); 74 | return 1; 75 | } 76 | 77 | /*set CWMIN*/ 78 | int set_wme_cwmin(int class, int value) 79 | { 80 | 81 | printf("\nCWMIN impostato a: %d\n", value); 82 | return 1; 83 | } 84 | 85 | /*set CWMAX*/ 86 | int set_wme_cwmax(int class, int value) 87 | { 88 | 89 | printf("\nCWMAX impostato a: %d\n", value); 90 | return 1; 91 | } 92 | 93 | /*set AIFSN*/ 94 | int set_wme_aifsn(int class, int value) 95 | { 96 | 97 | printf("\nAIFSN impostato a: %d\n", value); 98 | return 1; 99 | } 100 | -------------------------------------------------------------------------------- /WTPmacFrameReceive.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __CAPWAP_WTPFrameReceive_HEADER__ 29 | #define __CAPWAP_WTPFrameReceive_HEADER__ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "CWWTP.h" 39 | 40 | #ifndef B_ENDIAN 41 | #define CHECK_PRISM_HEADER (buffer[0]==MESSAGE_CODE_1) && \ 42 | (buffer[1]==MESSAGE_CODE_2) && \ 43 | (buffer[2]==MESSAGE_CODE_3) && \ 44 | (buffer[3]==MESSAGE_CODE_4) 45 | #else 46 | #define CHECK_PRISM_HEADER (buffer[3]==MESSAGE_CODE_1) && \ 47 | (buffer[2]==MESSAGE_CODE_2) && \ 48 | (buffer[1]==MESSAGE_CODE_3) && \ 49 | (buffer[0]==MESSAGE_CODE_4) 50 | #endif 51 | 52 | //#define PROMODE_ON 53 | //#define FILTER_ON 54 | #define PRISMH_LEN 144 55 | #define RSSI_BYTE 68 56 | #define SIGNAL_BYTE 92 57 | #define NOISE_BYTE 104 58 | #define DATARATE_BYTE 116 59 | #define DEST_ADDR_START 4 60 | #define SOURCE_ADDR_START 10 61 | #define MESSAGE_CODE_1 68 62 | #define MESSAGE_CODE_2 0 63 | #define MESSAGE_CODE_3 0 64 | #define MESSAGE_CODE_4 0 65 | #define MAC_ADDR_LEN 6 66 | #define ATHEROS_CONV_VALUE 95 67 | 68 | #define ASSOCIATION_REQUEST_SUBTYPE 0 69 | #define ASSOCIATION_RESPONSE_SUBTYPE 1 70 | #define REASSOCIATION_REQUEST_SUBTYPE 2 71 | #define REASSOCIATION_RESPONSE_SUBTYPE 3 72 | #define PROBE_REQUEST_SUBTYPE 4 73 | #define PROBE_RESPONSE_SUBTYPE 5 74 | #define RESERVED6_SUBTYPE 6 75 | #define RESERVED7_SUBTYPE 7 76 | #define BEACON_SUBTYPE 8 77 | #define ATIM_SUBTYPE 9 78 | #define DISASSOCIATION_SUBTYPE 10 79 | #define AUTHENTICATION_SUBTYPE 11 80 | #define DEAUTHENTICATION_SUBTYPE 12 81 | 82 | #define RESERVED0_SUBTYPE 0 83 | #define RESERVED9_SUBTYPE 9 84 | #define POWER_SAVE_SUBTYPE 10 85 | #define RTS_SUBTYPE 11 86 | #define CTS_SUBTYPE 12 87 | #define ACKNOLEDGEMENT_SUBTYPE 13 88 | #define CF_END_SUBTYPE 14 89 | #define CF_END_CF_ACK_SUBTYPE 15 90 | 91 | #define DATA_SUBTYPE 0 92 | #define DATA_CF_ACK_SUBTYPE 1 93 | #define DATA_CF_POLL_SUBTYPE 2 94 | #define DATA_CF_ACK_CF_POLL_SUBTYPE 3 95 | #define NO_DATA_SUBTYPE 4 96 | #define CF_ACK_SUBTYPE 5 97 | #define CF_POLL_SUBTYPE 6 98 | #define CF_ACK_CF_POLL_SUBTYPE 7 99 | #define RESERVED8_SUBTYPE 8 100 | #define RESERVED15_SUBTYPE 15 101 | 102 | int extract802_11_Frame(CWProtocolMessage ** frame, unsigned char *buffer, int len); 103 | int CWWTPSendFrame(unsigned char *buf, int len); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /WUM.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WUM.h - WTP Update Messages 3 | * 4 | * 5 | * 4/11/2009 - Donato Capitella (d.capitella@gmail.com) 6 | */ 7 | 8 | #ifndef WUM_H 9 | #define WUM_H 10 | 11 | #include "CWCommon.h" 12 | 13 | #define WTP_VERSION_MAJOR 0 14 | #define WTP_VERSION_MINOR 93 15 | #define WTP_VERSION_REVISION 2 16 | 17 | #define WTP_VERSION_REQUEST 1 18 | #define WTP_VERSION_RESPONSE 2 19 | 20 | #define WTP_UPDATE_REQUEST 3 21 | #define WTP_UPDATE_RESPONSE 4 22 | 23 | #define WTP_CUP_FRAGMENT 5 24 | #define WTP_CUP_ACK 6 25 | 26 | #define WTP_COMMIT_UPDATE 7 27 | #define WTP_COMMIT_ACK 8 28 | 29 | #define WTP_CANCEL_UPDATE_REQUEST 9 30 | #define WTP_CANCEL_UPDATE_RESPONSE 10 31 | 32 | #define WTP_LOCK_FILE "wtp.lock" 33 | 34 | void WTPUpdateAgent(char *CupPath); 35 | 36 | #endif /* WUM_H */ 37 | -------------------------------------------------------------------------------- /capwap_bugfix_0.01: -------------------------------------------------------------------------------- 1 | 2 | ___ ____ 3 | / _ \ _ __ ___ _ __ / ___|__ _ _ ____ ____ _ _ __ 4 | | | | | '_ \ / _ \ '_ \| | / _` | '_ \ \ /\ / / _` | '_ \ 5 | | |_| | |_) | __/ | | | |__| (_| | |_) \ V V / (_| | |_) | 6 | \___/| .__/ \___|_| |_|\____\__,_| .__/ \_/\_/ \__,_| .__/ 7 | |_| |_|BUGFIX 0.01 |_| 8 | 9 | by mty (Matteo Latini, mtylty@gmail.com) 10 | 11 | 12 | 13 | This stuff """should""" now work the way is intended below...Please don't be harsh!!! :) 14 | 15 | ===> WTP re-enters Discovery State when session times out (WTPRunstate.c in CWWTPManageGenericRunMessage when using CWResetTimers) <=== 16 | 17 | ===> Fixed Segfault when using configuration tags missing preceding whitespace (ACConfigFile.c and WTPConfigFile.c) <=== 18 | 19 | ===> *** Neighbour Dead interval timeout is now down to 70 (previous value 200). DTLS doesn't complain anymore about wrong format certificates when 20 | Neighbour Dead interval timeout drops below 200. Please read the quick note to know more... *** <=== 21 | 22 | ===> WTP won't crash anymore when changing the status of the interface on which its socket is binded. Now it simply reenters discovery state with 23 | a reset <=== 24 | 25 | 26 | 27 | 28 | *** Quick Note: 29 | It should be possible (in my opinion) to lower the Neighbour Dead interval timeout even more... WARNING! Before doing so, another bugfix 30 | will be required. Infact, by running some tests, I found a bug (???) which I could not fix. Essentially, the problem lays in a concurrent 31 | thread-wait-for-condition function of both WTP and AC, after the Neighbour dead interval alarm has been started on both daemons. 32 | The condition (if I got it correctly) is just the daemon waiting for some frames on the interface. Since both daemons are waiting to hear 33 | from each other, they take some time to unlock... So, if the neighbour dead interval timeout is too low, they both (the AC and the WTP) get 34 | stuck in an endless loop (every time the timeout reaches zero the AC will think the WTP is dead so it will close the DTLS session while the 35 | WTP is still waiting to send Echo requests to the AC). 36 | The current setting (70) is the value I found working in all my tests. 37 | DISCLAIMER: Since all tests I made were carried out on my home LAN, maybe a value below 70 is even possible (or maybe my LAN did not work 38 | properly during the tests and this isn't a bug at all..) 39 | 40 | 41 | 42 | In case you were curious, this is the code (or at least this is where it got stuck (checked it with gdb)): 43 | 44 | AC Side (Function CWManageWTP inside ACMainLoop.c): 45 | 46 | /* Wait WTP action */ 47 | CWThreadMutexLock(&gWTPs[i].interfaceMutex); 48 | 49 | while ((gWTPs[i].isRequestClose == CW_FALSE) && 50 | (CWGetCountElementFromSafeList(gWTPs[i].packetReceiveList) == 0) && 51 | (gWTPs[i].interfaceCommand == NO_CMD)) { 52 | 53 | /*TODO: Check system */ 54 | CWWaitThreadCondition(&gWTPs[i].interfaceWait, 55 | &gWTPs[i].interfaceMutex); 56 | } 57 | 58 | CWThreadMutexUnlock(&gWTPs[i].interfaceMutex); 59 | 60 | 61 | 62 | 63 | WTP Side (Function CWManageWTP inside ACMainLoop.c): 64 | 65 | /* 66 | * if there are no frames from stations 67 | * and no packets from AC... 68 | */ 69 | if ((CWGetCountElementFromSafeList(gPacketReceiveList) == 0) && (CWGetCountElementFromSafeList(gFrameList) == 0)) { 70 | /* 71 | * ...wait at most 4 mins for a frame or packet. 72 | */ 73 | if (!CWErr(CWWaitThreadConditionTimeout(&gInterfaceWait, &gInterfaceMutex, &timenow))) { 74 | 75 | CWThreadMutexUnlock(&gInterfaceMutex); 76 | 77 | if (CWErrorGetLastErrorCode() == CW_ERROR_TIME_EXPIRED) { 78 | 79 | CWLog("No Message from AC for a long time... restart Discovery State"); 80 | break; 81 | } 82 | continue; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /changeLog-0.92: -------------------------------------------------------------------------------- 1 | OpenCapWap 0.92 - 27/10/2009 2 | Donato Capitella - d.capitella@gmail.com 3 | 4 | This version corrects 18 bugs mainly related to resource leakages in the WTP. 5 | Here follows a brief report: 6 | 7 | Note: TRL(Thread Resource Leakage) 8 | ML (Memory Leak) 9 | LE (Logic Error) 10 | UMR (Uninitialized Memory Rea) 11 | 12 | (Descriptions about each bug can be found in the source code) 13 | 14 | TRL01 - ACInterface.c 15 | LE01 - ACInterface.c 16 | ML01 - WTPRunState.c 17 | TRL02 - timerlib.c 18 | ML02 - WTPConfigureState.c 19 | ML03 - WTPJoinState.c 20 | ML04 - WTPConfigureState.c 21 | ML05 - WTPConfigureState.c 22 | ML06 - WTPProtocol.c 23 | LE02 - CWConfigFile.c 24 | ML07 - WTPJoinState.c 25 | ML08 - WTPJoinState.c 26 | ML09 - WTPProtocol.c 27 | UMR02 - WTPFrameReceive.c 28 | LE03 - CWStevens.c 29 | ML11 - ACDiscoveryState.c 30 | ML12 - ACRetransmission.c 31 | UMR03 - ACMainLoop.c 32 | 33 | -------------------------------------------------------------------------------- /changeLog-0.93: -------------------------------------------------------------------------------- 1 | OpenCapWap 0.93.3 - 02/12/2009 2 | Donato Capitella - d.capitella@gmail.com 3 | 4 | This version adds a vendor specific WTP Update System together with 5 | some minor bugfixes. 6 | 7 | *----------------------------* 8 | | WTP Update System | 9 | *----------------------------* 10 | The update system consists of a tool used AC-side to send 11 | updates (wum) and an update agent (WUA) executed WTP-side which 12 | takes care of installing an update package. 13 | 14 | *** WUA *** 15 | The WUA can be compiled like this: 16 | 17 | $ make WUA 18 | 19 | Once compiled, it has to be reside in the same directory as the WTP binary. 20 | 21 | *** wum *** 22 | The wum commmad source code is located in the /wum sub-directory. To 23 | compile it, just cd into /wum and then execute 'make'. This command 24 | can be installed anywhere on the AC machine and it relies on the 25 | AC Interface to operate. 26 | 27 | For further information about the update system and how update packages 28 | are biult, refer to the document WTPUpdateSystem.pdf in the /docs sub-directory 29 | in this source tree. 30 | 31 | *---------------------------* 32 | Note about log location 33 | *---------------------------* 34 | From this version on, WTP and AC logs are stored in /var/log/. 35 | This behaviour can be changed editing the header files CWAC.h and 36 | CWWTP.h before building Open CAPWAP. 37 | 38 | -------------------------------------------------------------------------------- /changeLog-0.93.3: -------------------------------------------------------------------------------- 1 | OpenCAPWAP 0.93.3 - 03/02/2010 2 | Elena Agostini & Donato Capitella 3 | 4 | A bug in timerlib.c was identified and corrected. This bug caused a pointer to be freed multiple times. 5 | Files changed: 6 | timerlib.c - LE-03-02-2010.01 7 | CWThread.c - LE-03-02-2010.01 8 | CWThread.c - LE-03-02-2010.02 9 | 10 | -------------------------------------------------------------------------------- /client.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQDNo9iIeIifo0astEKSDLU/TsIVckZ4/K/b/8KrZ6cE6Lx7wROE 3 | u/QWjEXYe6nPRX80TeQ4zEe989QMLkD9p28binly7c8SyGNMlTGKLDksNndVMa1r 4 | bXS+XxeqJ6I1VDe7c42jb9E4wzgpCkHlitG+r/va9rx+GqHVZFs05YctVQIDAQAB 5 | AoGAVa7ea0alzrZunUlir44h+yXq0prR6FmJQQaZa2f9/Jqo5nu1kUnrU3XRKHmm 6 | cJnJfdaysEPV5Lzy7rxbEhWwwi6vq5gvPWkRgJ5VLFQv3/l65+ZLgq3E9a9pv6uz 7 | AG77YDzHuTKpc5o0Nc1G+vvdsklAM3RwA0TRXmcDMj9EZYUCQQDsXKkdfuoZGzj+ 8 | a6nlV7SaiANuG9WSTBoFAbJtKDBOm8HucvjmnrCD8NRRz8zMJZ86E6vdPyotOAy1 9 | 92DgSD8HAkEA3rm9cxml08Ar9xes1WCIbKFaskJBXfOAOhqgUBMjbMDo4MgS2L8f 10 | +TszJPsUfXRLRRjEdEpSZDl7gOqIk5G9wwJAR6MB4p2vp/JXQM0yzf7aDygAGiQ3 11 | g8Kq9C+Ce5D9qyWMDpAsHgGksCiSwUUA5jLU4o5JvaHCT7g4KgKTCwb6iwJBAMSs 12 | QXV07XC5nlkYB9932aALL3p/dRdQYSdtwahT7hEnm7x6D+Jjiwla1EPQjvxlB95h 13 | C4Eg6/ZiqANjluywYl8CQFn3HbACM4//Yy0Z50gvokERAYW9W/94J+4W3siB4lmC 14 | FBa29h7GVu0Zt1G9OQBfi0dmp2UN3NjfZaCrhXAShTQ= 15 | -----END RSA PRIVATE KEY----- 16 | Certificate: 17 | Data: 18 | Version: 3 (0x2) 19 | Serial Number: 2 (0x2) 20 | Signature Algorithm: md5WithRSAEncryption 21 | Issuer: CN=Local CAPWAP Root Certificate Authority, ST=Some State, C=IT/emailAddress=root@somename.somewhere.com, O=Root Certificate Authority, OU=My Subunit of Large Organization 22 | Validity 23 | Not Before: Oct 5 09:58:10 2006 GMT 24 | Not After : Oct 4 09:58:10 2011 GMT 25 | Subject: CN=somename.somewhere.com, ST=Some State, C=IT/emailAddress=root@somename.somewhere.com, O=My Large Organization Name, OU=My Subunit of Large Organization 26 | Subject Public Key Info: 27 | Public Key Algorithm: rsaEncryption 28 | RSA Public Key: (1024 bit) 29 | Modulus (1024 bit): 30 | 00:cd:a3:d8:88:78:88:9f:a3:46:ac:b4:42:92:0c: 31 | b5:3f:4e:c2:15:72:46:78:fc:af:db:ff:c2:ab:67: 32 | a7:04:e8:bc:7b:c1:13:84:bb:f4:16:8c:45:d8:7b: 33 | a9:cf:45:7f:34:4d:e4:38:cc:47:bd:f3:d4:0c:2e: 34 | 40:fd:a7:6f:1b:8a:79:72:ed:cf:12:c8:63:4c:95: 35 | 31:8a:2c:39:2c:36:77:55:31:ad:6b:6d:74:be:5f: 36 | 17:aa:27:a2:35:54:37:bb:73:8d:a3:6f:d1:38:c3: 37 | 38:29:0a:41:e5:8a:d1:be:af:fb:da:f6:bc:7e:1a: 38 | a1:d5:64:5b:34:e5:87:2d:55 39 | Exponent: 65537 (0x10001) 40 | X509v3 extensions: 41 | X509v3 Extended Key Usage: 42 | 1.3.6.1.5.5.7.3.19 43 | Netscape Cert Type: 44 | SSL Client 45 | X509v3 Subject Alternative Name: 46 | DNS:altname.somewhere.com 47 | X509v3 Basic Constraints: 48 | CA:FALSE 49 | Signature Algorithm: md5WithRSAEncryption 50 | 91:b8:93:f1:01:49:44:55:7d:09:f1:d8:69:7e:5f:bf:a5:7a: 51 | a0:f5:32:5f:8a:df:47:0d:87:b8:da:76:49:17:24:6b:e0:fd: 52 | 67:b4:43:8c:1d:c6:68:d3:82:7f:0c:b5:48:80:af:3a:58:fd: 53 | 73:99:dc:f5:b8:17:af:99:6d:ce:0e:19:e9:a5:74:03:90:c9: 54 | 02:e4:72:b2:56:07:43:67:61:8b:33:da:5a:b5:39:dc:c9:eb: 55 | f2:5f:10:35:c5:14:18:ac:3f:f5:70:a6:63:c6:d4:0c:d4:f7: 56 | 4d:6f:ea:2d:0d:6f:4a:65:27:af:ff:b7:9f:fa:d0:83:8d:a2: 57 | df:a3 58 | -----BEGIN CERTIFICATE----- 59 | MIIDXjCCAsegAwIBAgIBAjANBgkqhkiG9w0BAQQFADCB0DEwMC4GA1UEAxMnTG9j 60 | YWwgQ0FQV0FQIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MRMwEQYDVQQIEwpT 61 | b21lIFN0YXRlMQswCQYDVQQGEwJJVDEqMCgGCSqGSIb3DQEJARYbcm9vdEBzb21l 62 | bmFtZS5zb21ld2hlcmUuY29tMSMwIQYDVQQKExpSb290IENlcnRpZmljYXRlIEF1 63 | dGhvcml0eTEpMCcGA1UECxMgTXkgU3VidW5pdCBvZiBMYXJnZSBPcmdhbml6YXRp 64 | b24wHhcNMDYxMDA1MDk1ODEwWhcNMTExMDA0MDk1ODEwWjCBvzEfMB0GA1UEAxMW 65 | c29tZW5hbWUuc29tZXdoZXJlLmNvbTETMBEGA1UECBMKU29tZSBTdGF0ZTELMAkG 66 | A1UEBhMCSVQxKjAoBgkqhkiG9w0BCQEWG3Jvb3RAc29tZW5hbWUuc29tZXdoZXJl 67 | LmNvbTEjMCEGA1UEChMaTXkgTGFyZ2UgT3JnYW5pemF0aW9uIE5hbWUxKTAnBgNV 68 | BAsTIE15IFN1YnVuaXQgb2YgTGFyZ2UgT3JnYW5pemF0aW9uMIGfMA0GCSqGSIb3 69 | DQEBAQUAA4GNADCBiQKBgQDNo9iIeIifo0astEKSDLU/TsIVckZ4/K/b/8KrZ6cE 70 | 6Lx7wROEu/QWjEXYe6nPRX80TeQ4zEe989QMLkD9p28binly7c8SyGNMlTGKLDks 71 | NndVMa1rbXS+XxeqJ6I1VDe7c42jb9E4wzgpCkHlitG+r/va9rx+GqHVZFs05Yct 72 | VQIDAQABo1cwVTATBgNVHSUEDDAKBggrBgEFBQcDEzARBglghkgBhvhCAQEEBAMC 73 | B4AwIAYDVR0RBBkwF4IVYWx0bmFtZS5zb21ld2hlcmUuY29tMAkGA1UdEwQCMAAw 74 | DQYJKoZIhvcNAQEEBQADgYEAkbiT8QFJRFV9CfHYaX5fv6V6oPUyX4rfRw2HuNp2 75 | SRcka+D9Z7RDjB3GaNOCfwy1SICvOlj9c5nc9bgXr5ltzg4Z6aV0A5DJAuRyslYH 76 | Q2dhizPaWrU53Mnr8l8QNcUUGKw/9XCmY8bUDNT3TW/qLQ1vSmUnr/+3n/rQg42i 77 | 36M= 78 | -----END CERTIFICATE----- 79 | -------------------------------------------------------------------------------- /config.ac: -------------------------------------------------------------------------------- 1 | # Config File for AC. Lines beginning with # and blank lines will be ignored 2 | 3 | # HW version of the AC 4 | 1235656 5 | 6 | # SW version of the AC 7 | 3256984 8 | 9 | # Max number of mobile stations supported 10 | 200 11 | 12 | # Max number of WTP supported 13 | 15 14 | 15 | # Authentication mode for AC. Can be X509_CERTIFICATE or PRESHARED (for 16 | # preshared keys) 17 | # X509_CERTIFICATE 18 | PRESHARED 19 | 20 | # Can be IPv4 or IPv6. Of course the host must have IPv6 enabled to work with the 21 | # setting IPv6 22 | IPv4 23 | 24 | # Force MTU to 50 bytes, used to debug fragmentation ;-) If you don't need this, simply 25 | # comment the line by adding a #. 26 | 1420 27 | 28 | My AC 29 | 30 | # The AC will join the Multicast Groups you add here 31 | 32 | #239.255.1.2 33 | #239.255.1.3 34 | 35 | 36 | 1 37 | 38 | 30000000 39 | -------------------------------------------------------------------------------- /config.wtp: -------------------------------------------------------------------------------- 1 | 2 | # Config File for WTP. Lines beginning with # and blank lines will be ignored 3 | 4 | # List of ACs' addresses for Discovery. They can be host names (e.g. "localhost", 5 | # IPv4 addresses if we are an IPv4 host or IPv6 addresses if we are an 6 | # IPv6Host. Wecan also add limited broadcast address (255.255.255.255) or 7 | # multicast addresses 8 | 9 | #255.255.255.255 10 | #localhost 11 | #192.168.1.2 12 | #192.168.1.8 13 | #239.255.1.3 14 | 172.16.151.1 15 | #127.0.0.1 16 | #10.10.3.252 17 | #1.1.1.2 18 | #172.16.1.104 19 | #localhost 20 | 21 | 22 | My WTP 1 23 | Next to Fridge 24 | 25 | # Can be IPv4 or IPv6. Of course the host must have IPv6 enabled to work with the 26 | # setting IPv6 27 | IPv4 28 | 29 | # Force MTU to 50 bytes, used to debug fragmentation ;-) If you don't need this, simply 30 | # comment the line by adding a #. 31 | 1420 32 | 33 | # If you uncomment the following line, the WTP will jump to Join State 34 | # (without doing Discovery) and the address will be considered the AC's address. 35 | # 192.168.1.2 36 | 37 | # Usually the WTP knows if the AC supports Certificate or Preshared-keys authentication 38 | # from the Discovery Response. If we jump to the Join State using , 39 | # however, we must know how to behave. This setting can be X509_CERTIFICATE (default if you 40 | # leave the line commented) or PRESHARED. This setting is ignored if you don't use 41 | # . 42 | # PRESHARED 43 | X509_CERTIFICATE 44 | 45 | 1 46 | 47 | 8388608 48 | 49 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([opencapwap], [1.0], [info@travelping.com]) 2 | AM_INIT_AUTOMAKE([1.9 foreign silent-rules]) 3 | AC_CONFIG_MACRO_DIR([m4]) 4 | AC_USE_SYSTEM_EXTENSIONS 5 | 6 | LT_INIT 7 | 8 | AM_CONFIG_HEADER(config.h) 9 | AC_PREFIX_DEFAULT(/usr) 10 | 11 | AC_CANONICAL_HOST 12 | AC_USE_SYSTEM_EXTENSIONS 13 | 14 | AM_SILENT_RULES([yes]) 15 | 16 | AC_PROG_LIBTOOL 17 | 18 | AC_PROG_CC 19 | AC_PROG_CC_C99 20 | AM_PROG_CC_C_O 21 | 22 | AC_PROG_INSTALL 23 | AC_SET_MAKE 24 | 25 | AC_CHECK_HEADER([pthread.h], [], [AC_MSG_ERROR(You need the pthread headers)]) 26 | AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR(You need the pthread library)]) 27 | 28 | AC_CHECK_FUNC([sem_timedwait], [AC_DEFINE([HAVE_SEM_TIMEDWAIT], [1], 29 | [Define if sem_timedwait exists.])]) 30 | 31 | AC_ARG_ENABLE([debug], 32 | AS_HELP_STRING([--enable-debug], [enable debug]), 33 | [CFLAGS="$CFLAGS -DCW_DEBUGGING"], []) 34 | 35 | AC_ARG_ENABLE([dtls], 36 | AS_HELP_STRING([--disable-dtls], [disable DTLS support])) 37 | 38 | AM_CONDITIONAL([USE_SSL], [test "x$enable_dtls" != "xno"]) 39 | AS_IF([test "x$enable_dtls" != "xno"], [ 40 | AX_CHECK_OPENSSL([], [AC_MSG_ERROR(OpenSSL not found!)]) 41 | ], [ 42 | CFLAGS="$CFLAGS -DCW_NO_DTLS -DCW_NO_DTLSCWParseConfigurationUpdateRequest" 43 | ]) 44 | AC_CONFIG_FILES([Makefile]) 45 | AC_OUTPUT -------------------------------------------------------------------------------- /debian-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | autoreconf -fi 3 | CFLAGS="-Os -pipe -fno-caller-saves -DCW_NO_DTLS -DWRITE_STD_OUTPUT -DCW_DEBUGGING -DNETUDP -DAC -fgnu89-inline" ./configure 4 | make 5 | cp AC /usr/sbin/AC 6 | mkdir /etc/capwap 7 | cp -f config.ac /etc/capwap 8 | cp -f settings.ac.txt /etc/capwap 9 | cd hostapd_wrapper/hostapd2 10 | ./linux-ac.sh 11 | -------------------------------------------------------------------------------- /docs/OpenCapwap.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/docs/OpenCapwap.pdf -------------------------------------------------------------------------------- /docs/WTPUpdateSystem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/docs/WTPUpdateSystem.pdf -------------------------------------------------------------------------------- /hostapd_wrapper/README.rst: -------------------------------------------------------------------------------- 1 | =================== 2 | WRAPPER FOR HOSTAPD 3 | =================== 4 | 5 | Requirements 6 | ------------ 7 | 8 | * patch 9 | * hostapd-1.1 10 | 11 | Install 12 | ------- 13 | 14 | * copy content of src to hostapd-1.1/src 15 | * apply hostapd-capwap.patch 16 | 17 | Sample 18 | ------ 19 | 20 | cp hostapd-1.1 21 | cp -a ../opencapwap.git/hostapd_wrapper/src . 22 | patch -p1 < ../opencapwap.git/hostapd_wrapper/hostapd-capwap.patch 23 | 24 | Build 25 | ----- 26 | 27 | You can either the build the AC wrapper or the WTP wrapper, but not both 28 | at the same time! 29 | 30 | Check hostapd's build instructions on how to configure and build it. 31 | 32 | Adjust hostapd-1.1/hostapd/.config and enable either CONFIG_DRIVER_CAPWAP_WTP or 33 | CONFIG_DRIVER_CAPWAP 34 | 35 | Running WTP 36 | ----------- 37 | 38 | * copy hostapd_wtp.conf to /etc/hostapd 39 | * copy hostapd.conf-wtp to /etc/hostapd/hostapd.conf 40 | * adjust above files for your setup 41 | * create an AP interface, e.g.: /usr/sbin/iw phy phy0 interface add wlan0 type managed 42 | * start WTP deamon *first* 43 | * start hostapd 44 | 45 | Running AP 46 | ----------- 47 | 48 | * copy hostapd_ap.conf to /etc/hostapd 49 | * copy hostapd.conf-ap to /etc/hostapd/hostapd.conf 50 | * adjust above files for your setup 51 | * start AP deamon *first* 52 | * start hostapd 53 | 54 | Known Problems 55 | -------------- 56 | 57 | The communication protocol between WTP/AC and hostapd is not stable. It does 58 | not detect communication failures and therefor has no reconnect behavior. 59 | A WTP/AC restart always requires a hostapd restart as well. It also does not 60 | handle delayed connects (i.e. hostapd started before WTP/AC is ready). Therefore 61 | make sure the WTP/AC deamons are always started before hostapd. 62 | 63 | The WTP does not handle AC connection lost and AC restart. The WTP needs to be 64 | restarted to recover from such a situation. 65 | 66 | -------------------------------------------------------------------------------- /hostapd_wrapper/hostapd2/README.Debian: -------------------------------------------------------------------------------- 1 | 2 | Installation steps: 3 | 4 | 1. Flash a firmware with the hostapd-capwap package on a OpenWRT compatible router. 5 | 2. Setup a Debian box where you want to run AC. 6 | 3. On the Debian box : 7 | - Run ./debian-install.sh 8 | - Edit /etc/hostapd.conf 9 | - Run AC; hostapd /etc/hostapd.conf 10 | 4. On the OpenWRT router : 11 | - Run killall -9 hostapd 12 | - Copy /tmp/run/hostapd-phy0.conf to /etc/capwap/hostapd.conf 13 | - Edit the driver in /etc/capwap/hostapd.conf line and set it to capwap_wtp 14 | - Run cd /etc/capwap; WTP; hostapd hostapd.conf 15 | 9. Enjoy the RX_MGMT events flowing trough the radiotap tunnel. 16 | 17 | 18 | Notes: 19 | 20 | - Always run AC first and WTP after. 21 | - When hostapd on AC is closed also the hostapd on WTP is closed. 22 | - When you want to restart allways kill hostapd, AC and WTP processes. 23 | -------------------------------------------------------------------------------- /hostapd_wrapper/hostapd2/hostapd-20130302.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/hostapd_wrapper/hostapd2/hostapd-20130302.tar.bz2 -------------------------------------------------------------------------------- /hostapd_wrapper/hostapd2/hostapd_linux_ac.conf: -------------------------------------------------------------------------------- 1 | ip_daemon_ac=127.0.0.1 2 | sock_path_ac=/tmp/ac_ipc_hostapd 3 | port_daemon_ac=5543 4 | -------------------------------------------------------------------------------- /hostapd_wrapper/hostapd2/linux-ac.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | cp -f hostapd_linux.conf /etc/hostapd.conf 3 | cp -f hostapd_linux_ac.conf /etc/hostapd_ac.conf 4 | apt-get -y purge libnl1 libnl2 hostapd 5 | apt-get -y autoremove 6 | rm -rf /tmp/hostapd-linux/ 7 | mkdir -p /tmp/hostapd-linux 8 | cp -f *.tar.* *.patch /tmp/hostapd-linux 9 | cd /tmp/hostapd-linux 10 | tar zxvf nl-tiny.tar.gz 11 | mv src nl-tiny 12 | cd nl-tiny/ 13 | rm -rf *.o 14 | make 15 | cp libnl-tiny.so /usr/lib 16 | cp -rf include/* /usr/include/ 17 | ldconfig -v | grep tiny 18 | cd .. 19 | rm -rf nl-tiny 20 | tar jxvf hostapd-20130302.tar.bz2 21 | cd hostapd-20130302 22 | patch -p1 < ../hostapd-20130302-linux.patch 23 | cd hostapd 24 | CFLAGS="-DCONFIG_LIBNL20 -D_GNU_SOURCE -DCONFIG_MSG_MIN_PRIORITY=3 -Os -pipe -fno-caller-saves -ffunction-sections -fdata-sections -DNETUDP" make CONFIG_DRIVER_NL80211=y CONFIG_DRIVER_MADWIFI= CONFIG_DRIVER_HOSTAP= CONFIG_IEEE80211N=y CONFIG_IEEE80211W=y CONFIG_DRIVER_WEXT= LIBS="-lm -lnl-tiny" BCHECK= hostapd hostapd_cli 25 | cp -f hostapd /usr/sbin/hostapd 26 | apt-get -y install iw 27 | cd ~ 28 | rm -rf /tmp/hostapd-linux 29 | -------------------------------------------------------------------------------- /hostapd_wrapper/hostapd2/nl-tiny.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/hostapd_wrapper/hostapd2/nl-tiny.tar.gz -------------------------------------------------------------------------------- /hostapd_wrapper/hostapd_ac.conf: -------------------------------------------------------------------------------- 1 | ip_daemon_ac=127.0.0.1 2 | sock_path_ac=/tmp/ac_ipc_hostapd 3 | port_daemon_ac=5543 4 | -------------------------------------------------------------------------------- /hostapd_wrapper/hostapd_wtp.conf: -------------------------------------------------------------------------------- 1 | ip_daemon_wtp=127.0.0.1 2 | port_daemon_wtp=6333 3 | sock_pach_wtp=/tmp/wtp_ipc_hostapd 4 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/capwap_mgmt_frame_ac.c: -------------------------------------------------------------------------------- 1 | #include "utils/includes.h" 2 | 3 | #include "utils/common.h" 4 | #include "radius/radius.h" 5 | #include "drivers/driver.h" 6 | #include "common/ieee802_11_defs.h" 7 | #include "common/ieee802_11_common.h" 8 | #include "common/wpa_ctrl.h" 9 | #include "crypto/random.h" 10 | 11 | 12 | #define MAC_LENGTH 6 13 | #define HLEN_80211 24 14 | #define HLEN_LLC 8 15 | 16 | int same_mac( unsigned char *mac1, unsigned char *mac2){// return 0 17 | int i; 18 | for(i=0;iaddr2, MAC_LENGTH); 26 | return HLEN_80211 + HLEN_LLC; 27 | } 28 | 29 | int isEAPOL_Frame( unsigned char *buf, int len){ 30 | unsigned char rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; 31 | int i; 32 | 33 | for(i=0; i<6; i++)if(rfc1042_header[i]!=buf[i + HLEN_80211])return 0; 34 | return 1; 35 | } 36 | 37 | void stampa_mac(char *s, unsigned char *mac){ 38 | int i; 39 | wpa_printf(MSG_DEBUG,"%s",s); 40 | for(i=0; i<6; i++)wpa_printf(MSG_DEBUG,"%02X ",mac[i]); 41 | wpa_printf(MSG_DEBUG,"\n"); 42 | } 43 | 44 | void stamp_all_max( unsigned char *buf, unsigned char *own_mac){ 45 | struct ieee80211_hdr *hdr; 46 | 47 | hdr = (struct ieee80211_hdr *) buf; 48 | 49 | stampa_mac("addr1 ",hdr->addr1); 50 | stampa_mac("addr2 ",hdr->addr2); 51 | stampa_mac("addr3 ",hdr->addr3); 52 | stampa_mac("own_mac ", own_mac); 53 | } 54 | 55 | int isCallBackFrame( unsigned char *buf, int len, unsigned char *own_mac){ 56 | // return 1 if is it CALL Back Frame 57 | // return 0 if is NOT CALL Back Frame 58 | struct ieee80211_hdr *hdr; 59 | /* 60 | u16 fc; 61 | */ 62 | 63 | hdr = (struct ieee80211_hdr *) buf; 64 | /* capwap FIXME: needed? 65 | fc = le_to_host16(hdr->frame_control); 66 | */ 67 | 68 | if( same_mac(hdr->addr2,own_mac)==0 && same_mac(hdr->addr3,own_mac)==0 )return 1; 69 | return 0; 70 | } 71 | 72 | int AC_get_SubType( unsigned char *buf, int len){ 73 | struct ieee80211_hdr *hdr; 74 | u16 fc; 75 | 76 | hdr = (struct ieee80211_hdr *) buf; 77 | fc = le_to_host16(hdr->frame_control); 78 | 79 | return WLAN_FC_GET_STYPE(fc); 80 | } 81 | 82 | int AC_get_Type( unsigned char *buf, int len){ 83 | struct ieee80211_hdr *hdr; 84 | u16 fc; 85 | 86 | hdr = (struct ieee80211_hdr *) buf; 87 | fc = le_to_host16(hdr->frame_control); 88 | 89 | return WLAN_FC_GET_TYPE(fc); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/capwap_mgmt_frame_ac.h: -------------------------------------------------------------------------------- 1 | #ifndef __CAPWAP_MGMT_FRAME_AC_H 2 | #define __CAPWAP_MGMT_FRAME_AC_H 3 | 4 | #include "drivers/driver.h" 5 | 6 | int GetEapol_Frame( unsigned char *sa, unsigned char *buf, int len); 7 | 8 | int isEAPOL_Frame( unsigned char *buf, int len); 9 | 10 | int isCallBackFrame( unsigned char *buf, int len, unsigned char *own_mac); 11 | 12 | int AC_get_SubType( unsigned char *buf, int len); 13 | 14 | int AC_get_Type( unsigned char *buf, int len); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/capwap_mgmt_frame_wtp.c: -------------------------------------------------------------------------------- 1 | #include "utils/includes.h" 2 | 3 | #include "utils/common.h" 4 | #include "radius/radius.h" 5 | #include "drivers/driver.h" 6 | #include "common/ieee802_11_defs.h" 7 | #include "common/ieee802_11_common.h" 8 | #include "common/wpa_ctrl.h" 9 | #include "crypto/random.h" 10 | #include "p2p/p2p.h" 11 | #include "wps/wps.h" 12 | #include "ap/hostapd.h" 13 | #include "ap/ieee802_11.h" 14 | #include "ap/sta_info.h" 15 | #include "ap/accounting.h" 16 | #include "ap/tkip_countermeasures.h" 17 | #include "ap/iapp.h" 18 | #include "ap/ieee802_1x.h" 19 | #include "ap/wpa_auth.h" 20 | #include "ap/wmm.h" 21 | #include "ap/wps_hostapd.h" 22 | #include "ap/ap_drv_ops.h" 23 | #include "ap/ap_config.h" 24 | 25 | #define HAPD_BROADCAST ((struct hostapd_data *) -1) 26 | #define HLEN_80211 24 27 | 28 | void WTP_handle_assoc_cb(struct hostapd_data *hapd,const struct ieee80211_mgmt *mgmt,size_t len, int reassoc, int ok){ 29 | wpa_printf(MSG_DEBUG,"WTP: WTP_handle_assoc_cb\n"); 30 | u16 status; 31 | struct sta_info *sta; 32 | int new_assoc = 1; 33 | 34 | if (!ok) { 35 | hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211, 36 | HOSTAPD_LEVEL_DEBUG, 37 | "did not acknowledge association response"); 38 | return; 39 | } 40 | 41 | if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) : 42 | sizeof(mgmt->u.assoc_resp))) { 43 | printf("handle_assoc_cb(reassoc=%d) - too short payload " 44 | "(len=%lu)\n", reassoc, (unsigned long) len); 45 | return; 46 | } 47 | 48 | if (reassoc) 49 | status = le_to_host16(mgmt->u.reassoc_resp.status_code); 50 | else 51 | status = le_to_host16(mgmt->u.assoc_resp.status_code); 52 | 53 | ap_sta_add(hapd, mgmt->da); 54 | sta = ap_get_sta(hapd, mgmt->da); 55 | 56 | static unsigned char sup[4]={ 0x82 ,0x84 ,0x8B ,0x96 }; 57 | 58 | hostapd_sta_add(hapd, sta->addr, ( unsigned short)1, ( unsigned short)33, sup, 4, 59 | (u16)1, 60 | NULL, 61 | (u32)32931); 62 | return ; 63 | 64 | } 65 | 66 | struct hostapd_data * WTP_get_hapd_bssid(struct hostapd_iface *iface,const unsigned char *bssid){ 67 | size_t i; 68 | if (bssid == NULL) 69 | return NULL; 70 | if (bssid[0] == 0xff && bssid[1] == 0xff && bssid[2] == 0xff && 71 | bssid[3] == 0xff && bssid[4] == 0xff && bssid[5] == 0xff) 72 | return HAPD_BROADCAST; 73 | 74 | for (i = 0; i < iface->num_bss; i++) { 75 | if (os_memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0) 76 | return iface->bss[i]; 77 | } 78 | return NULL; 79 | } 80 | 81 | void WTP_handle_tx_callback_ASS_RES(void *ctx, unsigned char *buf, size_t len, int ok){ 82 | return; 83 | struct ieee80211_hdr *hdr; 84 | const struct ieee80211_mgmt *mgmt; 85 | 86 | u16 fc; 87 | union wpa_event_data event; 88 | struct hostapd_data *hapd=ctx; 89 | 90 | hdr = (struct ieee80211_hdr *) buf; 91 | mgmt = (const struct ieee80211_mgmt *) buf; 92 | fc = le_to_host16(hdr->frame_control); 93 | 94 | os_memset(&event, 0, sizeof(event)); 95 | event.tx_status.type = WLAN_FC_GET_TYPE(fc); 96 | event.tx_status.stype = WLAN_FC_GET_STYPE(fc); 97 | event.tx_status.dst = hdr->addr1; 98 | event.tx_status.data = buf; 99 | event.tx_status.data_len = len; 100 | event.tx_status.ack = ok; 101 | 102 | //hapd = WTP_get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len)); 103 | //if (hapd == NULL || hapd == HAPD_BROADCAST) 104 | // return; 105 | 106 | if(event.tx_status.stype==WLAN_FC_STYPE_ASSOC_RESP) 107 | WTP_handle_assoc_cb(hapd, mgmt, len, 0, ok); 108 | else 109 | WTP_handle_assoc_cb(hapd, mgmt, len, 1, ok); 110 | 111 | } 112 | 113 | int isEAPOL_Frame( unsigned char *buf, int len){ 114 | unsigned char rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; 115 | int i; 116 | 117 | for(i=0; i<6; i++)if(rfc1042_header[i]!=buf[i + HLEN_80211])return 0; 118 | return 1; 119 | } 120 | 121 | int WTP_get_SubType( unsigned char *buf,int len){ 122 | struct ieee80211_hdr *hdr; 123 | u16 fc; 124 | 125 | hdr = (struct ieee80211_hdr *) buf; 126 | fc = le_to_host16(hdr->frame_control); 127 | 128 | return WLAN_FC_GET_STYPE(fc); 129 | } 130 | 131 | int WTP_get_Type( unsigned char*buf,int len){ 132 | struct ieee80211_hdr *hdr; 133 | u16 fc; 134 | 135 | hdr = (struct ieee80211_hdr *) buf; 136 | fc = le_to_host16(hdr->frame_control); 137 | 138 | return WLAN_FC_GET_TYPE(fc); 139 | } 140 | 141 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/capwap_mgmt_frame_wtp.h: -------------------------------------------------------------------------------- 1 | #ifndef __CAPWAP_MGMT_FRAME_WTP_H 2 | #define __CAPWAP_MGMT_FRAME_WTP_H 3 | 4 | #include "drivers/driver.h" 5 | #include "ap/hostapd.h" 6 | 7 | void WTP_handle_assoc_cb(struct hostapd_data *hapd,const struct ieee80211_mgmt *mgmt,size_t len, int reassoc, int ok); 8 | 9 | void WTP_ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,u16 stype, int ok); 10 | 11 | struct hostapd_data * WTP_get_hapd_bssid(struct hostapd_iface *iface,const u8 *bssid); 12 | 13 | void WTP_hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf,size_t len, u16 stype, int ok); 14 | 15 | void WTP_wpa_supplicant_event(void *ctx, enum wpa_event_type event,union wpa_event_data *data); 16 | 17 | 18 | int WTP_get_SubType(u8 *buf,int len); 19 | 20 | int WTP_get_Type(u8 *buf,int len); 21 | 22 | int isEAPOL_Frame( unsigned char *buf, int len); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/file_conf_ac.h: -------------------------------------------------------------------------------- 1 | #define CONFIGFILE "hostapd_ac.conf" 2 | #define VARLENGTH 1024 3 | 4 | struct config_ac { 5 | int ac_port; 6 | char ip_ac[50]; 7 | char path_unix_socket[50]; 8 | }config_ac; 9 | 10 | int max_(int integer1,int integer2){ 11 | if(integer1>integer2)return integer1; 12 | return integer2; 13 | } 14 | 15 | int countString(char string[]){ 16 | int cnt=0; 17 | for(cnt=0;string[cnt]!=0;cnt++); 18 | return cnt; 19 | } 20 | 21 | int isEqualString(char String1[],char String2[]){ 22 | int len1=countString(String1); 23 | int len2=countString(String2); 24 | int i; 25 | for( i=0;i=1)b=1; 57 | for(j=0;j<=strlen(rep)-1;j++){ 58 | if(String1[i+j]!=rep[j]){ 59 | b=0; 60 | break; 61 | } 62 | } 63 | if(b){ 64 | for(k=0;k0){ 66 | for(m=0;m<=strlen(String2)-1;++m,k++)tmp[k]=String2[m]; 67 | } 68 | for(l=i+j;l<=strlen(String1)-1;l++,k++)tmp[k]=String1[l]; 69 | tmp[k]=0; 70 | 71 | for(k=0;kip_ac, "%s", ss); 97 | 98 | }else if(StartWith(ss,"sock_path_ac")){ 99 | ReplaceString(ss, "sock_path_ac", ""); 100 | ReplaceString(ss, "=", ""); 101 | ReplaceString(ss, "\n", ""); 102 | ReplaceString(ss, " ", ""); 103 | sprintf(con_ac->path_unix_socket, "%s", ss); 104 | 105 | }else if(StartWith(ss,"port_daemon_ac")){ 106 | ReplaceString(ss, "port_daemon_ac",""); 107 | ReplaceString(ss, "\n", ""); 108 | ReplaceString(ss, " ", ""); 109 | ReplaceString(ss, "=", ""); 110 | con_ac->ac_port = atoi(ss); 111 | } 112 | 113 | } 114 | fclose(file); 115 | return; 116 | } 117 | 118 | 119 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/file_conf_wtp.h: -------------------------------------------------------------------------------- 1 | #define CONFIGFILE "hostapd_wtp.conf" 2 | #define VARLENGTH 1024 3 | 4 | struct config_wtp { 5 | int wtp_port; 6 | char ip_wtp[50]; 7 | char path_unix_socket[50]; 8 | }config_wtp; 9 | 10 | int max_(int integer1,int integer2){ 11 | if(integer1>integer2)return integer1; 12 | return integer2; 13 | } 14 | 15 | int countString(char string[]){ 16 | int cnt=0; 17 | for(cnt=0;string[cnt]!=0;cnt++); 18 | return cnt; 19 | } 20 | 21 | int isEqualString(char String1[],char String2[]){ 22 | int len1=countString(String1); 23 | int len2=countString(String2); 24 | int i; 25 | for( i=0;i=1)b=1; 57 | for(j=0;j<=strlen(rep)-1;j++){ 58 | if(String1[i+j]!=rep[j]){ 59 | b=0; 60 | break; 61 | } 62 | } 63 | if(b){ 64 | for(k=0;k0){ 66 | for(m=0;m<=strlen(String2)-1;++m,k++)tmp[k]=String2[m]; 67 | } 68 | for(l=i+j;l<=strlen(String1)-1;l++,k++)tmp[k]=String1[l]; 69 | tmp[k]=0; 70 | 71 | for(k=0;kip_wtp, "%s", ss); 97 | 98 | }else if(StartWith(ss,"sock_pach_wtp")){ 99 | ReplaceString(ss, "sock_pach_wtp", ""); 100 | ReplaceString(ss, "=", ""); 101 | ReplaceString(ss, "\n", ""); 102 | ReplaceString(ss, " ", ""); 103 | sprintf(con_wtp->path_unix_socket, "%s", ss); 104 | 105 | }else if(StartWith(ss,"port_daemon_wtp")){ 106 | ReplaceString(ss, "port_daemon_wtp",""); 107 | ReplaceString(ss, "\n", ""); 108 | ReplaceString(ss, " ", ""); 109 | ReplaceString(ss, "=", ""); 110 | con_wtp->wtp_port = atoi(ss); 111 | } 112 | 113 | } 114 | fclose(file); 115 | return; 116 | } 117 | 118 | 119 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/ipc_capwap_ac.h: -------------------------------------------------------------------------------- 1 | #ifndef __IPC_CAPWAP_AC_H 2 | #define __IPC_CAPWAP_AC_H 3 | 4 | typedef void (* WTP_frame_inject)(void *, unsigned char *, int); 5 | 6 | void ipc_send_80211_to_wtp(int fd, u8 *buf, int len); 7 | int start_ipc(void *hapd, void *inject_func); 8 | int end_ipc(int fd); 9 | 10 | int capability_is_B(); 11 | int capability_get_num_modes(); 12 | int capability_get_num_channels(); 13 | int capability_get_rates(int *rate_arr); 14 | void capability_get_mac(unsigned char *buf); 15 | void prep_beacon(int fd,struct hostapd_data *hapd,struct wpa_driver_ap_params *params); 16 | 17 | void ipc_send_DEL_WLAN(int fd); 18 | void ipc_send_add_station(int fd, u8 *buf, int len); 19 | void ipc_send_del_station(int fd, u8 *buf, int len); 20 | 21 | void send_response(int fd, u8 code, u8 *buf, int len); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/ipc_capwap_wtp.h: -------------------------------------------------------------------------------- 1 | #ifndef __IPC_CAPWAP_WTP_H 2 | #define __IPC_CAPWAP_WTP_H 3 | 4 | typedef void (* WTP_frame_inject)(void *, unsigned char *, int); 5 | 6 | void ipc_send_80211_to_ac(int fd, u8 *buf, int len); 7 | void flush_SET_TXQ_handle(int fd, void *hapd); 8 | int start_ipc(void *hapd, unsigned char *, int *, void * inject_func, unsigned char *); 9 | int end_ipc(int fd); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/smac_code.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Sotiraq Sima (Sotiraq.Sima@gmail.com) * 22 | * * 23 | *******************************************************************************************/ 24 | 25 | #include 26 | 27 | enum { 28 | ERROR = 0, 29 | CLOSE = 1, 30 | 31 | PING = 2, // [2]ping 32 | PONG = 3,// [3]pong 33 | 34 | START_WLAN = 4, 35 | START_WLAN_R = 5, 36 | 37 | STOP_WLAN = 6, 38 | STOP_WLAN_R = 7, 39 | 40 | SET_FREQ = 8, // FREQ sec_channel_offset ht_enabled channel MODE ex. "[8]2462 0 0 11 0" 41 | SET_FREQ_R = 9, // 0 or 1 ex. "[9]0" 42 | 43 | GET_FREQ = 10, // ex. "[10]" 44 | GET_FREQ_R = 11, // ex. "[11]2462 0 0 11 0" 45 | 46 | SET_FRAG = 12, // Typically the range used for fragmentation threshold is 256-2346 (-1 == off) ex. "[12]2000" 47 | SET_FRAG_R = 13,// ex. "[13]0" 48 | 49 | GET_FRAG = 14, // ex. "[14]" (-1 == off) 50 | GET_FRAG_R = 15, // ex. "[15]2000" 51 | 52 | SET_BITRATE = 16, 53 | SET_BITRATE_R = 17, 54 | 55 | GET_BITRATE = 18, 56 | GET_BITRATE_R = 19, 57 | 58 | SET_RTS = 20, // 0-2347 (-1 == off) ex. "[20]100" (-1 == off) 59 | SET_RTS_R = 21,// ex. "[21]0" 60 | 61 | GET_RTS = 22, // ex. "]22]" (-1 == off) 62 | GET_RTS_R = 23, // ex. "[23]100" 63 | 64 | SET_TXPOWER = 24, 65 | SET_TXPOWER_R = 25, 66 | 67 | GET_TXPOWER = 26, 68 | GET_TXPOWER_R = 27, 69 | 70 | /* 71 | * VO - 0 CWMIN:3 CWMAX:7 AIFS:2 72 | * VI - 1 CWMIN:7 CWMAX:15 AIFS:2 73 | * BE - 2 CWMIN:15 CWMAX:1023 AIFS:3 74 | * BK - 3 CWMIN:15 CWMAX:1023 AIFS:7 75 | */ 76 | SET_TXQ = 28, 77 | SET_TXQ_R = 29, 78 | 79 | GET_TXQ = 30, 80 | GET_TXQ_R = 31, 81 | 82 | SET_ADDR = 32, 83 | SET_ADDR_R = 33, 84 | 85 | DEL_ADDR = 34, 86 | DEL_ADDR_R = 35, 87 | 88 | ADD_WLAN = 36, 89 | ADD_WLAN_R = 37, 90 | 91 | DEL_WLAN = 38, 92 | DEL_WLAN_R = 39, 93 | 94 | WTPRINFO = 40, 95 | WTPRINFO_R = 41, 96 | 97 | GET_RATES = 42, 98 | GET_RATES_R = 43, 99 | 100 | GET_MDC = 44, 101 | GET_MDC_R = 45, 102 | 103 | SET_WTPRINFO = 46, 104 | SET_WTPRINFO_R = 47, 105 | 106 | SET_RATES = 48, 107 | SET_RATES_R = 49, 108 | 109 | SET_MDC = 50, 110 | SET_MDC_R = 51, 111 | 112 | GOLIVE = 52, 113 | GOLIVE_R = 53, 114 | 115 | WANT_GOLIVE = 54, 116 | HAVE_TO_WAIT = 55, 117 | 118 | GET_MAC = 56, 119 | GET_MAC_R = 57, 120 | 121 | SET_MAC = 58, 122 | SET_MAC_R = 59, 123 | 124 | DATE_TO_WTP = 100, 125 | DATE_TO_AC = 101, 126 | 127 | CONNECT = 102, 128 | CONNECT_R = 103, 129 | 130 | GOWAITWLAN = 104, 131 | GOWAITWLAN_R = 105 132 | }; 133 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/capwap/switch_8023_80211.c: -------------------------------------------------------------------------------- 1 | #include "utils/includes.h" 2 | 3 | #include "utils/common.h" 4 | #include "radius/radius.h" 5 | #include "drivers/driver.h" 6 | #include "common/ieee802_11_defs.h" 7 | #include "common/ieee802_11_common.h" 8 | 9 | 10 | #define SETBIT(ADDRESS,BIT) (ADDRESS |= (1< 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | 16 | #include "utils/includes.h" 17 | #include 18 | #include 19 | #include 20 | 21 | #include "utils/common.h" 22 | #include "linux_ioctl_fake.h" 23 | 24 | 25 | 26 | int linux_set_iface_flags(int sock, const char *ifname, int dev_up){ 27 | 28 | return 0; 29 | } 30 | 31 | int linux_iface_up(int sock, const char *ifname){ 32 | 33 | return 0; 34 | } 35 | 36 | int linux_get_ifhwaddr(int sock, const char *ifname, u8 *addr){ 37 | 38 | int i=2; 39 | 40 | if(i==0){ // TP-LINK (Atheros) 41 | addr[0]=0xB0; 42 | addr[1]=0x48; 43 | addr[2]=0x7A; 44 | addr[3]=0x93; 45 | addr[4]=0x90; 46 | addr[5]=0xF8; 47 | 48 | }else if(i==1){// D-Link 49 | addr[0]=0x28; 50 | addr[1]=0x10; 51 | addr[2]=0x7B; 52 | addr[3]=0x44; 53 | addr[4]=0xd0; 54 | addr[5]=0xB1; 55 | 56 | }else if(i==2){// TP-LINK (Atheros) 57 | addr[0]=0xAA; 58 | addr[1]=0xBB; 59 | addr[2]=0xCC; 60 | addr[3]=0xDD; 61 | addr[4]=0xEE; 62 | addr[5]=0xFF; 63 | 64 | } 65 | 66 | return 0; 67 | } 68 | 69 | int linux_set_ifhwaddr(int sock, const char *ifname, const u8 *addr){ 70 | 71 | return 0; 72 | } 73 | 74 | 75 | #ifndef SIOCBRADDBR 76 | #define SIOCBRADDBR 0x89a0 77 | #endif 78 | #ifndef SIOCBRDELBR 79 | #define SIOCBRDELBR 0x89a1 80 | #endif 81 | #ifndef SIOCBRADDIF 82 | #define SIOCBRADDIF 0x89a2 83 | #endif 84 | #ifndef SIOCBRDELIF 85 | #define SIOCBRDELIF 0x89a3 86 | #endif 87 | 88 | 89 | int linux_br_add(int sock, const char *brname){ 90 | return 0; 91 | } 92 | 93 | int linux_br_del(int sock, const char *brname){ 94 | return 0; 95 | } 96 | 97 | int linux_br_add_if(int sock, const char *brname, const char *ifname){ 98 | return 0; 99 | } 100 | 101 | int linux_br_del_if(int sock, const char *brname, const char *ifname){ 102 | return 0; 103 | } 104 | 105 | int linux_br_get(char *brname, const char *ifname){ 106 | return 0; 107 | } 108 | 109 | 110 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/drivers/linux_ioctl_fake.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux ioctl helper functions for driver wrappers 3 | * Copyright (c) 2002-2010, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef LINUX_IOCTL_H 16 | #define LINUX_IOCTL_H 17 | 18 | int linux_set_iface_flags(int sock, const char *ifname, int dev_up); 19 | int linux_iface_up(int sock, const char *ifname); 20 | int linux_get_ifhwaddr(int sock, const char *ifname, u8 *addr); 21 | int linux_set_ifhwaddr(int sock, const char *ifname, const u8 *addr); 22 | int linux_br_add(int sock, const char *brname); 23 | int linux_br_del(int sock, const char *brname); 24 | int linux_br_add_if(int sock, const char *brname, const char *ifname); 25 | int linux_br_del_if(int sock, const char *brname, const char *ifname); 26 | int linux_br_get(char *brname, const char *ifname); 27 | 28 | #endif /* LINUX_IOCTL_H */ 29 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/drivers/netlink_fake.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Netlink helper functions for driver wrappers 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | 16 | #include "includes.h" 17 | 18 | #include "common.h" 19 | #include "eloop.h" 20 | #include "priv_netlink.h" 21 | #include "netlink_fake.h" 22 | 23 | 24 | 25 | struct netlink_data { 26 | struct netlink_config *cfg; 27 | int sock; 28 | }; 29 | 30 | 31 | static void netlink_receive_link(struct netlink_data *netlink, 32 | void (*cb)(void *ctx, struct ifinfomsg *ifi, 33 | u8 *buf, size_t len), 34 | struct nlmsghdr *h) 35 | { 36 | 37 | return; 38 | } 39 | 40 | 41 | static void netlink_receive(int sock, void *eloop_ctx, void *sock_ctx) 42 | { 43 | return; 44 | } 45 | 46 | 47 | struct netlink_data * netlink_init(struct netlink_config *cfg) 48 | { 49 | 50 | struct netlink_data *netlink; 51 | struct sockaddr_nl local; 52 | 53 | netlink = os_zalloc(sizeof(*netlink)); 54 | if (netlink == NULL) 55 | return NULL; 56 | 57 | netlink->cfg = cfg; 58 | 59 | netlink->sock = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); 60 | 61 | os_memset(&local, 0, sizeof(local)); 62 | local.nl_family = AF_NETLINK; 63 | local.nl_groups = RTMGRP_LINK; 64 | 65 | eloop_register_read_sock(netlink->sock, netlink_receive, netlink, 66 | NULL); 67 | 68 | return netlink; 69 | 70 | } 71 | 72 | 73 | void netlink_deinit(struct netlink_data *netlink) 74 | { 75 | return; 76 | } 77 | 78 | int netlink_send_oper_ifla(struct netlink_data *netlink, int ifindex, 79 | int linkmode, int operstate){ 80 | 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /hostapd_wrapper/src/drivers/netlink_fake.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Netlink helper functions for driver wrappers 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef NETLINK_H 16 | #define NETLINK_H 17 | 18 | struct netlink_data; 19 | struct ifinfomsg; 20 | 21 | struct netlink_config { 22 | void *ctx; 23 | void (*newlink_cb)(void *ctx, struct ifinfomsg *ifi, u8 *buf, 24 | size_t len); 25 | void (*dellink_cb)(void *ctx, struct ifinfomsg *ifi, u8 *buf, 26 | size_t len); 27 | }; 28 | 29 | struct netlink_data * netlink_init(struct netlink_config *cfg); 30 | void netlink_deinit(struct netlink_data *netlink); 31 | int netlink_send_oper_ifla(struct netlink_data *netlink, int ifindex, 32 | int linkmode, int operstate); 33 | 34 | #endif /* NETLINK_H */ 35 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/m4/.gitignore -------------------------------------------------------------------------------- /m4/ax_check_openssl.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Look for OpenSSL in a number of default spots, or in a user-selected 12 | # spot (via --with-openssl). Sets 13 | # 14 | # OPENSSL_INCLUDES to the include directives required 15 | # OPENSSL_LIBS to the -l directives required 16 | # OPENSSL_LDFLAGS to the -L or -R flags required 17 | # 18 | # and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately 19 | # 20 | # This macro sets OPENSSL_INCLUDES such that source files should use the 21 | # openssl/ directory in include directives: 22 | # 23 | # #include 24 | # 25 | # LICENSE 26 | # 27 | # Copyright (c) 2009,2010 Zmanda Inc. 28 | # Copyright (c) 2009,2010 Dustin J. Mitchell 29 | # 30 | # Copying and distribution of this file, with or without modification, are 31 | # permitted in any medium without royalty provided the copyright notice 32 | # and this notice are preserved. This file is offered as-is, without any 33 | # warranty. 34 | 35 | #serial 8 36 | 37 | AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) 38 | AC_DEFUN([AX_CHECK_OPENSSL], [ 39 | found=false 40 | AC_ARG_WITH([openssl], 41 | [AS_HELP_STRING([--with-openssl=DIR], 42 | [root of the OpenSSL directory])], 43 | [ 44 | case "$withval" in 45 | "" | y | ye | yes | n | no) 46 | AC_MSG_ERROR([Invalid --with-openssl value]) 47 | ;; 48 | *) ssldirs="$withval" 49 | ;; 50 | esac 51 | ], [ 52 | # if pkg-config is installed and openssl has installed a .pc file, 53 | # then use that information and don't search ssldirs 54 | AC_PATH_PROG([PKG_CONFIG], [pkg-config]) 55 | if test x"$PKG_CONFIG" != x""; then 56 | OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` 57 | if test $? = 0; then 58 | OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` 59 | OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` 60 | found=true 61 | fi 62 | fi 63 | 64 | # no such luck; use some default ssldirs 65 | if ! $found; then 66 | ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" 67 | fi 68 | ] 69 | ) 70 | 71 | 72 | # note that we #include , so the OpenSSL headers have to be in 73 | # an 'openssl' subdirectory 74 | 75 | if ! $found; then 76 | OPENSSL_INCLUDES= 77 | for ssldir in $ssldirs; do 78 | AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) 79 | if test -f "$ssldir/include/openssl/ssl.h"; then 80 | OPENSSL_INCLUDES="-I$ssldir/include" 81 | OPENSSL_LDFLAGS="-L$ssldir/lib" 82 | OPENSSL_LIBS="-lssl -lcrypto" 83 | found=true 84 | AC_MSG_RESULT([yes]) 85 | break 86 | else 87 | AC_MSG_RESULT([no]) 88 | fi 89 | done 90 | 91 | # if the file wasn't found, well, go ahead and try the link anyway -- maybe 92 | # it will just work! 93 | fi 94 | 95 | # try the preprocessor and linker with our new flags, 96 | # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS 97 | 98 | AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) 99 | echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ 100 | "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD 101 | 102 | save_LIBS="$LIBS" 103 | save_LDFLAGS="$LDFLAGS" 104 | save_CPPFLAGS="$CPPFLAGS" 105 | LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" 106 | LIBS="$OPENSSL_LIBS $LIBS" 107 | CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" 108 | AC_LINK_IFELSE( 109 | [AC_LANG_PROGRAM([#include ], [SSL_new(NULL)])], 110 | [ 111 | AC_MSG_RESULT([yes]) 112 | $1 113 | ], [ 114 | AC_MSG_RESULT([no]) 115 | $2 116 | ]) 117 | CPPFLAGS="$save_CPPFLAGS" 118 | LDFLAGS="$save_LDFLAGS" 119 | LIBS="$save_LIBS" 120 | 121 | AC_SUBST([OPENSSL_INCLUDES]) 122 | AC_SUBST([OPENSSL_LIBS]) 123 | AC_SUBST([OPENSSL_LDFLAGS]) 124 | ]) 125 | -------------------------------------------------------------------------------- /modifiche_uci_frequency_2009.txt: -------------------------------------------------------------------------------- 1 | Capwap README 2009: Uci - Frequency 2 | 3 | 4 | DISCLAIMER: If you want to realize new capabilities into the OpenCapwap Protocol, you need to read the IETF draft writed by CAPWAP Working Group and ACAppsProtocol.h (inside Capwap directoy) first, then you need to modify the Application server which we talk about below is just a way of centering application development, it's not meant to bypass coding in the OpenCapwap code base (many message elements are still missing, so you may have to implement some new ones). 5 | 6 | AC side: 7 | 8 | - All sockets, previously Unix sockets, are now Inet sockets. 9 | 10 | To let the Access Controller receive multiple connections from other applications (the ones which add fuctionality), we added to 11 | ACInterface a multi-thread TCP server. This TCP server provides to external applications the possibility to talk to the connected 12 | Wireless Termination Points tunnelling packets through the Capwap protocol. 13 | 14 | When the AC server is started, a standalone thread is spawned to manage the various applications' requests. 15 | Every time the TCP server receives a new connection, a new thread is spawned to manage that one specific external application. 16 | The communication between the AC (through the TCP server) and external applications is ruled by a protocol which (we hope) will 17 | be used for every other application (even those which are not yet implemented) as is. This simple protocol is basically made of 18 | the command id, the WTP id, the length of the attached payload and the payload itself (refer to ACAppsProtocol.h for header specs). 19 | The protocol's main commands are LIST_MSG and CONF_UPDATE_MSG: 20 | LIST_MSG returns the list of the WTPs attached to the AC 21 | CONF_UPDATE_MSG lets the application send a Capwap Configuration Update Request Message to a single (or all) connected WTP. 22 | 23 | 24 | At the moment, implemented Configuration Update Request/Response message elements are: 25 | - OFDM Element Type ( Binding 802.11 ) 26 | - Vendor Specific Payload Type 27 | 28 | *** All other element types are NOT yet implemented in the OpenCapwap protocol (except those already implemented) 29 | 30 | 31 | 32 | WTP side: 33 | 34 | Frequencies Management: 35 | To realize Frequencies management inside Capwap WTP we added an additional parsing of Configuration Update Request Message 36 | (inside code of 802.11 Binding) with Orthogonal Frequency Division Multiplexing (OFDM) Element Type. (This message, 37 | when sent by AC, force the WTP to adhere to received values). 38 | 39 | When a new OFDM message is received, the WTP provide to forward it, through an inet socket (udp), to an external application 40 | that will do the corrispondent operations (scanning, monitoring, setting). 41 | We added a new thread too (WTPFreqStatsReceive) inside WTP that receive the statistics packets (or ack packet, for frequency 42 | setting operation) and provide to encapsulate them in CAPWAP Data Message that will recognize by AC through an apposite flag 43 | (for more informations see CWBinding.h). 44 | 45 | 46 | Remote UCI command execution via Vendor Specific Payload: 47 | OpenCapwap was used to deploy basic remote administration and configuration to a number of access points. The access points 48 | use OpenWrt (http://openwrt.org/) running the OpenCapwap WTP daemon. Since OpenWrt comes with a very handy, centralized 49 | configuration utility called UCI, custom Vendor Specific Payloads have been coded to implement Uci Vendor Specific Payloads. 50 | These custom payloads basically carry uci commands to be executed on one or more wtps (the access points). When the AC issues 51 | a Configuration Update Request containing an Uci Vendor Specific Payload to a WTP, the WTP daemon unpacks it and forwards the 52 | command to be executed to an external application. The WTP daemon and the external application talk through an inet socket (udp). 53 | The external application basically executes the command and signals back the daemon if the command succeded/failed. The WTP 54 | daemon then forwards this response to the AC via a Configuration Update Response carrying an Uci Vendor Specific Payload. 55 | (For more information see CWVendorPayloads.h) 56 | These messages have all been handled by some new code which is completely separated from the 802.11 Binding Code. This code 57 | is essentially meant to manage Capwap Protocol Element Types (which couldn't be treated as part of a specific Technology Binding). 58 | -------------------------------------------------------------------------------- /packages/Debian-6/hostapd-cw_2.0-1_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/packages/Debian-6/hostapd-cw_2.0-1_all.deb -------------------------------------------------------------------------------- /packages/Debian-6/nltiny_2.0-1_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/packages/Debian-6/nltiny_2.0-1_all.deb -------------------------------------------------------------------------------- /packages/Debian-6/opencapwap_0.99b-1_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/packages/Debian-6/opencapwap_0.99b-1_all.deb -------------------------------------------------------------------------------- /packages/FC18/x86_64/README.FC18: -------------------------------------------------------------------------------- 1 | 2 | Installation steps: 3 | 4 | 1. Flash a firmware with the hostapd-capwap package on a OpenWRT compatible router. 5 | 2. Setup a FC18 box where you want to run AC. 6 | 3. On the FC18 box: 7 | - Copy the RPMS and run: yum -y erase openssl-libs.i686; yum -y install openssl-libs.i686; rpm -ivh --force *.rpm 8 | - Edit /etc/hostapd/hostapd.conf 9 | - Run /etc/init.d/capwap-ac start 10 | - Run /etc/init.d/hostapd start 11 | 4. On the OpenWRT router : 12 | - Run killall -9 hostapd 13 | - Copy /tmp/run/hostapd-phy0.conf to /etc/capwap/hostapd.conf 14 | - Edit the driver in /etc/capwap/hostapd.conf line and set it to capwap_wtp 15 | - Run cd /etc/capwap; WTP; hostapd hostapd.conf 16 | 9. Enjoy the RX_MGMT events flowing trough the radiotap tunnel. 17 | 18 | Logs: 19 | 20 | - on WTP /var/log/wtp.log.txt 21 | - on AC /var/log/ac.log.txt 22 | 23 | Notes: 24 | 25 | - Always run AC first and WTP after otherwise they might get stuck in join state. 26 | - When hostapd on AC is closed also the hostapd on WTP needs to be closed. 27 | - When AC and WTP don't talk to eachother because they are stuck in join state 28 | allways kill hostapd, AC and WTP processes. 29 | -------------------------------------------------------------------------------- /packages/FC18/x86_64/capwap-ac-0.9b-3.fc18.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/packages/FC18/x86_64/capwap-ac-0.9b-3.fc18.x86_64.rpm -------------------------------------------------------------------------------- /packages/FC18/x86_64/hostapd-capwap-20130302-3.fc18.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/packages/FC18/x86_64/hostapd-capwap-20130302-3.fc18.x86_64.rpm -------------------------------------------------------------------------------- /packages/FC18/x86_64/libnl-tiny-2.0-1.fc18.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosifpeterfi/openCAPWAP-OpenWRT/1c1984d6cf7f310d39bc304782cea16f34592dbb/packages/FC18/x86_64/libnl-tiny-2.0-1.fc18.x86_64.rpm -------------------------------------------------------------------------------- /root.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDqzCCApOgAwIBAgIJAKFrKBWkidxvMA0GCSqGSIb3DQEBBQUAMGwxCzAJBgNV 3 | BAYTAlRXMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxDTALBgNVBAoMBFRPREQxFDAS 4 | BgNVBAMMC0NBUFdBUF9ST09UMSEwHwYJKoZIhvcNAQkBFhJ0b2RkY2hvdUBnbWFp 5 | bC5jb20wHhcNMTIwMjI0MTYzNDI0WhcNMzIwMjI0MTYzNDI0WjBsMQswCQYDVQQG 6 | EwJUVzEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MQ0wCwYDVQQKDARUT0REMRQwEgYD 7 | VQQDDAtDQVBXQVBfUk9PVDEhMB8GCSqGSIb3DQEJARYSdG9kZGNob3VAZ21haWwu 8 | Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtGgC6q7ss4Kbcn4H 9 | foWNBaXZOp+F/C5kQlsB5aO6k6FGZzij7nJhOpQASR0kSg8TciTPm1eMxn7pIJ7A 10 | b5raDXnIcRCrpZVEdgAhUPKVkPWRIAhJtjqz6ix2ZrJI2hXjf24kvAzfIwCJgtaP 11 | 0phaUeAUpofzW5PILwiFLrb59oNaMkUxpv6bWHYYQIh5rGf2nVKDZebf+tGEzCxB 12 | jhVVgTfstuTu1tNaQVSR6pTuEoFiOUINLSRfMZ37ajEM+tlK5juETaviT8XMXqMP 13 | MSAsjwwd3FxmJYi79iNSqmR0/izjlAD/5R/2ZD+0usEhvTR8R0aKbTPvCvU5ZSWL 14 | MJ8ZPwIDAQABo1AwTjAdBgNVHQ4EFgQUrD4UNtUPiyDVWRbnMfqPtgnNucMwHwYD 15 | VR0jBBgwFoAUrD4UNtUPiyDVWRbnMfqPtgnNucMwDAYDVR0TBAUwAwEB/zANBgkq 16 | hkiG9w0BAQUFAAOCAQEAsfmB0z1C8tYE+sRKSTOPKdsVaiwXdOxWkYK++ZyEJR9H 17 | 5zukOQTev5bOQU38JHG7iXMDpSeRwZsaQlJc+/rbn0NDaQa5A3mlQH7EcY7kbxav 18 | yQ57wHivqUjbQry8oJ5TSvAytb46oJ08zcfVvp4ZPFURTwnf6N9gFibNoBphKPKZ 19 | l/sRfr+zTPTP2kRFVY2/Jf0VQ8MT+rZFU3mRz2v5pxIrvfhfLheEgySTVBUQ34WE 20 | Mt4a54zhANOt713ZJPeFMM73A46SIJt1rYWzZZ3dyjBREXgXRoeC5myGULMJyLaK 21 | fZU/B2aHf4uOwOtL/iRuFomKPZwyAK4aMxDEUrp6YA== 22 | -----END CERTIFICATE----- 23 | -----BEGIN RSA PRIVATE KEY----- 24 | Proc-Type: 4,ENCRYPTED 25 | DEK-Info: DES-EDE3-CBC,3FC7B4CF6DC46853 26 | 27 | Lt8A8/KZnD7khLrT10brqWMYg2RQ325Xbi8HQAxcEdfkb15lcucz1eUh4fZ3Fjlf 28 | K6b63SUXaIY1rr2uVCv3cUMS2L3aZeyJI68rz28jpZ70vEY399MxXeABEGV4YDhe 29 | /x97rI3EQJ9Q2fnNwoXMd58nFIA5odx7xwv37+3UnDi04bCd0aXs+ejnTpcAVDCS 30 | ERAbjoBxmwc4uwWXcXV2CTpjUham9h1dzb3LHaRYM0uy2rz38WaixlcFbzkh/t97 31 | /s0L+tiw7N8uwBTsAOF7DxsoB/NXtfaF0FiSnSOdSb8DfXuGH4K1uFZ6XUryyblJ 32 | ExlTwveP2uZVhyFoUBj+x5dcX0YyijunJAizr4ca5piXO4LgIjKrCss2HSO1MNLR 33 | ubLtXFGh/UtQhpBkebbaYC8XHPiFe3BeUyrp3PL+770bF7XfJeH+U3W731Jc2H1t 34 | WkvNa7UUtKjizaeDY6BRxRCwcYmqKNUwCji2E5KehNii7ErUbqc2zaMAxerzUTdC 35 | wWw6JdGuRO8jy5Q5QlrBxEaxQUzPxlibe0wFpPp0SKwNwR9CyNhryplTmguhSwbT 36 | N3/EtSxY3fDz5AWqD/KKy7iqB/l9VZN97uqlVYArdZQ3bmSp991PxWI7zCi+vPYQ 37 | OaMm7RiRU5ssjjb/xutjYp0iRsf/trbZSfyzEgHzHIk7PsQ/azTc/WhwDjPm0W4h 38 | Cxf+xhgPMLCxfDt46Gr03tw2s3ohcm1czEowY8gctpAMsx3mGROggS6mrQDPlO+9 39 | gS3Erc8Tn533vYrIVQsYzpLV5UOsc3UHpysc7bBOUUWa4Pcxf6aGxi6EV/BBniKU 40 | Crptz/crTGe+xtCFYSR9HewHp1eqV1UtBm8nb5If7KddgHTfskGDNsJiTVBpSS1x 41 | mL8debg3dTzmYgnA7lqQ689DexD6GoqBug7SRUL7dpxfIEL+M+ylbr20kxqDo+Vq 42 | 0pka/SJbIXlnWQxzwKx+6M2e579wAB9dIRKVVm5QzB2L7H6JN2gQ4n9/b/rkaerR 43 | sLnqNdQQI5ULe3rOnPVJiQj/0IvxnQkZv5fJkRNrWGDrGUp+egzU3cyXL0gYFrXO 44 | T0wgocPyU/6qfOEGMXJUukgu8id235k+eRRwY3utwPA4gxdTaZmyKtrzjByLUYhU 45 | gEwbho07Yaifnb0xEBEO/74iCC4A18ig24vNLVF9jsweiB4UpG7rHXKNxDXEdA/d 46 | PUJbOC3XbtfD20MM3oiPm0H9ZHuOhFmZ981R3Qw3CzGIIZlWC3ntycDxHKM9hxTk 47 | Zafj7PU121263H3buZz8i3BJNf9qBi697PV6UcluVVgqVJsN4gJspmTJgbblwPZW 48 | 2QOg+A2bPNhRBOWXGNPoRnBed36DBS/weR2hmDbZkjpbbYqL1Q964eU3he1Xjrzi 49 | xVcz6gyjQqatLChakHSliIBOu+PGCjpP5x0ECqh4jyz3KT3CUGY+8iSIGsAt32Cb 50 | eX/1GbaI+GdONVI427N5wY14FRfmvXT04+6FqzOkZGdbCHNi9eqUx+gueTAIm8YX 51 | PFQv9AIhjM5U4mLmsVvQrf3FVRP/Pq4IkpuSmxv3iJVMPu6vSAjI/Q== 52 | -----END RSA PRIVATE KEY----- 53 | -------------------------------------------------------------------------------- /server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDaDCCAlCgAwIBAgIJAJI6srPP97u0MA0GCSqGSIb3DQEBBQUAMGwxCzAJBgNV 3 | BAYTAlRXMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxDTALBgNVBAoMBFRPREQxFDAS 4 | BgNVBAMMC0NBUFdBUF9ST09UMSEwHwYJKoZIhvcNAQkBFhJ0b2RkY2hvdUBnbWFp 5 | bC5jb20wHhcNMTIwMjI0MTYzNTUzWhcNMjIwMjIxMTYzNTUzWjBfMQswCQYDVQQG 6 | EwJUVzEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRYwFAYDVQQKDA1DQVBXQVBfU0VS 7 | VkVSMSEwHwYJKoZIhvcNAQkBFhJ0b2RkY2hvdUBnbWFpbC5jb20wggEiMA0GCSqG 8 | SIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3AadIRJYKHVOhsk4J/6gSTJSxljSa5MNe 9 | 2pkwZPT0Vi5FUuw7ogTqXfiwutiupxnl1CEX3sDk6j7RlkwY0mnsBwruErlRmeH1 10 | Zkr7kgbfjKcaKhVvJAbfjCOSiYcgi+pGcu1GGTDm9Jkmwy/yKxWW2CBRUGQOrpVa 11 | rBQobQ5WYmZm66/mBRHwJzLExLWDzZPhNHcSk1H2VxqaTmHzFeSmN4o2HtupCuOE 12 | dvMzgp+RV87mMBQnQv1FjIoeb3Mqir1wgkcaGWrut+t6uatwRU/vu9tJYuPhpC4N 13 | D/VmjYnPkR7GFNyncp1ELp2blQls327dTAvjt0gRZCKLxKUGOAh/AgMBAAGjGjAY 14 | MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgXgMA0GCSqGSIb3DQEBBQUAA4IBAQAdmZA+ 15 | 7E0z086Q7ol99z1UQjQ+O5jSdCdwzmekvAru7vsM5Sbbm5ODMyabauKI0nnRRGrX 16 | ISS72BEk5T1I0Nr14YzT8uINnxh/sZWJq1a/hX2/O/YVwfJdSLhCU6oMz1kGaOGG 17 | pNoT7SsVxLUBd61FhTIZp7k8QB3tN/gG4pATv0EnzhQCYASWvRu/Loydeu5XE7WV 18 | HP6eO1O48l/7CFNW06ilewAURm7Hnnrt7+6HB9bG7Nn9TWoludc54JibrnYw1Q0I 19 | rLEv+LRBiZtoKqrscJ6/VoD0uBnC2K69yOdbcgcgiykbD6S777c2iwIvtklysIRX 20 | cHPrByM9nQ/jGHK9 21 | -----END CERTIFICATE----- 22 | -----BEGIN RSA PRIVATE KEY----- 23 | MIIEpAIBAAKCAQEAtwGnSESWCh1TobJOCf+oEkyUsZY0muTDXtqZMGT09FYuRVLs 24 | O6IE6l34sLrYrqcZ5dQhF97A5Oo+0ZZMGNJp7AcK7hK5UZnh9WZK+5IG34ynGioV 25 | byQG34wjkomHIIvqRnLtRhkw5vSZJsMv8isVltggUVBkDq6VWqwUKG0OVmJmZuuv 26 | 5gUR8CcyxMS1g82T4TR3EpNR9lcamk5h8xXkpjeKNh7bqQrjhHbzM4KfkVfO5jAU 27 | J0L9RYyKHm9zKoq9cIJHGhlq7rfrermrcEVP77vbSWLj4aQuDQ/1Zo2Jz5EexhTc 28 | p3KdRC6dm5UJbN9u3UwL47dIEWQii8SlBjgIfwIDAQABAoIBAAZRuUwGikPJJXUk 29 | 6grwWAZhvJSxQhnDInfpBnckVU0GmMxuA5g/jPnmysqXeRn2zS8hdw8S8wg0inzE 30 | OtZ0lZG/4IG+BcYqkSHfKWGsdi5L9g0yPNE8pjwb47KQqyjVi/5ow4azIfwnoA41 31 | mTc8g59U0TDdnMbhAmlCHeQTd/ZFmpZIygD176nahmYENutV1Y+nm9r9m9FpffCs 32 | j3Kj7RmjgFx85fQwzLpLKirauVA2RDXCRe0u8xFIH49UmcqkPzFZNeuc/IStVBtp 33 | Hzl9fpLLCIjEcrUlHcfsj+LXFoQ5t/BG59hC3Y5Rk2/awCo8HC2oz4lFaNNt4pGv 34 | zaDbTiECgYEA53QqVLV7FNBZd+YCnV2SWr4YsoTfounzs4Ro3koP1PRKt7RTerBV 35 | 2H1v8PsxbHibyGMlr6Lu8qpyUoSrC3w5eswbhvHsqF7lZiPfA/+yxDdcb0/JN8cp 36 | rTqLwR1Yh5XYuMsHTVMmPS5vcUxhBgmeALAzxB6sNAs4puS1I9IxrRECgYEAymor 37 | /+08p4NU4oP2l1oR8dBIR++da4LLUu4/GEhfkmcU+zugy0xVdl8pzHvdV2qvFOAz 38 | RBybgez7lBW7rj40/34Bs0fcM2J6FQlWkPjORKVMmyuaaREb8JWd56fIJJRrV51K 39 | aCthUvEUYhuY6vRc33CEoZS+0lE0MZrNEK7inI8CgYEAvTjoXqacAHExo+dEnfjg 40 | 7RTaxiABYYRY+5u1zH3KIbSy3Sss0HIXTM2IVgBW8LJN0e7U4ZmYNoYIvtO9rr8Z 41 | kv4JRzLD4wbqDq4m5nMGaIpGJK6a9+H4faoOlYvzU627J6C80Ie5DG3JKFxkOfZk 42 | 2XU0bRMSf93oq/Dw8l8mw7ECgYEAogKe2wYgYRduDqt+6J9v83M5F1LDVfTnFqaY 43 | m6/5xu14zqloRq//S3JZu1B81eYO4o+cmOyozzJGHr3SbWFe/Av4Am4G4p30hvfl 44 | cL2kIy+HBD+/JE9MZKDsNSmGuTiOPh8oGf52tHM/VFMwbwZNe43MqqOqpB3Yv8de 45 | UPcZbCMCgYB0Im6UAz6v0j1lPM7P3h8LmHbPiGAUGN5Wx9KmClvmiatxr4EFvX93 46 | lKry92i809q+CNe3nMWwijoICk1h0w86XXfHo/3GS3GehIPeD9i3lvDZm/iNsG59 47 | APP6QvNascmG0mqx/B4xaIqbKz2RUdk+nsob2jhJHbe1g6luYaUFdw== 48 | -----END RSA PRIVATE KEY----- 49 | -------------------------------------------------------------------------------- /settings.ac.txt: -------------------------------------------------------------------------------- 1 | # Settings File for AC. Lines beginning with # and blank lines will be ignored 2 | # 3 | # 4 | # 5 | 2 6 | 3 7 | 1 8 | # 9 | # 10 | 3 11 | 4 12 | 1 13 | # 14 | # 15 | 3 16 | 10 17 | 2 18 | # 19 | # 20 | 4 21 | 10 22 | 7 23 | 24 | 25 | 5543 26 | /tmp/ac_ipc_hostapd 27 | 28 | -------------------------------------------------------------------------------- /settings.wtp.txt: -------------------------------------------------------------------------------- 1 | # Settings File for WTP. Lines beginning with # and blank lines will be ignored 2 | # 3 | 4 | # 5 | mon.wlan0 6 | vmnet1 7 | wlan0 8 | vmnet1 9 | eth0 10 | 12345678 11 | 12345678 12 | 13 | 6333 14 | /tmp/wtp_ipc_hostapd 15 | 16 | 17 | # mon.wlan0 18 | # eth0 19 | # wlan0 20 | # lo 21 | # eth0 22 | # 12345678 23 | # 12345678 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /smac_code.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Sotiraq Sima (Sotiraq.Sima@gmail.com) * 22 | * * 23 | *******************************************************************************************/ 24 | 25 | #include 26 | #ifndef AC 27 | typedef unsigned char u8; 28 | typedef unsigned short u16; 29 | typedef unsigned int u32; 30 | #endif 31 | 32 | enum { 33 | ERROR = 0, 34 | 35 | CLOSE = 1, 36 | 37 | PING = 2, // [2]ping 38 | PONG = 3, // [3]pong 39 | 40 | /* only WTP */ 41 | 42 | START_WLAN = 4, 43 | START_WLAN_R = 5, 44 | 45 | STOP_WLAN = 6, 46 | STOP_WLAN_R = 7, 47 | 48 | SET_FREQ = 8, // FREQ sec_channel_offset ht_enabled channel MODE ex. "[8]2462 0 0 11 0" 49 | SET_FREQ_R = 9, // 0 or 1 ex. "[9]0" 50 | 51 | GET_FREQ = 10, // ex. "[10]" 52 | GET_FREQ_R = 11, // ex. "[11]2462 0 0 11 0" 53 | 54 | SET_FRAG = 12, // Typically the range used for fragmentation threshold is 256-2346 (-1 == off) ex. "[12]2000" 55 | SET_FRAG_R = 13, // ex. "[13]0" 56 | 57 | GET_FRAG = 14, // ex. "[14]" (-1 == off) 58 | GET_FRAG_R = 15, // ex. "[15]2000" 59 | 60 | SET_BITRATE = 16, 61 | SET_BITRATE_R = 17, 62 | 63 | GET_BITRATE = 18, 64 | GET_BITRATE_R = 19, 65 | 66 | SET_RTS = 20, // 0-2347 (-1 == off) ex. "[20]100" (-1 == off) 67 | SET_RTS_R = 21, // ex. "[21]0" 68 | 69 | GET_RTS = 22, // ex. "]22]" (-1 == off) 70 | GET_RTS_R = 23, // ex. "[23]100" 71 | 72 | SET_TXPOWER = 24, 73 | SET_TXPOWER_R = 25, 74 | 75 | GET_TXPOWER = 26, 76 | GET_TXPOWER_R = 27, 77 | 78 | /* 79 | * VO - 0 CWMIN:3 CWMAX:7 AIFS:2 80 | * VI - 1 CWMIN:7 CWMAX:15 AIFS:2 81 | * BE - 2 CWMIN:15 CWMAX:1023 AIFS:3 82 | * BK - 3 CWMIN:15 CWMAX:1023 AIFS:7 83 | */ 84 | SET_TXQ = 28, 85 | SET_TXQ_R = 29, 86 | 87 | GET_TXQ = 30, 88 | GET_TXQ_R = 31, 89 | 90 | SET_ADDR = 32, 91 | SET_ADDR_R = 33, 92 | 93 | DEL_ADDR = 34, 94 | DEL_ADDR_R = 35, 95 | 96 | ADD_WLAN = 36, 97 | ADD_WLAN_R = 37, 98 | 99 | DEL_WLAN = 38, 100 | DEL_WLAN_R = 39, 101 | 102 | WTPRINFO = 40, 103 | WTPRINFO_R = 41, 104 | 105 | GET_RATES = 42, 106 | GET_RATES_R = 43, 107 | 108 | GET_MDC = 44, 109 | GET_MDC_R = 45, 110 | 111 | SET_WTPRINFO = 46, 112 | SET_WTPRINFO_R = 47, 113 | 114 | SET_RATES = 48, 115 | SET_RATES_R = 49, 116 | 117 | SET_MDC = 50, 118 | SET_MDC_R = 51, 119 | 120 | GOLIVE = 52, 121 | GOLIVE_R = 53, 122 | 123 | WANT_GOLIVE = 54, 124 | HAVE_TO_WAIT = 55, 125 | 126 | GET_MAC = 56, 127 | GET_MAC_R = 57, 128 | 129 | SET_MAC = 58, 130 | SET_MAC_R = 59, 131 | 132 | //-------- 133 | 134 | DATE_TO_WTP = 100, 135 | DATE_TO_AC = 101, 136 | 137 | CONNECT = 102, 138 | CONNECT_R = 103, 139 | 140 | GOWAITWLAN = 104, 141 | GOWAITWLAN_R = 105, 142 | SEND_WLAN_TO_WTP = 106 143 | }; 144 | -------------------------------------------------------------------------------- /tap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Documentation/networking/tuntap.txt 3 | * 4 | */ 5 | 6 | #include "CWAC.h" 7 | #include "CWVendorPayloads.h" 8 | #include "CWFreqPayloads.h" 9 | #include "WUM.h" 10 | 11 | #include 12 | 13 | #ifdef DMALLOC 14 | #include "../dmalloc-5.5.0/dmalloc.h" 15 | #endif 16 | 17 | int tun_alloc(char *dev, int flags) 18 | { 19 | 20 | struct ifreq ifr; 21 | int fd, err; 22 | char *clonedev = "/dev/net/tun"; 23 | 24 | /* Arguments taken by the function: 25 | * 26 | * char *dev: the name of an interface (or '\0'). MUST have enough 27 | * space to hold the interface name if '\0' is passed 28 | * int flags: interface flags (eg, IFF_TUN etc.) 29 | */ 30 | 31 | /* open the clone device */ 32 | if ((fd = open(clonedev, O_RDWR)) < 0) { 33 | return fd; 34 | } 35 | 36 | /* preparation of the struct ifr, of type "struct ifreq" */ 37 | memset(&ifr, 0, sizeof(ifr)); 38 | 39 | ifr.ifr_flags = flags; /* IFF_TUN or IFF_TAP, plus maybe IFF_NO_PI */ 40 | 41 | if (*dev) { 42 | /* if a device name was specified, put it in the structure; otherwise, 43 | * the kernel will try to allocate the "next" device of the 44 | * specified type */ 45 | strncpy(ifr.ifr_name, dev, IFNAMSIZ); 46 | } 47 | 48 | /* try to create the device */ 49 | if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) { 50 | CWLog("Err to creater tap device"); 51 | close(fd); 52 | return err; 53 | } 54 | 55 | /* if the operation was successful, write back the name of the 56 | * interface to the variable "dev", so the caller can know 57 | * it. Note that the caller MUST reserve space in *dev (see calling 58 | * code below) */ 59 | strcpy(dev, ifr.ifr_name); 60 | 61 | /* this is the special file descriptor that the caller will use to talk 62 | * with the virtual interface */ 63 | return fd; 64 | } 65 | 66 | int init_AC_tap_interface(int WTPIndex) 67 | { 68 | sprintf(gWTPs[WTPIndex].tap_name, "wtp%d", WTPIndex); 69 | 70 | gWTPs[WTPIndex].tap_fd = tun_alloc(gWTPs[WTPIndex].tap_name, IFF_TAP | IFF_NO_PI); 71 | 72 | CWDebugLog("gWTPs[%d].tap_name %s,tap_fd %d", WTPIndex, gWTPs[WTPIndex].tap_name, gWTPs[WTPIndex].tap_fd); 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /tap.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica * 3 | * Universita' Campus BioMedico - Italy * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify it under the terms * 6 | * of the GNU General Public License as published by the Free Software Foundation; either * 7 | * version 2 of the License, or (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 | * * 13 | * You should have received a copy of the GNU General Public License along with this * 14 | * program; if not, write to the: * 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 16 | * MA 02111-1307, USA. * 17 | * * 18 | * --------------------------------------------------------------------------------------- * 19 | * Project: Capwap * 20 | * * 21 | * Author : Ludovico Rossi (ludo@bluepixysw.com) * 22 | * Del Moro Andrea (andrea_delmoro@libero.it) * 23 | * Giovannini Federica (giovannini.federica@gmail.com) * 24 | * Massimo Vellucci (m.vellucci@unicampus.it) * 25 | * Mauro Bisson (mauro.bis@gmail.com) * 26 | *******************************************************************************************/ 27 | 28 | #ifndef __AC_TAP_H__ 29 | #define __AC_TAP_H__ 30 | 31 | int init_AC_tap_interface(int WTPIndex); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /timerlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A * 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 17 | * 18 | * Author(s): Mauro Bisson 19 | */ 20 | 21 | /* 22 | * This C module implements a simple timer library. 23 | */ 24 | 25 | #ifndef TIMERLIB_H 26 | #define TIMERLIB_H 27 | 28 | /* 29 | * Initializes the timer library. It is important that the calling thread and 30 | * any other thread in the process block the signal SIGALRM. 31 | * 32 | * Return: 1 in case of success; 0 otherwise. 33 | */ 34 | int timer_init(); 35 | 36 | /* 37 | * Tears down any data allocated for the library. 38 | */ 39 | void timer_destroy(); 40 | 41 | /* 42 | * Adds a timer to expire "sec" seconds + "usec" milliseconds after the 43 | * invocation. When the timer will expire, function "hndlr" will be executed 44 | * with arg "hndlr_arg". The id of the timer (>=0) is returned. 45 | * 46 | * Return: id>=0 in case of success; -1 in case of error. 47 | * 48 | * Remarks: sec and usec must define a future time relative to "now". If 49 | * one is negative or both equal zero the funtion will return -1. The 50 | * library don't manipulate in any way the address pointed by "hndlr_arg", 51 | * it is responsibility of the calling thread to free any memory, if 52 | * allocated (a good place is at the end of "hndlr" function or when calling 53 | * "timer_rem()" ;). 54 | * There is no costraint about relative time definition, you can set a two 55 | * second timer as (sec,usec)=(2,0) or (sec,usec)=(0,2000000). 56 | * Since this library implementation do not rely on "sigaction()" syscall, 57 | * inside "hndlr" it is perfectly legal to call any not signal safe and 58 | * pthread_* function. The only limitation is that timer_destroy() MUST 59 | * NOT be called inside hndlr. 60 | * Note that this fuction can be called inside "hndlr" to create 61 | * "chain timers". 62 | */ 63 | int timer_add(long /*sec */ , long /*usec */ , void (* /*hndlr */ )(void *), 64 | void * /*hndlr_arg */ ); 65 | 66 | /* 67 | * Remove from the queue the timer of identifier "id", if it retured 68 | * from a previous succesful call to timer_add(). The function 69 | * "free_arg" is called with the handler argument specified in "timer_add" 70 | * call. It should be used to free the memory when the timer is destroyed 71 | * before expiring. 72 | * 73 | * Remarks: if "id" is a value not returned by timer_add() nothing happens. 74 | */ 75 | void timer_rem(int /*id */ , void (* /*free_arg */ )(void *)); 76 | 77 | /* 78 | * Prints the content of the timer queue (do not use, it's for debug purpose). 79 | */ 80 | void timer_print(); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /wum/Makefile: -------------------------------------------------------------------------------- 1 | wum: wum.o wumLib.o 2 | clean: 3 | rm -rf wum *.o 4 | -------------------------------------------------------------------------------- /wum/README: -------------------------------------------------------------------------------- 1 | WUM - WTP Update Manager 2 | 3 | Wum (WTP Update Manager) is the command line tool used to send update 4 | requests to the WTPs. Of course it is executed on the AC machine and interacts 5 | with the AC Interface. 6 | 7 | To compile it, just run 'make'. 8 | 9 | For further details about how to use it, refer to the document WTPUpdateSystem.pdf 10 | in the docs sub-directory of this source tree. 11 | -------------------------------------------------------------------------------- /wum/wumLib.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #define QUIT_MSG 0 5 | #define LIST_MSG 1 6 | #define CONF_UPDATE_MSG 2 7 | 8 | #define MSG_ELEMENT_TYPE_VENDOR_WUM 3 9 | 10 | #define WTP_VERSION_REQUEST 1 11 | #define WTP_VERSION_RESPONSE 2 12 | 13 | #define WTP_UPDATE_REQUEST 3 14 | #define WTP_UPDATE_RESPONSE 4 15 | 16 | #define WTP_CUP_FRAGMENT 5 17 | #define WTP_CUP_ACK 6 18 | 19 | #define WTP_COMMIT_UPDATE 7 20 | #define WTP_COMMIT_ACK 8 21 | 22 | #define WTP_CANCEL_UPDATE_REQUEST 9 23 | #define WTP_CANCEL_UPDATE_RESPONSE 10 24 | 25 | #define SUCCESS 0 26 | #define ERROR 1 27 | 28 | #define FRAGMENT_SIZE 4000 29 | 30 | struct WTPInfo { 31 | int wtpId; 32 | char *name; 33 | }; 34 | 35 | struct version_info { 36 | char major; 37 | char minor; 38 | char revision; 39 | int size; 40 | }; 41 | 42 | int ACServerConnect(char *address, int port); 43 | void ACServerDisconnect(int acserver); 44 | struct WTPInfo *ACServerWTPList(int acserver, int *nWTPs); 45 | void freeWTPList(struct WTPInfo *wtpList, int nWTPs); 46 | 47 | int WUMGetWTPVersion(int acserver, int wtpId, struct version_info *); 48 | int WUMReadCupVersion(char *cup_pathname, struct version_info *update_v); 49 | int WUMUpdate(int acserver, int wtpId, void *cup_buf, struct version_info update_v); 50 | int WUMSendCancelRequest(int acserver, int wtpId); 51 | --------------------------------------------------------------------------------