master 1c1984d6cf7f cached
167 files
2.2 MB
579.5k tokens
1646 symbols
1 requests
Download .txt
Showing preview only (2,317K chars total). Download the full file or copy to clipboard to get everything.
Repository: iosifpeterfi/openCAPWAP-OpenWRT
Branch: master
Commit: 1c1984d6cf7f
Files: 167
Total size: 2.2 MB

Directory structure:
gitextract_iujx8crt/

├── .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
├── 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
│   ├── 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
├── 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/
    ├── README
    ├── wum.c
    ├── wumLib.c
    └── wumLib.h

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*~
*.o
*.lo
*.la
m4
.deps
.libs

#
# binaries
#
AC
WTP
WUA

#
# autoconf files
#
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
stamp-h1


================================================
FILE: AC.c
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#include "CWAC.h"
#include "CWCommon.h"
#include "tap.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

/*_________________________________________________________*/
/*  *******************___VARIABLES___*******************  */
CWThreadMutex gCreateIDMutex;

/* array that stores per WTPs infos */
CWWTPManager gWTPs[CW_MAX_WTP];
CWThreadMutex gWTPsMutex;

int gEnabledLog;
int gMaxLogFileSize;
char gLogFileName[] = AC_LOG_FILE_NAME;

/* number of active WTPs */
int gActiveWTPs = 0;
CWThreadMutex gActiveWTPsMutex;

/* max WTPs */
int gMaxWTPs;
/* The Radio MAC Field of the discovery response */
int gRMACField = 2;
/* The Wireless Field of the discovery response */
int gWirelessField = 0;
/* DTLS Policy for data channel */
int gDTLSPolicy = DTLS_ENABLED_DATA;
/* special socket to handle multiple network interfaces */
CWMultiHomedSocket gACSocket;
/* AC's network interfaces */
CWProtocolNetworkInterface *gInterfaces = NULL;
int gInterfacesCount = 0;
/* DTLS Context */
CWSecurityContext gACSecurityContext;
int gActiveStations = 0;
/* max stations */
int gLimit;
char **gMulticastGroups;
int gMulticastGroupsCount;
CWAuthSecurity gACDescriptorSecurity;
int gACHWVersion;
int gACSWVersion;
char *gACName = NULL;

int gDiscoveryTimer = 20;
int gEchoRequestTimer = CW_ECHO_INTERVAL_DEFAULT;
/* PROVVISORIO: Il valore e' scelto a caso */
int gIdleTimeout = 10;

/*_________________________________________________________*/
/*  *******************___FUNCTIONS___*******************  */

void usage(void)
{
}

int main(int argc, char * const argv[])
{
	int run_daemon = 1;
	int c;

#ifdef CW_DEBUGGING
	const struct rlimit rlim = {
		.rlim_cur = RLIM_INFINITY,
		.rlim_max = RLIM_INFINITY
	};

	/* unlimited size for cores */
	setrlimit(RLIMIT_CORE, &rlim);
#endif

	while (-1 != (c = getopt(argc, argv, "hf"))) {
		switch(c) {
		case 'h':
			usage();
			exit(1);
			break;

		case 'f':
			run_daemon = 0;
			break;

		default:
			usage();
			exit(1);
			break;
		}
	}

	/* Daemon Mode */
	if (run_daemon)
		if (daemon(1, 0) != 0) {
			fprintf(stderr, "daemon failed: %s\n", strerror(errno));
			exit(1);

		}

	CWACInit();
	CWCreateConnectionWithHostapdAC();
	CWACEnterMainLoop();
	CWACDestroy();
	CWLogCloseFile();

	return 0;
}

int CWACSemPostForOpenSSLHack(void *s)
{

	CWThreadTimedSem *semPtr = (CWThreadTimedSem *) s;

	if (!CWThreadTimedSemIsZero(semPtr)) {
		CWLog("This Semaphore's Value should really be 0");
		/* note: we can consider setting the value to 0 and going on,
		 * that is what we do here
		 */
		if (!CWErr(CWThreadTimedSemSetValue(semPtr, 0)))
			return 0;
	}

	if (!CWErr(CWThreadTimedSemPost(semPtr))) {
		return 0;
	}

	return 1;
}

void CWACInit()
{
	int i;
	CWNetworkLev4Address *addresses = NULL;
	struct sockaddr_in *IPv4Addresses = NULL;

	CWLogInitFile(AC_LOG_FILE_NAME);

#ifndef CW_SINGLE_THREAD
	CWDebugLog("Use Threads");
#else
	CWDebugLog("Don't Use Threads");
#endif

	CWErrorHandlingInitLib();

	if (!CWParseSettingsFile()) {
		fprintf(stderr,"Can't load AC settings file\n");
		exit(1);
	}


	CWThreadSetSignals(SIG_BLOCK, 1, SIGALRM);
	if (timer_init() == 0) {
		fprintf(stderr,"Can't init timer module\n");
		exit(1);
	}

        if (!CWErr(CWParseConfigFile())) {
                /* error starting */
                fprintf(stderr,"Can't load AC config file\n");
                exit(1);
        }

        CWDebugLog("Starting AC");
        CWDebugLog("Waiting for WTPs to enter join state");
        sleep(CW_NEIGHBORDEAD_INTERVAL_DEFAULT+CW_ECHO_INTERVAL_DEFAULT);

	if (
#ifndef CW_NO_DTLS
	    !CWErr(CWSecurityInitLib()) ||
#endif
	    !CWErr(CWNetworkInitSocketServerMultiHomed
		   (&gACSocket, CW_CONTROL_PORT, gMulticastGroups, gMulticastGroupsCount))
	    || !CWErr(CWNetworkGetInterfaceAddresses(&gACSocket, &addresses, &IPv4Addresses))
	    || !CWErr(CWCreateThreadMutex(&gWTPsMutex)) || !CWErr(CWCreateThreadMutex(&gActiveWTPsMutex))) {

		/* error starting */
		CWLog("Can't start AC");
		exit(1);
	}
#ifndef CW_NO_DTLS
	if (gACDescriptorSecurity == CW_X509_CERTIFICATE) {

		if (!CWErr(CWSecurityInitContext(&gACSecurityContext,
						 "root.pem",
						 "server.pem", "prova", CW_FALSE, CWACSemPostForOpenSSLHack))) {

			CWLog("Can't start AC");
			exit(1);
		}
	} else {		/* preshared */
		if (!CWErr(CWSecurityInitContext(&gACSecurityContext,
						 NULL, NULL, NULL, CW_FALSE, CWACSemPostForOpenSSLHack))) {
			CWLog("Can't start AC");
			exit(1);
		}
	}
#endif
	CW_FREE_OBJECTS_ARRAY(gMulticastGroups, gMulticastGroupsCount);

	for (i = 0; i < gMaxWTPs; i++) {
		gWTPs[i].isNotFree = CW_FALSE;

		if (!gWTPs[i].tap_fd) {
			init_AC_tap_interface(i);
		}

	}

	/* store network interface's addresses */
	gInterfacesCount = CWNetworkCountInterfaceAddresses(&gACSocket);
	CWLog("Found %d Network Interface(s)", gInterfacesCount);

	if (gInterfacesCount <= 0) {
		CWLog("Can't start AC");
		exit(1);
	}

	CW_CREATE_ARRAY_ERR(gInterfaces, gInterfacesCount, CWProtocolNetworkInterface, CWLog("Out of Memory");
			    return;
	    );

	for (i = 0; i < gInterfacesCount; i++) {
		gInterfaces[i].WTPCount = 0;
		CW_COPY_NET_ADDR_PTR(&(gInterfaces[i].addr), ((CWNetworkLev4Address *) & ((addresses)[i])));
		if (IPv4Addresses != NULL) {
			CW_COPY_NET_ADDR_PTR(&(gInterfaces[i].addrIPv4), &((IPv4Addresses)[i]));
		}
	}
	CW_FREE_OBJECT(addresses);
	CW_FREE_OBJECT(IPv4Addresses);

	if (!CWErr(CWCreateThreadMutex(&gCreateIDMutex))) {
		exit(1);
	}

	CWLog("AC Started");
}

void CWCreateConnectionWithHostapdAC()
{

	CWThread thread_ipc_with_ac_hostapd;
	if (!CWErr(CWCreateThread(&thread_ipc_with_ac_hostapd, CWACipc_with_ac_hostapd, NULL))) {
		CWLog("Error starting Thread that receive command and 802.11 frame from hostapd (WTP side)");
		exit(1);
	}

}

void CWACDestroy()
{

	CWNetworkCloseMultiHomedSocket(&gACSocket);

	/*
	   for(i = 0; i < CW_MAX_WTP; i++) {
	   //CW_FREE_OBJECT(gWTPs[i].addr);
	   }
	 */

#ifndef CW_NO_DTLS
	CWSslCleanUp();
#endif

	CWDestroyThreadMutex(&gWTPsMutex);
	CWDestroyThreadMutex(&gCreateIDMutex);
	CWDestroyThreadMutex(&gActiveWTPsMutex);

	CW_FREE_OBJECT(gACName);
	CW_FREE_OBJECT(gInterfaces);

	CWLog("AC Destroyed");
}

unsigned int CWGetSeqNum()
{

	static unsigned int seqNum = 0;
	unsigned int r;

	if (!CWThreadMutexLock(&gCreateIDMutex)) {

		CWDebugLog("Error Locking a mutex");
	}

	r = seqNum;

	if (seqNum == CW_MAX_SEQ_NUM)
		seqNum = 0;
	else
		seqNum++;

	CWThreadMutexUnlock(&gCreateIDMutex);
	return r;
}

int CWGetFragmentID()
{

	static int fragID = 0;
	int r;

	if (!CWThreadMutexLock(&gCreateIDMutex)) {

		CWDebugLog("Error Locking a mutex");
	}

	r = fragID;

	if (fragID == CW_MAX_FRAGMENT_ID)
		fragID = 0;
	else
		fragID++;

	CWThreadMutexUnlock(&gCreateIDMutex);
	return r;
}


================================================
FILE: ACAppsProtocol.h
================================================
/*
 *  appsToAcProtocol.h
 *
 *
 *  Created by Antonio Davoli on 03/03/09.
 *  Copyright 2009 La Sapienza. All rights reserved.
 *
 */

/* Macro Definition */

/* AC Request Message */

/****************************************
 *  For LIST, QUIT (without argument)   *
 *                                      *
 *      0               7               *
 *      +-+-+-+-+-+-+-+-+               *
 *      |    Cmd_msg    |               *
 *      +-+-+-+-+-+-+-+-+               *
 *                                      *
 ****************************************/

/* CMD_MSG Types */

#define FULL_CLIENT_CONNECTED -1
#define CONNECTION_OK 1
#define QUIT_MSG 0
#define LIST_MSG 1
#define CONF_UPDATE_MSG 2

/********************************************************************************************************************************
 * List Response Message:                                                                                                       *
 *                                                                                                                              *
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   *
 *  |   Active#   |    WTP_ID 1   | NameLength 1  |   WTP Name 1    | ... |    WTP ID N   | NameLength N  |   WTP Name N    |   *
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   *
 *                                                                                                                              *
 *  where N is equal to Active# (Number of Active WTPs)                                                                         *
 ********************************************************************************************************************************/

/********************************************************************************************************
 * For CONF_UPDATE_MSG type:                                                                            *
 *                                                                                                      *
 *      0              7               15              23                                    X          *
 *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         *
 *      |    cmd_msg    |    msg_elem   |   WPT Index   |       Message Specific Payload      |         *
 *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         *
 *                                                                                                      *
 ********************************************************************************************************/

#define PAYLOAD_START ((sizeof(unsigned char)*2) + sizeof(int))
#define ALL_ACTIVE_WTPS -1

#define MSG_ELEMENT_TYPE_OFDM 1
#define MSG_ELEMENT_TYPE_VENDOR_UCI 2
#define MSG_ELEMENT_TYPE_VENDOR_WUM 3

/****************************************************************************************
 * Message Specific Payload for MSG_ELEMENT_TYPE_OFDM TYPE (802.11 Binding Version)     *
 *                                                                                      *
 *      0                   1                   2                   3                   *
 *      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1                 *
 *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               *
 *      |    Radio ID   |    Reserved   | Current Chan  |  Band Support |               *
 *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               *
 *      |                         TI Threshold                          |               *
 *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               *
 *                                                                                      *
 ****************************************************************************************/

/* Radio ID is filled in the creation message funcion (inside the AC) */


================================================
FILE: ACBinding.c
================================================
/************************************************************************************************
 * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica   *
 *                          Universita' Campus BioMedico - Italy                                *
 *                                                                                              *
 * This program is free software; you can redistribute it and/or modify it under the terms      *
 * of the GNU General Public License as published by the Free Software Foundation; either       *
 * version 2 of the License, or (at your option) any later version.                             *
 *                                                                                              *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY              *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A              *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                     *
 *                                                                                              *
 * You should have received a copy of the GNU General Public License along with this            *
 * program; if not, write to the:                                                               *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                         *
 * MA  02111-1307, USA.                                                                         *
 *                                                                                              *
 * -------------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                             *
 *                                                                                              *
 * Authors : Ludovico Rossi (ludo@bluepixysw.com)                                               *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                         *
 *           Giovannini Federica (giovannini.federica@gmail.com)                                *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                         *
 *           Mauro Bisson (mauro.bis@gmail.com)                                                 *
 *           Daniele De Sanctis (danieledesanctis@gmail.com)                                    *
 *           Antonio Davoli (antonio.davoli@gmail.com)                                          *
 ************************************************************************************************/

#include "CWAC.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

CWBool CWACInitBinding(int i)
{
	int j;
	bindingValues *aux;

	CW_CREATE_OBJECT_ERR(aux, bindingValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	(gWTPs[i].WTPProtocolManager).bindingValuesPtr = (void *)aux;

	CW_CREATE_ARRAY_ERR(aux->qosValues, NUM_QOS_PROFILES, WTPQosValues,
			    return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	//Init default values
	for (j = 0; j < NUM_QOS_PROFILES; j++) {
		aux->qosValues[j].cwMin = gDefaultQosValues[j].cwMin;
		aux->qosValues[j].cwMax = gDefaultQosValues[j].cwMax;
		aux->qosValues[j].AIFS = gDefaultQosValues[j].AIFS;

		aux->qosValues[j].queueDepth = 0;
		aux->qosValues[j].dot1PTag = 0;
		aux->qosValues[j].DSCPTag = 0;
	}

	return CW_TRUE;
}

CWBool CWMergeQosValues(int WTPIndex)
{
	int i;
	bindingValues *aux;

	aux = (bindingValues *) (gWTPs[WTPIndex].WTPProtocolManager).bindingValuesPtr;

	for (i = 0; i < NUM_QOS_PROFILES; i++) {
		if (gWTPs[WTPIndex].qosValues[i].cwMin == UNUSED_QOS_VALUE) {
			gWTPs[WTPIndex].qosValues[i].cwMin = aux->qosValues[i].cwMin;
		}

		if (gWTPs[WTPIndex].qosValues[i].cwMax == UNUSED_QOS_VALUE) {
			gWTPs[WTPIndex].qosValues[i].cwMax = aux->qosValues[i].cwMax;
		}

		if (gWTPs[WTPIndex].qosValues[i].AIFS == UNUSED_QOS_VALUE) {
			gWTPs[WTPIndex].qosValues[i].AIFS = aux->qosValues[i].AIFS;
		}
	}
	return CW_TRUE;
}

/******************************************************************
 * 2009 Updates:                                                  *
 *              Functions for management of Configuration Update  *
 *              Request with OFDM Message Element                 *
 ******************************************************************/

CWBool CWMergeOFDMValues(int WTPIndex)
{

	OFDMControlValues *aux;

	aux = (OFDMControlValues *) (gWTPs[WTPIndex].WTPProtocolManager).bindingValuesPtr;

	if (gWTPs[WTPIndex].ofdmValues->currentChan == UNUSED_OFDM_VALUE)
		gWTPs[WTPIndex].ofdmValues->currentChan = aux->currentChan;

	if (gWTPs[WTPIndex].ofdmValues->BandSupport == UNUSED_OFDM_VALUE)
		gWTPs[WTPIndex].ofdmValues->BandSupport = aux->BandSupport;

	if (gWTPs[WTPIndex].ofdmValues->TIThreshold == UNUSED_OFDM_VALUE)
		gWTPs[WTPIndex].ofdmValues->TIThreshold = aux->TIThreshold;

	return CW_TRUE;
}

CWBool CWAssembleWTPOFDM(CWProtocolMessage * msgPtr, int radioID)
{
	const int totalMessageLength = BINDING_MSG_ELEMENT_TYPE_OFDM_CONTROL_LENGTH;
	int *iPtr;
	OFDMControlValues *valuesPtr;

	CWLog("Assembling Binding Configuration Update Request [OFDM CASE]...");

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {
		return CW_FALSE;
	}

	if (!CWMergeOFDMValues(*iPtr)) {
		return CW_FALSE;
	}

	valuesPtr = gWTPs[*iPtr].ofdmValues;

	/* create message */
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, totalMessageLength, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStore8(msgPtr, radioID);
	CWProtocolStore32(msgPtr, valuesPtr->currentChan);
	CWProtocolStore8(msgPtr, valuesPtr->BandSupport);
	CWProtocolStore32(msgPtr, valuesPtr->TIThreshold);

	CWLog("Assembling Binding Configuration Update Request [OFDM CASE]: Message Assembled.");

	return CWAssembleMsgElem(msgPtr, BINDING_MSG_ELEMENT_TYPE_OFDM_CONTROL);
}

CWBool CWAssembleWTPQoS(CWProtocolMessage * msgPtr, int radioID, int tagPackets)
{
	const int headerLength = 2;
	const int messageBodyLength = 32;
	const int totalMessageLength = headerLength + messageBodyLength;
	int i;
	int *iPtr;
	WTPQosValues *valuesPtr;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {
		return CW_FALSE;
	}
	if (!CWMergeQosValues(*iPtr)) {
		return CW_FALSE;
	}

	valuesPtr = gWTPs[*iPtr].qosValues;

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, totalMessageLength, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStore8(msgPtr, radioID);
	CWProtocolStore8(msgPtr, tagPackets);

	for (i = 0; i < NUM_QOS_PROFILES; i++) {
		CWProtocolStore8(msgPtr, valuesPtr[i].queueDepth);
		CWProtocolStore16(msgPtr, valuesPtr[i].cwMin);
		CWProtocolStore16(msgPtr, valuesPtr[i].cwMax);
		CWProtocolStore8(msgPtr, valuesPtr[i].AIFS);
		CWProtocolStore8(msgPtr, valuesPtr[i].dot1PTag);
		CWProtocolStore8(msgPtr, valuesPtr[i].DSCPTag);
	}

	return CWAssembleMsgElem(msgPtr, BINDING_MSG_ELEMENT_TYPE_WTP_QOS);
}

CWBool CWBindingAssembleConfigureResponse(CWProtocolMessage ** msgElems, int *msgElemCountPtr)
{
	CWWTPRadiosInfo radiosInfo;
	int *iPtr;
	const int tagPackets = 0;
	int k = -1, radioCount, radioID, j;

	if (msgElems == NULL || msgElemCountPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {
		return CW_FALSE;
	}
	//Calculate the number of msg Elements
	*msgElemCountPtr = 0;
	radiosInfo = gWTPs[*iPtr].WTPProtocolManager.radiosInfo;
	radioCount = radiosInfo.radioCount;
	*msgElemCountPtr = radioCount;

	CWLog("Assembling Binding Configuration Response...");

	//Reserve memory for msg Elements
	CW_CREATE_PROTOCOL_MSG_ARRAY_ERR(*msgElems, *msgElemCountPtr, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	if (!CWThreadMutexLock(&(gWTPs[*iPtr].interfaceMutex))) {
		CWLog("Error locking a mutex");
		CWCloseThread();
	}
	//Fill gWTPs[*iPtr].qosValues with default settings
	gWTPs[*iPtr].qosValues = gDefaultQosValues;

	for (j = 0; j < radioCount; j++) {
		radioID = radiosInfo.radiosInfo[j].radioID;
		// Assemble WTP QoS Message Element for each radio
		if (!(CWAssembleWTPQoS(&(*msgElems[++k]), radioID, tagPackets))) {
			int i;
			for (i = 0; i <= k; i++) {
				CW_FREE_PROTOCOL_MESSAGE(*msgElems[i]);
			}
			CW_FREE_OBJECT(*msgElems);
			CWThreadMutexUnlock(&(gWTPs[*iPtr].interfaceMutex));
			return CW_FALSE;	// error will be handled by the caller
		}
	}

	gWTPs[*iPtr].qosValues = NULL;
	CWThreadMutexUnlock(&(gWTPs[*iPtr].interfaceMutex));

	CWLog("Binding Configuration Response Assembled");

	return CW_TRUE;
}

/******************************************************************
 * 2009 Updates:                                                  *
 *              Added new switch case for ofdm message management *
 ******************************************************************/

CWBool CWBindingAssembleConfigurationUpdateRequest(CWProtocolMessage ** msgElems, int *msgElemCountPtr,
						   int BindingMsgElement)
{
	CWWTPRadiosInfo radiosInfo;
	int *iPtr;
	const int tagPackets = 0;
	int k = -1, radioCount, radioID, j;

	if (msgElems == NULL || msgElemCountPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {
		return CW_FALSE;
	}

	*msgElemCountPtr = 0;

	radiosInfo = gWTPs[*iPtr].WTPProtocolManager.radiosInfo;
	radioCount = radiosInfo.radioCount;
	*msgElemCountPtr = radioCount;

	CWLog("Assembling Binding Configuration Update Request...");

	CW_CREATE_PROTOCOL_MSG_ARRAY_ERR(*msgElems, *msgElemCountPtr, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	/* Selection of type of Conf Update Request */

	switch (BindingMsgElement) {
	case BINDING_MSG_ELEMENT_TYPE_WTP_QOS:{
			for (j = 0; j < radioCount; j++) {
				radioID = radiosInfo.radiosInfo[j].radioID;

				// Assemble Message Elements
				if (!(CWAssembleWTPQoS(&(*msgElems[++k]), radioID, tagPackets))) {
					int i;
					for (i = 0; i <= k; i++) {
						CW_FREE_PROTOCOL_MESSAGE(*msgElems[i]);
					}
					CW_FREE_OBJECT(*msgElems);
					return CW_FALSE;	// error will be handled by the caller
				}
			}
			break;
		}
	case BINDING_MSG_ELEMENT_TYPE_OFDM_CONTROL:{
			for (j = 0; j < radioCount; j++) {
				radioID = radiosInfo.radiosInfo[j].radioID;

				/* Assemble Message Elements */
				if (!(CWAssembleWTPOFDM(&(*msgElems[++k]), radioID))) {
					int i;
					for (i = 0; i <= k; i++) {
						CW_FREE_PROTOCOL_MESSAGE(*msgElems[i]);
					}
					CW_FREE_OBJECT(*msgElems);
					return CW_FALSE;	// error will be handled by the caller
				}
			}
			break;
		}
	default:{
			return CW_FALSE;	// error will be handled by the caller
		}
	}

	CWLog("Binding Configuration Update Request Assembled");

	return CW_TRUE;
}

CWBool CWBindingSaveConfigurationUpdateResponse(CWProtocolResultCode resultCode, int WTPIndex)
{
	int i;

	bindingValues *aux = (bindingValues *) gWTPs[WTPIndex].WTPProtocolManager.bindingValuesPtr;

	if (resultCode == CW_PROTOCOL_SUCCESS) {
		if (gWTPs[WTPIndex].qosValues != NULL) {
			for (i = 0; i < NUM_QOS_PROFILES; i++) {
				aux->qosValues[i].cwMin = gWTPs[WTPIndex].qosValues[i].cwMin;
				aux->qosValues[i].cwMax = gWTPs[WTPIndex].qosValues[i].cwMax;
				aux->qosValues[i].AIFS = gWTPs[WTPIndex].qosValues[i].AIFS;
			}
		}
	}

	return CW_TRUE;
}


================================================
FILE: ACBinding.h
================================================
/************************************************************************************************
 * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica   *
 *                          Universita' Campus BioMedico - Italy                                *
 *                                                                                              *
 * This program is free software; you can redistribute it and/or modify it under the terms      *
 * of the GNU General Public License as published by the Free Software Foundation; either       *
 * version 2 of the License, or (at your option) any later version.                             *
 *                                                                                              *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY              *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A              *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                     *
 *                                                                                              *
 * You should have received a copy of the GNU General Public License along with this            *
 * program; if not, write to the:                                                               *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                         *
 * MA  02111-1307, USA.                                                                         *
 *                                                                                              *
 * -------------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                             *
 *                                                                                              *
 * Authors : Ludovico Rossi (ludo@bluepixysw.com)                                               *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                         *
 *           Giovannini Federica (giovannini.federica@gmail.com)                                *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                         *
 *           Mauro Bisson (mauro.bis@gmail.com)                                                 *
 *           Antonio Davoli (antonio.davoli@gmail.com)                                          *
 ************************************************************************************************/

#ifndef __CAPWAP_ACBinding_HEADER__
#define __CAPWAP_ACBinding_HEADER__

CWBool CWACInitBinding(int i);
CWBool CWBindingAssembleConfigureResponse(CWProtocolMessage ** msgElems, int *msgElemCountPtr);
/****************************************************
 * 2009 Update:                                     *
 * The field BindingMsgElement has been added for   *
 * the multiple type of Message Element.            *
 ****************************************************/
CWBool CWBindingAssembleConfigurationUpdateRequest(CWProtocolMessage ** msgElems, int *msgElemCountPtr,
						   int BindingMsgElement);
CWBool CWBindingSaveConfigurationUpdateResponse(CWProtocolResultCode resultCode, int WTPIndex);

#endif


================================================
FILE: ACConfigFile.c
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#include "CWAC.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

const char *CW_CONFIG_FILE = "/etc/capwap/config.ac";

CWBool CWConfigFileInitLib()
{

	gConfigValuesCount = 11;

	CW_CREATE_ARRAY_ERR(gConfigValues,
			    gConfigValuesCount, CWConfigValue, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	gConfigValues[0].type = CW_INTEGER;
	gConfigValues[0].code = "</AC_HW_VERSION>";
	gConfigValues[0].value.int_value = 0;

	gConfigValues[1].type = CW_INTEGER;
	gConfigValues[1].code = "</AC_SW_VERSION>";
	gConfigValues[1].value.int_value = 0;

	gConfigValues[2].type = CW_INTEGER;
	gConfigValues[2].code = "</AC_MAX_STATIONS>";
	gConfigValues[2].value.int_value = 0;

	gConfigValues[3].type = CW_INTEGER;
	gConfigValues[3].code = "</AC_MAX_WTPS>";
	gConfigValues[3].value.int_value = 0;

	gConfigValues[4].type = CW_STRING;
	gConfigValues[4].code = "</AC_SECURITY>";
	gConfigValues[4].value.str_value = NULL;

	gConfigValues[5].type = CW_STRING;
	gConfigValues[5].code = "</AC_NAME>";
	gConfigValues[5].value.str_value = NULL;

	gConfigValues[6].type = CW_STRING_ARRAY;
	gConfigValues[6].code = "<AC_MCAST_GROUPS>";
	gConfigValues[6].endCode = "</AC_MCAST_GROUPS>";
	gConfigValues[6].value.str_array_value = NULL;
	gConfigValues[6].count = 0;

	gConfigValues[7].type = CW_INTEGER;
	gConfigValues[7].code = "</AC_FORCE_MTU>";
	gConfigValues[7].value.int_value = 0;

	gConfigValues[8].type = CW_STRING;
	gConfigValues[8].code = "</AC_LEV3_PROTOCOL>";
	gConfigValues[8].value.str_value = NULL;

	gConfigValues[9].type = CW_INTEGER;
	gConfigValues[9].code = "</AC_LOG_FILE_ENABLE>";
	gConfigValues[9].value.int_value = 0;

	gConfigValues[10].type = CW_INTEGER;
	gConfigValues[10].code = "</AC_LOG_FILE_SIZE>";
	gConfigValues[10].value.int_value = DEFAULT_LOG_SIZE;

	return CW_TRUE;
}

CWBool CWConfigFileDestroyLib()
{

	int i;

	/* save the preferences we read */
	gACHWVersion = gConfigValues[0].value.int_value;
	gACSWVersion = gConfigValues[1].value.int_value;
	gLimit = gConfigValues[2].value.int_value;
	gMaxWTPs = gConfigValues[3].value.int_value;

#ifndef CW_NO_DTLS
	if (gConfigValues[4].value.str_value != NULL && !strcmp(gConfigValues[4].value.str_value, "PRESHARED")) {
		gACDescriptorSecurity = CW_PRESHARED;
	} else {
		/* default */
		gACDescriptorSecurity = CW_X509_CERTIFICATE;
	}
#endif

	if (gConfigValues[5].value.str_value != NULL) {

		CW_CREATE_STRING_FROM_STRING_ERR(gACName,
						 (gConfigValues[5].value.str_value),
						 return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		//CW_FREE_OBJECT(gACName);
	}

	/* avoid to allocate 0 bytes */
	if (gConfigValues[6].count) {

		CW_CREATE_ARRAY_ERR(gMulticastGroups, gConfigValues[6].count, char *,
				    return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );

		for (i = 0; i < gConfigValues[6].count; i++) {

			CW_CREATE_STRING_FROM_STRING_ERR(gMulticastGroups[i],
							 (gConfigValues[6].value.str_array_value)[i],
							 return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
			    );
		}
	}

	gMulticastGroupsCount = gConfigValues[6].count;
	CW_PRINT_STRING_ARRAY(gMulticastGroups, gMulticastGroupsCount);

	gCWForceMTU = gConfigValues[7].value.int_value;

	if (gConfigValues[8].value.str_value != NULL && !strcmp(gConfigValues[8].value.str_value, "IPv6")) {

		gNetworkPreferredFamily = CW_IPv6;
	} else {
		/* default */
		gNetworkPreferredFamily = CW_IPv4;
	}

	for (i = 0; i < gConfigValuesCount; i++) {
		if (gConfigValues[i].type == CW_STRING) {
			CW_FREE_OBJECT(gConfigValues[i].value.str_value);
		} else if (gConfigValues[i].type == CW_STRING_ARRAY) {
			CW_FREE_OBJECTS_ARRAY((gConfigValues[i].value.str_array_value), gConfigValues[i].count);
		}
	}

	gEnabledLog = gConfigValues[9].value.int_value;
	gMaxLogFileSize = gConfigValues[10].value.int_value;

	CW_FREE_OBJECT(gConfigValues);

	return CW_TRUE;
}


================================================
FILE: ACConfigureState.c
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#include "CWAC.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

int gCWChangeStatePendingTimer = CW_CHANGE_STATE_INTERVAL_DEFAULT;

CWBool CWAssembleConfigureResponse(CWProtocolMessage ** messagesPtr, int *fragmentsNumPtr, int PMTU, int seqNum);

CWBool CWParseConfigureRequestMessage(unsigned char *msg,
				      int len,
				      int *seqNumPtr,
				      CWProtocolConfigureRequestValues * valuesPtr, unsigned char *, unsigned char *, char *, int);

CWBool CWSaveConfigureRequestMessage(CWProtocolConfigureRequestValues * configureRequest,
				     CWWTPProtocolManager * WTPProtocolManager);

CWBool ACEnterConfigure(int WTPIndex, CWProtocolMessage * msgPtr)
{

	/*** tmp Radio Info ***/
	unsigned char tmp_RadioInformationABGN;
	unsigned char tmp_SuppRates[8];
	char tmp_MultiDomCapa[6];

	int seqNum;
	CWProtocolConfigureRequestValues configureRequest;

	CWLog("\n");
	CWLog("######### Configure State #########");

	if (!(CWParseConfigureRequestMessage(msgPtr->msg,
					     msgPtr->offset,
					     &seqNum,
					     &configureRequest,
					     &tmp_RadioInformationABGN, tmp_SuppRates, tmp_MultiDomCapa, WTPIndex))) {
		/* note: we can kill our thread in case of out-of-memory
		 * error to free some space.
		 * we can see this just calling CWErrorGetLastErrorCode()
		 */
		return CW_FALSE;
	}

	CWLog("Configure Request Received");

	if (!(CWSaveConfigureRequestMessage(&configureRequest, &(gWTPs[WTPIndex].WTPProtocolManager)))) {
		return CW_FALSE;
	}

	/* Store Radio Info in gWTPs */
	gWTPs[WTPIndex].RadioInformationABGN = tmp_RadioInformationABGN;
	memcpy(gWTPs[WTPIndex].SuppRates, tmp_SuppRates, 8);
	memcpy(gWTPs[WTPIndex].MultiDomCapa, tmp_MultiDomCapa, 6);

	/* Store Radio Info in gWTPs */

	if (!(CWAssembleConfigureResponse(&(gWTPs[WTPIndex].messages),
					  &(gWTPs[WTPIndex].messagesCount), gWTPs[WTPIndex].pathMTU, seqNum))) {
		return CW_FALSE;
	}

	if (!CWACSendFragments(WTPIndex)) {
		return CW_FALSE;
	}

	CWLog("Configure Response Sent");

	/* start Change State Pending timer */
	if (!CWErr(CWTimerRequest(gCWChangeStatePendingTimer,
				  &(gWTPs[WTPIndex].thread),
				  &(gWTPs[WTPIndex].currentTimer), CW_CRITICAL_TIMER_EXPIRED_SIGNAL))) {

		CWCloseThread();
	}

	gWTPs[WTPIndex].currentState = CW_ENTER_DATA_CHECK;
	return CW_TRUE;
}

CWBool CWParseConfigureRequestMessage(unsigned char *msg,
				      int len,
				      int *seqNumPtr,
				      CWProtocolConfigureRequestValues * valuesPtr,
				      unsigned char *tmp_RadioInformationABGN, unsigned char *tmp_SuppRates, char *tmp_MultiDomCapa, int WTPIndex)
{

	CWControlHeaderValues controlVal;
	int i, j;
	int offsetTillMessages;

	CWProtocolMessage completeMsg;

	if (msg == NULL || seqNumPtr == NULL || valuesPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	CWDebugLog("Parsing Configure Request...");

	completeMsg.msg = msg;
	completeMsg.offset = 0;

	if (!(CWParseControlHeader(&completeMsg, &controlVal)))
		/* will be handled by the caller */
		return CW_FALSE;

	/* Join Request in Configure state - WTP might have been restarted */

        if (controlVal.messageTypeValue == CW_MSG_TYPE_VALUE_JOIN_REQUEST ){
		gWTPs[WTPIndex].currentState = CW_ENTER_JOIN;
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT,
                                    "Message is Join Request in Configure State - switching state");
	}
	
        /* different type */

	if (controlVal.messageTypeValue != CW_MSG_TYPE_VALUE_CONFIGURE_REQUEST)
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT,
				    "Message is not Configure Request (maybe it is Image Data Request)");

	*seqNumPtr = controlVal.seqNum;
	/* skip timestamp */
	controlVal.msgElemsLen -= CW_CONTROL_HEADER_OFFSET_FOR_MSG_ELEMS;

	offsetTillMessages = completeMsg.offset;

	/* valuesPtr->WTPRadioInfo.radiosCount=0; */
	valuesPtr->ACinWTP.count = 0;
	valuesPtr->radioAdminInfoCount = 0;

	/* parse message elements */
	while ((completeMsg.offset - offsetTillMessages) < controlVal.msgElemsLen) {

		unsigned short int elemType = 0;	/* = CWProtocolRetrieve32(&completeMsg); */
		unsigned short int elemLen = 0;	/* = CWProtocolRetrieve16(&completeMsg); */

		CWParseFormatMsgElem(&completeMsg, &elemType, &elemLen);

		/*CWDebugLog("Parsing Message Element: %u, elemLen: %u", elemType, elemLen); */

		switch (elemType) {
		case CW_MSG_ELEMENT_AC_NAME_CW_TYPE:
			if (!(CWParseACName(&completeMsg, elemLen, &(valuesPtr->ACName))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;
		case CW_MSG_ELEMENT_AC_NAME_INDEX_CW_TYPE:
			/* just count how many radios we have,
			 * so we can allocate the array
			 */
			valuesPtr->ACinWTP.count++;
			completeMsg.offset += elemLen;
			break;
		case CW_MSG_ELEMENT_RADIO_ADMIN_STATE_CW_TYPE:
			/* just count how many radios we have,
			 * so we can allocate the array
			 */
			(valuesPtr->radioAdminInfoCount)++;
			completeMsg.offset += elemLen;
			break;
		case CW_MSG_ELEMENT_STATISTICS_TIMER_CW_TYPE:
			if (!(CWParseWTPStatisticsTimer(&completeMsg, elemLen, &(valuesPtr->StatisticsTimer))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;
		case CW_MSG_ELEMENT_WTP_REBOOT_STATISTICS_CW_TYPE:
			CW_CREATE_OBJECT_ERR(valuesPtr->WTPRebootStatistics,
					     WTPRebootStatisticsInfo, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
			    );
			if (!(CWParseWTPRebootStatistics(&completeMsg, elemLen, valuesPtr->WTPRebootStatistics)))
				/* will be handled by the caller */
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_IEEE80211_WTP_RADIO_INFORMATION_CW_TYPE:
			if (!(CWParseWTPRadioInformation(&completeMsg, elemLen, tmp_RadioInformationABGN)))
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_IEEE80211_MULTI_DOMAIN_CAPABILITY_CW_TYPE:
			if (!(CWParseWTPMultiDomainCapability(&completeMsg, elemLen, tmp_MultiDomCapa)))
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_IEEE80211_SUPPORTED_RATES_CW_TYPE:
			if (!(CWParseWTPSupportedRates(&completeMsg, elemLen, tmp_SuppRates)))
				return CW_FALSE;
			break;

		default:
			return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Unrecognized Message Element");
		}
	}

	if (completeMsg.offset != len)
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Garbage at the End of the Message");

	/* actually read each radio info */
	CW_CREATE_ARRAY_ERR((valuesPtr->ACinWTP).ACNameIndex,
			    (valuesPtr->ACinWTP).count,
			    CWACNameWithIndexValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CW_CREATE_ARRAY_ERR(valuesPtr->radioAdminInfo,
			    valuesPtr->radioAdminInfoCount,
			    CWRadioAdminInfoValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );
	i = 0;
	j = 0;

	completeMsg.offset = offsetTillMessages;
	while (completeMsg.offset - offsetTillMessages < controlVal.msgElemsLen) {
		unsigned short int type = 0;
		unsigned short int len = 0;

		CWParseFormatMsgElem(&completeMsg, &type, &len);

		switch (type) {
		case CW_MSG_ELEMENT_AC_NAME_INDEX_CW_TYPE:
			if (!(CWParseACNameWithIndex(&completeMsg, len, &(valuesPtr->ACinWTP.ACNameIndex[i]))))
				/* will be handled by the caller */
				return CW_FALSE;
			i++;
			break;
		case CW_MSG_ELEMENT_RADIO_ADMIN_STATE_CW_TYPE:
			if (!(CWParseWTPRadioAdminState(&completeMsg, len, &(valuesPtr->radioAdminInfo[j]))))
				/* will be handled by the caller */
				return CW_FALSE;
			j++;
			break;
		default:
			completeMsg.offset += len;
			break;
		}
	}
	CWDebugLog("Configure Request Parsed");
	return CW_TRUE;
}

CWBool CWAssembleConfigureResponse(CWProtocolMessage ** messagesPtr, int *fragmentsNumPtr, int PMTU, int seqNum)
{

	CWProtocolMessage *msgElems = NULL;
	const int MsgElemCount = 6;
	CWProtocolMessage *msgElemsBinding = NULL;
	int msgElemBindingCount = 0;
	int k = -1;

	if (messagesPtr == NULL || fragmentsNumPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	CWDebugLog("Assembling Configure Response...");
	CW_CREATE_PROTOCOL_MSG_ARRAY_ERR(msgElems, MsgElemCount, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	/* Assemble Message Elements */
	if ((!(CWAssembleMsgElemACIPv4List(&(msgElems[++k])))) ||
	    (!(CWAssembleMsgElemACIPv6List(&(msgElems[++k])))) || (!(CWAssembleMsgElemCWTimer(&(msgElems[++k])))) ||
	    /*(!(CWAssembleMsgElemRadioOperationalState(-1, &(msgElems[++k])))) || */
	    (!(CWAssembleMsgElemDecryptErrorReportPeriod(&(msgElems[++k])))) ||
	    (!(CWAssembleMsgElemIdleTimeout(&(msgElems[++k])))) || (!(CWAssembleMsgElemWTPFallback(&(msgElems[++k]))))
	    ) {
		int i;
		for (i = 0; i <= k; i++) {
			CW_FREE_PROTOCOL_MESSAGE(msgElems[i]);
		}
		CW_FREE_OBJECT(msgElems);
		/* error will be handled by the caller */
		return CW_FALSE;
	}

	if (!CWBindingAssembleConfigureResponse(&msgElemsBinding, &msgElemBindingCount)) {
		int i;
		for (i = 0; i <= MsgElemCount; i++) {
			CW_FREE_PROTOCOL_MESSAGE(msgElems[i]);
		}
		CW_FREE_OBJECT(msgElems);
		return CW_FALSE;
	}

	/*CWDebugLog("~~~~~ msg count: %d ", msgElemBindingCount); */

	if (!(CWAssembleMessage(messagesPtr,
				fragmentsNumPtr,
				PMTU,
				seqNum,
				CW_MSG_TYPE_VALUE_CONFIGURE_RESPONSE,
				msgElems, MsgElemCount, msgElemsBinding, msgElemBindingCount)))
		return CW_FALSE;

	CWDebugLog("Configure Response Assembled");
	return CW_TRUE;
}

CWBool CWSaveConfigureRequestMessage(CWProtocolConfigureRequestValues * configureRequest,
				     CWWTPProtocolManager * WTPProtocolManager)
{

	CWDebugLog("Saving Configure Request...");

	CW_FREE_OBJECT(WTPProtocolManager->ACName);

	if ((configureRequest->ACName) != NULL)
		WTPProtocolManager->ACName = configureRequest->ACName;

	CW_FREE_OBJECT((WTPProtocolManager->ACNameIndex).ACNameIndex);
	WTPProtocolManager->ACNameIndex = configureRequest->ACinWTP;

	CW_FREE_OBJECT((WTPProtocolManager->radioAdminInfo).radios);
	(WTPProtocolManager->radioAdminInfo).radiosCount = configureRequest->radioAdminInfoCount;
	(WTPProtocolManager->radioAdminInfo).radios = configureRequest->radioAdminInfo;

	WTPProtocolManager->StatisticsTimer = configureRequest->StatisticsTimer;

	/*
	   CW_FREE_OBJECT((WTPProtocolManager->WTPRadioInfo).radios);
	   WTPProtocolManager->WTPRadioInfo = configureRequest->WTPRadioInfo;
	 */

	CW_FREE_OBJECT(WTPProtocolManager->WTPRebootStatistics);
	WTPProtocolManager->WTPRebootStatistics = configureRequest->WTPRebootStatistics;

	CWDebugLog("Configure Request Saved");
	return CW_TRUE;
}


================================================
FILE: ACDataCheckState.c
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#include "CWAC.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

CWBool ACEnterDataCheck(int WTPIndex, CWProtocolMessage * msgPtr)
{

	/*CWProtocolMessage *messages = NULL; */
	int seqNum;
	CWProtocolChangeStateEventRequestValues *changeStateEvent;

	CWLog("\n");
	CWDebugLog("######### Status Event #########");

	/* Destroy ChangeStatePending timer */
	if (!CWErr(CWTimerCancel(&(gWTPs[WTPIndex].currentTimer)))) {

		CWCloseThread();
	}

	CW_CREATE_OBJECT_ERR(changeStateEvent,
			     CWProtocolChangeStateEventRequestValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	if (!(CWParseChangeStateEventRequestMessage(msgPtr->msg, msgPtr->offset, &seqNum, changeStateEvent))) {
		/* note: we can kill our thread in case of out-of-memory
		 * error to free some space.
		 * we can see this just calling CWErrorGetLastErrorCode()
		 */
		return CW_FALSE;
	}

	CWLog("Change State Event Received");

	if (!(CWSaveChangeStateEventRequestMessage(changeStateEvent, &(gWTPs[WTPIndex].WTPProtocolManager))))
		return CW_FALSE;

	if (!(CWAssembleChangeStateEventResponse(&(gWTPs[WTPIndex].messages),
						 &(gWTPs[WTPIndex].messagesCount), gWTPs[WTPIndex].pathMTU, seqNum))) {
		return CW_FALSE;
	}

	if (!CWACSendFragments(WTPIndex)) {

		return CW_FALSE;
	}

	/* Start NeighbourDeadInterval timer */
	if (!CWErr(CWTimerRequest(gCWNeighborDeadInterval,
				  &(gWTPs[WTPIndex].thread),
				  &(gWTPs[WTPIndex].currentTimer), CW_CRITICAL_TIMER_EXPIRED_SIGNAL))) {

		CWCloseThread();
	}

	CWLog("Change State Event Response Sent");

	gWTPs[WTPIndex].currentState = CW_ENTER_RUN;
	gWTPs[WTPIndex].subState = CW_WAITING_REQUEST;
        CWACsend_command_to_hostapd_SEND_WLAN(WTPIndex);

	return CW_TRUE;
}

CWBool CWParseChangeStateEventRequestMessage(unsigned char *msg,
					     int len,
					     int *seqNumPtr, CWProtocolChangeStateEventRequestValues * valuesPtr)
{

	CWProtocolMessage completeMsg;
	CWControlHeaderValues controlVal;
	int i;
	int offsetTillMessages;

	if (msg == NULL || seqNumPtr == NULL || valuesPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	CWDebugLog("Parsing Change State Event Request...");

	completeMsg.msg = msg;
	completeMsg.offset = 0;

	if (!(CWParseControlHeader(&completeMsg, &controlVal)))
		/* will be handled by the caller */
		return CW_FALSE;

	/* different type */
	if (controlVal.messageTypeValue != CW_MSG_TYPE_VALUE_CHANGE_STATE_EVENT_REQUEST)
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Message is not Change State Event Request");

	*seqNumPtr = controlVal.seqNum;
	/* skip timestamp */
	controlVal.msgElemsLen -= CW_CONTROL_HEADER_OFFSET_FOR_MSG_ELEMS;

	offsetTillMessages = completeMsg.offset;
	valuesPtr->radioOperationalInfo.radiosCount = 0;

	/* parse message elements */
	while ((completeMsg.offset - offsetTillMessages) < controlVal.msgElemsLen) {
		unsigned short int elemType = 0;	/* = CWProtocolRetrieve32(&completeMsg); */
		unsigned short int elemLen = 0;	/* = CWProtocolRetrieve16(&completeMsg); */

		CWParseFormatMsgElem(&completeMsg, &elemType, &elemLen);

		/*CWDebugLog("Parsing Message Element: %u, elemLen: %u", elemType, elemLen); */

		switch (elemType) {
		case CW_MSG_ELEMENT_RADIO_OPERAT_STATE_CW_TYPE:
			/* just count how many radios we have,
			 * so we can allocate the array
			 */
			valuesPtr->radioOperationalInfo.radiosCount++;
			completeMsg.offset += elemLen;
			break;
		case CW_MSG_ELEMENT_RESULT_CODE_CW_TYPE:
			if (!(CWParseResultCode(&completeMsg, elemLen, &(valuesPtr->resultCode))))
				return CW_FALSE;
			break;
		default:
			return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Unrecognized Message Element");
		}
	}

	if (completeMsg.offset != len)
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Garbage at the End of the Message");

	CW_CREATE_ARRAY_ERR(valuesPtr->radioOperationalInfo.radios,
			    valuesPtr->radioOperationalInfo.radiosCount,
			    CWRadioOperationalInfoValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	completeMsg.offset = offsetTillMessages;
	i = 0;

	while (completeMsg.offset - offsetTillMessages < controlVal.msgElemsLen) {
		unsigned short int type = 0;	/* = CWProtocolRetrieve32(&completeMsg); */
		unsigned short int len = 0;	/* = CWProtocolRetrieve16(&completeMsg); */

		CWParseFormatMsgElem(&completeMsg, &type, &len);

		switch (type) {
		case CW_MSG_ELEMENT_RADIO_OPERAT_STATE_CW_TYPE:
			if (!
			    (CWParseWTPRadioOperationalState
			     (&completeMsg, len, &(valuesPtr->radioOperationalInfo.radios[i]))))
				/* will be handled by the caller */
				return CW_FALSE;
			i++;
			break;
		default:
			completeMsg.offset += len;
			break;
		}
	}
	CWDebugLog("Change State Event Request Parsed");

	return CW_TRUE;
}

CWBool CWAssembleChangeStateEventResponse(CWProtocolMessage ** messagesPtr, int *fragmentsNumPtr, int PMTU, int seqNum)
{

	CWProtocolMessage *msgElems = NULL;
	const int msgElemCount = 0;
	CWProtocolMessage *msgElemsBinding = NULL;
	int msgElemBindingCount = 0;

	if (messagesPtr == NULL || fragmentsNumPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	CWDebugLog("Assembling Change State Event Response...");
	/*CW_CREATE_ARRAY_ERR(msgElems,
	 *            msgElemCount,
	 *            CWProtocolMessage,
	 *            return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL););
	 */
	if (!(CWAssembleMessage(messagesPtr,
				fragmentsNumPtr,
				PMTU,
				seqNum,
				CW_MSG_TYPE_VALUE_CHANGE_STATE_EVENT_RESPONSE,
				msgElems, msgElemCount, msgElemsBinding, msgElemBindingCount)))
	    return CW_FALSE;

	CWDebugLog("Change State Event Response Assembled");
	return CW_TRUE;
}


================================================
FILE: ACDiscoveryState.c
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#include "CWAC.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

/*__________________________________________________________*/
/*  *******************___PROTOTYPES___*******************  */

__inline__ int CWACGetHWVersion();
__inline__ int CWACGetSWVersion();
__inline__ int CWACGetStations();
__inline__ int CWACGetLimit();
__inline__ int CWACGetActiveWTPs();
__inline__ int CWACGetMaxWTPs();
__inline__ int CWACGetSecurity();
__inline__ char *CWACGetName();
__inline__ int CWACGetInterfacesCount();

/*_________________________________________________________*/
/*  *******************___FUNCTIONS___*******************  */

/* send Discovery Response to the host at the specified address */
CWBool CWAssembleDiscoveryResponse(CWProtocolMessage ** messagesPtr, int seqNum)
{

	CWProtocolMessage *msgElems = NULL;
	int msgElemCount = 4;
	CWProtocolMessage *msgElemsBinding = NULL;
	int msgElemBindingCount = 0;
	int fragmentsNum;

	int k = -1;
	if (messagesPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if (CWACSupportIPv6()) {
		msgElemCount++;
	}

	CWLog("Send Discovery Response");
	CW_CREATE_PROTOCOL_MSG_ARRAY_ERR(msgElems, msgElemCount, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	/* Assemble Message Elements */
	if ((!(CWAssembleMsgElemACDescriptor(&(msgElems[++k])))) ||
	    (!(CWAssembleMsgElemACName(&(msgElems[++k])))) ||
	    (!(CWAssembleMsgElemCWControlIPv4Addresses(&(msgElems[++k])))) ||
	    (!(CWAssembleMsgElemACWTPRadioInformation(&(msgElems[++k]))))
	    /*(CWACSupportIPv6() && (!(CWAssembleMsgElemCWControlIPv6Addresses(&(msgElems[++k]))))) */
	    ) {
		CWErrorHandleLast();
		int i;
		for (i = 0; i <= k; i++) {
			CW_FREE_PROTOCOL_MESSAGE(msgElems[i]);
		}
		CW_FREE_OBJECT(msgElems);
		return CW_FALSE;	// error will be handled by the caller
	}

	return CWAssembleMessage(messagesPtr,
				 &fragmentsNum,
				 0,
				 seqNum,
				 CW_MSG_TYPE_VALUE_DISCOVERY_RESPONSE,
				 msgElems, msgElemCount, msgElemsBinding, msgElemBindingCount);
}

CWBool CWParseDiscoveryRequestMessage(unsigned char *msg, int len, int *seqNumPtr, CWDiscoveryRequestValues * valuesPtr)
{

	CWControlHeaderValues controlVal;
	CWProtocolTransportHeaderValues transportVal;
	unsigned char RadioInfoABGN;
	int offsetTillMessages;

	CWProtocolMessage completeMsg;

	if (msg == NULL || seqNumPtr == NULL || valuesPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	CWDebugLog("Parse Discovery Request");

	completeMsg.msg = msg;
	completeMsg.offset = 0;

	CWBool dataFlag = CW_FALSE;
	if (!(CWParseTransportHeader(&completeMsg, &transportVal, &dataFlag, NULL)))
		/* will be handled by the caller */
		return CW_FALSE;
	if (!(CWParseControlHeader(&completeMsg, &controlVal)))
		/* will be handled by the caller */
		return CW_FALSE;

	/* different type */

	if (controlVal.messageTypeValue != CW_MSG_TYPE_VALUE_DISCOVERY_REQUEST)
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Message is not Discovery Request as Expected");

	*seqNumPtr = controlVal.seqNum;

	/* skip timestamp */
	controlVal.msgElemsLen -= CW_CONTROL_HEADER_OFFSET_FOR_MSG_ELEMS;
	offsetTillMessages = completeMsg.offset;

	/* (*valuesPtr).radios.radiosCount = 0; */

	/* parse message elements */
	while ((completeMsg.offset - offsetTillMessages) < controlVal.msgElemsLen) {

		unsigned short int elemType = 0;	/* = CWProtocolRetrieve32(&completeMsg); */
		unsigned short int elemLen = 0;	/* = CWProtocolRetrieve16(&completeMsg); */

		CWParseFormatMsgElem(&completeMsg, &elemType, &elemLen);

		/* CWDebugLog("Parsing Message Element: %u, elemLen: %u", elemType, elemLen); */

		switch (elemType) {
		case CW_MSG_ELEMENT_DISCOVERY_TYPE_CW_TYPE:
			if (!(CWParseDiscoveryType(&completeMsg, elemLen, valuesPtr)))
				/* will be handled by the caller */
				return CW_FALSE;
			break;
		case CW_MSG_ELEMENT_WTP_BOARD_DATA_CW_TYPE:
			if (!(CWParseWTPBoardData(&completeMsg, elemLen, &(valuesPtr->WTPBoardData))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;
		case CW_MSG_ELEMENT_WTP_DESCRIPTOR_CW_TYPE:
			if (!(CWParseWTPDescriptor(&completeMsg, elemLen, &(valuesPtr->WTPDescriptor))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;
		case CW_MSG_ELEMENT_WTP_FRAME_TUNNEL_MODE_CW_TYPE:
			if (!(CWParseWTPFrameTunnelMode(&completeMsg, elemLen, &(valuesPtr->frameTunnelMode))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;
		case CW_MSG_ELEMENT_WTP_MAC_TYPE_CW_TYPE:
			if (!(CWParseWTPMACType(&completeMsg, elemLen, &(valuesPtr->MACType))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;
		case CW_MSG_ELEMENT_IEEE80211_WTP_RADIO_INFORMATION_CW_TYPE:
			if (!(CWParseWTPRadioInformation(&completeMsg, elemLen, &RadioInfoABGN)))
				return CW_FALSE;

			break;
			/*case CW_MSG_ELEMENT_WTP_RADIO_INFO_CW_TYPE:
			   // just count how many radios we have, so we can allocate the array
			   (*valuesPtr).radios.radiosCount++;
			   completeMsg.offset += elemLen;
			   break;
			 */
		default:
			return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Unrecognized Message Element");
		}

		/*CWDebugLog("bytes: %d/%d", (completeMsg.offset-offsetTillMessages), controlVal.msgElemsLen); */
	}

	if (completeMsg.offset != len)
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Garbage at the End of the Message");

	/*
	   // actually read each radio info
	   CW_CREATE_ARRAY_ERR((*valuesPtr).radios.radios, (*valuesPtr).radios.radiosCount, CWRadioInformationValues,
	   return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL););
	   i = 0;

	   completeMsg.offset = offsetTillMessages;
	   while(i < (*valuesPtr).radios.radiosCount && (completeMsg.offset-offsetTillMessages) < controlVal.msgElemsLen) {
	   unsigned short int type=0;// = CWProtocolRetrieve32(&completeMsg);
	   unsigned short int len=0;// = CWProtocolRetrieve16(&completeMsg);

	   CWParseFormatMsgElem(&completeMsg,&type,&len);

	   switch(type) {
	   case CW_MSG_ELEMENT_WTP_RADIO_INFO_CW_TYPE:
	   if(!(CWParseWTPRadioInfo(&completeMsg, len, &(valuesPtr->radios), i))) return CW_FALSE; // will be handled by the caller
	   i++;
	   break;
	   default:
	   completeMsg.offset += len;
	   break;
	   }
	   }
	 */
	return CW_TRUE;
}

void CWDestroyDiscoveryRequestValues(CWDiscoveryRequestValues * valPtr)
{

	int i;

	if (valPtr == NULL)
		return;
	for (i = 0; i < (valPtr->WTPDescriptor.vendorInfos).vendorInfosCount; i++) {

		CW_FREE_OBJECT(((valPtr->WTPDescriptor.vendorInfos).vendorInfos)[i].valuePtr);
	}
	CW_FREE_OBJECT((valPtr->WTPDescriptor.vendorInfos).vendorInfos);

	/*
	 * BUG ML11
	 *
	 * 10/10/2009 - Donato Capitella
	 */
	for (i = 0; i < valPtr->WTPBoardData.vendorInfosCount; i++) {
		CW_FREE_OBJECT(valPtr->WTPBoardData.vendorInfos[i].valuePtr);
	}
	CW_FREE_OBJECT(valPtr->WTPBoardData.vendorInfos);

	/*CW_FREE_OBJECT((valPtr->radios).radios); */
}


================================================
FILE: ACInterface.c
================================================
/************************************************************************************************
 * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica   *
 *                          Universita' Campus BioMedico - Italy                                *
 *                                                                                              *
 * This program is free software; you can redistribute it and/or modify it under the terms      *
 * of the GNU General Public License as published by the Free Software Foundation; either       *
 * version 2 of the License, or (at your option) any later version.                             *
 *                                                                                              *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY              *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                     *
 *                                                                                              *
 * You should have received a copy of the GNU General Public License along with this            *
 * program; if not, write to the:                                                               *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                         *
 * MA  02111-1307, USA.                                                                         *
 *                                                                                              *
 * -------------------------------------------------------------------------------------------- *
 * Project:  Capwap
 *
 *   Authors : Antonio Davoli (antonio.davoli@gmail.com)
 *   Donato Capitella (d.capitella@gmail.com)
 ************************************************************************************************/

#include "CWAC.h"
#include "ACAppsProtocol.h"
#include "CWVendorPayloads.h"
#include "WUM.h"

#define LIST_CMD "LIST"
#define SCAN_CMD "SCAN"
#define QUIT_CMD "QUIT"

#define LISTEN_PORT 1235
#define COMMAND_BUFFER_SIZE 5120
#define WTP_LIST_BUFFER_SIZE 1024

#define CMD_TYPE_SIZE   sizeof(unsigned char)

int is_valid_wtp_index(int index);
int Readn(int sock, void *buf, size_t n);

/********************************************************************
 * Now the only parameter need by the application thread manager    *
 * is the index of socket.                                          *
 ********************************************************************/

typedef struct {
	int index;
} CWInterfaceThreadArg;

/************************************************************************
 * CWOFDMSetValues provide to set the command values (type, parameters, *
 * output socket) on the correct wtp structure.                         *
 ************************************************************************/

int CWOFDMSetValues(int selection, int socketIndex, OFDMControlValues * ofdmValues)
{

	CWThreadMutexLock(&(gWTPs[selection].interfaceMutex));

	gWTPs[selection].ofdmValues = ofdmValues;
	gWTPs[selection].interfaceCommand = OFDM_CONTROL_CMD;
	gWTPs[selection].applicationIndex = socketIndex;
	CWSignalThreadCondition(&gWTPs[selection].interfaceWait);
	CWWaitThreadCondition(&gWTPs[selection].interfaceComplete, &gWTPs[selection].interfaceMutex);

	CWThreadMutexUnlock(&(gWTPs[selection].interfaceMutex));

	return 0;
}

int CWVendorSetValues(int selection, int socketIndex, CWProtocolVendorSpecificValues * vendorValues)
{

	CWThreadMutexLock(&(gWTPs[selection].interfaceMutex));

	gWTPs[selection].vendorValues = vendorValues;
	gWTPs[selection].interfaceCommand = UCI_CONTROL_CMD;
	gWTPs[selection].applicationIndex = socketIndex;
	CWSignalThreadCondition(&gWTPs[selection].interfaceWait);
	CWWaitThreadCondition(&gWTPs[selection].interfaceComplete, &gWTPs[selection].interfaceMutex);

	CWThreadMutexUnlock(&(gWTPs[selection].interfaceMutex));

	return 0;
}

int CWWumSetValues(int selection, int socketIndex, CWProtocolVendorSpecificValues * vendorValues)
{

	CWThreadMutexLock(&(gWTPs[selection].interfaceMutex));

	gWTPs[selection].vendorValues = vendorValues;
	gWTPs[selection].interfaceCommand = WTP_UPDATE_CMD;
	gWTPs[selection].applicationIndex = socketIndex;
	CWSignalThreadCondition(&gWTPs[selection].interfaceWait);
	CWWaitThreadCondition(&gWTPs[selection].interfaceComplete, &gWTPs[selection].interfaceMutex);

	CWThreadMutexUnlock(&(gWTPs[selection].interfaceMutex));

	return 0;
}

/************************************************************************
 * CWManageApplication is the function that provide the management of   *
 * interaction with a single application.                               *
 * -------------------------------------------------------------------- *
 * The messages used are defined in ACAppsProtocol.h                    *
 ************************************************************************/

CW_THREAD_RETURN_TYPE CWManageApplication(void *arg)
{

	int socketIndex = ((CWInterfaceThreadArg *) arg)->index;
	CWSocket sock = appsManager.appSocket[socketIndex];
	int n, connected = htonl(CONNECTION_OK), gActiveWTPsTemp;

	char commandBuffer[COMMAND_BUFFER_SIZE];
	char wtpListBuffer[WTP_LIST_BUFFER_SIZE];

	int payload_size;
	int i, nameLength, numActiveWTPs = 0, wtpIndex;
	int iTosend, nLtoSend;
	unsigned char cmd_msg, msg_elem;
	OFDMControlValues *ofdmValues;
	CWProtocolVendorSpecificValues *vendorValues;
	CWVendorUciValues *uciValues;
	CWVendorWumValues *wumValues;

	/********************************************************************************
	 * Write on application socket that connection setting is happened correctly.   *
	 ********************************************************************************/

	if (Writen(sock, &connected, sizeof(int)) < 0) {
		CWLog("Error on writing on application socket ");
		return NULL;
	}

	/*
	 * Before starting, make sure to detach the thread because the parent
	 * doesn't do a join and we risk resource leaks.
	 *
	 * ref -> BUG-TRL01
	 * 15/10/2009 - Donato Capitella
	 */

	pthread_detach(pthread_self());	// no need here to check return value

	/************************
	 *   Thread Main Loop   *
	 ************************/

	CW_REPEAT_FOREVER {

		memset(commandBuffer, 0, COMMAND_BUFFER_SIZE);

		/****************************************
		 *      Waiting for client commands     *
		 ****************************************/

		if ((n = Readn(sock, &cmd_msg, CMD_TYPE_SIZE)) > 0) {

			if (cmd_msg == QUIT_MSG) {
				/****************************************************
				 *      Quit Message: Clean socket information      *
				 ****************************************************/
				goto quit_manage;
			}

			if (cmd_msg == LIST_MSG) {

				/****************************************
				 *          Manage LIST command         *
				 * ------------------------------------ *
				 * 1. Get Number of active WTPs,        *
				 * 2. Create Message Answer,            *
				 * 3. Send To client socket.            *
				 ****************************************/

				if (!CWErr(CWThreadMutexLock(&gActiveWTPsMutex))) {
					CWLog("Error locking the mutex");
					return NULL;
				}

				gActiveWTPsTemp = gActiveWTPs;

				CWThreadMutexUnlock(&gActiveWTPsMutex);

				if (gActiveWTPsTemp > 0)
					for (i = 0; i < gMaxWTPs; i++)
						if (gWTPs[i].isNotFree)
							if (!gWTPs[i].WTPProtocolManager.name)
								gActiveWTPsTemp -= 1;

				numActiveWTPs = htonl(gActiveWTPsTemp);

				memset(wtpListBuffer, 0, sizeof(wtpListBuffer));
				payload_size = 0;

				memcpy(wtpListBuffer, &numActiveWTPs, sizeof(int));
				payload_size = sizeof(int);

				if (gActiveWTPsTemp > 0) {
					for (i = 0; i < gMaxWTPs; i++) {

						if (gWTPs[i].isNotFree) {

							if (!gWTPs[i].WTPProtocolManager.name)
								continue;

							nameLength = strlen(gWTPs[i].WTPProtocolManager.name);

							iTosend = htonl(i);
							nLtoSend = htonl(nameLength);

							memcpy(wtpListBuffer + payload_size, &iTosend, sizeof(int));
							payload_size += sizeof(int);

							memcpy(wtpListBuffer + payload_size, &nLtoSend, sizeof(int));
							payload_size += sizeof(int);

							memcpy(wtpListBuffer + payload_size,
							       gWTPs[i].WTPProtocolManager.name,
							       strlen(gWTPs[i].WTPProtocolManager.name));
							payload_size += strlen(gWTPs[i].WTPProtocolManager.name);
						}
					}
				}

				if (Writen(sock, wtpListBuffer, payload_size) < 0)
					CWLog("Error on write message on application socket");

			}

			if (cmd_msg == CONF_UPDATE_MSG) {

				/****************************************
				 * Manage CONF command          *
				 * ------------------------------------ *
				 * 1. Select the type of CONF_UPDATE,   *
				 * 2. Get Index of WTP,         *
				 * 3. Manage request.           *
				 ****************************************/

				if ((n = Readn(sock, commandBuffer, sizeof(msg_elem) + sizeof(wtpIndex))) < 0) {
					CWLog("Error while reading from socket.");
					goto quit_manage;
				}

				memcpy(&msg_elem, commandBuffer, sizeof(unsigned char));	/* CONF_UPDATE type */
				memcpy(&wtpIndex, commandBuffer + sizeof(unsigned char), sizeof(int));	/* WTP Index */

				wtpIndex = ntohl(wtpIndex);

				/* Check if WTP Index is valid */
				if (!is_valid_wtp_index(wtpIndex)) {
					CWLog("WTP Index non valid!");
					goto quit_manage;
				}

				switch (msg_elem) {
				case MSG_ELEMENT_TYPE_OFDM:{
						/* Antonio Case */
						CW_CREATE_OBJECT_ERR(ofdmValues, OFDMControlValues, {
								     CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
								     return 0;
								     }
						);
						if ((n = Readn(sock, ofdmValues, sizeof(OFDMControlValues))) < 0) {
							CWLog("Error while reading from socket");
							goto quit_manage;
						}

					/****************************************************
					 * Two behaviors availables:                        *
					 *    - One message element For All WTPs Active     *
					 *    - One message for a specific WTP              *
					 ****************************************************/

						if (wtpIndex == ALL_ACTIVE_WTPS) {	/* All wpts case */

							if (!CWErr(CWThreadMutexLock(&gActiveWTPsMutex))) {
								CWLog("Error locking the mutex");
								return NULL;
							}
							numActiveWTPs = gActiveWTPs;
							CWThreadMutexUnlock(&gActiveWTPsMutex);

							if (numActiveWTPs > 0) {
								for (i = 0; i < gMaxWTPs; i++) {
									if (gWTPs[i].isNotFree) {
										CWOFDMSetValues(i, socketIndex,
												ofdmValues);
									}
								}
							}
						} else	/* One specific Wtp Case */
							CWOFDMSetValues(wtpIndex, socketIndex, ofdmValues);

						CW_FREE_OBJECT(ofdmValues);
						break;
					}
				case MSG_ELEMENT_TYPE_VENDOR_UCI:{
						/* Matteo Case */
						/*Do stuff to parse uci payload */
						int commandLength = 0;
						CW_CREATE_OBJECT_ERR(vendorValues, CWProtocolVendorSpecificValues, {
								     CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
								     return 0;
								     }
						);
						CW_CREATE_OBJECT_ERR(uciValues, CWVendorUciValues, {
								     CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
								     return 0;
								     }
						);
						vendorValues->vendorPayloadType =
						    CW_MSG_ELEMENT_VENDOR_SPEC_PAYLOAD_UCI;
						uciValues->response = NULL;

						if ((n =
						     Readn(sock, commandBuffer,
							   sizeof(unsigned char) + sizeof(int))) < 0) {
							CWLog("Error while reading from socket.");
							goto quit_manage;
						}

						memcpy(&(uciValues->command), commandBuffer, sizeof(unsigned char));
						memcpy(&commandLength, commandBuffer + sizeof(unsigned char),
						       sizeof(int));
						commandLength = ntohl(commandLength);

						if (commandLength > 0) {
							if ((n =
							     Readn(sock, commandBuffer + sizeof(char) + sizeof(int),
								   commandLength)) < 0) {
								CWLog("Error while reading from socket.");
								goto quit_manage;
							}

							CW_CREATE_STRING_ERR(uciValues->commandArgs, commandLength, {
									     CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
									     return 0;
									     }
							);
							memcpy(uciValues->commandArgs,
							       commandBuffer + sizeof(unsigned char) + sizeof(int),
							       sizeof(char) * commandLength);
							uciValues->commandArgs[commandLength] = '\0';
						} else
							uciValues->commandArgs = NULL;

						vendorValues->payload = uciValues;

					/****************************************************
					 * Two behaviors availables:                        *
					 *      - One message element For All WTPs Active   *
					 *      - One message for a specific WTP            *
					 ****************************************************/

						if (wtpIndex == ALL_ACTIVE_WTPS) {	/* All wpts case */

							if (!CWErr(CWThreadMutexLock(&gActiveWTPsMutex))) {
								CWLog("Error locking the mutex");
								return NULL;
							}
							numActiveWTPs = gActiveWTPs;
							CWThreadMutexUnlock(&gActiveWTPsMutex);

							if (numActiveWTPs > 0) {
								for (i = 0; i < gMaxWTPs; i++) {
									if (gWTPs[i].isNotFree) {
										printf
										    ("Sending UCI Configuration Message to: %d - %s \n",
										     i,
										     gWTPs[i].WTPProtocolManager.name);
										CWVendorSetValues(i, socketIndex,
												  vendorValues);
									}
								}
							}
						} else	/* One specific Wtp Case */
							CWVendorSetValues(wtpIndex, socketIndex, vendorValues);
						break;
					}
				case MSG_ELEMENT_TYPE_VENDOR_WUM:{
						/* Donato's Case */

						CW_CREATE_OBJECT_ERR(vendorValues, CWProtocolVendorSpecificValues, {
								     CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
								     return 0;
								     }
						);
						CW_CREATE_OBJECT_ERR(wumValues, CWVendorWumValues, {
								     CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
								     return 0;
								     }
						);
						vendorValues->vendorPayloadType =
						    CW_MSG_ELEMENT_VENDOR_SPEC_PAYLOAD_WUM;

						/*
						 * Read WTP Update Message fields into the wumValues structure
						 */

						if ((n = Readn(sock, &(wumValues->type), sizeof(unsigned char))) < 0) {
							CWLog("Error while reading from socket.");
							goto quit_manage;
						}

						if (wumValues->type == WTP_UPDATE_REQUEST) {
							if ((n =
							     Readn(sock, commandBuffer,
								   3 * sizeof(unsigned char) + sizeof(int))) < 0) {
								CWLog("Error while reading from socket.");
								goto quit_manage;
							}

							memcpy(&(wumValues->_major_v_), commandBuffer,
							       sizeof(unsigned char));
							memcpy(&(wumValues->_minor_v_),
							       commandBuffer + sizeof(unsigned char),
							       sizeof(unsigned char));
							memcpy(&(wumValues->_revision_v_),
							       commandBuffer + 2 * sizeof(unsigned char),
							       sizeof(unsigned char));
							memcpy(&(wumValues->_pack_size_),
							       commandBuffer + 3 * sizeof(unsigned char),
							       sizeof(unsigned int));
							wumValues->_pack_size_ = ntohl(wumValues->_pack_size_);
						} else if (wumValues->type == WTP_CUP_FRAGMENT) {
							int seqNum;
							int fragSize;

							/* Read sequence number and fragment size */
							if ((n = Readn(sock, commandBuffer, 2 * sizeof(int))) < 0) {
								CWLog("Error while reading from socket.");
								goto quit_manage;
							}

							memcpy(&seqNum, commandBuffer, sizeof(int));
							memcpy(&fragSize, commandBuffer + sizeof(int), sizeof(int));

							seqNum = ntohl(seqNum);
							fragSize = ntohl(fragSize);

							if (seqNum < 0) {
								CWLog("Update with sequence number < 0 not valid.");
								goto quit_manage;
							}

							if (fragSize <= 0) {
								CWLog("Update with fragment size <= 0 not valid.");
								goto quit_manage;
							}

							/* Read update package into buffer */
							unsigned char *buf = malloc(fragSize);
							if (buf == NULL) {
								CWLog("Can't allocate memory");
								goto quit_manage;
							}

							if ((n = Readn(sock, buf, fragSize)) < 0) {
								CWLog("Error while reading from socket.");
								goto quit_manage;
							}

							wumValues->_cup_ = buf;
							wumValues->_seq_num_ = seqNum;
							wumValues->_cup_fragment_size_ = fragSize;
						}

						vendorValues->payload = wumValues;

						/* Send Request */
						if (wtpIndex == ALL_ACTIVE_WTPS) {	/* All wpts case */

							if (!CWErr(CWThreadMutexLock(&gActiveWTPsMutex))) {
								CWLog("Error locking the mutex");
								return NULL;
							}
							numActiveWTPs = gActiveWTPs;
							CWThreadMutexUnlock(&gActiveWTPsMutex);

							if (numActiveWTPs > 0) {
								for (i = 0; i < gMaxWTPs; i++) {
									if (gWTPs[i].isNotFree) {
										printf
										    ("Sending WUM Configuration Message to: %d - %s \n",
										     i,
										     gWTPs[i].WTPProtocolManager.name);
										CWWumSetValues(i, socketIndex,
											       vendorValues);
									}
								}
							}
						} else	/* One specific Wtp Case */
							CWWumSetValues(wtpIndex, socketIndex, vendorValues);
						break;
					}
				default:
					/* Error Case: Not correct msg_elem type */
					break;
				}
			}
		} else {
			CWLog("Error on receive application command (read socket)");
			goto quit_manage;
		}
	}

 quit_manage:

	if (!CWErr(CWThreadMutexLock(&appsManager.numSocketFreeMutex))) {
		CWLog("Error locking numSocketFree Mutex");
		return NULL;
	}

	appsManager.isFree[socketIndex] = CW_TRUE;
	appsManager.numSocketFree++;

	CWDestroyThreadMutex(&appsManager.socketMutex[socketIndex]);

	CWThreadMutexUnlock(&appsManager.numSocketFreeMutex);

	close(sock);
	return NULL;
}

/****************************************************************************
 * CWInterface is the function that provide the interaction between AC and  *
 * extern applications. Listen on main Inet familty socket and create a     *
 * CWManageApplication thread for every client connected.                   *
 ****************************************************************************/

CW_THREAD_RETURN_TYPE CWInterface(void *arg)
{

	CWSocket listen_sock, conn_sock;
	struct sockaddr_in servaddr;
	CWInterfaceThreadArg *argPtr;
	CWThread thread_id;
	int i, clientFull = htonl(FULL_CLIENT_CONNECTED), optValue = 1;

	/****************************************************
	 * Setup of Application Socket Management Structure *
	 ****************************************************/

	for (i = 0; i < MAX_APPS_CONNECTED_TO_AC; i++)
		appsManager.isFree[i] = CW_TRUE;

	appsManager.numSocketFree = MAX_APPS_CONNECTED_TO_AC;

	if (!CWErr(CWCreateThreadMutex(&appsManager.numSocketFreeMutex))) {
		CWLog("Error on mutex creation on appManager structure");
		return NULL;
	}

	/****************************************************
	 * Setup (Creation and filling) of main socket      *
	 ****************************************************/

	if ((listen_sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		CWLog("Error on socket creation on Interface");
		return NULL;
	}

	memset(&servaddr, 0, sizeof(servaddr));

	servaddr.sin_family = AF_INET;
	servaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);	/* Not Extern: INADDR_ANY */
	servaddr.sin_port = htons(LISTEN_PORT);

	if (setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &optValue, sizeof(int)) == -1) {
		CWLog("Error on socket creation on Interface");
		return NULL;
	}

	/************************************
	 * Binding socket and Listen call   *
	 ************************************/

	if (bind(listen_sock, (struct sockaddr *)&servaddr, sizeof(struct sockaddr_in)) < 0) {
		CWLog("Error on Binding");
		return NULL;
	}

	if (listen(listen_sock, MAX_APPS_CONNECTED_TO_AC) < 0) {
		CWLog("Error on LIsTsocket creation");
		return NULL;
	}

	/********************************
	 *          Main Loop           *
	 ********************************/

	CW_REPEAT_FOREVER {
		if ((conn_sock = accept(listen_sock, (struct sockaddr *)NULL, NULL)) > 0) {

			/************************************************************************
			 * Check (with lock) the number of socket free at the moment of accept, *
			 * if this value is greater than 0 will be spawn a new Manage thread.   *
			 ************************************************************************/

			if (!CWErr(CWThreadMutexLock(&appsManager.numSocketFreeMutex))) {
				CWLog("Error locking numSocketFree Mutex");
				return NULL;
			}

			if (appsManager.numSocketFree > 0) {

				CW_CREATE_OBJECT_ERR(argPtr, CWInterfaceThreadArg, {
						     CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
						     return 0;
						     }
				);

				/************************************
				 *  Search socket for application   *
				 ************************************/

				for (i = 0; i < MAX_APPS_CONNECTED_TO_AC; i++) {
					if (appsManager.isFree[i] == CW_TRUE) {
						argPtr->index = i;
						appsManager.isFree[i] = CW_FALSE;
						appsManager.appSocket[i] = conn_sock;
						break;
					}
				}

				appsManager.numSocketFree--;
				CWThreadMutexUnlock(&appsManager.numSocketFreeMutex);

				if (!CWErr(CWCreateThreadMutex(&appsManager.socketMutex[argPtr->index]))) {
					CWLog("Error on mutex creation on appManager structure");
					return NULL;
				}

				if (!CWErr(CWCreateThread(&thread_id, CWManageApplication, argPtr))) {
					CWLog("Error on thread CWManageApplication creation");
					appsManager.isFree[argPtr->index] = CW_TRUE;
					close(conn_sock);
					CW_FREE_OBJECT(argPtr);
					/*
					 * If we can't create the thread, we have to increment numSocketFree.
					 *
					 *   ref -> BUG-LE01
					 *   15/10/2009 - Donato Capitella
					 */
					if (!CWErr(CWThreadMutexLock(&appsManager.numSocketFreeMutex))) {
						CWLog("Error locking numSocketFree Mutex");
						return NULL;
					}
					appsManager.numSocketFree++;
					CWThreadMutexUnlock(&appsManager.numSocketFreeMutex);

				}
			} else {
				CWThreadMutexUnlock(&appsManager.numSocketFreeMutex);

				/****************************************************************
				 *  There isn't space for another client, send error answer.    *
				 ***************************************************************/

				if (Writen(conn_sock, &clientFull, sizeof(int)) < 0) {
					printf("Error on sending Error Message\n");
					close(conn_sock);
				}
			}
		} else
			CWLog("Error on accept (applications) system call");
	}

	CWDestroyThreadMutex(&appsManager.numSocketFreeMutex);
	close(listen_sock);
}

int is_valid_wtp_index(int wtpIndex)
{
	if (wtpIndex < gMaxWTPs && gWTPs[wtpIndex].isNotFree)
		return CW_TRUE;
	return CW_FALSE;
}

/*
 * Steven's readn().
 */
int readn(int fd, void *vptr, size_t n)
{
	size_t nleft;
	ssize_t nread;
	char *ptr;

	ptr = vptr;
	nleft = n;
	while (nleft > 0) {
		if ((nread = recv(fd, ptr, nleft, 0)) < 0) {
			if (errno == EINTR)
				nread = 0;	/* and call read() again */
			else
				return (-1);
		} else if (nread == 0)
			break;	/* EOF */

		nleft -= nread;
		ptr += nread;
	}
	return (n - nleft);	/* return >= 0 */
}

int Readn(int fd, void *ptr, size_t nbytes)
{
	int n;

	if ((n = readn(fd, ptr, nbytes)) < 0) {
		CWLog("Error while reading data from socket.");
		return -1;
	}

	return n;
}


================================================
FILE: ACInterface.h
================================================
/*******************************************************************************************
 * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria          *
 *                         Informatica Universita' Campus BioMedico - Italy                *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Authors : Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *           Daniele De Sanctis (danieledesanctis@gmail.com)                               *
 *           Antonio Davoli (antonio.davoli@gmail.com)                                     *
 *           Donato Capitella (d.capitella@gmail.com)                                      *
 *******************************************************************************************/

#ifndef __CAPWAP_ACInterface_HEADER__
#define __CAPWAP_ACInterface_HEADER__

//No Interface Command
#define NO_CMD          0
//Manual setting for QoS values
#define QOS_CMD         1
#define CLEAR_CONFIG_MSG_CMD    2
/* 2009 Update: Manual setting for OFDM values*/
#define OFDM_CONTROL_CMD        3
/*Update 2009:
        Manage UCI configuration command*/
#define UCI_CONTROL_CMD 4
/* Manage WTP Update Command */
#define WTP_UPDATE_CMD  5

#endif


================================================
FILE: ACJoinState.c
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#include "CWAC.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

CWBool CWAssembleJoinResponse(CWProtocolMessage ** messagesPtr,
			      int *fragmentsNumPtr, int PMTU, int seqNum, CWList msgElemList);

CWBool CWParseJoinRequestMessage(unsigned char *msg, int len, int *seqNumPtr, CWProtocolJoinRequestValues * valuesPtr);

CWBool CWSaveJoinRequestMessage(CWProtocolJoinRequestValues * joinRequest, CWWTPProtocolManager * WTPProtocolManager);

CWBool ACEnterJoin(int WTPIndex, CWProtocolMessage * msgPtr)
{
	int seqNum;
	CWProtocolJoinRequestValues joinRequest;
	CWList msgElemList = NULL;

	CWLog("\n");
	CWLog("######### Join State #########");

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if (!(CWParseJoinRequestMessage(msgPtr->msg, msgPtr->offset, &seqNum, &joinRequest))) {
		/* note: we can kill our thread in case of out-of-memory
		 * error to free some space.
		 * we can see this just calling CWErrorGetLastErrorCode()
		 */
		return CW_FALSE;
	}
	// cancel waitJoin timer
	if (!CWTimerCancel(&(gWTPs[WTPIndex].currentTimer))) {
		return CW_FALSE;
	}

	CWBool ACIpv4List = CW_FALSE;
	CWBool ACIpv6List = CW_FALSE;
	CWBool resultCode = CW_TRUE;
	int resultCodeValue = CW_PROTOCOL_SUCCESS;
	/* CWBool sessionID = CW_FALSE; */

	if (!(CWSaveJoinRequestMessage(&joinRequest, &(gWTPs[WTPIndex].WTPProtocolManager)))) {

		resultCodeValue = CW_PROTOCOL_FAILURE_RES_DEPLETION;
	}

	CWMsgElemData *auxData;
	if (ACIpv4List) {
		CW_CREATE_OBJECT_ERR(auxData, CWMsgElemData, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		auxData->type = CW_MSG_ELEMENT_AC_IPV4_LIST_CW_TYPE;
		auxData->value = 0;
		CWAddElementToList(&msgElemList, auxData);
	}
	if (ACIpv6List) {
		CW_CREATE_OBJECT_ERR(auxData, CWMsgElemData, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		auxData->type = CW_MSG_ELEMENT_AC_IPV6_LIST_CW_TYPE;
		auxData->value = 0;
		CWAddElementToList(&msgElemList, auxData);
	}
	if (resultCode) {
		CW_CREATE_OBJECT_ERR(auxData, CWMsgElemData, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		auxData->type = CW_MSG_ELEMENT_RESULT_CODE_CW_TYPE;
		auxData->value = resultCodeValue;
		CWAddElementToList(&msgElemList, auxData);
	}
	/*
	   if(sessionID){
	   CW_CREATE_OBJECT_ERR(auxData, CWMsgElemData, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL););
	   auxData->type =  CW_MSG_ELEMENT_SESSION_ID_CW_TYPE;
	   auxData->value = CWRandomIntInRange(0, INT_MAX);
	   CWAddElementToList(&msgElemList,auxData);
	   }
	 */

	/* random session ID */
	if (!(CWAssembleJoinResponse(&(gWTPs[WTPIndex].messages),
				     &(gWTPs[WTPIndex].messagesCount), gWTPs[WTPIndex].pathMTU, seqNum, msgElemList))) {

		CWDeleteList(&msgElemList, CWProtocolDestroyMsgElemData);
		return CW_FALSE;
	}

	CWDeleteList(&msgElemList, CWProtocolDestroyMsgElemData);

	if (!CWACSendFragments(WTPIndex)) {
		return CW_FALSE;
	}

	gWTPs[WTPIndex].currentState = CW_ENTER_CONFIGURE;

	return CW_TRUE;
}

/*
 * Assemble Join Response.
 */
CWBool CWAssembleJoinResponse(CWProtocolMessage ** messagesPtr,
			      int *fragmentsNumPtr, int PMTU, int seqNum, CWList msgElemList)
{

	CWProtocolMessage *msgElems = NULL;
	int msgElemCount = 0;
	/* Result code is not included because it's already
	 * in msgElemList. Control IPv6 to be added.
	 */
	const int mandatoryMsgElemCount = 4;
	CWProtocolMessage *msgElemsBinding = NULL;
	const int msgElemBindingCount = 0;
	int i;
	CWListElement *current;
	int k = -1;

	if (messagesPtr == NULL || fragmentsNumPtr == NULL || msgElemList == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	msgElemCount = CWCountElementInList(msgElemList);

	CW_CREATE_PROTOCOL_MSG_ARRAY_ERR(msgElems,
					 msgElemCount + mandatoryMsgElemCount,
					 return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWDebugLog("Assembling Join Response...");

	if ((!(CWAssembleMsgElemACDescriptor(&(msgElems[++k])))) ||
	    (!(CWAssembleMsgElemACName(&(msgElems[++k])))) ||
	    (!(CWAssembleMsgElemCWControlIPv4Addresses(&(msgElems[++k])))) ||
	    (!(CWAssembleMsgElemACWTPRadioInformation(&(msgElems[++k]))))
	    ) {
		CWErrorHandleLast();
		int i;
		for (i = 0; i <= k; i++) {
			CW_FREE_PROTOCOL_MESSAGE(msgElems[i]);
		}
		CW_FREE_OBJECT(msgElems);
		/* error will be handled by the caller */
		return CW_FALSE;
	}

	current = msgElemList;
	for (i = 0; i < msgElemCount; i++) {

		switch (((CWMsgElemData *) (current->data))->type) {

		case CW_MSG_ELEMENT_AC_IPV4_LIST_CW_TYPE:
			if (!(CWAssembleMsgElemACIPv4List(&(msgElems[++k]))))
				goto cw_assemble_error;
			break;
		case CW_MSG_ELEMENT_AC_IPV6_LIST_CW_TYPE:
			if (!(CWAssembleMsgElemACIPv6List(&(msgElems[++k]))))
				goto cw_assemble_error;
			break;
		case CW_MSG_ELEMENT_RESULT_CODE_CW_TYPE:
			if (!(CWAssembleMsgElemResultCode(&(msgElems[++k]), ((CWMsgElemData *) current->data)->value)))
				goto cw_assemble_error;
			break;
			/*
			   case CW_MSG_ELEMENT_SESSION_ID_CW_TYPE:
			   if (!(CWAssembleMsgElemSessionID(&(msgElems[++k]), ((CWMsgElemData *) current->data)->value)))
			   goto cw_assemble_error;
			   break;
			 */
		default:{
				int j;
				for (j = 0; j <= k; j++) {
					CW_FREE_PROTOCOL_MESSAGE(msgElems[j]);
				}
				CW_FREE_OBJECT(msgElems);
				return CWErrorRaise(CW_ERROR_INVALID_FORMAT,
						    "Unrecognized Message Element for Join Response Message");
				break;
			}
		}
		current = current->next;
	}

	if (!(CWAssembleMessage(messagesPtr,
				fragmentsNumPtr,
				PMTU,
				seqNum,
				CW_MSG_TYPE_VALUE_JOIN_RESPONSE,
				msgElems, msgElemCount + mandatoryMsgElemCount, msgElemsBinding, msgElemBindingCount)))
	    return CW_FALSE;

	CWDebugLog("Join Response Assembled");

	return CW_TRUE;

 cw_assemble_error:{
		int i;
		for (i = 0; i <= k; i++) {
			CW_FREE_PROTOCOL_MESSAGE(msgElems[i]);
		}
		CW_FREE_OBJECT(msgElems);
		/* error will be handled by the caller */
		return CW_FALSE;
	}
	return CW_TRUE;
}

/*
 * Parses Join Request.
 */
CWBool CWParseJoinRequestMessage(unsigned char *msg, int len, int *seqNumPtr, CWProtocolJoinRequestValues * valuesPtr)
{

	CWControlHeaderValues controlVal;
	int offsetTillMessages;
	CWProtocolMessage completeMsg;
	unsigned char RadioInfoABGN;

	if (msg == NULL || seqNumPtr == NULL || valuesPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	CWDebugLog("Parse Join Request");

	completeMsg.msg = msg;
	completeMsg.offset = 0;

	if (!(CWParseControlHeader(&completeMsg, &controlVal)))
		/* will be handled by the caller */
		return CW_FALSE;

	/* different type */
	if (controlVal.messageTypeValue != CW_MSG_TYPE_VALUE_JOIN_REQUEST)
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Message is not Join Request as Expected");

	*seqNumPtr = controlVal.seqNum;
	/* skip timestamp */
	controlVal.msgElemsLen -= CW_CONTROL_HEADER_OFFSET_FOR_MSG_ELEMS;
	offsetTillMessages = completeMsg.offset;

	/* parse message elements */
	while ((completeMsg.offset - offsetTillMessages) < controlVal.msgElemsLen) {

		unsigned short int elemType = 0;	/* = CWProtocolRetrieve32(&completeMsg); */
		unsigned short int elemLen = 0;	/* = CWProtocolRetrieve16(&completeMsg); */

		CWParseFormatMsgElem(&completeMsg, &elemType, &elemLen);

		/* CWDebugLog("Parsing Message Element: %u, elemLen: %u", elemType, elemLen); */

		switch (elemType) {
		case CW_MSG_ELEMENT_LOCATION_DATA_CW_TYPE:
			if (!(CWParseLocationData(&completeMsg, elemLen, &(valuesPtr->location))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_WTP_BOARD_DATA_CW_TYPE:
			if (!(CWParseWTPBoardData(&completeMsg, elemLen, &(valuesPtr->WTPBoardData))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_SESSION_ID_CW_TYPE:
			valuesPtr->sessionID = CWParseSessionID(&completeMsg, elemLen);
			break;

		case CW_MSG_ELEMENT_WTP_DESCRIPTOR_CW_TYPE:
			if (!(CWParseWTPDescriptor(&completeMsg, elemLen, &(valuesPtr->WTPDescriptor))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_WTP_IPV4_ADDRESS_CW_TYPE:
			if (!(CWParseWTPIPv4Address(&completeMsg, elemLen, valuesPtr)))
				/* will be handled by the caller */
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_WTP_NAME_CW_TYPE:
			if (!(CWParseWTPName(&completeMsg, elemLen, &(valuesPtr->name))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_WTP_FRAME_TUNNEL_MODE_CW_TYPE:
			if (!(CWParseWTPFrameTunnelMode(&completeMsg, elemLen, &(valuesPtr->frameTunnelMode))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_WTP_MAC_TYPE_CW_TYPE:
			if (!(CWParseWTPMACType(&completeMsg, elemLen, &(valuesPtr->MACType))))
				/* will be handled by the caller */
				return CW_FALSE;
			break;

		case CW_MSG_ELEMENT_IEEE80211_WTP_RADIO_INFORMATION_CW_TYPE:
			if (!(CWParseWTPRadioInformation(&completeMsg, elemLen, &RadioInfoABGN)))
				return CW_FALSE;
			break;

		default:
			completeMsg.offset += elemLen;
			CWLog("Unrecognized Message Element(%d) in Discovery response", elemType);
			break;
		}
		/*CWDebugLog("bytes: %d/%d", (completeMsg.offset-offsetTillMessages), controlVal.msgElemsLen); */
	}

	if (completeMsg.offset != len)
		return CWErrorRaise(CW_ERROR_INVALID_FORMAT, "Garbage at the End of the Message");

	return CW_TRUE;
}

CWBool CWSaveJoinRequestMessage(CWProtocolJoinRequestValues * joinRequest, CWWTPProtocolManager * WTPProtocolManager)
{

	CWDebugLog("Saving Join Request...");

	if (joinRequest == NULL || WTPProtocolManager == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if ((joinRequest->location) != NULL) {

		CW_FREE_OBJECT(WTPProtocolManager->locationData);
		WTPProtocolManager->locationData = joinRequest->location;
	} else
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if ((joinRequest->name) != NULL) {

		CW_FREE_OBJECT(WTPProtocolManager->name);
		WTPProtocolManager->name = joinRequest->name;
	} else
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	CW_FREE_OBJECT((WTPProtocolManager->WTPBoardData).vendorInfos);
	WTPProtocolManager->WTPBoardData = joinRequest->WTPBoardData;

	WTPProtocolManager->sessionID = joinRequest->sessionID;
	WTPProtocolManager->ipv4Address = joinRequest->addr;

	WTPProtocolManager->descriptor = joinRequest->WTPDescriptor;
	WTPProtocolManager->radiosInfo.radioCount = (joinRequest->WTPDescriptor).radiosInUse;
	CW_FREE_OBJECT(WTPProtocolManager->radiosInfo.radiosInfo);

	CW_CREATE_ARRAY_ERR(WTPProtocolManager->radiosInfo.radiosInfo,
			    WTPProtocolManager->radiosInfo.radioCount,
			    CWWTPRadioInfoValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	int i;

	for (i = 0; i < WTPProtocolManager->radiosInfo.radioCount; i++) {

		WTPProtocolManager->radiosInfo.radiosInfo[i].radioID = i;
		/*WTPProtocolManager->radiosInfo.radiosInfo[i].stationCount = 0; */
		/* default value for CAPWAP */
		WTPProtocolManager->radiosInfo.radiosInfo[i].adminState = ENABLED;
		WTPProtocolManager->radiosInfo.radiosInfo[i].adminCause = AD_NORMAL;
		WTPProtocolManager->radiosInfo.radiosInfo[i].operationalState = DISABLED;
		WTPProtocolManager->radiosInfo.radiosInfo[i].operationalCause = OP_NORMAL;
		WTPProtocolManager->radiosInfo.radiosInfo[i].TxQueueLevel = 0;
		WTPProtocolManager->radiosInfo.radiosInfo[i].wirelessLinkFramesPerSec = 0;
	}
	CWDebugLog("Join Request Saved");
	return CW_TRUE;
}


================================================
FILE: ACMainLoop.c
================================================
/************************************************************************************************
 * Copyright (c) 2006-2009 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica   *
 *                          Universita' Campus BioMedico - Italy                                *
 *                                                                                              *
 * This program is free software; you can redistribute it and/or modify it under the terms      *
 * of the GNU General Public License as published by the Free Software Foundation; either       *
 * version 2 of the License, or (at your option) any later version.                             *
 *                                                                                              *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY              *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A              *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                     *
 *                                                                                              *
 * You should have received a copy of the GNU General Public License along with this            *
 * program; if not, write to the:                                                               *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                         *
 * MA  02111-1307, USA.                                                                         *
 *                                                                                              *
 * -------------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                             *
 *                                                                                              *
 * Authors : Ludovico Rossi (ludo@bluepixysw.com)                                               *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                         *
 *           Giovannini Federica (giovannini.federica@gmail.com)                                *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                         *
 *           Mauro Bisson (mauro.bis@gmail.com)                                                 *
 *           Daniele De Sanctis (danieledesanctis@gmail.com)                                    *
 *           Antonio Davoli (antonio.davoli@gmail.com)                                          *
 ************************************************************************************************/

#include "CWAC.h"
#include "CWStevens.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

/* index of the current thread in the global array */
CWThreadSpecific gIndexSpecific;

int gCWWaitJoin = CW_WAIT_JOIN_DEFAULT;

CW_THREAD_RETURN_TYPE CWManageWTP(void *arg);
CW_THREAD_RETURN_TYPE CWManageTimers(void *arg);
void CWCriticalTimerExpiredHandler(int arg);
void CWSoftTimerExpiredHandler(int arg);

void CWACManageIncomingPacket(CWSocket sock,
			      unsigned char *buf,
			      int len, int incomingInterfaceIndex, CWNetworkLev4Address * addrPtr, CWBool dataFlag);
void _CWCloseThread(int i);
void CWResetWTPProtocolManager(CWWTPProtocolManager * WTPProtocolManager);
CWWTPManager *CWWTPByName(const char *addr);
int CWWTPByAddress(CWNetworkLev4Address * addressPtr, CWSocket sock);

void CWACEnterMainLoop()
{

	struct sigaction act;

	CWLog("AC enters in the MAIN_LOOP");


	/* set signals
	 * all the thread we spawn will inherit these settings
	 */

	/*
	 * BUG UMR03
	 *
	 * 20/10/2009 - Donato Capitella
	 */
	sigemptyset(&act.sa_mask);

	act.sa_flags = 0;
	/* called when a timer requested by the thread has expired */
	act.sa_handler = CWCriticalTimerExpiredHandler;
	sigaction(CW_CRITICAL_TIMER_EXPIRED_SIGNAL, &act, NULL);

	act.sa_flags = 0;
	/* called when a timer requested by the thread has expired */
	act.sa_handler = CWSoftTimerExpiredHandler;
	sigaction(CW_SOFT_TIMER_EXPIRED_SIGNAL, &act, NULL);

	/* signals will be unblocked by the threads that needs timers */
	CWThreadSetSignals(SIG_BLOCK, 2, CW_CRITICAL_TIMER_EXPIRED_SIGNAL, CW_SOFT_TIMER_EXPIRED_SIGNAL);

	if (!(CWThreadCreateSpecific(&gIndexSpecific, NULL))) {
		CWLog("Critical Error With Thread Data");
		exit(1);
	}

	CWThread thread_interface;
	if (!CWErr(CWCreateThread(&thread_interface, CWInterface, NULL))) {
		CWLog("Error starting Interface Thread");
		exit(1);
	}

	CW_REPEAT_FOREVER {
		/* CWACManageIncomingPacket will be called
		 * when a new packet is ready to be read
		 */
		if (!CWErr(CWNetworkUnsafeMultiHomed(&gACSocket, CWACManageIncomingPacket, CW_FALSE)))
			exit(1);
	}
}

/* argument passed to the thread func */
typedef struct {
	int index;
	CWSocket sock;
	int interfaceIndex;
} CWACThreadArg;

/*
 * This callback function is called when there is something to read in a
 * CWMultiHomedSocket (see ACMultiHomed.c).
 *
 * Params: sock,    is the socket that can receive the packet and it can be
 *          used to reply.
 *     buf,     (array of len chars) contains the packet which is ready
 *          on the socket's queue (obtained with MSG_PEEK).
 *     incomingInterfaceIndex,  is the index (different from the system
 *                  index, see ACMultiHomed.c) of the interface
 *                  the packet was sent to, in the array returned
 *                  by CWNetworkGetInterfaceAddresses. If the
 *                  packet was sent to a broadcast/multicast address,
 *                  incomingInterfaceIndex is -1.
 */
void CWACManageIncomingPacket(CWSocket sock,
			      unsigned char *buf,
			      int readBytes,
			      int incomingInterfaceIndex, CWNetworkLev4Address * addrPtr, CWBool dataFlag)
{

	int WTPIndex = 0;
	char *pData;

	/* check if sender address is known */
	WTPIndex = CWWTPByAddress(addrPtr, sock);

	if (WTPIndex >= 0) {
		/* known WTP */
		/* Clone data packet */
		CW_CREATE_OBJECT_SIZE_ERR(pData, readBytes, {
					  CWLog("Out Of Memory");
					  return;
					  }
		);
		memcpy(pData, buf, readBytes);

		CWLockSafeList(gWTPs[WTPIndex].packetReceiveList);
		CWAddElementToSafeListTailwitDataFlag(gWTPs[WTPIndex].packetReceiveList, pData, readBytes, dataFlag);
		CWUnlockSafeList(gWTPs[WTPIndex].packetReceiveList);
		if (dataFlag)
			CW_COPY_NET_ADDR_PTR(&(gWTPs[WTPIndex].dataAddress), addrPtr);

			
	} else {
		/* unknown WTP */
		int seqNum;
		CWDiscoveryRequestValues values;

		if (!CWErr(CWThreadMutexLock(&gActiveWTPsMutex)))
			exit(1);

		CWThreadMutexUnlock(&gActiveWTPsMutex);

		if (gActiveWTPs >= gMaxWTPs) {

			CWLog("Too many WTPs");
			return;
		}
		CWLog("\n");

		if (CWErr(CWParseDiscoveryRequestMessage(buf, readBytes, &seqNum, &values))) {

			CWProtocolMessage *msgPtr;

			CWLog("\n");
			CWLog("######### Discovery State #########");

			CWUseSockNtop(addrPtr, CWLog("CAPWAP Discovery Request from %s", str);
			    );

			/* don't add this WTP to our list to minimize DoS
			 * attacks (will be added after join)
			 */

			/* destroy useless values */
			CWDestroyDiscoveryRequestValues(&values);

			/* send response to WTP
			 * note: we can consider reassembling only changed part
			 * AND/OR do this in a new thread.
			 */
			if (!CWErr(CWAssembleDiscoveryResponse(&msgPtr, seqNum))) {
				/*
				 * note: maybe an out-of-memory memory error
				 * can be resolved without exit()-ing by
				 * killing some thread or doing other funky
				 * things.
				 */
				CWLog("Critical Error Assembling Discovery Response");
				exit(1);
			}

			if (!CWErr(CWNetworkSendUnsafeUnconnected(sock, addrPtr, (*msgPtr).msg, (*msgPtr).offset))) {

				CWLog("Critical Error Sending Discovery Response");
				exit(1);
			}

			CW_FREE_PROTOCOL_MESSAGE(*msgPtr);
			CW_FREE_OBJECT(msgPtr);
		} else {
			/* this isn't a Discovery Request */
			int i;
			CWACThreadArg *argPtr;

			CWUseSockNtop(addrPtr, CWDebugLog("Possible Client Hello from %s", str);
			    );

			if (!CWErr(CWThreadMutexLock(&gWTPsMutex)))
				exit(1);
			/* look for the first free slot */
			for (i = 0; i < gMaxWTPs && gWTPs[i].isNotFree; i++) ;

			CW_COPY_NET_ADDR_PTR(&(gWTPs[i].address), addrPtr);
	                if (dataFlag)
                        CW_COPY_NET_ADDR_PTR(&(gWTPs[i].dataAddress), addrPtr);

			gWTPs[i].isNotFree = CW_TRUE;
			gWTPs[i].isRequestClose = CW_FALSE;
			CWThreadMutexUnlock(&gWTPsMutex);

			/* Capwap receive packets list */
			if (!CWErr(CWCreateSafeList(&gWTPs[i].packetReceiveList))) {

				if (!CWErr(CWThreadMutexLock(&gWTPsMutex)))
					exit(1);
				gWTPs[i].isNotFree = CW_FALSE;
				CWThreadMutexUnlock(&gWTPsMutex);
				return;
			}

			CWSetMutexSafeList(gWTPs[i].packetReceiveList, &gWTPs[i].interfaceMutex);
			CWSetConditionSafeList(gWTPs[i].packetReceiveList, &gWTPs[i].interfaceWait);

			CW_CREATE_OBJECT_ERR(argPtr, CWACThreadArg, {
					     CWLog("Out Of Memory");
					     return;
					     }
			);

			argPtr->index = i;
			argPtr->sock = sock;
			argPtr->interfaceIndex = incomingInterfaceIndex;

			/*
			 * If the packet was addressed to a broadcast address,
			 * just choose an interface we like (note: we can consider
			 * a bit load balancing instead of hard-coding 0-indexed
			 * interface). Btw, Join Request should not really be
			 * accepted if addressed to a broadcast address, so we
			 * could simply discard the packet and go on.
			 * If you leave this code, the WTP Count will increase
			 * for the interface we hard-code here, even if it is not
			 * necessary the interface we use to send packets to that
			 * WTP. If we really want to accept Join Request from
			 * broadcast address, we can consider asking to the kernel
			 * which interface will be used to send the packet to a
			 * specific address (if it remains the same) and than
			 * increment WTPCount for that interface instead of 0-indexed one.
			 */
			if (argPtr->interfaceIndex < 0)
				argPtr->interfaceIndex = 0;

			/* create the thread that will manage this WTP */
			if (!CWErr(CWCreateThread(&(gWTPs[i].thread), CWManageWTP, argPtr))) {

				CW_FREE_OBJECT(argPtr);
				if (!CWErr(CWThreadMutexLock(&gWTPsMutex)))
					exit(1);

				CWDestroySafeList(&gWTPs[i].packetReceiveList);
				gWTPs[i].isNotFree = CW_FALSE;
				CWThreadMutexUnlock(&gWTPsMutex);

				return;
			}

			/* Clone data packet */
			CW_CREATE_OBJECT_SIZE_ERR(pData, readBytes, {
						  CWLog("Out Of Memory");
						  return;
						  }
			);
			memcpy(pData, buf, readBytes);

			CWLockSafeList(gWTPs[i].packetReceiveList);
			CWAddElementToSafeListTailwitDataFlag(gWTPs[i].packetReceiveList, pData, readBytes, dataFlag);
			CWUnlockSafeList(gWTPs[i].packetReceiveList);
		}
	}
}

/*
 * Simple job: see if we have a thread that is serving address *addressPtr
 */
__inline__ int CWWTPByAddress(CWNetworkLev4Address * addressPtr, CWSocket sock)
{

	int i;
	if (addressPtr == NULL)
		return -1; 

	CWThreadMutexLock(&gWTPsMutex);
	for (i = 0; i < gMaxWTPs; i++) {

		if (gWTPs[i].isNotFree &&
		    &(gWTPs[i].address) != NULL &&
		    !sock_cmp_addr((struct sockaddr *)addressPtr,
				   (struct sockaddr *)&(gWTPs[i].address), sizeof(CWNetworkLev4Address))) {

			/* we treat a WTP that sends packet to a different
			 * AC's interface as a new WTP
			 */
			CWThreadMutexUnlock(&gWTPsMutex);
			return i;
		}
	}

	CWThreadMutexUnlock(&gWTPsMutex);

	return -1;
}

/*
 * Session's thread function: each thread will manage a single session
 * with one WTP.
 */
CW_THREAD_RETURN_TYPE CWManageWTP(void *arg)
{

	int i = ((CWACThreadArg *) arg)->index;
	CWSocket sock = ((CWACThreadArg *) arg)->sock;
	int interfaceIndex = ((CWACThreadArg *) arg)->interfaceIndex;

	CW_FREE_OBJECT(arg);

	if (!(CWThreadSetSpecific(&gIndexSpecific, &i))) {

		CWLog("Critical Error with Thread Data");
		_CWCloseThread(i);
	}

	if (!CWErr(CWThreadMutexLock(&gActiveWTPsMutex)))
		exit(1);

	gActiveWTPs++;

	gInterfaces[interfaceIndex].WTPCount++;
	CWUseSockNtop(((struct sockaddr *)&(gInterfaces[interfaceIndex].addr)),
		      CWDebugLog("One more WTP on %s (%d)", str, interfaceIndex););

	CWThreadMutexUnlock(&gActiveWTPsMutex);

	CWACInitBinding(i);

	gWTPs[i].interfaceIndex = interfaceIndex;
	gWTPs[i].socket = sock;

	gWTPs[i].fragmentsList = NULL;
	/* we're in the join state for this session */
	gWTPs[i].currentState = CW_ENTER_JOIN;
	gWTPs[i].subState = CW_DTLS_HANDSHAKE_IN_PROGRESS;

	/**** ACInterface ****/
	gWTPs[i].interfaceCommandProgress = CW_FALSE;
	gWTPs[i].interfaceCommand = NO_CMD;
	CWDestroyThreadMutex(&gWTPs[i].interfaceMutex);
	CWCreateThreadMutex(&gWTPs[i].interfaceMutex);
	CWDestroyThreadMutex(&gWTPs[i].interfaceSingleton);
	CWCreateThreadMutex(&gWTPs[i].interfaceSingleton);
	CWDestroyThreadCondition(&gWTPs[i].interfaceWait);
	CWCreateThreadCondition(&gWTPs[i].interfaceWait);
	CWDestroyThreadCondition(&gWTPs[i].interfaceComplete);
	CWCreateThreadCondition(&gWTPs[i].interfaceComplete);
	gWTPs[i].qosValues = NULL;
	/**** ACInterface ****/

	gWTPs[i].messages = NULL;
	gWTPs[i].messagesCount = 0;
	gWTPs[i].isRetransmitting = CW_FALSE;
	gWTPs[i].retransmissionCount = 0;

	CWResetWTPProtocolManager(&(gWTPs[i].WTPProtocolManager));

	CWLog("New Session");

	/* start WaitJoin timer */
	if (!CWErr(CWTimerRequest(gCWWaitJoin,
				  &(gWTPs[i].thread), &(gWTPs[i].currentTimer), CW_CRITICAL_TIMER_EXPIRED_SIGNAL))) {

		CWCloseThread();
	}
#ifndef CW_NO_DTLS
	CWDebugLog("Init DTLS Session");

	if (!CWErr(CWSecurityInitSessionServer(&gWTPs[i],
					       sock, gACSecurityContext, &((gWTPs[i]).session), &(gWTPs[i].pathMTU)))) {

		CWTimerCancel(&(gWTPs[i].currentTimer));
		CWCloseThread();
	}
#endif
	(gWTPs[i]).subState = CW_WAITING_REQUEST;

	if (gCWForceMTU > 0)
		gWTPs[i].pathMTU = gCWForceMTU;

	CWDebugLog("Path MTU for this Session: %d", gWTPs[i].pathMTU);

	CW_REPEAT_FOREVER {
		int readBytes;
		CWProtocolMessage msg;
		CWBool dataFlag = CW_FALSE;

		msg.msg = NULL;
		msg.offset = 0;

		/* Wait WTP action */

		CWThreadMutexLock(&gWTPs[i].interfaceMutex);

		while ((gWTPs[i].isRequestClose == CW_FALSE) &&
		       (CWGetCountElementFromSafeList(gWTPs[i].packetReceiveList) == 0) &&
		       (gWTPs[i].interfaceCommand == NO_CMD)) {

			/*TODO: Check system */
			CWWaitThreadCondition(&gWTPs[i].interfaceWait, &gWTPs[i].interfaceMutex);
		}

		CWThreadMutexUnlock(&gWTPs[i].interfaceMutex);

		if (gWTPs[i].isRequestClose) {

			CWLog("Request close thread");
			_CWCloseThread(i);
		}

		CWThreadSetSignals(SIG_BLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);

		if (CWGetCountElementFromSafeList(gWTPs[i].packetReceiveList) > 0) {

			CWBool bCrypt = CW_FALSE;
			char *pBuffer;

			CWThreadMutexLock(&gWTPs[i].interfaceMutex);
			pBuffer = (char *)CWGetHeadElementFromSafeList(gWTPs[i].packetReceiveList, NULL);

			if (((pBuffer[0] & 0x0f) == CW_PACKET_CRYPT) && ((gWTPs[i].buf[0] & 0x0f) == CW_PACKET_CRYPT))
				bCrypt = CW_TRUE;

			CWThreadMutexUnlock(&gWTPs[i].interfaceMutex);

			if (bCrypt) {
#ifndef CW_NO_DTLS
				if (!CWErr(CWSecurityReceive(gWTPs[i].session,
							     gWTPs[i].buf, CW_BUFFER_SIZE - 1, &readBytes))) {
					/* error */

					CWDebugLog("Error during security receive");
					CWThreadSetSignals(SIG_UNBLOCK, 1, CW_SOFT_TIMER_EXPIRED_SIGNAL);

					continue;
				}
#else
				CWDebugLog("CAPWAP DTLS in not supported");
				CWThreadSetSignals(SIG_UNBLOCK, 1, CW_SOFT_TIMER_EXPIRED_SIGNAL);

				continue;
#endif
			} else {
				CWThreadMutexLock(&gWTPs[i].interfaceMutex);
				pBuffer =
				    (char *)CWRemoveHeadElementFromSafeListwithDataFlag(gWTPs[i].packetReceiveList,
											&readBytes, &dataFlag);
				CWThreadMutexUnlock(&gWTPs[i].interfaceMutex);

				memcpy(gWTPs[i].buf, pBuffer, readBytes);
				CW_FREE_OBJECT(pBuffer);
			}

			if (!CWProtocolParseFragment(gWTPs[i].buf,
						     readBytes,
						     &(gWTPs[i].fragmentsList), &msg, &dataFlag, gWTPs[i].RadioMAC)) {

				if (CWErrorGetLastErrorCode() == CW_ERROR_NEED_RESOURCE) {

					CWDebugLog("Need At Least One More Fragment");
				} else {
					CWErrorHandleLast();
				}
				CWThreadSetSignals(SIG_UNBLOCK, 1, CW_SOFT_TIMER_EXPIRED_SIGNAL);

				continue;
			}

			switch (gWTPs[i].currentState) {
			case CW_ENTER_JOIN:{
					/* we're inside the join state */
					if (!ACEnterJoin(i, &msg)) {
						if (CWErrorGetLastErrorCode() == CW_ERROR_INVALID_FORMAT) {
							/* Log and ignore other messages */
							CWErrorHandleLast();
							CWLog("Received something different from a Join Request");
						} else {
							/* critical error, close session */
							CWErrorHandleLast();
							CWThreadSetSignals(SIG_UNBLOCK, 1,
									   CW_SOFT_TIMER_EXPIRED_SIGNAL);
							CWCloseThread();
						}
					}
					break;
				}
			case CW_ENTER_CONFIGURE:{
					if (!ACEnterConfigure(i, &msg)) {
						if (CWErrorGetLastErrorCode() == CW_ERROR_INVALID_FORMAT) {
							/* Log and ignore other messages */
							CWErrorHandleLast();
							CWLog("Received something different from a Configure Request");
						} else {
							/* critical error, close session */
							CWErrorHandleLast();
							CWThreadSetSignals(SIG_UNBLOCK, 1,
									   CW_SOFT_TIMER_EXPIRED_SIGNAL);
							CWCloseThread();
						}
					}
					break;
				}
			case CW_ENTER_DATA_CHECK:{
					if (!ACEnterDataCheck(i, &msg)) {
						if (CWErrorGetLastErrorCode() == CW_ERROR_INVALID_FORMAT) {
							/* Log and ignore other messages */
							CWErrorHandleLast();
							CWLog
							    ("Received something different from a Change State Event Request");
						} else {
							/* critical error, close session */
							CWErrorHandleLast();
							CWThreadSetSignals(SIG_UNBLOCK, 1,
									   CW_SOFT_TIMER_EXPIRED_SIGNAL);
							CWCloseThread();
						}
					}
					break;
				}
			case CW_ENTER_RUN:{
					if (!ACEnterRun(i, &msg, dataFlag)) {
						if (CWErrorGetLastErrorCode() == CW_ERROR_INVALID_FORMAT) {
							/* Log and ignore other messages */
							CWErrorHandleLast();
							CWLog
							    ("--> Received something different from a valid Run Message");
						} else {
							/* critical error, close session */
							CWLog("--> Critical Error... closing thread");
							CWErrorHandleLast();
							CWThreadSetSignals(SIG_UNBLOCK, 1,
									   CW_SOFT_TIMER_EXPIRED_SIGNAL);
							CWCloseThread();
						}
					}
					break;
				}
			default:{
					CWLog("Not Handled Packet");
					break;
				}
			}
			CW_FREE_PROTOCOL_MESSAGE(msg);
		} else {

			CWThreadMutexLock(&gWTPs[i].interfaceMutex);

			if (gWTPs[i].interfaceCommand != NO_CMD) {

				CWBool bResult = CW_FALSE;

				switch (gWTPs[i].interfaceCommand) {
				case QOS_CMD:{
						int seqNum = CWGetSeqNum();

						/* CWDebugLog("~~~~~~seq num in Check: %d~~~~~~", seqNum); */
						if (CWAssembleConfigurationUpdateRequest(&(gWTPs[i].messages),
											 &(gWTPs[i].messagesCount),
											 gWTPs[i].pathMTU,
											 seqNum,
											 CONFIG_UPDATE_REQ_QOS_ELEMENT_TYPE))
						{

							if (CWACSendAcknowledgedPacket
							    (i, CW_MSG_TYPE_VALUE_CONFIGURE_UPDATE_RESPONSE, seqNum))
								bResult = CW_TRUE;
							else
								CWACStopRetransmission(i);
						}
						break;
					}
				case CLEAR_CONFIG_MSG_CMD:{
						int seqNum = CWGetSeqNum();

						/* Clear Configuration Request */
						if (CWAssembleClearConfigurationRequest(&(gWTPs[i].messages),
											&(gWTPs[i].messagesCount),
											gWTPs[i].pathMTU, seqNum)) {

							if (CWACSendAcknowledgedPacket
							    (i, CW_MSG_TYPE_VALUE_CLEAR_CONFIGURATION_RESPONSE, seqNum))
								bResult = CW_TRUE;
							else
								CWACStopRetransmission(i);
						}
						break;
					}
				/********************************************************
				 * 2009 Update:                                         *
				 *              New switch case for OFDM_CONTROL_CMD    *
				 ********************************************************/

				case OFDM_CONTROL_CMD:{
						int seqNum = CWGetSeqNum();

						if (CWAssembleConfigurationUpdateRequest(&(gWTPs[i].messages),
											 &(gWTPs[i].messagesCount),
											 gWTPs[i].pathMTU,
											 seqNum,
											 CONFIG_UPDATE_REQ_OFDM_ELEMENT_TYPE))
						{

							if (CWACSendAcknowledgedPacket
							    (i, CW_MSG_TYPE_VALUE_CONFIGURE_UPDATE_RESPONSE, seqNum))
								bResult = CW_TRUE;
							else
								CWACStopRetransmission(i);
						}
						break;
					}
					/*Update 2009
					   Added case to manage UCI configuration command */
				case UCI_CONTROL_CMD:{
						int seqNum = CWGetSeqNum();

						if (CWAssembleConfigurationUpdateRequest(&(gWTPs[i].messages),
											 &(gWTPs[i].messagesCount),
											 gWTPs[i].pathMTU,
											 seqNum,
											 CONFIG_UPDATE_REQ_VENDOR_UCI_ELEMENT_TYPE))
						{

							if (CWACSendAcknowledgedPacket
							    (i, CW_MSG_TYPE_VALUE_CONFIGURE_UPDATE_RESPONSE, seqNum))
								bResult = CW_TRUE;
							else
								CWACStopRetransmission(i);
						}
						break;
					}
				case WTP_UPDATE_CMD:{
						int seqNum = CWGetSeqNum();

						if (CWAssembleConfigurationUpdateRequest(&(gWTPs[i].messages),
											 &(gWTPs[i].messagesCount),
											 gWTPs[i].pathMTU,
											 seqNum,
											 CONFIG_UPDATE_REQ_VENDOR_WUM_ELEMENT_TYPE))
						{

							if (CWACSendAcknowledgedPacket
							    (i, CW_MSG_TYPE_VALUE_CONFIGURE_UPDATE_RESPONSE, seqNum))
								bResult = CW_TRUE;
							else
								CWACStopRetransmission(i);
						}
						break;

					}
				}

				gWTPs[i].interfaceCommand = NO_CMD;

				if (bResult)
					gWTPs[i].interfaceCommandProgress = CW_TRUE;
				else {
					gWTPs[i].interfaceResult = 0;
					CWSignalThreadCondition(&gWTPs[i].interfaceComplete);
					CWDebugLog("Error sending command");
				}
			}
			CWThreadMutexUnlock(&gWTPs[i].interfaceMutex);
		}
		CWThreadSetSignals(SIG_UNBLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);
	}
}

void _CWCloseThread(int i)
{

	CWThreadSetSignals(SIG_BLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);

	/**** ACInterface ****/
	gWTPs[i].qosValues = NULL;
	CWThreadMutexUnlock(&(gWTPs[i].interfaceMutex));
	/**** ACInterface ****/

	if (!CWErr(CWThreadMutexLock(&gActiveWTPsMutex)))
		exit(1);

	gInterfaces[gWTPs[i].interfaceIndex].WTPCount--;
	gActiveWTPs--;

	CWUseSockNtop(((struct sockaddr *)&(gInterfaces[gWTPs[i].interfaceIndex].addr)),
		      CWLog("Remove WTP on Interface %s (%d)", str, gWTPs[i].interfaceIndex);
	    );

	CWThreadMutexUnlock(&gActiveWTPsMutex);

	CWDebugLog("Close Thread: %08x", (unsigned int)CWThreadSelf());

#ifndef CW_NO_DTLS
	if (gWTPs[i].subState != CW_DTLS_HANDSHAKE_IN_PROGRESS) {

		CWSecurityDestroySession(gWTPs[i].session);
	}
#endif

	/* this will do nothing if the timer isn't active */
	CWTimerCancel(&(gWTPs[i].currentTimer));
	CWACStopRetransmission(i);

	if (gWTPs[i].interfaceCommandProgress == CW_TRUE) {

		CWThreadMutexLock(&gWTPs[i].interfaceMutex);

		gWTPs[i].interfaceResult = 1;
		gWTPs[i].interfaceCommandProgress = CW_FALSE;
		CWSignalThreadCondition(&gWTPs[i].interfaceComplete);

		CWThreadMutexUnlock(&gWTPs[i].interfaceMutex);
	}

	gWTPs[i].session = NULL;
	gWTPs[i].subState = CW_DTLS_HANDSHAKE_IN_PROGRESS;
	CWDeleteList(&(gWTPs[i].fragmentsList), CWProtocolDestroyFragment);

	/* CW_FREE_OBJECT(gWTPs[i].configureReqValuesPtr); */

	CWCleanSafeList(gWTPs[i].packetReceiveList, free);
	CWDestroySafeList(gWTPs[i].packetReceiveList);

	CWThreadMutexLock(&gWTPsMutex);
	gWTPs[i].isNotFree = CW_FALSE;
	CWThreadMutexUnlock(&gWTPsMutex);

	CWExitThread();
}

void CWCloseThread()
{

	int *iPtr;

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {

		CWLog("Error Closing Thread");
		return;
	}

	_CWCloseThread(*iPtr);
}

void CWCriticalTimerExpiredHandler(int arg)
{

	int *iPtr;

	CWThreadSetSignals(SIG_BLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);

	CWDebugLog("Critical Timer Expired for Thread: %08x", (unsigned int)CWThreadSelf());
	CWDebugLog("Abort Session");
	/* CWCloseThread(); */

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {

		CWLog("Error Handling Critical timer");
		CWThreadSetSignals(SIG_UNBLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);
		return;
	}

	/* Request close thread */
	gWTPs[*iPtr].isRequestClose = CW_TRUE;
	CWSignalThreadCondition(&gWTPs[*iPtr].interfaceWait);
}

void CWSoftTimerExpiredHandler(int arg)
{

	int *iPtr;

	CWThreadSetSignals(SIG_BLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);

	CWDebugLog("Soft Timer Expired for Thread: %08x", (unsigned int)CWThreadSelf());

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {

		CWLog("Error Handling Soft timer");
		CWThreadSetSignals(SIG_UNBLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);
		return;
	}

	if ((!gWTPs[*iPtr].isRetransmitting) || (gWTPs[*iPtr].messages == NULL)) {

		CWDebugLog("Soft timer expired but we are not retransmitting");
		CWThreadSetSignals(SIG_UNBLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);
		return;
	}

	(gWTPs[*iPtr].retransmissionCount)++;

	CWDebugLog("Retransmission Count increases to %d", gWTPs[*iPtr].retransmissionCount);

	if (gWTPs[*iPtr].retransmissionCount >= gCWMaxRetransmit) {
		CWDebugLog("Peer is Dead");
		/* ?? _CWCloseThread(*iPtr);
		 * Request close thread
		 */
		gWTPs[*iPtr].isRequestClose = CW_TRUE;
		CWSignalThreadCondition(&gWTPs[*iPtr].interfaceWait);
		return;
	}

	if (!CWErr(CWACResendAcknowledgedPacket(*iPtr))) {
		_CWCloseThread(*iPtr);
	}

	/* CWDebugLog("~~~~~~fine ritrasmissione ~~~~~"); */
	CWThreadSetSignals(SIG_UNBLOCK, 2, CW_SOFT_TIMER_EXPIRED_SIGNAL, CW_CRITICAL_TIMER_EXPIRED_SIGNAL);
}

void CWResetWTPProtocolManager(CWWTPProtocolManager * WTPProtocolManager)
{

	CW_FREE_OBJECT(WTPProtocolManager->locationData);
	CW_FREE_OBJECT(WTPProtocolManager->name);
	WTPProtocolManager->sessionID = 0;
	WTPProtocolManager->descriptor.maxRadios = 0;
	WTPProtocolManager->descriptor.radiosInUse = 0;
	WTPProtocolManager->descriptor.encCapabilities.encryptCapsCount = 0;
	CW_FREE_OBJECT(WTPProtocolManager->descriptor.encCapabilities.encryptCaps);
	WTPProtocolManager->descriptor.vendorInfos.vendorInfosCount = 0;
	CW_FREE_OBJECT(WTPProtocolManager->descriptor.vendorInfos.vendorInfos);

	WTPProtocolManager->radiosInfo.radioCount = 0;
	CW_FREE_OBJECT(WTPProtocolManager->radiosInfo.radiosInfo);
	CW_FREE_OBJECT(WTPProtocolManager->ACName);
	(WTPProtocolManager->ACNameIndex).count = 0;
	CW_FREE_OBJECT((WTPProtocolManager->ACNameIndex).ACNameIndex);
	(WTPProtocolManager->radioAdminInfo).radiosCount = 0;
	CW_FREE_OBJECT((WTPProtocolManager->radioAdminInfo).radios);
	WTPProtocolManager->StatisticsTimer = 0;
	(WTPProtocolManager->WTPBoardData).vendorInfosCount = 0;
	CW_FREE_OBJECT((WTPProtocolManager->WTPBoardData).vendorInfos);
	CW_FREE_OBJECT(WTPProtocolManager->WTPRebootStatistics);

	//CWWTPResetRebootStatistics(&(WTPProtocolManager->WTPRebootStatistics));

	/*
	 **mancano questi campi:**
	 CWNetworkLev4Address address;
	 int pathMTU;
	 struct sockaddr_in ipv4Address;
	 CWProtocolConfigureRequestValues *configureReqValuesPtr;
	 CWTimerID currentPacketTimer;
	 */
}


================================================
FILE: ACMultiHomedSocket.c
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#include "CWAC.h"

#include "common.h"
#include "ieee802_11_defs.h"

#define TYPE_LEN 2
#define ETH_ALEN 6
#define ETH_HLEN 14

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif

void CWNetworkDeleteMHInterface(void *intPtr)
{

	CW_FREE_OBJECT(intPtr);
}

int from_8023_to_80211(unsigned char *inbuffer, int inlen, unsigned char *outbuffer, unsigned char *own_addr)
{

	int indx = 0;
	struct ieee80211_hdr hdr;
	os_memset(&hdr, 0, sizeof(struct ieee80211_hdr));

	hdr.frame_control = IEEE80211_FC(WLAN_FC_TYPE_DATA, WLAN_FC_STYPE_DATA) | host_to_le16(WLAN_FC_FROMDS);
	hdr.duration_id = 0;
	hdr.seq_ctrl = 0;

	os_memcpy(hdr.addr1, inbuffer, ETH_ALEN);
	os_memcpy(hdr.addr2, own_addr, ETH_ALEN);
	os_memcpy(hdr.addr3, inbuffer + ETH_ALEN, ETH_ALEN);

	os_memcpy(outbuffer + indx, &hdr, sizeof(hdr));
	indx += sizeof(hdr);
	os_memcpy(outbuffer + indx, inbuffer, inlen);
	indx += inlen;

	return indx;
}

/*
 * Multihomed sockets maps the system index for each interface to a array-like
 * int index in range 0-(# of interfaces -1). This function returns the int
 * index given the system index of an interface managed by the given multihomed
 * socket.
 */
int CWNetworkGetInterfaceIndexFromSystemIndex(CWMultiHomedSocket * sockPtr, int systemIndex)
{

	int i, c;

	if (sockPtr == NULL || systemIndex == -1)
		return -1;

	for (i = 0, c = 0; i < sockPtr->count; i++) {

		if (sockPtr->interfaces[i].kind == CW_PRIMARY) {

			/* each primary interface increments the int index */
			if (sockPtr->interfaces[i].systemIndex == systemIndex)
				return c;
			c++;
		}
	}
	return -1;
}

/*
 * Check if the interface with system index systemIndex is already managed by
 * the multihomed socket. If the answer is yes, returns informations on that
 * interface, returns NULL otherwise.
 */
CWMultiHomedInterface *CWNetworkGetInterfaceAlreadyStored(CWList list, short systemIndex)
{

	CWListElement *el;

	for (el = list; el != NULL; el = el->next) {

		if (((CWMultiHomedInterface *) (el->data))->systemIndex == systemIndex &&
		    ((CWMultiHomedInterface *) (el->data))->kind == CW_PRIMARY)

			return (CWMultiHomedInterface *) el->data;
	}
	return NULL;
}

/*
 * Init multihomed socket. Will bind a socket for each interface + each
 * broadcast address + the wildcard addres + each multicast address in
 * multicastGroups.
 */
CWBool CWNetworkInitSocketServerMultiHomed(CWMultiHomedSocket * sockPtr,
					   int port, char **multicastGroups, int multicastGroupsCount)
{

	struct ifi_info *ifi, *ifihead;
	CWNetworkLev4Address wildaddr;
	int yes = 1;
	CWSocket sock;
	CWMultiHomedInterface *p;
	CWList interfaceList = CW_LIST_INIT;
	CWListElement *el = NULL;
	int i;

	if (sockPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	sockPtr->count = 0;

	/*
	 * note: if get_ifi_info is called with AF_INET6 on an host that doesn't
	 * support IPv6, it'll simply act like if it was called with AF_INET.
	 * Consider aliases as different interfaces (last arg of get_ifi_info is 1).
	 * Why? Just to increase the funny side of the thing.
	 */
#ifdef CW_DEBUGGING
	/* for each network interface... */
	for (ifihead = ifi = get_ifi_info((gNetworkPreferredFamily == CW_IPv6) ? AF_INET6 : AF_INET, 1); ifi != NULL;
	     ifi = ifi->ifi_next) {
#else
	/* for each network interface... */
	for (ifihead = ifi = get_ifi_info((gNetworkPreferredFamily == CW_IPv6) ? AF_INET6 : AF_INET, 0); ifi != NULL;
	     ifi = ifi->ifi_next) {
#endif
		/* bind a unicast address */
		if ((sock = socket(ifi->ifi_addr->sa_family, SOCK_DGRAM, 0)) < 0) {

			free_ifi_info(ifihead);
			CWNetworkRaiseSystemError(CW_ERROR_CREATING);
		}

		/* reuse address */
		setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));

		/* bind address */
		sock_set_port_cw(ifi->ifi_addr, htons(port));

		if (bind
		    (sock, (struct sockaddr *)ifi->ifi_addr,
		     CWNetworkGetAddressSize((CWNetworkLev4Address *) ifi->ifi_addr)) < 0) {

			close(sock);
			CWUseSockNtop(ifi->ifi_addr, CWDebugLog("failed %s", str);
			    );
			continue;
			/* CWNetworkRaiseSystemError(CW_ERROR_CREATING); */
		}

		CWUseSockNtop(ifi->ifi_addr, CWLog("bound %s (%d, %s)", str, ifi->ifi_index, ifi->ifi_name);
		    );

		/* store socket inside multihomed socket */
		CW_CREATE_OBJECT_ERR(p, CWMultiHomedInterface, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		p->sock = sock;
		if (CWNetworkGetInterfaceAlreadyStored(interfaceList, ifi->ifi_index) == NULL &&
		    strncmp(ifi->ifi_name, "lo", 2)) {
			/* don't consider loopback an interface
			   (even if we accept packets from loopback) */
			CWDebugLog("Primary Address");
			p->kind = CW_PRIMARY;

		} else {
			/* should be BROADCAST_OR_ALIAS_OR_MULTICAST_OR_LOOPBACK ;-) */
			p->kind = CW_BROADCAST_OR_ALIAS;
#ifdef CW_DEBUGGING
#if 0
			if (!strncmp(ifi->ifi_name, "lo", 2)) {
				p->kind = CW_PRIMARY;
			}
#endif
#endif
		}

		p->systemIndex = ifi->ifi_index;

		/* the next field is useful only if we are an IPv6 server. In
		 * this case, p->addr contains the IPv6 address of the interface
		 * and p->addrIPv4 contains the equivalent IPv4 address. On the
		 * other side, if we are an IPv4 server p->addr contains the
		 * IPv4 address of the interface and p->addrIPv4 is garbage.
		 */
		p->addrIPv4.ss_family = AF_UNSPEC;

		CW_COPY_NET_ADDR_PTR(&(p->addr), ifi->ifi_addr);
		// Todd: Bind data channel to port 5427
		/* bind a unicast address of data UDP stream */
		if ((sock = socket(ifi->ifi_addr->sa_family, SOCK_DGRAM, 0)) < 0) {
			free_ifi_info(ifihead);
			CWNetworkRaiseSystemError(CW_ERROR_CREATING);
		}

		/* reuse address */
		setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));

		/* bind address */
		sock_set_port_cw(ifi->ifi_addr, htons(port + 1));

		if (bind
		    (sock, (struct sockaddr *)ifi->ifi_addr,
		     CWNetworkGetAddressSize((CWNetworkLev4Address *) ifi->ifi_addr)) < 0) {
			close(sock);
			CWUseSockNtop(ifi->ifi_addr, CWDebugLog("failed %s", str);
			    );
			continue;
			/* CWNetworkRaiseSystemError(CW_ERROR_CREATING); */
		}

		CWUseSockNtop(ifi->ifi_addr,
			      CWLog("Data channel bound %s (%d, %s)", str, ifi->ifi_index, ifi->ifi_name);
		    );

		CW_COPY_NET_ADDR_PTR(&(p->dataAddr), ifi->ifi_addr);
		p->dataSock = sock;

		if (!CWAddElementToList(&interfaceList, p)) {

			return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		}
		/* we add a socket to the multihomed socket */
		sockPtr->count++;

		if (ifi->ifi_flags & IFF_BROADCAST) {
			/* try to bind broadcast address */
			if ((sock = socket(ifi->ifi_addr->sa_family, SOCK_DGRAM, 0)) < 0) {

				free_ifi_info(ifihead);
				CWDeleteList(&interfaceList, CWNetworkDeleteMHInterface);
				CWNetworkRaiseSystemError(CW_ERROR_CREATING);
			}

			/* reuse address */
			setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));

			sock_set_port_cw(ifi->ifi_brdaddr, htons(port));

			if (bind(sock, (struct sockaddr *)ifi->ifi_brdaddr,
				 CWNetworkGetAddressSize((CWNetworkLev4Address *) ifi->ifi_brdaddr)) < 0) {

				close(sock);
				if (errno == EADDRINUSE) {
					CWUseSockNtop(ifi->ifi_brdaddr, CWDebugLog("EADDRINUSE: %s", str););
					continue;
				} else {
					CWUseSockNtop(ifi->ifi_brdaddr, CWDebugLog("failed %s", str););
					continue;
					/* CWDeleteList(&interfaceList, CWNetworkDeleteMHInterface); */
					/* CWNetworkRaiseSystemError(CW_ERROR_CREATING); */
				}
			}

			CWUseSockNtop(ifi->ifi_brdaddr, CWLog("bound %s (%d, %s)", str, ifi->ifi_index, ifi->ifi_name);
			    );

			/* store socket inside multihomed socket */

			CW_CREATE_OBJECT_ERR(p, CWMultiHomedInterface,
					     return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
			    );
			p->sock = sock;
			p->kind = CW_BROADCAST_OR_ALIAS;
			p->systemIndex = ifi->ifi_index;
			CW_COPY_NET_ADDR_PTR(&(p->addr), ifi->ifi_brdaddr);

			/* The next field is useful only if we are an IPv6 server.
			 * In this case, p->addr contains the IPv6 address of the
			 * interface and p->addrIPv4 contains the equivalent IPv4
			 * address. On the other side, if we are an IPv4 server
			 * p->addr contains the IPv4 address of the interface and
			 * p->addrIPv4 is garbage.
			 */
			p->addrIPv4.ss_family = AF_UNSPEC;

			if (!CWAddElementToList(&interfaceList, p)) {

				return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
			}
			/* we add a socket to the multihomed socket */
			sockPtr->count++;
		}
	}

	/* get_ifi_info returned an error */
	if (ifihead == NULL) {

		CWDeleteList(&interfaceList, CWNetworkDeleteMHInterface);
		return CWErrorRaise(CW_ERROR_NEED_RESOURCE, "Error With get_ifi_info()");
	}
	free_ifi_info(ifihead);

#ifdef IPV6
	/* we are an IPv6 server */
	if (gNetworkPreferredFamily == CW_IPv6) {
		/*
		 * Store IPv4 addresses for our interfaces in the field "addrIPv4".
		 * Consider aliases as different interfaces (last arg of get_ifi_info is 1).
		 * Why? Just to increase the funny side of the thing.
		 */
#ifdef CW_DEBUGGING
		for (ifihead = ifi = get_ifi_info(AF_INET, 1); ifi != NULL; ifi = ifi->ifi_next) {
#else
		for (ifihead = ifi = get_ifi_info(AF_INET, 0); ifi != NULL; ifi = ifi->ifi_next) {
#endif
			CWMultiHomedInterface *s = CWNetworkGetInterfaceAlreadyStored(interfaceList, ifi->ifi_index);

			if (s == NULL ||
			    s->kind != CW_PRIMARY ||
			    s->addrIPv4.ss_family != AF_UNSPEC || ifi->ifi_addr->sa_family != AF_INET)
				continue;

			CW_COPY_NET_ADDR_PTR(&(s->addrIPv4), ifi->ifi_addr);

			CWUseSockNtop(&(s->addrIPv4),
				      CWDebugLog("IPv4 address %s (%d, %s)", str, ifi->ifi_index, ifi->ifi_name);
			    );
		}
		/* get_ifi_info returned an error */
		if (ifihead == NULL) {

			CWDeleteList(&interfaceList, CWNetworkDeleteMHInterface);
			return CWErrorRaise(CW_ERROR_NEED_RESOURCE, "Error with get_ifi_info()");
		}
		free_ifi_info(ifihead);
	}
#endif
	/* bind wildcard address */
#ifdef  IPV6
	if (gNetworkPreferredFamily == CW_IPv6) {

		if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
			goto fail;
		}
	} else
#endif
	{
		if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
			goto fail;
	}

	goto success;

 fail:
	CWDeleteList(&interfaceList, CWNetworkDeleteMHInterface);
	CWNetworkRaiseSystemError(CW_ERROR_CREATING);	/* this wil return */
	/* not reached */

 success:
	/* reuse address */
	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
	CW_ZERO_MEMORY(&wildaddr, sizeof(wildaddr));

#ifdef  IPV6
	if (gNetworkPreferredFamily == CW_IPv6) {
		/* fill wildaddr considering it an IPv6 addr */
		struct sockaddr_in6 *a = (struct sockaddr_in6 *)&wildaddr;
		a->sin6_family = AF_INET6;
		a->sin6_addr = in6addr_any;
		a->sin6_port = htons(port);
	} else
#endif
	{
		/* fill wildaddr considering it an IPv4 addr */
		struct sockaddr_in *a = (struct sockaddr_in *)&wildaddr;
		a->sin_family = AF_INET;
		a->sin_addr.s_addr = htonl(INADDR_ANY);
		a->sin_port = htons(port);
	}

	if (bind(sock, (struct sockaddr *)&wildaddr, CWNetworkGetAddressSize(&wildaddr)) < 0) {
		close(sock);
		CWDeleteList(&interfaceList, CWNetworkDeleteMHInterface);
		CWNetworkRaiseSystemError(CW_ERROR_CREATING);
	}

	CWUseSockNtop(&wildaddr, CWLog("bound %s", str););

	CW_CREATE_OBJECT_ERR(p, CWMultiHomedInterface, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );
	p->sock = sock;
	p->kind = CW_BROADCAST_OR_ALIAS;
	p->systemIndex = -1;	/* make sure this can't be
				   confused with an interface */

	/* addrIPv4 field for the wildcard address cause it
	 * is garbage in both cases (IPv4 + IPv6)
	 */
	p->addrIPv4.ss_family = AF_UNSPEC;

	CW_COPY_NET_ADDR_PTR(&(p->addr), &wildaddr);
	if (!CWAddElementToList(&interfaceList, p)) {
		return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	}
	sockPtr->count++;

	/* bind multicast addresses */
	for (i = 0; i < multicastGroupsCount; i++) {
		struct addrinfo hints, *res, *ressave;
		char serviceName[5];
		CWSocket sock;

		CW_ZERO_MEMORY(&hints, sizeof(struct addrinfo));
		hints.ai_family = AF_UNSPEC;
		hints.ai_socktype = SOCK_DGRAM;

		/* endianness will be handled by getaddrinfo */
		snprintf(serviceName, 5, "%d", CW_CONTROL_PORT);

		CWLog("Joining Multicast Group: %s...", multicastGroups[i]);

		if (getaddrinfo(multicastGroups[i], serviceName, &hints, &res) != 0) {

			CWNetworkRaiseSystemError(CW_ERROR_CREATING);
		}
		ressave = res;

		do {
			if ((sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
				continue;	/* try next address */
			}

			/* reuse address */
			setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));

			if (bind(sock, res->ai_addr, res->ai_addrlen) == 0)
				break;	/* success */

			close(sock);	/* failure */
		} while ((res = res->ai_next) != NULL);

		if (res == NULL) {	/* error on last iteration */
			CWNetworkRaiseSystemError(CW_ERROR_CREATING);
		}

		if (mcast_join(sock, res->ai_addr, res->ai_addrlen, NULL, 0) != 0) {
			CWNetworkRaiseSystemError(CW_ERROR_CREATING);
		}

		CWUseSockNtop((res->ai_addr), CWLog("Joined Multicast Group: %s", str););

		CW_CREATE_OBJECT_ERR(p, CWMultiHomedInterface, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		p->sock = sock;
		p->kind = CW_BROADCAST_OR_ALIAS;
		p->systemIndex = -1;

		p->addrIPv4.ss_family = AF_UNSPEC;

		CW_COPY_NET_ADDR_PTR(&(p->addr), res->ai_addr);
		if (!CWAddElementToList(&interfaceList, p)) {
			return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		}
		sockPtr->count++;	/* we add a socket to the multihomed socket */

		freeaddrinfo(ressave);
	}

	/*
	 * Lists are fun when you don't know how many sockets will not give an
	 * error on creating/binding, but now that we know the exact number we
	 * convert it into an array. The "interfaces" field of CWMultiHomedSocket
	 * is actually an array.
	 */
	CW_CREATE_ARRAY_ERR((sockPtr->interfaces), sockPtr->count, CWMultiHomedInterface,
			    return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	/* create array from list */
	for (el = interfaceList, i = 0; el != NULL; el = el->next, i++) {
		CW_COPY_MH_INTERFACE_PTR(&((sockPtr->interfaces)[i]), ((CWMultiHomedInterface *) (el->data)));
	}

	/* delete the list */
	CWDeleteList(&interfaceList, CWNetworkDeleteMHInterface);

	return CW_TRUE;
}

void CWNetworkCloseMultiHomedSocket(CWMultiHomedSocket * sockPtr)
{

	int i = 0;

	if (sockPtr == NULL || sockPtr->interfaces == NULL)
		return;

	for (i = 0; i < sockPtr->count; i++)
		close(sockPtr->interfaces[i].sock);

	CW_FREE_OBJECT(sockPtr->interfaces);
	sockPtr->count = 0;
}

int get_mac_addr(unsigned char *outBuf, char *eth_name)
{

	struct ifreq s;
	int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
	strcpy(s.ifr_name, eth_name);
	if (!ioctl(fd, SIOCGIFHWADDR, &s))
		memcpy(outBuf, s.ifr_addr.sa_data, 6);

	return 0;
}

/*
 * Blocks until one ore more interfaces are ready to read something. When there
 * is at least one packet pending, call CWManageIncomingPacket() for each pending
 * packet, then return.
 */
CWBool CWNetworkUnsafeMultiHomed(CWMultiHomedSocket * sockPtr,
				 void (*CWManageIncomingPacket) (CWSocket,
								 unsigned char *,
								 int,
								 int, CWNetworkLev4Address *, CWBool), CWBool peekRead)
{
	fd_set fset;
	int max = 0, i;
	CWNetworkLev4Address addr;
	CWNetworkLev4Address address;

	int k;
	int fragmentsNum = 0;
	CWProtocolMessage *completeMsgPtr = NULL;
	CWProtocolMessage *frame = NULL;
	int dataSocket = 0;
	int readBytes;
	int flags = ((peekRead != CW_FALSE) ? MSG_PEEK : 0);
	unsigned char buf[CW_BUFFER_SIZE];

	if (sockPtr == NULL || sockPtr->count == 0 || CWManageIncomingPacket == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	FD_ZERO(&fset);

	/* select() on all the sockets */
	for (i = 0; i < sockPtr->count; i++) {

		FD_SET(sockPtr->interfaces[i].sock, &fset);

		if (sockPtr->interfaces[i].sock > max)
			max = sockPtr->interfaces[i].sock;

		if (sockPtr->interfaces[i].dataSock != 0) {	// Todd: add tap device to 'select '
			FD_SET(sockPtr->interfaces[i].dataSock, &fset);

			if (sockPtr->interfaces[i].dataSock > max)
				max = sockPtr->interfaces[i].dataSock;
		}
	}

	for (i = 0; i < gMaxWTPs; i++) {
		if (gWTPs[i].tap_fd != 0) {
			FD_SET(gWTPs[i].tap_fd, &fset);

			if (gWTPs[i].tap_fd > max)
				max = gWTPs[i].tap_fd;
		}
	}

	while (select(max + 1, &fset, NULL, NULL, NULL) < 0) {

		if (errno != EINTR) {
			CWNetworkRaiseSystemError(CW_ERROR_GENERAL);
		}
	}

	/* calls CWManageIncomingPacket() for each interface
	 * that has an incoming packet
	 */

	for (i = 0; i < gMaxWTPs; i++) {
		// CWDebugLog("Parsing TAP %d", gWTPs[i].tap_fd);

		if (FD_ISSET(gWTPs[i].tap_fd, &fset)) {

			readBytes = read(gWTPs[i].tap_fd, buf, CW_BUFFER_SIZE);	//Todd: read from TAP then forward to WTP through data channel
			CWDebugLog("gWTPs[%d].tap_fd:%d is set,data(%d bytes)", i, gWTPs[i].tap_fd, readBytes);

			if (readBytes < 0) {
				CWDebugLog("Reading from tap interface");
				perror("Reading from interface");
				close(gWTPs[i].tap_fd);
				gWTPs[i].tap_fd = 0;
			}

			if (gWTPs[i].currentState != CW_ENTER_RUN) {
				CWDebugLog("WTP %d is not in RUN State. The packet was dropped.", i);
				continue;
			} else {

				unsigned char macAddrTap[6];
				get_mac_addr(macAddrTap, gWTPs[i].tap_name);
				unsigned char buf80211[CW_BUFFER_SIZE + 24];
				int readByest80211 = from_8023_to_80211(buf, readBytes, buf80211, macAddrTap);
				CW_CREATE_OBJECT_ERR(frame, CWProtocolMessage, return 0;
				    );
				CW_CREATE_PROTOCOL_MESSAGE(*frame, readByest80211, return 0;
				    );
				memcpy(frame->msg, buf80211, readByest80211);
				frame->offset = readByest80211;
				frame->data_msgType = CW_IEEE_802_11_FRAME_TYPE;

				if (!CWAssembleDataMessage(&completeMsgPtr,
							   &fragmentsNum,
							   gWTPs[i].pathMTU, frame, NULL, CW_PACKET_PLAIN, 0)) {

					for (k = 0; k < fragmentsNum; k++) {
						CW_FREE_PROTOCOL_MESSAGE(completeMsgPtr[k]);
					}
					CW_FREE_OBJECT(completeMsgPtr);
					CW_FREE_PROTOCOL_MESSAGE(*frame);
					CW_FREE_OBJECT(frame);
					continue;
				}

				for (k = 0; k < sockPtr->count; k++) {
					if (sockPtr->interfaces[k].sock == gWTPs[i].socket) {
						dataSocket = sockPtr->interfaces[k].dataSock;
						CW_COPY_NET_ADDR_PTR(&address, &(gWTPs[i].dataAddress));
						break;
					}
				}

				if (dataSocket == 0) {
					CWDebugLog("data socket of WTP %d isn't ready.");
					continue;
				}

				/* Set port and address of data tunnel */
				//sock_set_port_cw((struct sockaddr *)&(address), htons(CW_DATA_PORT));

				for (k = 0; k < fragmentsNum; k++) {
					if (!CWNetworkSendUnsafeUnconnected(dataSocket,
									    &(address),
									    completeMsgPtr[k].msg,
									    completeMsgPtr[k].offset)) {
						CWDebugLog("Failure sending Request");
						break;
					}
				}
				for (k = 0; k < fragmentsNum; k++) {
					CW_FREE_PROTOCOL_MESSAGE(completeMsgPtr[k]);
				}

				CW_FREE_OBJECT(completeMsgPtr);
				CW_FREE_PROTOCOL_MESSAGE(*(frame));
				CW_FREE_OBJECT(frame);

			}
		}
	}

	for (i = 0; i < sockPtr->count; i++) {

		if (FD_ISSET(sockPtr->interfaces[i].sock, &fset)) {
			int readBytes;

			/*
			   CWUseSockNtop(&(sockPtr->interfaces[i].addr),
			   CWDebugLog("Ready on %s", str);
			   );
			 */

			CW_ZERO_MEMORY(buf, CW_BUFFER_SIZE);

			/* message */
			if (!CWErr
			    (CWNetworkReceiveUnsafe
			     (sockPtr->interfaces[i].sock, buf, CW_BUFFER_SIZE - 1, flags, &addr, &readBytes))) {

				sleep(1);
				continue;
			}

			CWManageIncomingPacket(sockPtr->interfaces[i].sock,
					       buf,
					       readBytes,
					       CWNetworkGetInterfaceIndexFromSystemIndex(sockPtr,
											 sockPtr->interfaces[i].
											 systemIndex), &addr, CW_FALSE);
		}

		if (FD_ISSET(sockPtr->interfaces[i].dataSock, &fset)) {	//Todd: Bridge 802.3 packets of WTPs into AC
			int readBytes;

			CW_ZERO_MEMORY(buf, CW_BUFFER_SIZE);

			/* message */
			if (!CWErr
			    (CWNetworkReceiveUnsafe
			     (sockPtr->interfaces[i].dataSock, buf, CW_BUFFER_SIZE - 1, flags, &addr, &readBytes))) {

				sleep(1);
				continue;
			}

			CWManageIncomingPacket(sockPtr->interfaces[i].dataSock,
					       buf,
					       readBytes,
					       CWNetworkGetInterfaceIndexFromSystemIndex(sockPtr,
											 sockPtr->interfaces[i].
											 systemIndex), &addr, CW_TRUE);
		}
		/* else {CWDebugLog("~~~~~~~Non Ready on....~~~~~~");} */
	}
	return CW_TRUE;
}

/* count distinct interfaces managed by the multihomed socket */
int CWNetworkCountInterfaceAddresses(CWMultiHomedSocket * sockPtr)
{

	int count = 0;
	int i;

	if (sockPtr == NULL)
		return 0;

	for (i = 0; i < sockPtr->count; i++) {

		if (sockPtr->interfaces[i].kind == CW_PRIMARY)
			count++;
	}

	return count;
}

/*
 * Get the addresses of each distinct interface managed by the multihomed
 * socket. If we are an IPv6 server element with index i of addressesPtr contains
 * the IPv6 address of the interface at index i (our mapped index, not system
 * index) and the element at index i of IPv4AddressesPtr contains the IPv4
 * equivalent address for the interface at index i. If we are an IPv4 server,
 * addressesPtr are the IPv4 addresses and IPv4AddressesPtr is garbage.
 */
CWBool CWNetworkGetInterfaceAddresses(CWMultiHomedSocket * sockPtr,
				      CWNetworkLev4Address ** addressesPtr, struct sockaddr_in ** IPv4AddressesPtr)
{
	int i, j;

	if (sockPtr == NULL || addressesPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	CW_CREATE_ARRAY_ERR(*addressesPtr,
			    CWNetworkCountInterfaceAddresses(sockPtr),
			    CWNetworkLev4Address, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	if (IPv4AddressesPtr != NULL && gNetworkPreferredFamily == CW_IPv6) {

		CW_CREATE_ARRAY_ERR(*IPv4AddressesPtr,
				    CWNetworkCountInterfaceAddresses(sockPtr),
				    struct sockaddr_in, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
	}

	for (i = 0, j = 0; i < sockPtr->count; i++) {

		if (sockPtr->interfaces[i].kind == CW_PRIMARY) {

			CW_COPY_NET_ADDR_PTR(&((*addressesPtr)[j]),
					     ((CWNetworkLev4Address *) & (sockPtr->interfaces[i].addr)));

			if (IPv4AddressesPtr != NULL && gNetworkPreferredFamily == CW_IPv6) {

				CW_COPY_NET_ADDR_PTR(&((*IPv4AddressesPtr)[j]),
						     ((CWNetworkLev4Address *) & (sockPtr->interfaces[i].addrIPv4)));
			}
			j++;
		}
	}
	return CW_TRUE;
}


================================================
FILE: ACMultiHomedSocket.h
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#ifndef __CAPWAP_CWMultiHomedSocket_HEADER__
#define __CAPWAP_CWMultiHomedSocket_HEADER__

#include "CWNetwork.h"

/*_____________________________________________________*/
/*  *******************___TYPES___*******************  */

typedef struct {
	CWNetworkLev4Address addr;
	CWNetworkLev4Address addrIPv4;
	CWSocket sock;
	enum {
		CW_PRIMARY,
		CW_BROADCAST_OR_ALIAS
	} kind;
	short systemIndex;	// real interface index in the system

	CWNetworkLev4Address dataAddr;
	CWSocket dataSock;
} CWMultiHomedInterface;

typedef struct {
	int count;
	CWMultiHomedInterface *interfaces;
} CWMultiHomedSocket;

/*_____________________________________________________*/
/*  *******************___MACRO___*******************  */

#define CW_COPY_MH_INTERFACE_PTR(int1, int2)        CW_COPY_NET_ADDR_PTR( &((int1)->addr), &((int2)->addr));    \
                            CW_COPY_NET_ADDR_PTR( &((int1)->addrIPv4), &((int2)->addrIPv4));\
                            (int1)->sock = (int2)->sock;                    \
                            (int1)->dataSock = (int2)->dataSock;                \
                            (int1)->kind = (int2)->kind;    \
                            (int1)->systemIndex = (int2)->systemIndex;

/*__________________________________________________________*/
/*  *******************___PROTOTYPES___*******************  */

CWBool CWNetworkInitSocketServerMultiHomed(CWMultiHomedSocket * sockPtr, int port, char **multicastGroups,
					   int multicastGroupsCount);
void CWNetworkCloseMultiHomedSocket(CWMultiHomedSocket * sockPtr);
CWBool CWNetworkUnsafeMultiHomed(CWMultiHomedSocket * sockPtr,
				 void (*CWManageIncomingPacket) (CWSocket, unsigned char *, int, int, CWNetworkLev4Address *,
								 CWBool), CWBool peekRead);
int CWNetworkCountInterfaceAddresses(CWMultiHomedSocket * sockPtr);
CWBool CWNetworkGetInterfaceAddresses(CWMultiHomedSocket * sockPtr, CWNetworkLev4Address ** addressesPtr,
				      struct sockaddr_in **IPv4AddressesPtr);

#endif


================================================
FILE: ACProtocol.c
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#include "CWAC.h"
#include "CWVendorPayloads.h"

#ifdef DMALLOC
#include "../dmalloc-5.5.0/dmalloc.h"
#endif
unsigned char WTPRadioInformationType;

/*____________________________________________________________________________*/
/*  *****************************___ASSEMBLE___*****************************  */
/*Update 2009:
    Assemble protocol Configuration update request.
    Mainly added to  manage vendor specific packets*/
CWBool CWProtocolAssembleConfigurationUpdateRequest(CWProtocolMessage ** msgElems, int *msgElemCountPtr,
						    int MsgElementType)
{
	int *iPtr;
	int k = -1;

	if (msgElems == NULL || msgElemCountPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {
		return CW_FALSE;
	}

	*msgElemCountPtr = 1;

	CWLog("Assembling Protocol Configuration Update Request...");

	CW_CREATE_PROTOCOL_MSG_ARRAY_ERR(*msgElems, *msgElemCountPtr, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	/* Selection of type of Conf Update Request */

	switch (MsgElementType) {
	case CW_MSG_ELEMENT_VENDOR_SPEC_PAYLOAD_UCI:

		// Assemble Message Elements
		if (!(CWAssembleWTPVendorPayloadUCI(&(*msgElems[++k])))) {
			int i;
			for (i = 0; i <= k; i++) {
				CW_FREE_PROTOCOL_MESSAGE(*msgElems[i]);
			}
			CW_FREE_OBJECT(*msgElems);
			return CW_FALSE;	// error will be handled by the caller
		}
		break;
	case CW_MSG_ELEMENT_VENDOR_SPEC_PAYLOAD_WUM:

		// Assemble Message Elements
		if (!(CWAssembleWTPVendorPayloadWUM(&(*msgElems[++k])))) {
			int i;
			for (i = 0; i <= k; i++) {
				CW_FREE_PROTOCOL_MESSAGE(*msgElems[i]);
			}
			CW_FREE_OBJECT(*msgElems);
			return CW_FALSE;	// error will be handled by the caller
		}
		break;
	default:{
			return CW_FALSE;	// error will be handled by the caller
		}
	}

	CWLog("Protocol Configuration Update Request Assembled");

	return CW_TRUE;
}

CWBool CWAssembleMsgElemACWTPRadioInformation(CWProtocolMessage * msgPtr)
{

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);;

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, 5, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStore8(msgPtr, 0);	// Radio ID
	CWProtocolStore8(msgPtr, 0);	// Reserved
	CWProtocolStore8(msgPtr, 0);	// Reserved
	CWProtocolStore8(msgPtr, 0);	// Reserved
	CWProtocolStore8(msgPtr, 0);	// Radio Information Type ABGN

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_IEEE80211_WTP_RADIO_INFORMATION_CW_TYPE);
}

CWBool CWAssembleMsgElemACDescriptor(CWProtocolMessage * msgPtr)
{
	CWACVendorInfos infos;
	int i = 0, size = 0;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);;

	if (!CWACGetVendorInfos(&infos)) {	// get infos
		return CW_FALSE;
	}

	for (i = 0; i < infos.vendorInfosCount; i++) {
		size += (8 + ((infos.vendorInfos)[i]).length);
	}

	size += 12;		// size of message in bytes (excluding vendor infos, already counted)

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, size, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStore16(msgPtr, CWACGetStations());	// Number of mobile stations associated
	CWProtocolStore16(msgPtr, CWACGetLimit());	// Maximum number of mobile stations supported
	CWProtocolStore16(msgPtr, CWACGetActiveWTPs());	// Number of WTPs active
	CWProtocolStore16(msgPtr, CWACGetMaxWTPs());	// Maximum number of WTPs supported
	CWProtocolStore8(msgPtr, CWACGetSecurity());
	CWProtocolStore8(msgPtr, CWACGetRMACField());
	CWProtocolStore8(msgPtr, 0);	//Reserved
	CWProtocolStore8(msgPtr, CWACGetDTLSPolicy());	// DTLS Policy

	for (i = 0; i < infos.vendorInfosCount; i++) {
		CWProtocolStore32(msgPtr, ((infos.vendorInfos)[i].vendorIdentifier));
		CWProtocolStore16(msgPtr, ((infos.vendorInfos)[i].type));
		CWProtocolStore16(msgPtr, ((infos.vendorInfos)[i].length));
		if ((infos.vendorInfos)[i].length == 4) {
			*((infos.vendorInfos)[i].valuePtr) = htonl(*((infos.vendorInfos)[i].valuePtr));
		}
		CWProtocolStoreRawBytes(msgPtr, (unsigned char*)((infos.vendorInfos)[i].valuePtr),
					(infos.vendorInfos)[i].length);
	}

	CWACDestroyVendorInfos(&infos);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_AC_DESCRIPTOR_CW_TYPE);
}

CWBool CWAssembleMsgElemACIPv4List(CWProtocolMessage * msgPtr)
{
	int *list;
	int count, i;
	const int IPv4_List_length = 4;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if (!CWACGetACIPv4List(&list, &count))
		return CW_FALSE;

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, IPv4_List_length * count, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	for (i = 0; i < count; i++) {
		CWProtocolStore32(msgPtr, list[i]);
//      CWDebugLog("AC IPv4 List(%d): %d", i, list[i]);
	}

	CW_FREE_OBJECT(list);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_AC_IPV4_LIST_CW_TYPE);
}

CWBool CWAssembleMsgElemACIPv6List(CWProtocolMessage * msgPtr)
{
	struct in6_addr *list;
	const int IPv6_List_length = 16;
	int count, i;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if (!CWACGetACIPv6List(&list, &count))
		return CW_FALSE;

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, IPv6_List_length * count, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	/*--- ATTENZIONE! l'indirizzo ipv6 forse deve essere girato ---*/
	for (i = 0; i < count; i++) {
		CWProtocolStoreRawBytes(msgPtr, list[i].s6_addr, 16);
	}

	CW_FREE_OBJECT(list);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_AC_IPV6_LIST_CW_TYPE);
}

CWBool CWAssembleMsgElemACName(CWProtocolMessage * msgPtr)
{
	char *name;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	name = CWACGetName();

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, strlen(name), return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStoreStr(msgPtr, name);

//  CWDebugLog("AC Name: %s", name);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_AC_NAME_CW_TYPE);
}

CWBool CWAssembleMsgElemAddWLAN(int radioID, CWProtocolMessage * msgPtr, unsigned char *recv_packet, int len_packet)
{

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, len_packet, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStoreRawBytes(msgPtr, recv_packet, len_packet);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_IEEE80211_ADD_WLAN_CW_TYPE);

}

CWBool CWAssembleMsgElemDeleteWLAN(int radioID, CWProtocolMessage * msgPtr, unsigned char *recv_packet, int len_packet)
{

	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, len_packet, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStoreRawBytes(msgPtr, recv_packet, len_packet);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_IEEE80211_DELETE_WLAN_CW_TYPE);
}

CWBool CWAssembleMsgElemAddStation(int radioID, CWProtocolMessage * msgPtr, unsigned char *StationMacAddr)
{
	const int add_Station_Length = 8;
	int Length = 6;		//mac address length in bytes (48 bit)

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, add_Station_Length, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStore8(msgPtr, radioID);

	CWProtocolStore8(msgPtr, Length);

	CWProtocolStoreRawBytes(msgPtr, StationMacAddr, Length);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_ADD_STATION_CW_TYPE);

}

CWBool CWAssembleMsgElemDeleteStation(int radioID, CWProtocolMessage * msgPtr, unsigned char *StationMacAddr)
{
	const int delete_Station_Length = 8;
	int Length = 6;		//mac address length in bytes (48 bit)

	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, delete_Station_Length, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );
	CWProtocolStore8(msgPtr, radioID);
	CWProtocolStore8(msgPtr, Length);
	CWProtocolStoreRawBytes(msgPtr, StationMacAddr, Length);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_DELETE_STATION_CW_TYPE);
}

CWBool CWAssembleMsgElemCWControlIPv4Addresses(CWProtocolMessage * msgPtr)
{
	int count, i;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	count = CWACGetInterfacesCount();

	if (count <= 0) {
		return CWErrorRaise(CW_ERROR_NEED_RESOURCE, "No Interfaces Configured");
	}

	for (i = 0; i < count; i++) {	// one Message Element for each interface
		CWProtocolMessage temp;
		// create message
		CW_CREATE_PROTOCOL_MESSAGE(temp, 6, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );

		CWProtocolStore32(&temp, CWACGetInterfaceIPv4AddressAtIndex(i));
		CWProtocolStore16(&temp, CWACGetInterfaceWTPCountAtIndex(i));

		CWAssembleMsgElem(&temp, CW_MSG_ELEMENT_CW_CONTROL_IPV4_ADDRESS_CW_TYPE);

		if (i == 0) {
			CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, (temp.offset) * count,
						   return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
			    );
		}

		CWProtocolStoreMessage(msgPtr, &temp);
		CW_FREE_PROTOCOL_MESSAGE(temp);
	}

	return CW_TRUE;
}

CWBool CWAssembleMsgElemCWControlIPv6Addresses(CWProtocolMessage * msgPtr)
{
	int count, i;
	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	count = CWACGetInterfacesCount();

	for (i = 0; i < count; i++) {	// one Message Element for each interface
		CWProtocolMessage temp;
		// create message
		CW_CREATE_PROTOCOL_MESSAGE(temp, 18, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );

		CWProtocolStoreRawBytes(&temp, CWACGetInterfaceIPv6AddressAtIndex(i), 16);
		CWProtocolStore16(&temp, CWACGetInterfaceWTPCountAtIndex(i));

		CWAssembleMsgElem(&temp, CW_MSG_ELEMENT_CW_CONTROL_IPV6_ADDRESS_CW_TYPE);

		if (i == 0) {
			CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, (temp.offset) * count,
						   return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
			    );
		}

		CWProtocolStoreMessage(msgPtr, &temp);
		CW_FREE_PROTOCOL_MESSAGE(temp);
	}

	return CW_TRUE;
}

CWBool CWAssembleMsgElemCWTimer(CWProtocolMessage * msgPtr)
{
	int discoveryTimer, echoTimer;
	const int CWTimer_length = 2;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, CWTimer_length, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	if (!(CWACGetDiscoveryTimer(&discoveryTimer)) || !(CWACGetEchoRequestTimer(&echoTimer)))
		return CW_FALSE;
	CWProtocolStore8(msgPtr, discoveryTimer);
	CWProtocolStore8(msgPtr, echoTimer);

//  CWDebugLog("Discovery Timer: %d", discoveryTimer);
//  CWDebugLog("Echo Timer: %d", echoTimer);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_CW_TIMERS_CW_TYPE);
}

/* Le informazioni sui Radio ID vengono prese dalle informazioni del Configure Message
   Provvisoriamente l'error Report Period è settato allo stesso valore per tutte le radio del WTP*/
CWBool CWAssembleMsgElemDecryptErrorReportPeriod(CWProtocolMessage * msgPtr)
{
	const int radio_Decrypt_Error_Report_Period_Length = 3;
	const int reportInterval = 15;
	CWProtocolMessage *msgs;
	CWRadioAdminInfoValues *radiosInfoPtr;
	int radioCount = 0;
	int *iPtr;
	int len = 0;
	int i;
	int j;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if ((iPtr = ((int *)CWThreadGetSpecific(&gIndexSpecific))) == NULL) {
		CWLog("Critical Error... closing thread");
		CWCloseThread();
	}

	radiosInfoPtr = gWTPs[*iPtr].WTPProtocolManager.radioAdminInfo.radios;
	radioCount = gWTPs[*iPtr].WTPProtocolManager.radioAdminInfo.radiosCount;

	CW_CREATE_PROTOCOL_MSG_ARRAY_ERR(msgs, radioCount, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	for (i = 0; i < radioCount; i++) {
		// create message
		CW_CREATE_PROTOCOL_MESSAGE(msgs[i], radio_Decrypt_Error_Report_Period_Length,
					   return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		CWProtocolStore8(&(msgs[i]), radiosInfoPtr[i].ID);	// ID of the radio
		CWProtocolStore16(&(msgs[i]), reportInterval);	// state of the radio

		if (!(CWAssembleMsgElem(&(msgs[i]), CW_MSG_ELEMENT_CW_DECRYPT_ER_REPORT_PERIOD_CW_TYPE))) {
			for (j = i; j >= 0; j--) {
				CW_FREE_PROTOCOL_MESSAGE(msgs[j]);
			}
			CW_FREE_OBJECT(msgs);
			return CW_FALSE;
		}

		len += msgs[i].offset;
//      CWDebugLog("Decrypt Error Report Period: %d - %d", radiosInfoPtr[i].ID, reportInterval);
	}

	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, len, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	for (i = 0; i < radioCount; i++) {
		CWProtocolStoreMessage(msgPtr, &(msgs[i]));
		CW_FREE_PROTOCOL_MESSAGE(msgs[i]);
	}

	CW_FREE_OBJECT(msgs);

	return CW_TRUE;
}

CWBool CWAssembleMsgElemIdleTimeout(CWProtocolMessage * msgPtr)
{
	int idleTimeout;
	const int idle_Timeout_length = 4;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, idle_Timeout_length, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	if (!(CWACGetIdleTimeout(&idleTimeout)))
		return CW_FALSE;
	CWProtocolStore32(msgPtr, idleTimeout);

//  CWDebugLog("Idle Timeout: %d", idleTimeout);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_IDLE_TIMEOUT_CW_TYPE);
}

CWBool CWAssembleMsgElemWTPFallback(CWProtocolMessage * msgPtr)
{
	int value = 0;		//PROVVISORIO
	const int WTP_fallback_length = 1;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	// create message
	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, WTP_fallback_length, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	CWProtocolStore8(msgPtr, value);

//  CWDebugLog("Fallback: %d", value);

	return CWAssembleMsgElem(msgPtr, CW_MSG_ELEMENT_WTP_FALLBACK_CW_TYPE);
}

CWBool CWAssembleMsgElemRadioOperationalState(int radioID, CWProtocolMessage * msgPtr)
{
	const int radio_Operational_State_Length = 3;
	CWRadiosOperationalInfo infos;
	CWProtocolMessage *msgs;
	int len = 0;
	int i;
	int j;

	if (msgPtr == NULL)
		return CWErrorRaise(CW_ERROR_WRONG_ARG, NULL);

	if (!(CWGetWTPRadiosOperationalState(radioID, &infos))) {
		return CW_FALSE;
	}

	CW_CREATE_PROTOCOL_MSG_ARRAY_ERR(msgs, (infos.radiosCount), return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	for (i = 0; i < infos.radiosCount; i++) {
		// create message
		CW_CREATE_PROTOCOL_MESSAGE(msgs[i], radio_Operational_State_Length,
					   return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		CWProtocolStore8(&(msgs[i]), infos.radios[i].ID);	// ID of the radio
		CWProtocolStore8(&(msgs[i]), infos.radios[i].state);	// state of the radio
		CWProtocolStore8(&(msgs[i]), infos.radios[i].cause);

		if (!(CWAssembleMsgElem(&(msgs[i]), CW_MSG_ELEMENT_RADIO_OPERAT_STATE_CW_TYPE))) {
			for (j = i; j >= 0; j--) {
				CW_FREE_PROTOCOL_MESSAGE(msgs[j]);
			}
			CW_FREE_OBJECT(infos.radios);
			CW_FREE_OBJECT(msgs);
			return CW_FALSE;
		}

		len += msgs[i].offset;
//      CWDebugLog("Radio operational State: %d - %d - %d", infos.radios[i].ID, infos.radios[i].state, infos.radios[i].cause);
	}

	CW_CREATE_PROTOCOL_MESSAGE(*msgPtr, len, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	for (i = 0; i < infos.radiosCount; i++) {
		CWProtocolStoreMessage(msgPtr, &(msgs[i]));
		CW_FREE_PROTOCOL_MESSAGE(msgs[i]);
	}

	CW_FREE_OBJECT(msgs);
	CW_FREE_OBJECT(infos.radios);

	return CW_TRUE;
}

/*_________________________________________________________________________*/
/*  *****************************___PARSE___*****************************  */
CWBool CWParseACNameWithIndex(CWProtocolMessage * msgPtr, int len, CWACNameWithIndexValues * valPtr)
{
	CWParseMessageElementStart();

	valPtr->index = CWProtocolRetrieve8(msgPtr);
	//CWDebugLog("CW_MSG_ELEMENT_WTP_RADIO_ID: %d", (valPtr->radios)[radioIndex].ID);

	valPtr->ACName = CWProtocolRetrieveStr(msgPtr, len - 1);
	//CWDebugLog("CW_MSG_ELEMENT_WTP_RADIO_TYPE: %d",   (valPtr->radios)[radioIndex].type);

	//CWDebugLog("AC Name with index: %d - %s", valPtr->index, valPtr->ACName);

	CWParseMessageElementEnd();
}

CWBool CWParseDiscoveryType(CWProtocolMessage * msgPtr, int len, CWDiscoveryRequestValues * valPtr)
{
	CWParseMessageElementStart();

	valPtr->type = CWProtocolRetrieve8(msgPtr);

	CWParseMessageElementEnd();
}

CWBool CWParseLocationData(CWProtocolMessage * msgPtr, int len, char **valPtr)
{
	CWParseMessageElementStart();

	*valPtr = CWProtocolRetrieveStr(msgPtr, len);
	if (valPtr == NULL)
		return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
//  CWDebugLog("Location Data:%s", *valPtr);

	CWParseMessageElementEnd();
}

CWBool CWParseMsgElemDuplicateIPv4Address(CWProtocolMessage * msgPtr, int len, WTPDuplicateIPv4 * valPtr)
{
	CWParseMessageElementStart();

	valPtr->ipv4Address = CWProtocolRetrieve32(msgPtr);
	valPtr->status = CWProtocolRetrieve8(msgPtr);
	valPtr->length = CWProtocolRetrieve8(msgPtr);
	valPtr->MACoffendingDevice_forIpv4 = (unsigned char *)CWProtocolRetrieveRawBytes(msgPtr, valPtr->length);

	//valPtr->MACoffendingDevice_forIpv4 = (unsigned char*)CWProtocolRetrieveRawBytes(msgPtr,6);
	//valPtr->status = CWProtocolRetrieve8(msgPtr);
//  CWDebugLog("Duplicate IPv4: %d", valPtr->ipv4Address);

	CWParseMessageElementEnd();
}

CWBool CWParseMsgElemDuplicateIPv6Address(CWProtocolMessage * msgPtr, int len, WTPDuplicateIPv6 * valPtr)
{
	CWParseMessageElementStart();

	int i;
	for (i = 0; i < 16; i++) {
		unsigned char *aux;
		aux = CWProtocolRetrieveRawBytes(msgPtr, 1);
		(valPtr->ipv6Address).s6_addr[i] = *aux;
	}

//  CWDebugLog("Duplicate IPv6");
	//valPtr->MACoffendingDevice_forIpv6 = (unsigned char*)CWProtocolRetrieveRawBytes(msgPtr,6);

	valPtr->status = CWProtocolRetrieve8(msgPtr);

	valPtr->length = CWProtocolRetrieve8(msgPtr);

	valPtr->MACoffendingDevice_forIpv6 = (unsigned char *)CWProtocolRetrieveRawBytes(msgPtr, valPtr->length);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPStatisticsTimer(CWProtocolMessage * msgPtr, int len, int *valPtr)
{
	CWParseMessageElementStart();

	*valPtr = CWProtocolRetrieve16(msgPtr);

//  CWDebugLog("WTP Statistics Timer: %d", *valPtr);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPBoardData(CWProtocolMessage * msgPtr, int len, CWWTPVendorInfos * valPtr)
{
	int theOffset, i, vendorID;
	CWParseMessageElementStart();

	valPtr->vendorInfosCount = 0;

	// see how many vendor ID we have in the message
	vendorID = CWProtocolRetrieve32(msgPtr);	// ID
	theOffset = msgPtr->offset;
	while ((msgPtr->offset - oldOffset) < len) {	// oldOffset stores msgPtr->offset's value at the beginning of this function.
		// See the definition of the CWParseMessageElementStart() macro.
		int tmp;

		CWProtocolRetrieve16(msgPtr);	// type
		tmp = CWProtocolRetrieve16(msgPtr);
		msgPtr->offset += tmp;	// len
		valPtr->vendorInfosCount++;
	}

	msgPtr->offset = theOffset;

	// actually read each vendor ID
	CW_CREATE_ARRAY_ERR(valPtr->vendorInfos, valPtr->vendorInfosCount, CWWTPVendorInfoValues,
			    return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	for (i = 0; i < valPtr->vendorInfosCount; i++) {
		(valPtr->vendorInfos)[i].vendorIdentifier = vendorID;
		(valPtr->vendorInfos)[i].type = CWProtocolRetrieve16(msgPtr);
		(valPtr->vendorInfos)[i].length = CWProtocolRetrieve16(msgPtr);
		(valPtr->vendorInfos)[i].valuePtr =
		    (CWProtocolRetrieveRawBytes(msgPtr, (valPtr->vendorInfos)[i].length));

		if ((valPtr->vendorInfos)[i].valuePtr == NULL)
			return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);

		if ((valPtr->vendorInfos)[i].length == 4) {
			*(int *)((valPtr->vendorInfos)[i].valuePtr) = ntohl(*((valPtr->vendorInfos)[i].valuePtr));
		}
//      CWDebugLog("WTP Board Data: %d - %d - %d - %d", (valPtr->vendorInfos)[i].vendorIdentifier, (valPtr->vendorInfos)[i].type, (valPtr->vendorInfos)[i].length, *(valPtr->vendorInfos)[i].valuePtr);
	}

	CWParseMessageElementEnd();
}

CWBool CWParseMsgElemDataTransferData(CWProtocolMessage * msgPtr, int len,
				      CWProtocolWTPDataTransferRequestValues * valPtr)
{
	CWParseMessageElementStart();

	valPtr->data = CWProtocolRetrieve8(msgPtr);
	valPtr->length = CWProtocolRetrieve8(msgPtr);
	valPtr->debug_info = CWProtocolRetrieveStr(msgPtr, valPtr->length);
	//CWDebugLog("- %s ---",valPtr->debug_info);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPDescriptor(CWProtocolMessage * msgPtr, int len, CWWTPDescriptor * valPtr)
{
	int theOffset, i;
	CWParseMessageElementStart();

	valPtr->maxRadios = CWProtocolRetrieve8(msgPtr);
//  CWDebugLog("WTP Descriptor Max Radios: %d", valPtr->maxRadios);

	valPtr->radiosInUse = CWProtocolRetrieve8(msgPtr);
//  CWDebugLog("WTP Descriptor Active Radios: %d",  valPtr->radiosInUse);

	valPtr->encCapabilities.encryptCapsCount = CWProtocolRetrieve8(msgPtr);
	CW_CREATE_ARRAY_ERR(valPtr->encCapabilities.encryptCaps, valPtr->encCapabilities.encryptCapsCount,
			    CWWTPEncryptCapValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL); );
	for (i = 0; i < valPtr->encCapabilities.encryptCapsCount; i++) {
		(valPtr->encCapabilities.encryptCaps)[i].WBID = CWProtocolRetrieve8(msgPtr) & 0x1f;
		(valPtr->encCapabilities.encryptCaps)[i].encryptionCapabilities = CWProtocolRetrieve16(msgPtr);
	}

	valPtr->vendorInfos.vendorInfosCount = 0;
	theOffset = msgPtr->offset;

	// see how many vendor ID we have in the message
	while ((msgPtr->offset - oldOffset) < len) {	// oldOffset stores msgPtr->offset's value at the beginning of this function.
		// See the definition of the CWParseMessageElementStart() macro.
		int tmp;
		CWProtocolRetrieve32(msgPtr);	// ID
		CWProtocolRetrieve16(msgPtr);	// type
		tmp = CWProtocolRetrieve16(msgPtr);	// len
		msgPtr->offset += tmp;
		valPtr->vendorInfos.vendorInfosCount++;
	}

	msgPtr->offset = theOffset;

	// actually read each vendor ID
	CW_CREATE_ARRAY_ERR(valPtr->vendorInfos.vendorInfos, valPtr->vendorInfos.vendorInfosCount,
			    CWWTPVendorInfoValues, return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
	    );

	for (i = 0; i < valPtr->vendorInfos.vendorInfosCount; i++) {
		(valPtr->vendorInfos.vendorInfos)[i].vendorIdentifier = CWProtocolRetrieve32(msgPtr);
		(valPtr->vendorInfos.vendorInfos)[i].type = CWProtocolRetrieve16(msgPtr);
		(valPtr->vendorInfos.vendorInfos)[i].length = CWProtocolRetrieve16(msgPtr);
		(valPtr->vendorInfos.vendorInfos)[i].valuePtr =
		    (CWProtocolRetrieveRawBytes(msgPtr, (valPtr->vendorInfos.vendorInfos)[i].length));

		if ((valPtr->vendorInfos.vendorInfos)[i].valuePtr == NULL)
			return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);

		if ((valPtr->vendorInfos.vendorInfos)[i].length == 4) {
			*((valPtr->vendorInfos.vendorInfos)[i].valuePtr) =
			    ntohl(*((valPtr->vendorInfos.vendorInfos)[i].valuePtr));
		}
//      CWDebugLog("WTP Descriptor Vendor ID: %d", (valPtr->vendorInfos.vendorInfos)[i].vendorIdentifier);
//      CWDebugLog("WTP Descriptor Type: %d", (valPtr->vendorInfos.vendorInfos)[i].type);
//      CWDebugLog("WTP Descriptor Length: %d", (valPtr->vendorInfos.vendorInfos)[i].length);
//      CWDebugLog("WTP Descriptor Value: %d", *((valPtr->vendorInfos.vendorInfos)[i].valuePtr));
	}

	CWParseMessageElementEnd();
}

CWBool CWParseWTPFrameTunnelMode(CWProtocolMessage * msgPtr, int len, CWframeTunnelMode * valPtr)
{
	CWParseMessageElementStart();

	*valPtr = CWProtocolRetrieve8(msgPtr);
//  CWDebugLog("CW_MSG_ELEMENT_WTP_FRAME_ENCAPSULATION_TYPE: %d", valPtr->frameTunnelMode);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPIPv4Address(CWProtocolMessage * msgPtr, int len, CWProtocolJoinRequestValues * valPtr)
{
	CWParseMessageElementStart();

	valPtr->addr.sin_addr.s_addr = htonl(CWProtocolRetrieve32(msgPtr));
	valPtr->addr.sin_family = AF_INET;
	valPtr->addr.sin_port = htons(CW_CONTROL_PORT);
//  CWDebugLog("WTP Address: %s", sock_ntop((struct sockaddr*) (&(valPtr->addr)), sizeof(valPtr->addr)));

	CWParseMessageElementEnd();
}

CWBool CWParseWTPMACType(CWProtocolMessage * msgPtr, int len, CWMACType * valPtr)
{
	CWParseMessageElementStart();

	*valPtr = CWProtocolRetrieve8(msgPtr);
//  CWDebugLog("CW_MSG_ELEMENT_WTP_MAC_TYPE: %d",   valPtr->MACType);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPRadioInformation(CWProtocolMessage * msgPtr, int len, unsigned char *valPtr)
{
	CWParseMessageElementStart();

	CWProtocolRetrieve8(msgPtr);	// Radio ID
	CWProtocolRetrieve8(msgPtr);	// Res
	CWProtocolRetrieve8(msgPtr);	// Res
	CWProtocolRetrieve8(msgPtr);	// Res
	*valPtr = CWProtocolRetrieve8(msgPtr);	// Radio Information

	CWParseMessageElementEnd();

}

CWBool CWParseWTPSupportedRates(CWProtocolMessage * msgPtr, int len, unsigned char *valPtr)
{

	CWParseMessageElementStart();
	unsigned char sup_rates[8];

	CWProtocolRetrieve8(msgPtr);

	sup_rates[0] = CWProtocolRetrieve8(msgPtr);
	sup_rates[1] = CWProtocolRetrieve8(msgPtr);
	sup_rates[2] = CWProtocolRetrieve8(msgPtr);
	sup_rates[3] = CWProtocolRetrieve8(msgPtr);
	sup_rates[4] = CWProtocolRetrieve8(msgPtr);
	sup_rates[5] = CWProtocolRetrieve8(msgPtr);
	sup_rates[6] = CWProtocolRetrieve8(msgPtr);
	sup_rates[7] = CWProtocolRetrieve8(msgPtr);

	memcpy(valPtr, sup_rates, 8);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPMultiDomainCapability(CWProtocolMessage * msgPtr, int len, char *valPtr)
{

	CWParseMessageElementStart();
	unsigned char sup_cap[6];

	CWProtocolRetrieve8(msgPtr);
	CWProtocolRetrieve8(msgPtr);

	sup_cap[0] = CWProtocolRetrieve8(msgPtr);
	sup_cap[1] = CWProtocolRetrieve8(msgPtr);
	sup_cap[2] = CWProtocolRetrieve8(msgPtr);
	sup_cap[3] = CWProtocolRetrieve8(msgPtr);
	sup_cap[4] = CWProtocolRetrieve8(msgPtr);
	sup_cap[5] = CWProtocolRetrieve8(msgPtr);

	memcpy(valPtr, sup_cap, 6);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPName(CWProtocolMessage * msgPtr, int len, char **valPtr)
{
	CWParseMessageElementStart();

	*valPtr = CWProtocolRetrieveStr(msgPtr, len);
	if (valPtr == NULL)
		return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
//  CWDebugLog("WTP Name:%s", *valPtr);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPRebootStatistics(CWProtocolMessage * msgPtr, int len, WTPRebootStatisticsInfo * valPtr)
{
	CWParseMessageElementStart();

	valPtr->rebootCount = CWProtocolRetrieve16(msgPtr);
	valPtr->ACInitiatedCount = CWProtocolRetrieve16(msgPtr);
	valPtr->linkFailurerCount = CWProtocolRetrieve16(msgPtr);
	valPtr->SWFailureCount = CWProtocolRetrieve16(msgPtr);
	valPtr->HWFailuireCount = CWProtocolRetrieve16(msgPtr);
	valPtr->otherFailureCount = CWProtocolRetrieve16(msgPtr);
	valPtr->unknownFailureCount = CWProtocolRetrieve16(msgPtr);
	valPtr->lastFailureType = CWProtocolRetrieve8(msgPtr);

//  CWDebugLog("");
//  CWDebugLog("WTPRebootStat(1): %d - %d - %d", valPtr->rebootCount, valPtr->ACInitiatedCount, valPtr->linkFailurerCount);
//  CWDebugLog("WTPRebootStat(2): %d - %d - %d", valPtr->SWFailureCount, valPtr->HWFailuireCount, valPtr->otherFailureCount);
//  CWDebugLog("WTPRebootStat(3): %d - %d", valPtr->unknownFailureCount, valPtr->lastFailureType);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPRadioStatistics(CWProtocolMessage * msgPtr, int len, WTPRadioStatisticsValues * valPtr)
{
	CWParseMessageElementStart();

	valPtr->radioID = CWProtocolRetrieve8(msgPtr);
	valPtr->WTPRadioStatistics.lastFailureType = CWProtocolRetrieve8(msgPtr);
	valPtr->WTPRadioStatistics.resetCount = CWProtocolRetrieve16(msgPtr);
	valPtr->WTPRadioStatistics.SWFailureCount = CWProtocolRetrieve16(msgPtr);
	valPtr->WTPRadioStatistics.HWFailuireCount = CWProtocolRetrieve16(msgPtr);
	valPtr->WTPRadioStatistics.otherFailureCount = CWProtocolRetrieve16(msgPtr);
	valPtr->WTPRadioStatistics.unknownFailureCount = CWProtocolRetrieve16(msgPtr);
	valPtr->WTPRadioStatistics.configUpdateCount = CWProtocolRetrieve16(msgPtr);
	valPtr->WTPRadioStatistics.channelChangeCount = CWProtocolRetrieve16(msgPtr);
	valPtr->WTPRadioStatistics.bandChangeCount = CWProtocolRetrieve16(msgPtr);
	valPtr->WTPRadioStatistics.currentNoiseFloor = CWProtocolRetrieve16(msgPtr);

//  CWDebugLog("");
//  CWDebugLog("WTPRadioStatistics of radio: \"%d\"", valPtr->radioID);
//  CWDebugLog("WTPRadioStatistics(1): %d - %d - %d", valPtr->WTPRadioStatistics.lastFailureType, valPtr->WTPRadioStatistics.resetCount, valPtr->WTPRadioStatistics.SWFailureCount);
//  CWDebugLog("WTPRadioStatistics(2): %d - %d - %d", valPtr->WTPRadioStatistics.HWFailuireCount, valPtr->WTPRadioStatistics.otherFailureCount, valPtr->WTPRadioStatistics.unknownFailureCount);
//  CWDebugLog("WTPRadioStatistics(3): %d - %d - %d - %d", valPtr->WTPRadioStatistics.configUpdateCount, valPtr->WTPRadioStatistics.channelChangeCount, valPtr->WTPRadioStatistics.bandChangeCount, valPtr->WTPRadioStatistics.currentNoiseFloor);

	CWParseMessageElementEnd();
}

CWBool CWParseWTPOperationalStatistics(CWProtocolMessage * msgPtr, int len, WTPOperationalStatisticsValues * valPtr)
{
	CWParseMessageElementStart();

	valPtr->radioID = CWProtocolRetrieve8(msgPtr);
	valPtr->TxQueueLevel = CWProtocolRetrieve8(msgPtr);
	valPtr->wirelessLinkFramesPerSec = CWProtocolRetrieve16(msgPtr);

//  CWDebugLog("WTPOperationalStatistics of radio \"%d\": %d - %d", valPtr->radioID, valPtr->TxQueueLevel, valPtr->wirelessLinkFramesPerSec);

	CWParseMessageElementEnd();
}

CWBool CWParseMsgElemDecryptErrorReport(CWProtocolMessage * msgPtr, int len, CWDecryptErrorReportValues * valPtr)
{
	CWParseMessageElementStart();

	valPtr->ID = CWProtocolRetrieve8(msgPtr);
	valPtr->numEntries = CWProtocolRetrieve8(msgPtr);

	valPtr->length = CWProtocolRetrieve8(msgPtr);

	valPtr->decryptErrorMACAddressList = NULL;
	if ((valPtr->numEntries) > 0) {
		CW_CREATE_ARRAY_ERR(valPtr->decryptErrorMACAddressList, valPtr->numEntries, CWMACAddress,
				    return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, NULL);
		    );
		int size = sizeof(CWMACAddress) * (valPtr->numEntries);
		CW_COPY_MEMORY(valPtr->decryptErrorMACAddressList, CWProtocolRetrieveRawBytes(msgPtr, size), size);
		//valPtr->decryptErrorMACAddressList =(unsigned char*) CWProtocolRetrieveRawBytes(msgPtr, sizeof(CWMACAddress)*(valPtr->numEntries));
		//CW_COPY_MEMORY(&((valPtr->ACIPv6List)[i]), CWProtocolRetrieveRawBytes(msgPtr, 16), 16);
		/*
		   int j;
		   for (j=0;j<(sizeof(CWMACAddress)*(valPtr->numEntries)); j++)
		   CWDebugLog("##(%d/6) = %d", j%6, (valPtr->decryptErrorMACAddressList)[j/6][j%6]);
		 */
	}
//  CWDebugLog("");
//  CWDebugLog("Radio Decrypt Error Report of radio \"%d\": %d", valPtr->ID, valPtr->numEntries);

	CWParseMessageElementEnd();
}

/*
CWBool CWParseWTPRadioInfo(CWPr<otocolMessage *msgPtr, int len, CWRadiosInformation *valPtr, int radioIndex) {
    CWParseMessageElementStart();

    (valPtr->radios)[radioIndex].ID = CWProtocolRetrieve8(msgPtr);
    (valPtr->radios)[radioIndex].type = CWProtocolRetrieve32(msgPtr);

    CWDebugLog("WTP Radio info: %d %d ", (valPtr->radios)[radioIndex].ID, (valPtr->radios)[radioIndex].type);

    CWParseMessageElementEnd();
}
*/


================================================
FILE: ACProtocol.h
================================================
/*******************************************************************************************
 * Copyright (c) 2006-7 Laboratorio di Sistemi di Elaborazione e Bioingegneria Informatica *
 *                      Universita' Campus BioMedico - Italy                               *
 *                                                                                         *
 * This program is free software; you can redistribute it and/or modify it under the terms *
 * of the GNU General Public License as published by the Free Software Foundation; either  *
 * version 2 of the License, or (at your option) any later version.                        *
 *                                                                                         *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY         *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A         *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.                *
 *                                                                                         *
 * You should have received a copy of the GNU General Public License along with this       *
 * program; if not, write to the:                                                          *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,                    *
 * MA  02111-1307, USA.                                                                    *
 *                                                                                         *
 * --------------------------------------------------------------------------------------- *
 * Project:  Capwap                                                                        *
 *                                                                                         *
 * Author :  Ludovico Rossi (ludo@bluepixysw.com)                                          *
 *           Del Moro Andrea (andrea_delmoro@libero.it)                                    *
 *           Giovannini Federica (giovannini.federica@gmail.com)                           *
 *           Massimo Vellucci (m.vellucci@unicampus.it)                                    *
 *           Mauro Bisson (mauro.bis@gmail.com)                                            *
 *******************************************************************************************/

#ifndef __CAPWAP_ACProtocol_HEADER__
#define __CAPWAP_ACProtocol_HEADER__

//#define UNUSED_RADIO_ID   1000

typedef struct {
	char *locationData;
	char *name;
	unsigned char *sessionID;
	CWWTPDescriptor descriptor;
	struct sockaddr_in ipv4Address;

	CWWTPRadiosInfo radiosInfo;

	char *ACName;
	CWACNamesWithIndex ACNameIndex;
	CWRadiosAdminInfo radioAdminInfo;
	int StatisticsTimer;
	CWWTPVendorInfos WTPBoardData;
	//CWRadiosInformation WTPRadioInfo;
	WTPRebootStatisticsInfo *WTPRebootStatistics;

	void *bindingValuesPtr;
} CWWTPProtocolManager;

typedef struct {
	char *location;
	char *name;
	CWWTPVendorInfos WTPBoardData;
	unsigned char *sessionID;
	CWWTPDescriptor WTPDescriptor;
	struct sockaddr_in addr;
	CWframeTunnelMode frameTunnelMode;
	CWMACType MACType;

} CWProtocolJoinRequestValues;

typedef struct {
	char *ACName;
	CWACNamesWithIndex ACinWTP;
	int radioAdminInfoCount;
	CWRadioAdminInfoValues *radioAdminInfo;
	int StatisticsTimer;
	WTPRebootStatisticsInfo *WTPRebootStatistics;

} CWProtocolConfigureRequestValues;

typedef struct {
	CWRadiosOperationalInfo radioOperationalInfo;
	CWProtocolResultCode resultCode;
} CWProtocolChangeStateEventRequestValues;

typedef struct {
	unsigned int radioID;
	unsigned int TxQueueLevel;
	unsigned int wirelessLinkFramesPerSec;
} WTPOperationalStatisticsValues;

typedef struct {
	unsigned int radioID;
	WTPRadioStatisticsInfo WTPRadioStatistics;
} WTPRadioStatisticsValues;

typedef struct {
	int ipv4Address;
	unsigned int 
Download .txt
gitextract_iujx8crt/

├── .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
├── 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
│   ├── 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
├── 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/
    ├── README
    ├── wum.c
    ├── wumLib.c
    └── wumLib.h
Download .txt
SYMBOL INDEX (1646 symbols across 104 files)

FILE: AC.c
  function usage (line 85) | void usage(void)
  function main (line 89) | int main(int argc, char * const argv[])
  function CWACSemPostForOpenSSLHack (line 139) | int CWACSemPostForOpenSSLHack(void *s)
  type sockaddr_in (line 164) | struct sockaddr_in
  function CWCreateConnectionWithHostapdAC (line 270) | void CWCreateConnectionWithHostapdAC()
  function CWACDestroy (line 281) | void CWACDestroy()
  function CWGetSeqNum (line 306) | unsigned int CWGetSeqNum()
  function CWGetFragmentID (line 328) | int CWGetFragmentID()

FILE: ACBinding.c
  function CWBool (line 36) | CWBool CWACInitBinding(int i)
  function CWBool (line 64) | CWBool CWMergeQosValues(int WTPIndex)
  function CWBool (line 93) | CWBool CWMergeOFDMValues(int WTPIndex)
  function CWBool (line 112) | CWBool CWAssembleWTPOFDM(CWProtocolMessage * msgPtr, int radioID)
  function CWBool (line 147) | CWBool CWAssembleWTPQoS(CWProtocolMessage * msgPtr, int radioID, int tag...
  function CWBool (line 187) | CWBool CWBindingAssembleConfigureResponse(CWProtocolMessage ** msgElems,...
  function CWBool (line 246) | CWBool CWBindingAssembleConfigurationUpdateRequest(CWProtocolMessage ** ...
  function CWBool (line 317) | CWBool CWBindingSaveConfigurationUpdateResponse(CWProtocolResultCode res...

FILE: ACConfigFile.c
  function CWBool (line 36) | CWBool CWConfigFileInitLib()
  function CWBool (line 94) | CWBool CWConfigFileDestroyLib()

FILE: ACConfigureState.c
  function CWBool (line 46) | CWBool ACEnterConfigure(int WTPIndex, CWProtocolMessage * msgPtr)
  function CWBool (line 108) | CWBool CWParseConfigureRequestMessage(unsigned char *msg,
  function CWBool (line 266) | CWBool CWAssembleConfigureResponse(CWProtocolMessage ** messagesPtr, int...
  function CWBool (line 321) | CWBool CWSaveConfigureRequestMessage(CWProtocolConfigureRequestValues * ...

FILE: ACDataCheckState.c
  function CWBool (line 34) | CWBool ACEnterDataCheck(int WTPIndex, CWProtocolMessage * msgPtr)
  function CWBool (line 94) | CWBool CWParseChangeStateEventRequestMessage(unsigned char *msg,
  function CWBool (line 189) | CWBool CWAssembleChangeStateEventResponse(CWProtocolMessage ** messagesP...

FILE: ACDiscoveryState.c
  function CWBool (line 51) | CWBool CWAssembleDiscoveryResponse(CWProtocolMessage ** messagesPtr, int...
  function CWBool (line 96) | CWBool CWParseDiscoveryRequestMessage(unsigned char *msg, int len, int *...
  function CWDestroyDiscoveryRequestValues (line 219) | void CWDestroyDiscoveryRequestValues(CWDiscoveryRequestValues * valPtr)

FILE: ACInterface.c
  type CWInterfaceThreadArg (line 48) | typedef struct {
  function CWOFDMSetValues (line 57) | int CWOFDMSetValues(int selection, int socketIndex, OFDMControlValues * ...
  function CWVendorSetValues (line 73) | int CWVendorSetValues(int selection, int socketIndex, CWProtocolVendorSp...
  function CWWumSetValues (line 89) | int CWWumSetValues(int selection, int socketIndex, CWProtocolVendorSpeci...
  function CW_THREAD_RETURN_TYPE (line 112) | CW_THREAD_RETURN_TYPE CWManageApplication(void *arg)
  function CW_THREAD_RETURN_TYPE (line 538) | CW_THREAD_RETURN_TYPE CWInterface(void *arg)
  function is_valid_wtp_index (line 680) | int is_valid_wtp_index(int wtpIndex)
  function readn (line 690) | int readn(int fd, void *vptr, size_t n)
  function Readn (line 713) | int Readn(int fd, void *ptr, size_t nbytes)

FILE: ACJoinState.c
  function CWBool (line 41) | CWBool ACEnterJoin(int WTPIndex, CWProtocolMessage * msgPtr)
  function CWBool (line 129) | CWBool CWAssembleJoinResponse(CWProtocolMessage ** messagesPtr,
  function CWBool (line 236) | CWBool CWParseJoinRequestMessage(unsigned char *msg, int len, int *seqNu...
  function CWBool (line 341) | CWBool CWSaveJoinRequestMessage(CWProtocolJoinRequestValues * joinReques...

FILE: ACMainLoop.c
  function CWACEnterMainLoop (line 55) | void CWACEnterMainLoop()
  type CWACThreadArg (line 108) | typedef struct {
  function CWACManageIncomingPacket (line 129) | void CWACManageIncomingPacket(CWSocket sock,
  function CWWTPByAddress (line 310) | __inline__ int CWWTPByAddress(CWNetworkLev4Address * addressPtr, CWSocke...
  function CW_THREAD_RETURN_TYPE (line 342) | CW_THREAD_RETURN_TYPE CWManageWTP(void *arg)
  function _CWCloseThread (line 709) | void _CWCloseThread(int i)
  function CWCloseThread (line 771) | void CWCloseThread()
  function CWCriticalTimerExpiredHandler (line 785) | void CWCriticalTimerExpiredHandler(int arg)
  function CWSoftTimerExpiredHandler (line 808) | void CWSoftTimerExpiredHandler(int arg)
  function CWResetWTPProtocolManager (line 853) | void CWResetWTPProtocolManager(CWWTPProtocolManager * WTPProtocolManager)

FILE: ACMultiHomedSocket.c
  function CWNetworkDeleteMHInterface (line 41) | void CWNetworkDeleteMHInterface(void *intPtr)
  function from_8023_to_80211 (line 47) | int from_8023_to_80211(unsigned char *inbuffer, int inlen, unsigned char...
  function CWNetworkGetInterfaceIndexFromSystemIndex (line 76) | int CWNetworkGetInterfaceIndexFromSystemIndex(CWMultiHomedSocket * sockP...
  function CWMultiHomedInterface (line 102) | CWMultiHomedInterface *CWNetworkGetInterfaceAlreadyStored(CWList list, s...
  type ifi_info (line 126) | struct ifi_info
  type sockaddr (line 169) | struct sockaddr
  type sockaddr (line 230) | struct sockaddr
  type sockaddr (line 267) | struct sockaddr
  type sockaddr_in6 (line 385) | struct sockaddr_in6
  type sockaddr_in6 (line 385) | struct sockaddr_in6
  type sockaddr_in (line 393) | struct sockaddr_in
  type sockaddr_in (line 393) | struct sockaddr_in
  type sockaddr (line 399) | struct sockaddr
  type addrinfo (line 427) | struct addrinfo
  type addrinfo (line 431) | struct addrinfo
  function CWNetworkCloseMultiHomedSocket (line 508) | void CWNetworkCloseMultiHomedSocket(CWMultiHomedSocket * sockPtr)
  function get_mac_addr (line 523) | int get_mac_addr(unsigned char *outBuf, char *eth_name)
  function CWBool (line 540) | CWBool CWNetworkUnsafeMultiHomed(CWMultiHomedSocket * sockPtr,
  function CWNetworkCountInterfaceAddresses (line 740) | int CWNetworkCountInterfaceAddresses(CWMultiHomedSocket * sockPtr)
  function CWBool (line 766) | CWBool CWNetworkGetInterfaceAddresses(CWMultiHomedSocket * sockPtr,

FILE: ACMultiHomedSocket.h
  type CWMultiHomedInterface (line 36) | typedef struct {
  type CWMultiHomedSocket (line 50) | typedef struct {
  type sockaddr_in (line 76) | struct sockaddr_in

FILE: ACProtocol.c
  function CWBool (line 41) | CWBool CWProtocolAssembleConfigurationUpdateRequest(CWProtocolMessage **...
  function CWBool (line 98) | CWBool CWAssembleMsgElemACWTPRadioInformation(CWProtocolMessage * msgPtr)
  function CWBool (line 117) | CWBool CWAssembleMsgElemACDescriptor(CWProtocolMessage * msgPtr)
  function CWBool (line 164) | CWBool CWAssembleMsgElemACIPv4List(CWProtocolMessage * msgPtr)
  function CWBool (line 190) | CWBool CWAssembleMsgElemACIPv6List(CWProtocolMessage * msgPtr)
  function CWBool (line 216) | CWBool CWAssembleMsgElemACName(CWProtocolMessage * msgPtr)
  function CWBool (line 236) | CWBool CWAssembleMsgElemAddWLAN(int radioID, CWProtocolMessage * msgPtr,...
  function CWBool (line 249) | CWBool CWAssembleMsgElemDeleteWLAN(int radioID, CWProtocolMessage * msgP...
  function CWBool (line 260) | CWBool CWAssembleMsgElemAddStation(int radioID, CWProtocolMessage * msgP...
  function CWBool (line 279) | CWBool CWAssembleMsgElemDeleteStation(int radioID, CWProtocolMessage * m...
  function CWBool (line 293) | CWBool CWAssembleMsgElemCWControlIPv4Addresses(CWProtocolMessage * msgPtr)
  function CWBool (line 330) | CWBool CWAssembleMsgElemCWControlIPv6Addresses(CWProtocolMessage * msgPtr)
  function CWBool (line 362) | CWBool CWAssembleMsgElemCWTimer(CWProtocolMessage * msgPtr)
  function CWBool (line 387) | CWBool CWAssembleMsgElemDecryptErrorReportPeriod(CWProtocolMessage * msg...
  function CWBool (line 446) | CWBool CWAssembleMsgElemIdleTimeout(CWProtocolMessage * msgPtr)
  function CWBool (line 467) | CWBool CWAssembleMsgElemWTPFallback(CWProtocolMessage * msgPtr)
  function CWBool (line 486) | CWBool CWAssembleMsgElemRadioOperationalState(int radioID, CWProtocolMes...
  function CWBool (line 543) | CWBool CWParseACNameWithIndex(CWProtocolMessage * msgPtr, int len, CWACN...
  function CWBool (line 558) | CWBool CWParseDiscoveryType(CWProtocolMessage * msgPtr, int len, CWDisco...
  function CWBool (line 567) | CWBool CWParseLocationData(CWProtocolMessage * msgPtr, int len, char **v...
  function CWBool (line 579) | CWBool CWParseMsgElemDuplicateIPv4Address(CWProtocolMessage * msgPtr, in...
  function CWBool (line 595) | CWBool CWParseMsgElemDuplicateIPv6Address(CWProtocolMessage * msgPtr, in...
  function CWBool (line 618) | CWBool CWParseWTPStatisticsTimer(CWProtocolMessage * msgPtr, int len, in...
  function CWBool (line 629) | CWBool CWParseWTPBoardData(CWProtocolMessage * msgPtr, int len, CWWTPVen...
  function CWBool (line 675) | CWBool CWParseMsgElemDataTransferData(CWProtocolMessage * msgPtr, int len,
  function CWBool (line 688) | CWBool CWParseWTPDescriptor(CWProtocolMessage * msgPtr, int len, CWWTPDe...
  function CWBool (line 751) | CWBool CWParseWTPFrameTunnelMode(CWProtocolMessage * msgPtr, int len, CW...
  function CWBool (line 761) | CWBool CWParseWTPIPv4Address(CWProtocolMessage * msgPtr, int len, CWProt...
  function CWBool (line 773) | CWBool CWParseWTPMACType(CWProtocolMessage * msgPtr, int len, CWMACType ...
  function CWBool (line 783) | CWBool CWParseWTPRadioInformation(CWProtocolMessage * msgPtr, int len, u...
  function CWBool (line 797) | CWBool CWParseWTPSupportedRates(CWProtocolMessage * msgPtr, int len, uns...
  function CWBool (line 819) | CWBool CWParseWTPMultiDomainCapability(CWProtocolMessage * msgPtr, int l...
  function CWBool (line 840) | CWBool CWParseWTPName(CWProtocolMessage * msgPtr, int len, char **valPtr)
  function CWBool (line 852) | CWBool CWParseWTPRebootStatistics(CWProtocolMessage * msgPtr, int len, W...
  function CWBool (line 873) | CWBool CWParseWTPRadioStatistics(CWProtocolMessage * msgPtr, int len, WT...
  function CWBool (line 898) | CWBool CWParseWTPOperationalStatistics(CWProtocolMessage * msgPtr, int l...
  function CWBool (line 911) | CWBool CWParseMsgElemDecryptErrorReport(CWProtocolMessage * msgPtr, int ...

FILE: ACProtocol.h
  type CWWTPProtocolManager (line 33) | typedef struct {
  type CWProtocolJoinRequestValues (line 53) | typedef struct {
  type CWProtocolConfigureRequestValues (line 65) | typedef struct {
  type CWProtocolChangeStateEventRequestValues (line 75) | typedef struct {
  type WTPOperationalStatisticsValues (line 80) | typedef struct {
  type WTPRadioStatisticsValues (line 86) | typedef struct {
  type WTPDuplicateIPv4 (line 91) | typedef struct {
  type WTPDuplicateIPv6 (line 98) | typedef struct {
  type CWProtocolWTPEventRequestValues (line 105) | typedef struct {
  type CWProtocolWTPDataTransferRequestValues (line 117) | typedef struct {
  type in6_addr (line 176) | struct in6_addr

FILE: ACProtocol_User.c
  function CWBool (line 34) | __inline__ CWBool CWACSupportIPv6()
  function CWACGetStations (line 44) | __inline__ int CWACGetStations()
  function CWACGetLimit (line 49) | __inline__ int CWACGetLimit()
  function CWACGetActiveWTPs (line 54) | __inline__ int CWACGetActiveWTPs()
  function CWACGetMaxWTPs (line 65) | __inline__ int CWACGetMaxWTPs()
  function CWACGetSecurity (line 70) | __inline__ int CWACGetSecurity()
  function CWACGetRMACField (line 75) | __inline__ int CWACGetRMACField()
  function CWACGetWirelessField (line 80) | __inline__ int CWACGetWirelessField()
  function CWACGetDTLSPolicy (line 85) | __inline__ int CWACGetDTLSPolicy()
  function CWACGetHWVersion (line 90) | __inline__ int CWACGetHWVersion()
  function CWACGetSWVersion (line 95) | __inline__ int CWACGetSWVersion()
  function CWACGetInterfacesCount (line 100) | __inline__ int CWACGetInterfacesCount()
  function CWACGetInterfaceIPv4AddressAtIndex (line 105) | __inline__ int CWACGetInterfaceIPv4AddressAtIndex(int i)
  type sockaddr_in6 (line 120) | struct sockaddr_in6
  type sockaddr_in6 (line 122) | struct sockaddr_in6
  function CWACGetInterfaceWTPCountAtIndex (line 127) | __inline__ int CWACGetInterfaceWTPCountAtIndex(int i)
  function CWBool (line 132) | CWBool CWACGetVendorInfos(CWACVendorInfos * valPtr)
  function CWACDestroyVendorInfos (line 163) | __inline__ void CWACDestroyVendorInfos(CWACVendorInfos * valPtr)
  function CWBool (line 177) | CWBool CWACGetACIPv4List(int **listPtr, int *countPtr)
  function CWBool (line 199) | CWBool CWACGetACIPv6List(struct in6_addr ** listPtr, int *countPtr)
  function CWBool (line 217) | CWBool CWACGetDiscoveryTimer(int *timer)
  function CWBool (line 223) | CWBool CWACGetEchoRequestTimer(int *timer)
  function CWBool (line 229) | CWBool CWACGetIdleTimeout(int *timer)
  function CWBool (line 236) | CWBool CWGetWTPRadiosAdminState(CWRadiosAdminInfo * valPtr)
  function CWBool (line 263) | CWBool CWGetWTPRadiosOperationalState(int radioID, CWRadiosOperationalIn...

FILE: ACRetransmission.c
  function CW_FREE_WTP_MSG_ARRAY (line 41) | static void inline CW_FREE_WTP_MSG_ARRAY(int WTPIndex)
  function CWBool (line 85) | CWBool CWACResendAcknowledgedPacket(int WTPIndex)
  function CWBool (line 102) | __inline__ CWBool CWACSendAcknowledgedPacket(int WTPIndex, int msgType, ...
  function CWACStopRetransmission (line 112) | void CWACStopRetransmission(int WTPIndex)

FILE: ACRunState.c
  function flush_pcap (line 82) | int flush_pcap(u_char * buf, int len, char *filename)
  function isEAPOL_Frame (line 112) | int isEAPOL_Frame(unsigned char *buf, int len)
  function CWBool (line 123) | CWBool ACEnterRun(int WTPIndex, CWProtocolMessage * msgPtr, CWBool dataF...

FILE: ACSettingsFile.c
  function CWExtractValue (line 45) | void CWExtractValue(char *start, char **startValue, char **endValue, int...
  function CWBool (line 54) | CWBool CWParseSettingsFile()

FILE: ACipcHostapd.c
  type client_hostapd (line 37) | struct client_hostapd {
  type client_hostapd (line 54) | struct client_hostapd
  function CWACsend_data_to_hostapd (line 60) | void CWACsend_data_to_hostapd(int WTPIndex, unsigned char *buf, int len)
  function CWACsend_command_to_hostapd_CLOSE (line 75) | void CWACsend_command_to_hostapd_CLOSE(int WTPIndex, unsigned char *buf,...
  function CWACsend_command_to_hostapd_SET_WTPRINFO (line 87) | void CWACsend_command_to_hostapd_SET_WTPRINFO(int WTPIndex, char *buf, i...
  function CWACsend_command_to_hostapd_SET_RATES (line 98) | void CWACsend_command_to_hostapd_SET_RATES(int WTPIndex, char *buf, int ...
  function CWACsend_command_to_hostapd_SET_MDC (line 110) | void CWACsend_command_to_hostapd_SET_MDC(int WTPIndex, char *buf, int len)
  function CWACsend_command_to_hostapd_SET_MAC (line 122) | void CWACsend_command_to_hostapd_SET_MAC(int WTPIndex, char *buf, int len)
  function CWACsend_command_to_hostapd_GOLIVE (line 134) | void CWACsend_command_to_hostapd_GOLIVE(int WTPIndex)
  function CWACsend_command_to_hostapd_HAVE_TO_WAIT (line 148) | void CWACsend_command_to_hostapd_HAVE_TO_WAIT(int WTPIndex)
  function CWACsend_command_to_hostapd_SEND_WLAN (line 162) | void CWACsend_command_to_hostapd_SEND_WLAN(int WTPIndex)
  type sockaddr_un (line 176) | struct sockaddr_un
  function send_close_cmd (line 180) | void send_close_cmd(struct sockaddr_in6 cli, int as)

FILE: CWAC.h
  type applicationsManager (line 83) | typedef struct {
  type CWWTPManager (line 99) | typedef struct {
  type UNIX_SOCKS_INFO (line 210) | typedef struct {

FILE: CWBinding.c
  function CWBool (line 38) | CWBool CWBindingCheckType(int elemType)
  function CWBool (line 47) | CWBool CWAssembleDataMessage(CWProtocolMessage ** completeMsgPtr, int *f...
  function CWBool (line 174) | CWBool CWAssembleTransportHeaderBinding(CWProtocolMessage * transportHdr...
  function CWBool (line 217) | CWBool CWParseTransportHeaderMACAddress(CWProtocolMessage * msgPtr, unsi...
  function CWBool (line 242) | CWBool CWParseTransportHeaderBinding(CWProtocolMessage * msgPtr, CWBindi...

FILE: CWBinding.h
  type OFDMControlValues (line 102) | typedef struct {
  type WTPQosValues (line 108) | typedef struct {
  type bindingValues (line 117) | typedef struct {
  type CWBindingTransportHeaderValues (line 123) | typedef struct {
  type CWBindingDataListElement (line 129) | typedef struct {

FILE: CWCommon.c
  function CWTimevalSubtract (line 39) | int CWTimevalSubtract(struct timeval *res, const struct timeval *x, cons...

FILE: CWCommon.h
  type CWBool (line 69) | typedef enum {
  type CWStateTransition (line 74) | typedef enum {
  type timeval (line 132) | struct timeval
  type timeval (line 132) | struct timeval
  type timeval (line 132) | struct timeval

FILE: CWConfigFile.c
  function CWBool (line 108) | CWBool CWParseTheFile(CWBool isCount)
  function CWBool (line 221) | CWBool CWParseConfigFile()

FILE: CWConfigFile.h
  type CWConfigValue (line 33) | typedef struct {

FILE: CWErrorHandling.c
  function CWErrorHandlingInitLib (line 41) | void CWErrorHandlingInitLib()
  function CWBool (line 58) | CWBool _CWErrorRaise(CWErrorCode code, const char *msg, const char *file...
  function CWErrorPrint (line 94) | void CWErrorPrint(CWErrorHandlingInfo * infoPtr, const char *desc, const...
  function CWErrorCode (line 108) | CWErrorCode CWErrorGetLastErrorCode()
  function CWBool (line 124) | CWBool _CWErrorHandleLast(const char *fileName, int line)

FILE: CWErrorHandling.h
  type CWErrorCode (line 31) | typedef enum {
  type CWErrorHandlingInfo (line 48) | typedef struct {

FILE: CWList.c
  function CWBool (line 36) | CWBool CWAddElementToList(CWList * list, void *element)
  function CWBool (line 63) | CWBool CWAddElementToListTail(CWList * list, void *element)
  function CWList (line 91) | CWList CWListGetFirstElem(CWList * list)
  function CWDeleteList (line 174) | void CWDeleteList(CWList * list, void (*deleteFunc) (void *))
  function CWCountElementInList (line 189) | int CWCountElementInList(CWList list)

FILE: CWList.h
  type CWListElement (line 33) | typedef struct _s {
  type CWListIterateMode (line 38) | typedef enum {
  type CWListElement (line 43) | typedef CWListElement *CWList;

FILE: CWLog.c
  function CWLogInitFile (line 41) | void CWLogInitFile(char *fileName)
  function CWBool (line 58) | static CWBool checkResetFile()
  function CWLogCloseFile (line 76) | void CWLogCloseFile()
  function CWVLog (line 85) | void CWVLog(const char *format, va_list args)
  function CWLog (line 135) | void CWLog(const char *format, ...)
  function CWDebugLog (line 146) | void CWDebugLog(const char *format, ...)

FILE: CWNetwork.c
  function CWNetworkGetAddressSize (line 39) | __inline__ int CWNetworkGetAddressSize(CWNetworkLev4Address * addrPtr)
  function CWBool (line 59) | CWBool CWNetworkSendUnsafeUnconnected(CWSocket sock, CWNetworkLev4Addres...
  function CWBool (line 80) | CWBool CWNetworkSendUnsafeConnected(CWSocket sock, unsigned char *buf, i...
  function CWBool (line 99) | CWBool CWNetworkReceiveUnsafeConnected(CWSocket sock, unsigned char *buf...
  function CWBool (line 118) | CWBool CWNetworkReceiveUnsafe(CWSocket sock,
  type sockaddr_in6 (line 143) | struct sockaddr_in6
  type sockaddr_in (line 145) | struct sockaddr_in
  type sockaddr (line 167) | struct sockaddr
  type sockaddr (line 173) | struct sockaddr
  type sockaddr (line 185) | struct sockaddr
  type sockaddr (line 188) | struct sockaddr
  type sockaddr_in6 (line 206) | struct sockaddr_in6
  type sockaddr_in (line 208) | struct sockaddr_in
  type sockaddr (line 232) | struct sockaddr
  type sockaddr (line 238) | struct sockaddr
  type sockaddr (line 251) | struct sockaddr
  type sockaddr (line 252) | struct sockaddr
  type sockaddr (line 256) | struct sockaddr
  function CWBool (line 269) | CWBool CWNetworkTimedPollRead(CWSocket sock, struct timeval * timeout)
  function CWBool (line 305) | CWBool CWNetworkGetAddressForHost(char *host, CWNetworkLev4Address * add...

FILE: CWNetwork.h
  type CWSocket (line 40) | typedef int CWSocket;
  type CWNetworkLev4Address (line 42) | typedef struct sockaddr_storage CWNetworkLev4Address;
  type CWNetworkLev3Service (line 44) | typedef enum {
  type timeval (line 80) | struct timeval

FILE: CWOpenSSLBio.c
  type BIO_memory_data (line 45) | typedef struct {
  function BIO_METHOD (line 65) | BIO_METHOD *BIO_s_memory(void)
  function BIO (line 70) | BIO *BIO_new_memory(CWSocket sock, CWNetworkLev4Address * pSendAddress, ...
  function memory_new (line 88) | static int memory_new(BIO * bi)
  function memory_free (line 98) | static int memory_free(BIO * a)
  function memory_read (line 107) | static int memory_read(BIO * b, char *out, int outl)
  function memory_write (line 140) | static int memory_write(BIO * b, const char *in, int inl)
  function memory_ctrl (line 170) | static long memory_ctrl(BIO * b, int cmd, long num, void *ptr)
  function memory_puts (line 250) | static int memory_puts(BIO * bp, const char *str)

FILE: CWProtocol.c
  function CWProtocolStore8 (line 43) | void CWProtocolStore8(CWProtocolMessage * msgPtr, unsigned char val)
  function CWProtocolStore16 (line 50) | void CWProtocolStore16(CWProtocolMessage * msgPtr, unsigned short val)
  function CWProtocolStore32 (line 58) | void CWProtocolStore32(CWProtocolMessage * msgPtr, unsigned int val)
  function CWProtocolStoreStr (line 67) | void CWProtocolStoreStr(CWProtocolMessage * msgPtr, char *str)
  function CWProtocolStoreMessage (line 75) | void CWProtocolStoreMessage(CWProtocolMessage * msgPtr, CWProtocolMessag...
  function CWProtocolStoreRawBytes (line 82) | void CWProtocolStoreRawBytes(CWProtocolMessage * msgPtr, unsigned char *...
  function CWProtocolRetrieve8 (line 89) | unsigned char CWProtocolRetrieve8(CWProtocolMessage * msgPtr)
  function CWProtocolRetrieve16 (line 100) | unsigned short CWProtocolRetrieve16(CWProtocolMessage * msgPtr)
  function CWProtocolRetrieve32 (line 111) | unsigned int CWProtocolRetrieve32(CWProtocolMessage * msgPtr)
  function CWProtocolDestroyMsgElemData (line 151) | void CWProtocolDestroyMsgElemData(void *f)
  function CWBool (line 157) | CWBool CWAssembleMsgElem(CWProtocolMessage * msgPtr, unsigned int type)
  function CWBool (line 183) | CWBool CWAssembleTransportHeader(CWProtocolMessage * transportHdrPtr, CW...
  function CWBool (line 289) | CWBool CWAssembleTransportHeaderKeepAliveData(CWProtocolMessage * transp...
  function CWBool (line 363) | CWBool CWAssembleControlHeader(CWProtocolMessage * controlHdrPtr, CWCont...
  function CWBool (line 383) | CWBool CWAssembleVendorMsgElemResultCodeWithPayload(CWProtocolMessage * ...
  function CWBool (line 453) | CWBool CWAssembleMsgElemResultCode(CWProtocolMessage * msgPtr, CWProtoco...
  function CWBool (line 470) | CWBool CWAssembleMessage(CWProtocolMessage ** completeMsgPtr, int *fragm...
  function CWProtocolDestroyFragment (line 635) | void CWProtocolDestroyFragment(void *f)
  function CWBool (line 641) | CWBool CWCompareFragment(void *newFrag, void *oldFrag)
  function CWBool (line 657) | CWBool CWProtocolParseFragment(unsigned char *buf, int readBytes, CWList...
  function CWBool (line 816) | CWBool CWParseTransportHeader(CWProtocolMessage * msgPtr, CWProtocolTran...
  function CWBool (line 946) | CWBool CWParseControlHeader(CWProtocolMessage * msgPtr, CWControlHeaderV...
  function CWBool (line 973) | CWBool CWAssembleUnrecognizedMessageResponse(CWProtocolMessage ** messag...
  function CWBool (line 1005) | CWBool CWAssembleMsgElemSessionID(CWProtocolMessage * msgPtr, unsigned c...
  function CWBool (line 1019) | CWBool CWParseACName(CWProtocolMessage * msgPtr, int len, char **valPtr)
  function CWBool (line 1031) | CWBool CWParseWTPRadioAdminState(CWProtocolMessage * msgPtr, int len, CW...
  function CWBool (line 1044) | CWBool CWParseWTPRadioOperationalState(CWProtocolMessage * msgPtr, int l...
  function CWBool (line 1057) | CWBool CWParseFormatMsgElem(CWProtocolMessage * completeMsg, unsigned sh...
  function CWBool (line 1064) | CWBool CWParseResultCode(CWProtocolMessage * msgPtr, int len, CWProtocol...
  function CWWTPResetRadioStatistics (line 1074) | void CWWTPResetRadioStatistics(WTPRadioStatisticsInfo * radioStatistics)
  function CWFreeMessageFragments (line 1088) | void CWFreeMessageFragments(CWProtocolMessage * messages, int fragmentsNum)

FILE: CWProtocol.h
  type CWMsgElemData (line 303) | typedef struct {
  type CWProtocolResultCode (line 310) | typedef enum {
  type CWProtocolMessage (line 335) | typedef struct {
  type CWPendingRequestMessage (line 344) | typedef struct {
  type CWProtocolTransportHeaderValues (line 358) | typedef struct {
  type CWControlHeaderValues (line 369) | typedef struct {
  type CWProtocolFragment (line 376) | typedef struct {
  type CWWTPVendorInfoValues (line 382) | typedef struct {
  type CWWTPVendorInfos (line 398) | typedef struct {
  type CWWTPEncryptCapValues (line 403) | typedef struct {
  type CWWTPEncryptCaps (line 408) | typedef struct {
  type CWWTPDescriptor (line 413) | typedef struct {
  type CWframeTunnelMode (line 420) | typedef enum {
  type CWTunnelMode (line 428) | typedef enum {
  type CWMACType (line 434) | typedef enum {
  type CWDiscoveryRequestValues (line 440) | typedef struct {
  type CWAuthSecurity (line 452) | typedef enum {
  type CWProtocolNetworkInterface (line 457) | typedef struct {
  type CWProtocolIPv4NetworkInterface (line 464) | typedef struct {
  type CWProtocolIPv6NetworkInterface (line 469) | typedef struct {
  type CWACVendorInfoValues (line 474) | typedef struct {
  type CWACVendorInfos (line 484) | typedef struct {
  type WTPRebootStatisticsInfo (line 489) | typedef struct {
  type WTPDecryptErrorReportValues (line 508) | typedef struct {
  type WTPDecryptErrorReport (line 513) | typedef struct {
  type CWACNameWithIndexValues (line 518) | typedef struct {
  type CWACNamesWithIndex (line 523) | typedef struct {
  type CWRadioInformationValues (line 528) | typedef struct {
  type CWRadiosInformation (line 539) | typedef struct {
  type CWstate (line 544) | typedef enum {
  type CWAdminCause (line 549) | typedef enum {
  type CWOperationalCause (line 556) | typedef enum {
  type CWRadioAdminInfoValues (line 563) | typedef struct {
  type CWRadiosAdminInfo (line 569) | typedef struct {
  type CWRadioOperationalInfoValues (line 574) | typedef struct {
  type CWRadiosOperationalInfo (line 580) | typedef struct {
  type CWDecryptErrorReportValues (line 585) | typedef struct {
  type CWDecryptErrorReportInfo (line 592) | typedef struct {
  type WTPRadioStatisticsInfo (line 597) | typedef struct {
  type CWWTPRadioInfoValues (line 616) | typedef struct {
  type CWWTPRadiosInfo (line 638) | typedef struct {
  type CWProtocolVendorSpecificValues (line 647) | typedef struct {

FILE: CWRandom.c
  function CWRandomInitLib (line 34) | __inline__ void CWRandomInitLib()
  function CWRandomIntInRange (line 40) | __inline__ int CWRandomIntInRange(int min, int max)

FILE: CWSafeList.c
  function CWBool (line 34) | CWBool CWCreateSafeList(CWSafeList * pSafeList)
  function CWDestroySafeList (line 58) | void CWDestroySafeList(CWSafeList safeList)
  function CWSetMutexSafeList (line 69) | void CWSetMutexSafeList(CWSafeList safeList, CWThreadMutex * pThreadMutex)
  function CWSetConditionSafeList (line 79) | void CWSetConditionSafeList(CWSafeList safeList, CWThreadCondition * pTh...
  function CWBool (line 89) | CWBool CWLockSafeList(CWSafeList safeList)
  function CWUnlockSafeList (line 100) | void CWUnlockSafeList(CWSafeList safeList)
  function CWBool (line 111) | CWBool CWWaitElementFromSafeList(CWSafeList safeList)
  function CWBool (line 121) | CWBool CWSignalElementSafeList(CWSafeList safeList)
  function CWGetCountElementFromSafeList (line 132) | unsigned long CWGetCountElementFromSafeList(CWSafeList safeList)
  function CWBool (line 143) | CWBool CWAddElementToSafeListHead(CWSafeList safeList, void *pData, int ...
  function CWBool (line 243) | CWBool CWAddElementToSafeListTail(CWSafeList safeList, void *pData, int ...
  function CWBool (line 269) | CWBool CWAddElementToSafeListTailwitDataFlag(CWSafeList safeList, void *...
  function CWCleanSafeList (line 324) | void CWCleanSafeList(CWSafeList safeList, void (*deleteFunc) (void *))

FILE: CWSafeList.h
  type CWPrivateSafeElement (line 35) | typedef struct _CWPrivateSafeElement {
  type CWPrivateSafeList (line 43) | typedef struct _CWPrivateSafeList {

FILE: CWSecurity.c
  function CWSslLockingFunc (line 98) | static void CWSslLockingFunc(int mode, int n, const char *file, int line)
  function CWSslIdFunction (line 109) | static unsigned long CWSslIdFunction()
  function CWSslCleanUp (line 115) | void CWSslCleanUp()
  function CWBool (line 134) | CWBool CWSecurityInitLib()
  function CWBool (line 167) | CWBool CWSecurityInitSessionClient(CWSocket sock,
  function CWSecurityCloseSession (line 258) | void CWSecurityCloseSession(CWSecuritySession * sPtr)
  function CWBool (line 264) | CWBool CWSecurityReceive(CWSecuritySession session, char *buf, int len, ...
  function CWBool (line 285) | CWBool CWSecuritySend(CWSecuritySession session, const char *buf, int len)
  function CWBool (line 297) | CWBool CWSecurityInitSessionServer(CWWTPManager * pWtp,
  function CWBool (line 379) | CWBool CWSecurityInitContext(CWSecurityContext * ctxPtr,
  function CWSecurityDestroyContext (line 484) | void CWSecurityDestroyContext(CWSecurityContext ctx)
  function CWSecurityDestroySession (line 491) | void CWSecurityDestroySession(CWSecuritySession s)
  function CWBool (line 500) | CWBool CWSecurityVerifyCertEKU(X509 * x509, const char *const expected_oid)
  function CWBool (line 546) | CWBool CWSecurityVerifyPeerCertificateForCAPWAP(SSL * ssl, CWBool isClient)
  function CWDTLSPasswordCB (line 561) | static int CWDTLSPasswordCB(char *buf, int num, int rwflag, void *userdata)
  function CWSecurityVerifyCB (line 572) | int CWSecurityVerifyCB(int ok, X509_STORE_CTX * ctx)
  function CWSecurityPSKClientCB (line 628) | unsigned int CWSecurityPSKClientCB(SSL * ssl,
  function CWSecurityPSKServerCB (line 642) | unsigned int CWSecurityPSKServerCB(SSL * ssl, const char *identity, unsi...
  function psk_key2bn (line 653) | int psk_key2bn(const char *psk_key, unsigned char *psk, unsigned int max...

FILE: CWSecurity.h
  type SSL_CTX (line 35) | typedef SSL_CTX *CWSecurityContext;
  type SSL (line 36) | typedef SSL *CWSecuritySession;

FILE: CWStevens.c
  type sockaddr (line 42) | struct sockaddr
  type sockaddr_in (line 48) | struct sockaddr_in
  type sockaddr_in (line 48) | struct sockaddr_in
  type sockaddr_in6 (line 62) | struct sockaddr_in6
  type sockaddr_in6 (line 62) | struct sockaddr_in6
  type sockaddr_un (line 78) | struct sockaddr_un
  type sockaddr_un (line 78) | struct sockaddr_un
  type sockaddr_dl (line 92) | struct sockaddr_dl
  type sockaddr_dl (line 92) | struct sockaddr_dl
  function sock_cpy_addr_port (line 108) | int sock_cpy_addr_port(struct sockaddr *sa1, const struct sockaddr *sa2)
  function sock_set_port_cw (line 146) | void sock_set_port_cw(struct sockaddr *sa, int port)
  type ifi_info (line 169) | struct ifi_info
  type ifi_info (line 171) | struct ifi_info
  type ifconf (line 174) | struct ifconf
  type ifreq (line 175) | struct ifreq
  type sockaddr_in (line 176) | struct sockaddr_in
  type sockaddr_in6 (line 177) | struct sockaddr_in6
  type ifreq (line 182) | struct ifreq
  type ifreq (line 192) | struct ifreq
  type ifreq (line 201) | struct ifreq
  type sockaddr (line 204) | struct sockaddr
  type sockaddr_in6 (line 209) | struct sockaddr_in6
  type sockaddr (line 214) | struct sockaddr
  type ifreq (line 218) | struct ifreq
  type sockaddr_dl (line 223) | struct sockaddr_dl
  type sockaddr_dl (line 223) | struct sockaddr_dl
  type ifi_info (line 248) | struct ifi_info
  type ifi_info (line 248) | struct ifi_info
  type sockaddr_in (line 262) | struct sockaddr_in
  type sockaddr (line 263) | struct sockaddr
  type sockaddr_in (line 263) | struct sockaddr_in
  type sockaddr_in (line 264) | struct sockaddr_in
  type sockaddr_in (line 269) | struct sockaddr_in
  type sockaddr (line 270) | struct sockaddr
  type sockaddr_in (line 270) | struct sockaddr_in
  type sockaddr_in (line 271) | struct sockaddr_in
  type sockaddr_in6 (line 279) | struct sockaddr_in6
  type sockaddr (line 280) | struct sockaddr
  type sockaddr_in6 (line 280) | struct sockaddr_in6
  type sockaddr_in6 (line 281) | struct sockaddr_in6
  function free_ifi_info (line 296) | void free_ifi_info(struct ifi_info *ifihead)
  function sock_cmp_port (line 312) | int sock_cmp_port(const struct sockaddr *sa1, const struct sockaddr *sa2...
  function sock_cmp_addr (line 347) | int sock_cmp_addr(const struct sockaddr *sa1, const struct sockaddr *sa2...
  function mcast_join (line 380) | int mcast_join(int sockfd, const struct sockaddr *grp, socklen_t grplen,...
  function writen (line 444) | int /* Write "n" bytes to a descriptor. */ writen(int fd, const void *vp...
  function Writen (line 466) | int Writen(int fd, void *ptr, size_t nbytes)

FILE: CWStevens.h
  type ifi_info (line 37) | struct ifi_info {
  type ifi_info (line 46) | struct ifi_info
  type ifi_info (line 47) | struct ifi_info
  type sockaddr (line 48) | struct sockaddr
  type sockaddr (line 49) | struct sockaddr
  type sockaddr (line 49) | struct sockaddr
  type sockaddr (line 50) | struct sockaddr
  type sockaddr (line 51) | struct sockaddr
  type sockaddr (line 51) | struct sockaddr
  type sockaddr (line 52) | struct sockaddr
  type sockaddr (line 52) | struct sockaddr
  type sockaddr (line 53) | struct sockaddr

FILE: CWThread.c
  function CWBool (line 45) | CWBool CWCreateThread(CWThread * newThread, CW_THREAD_FUNCTION threadFun...
  function CWBool (line 61) | CWBool CWCreateThreadCondition(CWThreadCondition * theCondition)
  function CWDestroyThreadCondition (line 78) | void CWDestroyThreadCondition(CWThreadCondition * theCondition)
  function CWBool (line 86) | CWBool CWWaitThreadCondition(CWThreadCondition * theCondition, CWThreadM...
  function CWBool (line 105) | CWBool CWWaitThreadConditionTimeout(CWThreadCondition * theCondition, CW...
  function CWSignalThreadCondition (line 126) | void CWSignalThreadCondition(CWThreadCondition * theCondition)
  function CWBool (line 135) | CWBool CWCreateThreadMutex(CWThreadMutex * theMutex)
  function CWDestroyThreadMutex (line 152) | void CWDestroyThreadMutex(CWThreadMutex * theMutex)
  function CWBool (line 160) | CWBool CWThreadMutexLock(CWThreadMutex * theMutex)
  function CWBool (line 176) | CWBool CWThreadMutexTryLock(CWThreadMutex * theMutex)
  function CWThreadMutexUnlock (line 188) | void CWThreadMutexUnlock(CWThreadMutex * theMutex)
  function CWBool (line 200) | CWBool CWThreadCreateSem(CWThreadSem * semPtr, int value)
  function CWThreadDestroySem (line 228) | void CWThreadDestroySem(CWThreadSem * semPtr)
  function CWBool (line 296) | CWBool CWThreadSemGetValue(CWThreadSem * semPtr, int *valuePtr)
  function sem_t (line 322) | sem_t *CWThreadGetSemT(CWThreadSem * semPtr)
  function CWBool (line 333) | CWBool CWThreadCreateTimedSem(CWThreadTimedSem * semPtr, int value)
  function CWBool (line 382) | CWBool CWThreadTimedSemIsZero(CWThreadTimedSem * semPtr)
  function CWBool (line 418) | CWBool CWThreadTimedSemSetValue(CWThreadTimedSem * semPtr, int value)
  function CWThreadDestroyTimedSem (line 482) | void CWThreadDestroyTimedSem(CWThreadTimedSem * semPtr)
  type timespec (line 497) | struct timespec
  type timeval (line 533) | struct timeval
  function CWBool (line 613) | CWBool CWThreadTimedSemPost(CWThreadTimedSem * semPtr)
  function CWBool (line 680) | CWBool CWThreadCreateSpecific(CWThreadSpecific * specPtr, void (*destruc...
  function CWThreadDestroySpecific (line 693) | void CWThreadDestroySpecific(CWThreadSpecific * specPtr)
  function CWBool (line 707) | CWBool CWThreadSetSpecific(CWThreadSpecific * specPtr, void *valPtr)
  function CWExitThread (line 725) | void CWExitThread()
  function CWThreadSetSignals (line 732) | void CWThreadSetSignals(int how, int num, ...)
  type CWThreadTimerArg (line 751) | typedef struct {
  function CWHandleTimer (line 775) | void CWHandleTimer(CWTimerArg arg)
  function CWBool (line 791) | CWBool CWTimerRequest(int sec, CWThread * threadPtr, CWTimerID * idPtr, ...
  function CWTimerFreeArg (line 818) | void CWTimerFreeArg(CWTimerArg arg)
  function CWBool (line 833) | CWBool CWTimerCancel(CWTimerID * idPtr)

FILE: CWThread.h
  type CWThreadSem (line 42) | typedef struct {
  type sem_t (line 51) | typedef sem_t CWThreadSem;
  type CWThreadSem (line 55) | typedef CWThreadSem CWThreadTimedSem;
  type pthread_t (line 60) | typedef pthread_t CWThread;
  type pthread_mutex_t (line 61) | typedef pthread_mutex_t CWThreadMutex;
  type pthread_cond_t (line 62) | typedef pthread_cond_t CWThreadCondition;
  type pthread_key_t (line 63) | typedef pthread_key_t CWThreadSpecific;
  type pthread_once_t (line 64) | typedef pthread_once_t CWThreadOnce;
  type CWThreadId (line 67) | typedef int CWThreadId;
  type CWTimerID (line 69) | typedef int CWTimerID;
  type timespec (line 93) | struct timespec

FILE: CWTimer.h
  type int2 (line 61) | typedef short int int2;
  type int4 (line 62) | typedef int int4;
  type itimerval (line 65) | struct itimerval
  type timer (line 107) | struct timer {
  type timer (line 113) | struct timer
  type timer (line 114) | struct timer
  type itimerval (line 124) | struct itimerval
  type timer (line 130) | struct timer
  function CWBool (line 134) | __inline__ CWBool CWTimersInitLib()
  function CWTimersInit (line 144) | void CWTimersInit()
  function CWBool (line 151) | __inline__ CWBool CWTimerCreate(int sec, CWTimerID * idPtr, void (*hdl) ...
  function CWTimerArg (line 164) | __inline__ CWTimerArg CWTimerGetArg(CWTimerID * idPtr)
  function CWBool (line 182) | __inline__ CWBool CWTimerSetArg(CWTimerID * idPtr, CWTimerArg arg)
  function CWBool (line 198) | __inline__ CWBool CWTimerDestroy(CWTimerID * idPtr)
  type sigaction (line 215) | struct sigaction
  function _clkini (line 218) | void _clkini()
  function _setimr (line 258) | int _setimr(unsigned int timeout,	/* time to wait in 10msec ticks */
  function _cantim (line 325) | int _cantim(CWTimerID * idPtr)
  function clk_isr (line 351) | void clk_isr()
  function update_all_timers_by (line 367) | void update_all_timers_by(unsigned int time)
  type timer (line 394) | struct timer
  type timer (line 396) | struct timer
  function start_timer (line 407) | void start_timer(t)
  function current_time (line 424) | unsigned int current_time()
  function cancel_itimer (line 432) | void cancel_itimer()

FILE: CWVendorPayloads.h
  type CWVendorUciValues (line 41) | typedef struct {
  type mess_version_info (line 56) | typedef struct {
  type mess_up_req (line 61) | typedef struct {
  type mess_cup (line 65) | typedef struct {
  type CWVendorWumValues (line 71) | typedef struct {

FILE: CWVendorPayloadsAC.c
  function CWBool (line 41) | CWBool CWAssembleWTPVendorPayloadUCI(CWProtocolMessage * msgPtr)
  function CWBool (line 92) | CWBool CWAssembleWTPVendorPayloadWUM(CWProtocolMessage * msgPtr)

FILE: CWVendorPayloadsWTP.c
  function CWBool (line 46) | CWBool CWParseUCIPayload(CWProtocolMessage * msgPtr, CWVendorUciValues *...
  function CWBool (line 70) | CWBool CWParseWUMPayload(CWProtocolMessage * msgPtr, CWVendorWumValues *...
  function CWBool (line 98) | CWBool CWParseVendorPayload(CWProtocolMessage * msgPtr, int len, CWProto...
  type WUMState (line 142) | struct WUMState {
  type WUMState (line 150) | struct WUMState
  function CWBool (line 169) | CWBool WUMPrepareForUpdate(int size)
  function CWBool (line 198) | CWBool WUMStoreFragment(CWVendorWumValues * wumValues)
  function CWBool (line 234) | CWBool WUMIsComplete()
  function CWBool (line 249) | CWBool WUMCloseFile()
  function CWBool (line 260) | CWBool WUMCancel()
  function CWBool (line 273) | CWBool CWWTPCheckVersion(CWVendorWumValues * wumPayload)
  function CWBool (line 291) | CWBool StartWUA()
  function CWBool (line 324) | CWBool check_free_space(int bytes)
  function CWBool (line 339) | CWBool CWWTPSaveWUMValues(CWVendorWumValues * wumPayload, CWProtocolResu...
  function CWBool (line 421) | CWBool CWWTPSaveUCIValues(CWVendorUciValues * uciPayload, CWProtocolResu...

FILE: CWWTP.h
  type CWACDescriptor (line 45) | typedef struct {
  type sockaddr_in6 (line 130) | struct sockaddr_in6
  type iwreq (line 162) | struct iwreq
  type iwreq (line 163) | struct iwreq
  type iwreq (line 164) | struct iwreq
  type iwreq (line 165) | struct iwreq
  type iwreq (line 166) | struct iwreq
  type iwreq (line 167) | struct iwreq

FILE: WTP.c
  function CWBool (line 108) | CWBool CWReceiveMessage(CWProtocolMessage * msgPtr)
  function CWBool (line 212) | CWBool CWWTPSendAcknowledgedPacket(int seqNum,
  function usage (line 357) | void usage(void)
  type rlimit (line 367) | struct rlimit
  function CWGetSeqNum (line 545) | unsigned int CWGetSeqNum()
  function CWGetFragmentID (line 556) | int CWGetFragmentID()
  function CWBool (line 565) | CWBool CWWTPLoadConfiguration()
  function CWWTPDestroy (line 595) | void CWWTPDestroy()
  function CWBool (line 611) | CWBool CWWTPInitConfiguration()

FILE: WTPBcmDriverInteraction.c
  function set_rts_threshold (line 46) | int set_rts_threshold(int value)
  function get_rts_threshold (line 62) | int get_rts_threshold(int *value)
  function set_frag_threshold (line 79) | int set_frag_threshold(int value)
  function get_frag_threshold (line 95) | int get_frag_threshold(int *value)
  function set_maxassoc (line 112) | int set_maxassoc(int value)
  function get_maxassoc (line 128) | int get_maxassoc(int *value)
  function set_wme_cwmin (line 148) | int set_wme_cwmin(int class, int value)
  function set_wme_cwmax (line 176) | int set_wme_cwmax(int class, int value)
  function set_wme_aifsn (line 204) | int set_wme_aifsn(int class, int value)
  function wl_ioctl (line 233) | int wl_ioctl(char *name, int cmd, void *buf, int len)
  function wl_iovar_getbuf (line 263) | static int wl_iovar_getbuf(char *ifname, char *iovar, void *param, int p...
  function wl_iovar_setbuf (line 284) | static int wl_iovar_setbuf(char *ifname, char *iovar, void *param, int p...
  function wl_iovar_set (line 302) | int wl_iovar_set(char *ifname, char *iovar, void *param, int paramlen)
  function wl_iovar_get (line 309) | int wl_iovar_get(char *ifname, char *iovar, void *bufptr, int buflen)

FILE: WTPBcmDriverInteraction.h
  type uchar (line 362) | typedef unsigned char uchar;
  type ushort (line 366) | typedef unsigned short ushort;
  type uint (line 370) | typedef unsigned int uint;
  type ulong (line 374) | typedef unsigned long ulong;
  type uint8 (line 380) | typedef unsigned char uint8;
  type uint16 (line 384) | typedef unsigned short uint16;
  type uint32 (line 388) | typedef unsigned int uint32;
  type uint64 (line 392) | typedef unsigned long long uint64;
  type uintptr (line 396) | typedef unsigned int uintptr;
  type int8 (line 400) | typedef signed char int8;
  type int16 (line 404) | typedef signed short int16;
  type int32 (line 408) | typedef signed int int32;
  type int64 (line 412) | typedef signed long long int64;
  type float32 (line 418) | typedef float float32;
  type float64 (line 422) | typedef double float64;
  type float32 (line 434) | typedef float32 float_t;
  type float64 (line 436) | typedef float64 float_t;
  type edcf_acparam (line 514) | struct edcf_acparam {
  type edcf_acparam_t (line 519) | typedef struct edcf_acparam edcf_acparam_t;
  type wl_ioctl_t (line 522) | typedef struct wl_ioctl {
  function wl_iovar_setint (line 558) | static inline int wl_iovar_setint(char *ifname, char *iovar, int val)
  function wl_iovar_getint (line 567) | static inline int wl_iovar_getint(char *ifname, char *iovar, int *val)

FILE: WTPBcmFrameReceive.c
  function extractFrame (line 34) | int extractFrame(CWProtocolMessage ** frame, unsigned char *buffer, int ...
  function get_mac (line 46) | int get_mac(u_char * buf)
  function macAddrCmp (line 72) | int macAddrCmp(unsigned char *addr1, unsigned char *addr2)
  function print_mac (line 98) | void print_mac(u_char * mac, char *extra)
  function fprint_mac (line 103) | void fprint_mac(FILE * outf, u_char * mac, char *extra)
  function CW_THREAD_RETURN_TYPE (line 109) | CW_THREAD_RETURN_TYPE CWWTPReceiveFrame(void *arg)

FILE: WTPBcmFrameReceive.h
  type u_short (line 64) | typedef unsigned short u_short;
  type u_char (line 65) | typedef unsigned char u_char;
  type u_int (line 66) | typedef unsigned int u_int;
  type wifi_frametype (line 69) | typedef enum {
  type ieee802_11_hdr (line 82) | typedef struct ieee802_11_hdr {
  type ieee_802_11_mgt_frame (line 100) | typedef struct {
  type prism_hdr (line 109) | typedef struct prism_hdr {
  type prism_did (line 115) | typedef struct prism_did {
  type prism_did_num (line 123) | typedef enum prism_did_num {
  type pcap_pkthdr (line 136) | struct pcap_pkthdr

FILE: WTPBinding.c
  function CWTranslateQueueIndex (line 46) | int CWTranslateQueueIndex(int j)
  function CWBool (line 59) | CWBool CWWTPInitBinding(int radioIndex)
  function CWBool (line 87) | CWBool CWWTPInitBinding(int radioIndex)
  function CWBool (line 144) | CWBool CWWTPInitBinding(int radioIndex)
  function CWBool (line 174) | CWBool CWBindingSetQosValues(int qosCount, RadioQosValues * radioQosValu...
  function CWBool (line 249) | CWBool CWBindingSetQosValues(int qosCount, RadioQosValues * radioQosValu...
  function CWBool (line 326) | CWBool CWBindingSetQosValues(int qosCount, RadioQosValues * radioQosValu...
  function CWBool (line 392) | CWBool CWManageOFDMValues(CWBindingConfigurationUpdateRequestValuesOFDM ...
  function CWBool (line 440) | CWBool CWParseWTPOFDM(CWProtocolMessage * msgPtr, int len, unsigned char...
  function CWBool (line 454) | CWBool CWParseWTPQoS(CWProtocolMessage * msgPtr, int len, unsigned char ...
  function CWBool (line 476) | CWBool CWBindingSaveConfigurationUpdateRequest(void *bindingValuesPtr, C...
  function CWBool (line 521) | CWBool CWBindingParseConfigurationUpdateRequest(unsigned char *msg, int ...
  function CWBool (line 655) | CWBool CWBindingSaveConfigureResponse(void *bindingValuesPtr, CWProtocol...
  function CWBool (line 674) | CWBool CWBindingParseConfigureResponse(unsigned char *msg, int len, void...

FILE: WTPBinding.h
  type RadioQosValues (line 32) | typedef struct {
  type CWBindingConfigurationRequestValues (line 37) | typedef struct {
  type CWBindingConfigurationUpdateRequestValues (line 42) | typedef struct {
  type CWBindingConfigurationUpdateRequestValuesOFDM (line 53) | typedef struct {

FILE: WTPConfigFile.c
  function CWBool (line 36) | CWBool CWConfigFileInitLib()
  function CWBool (line 86) | CWBool CWConfigFileDestroyLib()

FILE: WTPConfigureState.c
  function CWStateTransition (line 48) | CWStateTransition CWWTPEnterConfigure()
  function CWBool (line 90) | CWBool CWAssembleConfigureRequest(CWProtocolMessage ** messagesPtr,
  function CWBool (line 138) | CWBool CWParseConfigureResponseMessage(unsigned char *msg, int len, int ...
  function CWBool (line 286) | CWBool CWSaveConfigureResponseMessage(CWProtocolConfigureResponseValues ...

FILE: WTPDataCheckState.c
  function CWStateTransition (line 41) | CWStateTransition CWWTPEnterDataCheck()
  function CWBool (line 75) | CWBool CWAssembleChangeStateEventRequest(CWProtocolMessage ** messagesPtr,
  function CWBool (line 121) | CWBool CWParseChangeStateEventResponseMessage(unsigned char *msg, int le...
  function CWBool (line 156) | CWBool CWSaveChangeStateEventResponseMessage(void *changeStateEventResp)

FILE: WTPDiscoveryState.c
  function CWStateTransition (line 68) | CWStateTransition CWWTPEnterDiscovery()
  function CWBool (line 180) | CWBool CWReadResponses()
  function CWBool (line 238) | CWBool CWReceiveDiscoveryResponse()
  function CWWTPEvaluateAC (line 287) | void CWWTPEvaluateAC(CWACInfoValues * ACInfoPtr)
  function CWWTPPickACInterface (line 319) | void CWWTPPickACInterface()
  function CWBool (line 397) | CWBool CWAssembleDiscoveryRequest(CWProtocolMessage ** messagesPtr, int ...
  function CWBool (line 442) | CWBool CWParseDiscoveryResponseMessage(unsigned char *msg, int len, int ...

FILE: WTPDriverInteraction.c
  function set_freq (line 45) | int set_freq(int sock, struct iwreq wrq, int value)
  function get_freq (line 60) | int get_freq(int sock, struct iwreq *wrq)
  function set_bitrate (line 73) | int set_bitrate(int sock, struct iwreq wrq, int value)
  function get_bitrate (line 88) | int get_bitrate(int sock, struct iwreq *wrq)
  function set_rts_cts (line 101) | int set_rts_cts(int sock, struct iwreq wrq, int value)
  function get_rts_cts (line 119) | int get_rts_cts(int sock, struct iwreq *wrq)
  function set_frag (line 136) | int set_frag(int sock, struct iwreq wrq, int value)
  function get_frag (line 154) | int get_frag(int sock, struct iwreq *wrq)
  function set_txpower (line 171) | int set_txpower(int sock, struct iwreq wrq, int value)
  function get_txpower (line 186) | int get_txpower(int sock, struct iwreq *wrq)
  function set_cwmin (line 204) | int set_cwmin(int sock, struct iwreq wrq, int acclass, int sta, int value)
  function get_cwmin (line 224) | int get_cwmin(int sock, struct iwreq *wrq, int acclass, int sta)
  function set_cwmax (line 243) | int set_cwmax(int sock, struct iwreq wrq, int acclass, int sta, int value)
  function get_cwmax (line 263) | int get_cwmax(int sock, struct iwreq *wrq, int acclass, int sta)
  function set_aifs (line 282) | int set_aifs(int sock, struct iwreq wrq, int acclass, int sta, int value)
  function get_aifs (line 302) | int get_aifs(int sock, struct iwreq *wrq, int acclass, int sta)

FILE: WTPFrameReceive.c
  function getMacAddr (line 38) | int getMacAddr(int sock, char *interface, unsigned char *macAddr)
  function extractFrameInfo (line 58) | int extractFrameInfo(char *buffer, char *RSSI, char *SNR, int *dataRate)
  function extractFrame (line 72) | int extractFrame(CWProtocolMessage ** frame, unsigned char *buffer, int ...
  function extract802_3_Frame (line 85) | int extract802_3_Frame(CWProtocolMessage ** frame, unsigned char *buffer...
  function extractAddr (line 97) | int extractAddr(unsigned char *destAddr, unsigned char *sourceAddr, char...
  function macAddrCmp (line 107) | int macAddrCmp(unsigned char *addr1, unsigned char *addr2)
  function CW_THREAD_RETURN_TYPE (line 142) | CW_THREAD_RETURN_TYPE CWWTPReceiveFrame(void *arg)

FILE: WTPFreqStatsReceive.c
  function CW_THREAD_RETURN_TYPE (line 27) | CW_THREAD_RETURN_TYPE CWWTPReceiveFreqStats(void *arg)

FILE: WTPFreqStatsReceive.h
  type uint8 (line 42) | typedef unsigned char uint8;
  type quality (line 48) | typedef struct _quality {
  type FreqQualityInfo (line 53) | typedef struct _FreqQualityInfo {
  type FREQ_MONITOR_DATA (line 65) | typedef struct _FREQ_MONITOR_DATA {

FILE: WTPJoinState.c
  function CWStateTransition (line 54) | CWStateTransition CWWTPEnterJoin()
  function CWWTPWaitJoinExpired (line 216) | void CWWTPWaitJoinExpired(CWTimerArg arg)
  function CWBool (line 224) | CWBool CWAssembleJoinRequest(CWProtocolMessage ** messagesPtr,
  function CWBool (line 275) | CWBool CWParseJoinResponseMessage(unsigned char *msg, int len, int seqNu...
  function CWBool (line 433) | CWBool CWSaveJoinResponseMessage(CWProtocolJoinResponseValues * joinResp...

FILE: WTPProtocol.c
  function CWBool (line 37) | CWBool CWAssembleMsgElemACName(CWProtocolMessage * msgPtr)
  function CWBool (line 55) | CWBool CWAssembleMsgElemACNameWithIndex(CWProtocolMessage * msgPtr)
  function CWBool (line 120) | CWBool CWAssembleMsgElemDataTransferData(CWProtocolMessage * msgPtr, int...
  function CWBool (line 137) | CWBool CWAssembleMsgElemDiscoveryType(CWProtocolMessage * msgPtr)
  function CWBool (line 153) | CWBool CWAssembleMsgElemLocationData(CWProtocolMessage * msgPtr)
  function CWBool (line 173) | CWBool CWAssembleMsgElemStatisticsTimer(CWProtocolMessage * msgPtr)
  function CWBool (line 187) | CWBool CWAssembleMsgElemWTPBoardData(CWProtocolMessage * msgPtr)
  function CWBool (line 232) | CWBool CWAssembleMsgElemVendorSpecificPayload(CWProtocolMessage * msgPtr)
  function CWBool (line 265) | CWBool CWAssembleMsgElemWTPDescriptor(CWProtocolMessage * msgPtr)
  function CWBool (line 334) | CWBool CWAssembleMsgElemWTPFrameTunnelMode(CWProtocolMessage * msgPtr)
  function CWBool (line 349) | CWBool CWAssembleMsgElemWTPIPv4Address(CWProtocolMessage * msgPtr)
  function CWBool (line 364) | CWBool CWAssembleMsgElemWTPMACType(CWProtocolMessage * msgPtr)
  function CWBool (line 380) | CWBool CWAssembleMsgElemWTPRadioInformation(CWProtocolMessage * msgPtr)
  function CWBool (line 402) | CWBool CWAssembleMsgElemSupportedRates(CWProtocolMessage * msgPtr)
  function CWBool (line 430) | CWBool CWAssembleMsgElemMultiDomainCapability(CWProtocolMessage * msgPtr)
  function CWBool (line 457) | CWBool CWAssembleMsgElemWTPName(CWProtocolMessage * msgPtr)
  function CWBool (line 476) | CWBool CWAssembleMsgElemWTPOperationalStatistics(CWProtocolMessage * msg...
  function CWBool (line 502) | CWBool CWAssembleMsgElemWTPRadioStatistics(CWProtocolMessage * msgPtr, i...
  function CWBool (line 540) | CWBool CWAssembleMsgElemWTPRebootStatistics(CWProtocolMessage * msgPtr)
  function CWBool (line 568) | CWBool CWAssembleMsgElemDuplicateIPv4Address(CWProtocolMessage * msgPtr)
  function CWBool (line 607) | CWBool CWAssembleMsgElemDuplicateIPv6Address(CWProtocolMessage * msgPtr)
  function CWBool (line 647) | CWBool CWAssembleMsgElemRadioAdminState(CWProtocolMessage * msgPtr)
  function CWBool (line 703) | CWBool CWAssembleMsgElemRadioOperationalState(int radioID, CWProtocolMes...
  function CWBool (line 758) | CWBool CWAssembleMsgElemDecryptErrorReport(CWProtocolMessage * msgPtr, i...
  function CWBool (line 892) | CWBool CWParseWTPRadioInformation_FromAC(CWProtocolMessage * msgPtr, int...
  function CWBool (line 906) | CWBool CWParseACDescriptor(CWProtocolMessage * msgPtr, int len, CWACInfo...
  function CWBool (line 992) | CWBool CWParseACIPv4List(CWProtocolMessage * msgPtr, int len, ACIPv4List...
  function CWBool (line 1020) | CWBool CWParseACIPv6List(CWProtocolMessage * msgPtr, int len, ACIPv6List...
  function CWBool (line 1055) | CWBool CWParseDeleteStation(CWProtocolMessage * msgPtr, int len)
  function CWBool (line 1095) | CWBool CWParseDeleteWLAN(CWProtocolMessage * msgPtr, int len)
  function CWBool (line 1115) | CWBool CWParseAddWLAN(CWProtocolMessage * msgPtr, int len)
  function CWBool (line 1190) | CWBool CWParseAddStation(CWProtocolMessage * msgPtr, int len)
  function CWBool (line 1230) | CWBool CWParseCWControlIPv4Addresses(CWProtocolMessage * msgPtr, int len...
  function CWBool (line 1247) | CWBool CWParseCWControlIPv6Addresses(CWProtocolMessage * msgPtr, int len...
  function CWBool (line 1264) | CWBool CWParseCWTimers(CWProtocolMessage * msgPtr, int len, CWProtocolCo...
  function CWBool (line 1276) | CWBool CWParseDecryptErrorReportPeriod(CWProtocolMessage * msgPtr, int l...
  function CWBool (line 1287) | CWBool CWParseIdleTimeout(CWProtocolMessage * msgPtr, int len, CWProtoco...
  function CWBool (line 1297) | CWBool CWParseWTPFallback(CWProtocolMessage * msgPtr, int len, CWProtoco...
  function CWWTPResetRebootStatistics (line 1307) | void CWWTPResetRebootStatistics(WTPRebootStatisticsInfo * rebootStatistics)

FILE: WTPProtocol.h
  type ACIPv4ListValues (line 33) | typedef struct {
  type ACIPv6ListValues (line 38) | typedef struct {
  type CWACInfoValues (line 43) | typedef struct {
  type CWProtocolJoinResponseValues (line 64) | typedef struct {
  type CWProtocolConfigureResponseValues (line 71) | typedef struct {
  type CWProtocolConfigurationUpdateRequestValues (line 84) | typedef struct {

FILE: WTPProtocol_User.c
  function CWWTPGetDiscoveryType (line 36) | __inline__ int CWWTPGetDiscoveryType()
  function CWWTPGetMaxRadios (line 41) | __inline__ int CWWTPGetMaxRadios()
  function CWWTPGetRadiosInUse (line 46) | __inline__ int CWWTPGetRadiosInUse()
  function CWBool (line 58) | CWBool CWWTPGetEncCapabilities(CWWTPEncryptCaps * encc)
  function CWWTPDestroyEncCapabilities (line 73) | void CWWTPDestroyEncCapabilities(CWWTPEncryptCaps * encc)
  function CWBool (line 81) | CWBool CWWTPGetBoardData(CWWTPVendorInfos * valPtr)
  function CWBool (line 112) | CWBool CWWTPGetVendorInfos(CWWTPVendorInfos * valPtr)
  function CWWTPDestroyVendorInfos (line 152) | __inline__ void CWWTPDestroyVendorInfos(CWWTPVendorInfos * valPtr)
  function CWWTPGetFrameTunnelMode (line 166) | __inline__ int CWWTPGetFrameTunnelMode()
  function CWWTPGetMACType (line 178) | __inline__ int CWWTPGetMACType()
  function CWWTPGetSessionID (line 194) | __inline__ int CWWTPGetSessionID()
  function CWWTPGetIPv4Address (line 199) | __inline__ int CWWTPGetIPv4Address()
  function CWWTPGetIPv6Address (line 212) | __inline__ void CWWTPGetIPv6Address(struct sockaddr_in6 *myAddr)
  function CWWTPGetIPv4StatusDuplicate (line 221) | __inline__ int CWWTPGetIPv4StatusDuplicate()
  function CWWTPGetIPv6StatusDuplicate (line 226) | __inline__ int CWWTPGetIPv6StatusDuplicate()
  function CWBool (line 254) | CWBool CWGetWTPRadiosAdminState(CWRadiosAdminInfo * valPtr)
  function CWBool (line 276) | CWBool CWGetWTPRadiosOperationalState(int radioID, CWRadiosOperationalIn...
  function CWBool (line 316) | CWBool CWGetDecryptErrorReport(int radioID, CWDecryptErrorReportInfo * v...
  function CWWTPGetACIndex (line 395) | int CWWTPGetACIndex()
  function CWWTPGetStatisticsTimer (line 405) | int CWWTPGetStatisticsTimer()
  function CWBool (line 410) | CWBool CWWTPGetACNameWithIndex(CWACNamesWithIndex * ACsInfo)
  function getInterfaceMacAddr (line 434) | int getInterfaceMacAddr(char *interface, unsigned char *macAddr)
  function initWTPSessionID (line 458) | int initWTPSessionID(unsigned char *sessionID)

FILE: WTPRetransmission.c
  function CWResetPendingMsgBox (line 34) | void CWResetPendingMsgBox(CWPendingRequestMessage * pendingRequestMsgs)
  function CWFindFreePendingMsgBox (line 58) | int CWFindFreePendingMsgBox(CWPendingRequestMessage * pendingRequestMsgs...
  function CWBool (line 71) | CWBool CWUpdatePendingMsgBox(CWPendingRequestMessage * pendingRequestMsgs,
  function CWFindPendingRequestMsgsBox (line 100) | int CWFindPendingRequestMsgsBox(CWPendingRequestMessage * pendingRequest...
  function CWSendPendingRequestMessage (line 120) | int CWSendPendingRequestMessage(CWPendingRequestMessage * pendingRequest...

FILE: WTPRunState.c
  function CW_THREAD_RETURN_TYPE (line 101) | CW_THREAD_RETURN_TYPE CWWTPReceiveDtlsPacket(void *arg)
  function isEAPOL_Frame (line 141) | int isEAPOL_Frame(unsigned char *buf, unsigned int len)
  function CW_THREAD_RETURN_TYPE (line 152) | CW_THREAD_RETURN_TYPE CWWTPReceiveDataPacket(void *arg)
  function CWStateTransition (line 324) | CWStateTransition CWWTPEnterRun()
  function CWBool (line 431) | CWBool CWWTPManageGenericRunMessage(CWProtocolMessage * msgPtr)
  function CWWTPKeepAliveDataTimerExpiredHandler (line 758) | void CWWTPKeepAliveDataTimerExpiredHandler(void *arg)
  function CWWTPNeighborDeadTimerExpired (line 801) | void CWWTPNeighborDeadTimerExpired(void *arg)
  function CWBool (line 813) | CWBool CWStartHeartbeatTimer()
  function CWBool (line 831) | CWBool CWStopHeartbeatTimer()
  function CWBool (line 841) | CWBool CWStartNeighborDeadTimer()
  function CWBool (line 854) | CWBool CWStopNeighborDeadTimer()
  function CWBool (line 863) | CWBool CWResetTimers()
  function CWBool (line 883) | CWBool CWAssembleEchoRequest(CWProtocolMessage ** messagesPtr,
  function CWBool (line 911) | CWBool CWAssembleWTPDataTransferRequest(CWProtocolMessage ** messagesPtr...
  function CWBool (line 980) | CWBool CWAssembleWTPEventRequest(CWProtocolMessage ** messagesPtr,
  function CWBool (line 1075) | CWBool CWAssembleConfigurationUpdateResponse(CWProtocolMessage ** messag...
  function CWBool (line 1140) | CWBool CWAssembleClearConfigurationResponse(CWProtocolMessage ** message...
  function CWBool (line 1174) | CWBool CWAssembleStationConfigurationResponse(CWProtocolMessage ** messa...
  function CWBool (line 1209) | CWBool CWAssembleWLANConfigurationResponse(CWProtocolMessage ** messages...
  function CWBool (line 1256) | CWBool CWParseVendorMessage(unsigned char *msg, int len, void **valuesPtr)
  function CWBool (line 1342) | CWBool CWParseConfigurationUpdateRequest(unsigned char *msg,
  function CWBool (line 1427) | CWBool CWParseWLANConfigurationRequest(unsigned char *msg, int len)
  function CWBool (line 1474) | CWBool CWParseStationConfigurationRequest(unsigned char *msg, int len)
  function CWBool (line 1538) | CWBool CWParseWTPEventResponseMessage(unsigned char *msg, int len, int s...
  function CWBool (line 1576) | CWBool CWSaveWTPEventResponseMessage(void *WTPEventResp)
  function CWBool (line 1586) | CWBool CWSaveVendorMessage(void *protocolValuesPtr, CWProtocolResultCode...
  function CWBool (line 1618) | CWBool CWSaveConfigurationUpdateRequest(CWProtocolConfigurationUpdateReq...
  function CWBool (line 1643) | CWBool CWSaveClearConfigurationRequest(CWProtocolResultCode * resultCode)

FILE: WTPRunStateCheck.c
  function CWBool (line 37) | CWBool CWWTPCheckForBindingFrame()
  function CWBool (line 92) | CWBool CWWTPCheckForWTPEventRequest()
  function CWWTPRetransmitTimerExpiredHandler (line 193) | void CWWTPRetransmitTimerExpiredHandler(CWTimerArg hdl_arg)

FILE: WTPSettingsFile.c
  function CWExtractValue (line 46) | void CWExtractValue(char *start, char **startValue, char **endValue, int...
  function CWBool (line 55) | CWBool CWParseSettingsFile()

FILE: WTPStatsReceive.c
  function create_data_Frame (line 27) | int create_data_Frame(CWProtocolMessage ** frame, char *buffer, int len)
  function CW_THREAD_RETURN_TYPE (line 40) | CW_THREAD_RETURN_TYPE CWWTPReceiveStats(void *arg)

FILE: WTPStatsReceive.h
  type ath_stats_wme_clone (line 78) | struct ath_stats_wme_clone {
  type ath_stats_clone (line 100) | struct ath_stats_clone {
  type MM_MONITOR_DATA (line 164) | typedef struct _MM_MONITOR_DATA {

FILE: WTPSulkingState.c
  function CWStateTransition (line 43) | CWStateTransition CWWTPEnterSulking()

FILE: WTPipcHostapd.c
  type sockaddr_un (line 44) | struct sockaddr_un
  type sockaddr_in6 (line 47) | struct sockaddr_in6
  type sockaddr_in (line 49) | struct sockaddr_in
  function flush_pcap (line 66) | int flush_pcap(u_char * buf, int len, char *filename)
  function CWWTP_get_WTP_Rates (line 96) | void CWWTP_get_WTP_Rates(unsigned char *buf)
  function CWWTP_get_WTP_MDC (line 105) | void CWWTP_get_WTP_MDC(unsigned char *buf)
  function CWTP_get_WTP_Radio_Information (line 114) | unsigned char CWTP_get_WTP_Radio_Information()
  function CWWTPsend_data_to_hostapd (line 125) | void CWWTPsend_data_to_hostapd(unsigned char *buf, int len)
  function CWWTPsend_command_to_hostapd_SET_TXQ (line 142) | void CWWTPsend_command_to_hostapd_SET_TXQ(unsigned char *buf, int len)
  function CWWTPsend_command_to_hostapd_SET_ADDR (line 156) | void CWWTPsend_command_to_hostapd_SET_ADDR(unsigned char *buf, int len)
  function CWWTPsend_command_to_hostapd_ADD_WLAN (line 170) | void CWWTPsend_command_to_hostapd_ADD_WLAN(unsigned char *buf, int len)
  function CWWTPsend_command_to_hostapd_DEL_WLAN (line 187) | void CWWTPsend_command_to_hostapd_DEL_WLAN(unsigned char *buf, int len)
  function CWWTPsend_command_to_hostapd_DEL_ADDR (line 205) | void CWWTPsend_command_to_hostapd_DEL_ADDR(unsigned char *buf, int len)
  function CWWTPsend_command_to_hostapd_CLOSE (line 219) | void CWWTPsend_command_to_hostapd_CLOSE(unsigned char *buf, int len)
  function CW_THREAD_RETURN_TYPE (line 231) | CW_THREAD_RETURN_TYPE CWWTPThread_read_data_from_hostapd(void *arg)

FILE: WTPmacDriverInteraction.c
  function set_rts_threshold (line 39) | int set_rts_threshold(int value)
  function get_rts_threshold (line 46) | int get_rts_threshold(int *value)
  function set_frag_threshold (line 54) | int set_frag_threshold(int value)
  function get_frag_threshold (line 61) | int get_frag_threshold(int *value)
  function set_txq (line 68) | int set_txq(int code, int cwmin, int cwmax, int aifs, int burst_time)
  function set_wme_cwmin (line 78) | int set_wme_cwmin(int class, int value)
  function set_wme_cwmax (line 86) | int set_wme_cwmax(int class, int value)
  function set_wme_aifsn (line 94) | int set_wme_aifsn(int class, int value)

FILE: WTPmacDriverInteraction.h
  type uchar (line 363) | typedef unsigned char uchar;
  type ushort (line 367) | typedef unsigned short ushort;
  type uint (line 371) | typedef unsigned int uint;
  type ulong (line 375) | typedef unsigned long ulong;
  type uint8 (line 381) | typedef unsigned char uint8;
  type uint16 (line 385) | typedef unsigned short uint16;
  type uint32 (line 389) | typedef unsigned int uint32;
  type uint64 (line 393) | typedef unsigned long long uint64;
  type uintptr (line 397) | typedef unsigned int uintptr;
  type int8 (line 401) | typedef signed char int8;
  type int16 (line 405) | typedef signed short int16;
  type int32 (line 409) | typedef signed int int32;
  type int64 (line 413) | typedef signed long long int64;
  type float32 (line 419) | typedef float float32;
  type float64 (line 423) | typedef double float64;
  type float32 (line 435) | typedef float32 float_t;
  type float64 (line 437) | typedef float64 float_t;
  type edcf_acparam (line 515) | struct edcf_acparam {
  type edcf_acparam_t (line 520) | typedef struct edcf_acparam edcf_acparam_t;
  type wl_ioctl_t (line 523) | typedef struct wl_ioctl {
  function wl_iovar_setint (line 559) | static inline int wl_iovar_setint(char *ifname, char *iovar, int val)
  function wl_iovar_getint (line 568) | static inline int wl_iovar_getint(char *ifname, char *iovar, int *val)

FILE: WTPmacFrameReceive.c
  function getMacAddr (line 45) | int getMacAddr(int sock, char *interface, unsigned char *macAddr)
  function extractFrameInfo (line 59) | int extractFrameInfo(char *buffer, char *RSSI, char *SNR, int *dataRate)
  function extractFrame (line 73) | int extractFrame(CWProtocolMessage ** frame, unsigned char *buffer, int ...
  function extract802_11_Frame (line 86) | int extract802_11_Frame(CWProtocolMessage ** frame, unsigned char *buffe...
  function extractAddr (line 98) | int extractAddr(unsigned char *destAddr, unsigned char *sourceAddr, char...
  function macAddrCmp (line 108) | int macAddrCmp(unsigned char *addr1, unsigned char *addr2)
  function from_8023_to_80211 (line 127) | int from_8023_to_80211(unsigned char *inbuffer, int inlen, unsigned char...
  function CWWTPSendFrame (line 153) | int CWWTPSendFrame(unsigned char *buf, int len)
  function CW_THREAD_RETURN_TYPE (line 166) | CW_THREAD_RETURN_TYPE CWWTPReceiveFrame(void *arg)

FILE: WUA.c
  type CWUpdateDescriptor (line 55) | struct CWUpdateDescriptor {
  type CWUpdateDescriptor (line 62) | struct CWUpdateDescriptor
  function main (line 91) | int main(int argc, char *argv[])
  function WTPUpdateAgent (line 119) | void WTPUpdateAgent(char *CupPath)
  function WaitForWTPTermination (line 166) | void WaitForWTPTermination()
  function CWBool (line 196) | CWBool WUAStage1(char *CupPath, char *WTPDir)
  function CWBool (line 243) | CWBool WUAStage2(char *WTPDir)
  function CWBool (line 289) | CWBool Unzip(char *filename, char *destdir)
  function CWBool (line 309) | CWBool StartWTP(char *WTPDir)
  function CWBool (line 332) | CWBool RestoreBackupWTP(char *WTPDir)
  function StringToLower (line 357) | void StringToLower(char *str)
  function CWBool (line 363) | CWBool ParseCUD()
  function CleanTmpFiles (line 421) | void CleanTmpFiles(char *cupFile)
  function CWBool (line 440) | CWBool BackupCurrentWTP(char *WTPDir)
  function CWBool (line 456) | CWBool MakeDir(char *dirname)
  function CWBool (line 473) | CWBool WUAInitLog(char *logFile)
  function WUALog (line 481) | void WUALog(char *msg, ...)
  function WUALogClose (line 502) | void WUALogClose()
  function daemonize (line 508) | void daemonize()

FILE: common.h
  function bswap_16 (line 50) | static inline unsigned short bswap_16(unsigned short v)
  function bswap_32 (line 55) | static inline unsigned int bswap_32(unsigned int v)
  type socklen_t (line 80) | typedef int socklen_t;
  type UINT64 (line 100) | typedef UINT64 u64;
  type UINT32 (line 101) | typedef UINT32 u32;
  type UINT16 (line 102) | typedef UINT16 u16;
  type UINT8 (line 103) | typedef UINT8 u8;
  type INT64 (line 104) | typedef INT64 s64;
  type INT32 (line 105) | typedef INT32 s32;
  type INT16 (line 106) | typedef INT16 s16;
  type INT8 (line 107) | typedef INT8 s8;
  type u64 (line 112) | typedef unsigned long long u64;
  type UINT32 (line 113) | typedef UINT32 u32;
  type UINT16 (line 114) | typedef UINT16 u16;
  type UINT8 (line 115) | typedef UINT8 u8;
  type s64 (line 116) | typedef long long s64;
  type INT32 (line 117) | typedef INT32 s32;
  type INT16 (line 118) | typedef INT16 s16;
  type INT8 (line 119) | typedef INT8 s8;
  type u64 (line 125) | typedef unsigned long long u64;
  type u64 (line 131) | typedef unsigned long u64;
  type u32 (line 133) | typedef unsigned int u32;
  type u16 (line 134) | typedef unsigned short u16;
  type u8 (line 135) | typedef unsigned char u8;
  type TUint64 (line 142) | typedef TUint64 u64;
  type TUint32 (line 143) | typedef TUint32 u32;
  type TUint16 (line 144) | typedef TUint16 u16;
  type TUint8 (line 145) | typedef TUint8 u8;
  type u64 (line 155) | typedef uint64_t u64;
  type u32 (line 156) | typedef uint32_t u32;
  type u16 (line 157) | typedef uint16_t u16;
  type u8 (line 158) | typedef uint8_t u8;
  type s64 (line 159) | typedef int64_t s64;
  type s32 (line 160) | typedef int32_t s32;
  type s16 (line 161) | typedef int16_t s16;
  type s8 (line 162) | typedef int8_t s8;
  function wpa_swap_16 (line 170) | static inline unsigned short wpa_swap_16(unsigned short v)
  function wpa_swap_32 (line 175) | static inline unsigned int wpa_swap_32(unsigned int v)
  type socklen_t (line 360) | typedef int socklen_t;
  type u16 (line 423) | typedef u16 __bitwise be16;
  type u16 (line 424) | typedef u16 __bitwise le16;
  type u32 (line 425) | typedef u32 __bitwise be32;
  type u32 (line 426) | typedef u32 __bitwise le32;
  type u64 (line 427) | typedef u64 __bitwise be64;
  type u64 (line 428) | typedef u64 __bitwise le64;
  function is_zero_ether_addr (line 458) | static inline int is_zero_ether_addr(const u8 * a)
  function is_broadcast_ether_addr (line 463) | static inline int is_broadcast_ether_addr(const u8 * a)

FILE: hostapd_wrapper/src/capwap/capwap_mgmt_frame_ac.c
  function same_mac (line 16) | int same_mac( unsigned char *mac1, unsigned char *mac2){// return 0
  function GetEapol_Frame (line 22) | int GetEapol_Frame( unsigned char *sa,  unsigned char *buf, int len){
  function isEAPOL_Frame (line 29) | int isEAPOL_Frame( unsigned char *buf, int len){
  function stampa_mac (line 37) | void stampa_mac(char *s,  unsigned char *mac){
  function stamp_all_max (line 44) | void stamp_all_max( unsigned char *buf,  unsigned char *own_mac){
  function isCallBackFrame (line 55) | int isCallBackFrame( unsigned char *buf, int len,  unsigned char *own_mac){
  function AC_get_SubType (line 72) | int AC_get_SubType( unsigned char *buf, int len){
  function AC_get_Type (line 82) | int AC_get_Type( unsigned char *buf, int len){

FILE: hostapd_wrapper/src/capwap/capwap_mgmt_frame_wtp.c
  function WTP_handle_assoc_cb (line 28) | void WTP_handle_assoc_cb(struct hostapd_data *hapd,const struct ieee8021...
  type hostapd_data (line 66) | struct hostapd_data
  type hostapd_iface (line 66) | struct hostapd_iface
  function WTP_handle_tx_callback_ASS_RES (line 81) | void WTP_handle_tx_callback_ASS_RES(void *ctx,  unsigned char *buf, size...
  function isEAPOL_Frame (line 113) | int isEAPOL_Frame( unsigned char *buf, int len){
  function WTP_get_SubType (line 121) | int WTP_get_SubType( unsigned char *buf,int len){
  function WTP_get_Type (line 131) | int WTP_get_Type( unsigned char*buf,int len){

FILE: hostapd_wrapper/src/capwap/capwap_mgmt_frame_wtp.h
  type hostapd_data (line 7) | struct hostapd_data
  type ieee80211_mgmt (line 7) | struct ieee80211_mgmt
  type hostapd_data (line 9) | struct hostapd_data
  type hostapd_data (line 11) | struct hostapd_data
  type hostapd_iface (line 11) | struct hostapd_iface
  type hostapd_data (line 13) | struct hostapd_data
  type wpa_event_type (line 15) | enum wpa_event_type

FILE: hostapd_wrapper/src/capwap/file_conf_ac.h
  type config_ac (line 4) | struct config_ac {
  function max_ (line 10) | int max_(int integer1,int integer2){
  function countString (line 15) | int countString(char string[]){
  function isEqualString (line 21) | int isEqualString(char String1[],char String2[]){
  function StartWith (line 33) | int StartWith(char String1[],char String2[]){
  function ReplaceString (line 45) | void ReplaceString(char *String1,char *rep,char *String2){
  function ReadConfiguration (line 78) | void ReadConfiguration(struct config_ac *con_ac){

FILE: hostapd_wrapper/src/capwap/file_conf_wtp.h
  type config_wtp (line 4) | struct config_wtp {
  function max_ (line 10) | int max_(int integer1,int integer2){
  function countString (line 15) | int countString(char string[]){
  function isEqualString (line 21) | int isEqualString(char String1[],char String2[]){
  function StartWith (line 33) | int StartWith(char String1[],char String2[]){
  function ReplaceString (line 45) | void ReplaceString(char *String1,char *rep,char *String2){
  function ReadConfiguration (line 78) | void ReadConfiguration(struct config_wtp *con_wtp){

FILE: hostapd_wrapper/src/capwap/ipc_capwap_ac.c
  type config_ac (line 32) | struct config_ac
  type sockaddr_un (line 40) | struct sockaddr_un
  type sockaddr_un (line 41) | struct sockaddr_un
  type sockaddr_in6 (line 46) | struct sockaddr_in6
  type sockaddr_in6 (line 47) | struct sockaddr_in6
  type sockaddr_in (line 49) | struct sockaddr_in
  type sockaddr_in (line 50) | struct sockaddr_in
  function capability_is_A (line 60) | int capability_is_A(){
  function capability_is_B (line 64) | int capability_is_B(){
  function capability_is_G (line 68) | int capability_is_G(){
  function capability_is_N (line 72) | int capability_is_N(){
  function capability_get_num_modes (line 77) | int capability_get_num_modes(){
  function capability_get_first_channel (line 88) | int capability_get_first_channel(){
  function capability_get_num_channels (line 92) | int capability_get_num_channels(){
  function capability_get_max_dBm (line 96) | int capability_get_max_dBm(){
  function capability_get_rates (line 100) | int capability_get_rates(int *rate_arr){
  function capability_get_mac (line 117) | void capability_get_mac(unsigned char *buf) {
  function prep_beacon (line 121) | void prep_beacon(int fd,struct hostapd_data *hapd,struct wpa_driver_ap_p...
  function ipc_send_ADD_WLAN (line 213) | void ipc_send_ADD_WLAN(int fd,char *ssid, int len){
  function ipc_send_DEL_WLAN (line 253) | void ipc_send_DEL_WLAN(int fd){
  function ipc_send_CLOSE_to_AC (line 262) | void ipc_send_CLOSE_to_AC(int fd){
  function ipc_send_add_station (line 267) | void ipc_send_add_station(int fd, u8 *buf, int len){
  function ipc_send_del_station (line 297) | void ipc_send_del_station(int fd, u8 *buf, int len){
  function ipc_send_80211_to_wtp (line 317) | void ipc_send_80211_to_wtp(int fd, u8 *buf, int len){
  function send_response (line 322) | void send_response(int fd, u8 code, u8 *buf, int len){
  function management_recv (line 346) | void management_recv(int fd, u8 code, u8 *buf, int len, void *hapd, void...
  function recv_request (line 366) | void recv_request(int fd,void *hapd, void *inject_func)
  function open_socket (line 387) | int open_socket()
  function wait_capability_from_AC (line 472) | void wait_capability_from_AC(int fd, void *hapd){
  function end_ipc (line 549) | int end_ipc(int fd){
  function start_ipc (line 569) | int start_ipc(void *hapd,void *inject_func){

FILE: hostapd_wrapper/src/capwap/ipc_capwap_ac.h
  type hostapd_data (line 15) | struct hostapd_data
  type wpa_driver_ap_params (line 15) | struct wpa_driver_ap_params

FILE: hostapd_wrapper/src/capwap/ipc_capwap_wtp.c
  type pre_txq (line 34) | struct pre_txq {
  type queue_qos (line 40) | struct queue_qos {
  type wlan_state (line 48) | struct wlan_state {
  type config_wtp (line 55) | struct config_wtp
  type pre_txq (line 57) | struct pre_txq
  type sockaddr_un (line 62) | struct sockaddr_un
  type sockaddr_un (line 63) | struct sockaddr_un
  type sockaddr_in6 (line 67) | struct sockaddr_in6
  type sockaddr_in (line 69) | struct sockaddr_in
  type wlan_state (line 76) | struct wlan_state
  type sockaddr_un (line 78) | struct sockaddr_un
  function ipc_send_CLOSE_to_WTP (line 84) | static void ipc_send_CLOSE_to_WTP(int fd)
  function ipc_send_80211_to_ac (line 91) | void ipc_send_80211_to_ac(int fd, u8 *buf, int len)
  function send_varesponse (line 96) | static void send_varesponse(int fd, u8 code, const char *fmt, ...)
  function send_response (line 109) | static void send_response(int fd, u8 code, u8 *buf, int len)
  function SET_RTS_handle (line 132) | static void SET_RTS_handle(int fd, u8 *buf, int len, void *hapd)
  function GET_RTS_handle (line 150) | static void GET_RTS_handle(int fd, u8 *buf, int len, void *hapd)
  function SET_FRAG_handle (line 157) | static void SET_FRAG_handle(int fd, u8 *buf, int len, void *hapd)
  function GET_FRAG_handle (line 172) | static void GET_FRAG_handle(int fd, u8 *buf, int len, void *hapd)
  function SET_FREQ_handle (line 177) | static void SET_FREQ_handle(int fd, u8 *buf, int len, void *hapd)
  function GET_FREQ_handle (line 207) | static void GET_FREQ_handle(int fd, u8 *buf, int len, void *hapd)
  function add_in_SET_TXQ_handle (line 216) | static void add_in_SET_TXQ_handle(u8 *buf, int len)
  function SET_TXQ_handle (line 230) | static void SET_TXQ_handle(int fd, u8 *buf, int len, void *hapd)
  function flush_SET_TXQ_handle (line 266) | void flush_SET_TXQ_handle(int fd, void *hapd)
  function SET_ADDR_handle (line 277) | static void SET_ADDR_handle(int fd, u8 *buf, int len, void *hapd)
  function DEL_ADDR_handle (line 289) | void DEL_ADDR_handle(int fd, u8 *buf, int len, void *hapd)
  function DEL_WLAN_handle (line 298) | static void DEL_WLAN_handle(int fd, u8 *buf, int len, void *hapd)
  function ADD_WLAN_handle (line 312) | static void ADD_WLAN_handle(int fd, u8 *buf, int len, void *hapd, unsign...
  function management_recv (line 383) | static void management_recv(int fd, u8 code, u8 *buf, int len, void *hap...
  function recv_request (line 441) | static void recv_request(int fd, void *hapd, void *inject_func)
  function open_socket (line 462) | static int open_socket()
  function end_ipc (line 546) | int end_ipc(int fd)
  function goto_preconnect (line 565) | static void goto_preconnect(int fd, void *hapd){
  function wait_ADD_WLAN (line 616) | static void wait_ADD_WLAN(int fd, unsigned char *ssid_p, int *ssid_len_p...
  function start_ipc (line 655) | int start_ipc(void *hapd, unsigned char *ssid_p, int *ssid_len_p, void *...

FILE: hostapd_wrapper/src/capwap/switch_8023_80211.c
  function add_8022_header (line 18) | int add_8022_header( unsigned char *inbuf, int inlen,  unsigned char *ou...
  function add_80211_Data_header (line 48) | int add_80211_Data_header( unsigned char *da,  unsigned char *sa,  unsig...
  function add_8023_header (line 95) | int add_8023_header( unsigned char *mac_src, unsigned char *mac_dst, uns...
  function from_8023_to_80211 (line 114) | int from_8023_to_80211( unsigned char *inbuffer,int inlen, unsigned char...
  function from_80211_to_8023 (line 140) | int from_80211_to_8023( unsigned char *inbuffer,int inlen, unsigned char...

FILE: hostapd_wrapper/src/drivers/driver_capwap.c
  type priv_params (line 62) | struct priv_params
  type ac_info (line 72) | struct ac_info {
  type ac_info (line 79) | struct ac_info
  type nl_handle (line 98) | struct nl_handle
  type nl_handle (line 99) | struct nl_handle
  function capwap_handle_destroy (line 118) | static void capwap_handle_destroy(struct nl_handle *handle)
  function __genl_ctrl_alloc_cache (line 128) | static inline int __genl_ctrl_alloc_cache(struct nl_handle *h,
  type capwap_handles (line 141) | struct capwap_handles {
  function nl_create_handles (line 147) | static int nl_create_handles(struct capwap_handles *handles, struct nl_c...
  function nl_destroy_handles (line 182) | static void nl_destroy_handles(struct capwap_handles *handles)
  type capwap_global (line 206) | struct capwap_global {
  type i802_bss (line 219) | struct i802_bss {
  type wpa_driver_capwap_data (line 230) | struct wpa_driver_capwap_data {
  type i802_bss (line 297) | struct i802_bss
  type nl80211_iftype (line 298) | enum nl80211_iftype
  type wpa_driver_capwap_data (line 300) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 301) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 305) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 306) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 313) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 314) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 315) | struct wpa_driver_capwap_data
  type wpa_driver_if_type (line 317) | enum wpa_driver_if_type
  function add_ifidx (line 320) | static inline void add_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function del_ifidx (line 324) | static inline void del_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function have_ifidx (line 328) | static inline int have_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  type hostapd_freq_params (line 334) | struct hostapd_freq_params
  type wpa_driver_capwap_data (line 335) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 338) | struct wpa_driver_capwap_data
  function is_ap_interface (line 341) | static int is_ap_interface(enum nl80211_iftype nlmode)
  function is_sta_interface (line 348) | static int is_sta_interface(enum nl80211_iftype nlmode)
  function is_p2p_interface (line 355) | static int is_p2p_interface(enum nl80211_iftype nlmode)
  type capwap_bss_info_arg (line 362) | struct capwap_bss_info_arg {
  type nl_msg (line 369) | struct nl_msg
  function ack_handler (line 373) | static int ack_handler(struct nl_msg *msg, void *arg)
  function finish_handler (line 380) | static int finish_handler(struct nl_msg *msg, void *arg)
  function error_handler (line 387) | static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
  function no_seq_check (line 396) | static int no_seq_check(struct nl_msg *msg, void *arg)
  function send_and_recv (line 402) | static int send_and_recv(struct wpa_driver_capwap_data *drv,
  function send_and_recv_msgs (line 440) | static int send_and_recv_msgs(struct wpa_driver_capwap_data *drv,
  type family_data (line 451) | struct family_data {
  function family_handler (line 457) | static int family_handler(struct nl_msg *msg, void *arg)
  function nl_get_multicast_id (line 488) | static int nl_get_multicast_id(struct wpa_driver_capwap_data *drv,
  type wpa_driver_capwap_data (line 516) | struct wpa_driver_capwap_data
  type nl_msg (line 517) | struct nl_msg
  function wpa_driver_capwap_get_bssid (line 525) | static int wpa_driver_capwap_get_bssid(void *priv, u8 *bssid)
  function wpa_driver_capwap_get_ssid (line 537) | static int wpa_driver_capwap_get_ssid(void *priv, u8 *ssid)
  function wpa_driver_capwap_event_link (line 549) | static void wpa_driver_capwap_event_link(struct wpa_driver_capwap_data *...
  function wpa_driver_capwap_own_ifname (line 596) | static int wpa_driver_capwap_own_ifname(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_own_ifindex (line 622) | static int wpa_driver_capwap_own_ifindex(struct wpa_driver_capwap_data *...
  type wpa_driver_capwap_data (line 641) | struct wpa_driver_capwap_data
  type capwap_global (line 642) | struct capwap_global
  type wpa_driver_capwap_data (line 644) | struct wpa_driver_capwap_data
  function wpa_driver_capwap_event_rtm_newlink (line 655) | static void wpa_driver_capwap_event_rtm_newlink(void *ctx,
  function wpa_driver_capwap_event_rtm_dellink (line 761) | static void wpa_driver_capwap_event_rtm_dellink(void *ctx,
  function mlme_event_auth (line 804) | static void mlme_event_auth(struct wpa_driver_capwap_data *drv,
  function capwap_get_assoc_freq (line 831) | static unsigned int capwap_get_assoc_freq(struct wpa_driver_capwap_data ...
  function mlme_event_assoc (line 863) | static void mlme_event_assoc(struct wpa_driver_capwap_data *drv,
  function mlme_event_connect (line 909) | static void mlme_event_connect(struct wpa_driver_capwap_data *drv,
  function mlme_event_disconnect (line 960) | static void mlme_event_disconnect(struct wpa_driver_capwap_data *drv,
  function mlme_timeout_event (line 983) | static void mlme_timeout_event(struct wpa_driver_capwap_data *drv,
  function mlme_event_mgmt (line 1008) | static void mlme_event_mgmt(struct wpa_driver_capwap_data *drv,
  function mlme_event_action_tx_status (line 1046) | static void mlme_event_action_tx_status(struct wpa_driver_capwap_data *drv,
  function mlme_event_deauth_disassoc (line 1081) | static void mlme_event_deauth_disassoc(struct wpa_driver_capwap_data *drv,
  function mlme_event_unprot_disconnect (line 1138) | static void mlme_event_unprot_disconnect(struct wpa_driver_capwap_data *...
  function mlme_event (line 1170) | static void mlme_event(struct wpa_driver_capwap_data *drv,
  function mlme_event_michael_mic_failure (line 1227) | static void mlme_event_michael_mic_failure(struct wpa_driver_capwap_data...
  function mlme_event_join_ibss (line 1263) | static void mlme_event_join_ibss(struct wpa_driver_capwap_data *drv,
  function mlme_event_remain_on_channel (line 1280) | static void mlme_event_remain_on_channel(struct wpa_driver_capwap_data *...
  function send_scan_event (line 1328) | static void send_scan_event(struct wpa_driver_capwap_data *drv, int abor...
  function get_link_signal (line 1369) | static int get_link_signal(struct nl_msg *msg, void *arg)
  function capwap_get_link_signal (line 1417) | static int capwap_get_link_signal(struct wpa_driver_capwap_data *drv,
  function get_link_noise (line 1442) | static int get_link_noise(struct nl_msg *msg, void *arg)
  function capwap_get_link_noise (line 1486) | static int capwap_get_link_noise(struct wpa_driver_capwap_data *drv,
  function get_noise_for_scan_results (line 1510) | static int get_noise_for_scan_results(struct nl_msg *msg, void *arg)
  function capwap_get_noise_for_scan_results (line 1563) | static int capwap_get_noise_for_scan_results(
  function capwap_cqm_event (line 1585) | static void capwap_cqm_event(struct wpa_driver_capwap_data *drv,
  function capwap_new_station_event (line 1652) | static void capwap_new_station_event(struct wpa_driver_capwap_data *drv,
  function capwap_del_station_event (line 1684) | static void capwap_del_station_event(struct wpa_driver_capwap_data *drv,
  function capwap_rekey_offload_event (line 1710) | static void capwap_rekey_offload_event(struct wpa_driver_capwap_data *drv,
  function capwap_pmksa_candidate_event (line 1752) | static void capwap_pmksa_candidate_event(struct wpa_driver_capwap_data *...
  function process_event (line 1786) | static int process_event(struct nl_msg *msg, void *arg)
  function wpa_driver_capwap_event_receive (line 1919) | static void wpa_driver_capwap_event_receive(int sock, void *eloop_ctx,
  function wpa_driver_capwap_set_country (line 1947) | static int wpa_driver_capwap_set_country(void *priv, const char *alpha2_...
  type wiphy_info_data (line 1976) | struct wiphy_info_data {
  function wiphy_info_handler (line 1983) | static int wiphy_info_handler(struct nl_msg *msg, void *arg)
  function wpa_driver_capwap_get_info (line 2170) | static int wpa_driver_capwap_get_info(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_capa (line 2178) | static int wpa_driver_capwap_capa(struct wpa_driver_capwap_data *drv)
  function android_genl_ctrl_resolve (line 2212) | static int android_genl_ctrl_resolve(struct nl_handle *handle,
  function wpa_driver_capwap_init_nl_global (line 2247) | static int wpa_driver_capwap_init_nl_global(struct capwap_global *global)
  function wpa_driver_capwap_init_nl (line 2271) | static int wpa_driver_capwap_init_nl(struct wpa_driver_capwap_data *drv)
  function wpa_driver_capwap_rfkill_blocked (line 2278) | static void wpa_driver_capwap_rfkill_blocked(void *ctx)
  function wpa_driver_capwap_rfkill_unblocked (line 2288) | static void wpa_driver_capwap_rfkill_unblocked(void *ctx)
  function capwap_get_phy_name (line 2302) | static void capwap_get_phy_name(struct wpa_driver_capwap_data *drv)
  function capwap_l2_read (line 2313) | static void capwap_l2_read(void *ctx, const u8 *src_addr, const u8 *buf,
  type wpa_driver_capwap_data (line 2334) | struct wpa_driver_capwap_data
  type rfkill_config (line 2335) | struct rfkill_config
  type i802_bss (line 2336) | struct i802_bss
  function capwap_register_frame (line 2393) | static int capwap_register_frame(struct wpa_driver_capwap_data *drv,
  function capwap_register_action_frame (line 2428) | static int capwap_register_action_frame(struct wpa_driver_capwap_data *drv,
  function capwap_register_action_frames (line 2437) | static int capwap_register_action_frames(struct wpa_driver_capwap_data *...
  function wpa_driver_capwap_send_rfkill (line 2445) | static void wpa_driver_capwap_send_rfkill(void *eloop_ctx, void *timeout...
  function wpa_driver_capwap_finish_drv_init (line 2451) | static int
  function wpa_driver_capwap_del_beacon (line 2527) | static int wpa_driver_capwap_del_beacon(struct wpa_driver_capwap_data *drv)
  function wpa_driver_capwap_deinit (line 2552) | static void wpa_driver_capwap_deinit(void *priv)
  function wpa_driver_capwap_scan_timeout (line 2572) | static void wpa_driver_capwap_scan_timeout(void *eloop_ctx, void *timeou...
  function wpa_driver_capwap_scan (line 2591) | static int wpa_driver_capwap_scan(void *priv,
  function wpa_driver_capwap_sched_scan (line 2725) | static int wpa_driver_capwap_sched_scan(void *priv,
  function wpa_driver_capwap_stop_sched_scan (line 2835) | static int wpa_driver_capwap_stop_sched_scan(void *priv)
  function u8 (line 2867) | static const u8 * capwap_get_ie(const u8 *ies, size_t ies_len, u8 ie)
  function capwap_scan_filtered (line 2889) | static int capwap_scan_filtered(struct wpa_driver_capwap_data *drv,
  function bss_info_handler (line 2913) | static int bss_info_handler(struct nl_msg *msg, void *arg)
  function clear_state_mismatch (line 3082) | static void clear_state_mismatch(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_check_bss_status (line 3095) | static void wpa_driver_capwap_check_bss_status(
  type wpa_scan_results (line 3146) | struct wpa_scan_results
  type wpa_driver_capwap_data (line 3147) | struct wpa_driver_capwap_data
  type nl_msg (line 3149) | struct nl_msg
  type wpa_scan_results (line 3150) | struct wpa_scan_results
  type capwap_bss_info_arg (line 3152) | struct capwap_bss_info_arg
  type wpa_scan_results (line 3188) | struct wpa_scan_results
  type i802_bss (line 3192) | struct i802_bss
  type wpa_driver_capwap_data (line 3193) | struct wpa_driver_capwap_data
  type wpa_scan_results (line 3194) | struct wpa_scan_results
  function capwap_dump_scan (line 3203) | static void capwap_dump_scan(struct wpa_driver_capwap_data *drv)
  function wpa_driver_capwap_set_key (line 3227) | static int wpa_driver_capwap_set_key(const char *ifname, void *priv,
  function nl_add_key (line 3384) | static int nl_add_key(struct nl_msg *msg, enum wpa_alg alg,
  function capwap_set_conn_keys (line 3438) | static int capwap_set_conn_keys(struct wpa_driver_associate_params *params,
  function wpa_driver_capwap_mlme (line 3498) | static int wpa_driver_capwap_mlme(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_disconnect (line 3533) | static int wpa_driver_capwap_disconnect(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_deauthenticate (line 3544) | static int wpa_driver_capwap_deauthenticate(void *priv, const u8 *addr,
  function wpa_driver_capwap_disassociate (line 3562) | static int wpa_driver_capwap_disassociate(void *priv, const u8 *addr,
  function wpa_driver_capwap_authenticate (line 3577) | static int wpa_driver_capwap_authenticate(
  type phy_info_arg (line 3694) | struct phy_info_arg {
  function phy_info_handler (line 3699) | static int phy_info_handler(struct nl_msg *msg, void *arg)
  type hostapd_hw_modes (line 3872) | struct hostapd_hw_modes
  type hostapd_hw_modes (line 3873) | struct hostapd_hw_modes
  type hostapd_hw_modes (line 3877) | struct hostapd_hw_modes
  type hostapd_channel_data (line 3910) | struct hostapd_channel_data
  type hostapd_channel_data (line 3916) | struct hostapd_channel_data
  function capwap_set_ht40_mode (line 3963) | static void capwap_set_ht40_mode(struct hostapd_hw_modes *mode, int start,
  function capwap_set_ht40_mode_sec (line 3976) | static void capwap_set_ht40_mode_sec(struct hostapd_hw_modes *mode, int ...
  function capwap_reg_rule_ht40 (line 3993) | static void capwap_reg_rule_ht40(struct nlattr *tb[],
  function capwap_reg_rule_sec (line 4022) | static void capwap_reg_rule_sec(struct nlattr *tb[],
  function capwap_get_reg (line 4049) | static int capwap_get_reg(struct nl_msg *msg, void *arg)
  function capwap_set_ht40_flags (line 4096) | static int capwap_set_ht40_flags(struct wpa_driver_capwap_data *drv,
  type hostapd_hw_modes (line 4110) | struct hostapd_hw_modes
  type hostapd_hw_modes (line 4124) | struct hostapd_hw_modes
  type hostapd_hw_modes (line 4131) | struct hostapd_hw_modes
  type hostapd_channel_data (line 4148) | struct hostapd_channel_data
  type hostapd_hw_modes (line 4181) | struct hostapd_hw_modes
  function wpa_driver_capwap_send_frame (line 4191) | static int wpa_driver_capwap_send_frame(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_send_mlme (line 4253) | static int wpa_driver_capwap_send_mlme(void *priv, const u8 *data,
  function capwap_set_ap_isolate (line 4304) | static int capwap_set_ap_isolate(struct i802_bss *bss, int enabled)
  function capwap_set_bss (line 4324) | static int capwap_set_bss(struct i802_bss *bss, int cts, int preamble,
  function wpa_driver_capwap_set_ap (line 4353) | static int wpa_driver_capwap_set_ap(void *priv,
  function wpa_driver_capwap_set_freq (line 4515) | static int wpa_driver_capwap_set_freq(struct wpa_driver_capwap_data *drv,
  function u32 (line 4525) | static u32 sta_flags_capwap(int flags)
  function wpa_driver_capwap_sta_add (line 4544) | static int wpa_driver_capwap_sta_add(void *priv,
  function wpa_driver_capwap_sta_remove (line 4599) | static int wpa_driver_capwap_sta_remove(void *priv, const u8 *addr)
  function capwap_remove_iface (line 4627) | static void capwap_remove_iface(struct wpa_driver_capwap_data *drv,
  type nl80211_iftype (line 4653) | enum nl80211_iftype
  function capwap_create_iface_once (line 4674) | static int capwap_create_iface_once(struct wpa_driver_capwap_data *drv,
  function capwap_create_iface (line 4747) | static int capwap_create_iface(struct wpa_driver_capwap_data *drv,
  function handle_tx_callback (line 4775) | static void handle_tx_callback(void *ctx, u8 *buf, size_t len, int ok)
  function from_unknown_sta (line 4796) | static void from_unknown_sta(struct wpa_driver_capwap_data *drv,
  function handle_frame (line 4817) | static void handle_frame(struct wpa_driver_capwap_data *drv,
  function handle_monitor_read (line 4856) | static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx){
  type sock_filter (line 4933) | struct sock_filter
  type sock_fprog (line 5033) | struct sock_fprog
  function add_monitor_filter (line 5039) | static int add_monitor_filter(int s)
  function capwap_remove_monitor_interface (line 5077) | static void capwap_remove_monitor_interface(
  function capwap_create_monitor_interface (line 5085) | static int capwap_create_monitor_interface(struct wpa_driver_capwap_data...
  function capwap_send_eapol_data (line 5164) | static int capwap_send_eapol_data(struct i802_bss *bss,
  function wpa_driver_capwap_hapd_send_eapol (line 5184) | static int wpa_driver_capwap_hapd_send_eapol(
  function wpa_driver_capwap_sta_set_flags (line 5256) | static int wpa_driver_capwap_sta_set_flags(void *priv, const u8 *addr,
  function wpa_driver_capwap_ap (line 5319) | static int wpa_driver_capwap_ap(struct wpa_driver_capwap_data *drv,
  function capwap_leave_ibss (line 5352) | static int capwap_leave_ibss(struct wpa_driver_capwap_data *drv)
  function wpa_driver_capwap_ibss (line 5380) | static int wpa_driver_capwap_ibss(struct wpa_driver_capwap_data *drv,
  function capwap_get_assoc_bssid (line 5454) | static unsigned int capwap_get_assoc_bssid(struct wpa_driver_capwap_data...
  function capwap_disconnect (line 5486) | static int capwap_disconnect(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_connect (line 5503) | static int wpa_driver_capwap_connect(
  function wpa_driver_capwap_associate (line 5671) | static int wpa_driver_capwap_associate(
  function capwap_set_mode (line 5811) | static int capwap_set_mode(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_set_mode (line 5847) | static int wpa_driver_capwap_set_mode(struct i802_bss *bss,
  function wpa_driver_capwap_get_capa (line 5940) | static int wpa_driver_capwap_get_capa(void *priv,
  function wpa_driver_capwap_set_operstate (line 5954) | static int wpa_driver_capwap_set_operstate(void *priv, int state)
  function wpa_driver_capwap_set_supp_port (line 5968) | static int wpa_driver_capwap_set_supp_port(void *priv, int authorized)
  function i802_set_freq (line 6000) | static int i802_set_freq(void *priv, struct hostapd_freq_params *freq)
  function min_int (line 6012) | static inline int min_int(int a, int b)
  function get_key_handler (line 6020) | static int get_key_handler(struct nl_msg *msg, void *arg)
  function i802_get_seqnum (line 6041) | static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
  function i802_set_rate_sets (line 6069) | static int i802_set_rate_sets(void *priv, int *supp_rates, int *basic_ra...
  function i802_set_rts (line 6102) | static int i802_set_rts(void *priv, int rts)
  function i802_set_frag (line 6136) | static int i802_set_frag(void *priv, int frag)
  function i802_flush (line 6170) | static int i802_flush(void *priv)
  function get_sta_handler (line 6196) | static int get_sta_handler(struct nl_msg *msg, void *arg)
  function i802_read_sta_data (line 6248) | static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data ...
  function i802_set_tx_queue_params (line 6274) | static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
  function i802_set_sta_vlan (line 6334) | static int i802_set_sta_vlan(void *priv, const u8 *addr,
  function i802_get_inact_sec (line 6369) | static int i802_get_inact_sec(void *priv, const u8 *addr)
  function i802_sta_clear_stats (line 6383) | static int i802_sta_clear_stats(void *priv, const u8 *addr)
  function i802_sta_deauth (line 6392) | static int i802_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
  function i802_sta_disassoc (line 6415) | static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *a...
  function add_ifidx (line 6438) | static void add_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function del_ifidx (line 6477) | static void del_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function have_ifidx (line 6490) | static int have_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function i802_set_wds_sta (line 6502) | static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val,
  function AC_handle_eapol (line 6533) | void AC_handle_eapol(struct wpa_driver_capwap_data *drv, u8 *buf, int len){
  function handle_eapol (line 6543) | static void handle_eapol(int sock, void *eloop_ctx, void *sock_ctx)
  function i802_check_bridge (line 6573) | static int i802_check_bridge(struct wpa_driver_capwap_data *drv,
  type hostapd_data (line 6628) | struct hostapd_data
  type wpa_init_params (line 6629) | struct wpa_init_params
  type wpa_driver_capwap_data (line 6635) | struct wpa_driver_capwap_data
  type i802_bss (line 6636) | struct i802_bss
  function i802_deinit (line 6740) | static void i802_deinit(void *priv)
  function wpa_driver_capwap_if_type (line 6751) | static enum nl80211_iftype wpa_driver_capwap_if_type(
  function capwap_addr_in_use (line 6773) | static int capwap_addr_in_use(struct capwap_global *global, const u8 *addr)
  function capwap_p2p_interface_addr (line 6785) | static int capwap_p2p_interface_addr(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_if_add (line 6812) | static int wpa_driver_capwap_if_add(void *priv, enum wpa_driver_if_type ...
  function wpa_driver_capwap_if_remove (line 6917) | static int wpa_driver_capwap_if_remove(void *priv,
  function cookie_handler (line 6974) | static int cookie_handler(struct nl_msg *msg, void *arg)
  function capwap_send_frame_cmd (line 6987) | static int capwap_send_frame_cmd(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_send_action (line 7033) | static int wpa_driver_capwap_send_action(void *priv, unsigned int freq,
  function wpa_driver_capwap_send_action_cancel_wait (line 7074) | static void wpa_driver_capwap_send_action_cancel_wait(void *priv)
  function wpa_driver_capwap_remain_on_channel (line 7102) | static int wpa_driver_capwap_remain_on_channel(void *priv, unsigned int ...
  function wpa_driver_capwap_cancel_remain_on_channel (line 7142) | static int wpa_driver_capwap_cancel_remain_on_channel(void *priv)
  function wpa_driver_capwap_probe_req_report (line 7181) | static int wpa_driver_capwap_probe_req_report(void *priv, int report)
  function capwap_disable_11b_rates (line 7234) | static int capwap_disable_11b_rates(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_deinit_ap (line 7283) | static int wpa_driver_capwap_deinit_ap(void *priv)
  function wpa_driver_capwap_deinit_p2p_cli (line 7295) | static int wpa_driver_capwap_deinit_p2p_cli(void *priv)
  function wpa_driver_capwap_resume (line 7306) | static void wpa_driver_capwap_resume(void *priv)
  function capwap_send_ft_action (line 7318) | static int capwap_send_ft_action(void *priv, u8 action, const u8 *target...
  function capwap_signal_monitor (line 7370) | static int capwap_signal_monitor(void *priv, int threshold, int hysteresis)
  function capwap_signal_poll (line 7407) | static int capwap_signal_poll(void *priv, struct wpa_signal_info *si)
  function capwap_send_frame (line 7423) | static int capwap_send_frame(void *priv, const u8 *data, size_t data_len,
  function capwap_set_param (line 7433) | static int capwap_set_param(void *priv, const char *param)
  type capwap_global (line 7459) | struct capwap_global
  type netlink_config (line 7460) | struct netlink_config
  function capwap_global_deinit (line 7496) | static void capwap_global_deinit(void *priv)
  type i802_bss (line 7528) | struct i802_bss
  type wpa_driver_capwap_data (line 7529) | struct wpa_driver_capwap_data
  function capwap_pmkid (line 7534) | static int capwap_pmkid(struct i802_bss *bss, int cmd, const u8 *bssid,
  function capwap_add_pmkid (line 7558) | static int capwap_add_pmkid(void *priv, const u8 *bssid, const u8 *pmkid)
  function capwap_remove_pmkid (line 7567) | static int capwap_remove_pmkid(void *priv, const u8 *bssid, const u8 *pm...
  function capwap_flush_pmkid (line 7577) | static int capwap_flush_pmkid(void *priv)
  function capwap_set_rekey_info (line 7586) | static void capwap_set_rekey_info(void *priv, const u8 *kek, const u8 *kck,
  function capwap_poll_client (line 7621) | static void capwap_poll_client(void *priv, const u8 *own_addr, const u8 ...
  function capwap_send_tdls_mgmt (line 7661) | static int capwap_send_tdls_mgmt(void *priv, const u8 *dst, u8 action_code,
  function capwap_tdls_oper (line 7696) | static int capwap_tdls_oper(void *priv, enum tdls_oper oper, const u8 *p...
  function AC_inject_frame_in_hostapd (line 7748) | void AC_inject_frame_in_hostapd(void *priv, u8 *buf, int len){
  type wpa_driver_ops (line 7803) | struct wpa_driver_ops

FILE: hostapd_wrapper/src/drivers/driver_capwap_wtp.c
  type wtp_info (line 65) | struct wtp_info {
  type priv_params (line 77) | struct priv_params {
  type priv_params (line 83) | struct priv_params
  function stampa_buffer (line 85) | void stampa_buffer(u8 *buf, int len){
  type wtp_info (line 95) | struct wtp_info
  type nl_handle (line 113) | struct nl_handle
  type nl_handle (line 115) | struct nl_handle
  function capwap_handle_destroy (line 134) | static void capwap_handle_destroy(struct nl_handle *handle)
  function __genl_ctrl_alloc_cache (line 144) | static inline int __genl_ctrl_alloc_cache(struct nl_handle *h,
  type capwap_handles (line 157) | struct capwap_handles {
  function nl_create_handles (line 162) | static int nl_create_handles(struct capwap_handles *handles, struct nl_c...
  function nl_destroy_handles (line 197) | static void nl_destroy_handles(struct capwap_handles *handles)
  type capwap_global (line 221) | struct capwap_global {
  type i802_bss (line 234) | struct i802_bss {
  type wpa_driver_capwap_data (line 245) | struct wpa_driver_capwap_data {
  type i802_bss (line 316) | struct i802_bss
  type nl80211_iftype (line 317) | enum nl80211_iftype
  type wpa_driver_capwap_data (line 319) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 320) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 324) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 325) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 332) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 333) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 334) | struct wpa_driver_capwap_data
  type wpa_driver_if_type (line 336) | enum wpa_driver_if_type
  function add_ifidx (line 339) | static inline void add_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function del_ifidx (line 343) | static inline void del_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function have_ifidx (line 347) | static inline int have_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  type hostapd_freq_params (line 353) | struct hostapd_freq_params
  type wpa_driver_capwap_data (line 354) | struct wpa_driver_capwap_data
  type wpa_driver_capwap_data (line 357) | struct wpa_driver_capwap_data
  function is_ap_interface (line 360) | static int is_ap_interface(enum nl80211_iftype nlmode)
  function is_sta_interface (line 367) | static int is_sta_interface(enum nl80211_iftype nlmode)
  function is_p2p_interface (line 374) | static int is_p2p_interface(enum nl80211_iftype nlmode)
  type capwap_bss_info_arg (line 381) | struct capwap_bss_info_arg {
  type nl_msg (line 388) | struct nl_msg
  function ack_handler (line 392) | static int ack_handler(struct nl_msg *msg, void *arg)
  function finish_handler (line 399) | static int finish_handler(struct nl_msg *msg, void *arg)
  function error_handler (line 406) | static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
  function no_seq_check (line 415) | static int no_seq_check(struct nl_msg *msg, void *arg)
  function send_and_recv (line 421) | static int send_and_recv(struct wpa_driver_capwap_data *drv,
  function send_and_recv_msgs (line 459) | static int send_and_recv_msgs(struct wpa_driver_capwap_data *drv,
  type family_data (line 470) | struct family_data {
  function family_handler (line 476) | static int family_handler(struct nl_msg *msg, void *arg)
  function nl_get_multicast_id (line 507) | static int nl_get_multicast_id(struct wpa_driver_capwap_data *drv,
  type wpa_driver_capwap_data (line 536) | struct wpa_driver_capwap_data
  type nl_msg (line 537) | struct nl_msg
  function wpa_driver_capwap_get_bssid (line 547) | static int wpa_driver_capwap_get_bssid(void *priv, u8 *bssid)
  function wpa_driver_capwap_get_ssid (line 559) | static int wpa_driver_capwap_get_ssid(void *priv, u8 *ssid)
  function wpa_driver_capwap_event_link (line 574) | static void wpa_driver_capwap_event_link(struct wpa_driver_capwap_data *...
  function wpa_driver_capwap_own_ifname (line 621) | static int wpa_driver_capwap_own_ifname(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_own_ifindex (line 647) | static int wpa_driver_capwap_own_ifindex(struct wpa_driver_capwap_data *...
  type wpa_driver_capwap_data (line 666) | struct wpa_driver_capwap_data
  type capwap_global (line 667) | struct capwap_global
  type wpa_driver_capwap_data (line 669) | struct wpa_driver_capwap_data
  function wpa_driver_capwap_event_rtm_newlink (line 680) | static void wpa_driver_capwap_event_rtm_newlink(void *ctx,
  function wpa_driver_capwap_event_rtm_dellink (line 786) | static void wpa_driver_capwap_event_rtm_dellink(void *ctx,
  function mlme_event_auth (line 829) | static void mlme_event_auth(struct wpa_driver_capwap_data *drv,
  function capwap_get_assoc_freq (line 856) | static unsigned int capwap_get_assoc_freq(struct wpa_driver_capwap_data ...
  function mlme_event_assoc (line 888) | static void mlme_event_assoc(struct wpa_driver_capwap_data *drv,
  function mlme_event_connect (line 934) | static void mlme_event_connect(struct wpa_driver_capwap_data *drv,
  function mlme_event_disconnect (line 985) | static void mlme_event_disconnect(struct wpa_driver_capwap_data *drv,
  function mlme_timeout_event (line 1008) | static void mlme_timeout_event(struct wpa_driver_capwap_data *drv,
  function mlme_event_mgmt (line 1033) | static void mlme_event_mgmt(struct wpa_driver_capwap_data *drv,
  function mlme_event_action_tx_status (line 1071) | static void mlme_event_action_tx_status(struct wpa_driver_capwap_data *drv,
  function mlme_event_deauth_disassoc (line 1106) | static void mlme_event_deauth_disassoc(struct wpa_driver_capwap_data *drv,
  function mlme_event_unprot_disconnect (line 1163) | static void mlme_event_unprot_disconnect(struct wpa_driver_capwap_data *...
  function mlme_event (line 1195) | static void mlme_event(struct wpa_driver_capwap_data *drv,
  function mlme_event_michael_mic_failure (line 1252) | static void mlme_event_michael_mic_failure(struct wpa_driver_capwap_data...
  function mlme_event_join_ibss (line 1288) | static void mlme_event_join_ibss(struct wpa_driver_capwap_data *drv,
  function mlme_event_remain_on_channel (line 1305) | static void mlme_event_remain_on_channel(struct wpa_driver_capwap_data *...
  function send_scan_event (line 1353) | static void send_scan_event(struct wpa_driver_capwap_data *drv, int abor...
  function get_link_signal (line 1394) | static int get_link_signal(struct nl_msg *msg, void *arg)
  function capwap_get_link_signal (line 1442) | static int capwap_get_link_signal(struct wpa_driver_capwap_data *drv,
  function get_link_noise (line 1467) | static int get_link_noise(struct nl_msg *msg, void *arg)
  function capwap_get_link_noise (line 1511) | static int capwap_get_link_noise(struct wpa_driver_capwap_data *drv,
  function get_noise_for_scan_results (line 1535) | static int get_noise_for_scan_results(struct nl_msg *msg, void *arg)
  function capwap_get_noise_for_scan_results (line 1588) | static int capwap_get_noise_for_scan_results(
  function capwap_cqm_event (line 1610) | static void capwap_cqm_event(struct wpa_driver_capwap_data *drv,
  function capwap_new_station_event (line 1677) | static void capwap_new_station_event(struct wpa_driver_capwap_data *drv,
  function capwap_del_station_event (line 1709) | static void capwap_del_station_event(struct wpa_driver_capwap_data *drv,
  function capwap_rekey_offload_event (line 1735) | static void capwap_rekey_offload_event(struct wpa_driver_capwap_data *drv,
  function capwap_pmksa_candidate_event (line 1777) | static void capwap_pmksa_candidate_event(struct wpa_driver_capwap_data *...
  function process_event (line 1811) | static int process_event(struct nl_msg *msg, void *arg)
  function wpa_driver_capwap_event_receive (line 1944) | static void wpa_driver_capwap_event_receive(int sock, void *eloop_ctx,
  function wpa_driver_capwap_set_country (line 1972) | static int wpa_driver_capwap_set_country(void *priv, const char *alpha2_...
  type wiphy_info_data (line 2001) | struct wiphy_info_data {
  function wiphy_info_handler (line 2008) | static int wiphy_info_handler(struct nl_msg *msg, void *arg)
  function wpa_driver_capwap_get_info (line 2196) | static int wpa_driver_capwap_get_info(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_capa (line 2224) | static int wpa_driver_capwap_capa(struct wpa_driver_capwap_data *drv)
  function android_genl_ctrl_resolve (line 2260) | static int android_genl_ctrl_resolve(struct nl_handle *handle,
  function wpa_driver_capwap_init_nl_global (line 2295) | static int wpa_driver_capwap_init_nl_global(struct capwap_global *global)
  function wpa_driver_capwap_init_nl (line 2320) | static int wpa_driver_capwap_init_nl(struct wpa_driver_capwap_data *drv)
  function wpa_driver_capwap_rfkill_blocked (line 2374) | static void wpa_driver_capwap_rfkill_blocked(void *ctx)
  function wpa_driver_capwap_rfkill_unblocked (line 2384) | static void wpa_driver_capwap_rfkill_unblocked(void *ctx)
  function capwap_get_phy_name (line 2398) | static void capwap_get_phy_name(struct wpa_driver_capwap_data *drv)
  function capwap_l2_read (line 2434) | static void capwap_l2_read(void *ctx, const u8 *src_addr, const u8 *buf,
  type wpa_driver_capwap_data (line 2455) | struct wpa_driver_capwap_data
  type rfkill_config (line 2456) | struct rfkill_config
  type i802_bss (line 2457) | struct i802_bss
  function capwap_register_frame (line 2514) | static int capwap_register_frame(struct wpa_driver_capwap_data *drv,
  function capwap_register_action_frame (line 2549) | static int capwap_register_action_frame(struct wpa_driver_capwap_data *drv,
  function capwap_register_action_frames (line 2558) | static int capwap_register_action_frames(struct wpa_driver_capwap_data *...
  function wpa_driver_capwap_send_rfkill (line 2616) | static void wpa_driver_capwap_send_rfkill(void *eloop_ctx, void *timeout...
  function wpa_driver_capwap_finish_drv_init (line 2622) | static int
  function wpa_driver_capwap_del_beacon (line 2695) | static int wpa_driver_capwap_del_beacon(struct wpa_driver_capwap_data *drv)
  function wpa_driver_capwap_deinit (line 2720) | static void wpa_driver_capwap_deinit(void *priv)
  function wpa_driver_capwap_scan_timeout (line 2803) | static void wpa_driver_capwap_scan_timeout(void *eloop_ctx, void *timeou...
  function wpa_driver_capwap_scan (line 2822) | static int wpa_driver_capwap_scan(void *priv,
  function wpa_driver_capwap_sched_scan (line 2963) | static int wpa_driver_capwap_sched_scan(void *priv,
  function wpa_driver_capwap_stop_sched_scan (line 3079) | static int wpa_driver_capwap_stop_sched_scan(void *priv)
  function u8 (line 3110) | static const u8 * capwap_get_ie(const u8 *ies, size_t ies_len, u8 ie)
  function capwap_scan_filtered (line 3132) | static int capwap_scan_filtered(struct wpa_driver_capwap_data *drv,
  function bss_info_handler (line 3156) | static int bss_info_handler(struct nl_msg *msg, void *arg)
  function clear_state_mismatch (line 3325) | static void clear_state_mismatch(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_check_bss_status (line 3338) | static void wpa_driver_capwap_check_bss_status(
  type wpa_scan_results (line 3389) | struct wpa_scan_results
  type wpa_driver_capwap_data (line 3390) | struct wpa_driver_capwap_data
  type nl_msg (line 3392) | struct nl_msg
  type wpa_scan_results (line 3393) | struct wpa_scan_results
  type capwap_bss_info_arg (line 3395) | struct capwap_bss_info_arg
  type wpa_scan_results (line 3431) | struct wpa_scan_results
  type i802_bss (line 3434) | struct i802_bss
  type wpa_driver_capwap_data (line 3435) | struct wpa_driver_capwap_data
  type wpa_scan_results (line 3436) | struct wpa_scan_results
  function capwap_dump_scan (line 3445) | static void capwap_dump_scan(struct wpa_driver_capwap_data *drv)
  function wpa_driver_capwap_set_key (line 3469) | static int wpa_driver_capwap_set_key(const char *ifname, void *priv,
  function nl_add_key (line 3625) | static int nl_add_key(struct nl_msg *msg, enum wpa_alg alg,
  function capwap_set_conn_keys (line 3679) | static int capwap_set_conn_keys(struct wpa_driver_associate_params *params,
  function wpa_driver_capwap_mlme (line 3739) | static int wpa_driver_capwap_mlme(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_disconnect (line 3774) | static int wpa_driver_capwap_disconnect(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_deauthenticate (line 3785) | static int wpa_driver_capwap_deauthenticate(void *priv, const u8 *addr,
  function wpa_driver_capwap_disassociate (line 3802) | static int wpa_driver_capwap_disassociate(void *priv, const u8 *addr,
  function wpa_driver_capwap_authenticate (line 3816) | static int wpa_driver_capwap_authenticate(
  type phy_info_arg (line 3933) | struct phy_info_arg {
  function phy_info_handler (line 3938) | static int phy_info_handler(struct nl_msg *msg, void *arg)
  type hostapd_hw_modes (line 4111) | struct hostapd_hw_modes
  type hostapd_hw_modes (line 4112) | struct hostapd_hw_modes
  type hostapd_hw_modes (line 4115) | struct hostapd_hw_modes
  type hostapd_channel_data (line 4145) | struct hostapd_channel_data
  type hostapd_channel_data (line 4151) | struct hostapd_channel_data
  function capwap_set_ht40_mode (line 4185) | static void capwap_set_ht40_mode(struct hostapd_hw_modes *mode, int start,
  function capwap_set_ht40_mode_sec (line 4198) | static void capwap_set_ht40_mode_sec(struct hostapd_hw_modes *mode, int ...
  function capwap_reg_rule_ht40 (line 4215) | static void capwap_reg_rule_ht40(struct nlattr *tb[],
  function capwap_reg_rule_sec (line 4244) | static void capwap_reg_rule_sec(struct nlattr *tb[],
  function capwap_get_reg (line 4271) | static int capwap_get_reg(struct nl_msg *msg, void *arg)
  function capwap_set_ht40_flags (line 4318) | static int capwap_set_ht40_flags(struct wpa_driver_capwap_data *drv,
  type hostapd_hw_modes (line 4332) | struct hostapd_hw_modes
  type i802_bss (line 4338) | struct i802_bss
  type wpa_driver_capwap_data (line 4339) | struct wpa_driver_capwap_data
  type nl_msg (line 4340) | struct nl_msg
  type phy_info_arg (line 4341) | struct phy_info_arg
  function wpa_driver_capwap_send_frame (line 4369) | int wpa_driver_capwap_send_frame(struct wpa_driver_capwap_data *drv,cons...
  function wpa_driver_capwap_send_mlme (line 4421) | static int wpa_driver_capwap_send_mlme(void *priv, const u8 *data,
  function capwap_set_ap_isolate (line 4472) | static int capwap_set_ap_isolate(struct i802_bss *bss, int enabled)
  function capwap_set_bss (line 4492) | static int capwap_set_bss(struct i802_bss *bss, int cts, int preamble,
  function wpa_driver_capwap_set_ap (line 4522) | static int wpa_driver_capwap_set_ap(void *priv,
  function wpa_driver_capwap_set_freq (line 4674) | static int wpa_driver_capwap_set_freq(struct wpa_driver_capwap_data *drv,
  function u32 (line 4723) | static u32 sta_flags_capwap(int flags)
  function wpa_driver_capwap_sta_add (line 4741) | static int wpa_driver_capwap_sta_add(void *priv,
  function wpa_driver_capwap_sta_remove (line 4802) | static int wpa_driver_capwap_sta_remove(void *priv, const u8 *addr)
  function capwap_remove_iface (line 4830) | static void capwap_remove_iface(struct wpa_driver_capwap_data *drv,
  type nl80211_iftype (line 4856) | enum nl80211_iftype
  function capwap_create_iface_once (line 4877) | static int capwap_create_iface_once(struct wpa_driver_capwap_data *drv,
  function capwap_create_iface (line 4948) | static int capwap_create_iface(struct wpa_driver_capwap_data *drv,
  function handle_tx_callback (line 4975) | static void handle_tx_callback(void *ctx, u8 *buf, size_t len, int ok)
  function from_unknown_sta (line 4996) | static void from_unknown_sta(struct wpa_driver_capwap_data *drv,
  function handle_frame (line 5017) | static void handle_frame(struct wpa_driver_capwap_data *drv,
  function handle_monitor_read (line 5050) | static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx){
  type sock_filter (line 5201) | struct sock_filter
  type sock_fprog (line 5301) | struct sock_fprog
  function add_monitor_filter (line 5307) | static int add_monitor_filter(int s)
  function capwap_remove_monitor_interface (line 5345) | static void capwap_remove_monitor_interface(
  function capwap_create_monitor_interface (line 5361) | static int capwap_create_monitor_interface(struct wpa_driver_capwap_data...
  function capwap_send_eapol_data (line 5442) | static int capwap_send_eapol_data(struct i802_bss *bss,
  function wpa_driver_capwap_hapd_send_eapol (line 5462) | static int wpa_driver_capwap_hapd_send_eapol(
  function wpa_driver_capwap_sta_set_flags (line 5532) | static int wpa_driver_capwap_sta_set_flags(void *priv, const u8 *addr,
  function wpa_driver_capwap_ap (line 5595) | static int wpa_driver_capwap_ap(struct wpa_driver_capwap_data *drv,
  function capwap_leave_ibss (line 5628) | static int capwap_leave_ibss(struct wpa_driver_capwap_data *drv)
  function wpa_driver_capwap_ibss (line 5656) | static int wpa_driver_capwap_ibss(struct wpa_driver_capwap_data *drv,
  function capwap_get_assoc_bssid (line 5730) | static unsigned int capwap_get_assoc_bssid(struct wpa_driver_capwap_data...
  function capwap_disconnect (line 5762) | static int capwap_disconnect(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_connect (line 5779) | static int wpa_driver_capwap_connect(
  function wpa_driver_capwap_associate (line 5947) | static int wpa_driver_capwap_associate(
  function capwap_set_mode (line 6087) | static int capwap_set_mode(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_set_mode (line 6123) | static int wpa_driver_capwap_set_mode(struct i802_bss *bss,
  function wpa_driver_capwap_get_capa (line 6216) | static int wpa_driver_capwap_get_capa(void *priv,
  function wpa_driver_capwap_set_operstate (line 6230) | static int wpa_driver_capwap_set_operstate(void *priv, int state)
  function wpa_driver_capwap_set_supp_port (line 6244) | static int wpa_driver_capwap_set_supp_port(void *priv, int authorized)
  function i802_set_freq (line 6276) | static int i802_set_freq(void *priv, struct hostapd_freq_params *freq)
  function min_int (line 6288) | static inline int min_int(int a, int b)
  function get_key_handler (line 6296) | static int get_key_handler(struct nl_msg *msg, void *arg)
  function i802_get_seqnum (line 6317) | static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
  function i802_set_rate_sets (line 6345) | static int i802_set_rate_sets(void *priv, int *supp_rates, int *basic_ra...
  function i802_set_rts (line 6375) | static int i802_set_rts(void *priv, int rts)
  function i802_set_frag (line 6409) | static int i802_set_frag(void *priv, int frag)
  function i802_flush (line 6443) | static int i802_flush(void *priv)
  function get_sta_handler (line 6469) | static int get_sta_handler(struct nl_msg *msg, void *arg)
  function i802_read_sta_data (line 6521) | static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data ...
  function i802_set_tx_queue_params (line 6547) | static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
  function i802_set_sta_vlan (line 6608) | static int i802_set_sta_vlan(void *priv, const u8 *addr,
  function i802_get_inact_sec (line 6643) | static int i802_get_inact_sec(void *priv, const u8 *addr)
  function i802_sta_clear_stats (line 6657) | static int i802_sta_clear_stats(void *priv, const u8 *addr)
  function i802_sta_deauth (line 6666) | static int i802_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
  function i802_sta_disassoc (line 6687) | static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *a...
  function add_ifidx (line 6710) | static void add_ifidx(struct wpa_driver_capwap_data *drv, int ifidx){
  function del_ifidx (line 6748) | static void del_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function have_ifidx (line 6761) | static int have_ifidx(struct wpa_driver_capwap_data *drv, int ifidx)
  function i802_set_wds_sta (line 6773) | static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val,
  function handle_eapol (line 6805) | static void handle_eapol(int sock, void *eloop_ctx, void *sock_ctx)
  function i802_check_bridge (line 6854) | static int i802_check_bridge(struct wpa_driver_capwap_data *drv,
  function AC_popu_capa_info (line 6908) | void AC_popu_capa_info(struct i802_bss *bss, unsigned char *mac_addr)
  type hostapd_data (line 6942) | struct hostapd_data
  type wpa_init_params (line 6943) | struct wpa_init_params
  type wpa_driver_capwap_data (line 6947) | struct wpa_driver_capwap_data
  type i802_bss (line 6948) | struct i802_bss
  function i802_deinit (line 7090) | static void i802_deinit(void *priv)
  function wpa_driver_capwap_if_type (line 7101) | static enum nl80211_iftype wpa_driver_capwap_if_type(
  function capwap_addr_in_use (line 7123) | static int capwap_addr_in_use(struct capwap_global *global, const u8 *addr)
  function capwap_p2p_interface_addr (line 7135) | static int capwap_p2p_interface_addr(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_if_add (line 7162) | static int wpa_driver_capwap_if_add(void *priv, enum wpa_driver_if_type ...
  function wpa_driver_capwap_if_remove (line 7266) | static int wpa_driver_capwap_if_remove(void *priv,
  function cookie_handler (line 7322) | static int cookie_handler(struct nl_msg *msg, void *arg)
  function capwap_send_frame_cmd (line 7335) | static int capwap_send_frame_cmd(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_send_action (line 7381) | static int wpa_driver_capwap_send_action(void *priv, unsigned int freq,
  function wpa_driver_capwap_send_action_cancel_wait (line 7421) | static void wpa_driver_capwap_send_action_cancel_wait(void *priv)
  function wpa_driver_capwap_remain_on_channel (line 7448) | static int wpa_driver_capwap_remain_on_channel(void *priv, unsigned int ...
  function wpa_driver_capwap_cancel_remain_on_channel (line 7487) | static int wpa_driver_capwap_cancel_remain_on_channel(void *priv)
  function wpa_driver_capwap_probe_req_report (line 7525) | static int wpa_driver_capwap_probe_req_report(void *priv, int report)
  function capwap_disable_11b_rates (line 7578) | static int capwap_disable_11b_rates(struct wpa_driver_capwap_data *drv,
  function wpa_driver_capwap_deinit_ap (line 7627) | static int wpa_driver_capwap_deinit_ap(void *priv)
  function wpa_driver_capwap_deinit_p2p_cli (line 7639) | static int wpa_driver_capwap_deinit_p2p_cli(void *priv)
  function wpa_driver_capwap_resume (line 7650) | static void wpa_driver_capwap_resume(void *priv)
  function capwap_send_ft_action (line 7662) | static int capwap_send_ft_action(void *priv, u8 action, const u8 *target...
  function capwap_signal_monitor (line 7714) | static int capwap_signal_monitor(void *priv, int threshold, int hysteresis)
  function capwap_signal_poll (line 7751) | static int capwap_signal_poll(void *priv, struct wpa_signal_info *si)
  function capwap_send_frame (line 7767) | static int capwap_send_frame(void *priv, const u8 *data, size_t data_len,
  function capwap_set_param (line 7777) | static int capwap_set_param(void *priv, const char *param)
  type capwap_global (line 7803) | struct capwap_global
  type netlink_config (line 7804) | struct netlink_config
  function capwap_global_deinit (line 7840) | static void capwap_global_deinit(void *priv)
  type i802_bss (line 7872) | struct i802_bss
  type wpa_driver_capwap_data (line 7873) | struct wpa_driver_capwap_data
  function capwap_pmkid (line 7878) | static int capwap_pmkid(struct i802_bss *bss, int cmd, const u8 *bssid,
  function capwap_add_pmkid (line 7902) | static int capwap_add_pmkid(void *priv, const u8 *bssid, const u8 *pmkid)
  function capwap_remove_pmkid (line 7911) | static int capwap_remove_pmkid(void *priv, const u8 *bssid, const u8 *pm...
  function capwap_flush_pmkid (line 7921) | static int capwap_flush_pmkid(void *priv)
  function capwap_set_rekey_info (line 7930) | static void capwap_set_rekey_info(void *priv, const u8 *kek, const u8 *kck,
  function capwap_poll_client (line 7965) | static void capwap_poll_client(void *priv, const u8 *own_addr, const u8 ...
  function capwap_send_tdls_mgmt (line 8005) | static int capwap_send_tdls_mgmt(void *priv, const u8 *dst, u8 action_code,
  function capwap_tdls_oper (line 8040) | static int capwap_tdls_oper(void *priv, enum tdls_oper oper, const u8 *p...
  function WTP_inject_frame_in_air (line 8093) | void WTP_inject_frame_in_air(void *priv, u8 *buf, int len)
  type wpa_driver_ops (line 8114) | struct wpa_driver_ops

FILE: hostapd_wrapper/src/drivers/linux_ioctl_fake.c
  function linux_set_iface_flags (line 26) | int linux_set_iface_flags(int sock, const char *ifname, int dev_up){
  function linux_iface_up (line 31) | int linux_iface_up(int sock, const char *ifname){
  function linux_get_ifhwaddr (line 36) | int linux_get_ifhwaddr(int sock, const char *ifname, u8 *addr){
  function linux_set_ifhwaddr (line 69) | int linux_set_ifhwaddr(int sock, const char *ifname, const u8 *addr){
  function linux_br_add (line 89) | int linux_br_add(int sock, const char *brname){
  function linux_br_del (line 93) | int linux_br_del(int sock, const char *brname){
  function linux_br_add_if (line 97) | int linux_br_add_if(int sock, const char *brname, const char *ifname){
  function linux_br_del_if (line 101) | int linux_br_del_if(int sock, const char *brname, const char *ifname){
  function linux_br_get (line 105) | int linux_br_get(char *brname, const char *ifname){

FILE: hostapd_wrapper/src/drivers/netlink_fake.c
  type netlink_data (line 25) | struct netlink_data {
  function netlink_receive_link (line 31) | static void netlink_receive_link(struct netlink_data *netlink,
  function netlink_receive (line 41) | static void netlink_receive(int sock, void *eloop_ctx, void *sock_ctx)
  type netlink_data (line 47) | struct netlink_data
  type netlink_config (line 47) | struct netlink_config
  type netlink_data (line 50) | struct netlink_data
  type sockaddr_nl (line 51) | struct sockaddr_nl
  function netlink_deinit (line 73) | void netlink_deinit(struct netlink_data *netlink)
  function netlink_send_oper_ifla (line 78) | int netlink_send_oper_ifla(struct netlink_data *netlink, int ifindex,

FILE: hostapd_wrapper/src/drivers/netlink_fake.h
  type netlink_data (line 18) | struct netlink_data
  type ifinfomsg (line 19) | struct ifinfomsg
  type netlink_config (line 21) | struct netlink_config {
  type netlink_data (line 29) | struct netlink_data
  type netlink_config (line 29) | struct netlink_config
  type netlink_data (line 30) | struct netlink_data
  type netlink_data (line 31) | struct netlink_data

FILE: ieee802_11_defs.h
  type adv_proto_id (line 309) | enum adv_proto_id {
  type anqp_info_id (line 318) | enum anqp_info_id {
  type nai_realm_eap_auth_param (line 338) | enum nai_realm_eap_auth_param {
  type nai_realm_eap_auth_inner_non_eap (line 348) | enum nai_realm_eap_auth_inner_non_eap {
  type nai_realm_eap_cred_type (line 355) | enum nai_realm_eap_cred_type {
  type ieee80211_hdr (line 372) | struct ieee80211_hdr {
  type ieee80211_mgmt (line 391) | struct ieee80211_mgmt {
  type ieee80211_ht_capabilities (line 519) | struct ieee80211_ht_capabilities {
  type ieee80211_ht_operation (line 528) | struct ieee80211_ht_operation {
  type wmm_information_element (line 660) | struct wmm_information_element {
  type wmm_ac_parameter (line 682) | struct wmm_ac_parameter {
  type wmm_parameter_element (line 692) | struct wmm_parameter_element {
  type wmm_tspec_element (line 706) | struct wmm_tspec_element {
  type p2p_attr_id (line 744) | enum p2p_attr_id {
  type p2p_status_code (line 794) | enum p2p_status_code {
  type p2p_act_frame_type (line 813) | enum p2p_act_frame_type {
  type p2p_action_frame_type (line 821) | enum p2p_action_frame_type {
  type p2p_service_protocol_type (line 833) | enum p2p_service_protocol_type {
  type p2p_sd_status (line 841) | enum p2p_sd_status {
  type wnm_action (line 866) | enum wnm_action {

FILE: os.h
  type os_time_t (line 18) | typedef long os_time_t;
  type os_time (line 27) | struct os_time {
  type os_time (line 37) | struct os_time
  type os_tm (line 71) | struct os_tm {
  type os_tm (line 80) | struct os_tm

FILE: smac_code.h
  type u8 (line 27) | typedef unsigned char u8;
  type u16 (line 28) | typedef unsigned short u16;
  type u32 (line 29) | typedef unsigned int u32;

FILE: tap.c
  function tun_alloc (line 17) | int tun_alloc(char *dev, int flags)
  function init_AC_tap_interface (line 66) | int init_AC_tap_interface(int WTPIndex)

FILE: timerlib.c
  type tl_timer_t (line 72) | typedef struct timer tl_timer_t;
  type timeval (line 76) | struct timeval
  type timer (line 79) | struct timer {
  function timer_free (line 101) | static void timer_free(tl_timer_t * t)
  function timer_dequeue (line 110) | static void timer_dequeue(tl_timer_t * t)
  function timer_start (line 140) | static void timer_start(struct timeval *abs_to)
  function timer_init (line 260) | int timer_init()
  function timer_destroy (line 322) | void timer_destroy()
  function timer_add (line 344) | int timer_add(long sec, long usec, void (*hndlr) (void *), void *hndlr_arg)
  function timer_rem (line 441) | void timer_rem(int id, void (*free_arg) (void *))
  function timer_print (line 491) | void timer_print()

FILE: wireless_copy.h
  type __uint32_t (line 90) | typedef __uint32_t __u32;
  type __int32_t (line 91) | typedef __int32_t __s32;
  type __uint16_t (line 92) | typedef __uint16_t __u16;
  type __int16_t (line 93) | typedef __int16_t __s16;
  type __uint8_t (line 94) | typedef __uint8_t __u8;
  type iw_param (line 650) | struct iw_param {
  type iw_point (line 661) | struct iw_point {
  type iw_freq (line 675) | struct iw_freq {
  type iw_quality (line 685) | struct iw_quality {
  type iw_discarded (line 700) | struct iw_discarded {
  type iw_missed (line 712) | struct iw_missed {
  type iw_thrspy (line 719) | struct iw_thrspy {
  type iw_scan_req (line 737) | struct iw_scan_req {
  type iw_encode_ext (line 798) | struct iw_encode_ext {
  type iw_mlme (line 811) | struct iw_mlme {
  type iw_pmksa (line 824) | struct iw_pmksa {
  type iw_michaelmicfailure (line 831) | struct iw_michaelmicfailure {
  type iw_pmkid_cand (line 839) | struct iw_pmkid_cand {
  type iw_statistics (line 850) | struct iw_statistics {
  type iw_point (line 877) | struct iw_point
  type iw_param (line 878) | struct iw_param
  type iw_freq (line 879) | struct iw_freq
  type iw_param (line 883) | struct iw_param
  type iw_param (line 884) | struct iw_param
  type iw_param (line 885) | struct iw_param
  type iw_param (line 886) | struct iw_param
  type iw_param (line 887) | struct iw_param
  type iw_param (line 889) | struct iw_param
  type iw_point (line 891) | struct iw_point
  type iw_param (line 892) | struct iw_param
  type iw_quality (line 893) | struct iw_quality
  type sockaddr (line 895) | struct sockaddr
  type sockaddr (line 896) | struct sockaddr
  type iw_param (line 898) | struct iw_param
  type iw_point (line 899) | struct iw_point
  type iwreq (line 908) | struct iwreq {
  type iw_range (line 927) | struct iw_range {
  type iw_priv_args (line 1028) | struct iw_priv_args {
  type iw_event (line 1045) | struct iw_event {

FILE: wum/wum.c
  type WTPInfo (line 11) | struct WTPInfo
  type version_info (line 13) | struct version_info
  type WTPInfo (line 13) | struct WTPInfo
  type cmd_t (line 27) | typedef struct {
  type WTPInfo (line 43) | struct WTPInfo
  function main (line 46) | int main(int argc, char *argv[])
  function sanitize_wtp_list (line 134) | int sanitize_wtp_list(int *work_list, int n)
  function count_tokens (line 178) | int count_tokens(char *str1, char *str2)
  function do_version_cmd (line 255) | void do_version_cmd(int acserver, char *wtpIds, char *wtpNames)
  function do_update_cmd (line 276) | void do_update_cmd(int acserver, char *wtpIds, char *wtpNames, char *cup...
  function do_cancel_cmd (line 324) | void do_cancel_cmd(int acserver, char *wtpIds, char *wtpNames)
  function WTP_name2id (line 346) | int WTP_name2id(char *name)
  function get_cmd_id (line 372) | int get_cmd_id(char *cmd)
  function printWTPList (line 383) | void printWTPList(struct WTPInfo *wtpList, int nWTPs)
  function printVersionHeader (line 401) | void printVersionHeader()
  function printVersionInfo (line 408) | void printVersionInfo(struct version_info v_info, int wtpId, struct WTPI...
  function printVersionFooter (line 415) | void printVersionFooter()
  function usage (line 420) | void usage(char *name)

FILE: wum/wumLib.c
  type WTPInfo (line 18) | struct WTPInfo
  type wum_req_t (line 20) | typedef struct __attribute__ ((__packed__)) {
  type wum_resp_t (line 29) | typedef struct {
  function ACServerConnect (line 52) | int ACServerConnect(char *address, int port)
  function ACServerDisconnect (line 87) | void ACServerDisconnect(int acserver)
  type WTPInfo (line 99) | struct WTPInfo
  type WTPInfo (line 103) | struct WTPInfo
  type WTPInfo (line 115) | struct WTPInfo
  function readWTPInfo (line 129) | void readWTPInfo(int acserver, struct WTPInfo *WTPInfo, int pos)
  function freeWTPList (line 161) | void freeWTPList(struct WTPInfo *wtpList, int nWTPs)
  function WUMGetWTPVersion (line 171) | int WUMGetWTPVersion(int acserver, int wtpId, struct version_info *v_info)
  function StringToLower (line 205) | void StringToLower(char *str)
  function WUMReadCupVersion (line 211) | int WUMReadCupVersion(char *cup_pathname, struct version_info *update_v)
  function WUMSendCommitRequest (line 264) | int WUMSendCommitRequest(int acserver, int wtpId)
  function WUMSendCancelRequest (line 294) | int WUMSendCancelRequest(int acserver, int wtpId)
  function WUMSendFragment (line 324) | int WUMSendFragment(int acserver, int wtpId, void *buf, int size, int seq)
  function WUMUpdate (line 359) | int WUMUpdate(int acserver, int wtpId, void *cup_buf, struct version_inf...
  function WUMSendUpdateRequest (line 390) | int WUMSendUpdateRequest(int acserver, int wtpId, struct version_info up...
  function WUMSendMessage (line 421) | int WUMSendMessage(int acserver, wum_req_t msg)
  function WUMReceiveMessage (line 441) | int WUMReceiveMessage(int acserver, wum_resp_t * msg)
  function WUMPayloadRetrieve8 (line 475) | char WUMPayloadRetrieve8(wum_resp_t * resp)
  function WUMPayloadStore8 (line 480) | void WUMPayloadStore8(wum_req_t * req, char c)
  function WUMPayloadStore32 (line 485) | void WUMPayloadStore32(wum_req_t * req, int i)
  function WUMPayloadStoreRawBytes (line 492) | void WUMPayloadStoreRawBytes(wum_req_t * req, void *buf, int size)
  function readn (line 498) | int /* Read "n" bytes from a descriptor. */ readn(int fd, void *vptr, si...
  function Readn (line 521) | int Readn(int fd, void *ptr, size_t nbytes)
  function writen (line 530) | int /* Write "n" bytes to a descriptor. */ writen(int fd, const void *vp...
  function Writen (line 552) | int Writen(int fd, void *ptr, size_t nbytes)
  function Read32 (line 560) | int Read32(int fd, int *ptr)
  function Write32 (line 571) | int Write32(int fd, void *ptr)

FILE: wum/wumLib.h
  type WTPInfo (line 30) | struct WTPInfo {
  type version_info (line 35) | struct version_info {
  type WTPInfo (line 44) | struct WTPInfo
  type WTPInfo (line 45) | struct WTPInfo
  type version_info (line 47) | struct version_info
  type version_info (line 48) | struct version_info
  type version_info (line 49) | struct version_info
Condensed preview — 167 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,460K chars).
[
  {
    "path": ".gitignore",
    "chars": 271,
    "preview": "*~\n*.o\n*.lo\n*.la\nm4\n.deps\n.libs\n\n#\n# binaries\n#\nAC\nWTP\nWUA\n\n#\n# autoconf files\n#\nMakefile\nMakefile.in\naclocal.m4\nautom4t"
  },
  {
    "path": "AC.c",
    "chars": 9144,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACAppsProtocol.h",
    "chars": 4193,
    "preview": "/*\n *  appsToAcProtocol.h\n *\n *\n *  Created by Antonio Davoli on 03/03/09.\n *  Copyright 2009 La Sapienza. All rights re"
  },
  {
    "path": "ACBinding.c",
    "chars": 11597,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "ACBinding.h",
    "chars": 3360,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "ACConfigFile.c",
    "chars": 6261,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACConfigureState.c",
    "chars": 12737,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACDataCheckState.c",
    "chars": 8019,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACDiscoveryState.c",
    "chars": 9271,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACInterface.c",
    "chars": 23289,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "ACInterface.h",
    "chars": 3150,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-2009 "
  },
  {
    "path": "ACJoinState.c",
    "chars": 13786,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACMainLoop.c",
    "chars": 27299,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "ACMultiHomedSocket.c",
    "chars": 24552,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACMultiHomedSocket.h",
    "chars": 4409,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACProtocol.c",
    "chars": 32703,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACProtocol.h",
    "chars": 10036,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACProtocol_User.c",
    "chars": 9839,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACRetransmission.c",
    "chars": 5248,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACRunState.c",
    "chars": 56822,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "ACSettingsFile.c",
    "chars": 8426,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACipcHostapd.c",
    "chars": 19779,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "ACipcHostapd.h",
    "chars": 2496,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "COPYING",
    "chars": 2432,
    "preview": "# *******************************************************************************************\n# * Copyright (c) 2006-7 L"
  },
  {
    "path": "CWAC.h",
    "chars": 11682,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "CWBinding.c",
    "chars": 11893,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "CWBinding.h",
    "chars": 6614,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "CWCommon.c",
    "chars": 3643,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWCommon.h",
    "chars": 6499,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-9 Lab"
  },
  {
    "path": "CWConfigFile.c",
    "chars": 7054,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWConfigFile.h",
    "chars": 2967,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWErrorHandling.c",
    "chars": 5888,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWErrorHandling.h",
    "chars": 3824,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWFreqPayloads.h",
    "chars": 2297,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "CWList.c",
    "chars": 6143,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWList.h",
    "chars": 3264,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWLog.c",
    "chars": 5915,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWLog.h",
    "chars": 2706,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWNetwork.c",
    "chars": 10609,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWNetwork.h",
    "chars": 4971,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWOpenSSLBio.c",
    "chars": 6431,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWProtocol.c",
    "chars": 40258,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWProtocol.h",
    "chars": 27657,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "CWRandom.c",
    "chars": 2680,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWRandom.h",
    "chars": 2565,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWSafeList.c",
    "chars": 9479,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWSafeList.h",
    "chars": 4131,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWSecurity.c",
    "chars": 20505,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWSecurity.h",
    "chars": 3581,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWStevens.c",
    "chars": 13487,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWStevens.h",
    "chars": 3660,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWThread.c",
    "chars": 21276,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWThread.h",
    "chars": 5829,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWTimer.h",
    "chars": 14134,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "CWVendorPayloads.h",
    "chars": 4250,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "CWVendorPayloadsAC.c",
    "chars": 6545,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "CWVendorPayloadsWTP.c",
    "chars": 19640,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "CWWTP.h",
    "chars": 8184,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2005-7 Lab"
  },
  {
    "path": "Doxyfile",
    "chars": 10099,
    "preview": "# Doxyfile 1.4.6\n\n#---------------------------------------------------------------------------\n# Project related configu"
  },
  {
    "path": "INSTALL.rst",
    "chars": 1369,
    "preview": "=============================================\nHOW TO BUILD AND RUN CAPWAP FOR LINUX SYSTEMS\n============================"
  },
  {
    "path": "Makefile.am",
    "chars": 1502,
    "preview": "ACLOCAL_AMFLAGS=-I m4\n\nAM_CPPFLAGS = -I$(srcdir)/include -D_REENTRANT\nAM_CPPFLAGS += -DOPENSSL_NO_KRB5\n\n# Capwap Debuggi"
  },
  {
    "path": "Makefile.bcm",
    "chars": 4109,
    "preview": "# *******************************************************************************************\n# * Copyright (c) 2006-7 L"
  },
  {
    "path": "Makefile.glibc",
    "chars": 4759,
    "preview": "# *******************************************************************************************\n# * Copyright (c) 2006-7 L"
  },
  {
    "path": "Makefile.uclibc",
    "chars": 5001,
    "preview": "# *******************************************************************************************\n# * Copyright (c) 2006-7 L"
  },
  {
    "path": "MakefileMac",
    "chars": 4751,
    "preview": "# *******************************************************************************************\n# * Copyright (c) 2006-7 L"
  },
  {
    "path": "README.md",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "WTP.c",
    "chars": 18108,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "WTPBcmDriverInteraction.c",
    "chars": 9061,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPBcmDriverInteraction.h",
    "chars": 18091,
    "preview": "#define __CAPWAP_WTPBroadcomDriverInteraction_HEADER__\n\n/* check this magic number */\n#define WLC_IOCTL_MAGIC     0x14e4"
  },
  {
    "path": "WTPBcmFrameReceive.c",
    "chars": 7873,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPBcmFrameReceive.h",
    "chars": 5124,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPBinding.c",
    "chars": 23096,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "WTPBinding.h",
    "chars": 4632,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "WTPConfigFile.c",
    "chars": 6072,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPConfigureState.c",
    "chars": 12631,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPDataCheckState.c",
    "chars": 6035,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPDiscoveryState.c",
    "chars": 18260,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPDriverInteraction.c",
    "chars": 8696,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPFrameReceive.c",
    "chars": 12796,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPFrameReceive.h",
    "chars": 4672,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPFreqStatsReceive.c",
    "chars": 5584,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2009 Labor"
  },
  {
    "path": "WTPFreqStatsReceive.h",
    "chars": 3191,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2009 Labor"
  },
  {
    "path": "WTPJoinState.c",
    "chars": 17342,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPProtocol.c",
    "chars": 45323,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPProtocol.h",
    "chars": 8532,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPProtocol_User.c",
    "chars": 15470,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPRetransmission.c",
    "chars": 5569,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPRunState.c",
    "chars": 49159,
    "preview": "/************************************************************************************************\n * Copyright (c) 2006-"
  },
  {
    "path": "WTPRunStateCheck.c",
    "chars": 8844,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPSettingsFile.c",
    "chars": 6896,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPStatsReceive.c",
    "chars": 4962,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2008 Labor"
  },
  {
    "path": "WTPStatsReceive.h",
    "chars": 8250,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2008 Labor"
  },
  {
    "path": "WTPSulkingState.c",
    "chars": 4388,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPipcHostapd.c",
    "chars": 13411,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPipcHostapd.h",
    "chars": 3028,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPmacDriverInteraction.c",
    "chars": 3825,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPmacDriverInteraction.h",
    "chars": 18092,
    "preview": "\n#define __CAPWAP_WTPBroadcomDriverInteraction_HEADER__\n\n/* check this magic number */\n#define WLC_IOCTL_MAGIC     0x14e"
  },
  {
    "path": "WTPmacFrameReceive.c",
    "chars": 8670,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WTPmacFrameReceive.h",
    "chars": 4807,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "WUA.c",
    "chars": 12614,
    "preview": "\n/*******************************************************************************************\n * Copyright (c) 2008 Labo"
  },
  {
    "path": "WUM.h",
    "chars": 694,
    "preview": "/*\n * WUM.h - WTP Update Messages\n *\n *\n * 4/11/2009 - Donato Capitella (d.capitella@gmail.com)\n */\n\n#ifndef WUM_H\n#defi"
  },
  {
    "path": "capwap_bugfix_0.01",
    "chars": 4179,
    "preview": "\n  ___                    ____                               \n / _ \\ _ __   ___ _ __  / ___|__ _ _ ____      ____ _ _ __"
  },
  {
    "path": "changeLog-0.92",
    "chars": 856,
    "preview": "OpenCapWap 0.92 - 27/10/2009\nDonato Capitella - d.capitella@gmail.com\n\nThis version corrects 18 bugs mainly related to r"
  },
  {
    "path": "changeLog-0.93",
    "chars": 1230,
    "preview": "OpenCapWap 0.93.3 - 02/12/2009\nDonato Capitella - d.capitella@gmail.com\n\nThis version adds a vendor specific WTP Update "
  },
  {
    "path": "changeLog-0.93.3",
    "chars": 278,
    "preview": "OpenCAPWAP 0.93.3 - 03/02/2010\nElena Agostini & Donato Capitella\n\nA bug in timerlib.c was identified and corrected. This"
  },
  {
    "path": "client.pem",
    "chars": 4308,
    "preview": "-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQDNo9iIeIifo0astEKSDLU/TsIVckZ4/K/b/8KrZ6cE6Lx7wROE\nu/QWjEXYe6nPRX80TeQ4zEe"
  },
  {
    "path": "common.h",
    "chars": 14230,
    "preview": "/*\n * wpa_supplicant/hostapd / common helper functions, etc.\n * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>\n *\n * T"
  },
  {
    "path": "config.ac",
    "chars": 896,
    "preview": "# Config File for AC. Lines beginning with # and blank lines will be ignored\n\n# HW version of the AC\n</AC_HW_VERSION> 12"
  },
  {
    "path": "config.wtp",
    "chars": 1519,
    "preview": "\n# Config File for WTP. Lines beginning with # and blank lines will be ignored\n\n# List of ACs' addresses for Discovery. "
  },
  {
    "path": "configure.ac",
    "chars": 1164,
    "preview": "AC_INIT([opencapwap], [1.0], [info@travelping.com])\nAM_INIT_AUTOMAKE([1.9 foreign silent-rules])\nAC_CONFIG_MACRO_DIR([m4"
  },
  {
    "path": "debian-install.sh",
    "chars": 296,
    "preview": "#!/bin/sh\nautoreconf -fi\nCFLAGS=\"-Os -pipe -fno-caller-saves -DCW_NO_DTLS -DWRITE_STD_OUTPUT -DCW_DEBUGGING -DNETUDP -DA"
  },
  {
    "path": "hostapd_wrapper/README.rst",
    "chars": 1635,
    "preview": "===================\nWRAPPER FOR HOSTAPD\n===================\n\nRequirements\n------------\n\n* patch\n* hostapd-1.1\n\nInstall\n-"
  },
  {
    "path": "hostapd_wrapper/hostapd-capwap.patch",
    "chars": 8649,
    "preview": "diff --git a/hostapd/Makefile b/hostapd/Makefile\nindex e46561e..b027b43 100644\n--- a/hostapd/Makefile\n+++ b/hostapd/Make"
  },
  {
    "path": "hostapd_wrapper/hostapd.conf-ac",
    "chars": 45915,
    "preview": "##### hostapd configuration file ##############################################\n# Empty lines and lines starting with # "
  },
  {
    "path": "hostapd_wrapper/hostapd.conf-wtp",
    "chars": 45919,
    "preview": "##### hostapd configuration file ##############################################\n# Empty lines and lines starting with # "
  },
  {
    "path": "hostapd_wrapper/hostapd2/README.Debian",
    "chars": 758,
    "preview": "\nInstallation steps:\n\n1. Flash a firmware with the hostapd-capwap package on a OpenWRT compatible router.\n2. Setup a Deb"
  },
  {
    "path": "hostapd_wrapper/hostapd2/hostapd-20130302-linux.patch",
    "chars": 428487,
    "preview": "diff -purN hostapd-20130302/hostapd/.config hostapd-20130302-linux/hostapd/.config\n--- hostapd-20130302/hostapd/.config\t"
  },
  {
    "path": "hostapd_wrapper/hostapd2/hostapd_linux.conf",
    "chars": 45913,
    "preview": "##### hostapd configuration file ##############################################\n# Empty lines and lines starting with # "
  },
  {
    "path": "hostapd_wrapper/hostapd2/hostapd_linux_ac.conf",
    "chars": 76,
    "preview": "ip_daemon_ac=127.0.0.1\nsock_path_ac=/tmp/ac_ipc_hostapd\nport_daemon_ac=5543\n"
  },
  {
    "path": "hostapd_wrapper/hostapd2/linux-ac.sh",
    "chars": 969,
    "preview": "#/bin/sh\ncp -f hostapd_linux.conf /etc/hostapd.conf\ncp -f hostapd_linux_ac.conf /etc/hostapd_ac.conf\napt-get -y purge li"
  },
  {
    "path": "hostapd_wrapper/hostapd_ac.conf",
    "chars": 76,
    "preview": "ip_daemon_ac=127.0.0.1\nsock_path_ac=/tmp/ac_ipc_hostapd\nport_daemon_ac=5543\n"
  },
  {
    "path": "hostapd_wrapper/hostapd_wtp.conf",
    "chars": 80,
    "preview": "ip_daemon_wtp=127.0.0.1\nport_daemon_wtp=6333\nsock_pach_wtp=/tmp/wtp_ipc_hostapd\n"
  },
  {
    "path": "hostapd_wrapper/src/capwap/capwap_mgmt_frame_ac.c",
    "chars": 2122,
    "preview": "#include \"utils/includes.h\"\n\n#include \"utils/common.h\"\n#include \"radius/radius.h\"\n#include \"drivers/driver.h\"\n#include \""
  },
  {
    "path": "hostapd_wrapper/src/capwap/capwap_mgmt_frame_ac.h",
    "chars": 400,
    "preview": "#ifndef __CAPWAP_MGMT_FRAME_AC_H\n#define __CAPWAP_MGMT_FRAME_AC_H\n\n#include \"drivers/driver.h\"\n\nint GetEapol_Frame( unsi"
  },
  {
    "path": "hostapd_wrapper/src/capwap/capwap_mgmt_frame_wtp.c",
    "chars": 3684,
    "preview": "#include \"utils/includes.h\"\n\n#include \"utils/common.h\"\n#include \"radius/radius.h\"\n#include \"drivers/driver.h\"\n#include \""
  },
  {
    "path": "hostapd_wrapper/src/capwap/capwap_mgmt_frame_wtp.h",
    "chars": 764,
    "preview": "#ifndef __CAPWAP_MGMT_FRAME_WTP_H\n#define __CAPWAP_MGMT_FRAME_WTP_H\n\n#include \"drivers/driver.h\"\n#include \"ap/hostapd.h\""
  },
  {
    "path": "hostapd_wrapper/src/capwap/file_conf_ac.h",
    "chars": 2573,
    "preview": "#define CONFIGFILE \"hostapd_ac.conf\"\n#define VARLENGTH 1024\n\nstruct config_ac {\n\tint ac_port;\n\tchar ip_ac[50];\n\tchar pat"
  },
  {
    "path": "hostapd_wrapper/src/capwap/file_conf_wtp.h",
    "chars": 2593,
    "preview": "#define CONFIGFILE \"hostapd_wtp.conf\"\n#define VARLENGTH 1024\n\nstruct config_wtp {\n\tint wtp_port;\n\tchar ip_wtp[50];\n\tchar"
  },
  {
    "path": "hostapd_wrapper/src/capwap/ipc_capwap_ac.c",
    "chars": 13340,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <string.h>\n#include <sys/types.h>\n#include <sys/socke"
  },
  {
    "path": "hostapd_wrapper/src/capwap/ipc_capwap_ac.h",
    "chars": 708,
    "preview": "#ifndef __IPC_CAPWAP_AC_H\n#define __IPC_CAPWAP_AC_H\n\ntypedef void (* WTP_frame_inject)(void *, unsigned char *, int);\n\nv"
  },
  {
    "path": "hostapd_wrapper/src/capwap/ipc_capwap_wtp.c",
    "chars": 15003,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n#include <errno.h>\n#include <string.h>\n#include <unistd.h>\n#i"
  },
  {
    "path": "hostapd_wrapper/src/capwap/ipc_capwap_wtp.h",
    "chars": 338,
    "preview": "#ifndef __IPC_CAPWAP_WTP_H\n#define __IPC_CAPWAP_WTP_H\n\ntypedef void (* WTP_frame_inject)(void *, unsigned char *, int);\n"
  },
  {
    "path": "hostapd_wrapper/src/capwap/smac_code.h",
    "chars": 3930,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "hostapd_wrapper/src/capwap/switch_8023_80211.c",
    "chars": 3807,
    "preview": "#include \"utils/includes.h\"\n\n#include \"utils/common.h\"\n#include \"radius/radius.h\"\n#include \"drivers/driver.h\"\n#include \""
  },
  {
    "path": "hostapd_wrapper/src/capwap/switch_8023_80211.h",
    "chars": 582,
    "preview": "\nint add_8022_header( unsigned char *inbuf, int inlen,  unsigned char *outbuf);\n\nint add_8023_header( unsigned char *mac"
  },
  {
    "path": "hostapd_wrapper/src/drivers/driver_capwap.c",
    "chars": 205004,
    "preview": "/*\n * Driver interaction with Linux capwap/cfg80211\n * Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi>\n * Copyright (c)"
  },
  {
    "path": "hostapd_wrapper/src/drivers/driver_capwap_wtp.c",
    "chars": 214476,
    "preview": "/*\n * Driver interaction with Linux capwap/cfg80211\n * Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi>\n * Copyright (c)"
  },
  {
    "path": "hostapd_wrapper/src/drivers/linux_ioctl_fake.c",
    "chars": 1888,
    "preview": "/*\n * Linux ioctl helper functions for driver wrappers\n * Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi>\n *\n * This pr"
  },
  {
    "path": "hostapd_wrapper/src/drivers/linux_ioctl_fake.h",
    "chars": 1054,
    "preview": "/*\n * Linux ioctl helper functions for driver wrappers\n * Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi>\n *\n * This pr"
  },
  {
    "path": "hostapd_wrapper/src/drivers/netlink_fake.c",
    "chars": 1566,
    "preview": "/*\n * Netlink helper functions for driver wrappers\n * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>\n *\n * This progra"
  },
  {
    "path": "hostapd_wrapper/src/drivers/netlink_fake.h",
    "chars": 960,
    "preview": "/*\n * Netlink helper functions for driver wrappers\n * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>\n *\n * This progra"
  },
  {
    "path": "ieee802_11_defs.h",
    "chars": 28838,
    "preview": "/*\n * IEEE 802.11 Frame type definitions\n * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>\n * Copyright (c) 2007-2008 "
  },
  {
    "path": "modifiche_daniele.txt",
    "chars": 9438,
    "preview": "ACBinding.c         : n/c\nACBinding.h         : n/c\nAC.c                : n/c\nACConfigFile.c      : n/c\nACConfigureState"
  },
  {
    "path": "modifiche_uci_frequency_2009.txt",
    "chars": 4523,
    "preview": "Capwap README 2009: Uci - Frequency\n\n    \nDISCLAIMER: If you want to realize new capabilities into the OpenCapwap Protoc"
  },
  {
    "path": "os.h",
    "chars": 15561,
    "preview": "/*\n * OS specific functions\n * Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>\n *\n * This program is free software; you"
  },
  {
    "path": "packages/FC18/x86_64/README.FC18",
    "chars": 1053,
    "preview": "\nInstallation steps:\n\n1. Flash a firmware with the hostapd-capwap package on a OpenWRT compatible router.\n2. Setup a FC1"
  },
  {
    "path": "root.pem",
    "chars": 3077,
    "preview": "-----BEGIN CERTIFICATE-----\nMIIDqzCCApOgAwIBAgIJAKFrKBWkidxvMA0GCSqGSIb3DQEBBQUAMGwxCzAJBgNV\nBAYTAlRXMRUwEwYDVQQHDAxEZWZ"
  },
  {
    "path": "server.pem",
    "chars": 2920,
    "preview": "-----BEGIN CERTIFICATE-----\nMIIDaDCCAlCgAwIBAgIJAJI6srPP97u0MA0GCSqGSIb3DQEBBQUAMGwxCzAJBgNV\nBAYTAlRXMRUwEwYDVQQHDAxEZWZ"
  },
  {
    "path": "settings.ac.txt",
    "chars": 435,
    "preview": "# Settings File for AC. Lines beginning with # and blank lines will be ignored\n#\n#\n#\n<CWMIN_VOICE>       2   \n<CWMAX_VOI"
  },
  {
    "path": "settings.wtp.txt",
    "chars": 539,
    "preview": "# Settings File for WTP. Lines beginning with # and blank lines will be ignored\n#\n\n#\n<IF_NAME>    mon.wlan0\n<WTP_ETH_IF_"
  },
  {
    "path": "smac_code.h",
    "chars": 4097,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "tap.c",
    "chars": 1853,
    "preview": "/*\n * Documentation/networking/tuntap.txt\n *\n */\n\n#include \"CWAC.h\"\n#include \"CWVendorPayloads.h\"\n#include \"CWFreqPayloa"
  },
  {
    "path": "tap.h",
    "chars": 2512,
    "preview": "/*******************************************************************************************\n * Copyright (c) 2006-7 Lab"
  },
  {
    "path": "timerlib.c",
    "chars": 11493,
    "preview": "/*\n * Copyright (C) 2008\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the term"
  },
  {
    "path": "timerlib.h",
    "chars": 2963,
    "preview": "/*\n * Copyright (C) 2008\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the term"
  },
  {
    "path": "wireless_copy.h",
    "chars": 41774,
    "preview": "/* This is based on Linux Wireless Extensions header file from WIRELESS_EXT 18.\n * I have just removed kernel related he"
  },
  {
    "path": "wum/README",
    "chars": 362,
    "preview": "WUM - WTP Update Manager\n\nWum (WTP Update Manager) is the command line tool used to send update\nrequests to the WTPs. Of"
  },
  {
    "path": "wum/wum.c",
    "chars": 9281,
    "preview": "#include <stdio.h>\n#include <sys/mman.h>\n#include <fcntl.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <stdli"
  },
  {
    "path": "wum/wumLib.c",
    "chars": 12425,
    "preview": "#include <stdio.h>\n#include <sys/socket.h>\n#include <arpa/inet.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unis"
  },
  {
    "path": "wum/wumLib.h",
    "chars": 1157,
    "preview": "\n#include <stdio.h>\n\n#define QUIT_MSG 0\n#define LIST_MSG 1\n#define CONF_UPDATE_MSG 2\n\n#define MSG_ELEMENT_TYPE_VENDOR_WU"
  }
]

// ... and 7 more files (download for full content)

About this extraction

This page contains the full source code of the iosifpeterfi/openCAPWAP-OpenWRT GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 167 files (2.2 MB), approximately 579.5k tokens, and a symbol index with 1646 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!