Compare commits
	
		
			28 Commits
		
	
	
		
			master
			...
			1e8b52fd03
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1e8b52fd03 | |||
| 2f1985b821 | |||
| 27506fa788 | |||
| 5ed35979cd | |||
| 2064f7dba1 | |||
| 190c94ded4 | |||
| 4fe2bae7f7 | |||
| 89e7e61e1d | |||
| 2b055175c7 | |||
| 0ebac6c98e | |||
| 15e363f34e | |||
| 2b6dc68ee5 | |||
| e39f4eb097 | |||
| 4ef1b69f83 | |||
| a77023165b | |||
| 62616b5e7b | |||
| 79b688c38e | |||
| 4995cac9b8 | |||
| d7c826fac6 | |||
| d668e0e5a7 | |||
| 63cb0b928f | |||
| 361e9dd1aa | |||
| 3f69dbf67e | |||
| 43b75502f7 | |||
| 4a565efff1 | |||
| 54955daff4 | |||
| 4047707fa8 | |||
| 5b1690bfbf | 
							
								
								
									
										22
									
								
								INSTALL
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								INSTALL
									
									
									
									
									
								
							@ -31,27 +31,5 @@ bmake
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RUN 
 | 
					 | 
				
			||||||
---
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Test start the ac with some debugging:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cd src/ac
 | 
					 | 
				
			||||||
export LD_LIBRARY_PATH=../../lib/<os name>/<arch>
 | 
					 | 
				
			||||||
./actube -d std -d info
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Connect shell to the running AC:
 | 
					 | 
				
			||||||
cd src/ac
 | 
					 | 
				
			||||||
./act -s 127.0.0.1:5000
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Some shell cmds:
 | 
					 | 
				
			||||||
list - list joined APs
 | 
					 | 
				
			||||||
select <name> - select an AP
 | 
					 | 
				
			||||||
cfg - show cfg  of selected AC
 | 
					 | 
				
			||||||
ucfg - show current update cfg
 | 
					 | 
				
			||||||
set <key:bal> - set value in ucfg
 | 
					 | 
				
			||||||
send - send ucfg to AC
 | 
					 | 
				
			||||||
clear - clear ucfg
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,35 +0,0 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					 | 
				
			||||||
<CodeLite_Workspace Name="actube" Database="">
 | 
					 | 
				
			||||||
  <Project Name="ac" Path="ac.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="wtp" Path="wtp.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_cisco" Path="mod_cisco.project" Active="Yes"/>
 | 
					 | 
				
			||||||
  <Project Name="libcw" Path="libcw.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
 | 
					 | 
				
			||||||
  <BuildMatrix>
 | 
					 | 
				
			||||||
    <WorkspaceConfiguration Name="Debug" Selected="yes">
 | 
					 | 
				
			||||||
      <Environment/>
 | 
					 | 
				
			||||||
      <Project Name="ac" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="wtp" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_cipwap" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_capwap" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_cisco" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="libcw" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_capwap80211" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_fortinet" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
    </WorkspaceConfiguration>
 | 
					 | 
				
			||||||
    <WorkspaceConfiguration Name="Release" Selected="yes">
 | 
					 | 
				
			||||||
      <Environment/>
 | 
					 | 
				
			||||||
      <Project Name="ac" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="wtp" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_cipwap" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_capwap" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_cisco" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="libcw" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_capwap80211" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_fortinet" ConfigName="Release"/>
 | 
					 | 
				
			||||||
    </WorkspaceConfiguration>
 | 
					 | 
				
			||||||
  </BuildMatrix>
 | 
					 | 
				
			||||||
</CodeLite_Workspace>
 | 
					 | 
				
			||||||
@ -31,6 +31,10 @@ INCL_DIRS=-I../ -I/usr/local/include -I./ -I../../include
 | 
				
			|||||||
#FLAGS=-DWITH_IPV6 -DWITH_OPENSSL -DSYS_ARCH="$(ARCH)" -DSYS_ARCH="XXX"
 | 
					#FLAGS=-DWITH_IPV6 -DWITH_OPENSSL -DSYS_ARCH="$(ARCH)" -DSYS_ARCH="XXX"
 | 
				
			||||||
FLAGS=-DWITH_IPV6 -DUSE_OPENSSL -DSYS_ARCH='"$(KERNEL)/$(ARCH)"'
 | 
					FLAGS=-DWITH_IPV6 -DUSE_OPENSSL -DSYS_ARCH='"$(KERNEL)/$(ARCH)"'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					all: act actube
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					act: act.c
 | 
				
			||||||
 | 
						$(CC) act.c $(INCL_DIRS) $(LIBPATH) -DSYS_ARCH='"$(KERNEL)/$(ARCH)"' -o act -l:libcw.a -lasan -lcrypto -ledit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -43,8 +47,9 @@ all: $(PRG) $(ACTPRG)
 | 
				
			|||||||
$(PRG): $(OBJS) 
 | 
					$(PRG): $(OBJS) 
 | 
				
			||||||
	$(CC) $(OBJS) -o $(PRG) $(LIBPATH) $(LDFLAGS) $(LIBS) 
 | 
						$(CC) $(OBJS) -o $(PRG) $(LIBPATH) $(LDFLAGS) $(LIBS) 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(ACTPRG): $(ACTOBJS)
 | 
					#$(ACTPRG): $(ACTOBJS)
 | 
				
			||||||
	$(CC) $(ACTOBJS) -o $(ACTPRG) $(LIBPATH) $(LDFLAGS) $(LIBS) -ledit 
 | 
					#	$(CC) $(ACTOBJS) -o $(ACTPRG) $(LIBPATH) $(LIBS) -ledit  
 | 
				
			||||||
 | 
						#$(CC) $(ACTOBJS) $(ACTPRG) $(LIBPATH) $(LDFLAGS) $(LIBS) -ledit  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -225,6 +225,10 @@ int main (int argc, char *argv[])
 | 
				
			|||||||
		goto errX;
 | 
							goto errX;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//const char *ttt = cw_cfg_get(global_cfg,"cisco/ssl-cipher",NULL);
 | 
				
			||||||
 | 
					//printf("CFG: %s\n",ttt);
 | 
				
			||||||
 | 
					//stop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_log_name = "AC-Tube";
 | 
						cw_log_name = "AC-Tube";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 | 
				
			|||||||
@ -15,10 +15,18 @@ capwap/ssl-dhbits: 1024
 | 
				
			|||||||
capwap/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
					capwap/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
				
			||||||
capwap/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
					capwap/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cisco/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
					#mod/cisco/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
				
			||||||
cisco/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
					#mod/cisco/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
				
			||||||
cisco/ssl-cipher: DEFAULT
 | 
					#
 | 
				
			||||||
cisco/ssl-dhbits: 2048
 | 
					mod/cisco/ssl-keyfile:  "../../ssl/certs/ac-cisco.key"
 | 
				
			||||||
 | 
					mod/cisco/ssl-certfile: "../../ssl/certs/ac-cisco.pem"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#cisco/ssl-cipher: DEFAULT
 | 
				
			||||||
 | 
					mod/cisco/ssl-cipher: RSA
 | 
				
			||||||
 | 
					mod/cisco/ssl-dhbits: 2048
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 
 | 
					# 
 | 
				
			||||||
@ -43,6 +51,7 @@ actube/mod.2: capwap80211
 | 
				
			|||||||
#actube/rpc/listen: unix:/tmp/actube
 | 
					#actube/rpc/listen: unix:/tmp/actube
 | 
				
			||||||
actube/rpc/listen: tcp:127.0.0.1:5000
 | 
					actube/rpc/listen: tcp:127.0.0.1:5000
 | 
				
			||||||
actube/rpc/enable: true
 | 
					actube/rpc/enable: true
 | 
				
			||||||
 | 
					actube/rpc/macros-dir: ./rpc-macros
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
capwap/ac-descriptor/dtls-policy:  1
 | 
					capwap/ac-descriptor/dtls-policy:  1
 | 
				
			||||||
@ -59,17 +68,100 @@ capwap/ac-descriptor/station-limit: 1000
 | 
				
			|||||||
capwap/ac-descriptor/stations: 0
 | 
					capwap/ac-descriptor/stations: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
capwap/control-ip-address/address.0: 192.168.0.24
 | 
					capwap/control-ip-address/address.0: 192.168.0.14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wlan.0/capwap80211/capability: 0
 | 
				
			||||||
 | 
					wlan.0/capwap80211/key-index: 0
 | 
				
			||||||
 | 
					wlan.0/capwap80211/key-status: 0
 | 
				
			||||||
 | 
					wlan.0/capwap80211/key: 1234
 | 
				
			||||||
 | 
					wlan.0/capwap80211/group-tcs: 123
 | 
				
			||||||
 | 
					wlan.0/capwap80211/qos: 0
 | 
				
			||||||
 | 
					wlan.0/capwap80211/auth-type: 1
 | 
				
			||||||
 | 
					wlan.0/capwap80211/mac-mode: 1
 | 
				
			||||||
 | 
					wlan.0/capwap80211/tunnel-mode: 1
 | 
				
			||||||
 | 
					wlan.0/capwap80211/suppress-ssid: false
 | 
				
			||||||
 | 
					wlan.0/capwap80211/ssid: ssid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# CAPWAP Timers
 | 
					# CAPWAP Timers
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
capwap/timers/change-state-pending-timer: Word: 3
 | 
					capwap/timers/change-state-pending-timer: 3
 | 
				
			||||||
capwap/timers/data-check-timer: Word: 10
 | 
					capwap/timers/data-check-timer: 10
 | 
				
			||||||
capwap/timers/echo-interval :Byte: 30
 | 
					capwap/timers/echo-interval: 30
 | 
				
			||||||
capwap/timers/max-discovery-interval :Byte: 10
 | 
					capwap/timers/max-discovery-interval: 10
 | 
				
			||||||
 | 
					capwap/decryption-error-report-period: 120
 | 
				
			||||||
 | 
					capwap/idle-timeout: 300
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/cfg-type: 1
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/country-str1: "DE "
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/country-str2: "DE "
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/occupancy-limit: 100
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/reg: 167772416
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/direct-sequence-control/cfg-type: 1 - global
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/direct-sequence-control/current-cca-mode: 0
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/direct-sequence-control/current-channel: 1
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/direct-sequence-control/energy-detect-threshold: -50
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#mode-802.11g support
 | 
				
			||||||
 | 
					#radio-cfg-a/cisco/direct-sequence-control/unknown: 1     
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/fragmentation-threshold: 2346
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/long-retry: 4
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/reserved: 1
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/rts-threshold: 2347
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/rx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/short-retry: 7
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/tx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/multi-domain-capability/first-channel: 1
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/multi-domain-capability/max-tx-power-level: 65535
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/multi-domain-capability/number-of-channels: 13
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/multi-domain-capability/reserved: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/rate-set: .x82848b960c1218243048606c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/802-11n-rx-antennas: 3
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/802-11n-tx-antennas: 7
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/antenna-cnt: 2
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/antenna-mode: 3
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/antenna.0: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/antenna.1: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/diversity-selection: 255
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/unknown: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/cfg-type: 1
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/country-str1: "DE "
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/country-str2: "DE "
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/occupancy-limit: 100
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/reg: 167772416
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										487
									
								
								src/ac/db.c
									
									
									
									
									
								
							
							
						
						
									
										487
									
								
								src/ac/db.c
									
									
									
									
									
								
							@ -1,487 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include <sqlite3.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw/log.h"
 | 
					 | 
				
			||||||
#include "cw/dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw/conn.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "conf.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static sqlite3 *handle;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static const char * init_tables = "\
 | 
					 | 
				
			||||||
	CREATE TABLE IF NOT EXISTS acs (acid TEXT PRIMARY KEY, acname TEXT, lastseen TIMESTAMP); \
 | 
					 | 
				
			||||||
	CREATE TABLE IF NOT EXISTS radios (\
 | 
					 | 
				
			||||||
		wtpid TEXT,\
 | 
					 | 
				
			||||||
		rid TEXT,\
 | 
					 | 
				
			||||||
		key TEXT,\
 | 
					 | 
				
			||||||
		sub_key,\
 | 
					 | 
				
			||||||
		val TEXT, \
 | 
					 | 
				
			||||||
		upd INTEGER, \
 | 
					 | 
				
			||||||
		PRIMARY KEY (wtpid,rid,key,sub_key)\
 | 
					 | 
				
			||||||
	);\
 | 
					 | 
				
			||||||
	CREATE TABLE IF NOT EXISTS acips (acid TEXT,ip TEXT); \
 | 
					 | 
				
			||||||
	CREATE TABLE IF NOT EXISTS wtps (wtpid TEXT PRIMARY KEY, acid TEXT,lastseen TIMESTAMP); \
 | 
					 | 
				
			||||||
	CREATE TABLE IF NOT EXISTS wtpprops (\
 | 
					 | 
				
			||||||
		wtpid TEXT NOT NULL,\
 | 
					 | 
				
			||||||
		id TEXT NOT NULL,\
 | 
					 | 
				
			||||||
		sub_id TEXT NOT NULL,\
 | 
					 | 
				
			||||||
		val TEXT,\
 | 
					 | 
				
			||||||
		upd INTEGER,\
 | 
					 | 
				
			||||||
		PRIMARY KEY(wtpid,id,sub_id)\
 | 
					 | 
				
			||||||
	);\
 | 
					 | 
				
			||||||
	CREATE TABLE IF NOT EXISTS wlans (wlanid INTEGER PRIMARY KEY);\
 | 
					 | 
				
			||||||
	CREATE TABLE IF NOT EXISTS wlanprops (wlanid INTEGER, id TEXT NOT NULL, val TEXT, PRIMARY KEY(wlanid,id));\
 | 
					 | 
				
			||||||
	";
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int db_init()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int rc;
 | 
					 | 
				
			||||||
	const char * filename="ac.sqlite3";
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO,"Initializing Sqlite3 DB: %s, SQLite3 Version %s",filename,SQLITE_VERSION);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = sqlite3_config(SQLITE_CONFIG_SERIALIZED);
 | 
					 | 
				
			||||||
	if (rc!=SQLITE_OK){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Error configuring SQLite3: %s",sqlite3_errmsg(handle)); 
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	} 
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	rc = sqlite3_initialize();
 | 
					 | 
				
			||||||
	if (rc!=SQLITE_OK){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Error initializing SQLite3 DB : %s",sqlite3_errmsg(handle)); 
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	} 
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	rc = sqlite3_open(filename,&handle);
 | 
					 | 
				
			||||||
	if (rc != SQLITE_OK)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Error opening SQLite3 DB %s: %s",filename,sqlite3_errmsg(handle)); 
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	const char * cmd = init_tables;
 | 
					 | 
				
			||||||
	rc = sqlite3_exec(handle,cmd,0,0,0);
 | 
					 | 
				
			||||||
	if (rc)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		const char *em = sqlite3_errmsg(handle);
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Error executing SQL \"%s\"\nSQL Error Message: %s",cmd, em);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static sqlite3_stmt * ping_stmt;
 | 
					 | 
				
			||||||
static sqlite3_stmt * put_wtp_prop_stmt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static sqlite3_stmt * get_tasks_stmt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static sqlite3_stmt * stmt_get_radio_tasks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static sqlite3_stmt * stmt_ping_wtp;
 | 
					 | 
				
			||||||
static sqlite3_stmt * stmt_put_radio_prop;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int db_start()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO,"Starting Sqlite3 DB");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	const char *sql="";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sqlite3_stmt *stmt;
 | 
					 | 
				
			||||||
	int rc = sqlite3_prepare_v2(handle, "INSERT OR REPLACE INTO acs (acid,acname) VALUES (?,?);",-1,&stmt,0);
 | 
					 | 
				
			||||||
	if (rc)
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = sqlite3_bind_text(stmt,1,conf_acid,-1,SQLITE_STATIC);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = sqlite3_bind_text(stmt,2,conf_acname,-1,SQLITE_STATIC);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sqlite3_step(stmt);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = sqlite3_prepare_v2(handle, "UPDATE acs SET lastseen=datetime('now') WHERE acid=?;",-1,&ping_stmt,0);
 | 
					 | 
				
			||||||
	rc = sqlite3_bind_text(ping_stmt,1,conf_acid,-1,SQLITE_STATIC);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Prepare statement to update a WTP property */
 | 
					 | 
				
			||||||
	sql = "INSERT OR REPLACE INTO wtpprops\
 | 
					 | 
				
			||||||
                (wtpid,id,sub_id,val,upd)\
 | 
					 | 
				
			||||||
                VALUES (?,?,?,?,?)";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = sqlite3_prepare_v2(handle, sql,-1, &put_wtp_prop_stmt,0);
 | 
					 | 
				
			||||||
	if (rc) 
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sql = "INSERT OR REPLACE INTO radios\
 | 
					 | 
				
			||||||
	       (wtpid,rid,key,sub_key,val,upd)\
 | 
					 | 
				
			||||||
	       VALUES (?,?,?,?,?,0)";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = sqlite3_prepare_v2(handle, sql,-1, &stmt_put_radio_prop,0);
 | 
					 | 
				
			||||||
	if (rc) 
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Prepare WTP ping statement */
 | 
					 | 
				
			||||||
	sql = "INSERT OR REPLACE INTO wtps  (wtpid,acid,lastseen) VALUES(?,?,datetime('now'))";
 | 
					 | 
				
			||||||
	rc = sqlite3_prepare_v2(handle, sql,-1, &stmt_ping_wtp,0);
 | 
					 | 
				
			||||||
	if (rc) 
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	sql = "SELECT wtpid,id,sub_id,val FROM wtpprops WHERE upd>0 AND wtpid=?";
 | 
					 | 
				
			||||||
	rc = sqlite3_prepare_v2(handle, sql,-1, &get_tasks_stmt,0);
 | 
					 | 
				
			||||||
	if (rc) 
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
	sql = "SELECT wtpid,rid,key,sub_key,val FROM radios WHERE upd>0 AND wtpid=?";
 | 
					 | 
				
			||||||
	rc = sqlite3_prepare_v2(handle, sql,-1, &stmt_get_radio_tasks,0);
 | 
					 | 
				
			||||||
	if (rc) 
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
errX:
 | 
					 | 
				
			||||||
	cw_log(LOG_ERR,"Fatal: Can't start Sqlite3 DB, Error while executing '%s' - %d - %s",sql,rc,sqlite3_errmsg(handle));
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void db_put_radio_prop(const char *wtp_id,const char *rid, const char * key,const char *sub_key,const char * val)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int rc=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*//	DBGX("Putting %s/%s:%s",id,sub_id,val);
 | 
					 | 
				
			||||||
//	       (wtpid,rid,key,sub_key,val,upd)
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	sqlite3_reset(stmt_put_radio_prop);
 | 
					 | 
				
			||||||
	sqlite3_clear_bindings(stmt_put_radio_prop);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(sqlite3_bind_text(stmt_put_radio_prop,1,wtp_id,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if(sqlite3_bind_text(stmt_put_radio_prop,2,rid,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (sqlite3_bind_text(stmt_put_radio_prop,3,key,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	if (!sub_key) 
 | 
					 | 
				
			||||||
		sub_key=CW_ITEM_NONE;
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	if (sqlite3_bind_text(stmt_put_radio_prop,4,sub_key,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (sqlite3_bind_text(stmt_put_radio_prop,5,val,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
//	if (sqlite3_bind_int(put_wtp_prop_stmt,5,0))
 | 
					 | 
				
			||||||
//		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	cw_dbg(DBG_X,"Her I am already, next is step");
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	rc = sqlite3_step(stmt_put_radio_prop);
 | 
					 | 
				
			||||||
	if (rc != SQLITE_DONE)
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
//	cw_dbg(DBG_X,"SQL schould be fine");
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	return;
 | 
					 | 
				
			||||||
errX:
 | 
					 | 
				
			||||||
/*//	cw_dbg (DBG_X, "Iam on err %d\n",rc);*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (rc) {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't update database with WTP props: %d - %s",
 | 
					 | 
				
			||||||
			rc,sqlite3_errmsg(handle));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void db_ping()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int rc = sqlite3_step(ping_stmt);
 | 
					 | 
				
			||||||
	if (rc!=SQLITE_DONE){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Error: Can't ping database, error code %d - %s",rc,sqlite3_errmsg(handle));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void db_ping_wtp(const char *wtpid,const char *acid)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int rc=0;
 | 
					 | 
				
			||||||
	sqlite3_reset(stmt_ping_wtp);
 | 
					 | 
				
			||||||
	sqlite3_clear_bindings(stmt_ping_wtp);
 | 
					 | 
				
			||||||
	if(sqlite3_bind_text(stmt_ping_wtp,1,wtpid,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if(sqlite3_bind_text(stmt_ping_wtp,2,acid,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = sqlite3_step(stmt_ping_wtp);
 | 
					 | 
				
			||||||
errX:
 | 
					 | 
				
			||||||
	if (rc!=SQLITE_DONE) {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't ping database for WTP: %d - %s",
 | 
					 | 
				
			||||||
			rc,sqlite3_errmsg(handle));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void db_put_wtp_prop(const char *wtp_id,const char * id,const char *sub_id,const char * val)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int rc=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*//	DBGX("Putting %s/%s:%s",id,sub_id,val);
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sqlite3_reset(put_wtp_prop_stmt);
 | 
					 | 
				
			||||||
	sqlite3_clear_bindings(put_wtp_prop_stmt);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(sqlite3_bind_text(put_wtp_prop_stmt,1,wtp_id,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if(sqlite3_bind_text(put_wtp_prop_stmt,2,id,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	if (!sub_id) 
 | 
					 | 
				
			||||||
		sub_id=CW_ITEM_NONE;
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (sqlite3_bind_text(put_wtp_prop_stmt,3,sub_id,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (sqlite3_bind_text(put_wtp_prop_stmt,4,val,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (sqlite3_bind_int(put_wtp_prop_stmt,5,0))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*//	cw_dbg(DBG_X,"Her I am already, next is step");
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	rc = sqlite3_step(put_wtp_prop_stmt);
 | 
					 | 
				
			||||||
	if (rc != SQLITE_DONE)
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
//	cw_dbg(DBG_X,"SQL schould be fine");
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	return;
 | 
					 | 
				
			||||||
errX:
 | 
					 | 
				
			||||||
/*//	cw_dbg (DBG_X, "Iam on err %d\n",rc);*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (rc) {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't update database with WTP props: %d - %s",
 | 
					 | 
				
			||||||
			rc,sqlite3_errmsg(handle));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*// TODO XXXX*/
 | 
					 | 
				
			||||||
mavl_t db_get_update_tasks(struct conn * conn,const char * wtpid)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
	sqlite3_reset(get_tasks_stmt);
 | 
					 | 
				
			||||||
	sqlite3_clear_bindings(get_tasks_stmt);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mavl_conststr_t r = mavl_create_conststr();
 | 
					 | 
				
			||||||
	if (!r)
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int rc=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(sqlite3_bind_text(get_tasks_stmt,1,wtpid,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	while (SQLITE_ROW == sqlite3_step(get_tasks_stmt)) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		int ii;
 | 
					 | 
				
			||||||
		//DBGX("-----------------------------------------------------","");
 | 
					 | 
				
			||||||
		for (ii=0; ii<5; ii++){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			//DBGX("CVALL: %s",(const char*)sqlite3_column_text(get_tasks_stmt,ii));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		const char *id =  (const char*)sqlite3_column_text(get_tasks_stmt,1);
 | 
					 | 
				
			||||||
		if (!id) {
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		const char *sub_id =  (const char*)sqlite3_column_text(get_tasks_stmt,2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		const char *val =  (const char*)sqlite3_column_text(get_tasks_stmt,3);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//DBGX("ID: (%s), SubID (%s), Val (%s)",id,sub_id,val);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		const struct cw_itemdef * cwi = cw_itemdef_get(conn->actions->items,id,sub_id);
 | 
					 | 
				
			||||||
		if (!cwi) {
 | 
					 | 
				
			||||||
			//DBGX("Not item definition found for: %s/%s",id,sub_id);
 | 
					 | 
				
			||||||
			continue;	
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//uint8_t data[2048];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!cwi->type->from_str) {
 | 
					 | 
				
			||||||
			cw_log(LOG_ERR,"Can't convert from string %s/%s - No method defined.",id,sub_id);
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		mbag_item_t * i = cwi->type->from_str(val);
 | 
					 | 
				
			||||||
		i->id=cwi->id;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		mbag_set(conn->outgoing,i);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		mavl_add(r,(void*)cwi->id);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (r->count)
 | 
					 | 
				
			||||||
		return r;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	mavl_destroy(r);
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
errX:
 | 
					 | 
				
			||||||
	if (rc) {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't get tasks: %d - %s",
 | 
					 | 
				
			||||||
			rc,sqlite3_errmsg(handle));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (r)
 | 
					 | 
				
			||||||
		mavl_destroy(r);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
mavl_t db_get_radio_tasks(struct conn * conn,const char * wtpid)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
//cw_dbg(DBG_X,"Get Radio Tasks for  %s",wtpid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sqlite3_reset(stmt_get_radio_tasks);
 | 
					 | 
				
			||||||
	sqlite3_clear_bindings(stmt_get_radio_tasks);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mavl_conststr_t r = mavl_create_conststr();
 | 
					 | 
				
			||||||
	if (!r)
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int rc=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(sqlite3_bind_text(stmt_get_radio_tasks,1,wtpid,-1,SQLITE_STATIC))
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	while (SQLITE_ROW == sqlite3_step(stmt_get_radio_tasks)) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		int ii;
 | 
					 | 
				
			||||||
		//DBGX("-----------------------------------------------------","");
 | 
					 | 
				
			||||||
		for (ii=0; ii<6; ii++){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			DBGX("CVALL: %s",(const char*)sqlite3_column_text(stmt_get_radio_tasks,ii));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		const char *strrid=  (const char*)sqlite3_column_text(stmt_get_radio_tasks,1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		const char *id =  (const char*)sqlite3_column_text(stmt_get_radio_tasks,2);
 | 
					 | 
				
			||||||
		if (!id) {
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		const char *sub_id =  (const char*)sqlite3_column_text(stmt_get_radio_tasks,3);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		const char *val =  (const char*)sqlite3_column_text(stmt_get_radio_tasks,4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//DBGX("ID: (%s), SubID (%s), Val (%s)",id,sub_id,val);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		const struct cw_itemdef * cwi = cw_itemdef_get(conn->actions->radioitems,id,sub_id);
 | 
					 | 
				
			||||||
		if (!cwi) {
 | 
					 | 
				
			||||||
			DBGX("No item definition found for: %s/%s",id,sub_id);
 | 
					 | 
				
			||||||
			continue;	
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!cwi->type->from_str) {
 | 
					 | 
				
			||||||
			cw_log(LOG_ERR,"Can't convert from string %s/%s - No method defined.",id,sub_id);
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		mbag_item_t * i = cwi->type->from_str(val);
 | 
					 | 
				
			||||||
		i->id=cwi->id;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		int rid = atoi(strrid);			
 | 
					 | 
				
			||||||
		cw_dbg(DBG_X,"RID: %d",rid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		mbag_t radio = mbag_i_get_mbag_c(conn->radios_upd,rid,mbag_create);
 | 
					 | 
				
			||||||
		mbag_set(radio,i);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//mbag_set(conn->outgoing,i);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		mavl_add(r,(void*)cwi->id);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (r->count)
 | 
					 | 
				
			||||||
		return r;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	mavl_destroy(r);
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
errX:
 | 
					 | 
				
			||||||
	if (rc) {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't get tasks: %d - %s",
 | 
					 | 
				
			||||||
			rc,sqlite3_errmsg(handle));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (r)
 | 
					 | 
				
			||||||
		mavl_destroy(r);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							
								
								
									
										21
									
								
								src/ac/db.h
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/ac/db.h
									
									
									
									
									
								
							@ -1,21 +0,0 @@
 | 
				
			|||||||
#ifndef CW_MAVL_H
 | 
					 | 
				
			||||||
#define CW_MAVL_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "mavl.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern void db_ping();
 | 
					 | 
				
			||||||
extern void db_ping_wtp(const char *wtpid,const char *acid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int db_init();
 | 
					 | 
				
			||||||
int db_start();
 | 
					 | 
				
			||||||
int db_get_tasks(struct conn * conn,const char * wtpid);
 | 
					 | 
				
			||||||
void db_put_wtp_prop(const char *wtp_id,const char * id,const char *sub_id,const char * val);
 | 
					 | 
				
			||||||
mavl_t db_get_update_tasks(struct conn * conn,const char * wtpid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void db_put_radio_prop(const char *wtp_id,const char *rid, const char * key,const char *sub_key,const char * val);
 | 
					 | 
				
			||||||
extern mavl_t db_get_radio_tasks(struct conn * conn,const char * wtpid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,29 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "module.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int init()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
//	regn = cw_register_actions_cipwap_ac(&capwap_actions);
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct ac_module module = {
 | 
					 | 
				
			||||||
	.name="Cipwap",
 | 
					 | 
				
			||||||
	.init= init,
 | 
					 | 
				
			||||||
	.detect_by_discovery = 0
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct ac_module * mod_cipwap()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return &module;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,13 +0,0 @@
 | 
				
			|||||||
#ifndef __MODULE_H
 | 
					 | 
				
			||||||
#define __MODULE_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct ac_module
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	const char *name;
 | 
					 | 
				
			||||||
	int (*init)();
 | 
					 | 
				
			||||||
	int (*detect_by_raw)(const char *msg, int len);
 | 
					 | 
				
			||||||
	int (*detect_by_discovery)(const char*);
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/led-off.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/led-off.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ap-led-state-config/led-state: 0
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/led-on.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/led-on.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ap-led-state-config/led-state: 1
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/telnet-off.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/telnet-off.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ap-telnet-ssh/telnet: false
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/telnet-on.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/telnet-on.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ap-telnet-ssh/telnet: true
 | 
				
			||||||
							
								
								
									
										18
									
								
								src/ac/rpc-macros/wlan13.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/ac/rpc-macros/wlan13.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					radio.0/wlan.13/capwap80211/capability: 1057
 | 
				
			||||||
 | 
					radio.0/wlan.13/capwap80211/qos: 0
 | 
				
			||||||
 | 
					radio.0/wlan.13/capwap80211/ssid: SuperSSID
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/aironet-ie: true
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/broadcast-ssid: true
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/dtim-period: 19
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/encryption-policy: 1
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/hreap-local-switch: 16
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/profile-name: SuerWLAN
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/scan-defer-period: 15420
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/scan-defer-time: 100
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/session-timout: 1800
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/wep-encryption: false
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/wep-key: .x55d80f0e2bf5223dd10f82407b
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/wep-key-index: 1
 | 
				
			||||||
 | 
					radio.0/wlan.13/radio-id: 0
 | 
				
			||||||
 | 
					radio.0/wlan.13/wlan-id: 13
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										212
									
								
								src/ac/rpc.c
									
									
									
									
									
								
							
							
						
						
									
										212
									
								
								src/ac/rpc.c
									
									
									
									
									
								
							@ -2,6 +2,7 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <ctype.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
#include <sys/socket.h>
 | 
					#include <sys/socket.h>
 | 
				
			||||||
@ -16,6 +17,7 @@
 | 
				
			|||||||
#include "cw/log.h"
 | 
					#include "cw/log.h"
 | 
				
			||||||
#include "cw/dbg.h"
 | 
					#include "cw/dbg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "wtpman.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cw/connlist.h"
 | 
					#include "cw/connlist.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -64,6 +66,11 @@ int wlan0_cmd(struct rpcdata *sd, const char * cmd);
 | 
				
			|||||||
int exit_cmd(struct rpcdata *sd, const char * cmd);
 | 
					int exit_cmd(struct rpcdata *sd, const char * cmd);
 | 
				
			||||||
int prompt_cmd(struct rpcdata *sd, const char * cmd);
 | 
					int prompt_cmd(struct rpcdata *sd, const char * cmd);
 | 
				
			||||||
int global_cfg_cmd(struct rpcdata *sd, const char * cmd);
 | 
					int global_cfg_cmd(struct rpcdata *sd, const char * cmd);
 | 
				
			||||||
 | 
					int status_cmd(struct rpcdata *sd, const char * cmd);
 | 
				
			||||||
 | 
					void print_mw(FILE *f, int w, const char * str);
 | 
				
			||||||
 | 
					int clear_cmd(struct rpcdata *sd, const char *cmd);
 | 
				
			||||||
 | 
					int load_cmd(struct rpcdata *sd, const char *cmd);
 | 
				
			||||||
 | 
					int save_cmd(struct rpcdata *sd, const char *cmd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//void show_cfg (FILE *out, mavl_t ktv);
 | 
					//void show_cfg (FILE *out, mavl_t ktv);
 | 
				
			||||||
int show_aps (FILE *out);
 | 
					int show_aps (FILE *out);
 | 
				
			||||||
@ -88,6 +95,11 @@ static struct command cmdlist[]={
 | 
				
			|||||||
	{"set", set_cmd },
 | 
						{"set", set_cmd },
 | 
				
			||||||
	{"wlan0",wlan0_cmd},
 | 
						{"wlan0",wlan0_cmd},
 | 
				
			||||||
	{"global_cfg", global_cfg_cmd},
 | 
						{"global_cfg", global_cfg_cmd},
 | 
				
			||||||
 | 
						{"status",status_cmd},
 | 
				
			||||||
 | 
						{"clear",clear_cmd},
 | 
				
			||||||
 | 
						{"load",load_cmd},
 | 
				
			||||||
 | 
						{"save",save_cmd},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{"@prompt",prompt_cmd},
 | 
						{"@prompt",prompt_cmd},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -112,9 +124,18 @@ int prompt_cmd(struct rpcdata *sd, const char *cmd)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int global_cfg_cmd(struct rpcdata *sd, const char *cmd)
 | 
					int global_cfg_cmd(struct rpcdata *sd, const char *str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cw_cfg_fdump(sd->out,sd->global_cfg);
 | 
						char *s;
 | 
				
			||||||
 | 
						while( isspace( *str ) )  
 | 
				
			||||||
 | 
							 str++; 
 | 
				
			||||||
 | 
						s=(char*)str;
 | 
				
			||||||
 | 
						while (!isspace(*s) && *s!=0)
 | 
				
			||||||
 | 
							s++;
 | 
				
			||||||
 | 
						*s=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_cfg_fdump(sd->out,sd->global_cfg,str);
 | 
				
			||||||
	finish_cmd(sd->out);
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -149,8 +170,18 @@ int exit_cmd(struct rpcdata *sd, const char *cmd)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cfg_cmd(struct rpcdata *sd, const char *cmd)
 | 
					int cfg_cmd(struct rpcdata *sd, const char *str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						char *s;
 | 
				
			||||||
 | 
						while( isspace( *str ) )  
 | 
				
			||||||
 | 
							 str++; 
 | 
				
			||||||
 | 
						s=(char*)str;
 | 
				
			||||||
 | 
						while (!isspace(*s) && *s!=0)
 | 
				
			||||||
 | 
							s++;
 | 
				
			||||||
 | 
						*s=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct cw_Conn * conn;
 | 
						struct cw_Conn * conn;
 | 
				
			||||||
	wtplist_lock();
 | 
						wtplist_lock();
 | 
				
			||||||
	conn = find_ap(sd->prompt);
 | 
						conn = find_ap(sd->prompt);
 | 
				
			||||||
@ -158,37 +189,112 @@ int cfg_cmd(struct rpcdata *sd, const char *cmd)
 | 
				
			|||||||
		fprintf(sd->out,"WTP '%s' not found\n",sd->prompt);
 | 
							fprintf(sd->out,"WTP '%s' not found\n",sd->prompt);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		cw_cfg_fdump(sd->out,conn->remote_cfg);
 | 
							cw_cfg_fdump(sd->out,conn->remote_cfg,str);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	finish_cmd(sd->out);
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
	wtplist_unlock();
 | 
						wtplist_unlock();
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ucfg_cmd(struct rpcdata *sd, const char *cmd)
 | 
					
 | 
				
			||||||
 | 
					int status_cmd(struct rpcdata *sd, const char *cmd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
//	struct cw_Conn * conn;
 | 
						struct cw_Conn * conn;
 | 
				
			||||||
	stop();
 | 
						int i;
 | 
				
			||||||
//	show_cfg(sd->out,sd->update_cfg);
 | 
						char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wtplist_lock();
 | 
				
			||||||
 | 
						print_mw(sd->out,8,"Radio");
 | 
				
			||||||
 | 
						print_mw(sd->out,15,"Admin State");
 | 
				
			||||||
 | 
						print_mw(sd->out,15,"Oper State");
 | 
				
			||||||
 | 
						print_mw(sd->out,13,"Cause");
 | 
				
			||||||
 | 
						fprintf(sd->out,"\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						conn = find_ap(sd->prompt);
 | 
				
			||||||
 | 
						if (conn==NULL){
 | 
				
			||||||
 | 
							fprintf(sd->out,"WTP '%s' not found\n",sd->prompt);
 | 
				
			||||||
 | 
							goto errX;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						i=0;
 | 
				
			||||||
 | 
						do {
 | 
				
			||||||
 | 
							char tmp[128];
 | 
				
			||||||
 | 
							sprintf(key,"radio.%d",i);
 | 
				
			||||||
 | 
							if (!cw_cfg_base_exists(conn->remote_cfg,key))
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							sprintf(tmp,"%d",i);
 | 
				
			||||||
 | 
							print_mw(sd->out,8,tmp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							sprintf(key,"radio.%d/capwap/admin-state",i);
 | 
				
			||||||
 | 
							print_mw(sd->out,15, cw_cfg_get(conn->remote_cfg,key,"?"));
 | 
				
			||||||
 | 
							sprintf(key,"radio.%d/capwap/operational-state/state",i);
 | 
				
			||||||
 | 
							print_mw(sd->out,15, cw_cfg_get(conn->remote_cfg,key,"?"));
 | 
				
			||||||
 | 
							sprintf(key,"radio.%d/capwap/operational-state/cause",i);
 | 
				
			||||||
 | 
							print_mw(sd->out,13, cw_cfg_get(conn->remote_cfg,key,"?"));
 | 
				
			||||||
 | 
							fprintf(sd->out,"\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							i++;	
 | 
				
			||||||
 | 
						}while(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					errX:	
 | 
				
			||||||
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
 | 
						wtplist_unlock();
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int ucfg_cmd(struct rpcdata *sd, const char *str)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char *s;
 | 
				
			||||||
 | 
						while( isspace( *str ) )  
 | 
				
			||||||
 | 
							 str++; 
 | 
				
			||||||
 | 
						s=(char*)str;
 | 
				
			||||||
 | 
						while (!isspace(*s) && *s!=0)
 | 
				
			||||||
 | 
							s++;
 | 
				
			||||||
 | 
						*s=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_cfg_fdump(sd->out,sd->update_cfg,str);
 | 
				
			||||||
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int clear_cmd(struct rpcdata *sd, const char *cmd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						cw_cfg_clear(sd->update_cfg);
 | 
				
			||||||
 | 
						fprintf(sd->out,"ucfg cleard\n");
 | 
				
			||||||
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "wtpman.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
send_cmd(struct rpcdata * sd, const char *cmd)
 | 
					send_cmd(struct rpcdata * sd, const char *cmd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						struct wtpman * wtpman;
 | 
				
			||||||
	struct cw_Conn * conn;
 | 
						struct cw_Conn * conn;
 | 
				
			||||||
	wtplist_lock();
 | 
						wtplist_lock();
 | 
				
			||||||
	conn = find_ap(sd->prompt);
 | 
						conn = find_ap(sd->prompt);
 | 
				
			||||||
	if (conn==NULL){
 | 
						if (conn==NULL){
 | 
				
			||||||
		fprintf(sd->out,"WTP '%s' not found\n",sd->prompt);
 | 
							fprintf(sd->out,"WTP '%s' not found\n",sd->prompt);
 | 
				
			||||||
 | 
							goto errX;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		conn->update_cfg=sd->update_cfg;
 | 
							wtpman=conn->data;
 | 
				
			||||||
 | 
							cw_cfg_copy(sd->update_cfg,conn->update_cfg,0,NULL);
 | 
				
			||||||
 | 
							wtpman->update=1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							fprintf(sd->out, "Sending update cmd\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//		conn->update_cfg=sd->update_cfg;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					errX:	
 | 
				
			||||||
	wtplist_unlock();
 | 
						wtplist_unlock();
 | 
				
			||||||
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -217,33 +323,74 @@ int set_cmd(struct rpcdata *sd, const char *str)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t *cfg;
 | 
						cw_Cfg_t *cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cfg = cw_cfg_create();
 | 
						cfg = cw_cfg_create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_cfg_read_from_string(str,cfg);
 | 
						cw_cfg_read_from_string(str,cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_cfg_fdump(sd->out,cfg);
 | 
						cw_cfg_fdump(sd->out,cfg,NULL);
 | 
				
			||||||
 | 
						cw_cfg_copy(cfg,sd->update_cfg,DBG_CFG_UPDATES,"rpc ucfg");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_cfg_destroy(cfg);
 | 
						cw_cfg_destroy(cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	finish_cmd(sd->out);
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
 | 
					 | 
				
			||||||
//	cw_ktv_init_str_reader(&r,str,strlen(str));
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	cw_ktv_parse_string(&r,key,type,val);
 | 
					 | 
				
			||||||
	/*cw_ktv_parse_string(key,type,val, 2048);*/
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	fprintf(sd->out,"%s %s\n",key,val);
 | 
					 | 
				
			||||||
//	cw_ktv_add(sd->update_cfg,key,CW_TYPE_STR,NULL,val,strlen(val));
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int load_cmd(struct rpcdata *sd, const char *str)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char fn[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
						const char * dir=cw_cfg_get(sd->global_cfg,"actube/rpc/macros-dir","./rpc-macros");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sprintf(fn,"%s/%s.ckv",dir,str);
 | 
				
			||||||
 | 
						rc= cw_cfg_load(fn,sd->update_cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (rc){
 | 
				
			||||||
 | 
							fprintf(sd->out,"Error loading %s: %s\n",fn,strerror(rc));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int save_cmd(struct rpcdata *sd, const char *str)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char fn[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
						const char * dir=cw_cfg_get(sd->global_cfg,"actube/rpc/macros-dir","./rpc-macros");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sprintf(fn,"%s/%s.ckv",dir,str);
 | 
				
			||||||
 | 
						rc= cw_cfg_save(fn,sd->update_cfg,"#\n# Managed by acTube\n#\n\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (rc){
 | 
				
			||||||
 | 
							fprintf(sd->out,"Error saving %s: %s\n",fn,strerror(rc));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int del_cmd(struct rpcdata *sd, const char *str)
 | 
					int del_cmd(struct rpcdata *sd, const char *str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char key[CW_CFG_MAX_KEY_LEN];
 | 
						char *s;
 | 
				
			||||||
	sscanf(str,"%s",key);
 | 
					
 | 
				
			||||||
	stop();
 | 
						while( isspace( *str ) )  
 | 
				
			||||||
//	cw_ktv_del_sub(sd->update_cfg,key);
 | 
							 str++; 
 | 
				
			||||||
//
 | 
						s=(char*)str;
 | 
				
			||||||
 | 
						while (!isspace(*s) && *s!=0)
 | 
				
			||||||
 | 
							s++;
 | 
				
			||||||
 | 
						*s=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fprintf(sd->out,"DEL: '%s'\n",str);
 | 
				
			||||||
 | 
						cw_cfg_del(sd->update_cfg,str);
 | 
				
			||||||
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -450,7 +597,19 @@ int execute_cmd (struct rpcdata * sd, const char *str)
 | 
				
			|||||||
	searchcmd = find_cmd(cmd);
 | 
						searchcmd = find_cmd(cmd);
 | 
				
			||||||
	if (searchcmd!=NULL){
 | 
						if (searchcmd!=NULL){
 | 
				
			||||||
		if (searchcmd->fun != NULL){
 | 
							if (searchcmd->fun != NULL){
 | 
				
			||||||
			return searchcmd->fun(sd, str+strlen(cmd));
 | 
								char *args;
 | 
				
			||||||
 | 
								int n;
 | 
				
			||||||
 | 
							      	args = (char*)(str+strlen(cmd));
 | 
				
			||||||
 | 
								while( isspace( *args ) )  
 | 
				
			||||||
 | 
									 args++; 
 | 
				
			||||||
 | 
								n = strlen(args);
 | 
				
			||||||
 | 
								n--;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								while (n>=0 && isspace(args[n]))
 | 
				
			||||||
 | 
									n--;
 | 
				
			||||||
 | 
								args[n+1]=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								return searchcmd->fun(sd, args);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else{
 | 
						else{
 | 
				
			||||||
@ -540,6 +699,7 @@ void rpc_loop (FILE *file, cw_Cfg_t *global_cfg)
 | 
				
			|||||||
	sd.in = file;
 | 
						sd.in = file;
 | 
				
			||||||
	sd.out = file;	
 | 
						sd.out = file;	
 | 
				
			||||||
	sd.global_cfg=global_cfg;
 | 
						sd.global_cfg=global_cfg;
 | 
				
			||||||
 | 
						sd.update_cfg=cw_cfg_create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sprintf(sd.prompt,"%s","*");
 | 
						sprintf(sd.prompt,"%s","*");
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										190
									
								
								src/ac/wtpman.c
									
									
									
									
									
								
							
							
						
						
									
										190
									
								
								src/ac/wtpman.c
									
									
									
									
									
								
							@ -298,6 +298,18 @@ int cw_run_state_machine(struct cw_Conn *conn, time_t * timer)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/*#define CW_TRANSITION(prestate,state) (prestate<<16|state)*/
 | 
					/*#define CW_TRANSITION(prestate,state) (prestate<<16|state)*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int run_update(struct wtpman *wtpman)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
						if (!wtpman->update)
 | 
				
			||||||
 | 
							return EAGAIN;
 | 
				
			||||||
 | 
						rc = cw_send_request(wtpman->conn, CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST);
 | 
				
			||||||
 | 
					        cw_cfg_clear(wtpman->conn->update_cfg);
 | 
				
			||||||
 | 
						wtpman->update=0;
 | 
				
			||||||
 | 
						return rc;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void *wtpman_main(void *arg)
 | 
					static void *wtpman_main(void *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	//mavl_t r;
 | 
						//mavl_t r;
 | 
				
			||||||
@ -343,6 +355,7 @@ static void *wtpman_main(void *arg)
 | 
				
			|||||||
	conn->capwap_prevstate = CAPWAP_STATE_DTLS_SETUP;
 | 
						conn->capwap_prevstate = CAPWAP_STATE_DTLS_SETUP;
 | 
				
			||||||
	conn->capwap_state = CAPWAP_STATE_JOIN;
 | 
						conn->capwap_state = CAPWAP_STATE_JOIN;
 | 
				
			||||||
	rc = 0;
 | 
						rc = 0;
 | 
				
			||||||
 | 
						wtpman->update=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (1) {
 | 
						while (1) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -359,59 +372,25 @@ static void *wtpman_main(void *arg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		while (!cw_timer_timeout(timer)) {
 | 
							while (!cw_timer_timeout(timer)) {
 | 
				
			||||||
 | 
								rc = run_update(wtpman);
 | 
				
			||||||
 | 
								if (rc !=EAGAIN)
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			rc = cw_read_messages(wtpman->conn);
 | 
								rc = cw_read_messages(wtpman->conn);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
			if (rc < 0) {
 | 
								if (rc < 0) {
 | 
				
			||||||
				if (errno == EAGAIN)
 | 
									if (errno == EAGAIN){
 | 
				
			||||||
					continue;
 | 
										continue;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (rc < 0) {
 | 
							if (rc < 0) {
 | 
				
			||||||
			conn->capwap_prevstate = conn->capwap_state;
 | 
								conn->capwap_prevstate = conn->capwap_state;
 | 
				
			||||||
			conn->capwap_state = CAPWAP_STATE_TIMEOUT;
 | 
								conn->capwap_state = CAPWAP_STATE_TIMEOUT;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* dtls is established, goto join state */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
	conn->capwap_state = CAPWAP_STATE_JOIN;
 | 
					 | 
				
			||||||
	if (!wtpman_join(wtpman)) {
 | 
					 | 
				
			||||||
		wtpman_remove(wtpman);
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO, "WTP from %s has joined with session id: %s",
 | 
					 | 
				
			||||||
	       sock_addr2str_p(&conn->addr, sock_buf),
 | 
					 | 
				
			||||||
	       format_bin2hex(conn->session_id, 16));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	exit(0);
 | 
						exit(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
@ -433,23 +412,10 @@ void wtpman_destroy(struct wtpman *wtpman)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void copy(struct cw_ElemHandlerParams * params)
 | 
					static void copy(struct cw_ElemHandlerParams * params)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
//	struct wtpman * wtpman;
 | 
					 | 
				
			||||||
	//struct cw_Conn * conn;
 | 
					 | 
				
			||||||
	//wtpman = (struct wtpman*)params->conn->data;
 | 
					 | 
				
			||||||
	//conn = (struct cw_Conn*)params->conn;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	cw_dbg(DBG_X,"-------------  Here is the config we ve got from WTP ---------------- ");
 | 
					 | 
				
			||||||
//	cw_cfg_dump(params->cfg);
 | 
					 | 
				
			||||||
//	cw_dbg(DBG_X,"-------------  This was the config we ve got from WTP ---------------- ");
 | 
					 | 
				
			||||||
//	cw_dbg(DBG_X,"Now copying:");
 | 
					 | 
				
			||||||
//	cw_cfg_copy(params->cfg,conn->local_cfg,0,"");
 | 
					 | 
				
			||||||
        cw_cfg_copy(params->cfg, params->conn->remote_cfg,DBG_CFG_UPDATES,"GlobalCfg");
 | 
					        cw_cfg_copy(params->cfg, params->conn->remote_cfg,DBG_CFG_UPDATES,"GlobalCfg");
 | 
				
			||||||
 | 
					 | 
				
			||||||
//	cw_dbg(DBG_X,"Copying done.");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int discovery_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data * d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
				
			||||||
	char filename[200];
 | 
						char filename[200];
 | 
				
			||||||
@ -465,10 +431,16 @@ static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_pt
 | 
				
			|||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int join_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					/*
 | 
				
			||||||
 | 
					static int join_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
				
			||||||
	char filename[200];
 | 
						char filename[200];
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						rc = 0;
 | 
				
			||||||
 | 
						if (d->parent)
 | 
				
			||||||
 | 
							rc =d->parent->fun(params,d->parent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_X,"JOIN Callback");
 | 
						cw_dbg(DBG_X,"JOIN Callback");
 | 
				
			||||||
	copy(params);
 | 
						copy(params);
 | 
				
			||||||
@ -476,18 +448,50 @@ static int join_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, in
 | 
				
			|||||||
	sprintf(filename,"wtp-join-%s.ckv",wtpname);
 | 
						sprintf(filename,"wtp-join-%s.ckv",wtpname);
 | 
				
			||||||
	cw_cfg_save(filename,params->cfg,NULL);
 | 
						cw_cfg_save(filename,params->cfg,NULL);
 | 
				
			||||||
	cw_cfg_clear(params->cfg);
 | 
						cw_cfg_clear(params->cfg);
 | 
				
			||||||
 | 
						return rc;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					static int fill_update_cfg(struct cw_Conn * conn)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cw_Cfg_iter cfi;
 | 
				
			||||||
 | 
						struct cw_Cfg_entry *e;
 | 
				
			||||||
 | 
						cw_Cfg_t * u;
 | 
				
			||||||
 | 
						u=cw_cfg_create();
 | 
				
			||||||
 | 
						if( cw_cfg_load("status_response.ckv",u)){
 | 
				
			||||||
 | 
							cw_log(LOG_ERR,"Cant load file");
 | 
				
			||||||
 | 
							stop();
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						cw_cfg_dump(conn->remote_cfg);
 | 
				
			||||||
 | 
					        cw_cfg_iter_init(u, &cfi, NULL);
 | 
				
			||||||
 | 
						while ((e = cw_cfg_iter_next(&cfi, NULL))!=NULL){
 | 
				
			||||||
 | 
							const char * r;
 | 
				
			||||||
 | 
							r = cw_cfg_get(conn->remote_cfg, e->key, "[]");
 | 
				
			||||||
 | 
						//	cw_dbg(DBG_CFG_UPDATES,"check: %s: %s",e->key,e->val);
 | 
				
			||||||
 | 
							if (strcmp(r,e->val)==0)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cw_dbg(DBG_CFG_UPDATES,"Status reps: %s: %s -> %s",e->key,r,e->val);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int update_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
				
			||||||
	char filename[200];
 | 
						char filename[200];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int rc = 0;
 | 
				
			||||||
 | 
						if (d->parent)
 | 
				
			||||||
 | 
							rc =d->parent->fun(params,d->parent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	cw_dbg(DBG_X,"UPDATE Callback");
 | 
						cw_dbg(DBG_X,"UPDATE Callback");
 | 
				
			||||||
	copy(params);
 | 
						//fill_update_cfg(params->conn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
 | 
						const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
 | 
				
			||||||
	sprintf(filename,"wtp-status-%s.ckv",wtpname);
 | 
						sprintf(filename,"wtp-status-%s.ckv",wtpname);
 | 
				
			||||||
@ -496,9 +500,11 @@ static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr,
 | 
				
			|||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int event_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
				
			||||||
 | 
						struct wtpman * wtpman = (struct wtpman *)conn->data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char filename[200];
 | 
						char filename[200];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -507,9 +513,26 @@ static int event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, i
 | 
				
			|||||||
	copy(params);
 | 
						copy(params);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
 | 
						const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
 | 
				
			||||||
	sprintf(filename,"wtp-event-%s.ckv",wtpname);
 | 
						sprintf(filename,"wtp-event-%d-%s.ckv",wtpman->ctr++,wtpname);
 | 
				
			||||||
	cw_cfg_save(filename,conn->remote_cfg,NULL);
 | 
						cw_cfg_save(filename,params->cfg,NULL);
 | 
				
			||||||
//stop();	
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int change_state_event_cb(struct cw_ElemHandlerParams * params,struct cw_MsgCb_data * d)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
				
			||||||
 | 
						struct wtpman * wtpman = (struct wtpman *)conn->data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						char filename[200];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						cw_dbg(DBG_X,"WTP EVENT Callback");
 | 
				
			||||||
 | 
						copy(params);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
 | 
				
			||||||
 | 
						sprintf(filename,"wtp-change-event-%d-%s.ckv",wtpman->ctr++,wtpname);
 | 
				
			||||||
 | 
						cw_cfg_save(filename,params->cfg,NULL);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -530,6 +553,8 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
	if (!wtpman)
 | 
						if (!wtpman)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wtpman->ctr=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (socklist[socklistindex].type != SOCKLIST_UNICAST_SOCKET) {
 | 
						if (socklist[socklistindex].type != SOCKLIST_UNICAST_SOCKET) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		int port = sock_getport(&socklist[socklistindex].addr);
 | 
							int port = sock_getport(&socklist[socklistindex].addr);
 | 
				
			||||||
@ -565,6 +590,8 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
		wtpman_destroy(wtpman);
 | 
							wtpman_destroy(wtpman);
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wtpman->conn->global_cfg = global_cfg;
 | 
						wtpman->conn->global_cfg = global_cfg;
 | 
				
			||||||
	wtpman->conn->local_cfg = cw_cfg_create();
 | 
						wtpman->conn->local_cfg = cw_cfg_create();
 | 
				
			||||||
	wtpman->wtp_cfg = cw_cfg_create();
 | 
						wtpman->wtp_cfg = cw_cfg_create();
 | 
				
			||||||
@ -584,23 +611,6 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
	sock_copyaddr(&wtpman->conn->data_addr,
 | 
						sock_copyaddr(&wtpman->conn->data_addr,
 | 
				
			||||||
		      (struct sockaddr *) &wtpman->conn->addr);
 | 
							      (struct sockaddr *) &wtpman->conn->addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_DISCOVERY_REQUEST,
 | 
					 | 
				
			||||||
			discovery_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_JOIN_REQUEST,
 | 
					 | 
				
			||||||
			join_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,
 | 
					 | 
				
			||||||
			update_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_WTP_EVENT_REQUEST,
 | 
					 | 
				
			||||||
			event_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	wtpman->conn->mods = conf_mods;
 | 
					//	wtpman->conn->mods = conf_mods;
 | 
				
			||||||
@ -640,9 +650,33 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
//        	                wtpman->conn->setup_complete(wtpman->conn);
 | 
					//        	                wtpman->conn->setup_complete(wtpman->conn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_DISCOVERY_REQUEST,
 | 
				
			||||||
 | 
									discovery_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*		cw_conn_set_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_JOIN_REQUEST,
 | 
				
			||||||
 | 
									join_cb);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*		cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,
 | 
				
			||||||
 | 
									update_cb);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_WTP_EVENT_REQUEST,
 | 
				
			||||||
 | 
									event_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*		cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST,
 | 
				
			||||||
 | 
									change_state_event_cb);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_X,"WTPMAN_CREATED: %p",wtpman);
 | 
						cw_dbg(DBG_X,"WTPMAN_CREATED: %p",wtpman);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return wtpman;
 | 
						return wtpman;
 | 
				
			||||||
 | 
				
			|||||||
@ -40,8 +40,8 @@ struct wtpman {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t * wtp_cfg;
 | 
						cw_Cfg_t * wtp_cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						int update;	
 | 
				
			||||||
 | 
						int ctr;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 | 
				
			|||||||
@ -18,13 +18,11 @@ CWSRC=\
 | 
				
			|||||||
	cw_in_capwap_local_ipv4_address.c\
 | 
						cw_in_capwap_local_ipv4_address.c\
 | 
				
			||||||
	cw_in_capwap_local_ipv6_address.c\
 | 
						cw_in_capwap_local_ipv6_address.c\
 | 
				
			||||||
	cw_in_generic_with_index.c\
 | 
						cw_in_generic_with_index.c\
 | 
				
			||||||
	cw_in_radio_generic_struct.c\
 | 
					 | 
				
			||||||
	cw_in_idx_generic.c\
 | 
						cw_in_idx_generic.c\
 | 
				
			||||||
	cw_in_idx_generic_struct.c\
 | 
						cw_in_idx_generic_struct.c\
 | 
				
			||||||
	cw_in_generic_indexed_enum.c\
 | 
						cw_in_generic_indexed_enum.c\
 | 
				
			||||||
	cw_out_generic_indexed_enum.c\
 | 
						cw_out_generic_indexed_enum.c\
 | 
				
			||||||
	cw_in_generic_enum.c\
 | 
						cw_in_generic_enum.c\
 | 
				
			||||||
	cw_out_generic_struct.c\
 | 
					 | 
				
			||||||
	cw_out_idx_generic_struct.c\
 | 
						cw_out_idx_generic_struct.c\
 | 
				
			||||||
	cw_init_data_keep_alive_msg.c\
 | 
						cw_init_data_keep_alive_msg.c\
 | 
				
			||||||
	cw_inline.c\
 | 
						cw_inline.c\
 | 
				
			||||||
@ -37,7 +35,6 @@ CWSRC=\
 | 
				
			|||||||
	cw_put_elem_radio_operational_state.c\
 | 
						cw_put_elem_radio_operational_state.c\
 | 
				
			||||||
	cw_put_image_data.c\
 | 
						cw_put_image_data.c\
 | 
				
			||||||
	cw_put_local_ip_address.c\
 | 
						cw_put_local_ip_address.c\
 | 
				
			||||||
	cw_radio_set_admin_state.c\
 | 
					 | 
				
			||||||
	cw_rand.c\
 | 
						cw_rand.c\
 | 
				
			||||||
	cw_randint.c\
 | 
						cw_randint.c\
 | 
				
			||||||
	cw_read_ac_descriptor.c\
 | 
						cw_read_ac_descriptor.c\
 | 
				
			||||||
@ -62,11 +59,11 @@ CWSRC=\
 | 
				
			|||||||
	cw_type_ipaddress.c\
 | 
						cw_type_ipaddress.c\
 | 
				
			||||||
	cw_type_word.c\
 | 
						cw_type_word.c\
 | 
				
			||||||
	cw_type_sysptr.c\
 | 
						cw_type_sysptr.c\
 | 
				
			||||||
 | 
						cw_type_array.c\
 | 
				
			||||||
	cw_write_descriptor_subelem.c\
 | 
						cw_write_descriptor_subelem.c\
 | 
				
			||||||
	cw_write_radio_element.c\
 | 
						cw_write_radio_element.c\
 | 
				
			||||||
	cw_detect_nat.c\
 | 
						cw_detect_nat.c\
 | 
				
			||||||
	cw_read_from.c \
 | 
						cw_read_from.c \
 | 
				
			||||||
	cw_in_generic_struct.c\
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#	cw_in_check_disc_req.c\
 | 
					#	cw_in_check_disc_req.c\
 | 
				
			||||||
#	cw_in_check_img_data_req_ac.c\
 | 
					#	cw_in_check_img_data_req_ac.c\
 | 
				
			||||||
@ -77,46 +74,15 @@ CWSRC=\
 | 
				
			|||||||
#	cw_out_generic.c\
 | 
					#	cw_out_generic.c\
 | 
				
			||||||
#	
 | 
					#	
 | 
				
			||||||
#	cw_process_element.c\
 | 
					#	cw_process_element.c\
 | 
				
			||||||
 | 
					#	cw_out_generic_struct.c\
 | 
				
			||||||
 | 
						cw_in_radio_generic_struct.c\
 | 
				
			||||||
 | 
						cw_in_generic_struct.c\
 | 
				
			||||||
 | 
						cw_radio_set_admin_state.c\
 | 
				
			||||||
 | 
					
 | 
				
			||||||
KTVSRC=\
 | 
					KTVSRC=\
 | 
				
			||||||
	cfg.c\
 | 
						cfg.c\
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#	cw_ktv_add.c\
 | 
					 | 
				
			||||||
	cw_ktv_idx_get.c\
 | 
					 | 
				
			||||||
	cw_ktv_mavlcmp.c\
 | 
					 | 
				
			||||||
	cw_ktv_mavlcmp_type_by_name.c\
 | 
					 | 
				
			||||||
	cw_ktv_mavldel.c\
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#	cw_ktv_parser.c\
 | 
					 | 
				
			||||||
#	cw_ktv_del_sub.c\
 | 
					 | 
				
			||||||
#	cw_ktv_base_exists.c\
 | 
					 | 
				
			||||||
	cw_ktv_add_from_str.c\
 | 
					 | 
				
			||||||
	cw_ktv_read_file.c\
 | 
					 | 
				
			||||||
	cw_ktv_readline.c\
 | 
					 | 
				
			||||||
	cw_ktv_save.c\
 | 
					 | 
				
			||||||
	cw_ktv_std_types.c\
 | 
					 | 
				
			||||||
	cw_ktv_read_struct.c\
 | 
					 | 
				
			||||||
	cw_ktv_write_struct.c\
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#	cw_ktv_get_byte.c\
 | 
					 | 
				
			||||||
	cw_ktv_get_bool.c\
 | 
					 | 
				
			||||||
	cw_ktv_get_bstr16.c\
 | 
					 | 
				
			||||||
	cw_ktv_set_byte.c\
 | 
					 | 
				
			||||||
	cw_ktv_set_word.c\
 | 
					 | 
				
			||||||
	cw_ktv_set_dword.c\
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#	cw_ktv_get_word.c\
 | 
					 | 
				
			||||||
	cw_ktv_get_dword.c\
 | 
					 | 
				
			||||||
	cw_ktv_get_sysptr.c\
 | 
					 | 
				
			||||||
	cw_ktv_get_str.c\
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#	cw_ktv_cast.c\
 | 
					 | 
				
			||||||
	cw_ktv_replace.c\
 | 
					 | 
				
			||||||
	cw_ktv_get.c\
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
LWSRC=\
 | 
					LWSRC=\
 | 
				
			||||||
	lw_addelem.c\
 | 
						lw_addelem.c\
 | 
				
			||||||
	lw_checksum.c\
 | 
						lw_checksum.c\
 | 
				
			||||||
 | 
				
			|||||||
@ -467,7 +467,7 @@ enum cw_reboot_failure_types {
 | 
				
			|||||||
 * WTP to the AC when the AC List is missing */
 | 
					 * WTP to the AC when the AC List is missing */
 | 
				
			||||||
#define CW_RESULT_MISSING_AC_LIST					1
 | 
					#define CW_RESULT_MISSING_AC_LIST					1
 | 
				
			||||||
#define CAPWAP_RESULT_SUCCESS_NAT					2
 | 
					#define CAPWAP_RESULT_SUCCESS_NAT					2
 | 
				
			||||||
#define CW_RESULT_JOIN_FAILURE					3
 | 
					#define CAPWAP_RESULT_JOIN_FAILURE					3
 | 
				
			||||||
#define CW_RESULT_JOIN_RESOURCE_DEPLETION			4
 | 
					#define CW_RESULT_JOIN_RESOURCE_DEPLETION			4
 | 
				
			||||||
#define CW_RESULT_JOIN_UNKNOWN_SOURCE				5
 | 
					#define CW_RESULT_JOIN_UNKNOWN_SOURCE				5
 | 
				
			||||||
#define CW_RESULT_JOIN_INCORRECT_DATA				6
 | 
					#define CW_RESULT_JOIN_INCORRECT_DATA				6
 | 
				
			||||||
@ -491,7 +491,7 @@ enum cw_reboot_failure_types {
 | 
				
			|||||||
      13 Configuration Failure (Unable to Apply Requested Configuration
 | 
					      13 Configuration Failure (Unable to Apply Requested Configuration
 | 
				
			||||||
         - Service Not Provided)
 | 
					         - Service Not Provided)
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#define CAPWAP_RESULT_CONFIGURATION_FAILURE_SERVICE_NOT PROVIDED	13
 | 
					#define CAPWAP_RESULT_CONFIGURATION_FAILURE_SERVICE_NOT_PROVIDED	13
 | 
				
			||||||
/** 
 | 
					/** 
 | 
				
			||||||
 * Image Data Error (Invalid Checksum)
 | 
					 * Image Data Error (Invalid Checksum)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
				
			|||||||
@ -86,12 +86,15 @@ enum radioelems {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** IEEE 802.11 Radio Information Message Element */
 | 
					
 | 
				
			||||||
#define CAPWAP80211_ELEM_WTP_RADIO_INFORMATION		1048
 | 
					/** IEEE 802.11 Add WLAN Message element */
 | 
				
			||||||
 | 
					#define	CAPWAP80211_ELEM_ADD_WLAN			1024
 | 
				
			||||||
/** IEEE 802.11 Antenna Message element */
 | 
					/** IEEE 802.11 Antenna Message element */
 | 
				
			||||||
#define CAPWAP80211_ELEM_ANTENNA			1025
 | 
					#define CAPWAP80211_ELEM_ANTENNA			1025
 | 
				
			||||||
 | 
					/** IEEE 802.11 WTP Radio Configuration */
 | 
				
			||||||
 | 
					#define CAPWAP80211_ELEM_WTP_RADIO_CONFIGURATION	1046
 | 
				
			||||||
 | 
					/** IEEE 802.11 Radio Information Message Element */
 | 
				
			||||||
 | 
					#define CAPWAP80211_ELEM_WTP_RADIO_INFORMATION		1048
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										177
									
								
								src/cw/cfg.c
									
									
									
									
									
								
							
							
						
						
									
										177
									
								
								src/cw/cfg.c
									
									
									
									
									
								
							@ -80,7 +80,13 @@ static void del(void *ptr)
 | 
				
			|||||||
	free((void *) e->val);
 | 
						free((void *) e->val);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Create an empty cfg
 | 
				
			||||||
 | 
					 * @return A pointer to the cfg or NULL if an error has accoured.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * In case of an error consult errno to find out the reason.
 | 
				
			||||||
 | 
					 * The created config must be freed by #cw_cfg_destroy.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
cw_Cfg_t *cw_cfg_create()
 | 
					cw_Cfg_t *cw_cfg_create()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cw_Cfg_t * cfg;
 | 
						cw_Cfg_t * cfg;
 | 
				
			||||||
@ -88,6 +94,7 @@ cw_Cfg_t *cw_cfg_create()
 | 
				
			|||||||
	if (cfg == NULL)
 | 
						if (cfg == NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	memset(cfg,0,sizeof(cw_Cfg_t));
 | 
						memset(cfg,0,sizeof(cw_Cfg_t));
 | 
				
			||||||
 | 
						cfg->name = CW_CFG_DEFAULT_NAME;
 | 
				
			||||||
	cfg->cfg = mavl_create(cmp, del, sizeof(struct cw_Cfg_entry));
 | 
						cfg->cfg = mavl_create(cmp, del, sizeof(struct cw_Cfg_entry));
 | 
				
			||||||
	if (cfg->cfg==NULL){
 | 
						if (cfg->cfg==NULL){
 | 
				
			||||||
		cw_cfg_destroy(cfg);
 | 
							cw_cfg_destroy(cfg);
 | 
				
			||||||
@ -122,6 +129,16 @@ int cw_cfg_set(cw_Cfg_t * cfg, const char *key, const char *val)
 | 
				
			|||||||
	return -1;
 | 
						return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cw_cfg_del(cw_Cfg_t * cfg, const char *key)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cw_Cfg_entry e;
 | 
				
			||||||
 | 
						e.key = key;
 | 
				
			||||||
 | 
						e.val=NULL;
 | 
				
			||||||
 | 
						mavl_del(cfg->cfg,&e);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *cw_cfg_get(cw_Cfg_t * cfg, const char *key, const char *def)
 | 
					const char *cw_cfg_get(cw_Cfg_t * cfg, const char *key, const char *def)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Cfg_entry e, *r;
 | 
						struct cw_Cfg_entry e, *r;
 | 
				
			||||||
@ -137,7 +154,6 @@ const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def)
 | 
				
			|||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	struct cw_Cfg_entry e, *r;
 | 
						struct cw_Cfg_entry e, *r;
 | 
				
			||||||
	for(i=0; cfg[i]!=NULL; i++){
 | 
						for(i=0; cfg[i]!=NULL; i++){
 | 
				
			||||||
//		cw_dbg(DBG_X,"GET_L IN: %p",cfg[i]);
 | 
					 | 
				
			||||||
		e.key = key;
 | 
							e.key = key;
 | 
				
			||||||
		r = mavl_get(cfg[i]->cfg, &e);
 | 
							r = mavl_get(cfg[i]->cfg, &e);
 | 
				
			||||||
		if (r!=NULL)
 | 
							if (r!=NULL)
 | 
				
			||||||
@ -160,11 +176,29 @@ bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	s = cw_cfg_get(cfg,key,def);
 | 
						s = cw_cfg_get(cfg,key,def);
 | 
				
			||||||
	if(s==NULL)
 | 
						if(s==NULL)
 | 
				
			||||||
 | 
							s=def;
 | 
				
			||||||
 | 
						if (s==NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return bstr16_create_from_str(s);
 | 
						return bstr16_create_from_str(s);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bstr16_t cw_cfg_get_bstr16_l(cw_Cfg_t **cfgs, const char * key, const char *def)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						bstr16_t s;
 | 
				
			||||||
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for(i=0; cfgs[i]!=NULL; i++){
 | 
				
			||||||
 | 
							s = cw_cfg_get_bstr16(cfgs[i],key,NULL);
 | 
				
			||||||
 | 
							if (s!=NULL)
 | 
				
			||||||
 | 
								return s;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (def == NULL)
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						return bstr16_create_from_str(def);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str)
 | 
					int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	CW_TYPE_BSTR16->read(cfg,key,bstr16_data(str),bstr16_len(str),NULL);
 | 
						CW_TYPE_BSTR16->read(cfg,key,bstr16_data(str),bstr16_len(str),NULL);
 | 
				
			||||||
@ -186,7 +220,7 @@ void cw_cfg_dump(cw_Cfg_t * cfg)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cw_cfg_fdump(FILE *f, cw_Cfg_t * cfg)
 | 
					void cw_cfg_fdump(FILE *f, cw_Cfg_t * cfg, const char *filter)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	mavliter_t it;
 | 
						mavliter_t it;
 | 
				
			||||||
	struct cw_Cfg_entry *e;
 | 
						struct cw_Cfg_entry *e;
 | 
				
			||||||
@ -194,6 +228,13 @@ void cw_cfg_fdump(FILE *f, cw_Cfg_t * cfg)
 | 
				
			|||||||
	mavliter_foreach(&it) {
 | 
						mavliter_foreach(&it) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		e = mavliter_get(&it);
 | 
							e = mavliter_get(&it);
 | 
				
			||||||
 | 
							if (filter != NULL){
 | 
				
			||||||
 | 
								if (strlen(filter)){
 | 
				
			||||||
 | 
									if (strstr(e->key,filter)==NULL){
 | 
				
			||||||
 | 
										continue;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		fprintf(f,"%s: '%s'\n", e->key, e->val);
 | 
							fprintf(f,"%s: '%s'\n", e->key, e->val);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -487,6 +528,7 @@ int cw_cfg_load(const char *filename, cw_Cfg_t * cfg)
 | 
				
			|||||||
	FILE *f = fopen(filename, "rb");
 | 
						FILE *f = fopen(filename, "rb");
 | 
				
			||||||
	if (!f)
 | 
						if (!f)
 | 
				
			||||||
		return errno;
 | 
							return errno;
 | 
				
			||||||
 | 
						errno=0;
 | 
				
			||||||
	errs = cw_cfg_read_from_file(f, cfg);
 | 
						errs = cw_cfg_read_from_file(f, cfg);
 | 
				
			||||||
	fclose(f);
 | 
						fclose(f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -559,6 +601,11 @@ void cw_cfg_iter_init(cw_Cfg_t * cfg, struct cw_Cfg_iter *cfi, const char *base)
 | 
				
			|||||||
	search.key = base;
 | 
						search.key = base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mavliter_init(&(cfi->it), cfg->cfg);
 | 
						mavliter_init(&(cfi->it), cfg->cfg);
 | 
				
			||||||
 | 
						if (base == NULL){
 | 
				
			||||||
 | 
							mavliter_seek_set(&(cfi->it));
 | 
				
			||||||
 | 
							mavliter_next(&(cfi->it));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
		mavliter_seek(&(cfi->it), &search, 0);
 | 
							mavliter_seek(&(cfi->it), &search, 0);
 | 
				
			||||||
	cfi->base = base;
 | 
						cfi->base = base;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -568,16 +615,16 @@ struct cw_Cfg_entry *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *nnkey
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Cfg_entry *e;
 | 
						struct cw_Cfg_entry *e;
 | 
				
			||||||
	int bl, kl;
 | 
						int bl, kl;
 | 
				
			||||||
	const char *d;
 | 
					//	const char *d;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	e = mavliter_get(&(cfi->it));
 | 
						e = mavliter_get(&(cfi->it));
 | 
				
			||||||
	if (e == NULL)
 | 
						if (e == NULL){
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (cfi->base ==NULL)
 | 
				
			||||||
 | 
							goto eeX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bl = strlen(cfi->base);
 | 
						bl = strlen(cfi->base);
 | 
				
			||||||
	kl = strlen(e->key);
 | 
						kl = strlen(e->key);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bl > kl)
 | 
						if (bl > kl)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -590,16 +637,19 @@ struct cw_Cfg_entry *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *nnkey
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	d = strchr(e->key, '.');
 | 
					
 | 
				
			||||||
	if (d == NULL)
 | 
						if (e->key[bl]!='.' && e->key[bl]!='/')
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (d - e->key != bl)
 | 
					/*	d = strchr(e->key, '.');
 | 
				
			||||||
 | 
						if (d == NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
						if (d - e->key != bl)
 | 
				
			||||||
 | 
							return NULL;*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (strncmp(cfi->base, e->key, bl) != 0)
 | 
						if (strncmp(cfi->base, e->key, bl) != 0)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					eeX:
 | 
				
			||||||
	mavliter_next(&(cfi->it));
 | 
						mavliter_next(&(cfi->it));
 | 
				
			||||||
	return e;
 | 
						return e;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -638,6 +688,14 @@ uint8_t cw_cfg_get_byte_l(cw_Cfg_t ** cfgs, char *key, uint8_t def)
 | 
				
			|||||||
	return v.val.byte;
 | 
						return v.val.byte;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_cfg_get_int(cw_Cfg_t * cfg, const char *key, int def)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const char *s = cw_cfg_get(cfg,key,NULL);
 | 
				
			||||||
 | 
						if (s==NULL)
 | 
				
			||||||
 | 
							return def;
 | 
				
			||||||
 | 
						return atoi(s);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, const char *key, uint16_t def)
 | 
					uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, const char *key, uint16_t def)
 | 
				
			||||||
@ -662,7 +720,6 @@ uint16_t cw_cfg_get_word_l(cw_Cfg_t ** cfg, const char *key, uint16_t def)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
int cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
 | 
					int cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -682,8 +739,7 @@ void cw_cfg_set_int(cw_Cfg_t * cfg, const char * key, int val)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_cfg_get_new_index(cw_Cfg_t * cfg, const char *key)
 | 
				
			||||||
int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char ikey[CW_CFG_MAX_KEY_LEN];
 | 
						char ikey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
	struct cw_Cfg_entry search, * result;
 | 
						struct cw_Cfg_entry search, * result;
 | 
				
			||||||
@ -699,7 +755,7 @@ int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key)
 | 
				
			|||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	d = strchr(result->key,'.');
 | 
						d = strrchr(result->key,'.');
 | 
				
			||||||
	if (d==NULL){
 | 
						if (d==NULL){
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -710,6 +766,46 @@ int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key)
 | 
				
			|||||||
	return atoi(d+1)+1;
 | 
						return atoi(d+1)+1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char ikey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						struct cw_Cfg_entry search, * result;
 | 
				
			||||||
 | 
						char *d;
 | 
				
			||||||
 | 
						int l;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						sprintf(ikey,"%s.%d",key,n);
 | 
				
			||||||
 | 
						search.key=ikey;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						result = mavl_get_first(cfg->cfg,&search);
 | 
				
			||||||
 | 
						if (result == NULL){
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						d = strrchr(ikey,'.');
 | 
				
			||||||
 | 
						if (d==NULL){
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						l = d-ikey;
 | 
				
			||||||
 | 
						if (strncmp(result->key,ikey,l)!=0)
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						return atoi(result->key+l+1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int r;
 | 
				
			||||||
 | 
						while(*cfgs != NULL){
 | 
				
			||||||
 | 
							r = cw_cfg_get_first_index(*cfgs,key,n);
 | 
				
			||||||
 | 
							if (r!=-1)
 | 
				
			||||||
 | 
								return r;
 | 
				
			||||||
 | 
							cfgs++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return -1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *type, const void * valguard, const uint8_t * data, int len)
 | 
					int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *type, const void * valguard, const uint8_t * data, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cw_Val_t mdata, *mresult;
 | 
						cw_Val_t mdata, *mresult;
 | 
				
			||||||
@ -808,22 +904,43 @@ void cw_cfg_clear(cw_Cfg_t *cfg)
 | 
				
			|||||||
int cw_cfg_base_exists(cw_Cfg_t * cfg, const char *key)
 | 
					int cw_cfg_base_exists(cw_Cfg_t * cfg, const char *key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
        struct cw_Cfg_entry e, *result;
 | 
					        struct cw_Cfg_entry e, *result;
 | 
				
			||||||
//cw_dbg(DBG_X,"LOOX FOR: %s",key);
 | 
						int rl,kl;
 | 
				
			||||||
        e.key=key;
 | 
						char skey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
        result = mavl_get_first(cfg->cfg,&e);
 | 
						char * delimiters = "/.";
 | 
				
			||||||
        if (result == NULL)
 | 
						char * d;
 | 
				
			||||||
                return 0;
 | 
					 | 
				
			||||||
//cw_dbg(DBG_X,"BASEXXX: %s",result->key);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (strlen(result->key)<strlen(key))
 | 
						/* can we find the base exactly ?*/
 | 
				
			||||||
		return 0;		
 | 
						if (cw_cfg_get(cfg,key,NULL)!=NULL)
 | 
				
			||||||
//cw_dbg(DBG_X,"BASEXXX1: %d",strlen(key));
 | 
					 | 
				
			||||||
	if (result->key[strlen(key)]!='/' && result->key[strlen(key)]!='.')
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
//cw_dbg(DBG_X,"BASEXXX2: ");
 | 
					 | 
				
			||||||
	if (strncmp(result->key,key,strlen(key))==0)
 | 
					 | 
				
			||||||
		return 1;
 | 
							return 1;
 | 
				
			||||||
cw_dbg(DBG_X,"BASEXXX3: ");
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for(d=delimiters; *d!=0; d++){
 | 
				
			||||||
 | 
							sprintf(skey,"%s%c",key,*d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						        e.key=skey;
 | 
				
			||||||
 | 
						        result = mavl_get_first(cfg->cfg,&e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
							/* if we've found nothing, we can't check more */
 | 
				
			||||||
 | 
						        if (result == NULL)
 | 
				
			||||||
 | 
						                continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							rl = strlen(result->key);
 | 
				
			||||||
 | 
							kl = strlen(skey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/* if result key is shorter than key */
 | 
				
			||||||
 | 
							if (rl<kl)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/* both keys are identical in length */
 | 
				
			||||||
 | 
							if (rl==kl){
 | 
				
			||||||
 | 
								if (strcmp(result->key,key)==0)
 | 
				
			||||||
 | 
									return 1;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
							if (strncmp(result->key,skey,kl)==0)
 | 
				
			||||||
 | 
								return 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										52
									
								
								src/cw/cfg.h
									
									
									
									
									
								
							
							
						
						
									
										52
									
								
								src/cw/cfg.h
									
									
									
									
									
								
							@ -5,28 +5,53 @@
 | 
				
			|||||||
#include "val.h"
 | 
					#include "val.h"
 | 
				
			||||||
#include "bstr.h"
 | 
					#include "bstr.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *@file
 | 
				
			||||||
 | 
					 *@brief
 | 
				
			||||||
 | 
					 *@defgroup CFG SOCK
 | 
				
			||||||
 | 
					 *@{
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** Maximum size of a key used in cfg objects */
 | 
				
			||||||
#define CW_CFG_MAX_KEY_LEN 1024	
 | 
					#define CW_CFG_MAX_KEY_LEN 1024	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** Default name for fresh cfg's created by #cw_cfg_create */ 
 | 
				
			||||||
 | 
					#define CW_CFG_DEFAULT_NAME "[anonymous]"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * A Cfg object 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
struct cw_Cfg {
 | 
					struct cw_Cfg {
 | 
				
			||||||
	struct mavl * cfg;
 | 
						struct mavl * cfg;	/**< The AVL-tree containig the keys 
 | 
				
			||||||
	const char *name;
 | 
									     and vals */
 | 
				
			||||||
 | 
						const char *name;	/**< A name for this config object */
 | 
				
			||||||
	int dbg_level;
 | 
						int dbg_level;
 | 
				
			||||||
	const char *dbg_prefix;
 | 
						const char *dbg_prefix;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct cw_Cfg cw_Cfg_t;
 | 
					typedef struct cw_Cfg cw_Cfg_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * An antry for a Cfg object
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					struct cw_Cfg_entry{
 | 
				
			||||||
 | 
						const char *key;	/**< A string representing the key 
 | 
				
			||||||
 | 
									     of this entry */
 | 
				
			||||||
 | 
						const char *val;	/**< The value, represented by a string */
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cw_Cfg_t * cw_cfg_create();
 | 
					cw_Cfg_t * cw_cfg_create();
 | 
				
			||||||
int cw_cfg_set(cw_Cfg_t *cfg,const char *key, const char *val);
 | 
					int cw_cfg_set(cw_Cfg_t *cfg,const char *key, const char *val);
 | 
				
			||||||
void cw_cfg_dump(cw_Cfg_t *cfg);
 | 
					void cw_cfg_dump(cw_Cfg_t *cfg);
 | 
				
			||||||
int cw_cfg_read_from_file(FILE * file, cw_Cfg_t * cfg);
 | 
					int cw_cfg_read_from_file(FILE * file, cw_Cfg_t * cfg);
 | 
				
			||||||
int cw_cfg_load(const char *filename,cw_Cfg_t * cfg);
 | 
					int cw_cfg_load(const char *filename,cw_Cfg_t * cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct cw_Cfg_entry{
 | 
					 | 
				
			||||||
	const char *key;
 | 
					 | 
				
			||||||
	const char *val;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct cw_Cfg_iter{
 | 
					struct cw_Cfg_iter{
 | 
				
			||||||
	struct mavliter it;
 | 
						struct mavliter it;
 | 
				
			||||||
@ -44,7 +69,7 @@ void cw_cfg_set_int(cw_Cfg_t * cfg, const char * key, int val);
 | 
				
			|||||||
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def);
 | 
					uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def);
 | 
				
			||||||
bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def);
 | 
					bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def);
 | 
				
			||||||
int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str);
 | 
					int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str);
 | 
				
			||||||
int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key);
 | 
					int cw_cfg_get_new_index(cw_Cfg_t * cfg, const char *key);
 | 
				
			||||||
const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def);
 | 
					const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def);
 | 
				
			||||||
void cw_cfg_copy(cw_Cfg_t *src, cw_Cfg_t *dst,int dbg_level,const char *dbg_prefix);
 | 
					void cw_cfg_copy(cw_Cfg_t *src, cw_Cfg_t *dst,int dbg_level,const char *dbg_prefix);
 | 
				
			||||||
void cw_cfg_destroy(cw_Cfg_t *cfg);
 | 
					void cw_cfg_destroy(cw_Cfg_t *cfg);
 | 
				
			||||||
@ -56,14 +81,20 @@ int cw_cfg_base_exists_l(cw_Cfg_t ** cfgs, const char *key);
 | 
				
			|||||||
int cw_cfg_save(const char *filename, cw_Cfg_t *cfg, const char *format, ...);
 | 
					int cw_cfg_save(const char *filename, cw_Cfg_t *cfg, const char *format, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint16_t cw_cfg_get_word_l(cw_Cfg_t ** cfg, const char *key, uint16_t def);
 | 
					uint16_t cw_cfg_get_word_l(cw_Cfg_t ** cfg, const char *key, uint16_t def);
 | 
				
			||||||
void cw_cfg_fdump(FILE *f, cw_Cfg_t * cfg);
 | 
					void cw_cfg_fdump(FILE *f, cw_Cfg_t * cfg, const char *filter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_cfg_read_from_string(const char *str, cw_Cfg_t *cfg);
 | 
					int cw_cfg_read_from_string(const char *str, cw_Cfg_t *cfg);
 | 
				
			||||||
 | 
					void cw_cfg_del(cw_Cfg_t * cfg, const char *key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n);
 | 
				
			||||||
 | 
					int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_cfg_get_int(cw_Cfg_t * cfg, const char *key, int def);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *t, const void * valguard, const uint8_t * data, int len);
 | 
					int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *t, const void * valguard, const uint8_t * data, int len);
 | 
				
			||||||
 | 
					bstr16_t cw_cfg_get_bstr16_l(cw_Cfg_t **cfgs, const char * key, const char *def);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define cw_cfg_get_word2(cfg1,cfg2,key,def) \
 | 
					#define cw_cfg_get_word2(cfg1,cfg2,key,def) \
 | 
				
			||||||
	cw_cfg_get_word(cfg1,key,cw_cfg_get_word(cfg2,key,def))
 | 
						cw_cfg_get_word(cfg1,key,cw_cfg_get_word(cfg2,key,def))
 | 
				
			||||||
@ -74,3 +105,6 @@ int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *t, con
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**@}*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -24,11 +24,12 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "dtls.h"
 | 
					#include "dtls.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MAX_MSG_CBS 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct msg_callback{
 | 
					struct msg_callback{
 | 
				
			||||||
	int type; 			/**< message type */
 | 
						int type; 			/**< message type */
 | 
				
			||||||
	cw_MsgCallbackFun fun;
 | 
						struct cw_MsgCb_data data[MAX_MSG_CBS];
 | 
				
			||||||
 | 
						int count;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int msg_callback_cmp(const void *v1,const void *v2)
 | 
					int msg_callback_cmp(const void *v1,const void *v2)
 | 
				
			||||||
@ -62,19 +63,55 @@ void cw_conn_init(struct cw_Conn * conn)
 | 
				
			|||||||
	conn->remote_cfg = cw_cfg_create();
 | 
						conn->remote_cfg = cw_cfg_create();
 | 
				
			||||||
	conn->local_cfg = cw_cfg_create();
 | 
						conn->local_cfg = cw_cfg_create();
 | 
				
			||||||
	conn->cfg_list[0]=NULL;
 | 
						conn->cfg_list[0]=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						conn->remote_addr[0]=0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_conn_set_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun)
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Register a message callback function. 
 | 
				
			||||||
 | 
					 * @param conn the connection the registered cb functions belongs to
 | 
				
			||||||
 | 
					 * @param type The associated msg type. Whenever a message of this type is 
 | 
				
			||||||
 | 
					 *             received, the callback function will be called
 | 
				
			||||||
 | 
					 * @param fun  A pinter to the callback function          
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int cw_conn_register_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct msg_callback cb;
 | 
						struct msg_callback cb, *result;
 | 
				
			||||||
	int exists;
 | 
						int exists;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cb.type = type;
 | 
						cb.type = type;
 | 
				
			||||||
	cb.fun = fun;
 | 
						cb.data[0].fun = fun;
 | 
				
			||||||
	mavl_insert(conn->msg_callbacks,&cb,&exists);
 | 
						cb.data[0].parent = NULL;
 | 
				
			||||||
 | 
						cb.count = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						result = mavl_insert(conn->msg_callbacks,&cb,&exists);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg(DBG_X, "Registering msg callback: %d %p",type,result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (result==NULL)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (exists){
 | 
				
			||||||
 | 
							if (result->count>=MAX_MSG_CBS){
 | 
				
			||||||
 | 
								cw_log(LOG_ERROR,"Too many msg callback registrations for msg id %d",type);
 | 
				
			||||||
 | 
								return 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							result->count++;
 | 
				
			||||||
 | 
							result->data[result->count].fun=fun;
 | 
				
			||||||
 | 
							result->data[result->count].parent=&(result->data[result->count-1]);
 | 
				
			||||||
 | 
							cw_dbg(DBG_X,"The result exists: %p %p %d %p",result,&cb,result->count,
 | 
				
			||||||
 | 
									result->data[result->count].parent
 | 
				
			||||||
 | 
									);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
 | 
					cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct msg_callback cb,*result;
 | 
						struct msg_callback cb,*result;
 | 
				
			||||||
@ -83,8 +120,22 @@ cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
 | 
				
			|||||||
	if (result == NULL)
 | 
						if (result == NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	return result->fun;
 | 
						return result->fun;
 | 
				
			||||||
 | 
					}*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_conn_run_msg_cbs(struct cw_Conn * conn, int type, struct cw_ElemHandlerParams *params)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct msg_callback cb,*result;
 | 
				
			||||||
 | 
						cb.type=type;
 | 
				
			||||||
 | 
						result = mavl_get(conn->msg_callbacks,&cb);
 | 
				
			||||||
 | 
						if (result == NULL)
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						return result->data[result->count].fun(params,&(result->data[result->count]));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Create a conn object
 | 
					 * Create a conn object
 | 
				
			||||||
 * @param sock a socket
 | 
					 * @param sock a socket
 | 
				
			||||||
@ -106,8 +157,10 @@ struct cw_Conn * cw_conn_create(int sock, struct sockaddr * addr, int qsize)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	conn->sock=sock;
 | 
						conn->sock=sock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (addr)
 | 
						if (addr){
 | 
				
			||||||
		sock_copyaddr(&conn->addr,addr);
 | 
							sock_copyaddr(&conn->addr,addr);
 | 
				
			||||||
 | 
							sock_addr2str_p(addr, conn->remote_addr);	
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	conn->fragman = fragman_create();
 | 
						conn->fragman = fragman_create();
 | 
				
			||||||
@ -516,12 +569,12 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
 | 
				
			|||||||
		message->postprocess(¶ms,elems_ptr, elems_len);
 | 
							message->postprocess(¶ms,elems_ptr, elems_len);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_MsgCallbackFun cb_fun = cw_conn_get_msg_cb(conn,message->type);
 | 
						result_code = cw_conn_run_msg_cbs(conn,message->type,¶ms);
 | 
				
			||||||
	if (cb_fun != NULL){
 | 
					
 | 
				
			||||||
		result_code = cb_fun(¶ms,elems_ptr, elems_len);
 | 
					//	cw_MsgCallbackFun cb_fun = cw_conn_get_msg_cb(conn,message->type);
 | 
				
			||||||
	}
 | 
						if (result_code==-1){
 | 
				
			||||||
	else{
 | 
					 | 
				
			||||||
		cw_cfg_clear(conn->update_cfg);
 | 
							cw_cfg_clear(conn->update_cfg);
 | 
				
			||||||
 | 
							result_code=0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	conn->remote_cfg=params.cfg;
 | 
					//	conn->remote_cfg=params.cfg;
 | 
				
			||||||
@ -554,7 +607,6 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
 | 
				
			|||||||
		 * Put further actions here, if needed.
 | 
							 * Put further actions here, if needed.
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (params.unrecognized)
 | 
						if (params.unrecognized)
 | 
				
			||||||
		mlist_destroy(params.unrecognized);
 | 
							mlist_destroy(params.unrecognized);
 | 
				
			||||||
	cw_cfg_destroy(params.cfg);
 | 
						cw_cfg_destroy(params.cfg);
 | 
				
			||||||
 | 
				
			|||||||
@ -58,6 +58,8 @@ struct cw_action_in;
 | 
				
			|||||||
struct cw_Conn {
 | 
					struct cw_Conn {
 | 
				
			||||||
	int sock;
 | 
						int sock;
 | 
				
			||||||
	struct sockaddr_storage addr;
 | 
						struct sockaddr_storage addr;
 | 
				
			||||||
 | 
						char remote_addr[64];	/* Contains a printfable string, of the connections
 | 
				
			||||||
 | 
									   peer address */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct connlist * connlist;
 | 
						struct connlist * connlist;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -71,19 +73,19 @@ struct cw_Conn {
 | 
				
			|||||||
	int recv_timeout;
 | 
						int recv_timeout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t * global_cfg;	/**< This should set the global cfg of the program
 | 
						cw_Cfg_t * global_cfg;	/**< This should set to the global cfg of the program
 | 
				
			||||||
				     which is using this conn object.
 | 
									     which is using this conn object.
 | 
				
			||||||
				     Teh global_cfg has to be treated read-only. */
 | 
									     Teh global_cfg has to be treated read-only. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t * local_cfg;	/**< local_cfg contains overrides for global_cfg 
 | 
						cw_Cfg_t * local_cfg;	/**< local_cfg contains overrides for global_cfg 
 | 
				
			||||||
				     wich are related to this conn object. */
 | 
									     wich are related to this conniection. */
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	cw_Cfg_t * remote_cfg;	/**< contains the configuration we now from the 
 | 
						cw_Cfg_t * remote_cfg;	/**< contains the configuration we now from the 
 | 
				
			||||||
				     device this conn object ist connected to.
 | 
									     device this conn object ist connected to.
 | 
				
			||||||
				     Typically this is what we have got from discovery
 | 
									     Typically this is what we have got from discovery
 | 
				
			||||||
				     response or join response in WTP mode. 
 | 
									     response or join response in WTP mode. 
 | 
				
			||||||
				     And in AC mode this contains date receive from 
 | 
									     And in AC mode this contains datia received by 
 | 
				
			||||||
				     configuration status request.  */
 | 
									     configuration status and join request.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t * update_cfg;
 | 
						cw_Cfg_t * update_cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -311,7 +313,18 @@ int conn_send_msg(struct cw_Conn *conn, uint8_t * rawmsg);
 | 
				
			|||||||
void conn_clear_upd(struct cw_Conn*conn, int merge);
 | 
					void conn_clear_upd(struct cw_Conn*conn, int merge);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_conn_set_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun);
 | 
					
 | 
				
			||||||
 | 
					struct cw_MsgCb_data;
 | 
				
			||||||
 | 
					//typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len, 
 | 
				
			||||||
 | 
					//		struct cw_MsgCb_data *d);
 | 
				
			||||||
 | 
					typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cw_MsgCb_data{
 | 
				
			||||||
 | 
						cw_MsgCallbackFun fun;
 | 
				
			||||||
 | 
						struct cw_MsgCb_data * parent;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_conn_register_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun);
 | 
				
			||||||
cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type);
 | 
					cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
 | 
					int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										209
									
								
								src/cw/cw.c
									
									
									
									
									
								
							
							
						
						
									
										209
									
								
								src/cw/cw.c
									
									
									
									
									
								
							@ -36,10 +36,9 @@ int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams *
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					int cw_out_generic0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
			, uint8_t * dst)
 | 
								, uint8_t * dst,const char *key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
	int start, len, l;
 | 
						int start, len, l;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
//	cw_dbg(DBG_X,"cw_out_generic (%s)%s",((struct cw_Type*)handler->type)->name,handler->key);
 | 
					//	cw_dbg(DBG_X,"cw_out_generic (%s)%s",((struct cw_Type*)handler->type)->name,handler->key);
 | 
				
			||||||
@ -47,10 +46,23 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
 | 
				
			|||||||
//	cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
 | 
					//	cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
 | 
				
			||||||
//	cw_cfg_dump(params->cfg);
 | 
					//	cw_cfg_dump(params->cfg);
 | 
				
			||||||
//	cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!! ENDDUMP");
 | 
					//	cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!! ENDDUMP");
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
						if (!params->elemdata->mand){
 | 
				
			||||||
 | 
							if (!cw_cfg_base_exists(params->cfg_list[0],key)){
 | 
				
			||||||
 | 
								cw_dbg(DBG_MSG_COMPOSE,"    Add Elem: %d %d %d %s %s - (bskip)", 
 | 
				
			||||||
 | 
									params->elemdata->proto, 
 | 
				
			||||||
 | 
									params->elemdata->vendor, 
 | 
				
			||||||
 | 
									params->elemdata->id, 
 | 
				
			||||||
 | 
									handler->name, key);
 | 
				
			||||||
 | 
								return 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	start = params->msgset->header_len(handler);
 | 
						start = params->msgset->header_len(handler);
 | 
				
			||||||
	len = ((const cw_Type_t*)(handler->type))->
 | 
						len = ((const cw_Type_t*)(handler->type))->
 | 
				
			||||||
		write(params->cfg_list,handler->key,dst+start,handler->param);
 | 
							write(params->cfg_list,key,dst+start,handler->param);
 | 
				
			||||||
//	cw_dbg(DBG_X, "Type result is %d",len);
 | 
					//	cw_dbg(DBG_X, "Type result is %d",len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (len == -1) {
 | 
						if (len == -1) {
 | 
				
			||||||
@ -62,7 +74,7 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
 | 
				
			|||||||
			cw_log(LOG_ERR,
 | 
								cw_log(LOG_ERR,
 | 
				
			||||||
			       "Can't put mandatory element %s %d-(%s) into %s. No value for '%s' found.",
 | 
								       "Can't put mandatory element %s %d-(%s) into %s. No value for '%s' found.",
 | 
				
			||||||
				vendor, handler->id, handler->name, params->msgdata->name
 | 
									vendor, handler->id, handler->name, params->msgdata->name
 | 
				
			||||||
			       , handler->key
 | 
								       , key
 | 
				
			||||||
			    );
 | 
								    );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
@ -79,6 +91,15 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
 | 
				
			|||||||
	l = params->msgset->write_header(handler,dst,len);
 | 
						l = params->msgset->write_header(handler,dst,len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return l;
 | 
						return l;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cw_out_generic0(handler,params,dst,handler->key);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -118,6 +139,39 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
 | 
				
			|||||||
	int radios;
 | 
						int radios;
 | 
				
			||||||
	len =0;
 | 
						len =0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (i=0; (i=cw_cfg_get_first_index_l(params->cfg_list,"radio",i))!=-1; i++){
 | 
				
			||||||
 | 
							sprintf(key,"radio.%d/%s",i,handler->key);
 | 
				
			||||||
 | 
							if (!params->elemdata->mand){
 | 
				
			||||||
 | 
								if (!cw_cfg_base_exists(params->cfg_list[0],key)){
 | 
				
			||||||
 | 
									cw_dbg(DBG_MSG_COMPOSE,"    Add Elem: %d %d %d %s %s - (skip)", 
 | 
				
			||||||
 | 
											params->elemdata->proto, 
 | 
				
			||||||
 | 
											params->elemdata->vendor, 
 | 
				
			||||||
 | 
											params->elemdata->id, 
 | 
				
			||||||
 | 
											handler->name, key);
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							type = (struct cw_Type*)handler->type;
 | 
				
			||||||
 | 
							start = params->msgset->header_len(handler)+len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							l = type->write(params->cfg_list, key,dst+start+1,handler->param);
 | 
				
			||||||
 | 
							if (l==-1)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							l += cw_put_byte(dst+start,i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							l = params->msgset->write_header(handler,dst+len,l);
 | 
				
			||||||
 | 
							len+=l;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	radios = cw_cfg_get_byte_l(params->cfg_list,"capwap/wtp-descriptor/max-radios",0);
 | 
						radios = cw_cfg_get_byte_l(params->cfg_list,"capwap/wtp-descriptor/max-radios",0);
 | 
				
			||||||
	for(i=0;i<radios;i++){
 | 
						for(i=0;i<radios;i++){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -270,3 +324,148 @@ cw_put_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	return d-dst;
 | 
						return d-dst;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst, int i, const char *current, const char * next, 
 | 
				
			||||||
 | 
								int * stack)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char *sl;
 | 
				
			||||||
 | 
						int l;
 | 
				
			||||||
 | 
						char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						int len;
 | 
				
			||||||
 | 
						len = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf("Next: %s\n", next);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sl = strchr(next,'/');
 | 
				
			||||||
 | 
						if (sl==NULL){
 | 
				
			||||||
 | 
							cw_Val_t * result;
 | 
				
			||||||
 | 
							sprintf(key,"%s/%s",current,next);
 | 
				
			||||||
 | 
							result = cw_ktv_base_exists(params->cfg,key);
 | 
				
			||||||
 | 
							if (result != NULL){
 | 
				
			||||||
 | 
								int offset;
 | 
				
			||||||
 | 
								int i,l;
 | 
				
			||||||
 | 
								offset = params->msgset->header_len(handler);
 | 
				
			||||||
 | 
								printf("Yea! We can do it: %s\n",result->key);
 | 
				
			||||||
 | 
								for (i=0;i<stack[0];i++){
 | 
				
			||||||
 | 
									printf("I=%i\n",stack[i+1]);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								l= cw_ktv_write_struct(params->cfg,params->cfg, 
 | 
				
			||||||
 | 
									handler->type,key,dst+offset);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								printf("Write struct len %i\n",l);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								l=params->msgset->write_header(handler,dst,l);
 | 
				
			||||||
 | 
								printf("header wr len %d\n",l);
 | 
				
			||||||
 | 
								if (handler->patch){
 | 
				
			||||||
 | 
									handler->patch(dst+offset,stack);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								return l;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						strcpy(key,current);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf("current is %s\n", current);	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (key[0!=0])
 | 
				
			||||||
 | 
							strcat(key,"/");
 | 
				
			||||||
 | 
						l = sl - next;
 | 
				
			||||||
 | 
						strncat(key,next,l);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						printf("Here we are %s\n",key);
 | 
				
			||||||
 | 
						cw_dbg_ktv_dump(params->cfg,DBG_INFO,"start"," ", "end" );
 | 
				
			||||||
 | 
						i=-1;
 | 
				
			||||||
 | 
						while(1){
 | 
				
			||||||
 | 
							char basekey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
							cw_Val_t * result;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							i = cw_ktv_idx_get_next(params->cfg,key,i+1);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (i==-1)
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							sprintf(basekey,"%s.%d",key,i);
 | 
				
			||||||
 | 
							printf("Our basekey is %s\n",basekey);
 | 
				
			||||||
 | 
							result = cw_ktv_base_exists(params->cfg,basekey);
 | 
				
			||||||
 | 
							if (result == NULL){
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							stack[0]++;
 | 
				
			||||||
 | 
							stack[stack[0]]=i;
 | 
				
			||||||
 | 
							len += cw_out_traverse0(handler,params,dst+len,-1,basekey,next+l+1, stack);
 | 
				
			||||||
 | 
							printf("Len is now %d\n", len);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return len;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					/*	char current[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						int stack[10];
 | 
				
			||||||
 | 
						stack[0]=0;
 | 
				
			||||||
 | 
						current[0]=0;
 | 
				
			||||||
 | 
					//	return cw_out_traverse0(handler,params,dst,-1,current,handler->key, stack);*/
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int walk0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
							, uint8_t * dst, const char *current, const char * next)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
					        const char *sl;
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
					        int len=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* Is this the last key ? */
 | 
				
			||||||
 | 
					        sl = strchr(next,'/');
 | 
				
			||||||
 | 
					        if (sl){
 | 
				
			||||||
 | 
					                char basekey[CW_CFG_MAX_KEY_LEN+13];
 | 
				
			||||||
 | 
					                int i,l;
 | 
				
			||||||
 | 
					                strcpy(key,current);
 | 
				
			||||||
 | 
					                l = sl - next;
 | 
				
			||||||
 | 
					                strncat(key,next,l);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                for (i=0; (i=cw_cfg_get_first_index_l(params->cfg_list,key,i))!=-1; i++){
 | 
				
			||||||
 | 
					                        sprintf(basekey,"%s.%d%c",key,i, *(sl+1) ?'/':'\0');
 | 
				
			||||||
 | 
					                        rc = walk0(handler,params,dst,basekey,next+l+1);
 | 
				
			||||||
 | 
								if (rc>0)
 | 
				
			||||||
 | 
									len+=rc;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        printf("Final %s [%s]\n",current,next);
 | 
				
			||||||
 | 
						return cw_out_generic0(handler,params,dst,current);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_out_generic_walk(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        char current[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
					//        int stack[10];
 | 
				
			||||||
 | 
					 //       stack[0]=0;
 | 
				
			||||||
 | 
					        current[0]=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return walk0(handler,params,dst,current,handler->key);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -558,6 +558,8 @@ int cw_put_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_send_request(struct cw_Conn *conn,int msg_id);
 | 
					int cw_send_request(struct cw_Conn *conn,int msg_id);
 | 
				
			||||||
 | 
					int cw_out_generic_walk(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *@}
 | 
					 *@}
 | 
				
			||||||
 | 
				
			|||||||
@ -3,9 +3,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "dbg.h"
 | 
					#include "dbg.h"
 | 
				
			||||||
#include "cw.h"
 | 
					#include "cw.h"
 | 
				
			||||||
 | 
					#include "cfg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Detect NAT after a join/discovery request
 | 
					 * @brief Detect NAT after a Join Request
 | 
				
			||||||
 * @param conn Connection object
 | 
					 * @param conn Connection object
 | 
				
			||||||
 * @retval 1 NAT detected
 | 
					 * @retval 1 NAT detected
 | 
				
			||||||
 * @retval 0 no NAT was detected
 | 
					 * @retval 0 no NAT was detected
 | 
				
			||||||
@ -15,7 +16,8 @@ int cw_detect_nat(struct cw_ElemHandlerParams *params)
 | 
				
			|||||||
	const char  * remote_str;
 | 
						const char  * remote_str;
 | 
				
			||||||
	char local_str[128];
 | 
						char local_str[128];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	remote_str = cw_cfg_get(params->cfg,"capwap-local-ip-address",NULL);
 | 
						remote_str = cw_cfg_get(params->cfg,"capwap/local-ip-address",NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (remote_str == NULL){
 | 
						if (remote_str == NULL){
 | 
				
			||||||
		cw_dbg(DBG_WARN,"Can't detect NAT. No local IP from peer received.");
 | 
							cw_dbg(DBG_WARN,"Can't detect NAT. No local IP from peer received.");
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
@ -29,9 +31,12 @@ int cw_detect_nat(struct cw_ElemHandlerParams *params)
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	/* if connected and sent address is the same, there is 
 | 
						/* if connected and sent address is the same, there is 
 | 
				
			||||||
	 * no NAT */
 | 
						 * no NAT */
 | 
				
			||||||
	if (strcmp(remote_str,local_str)==0)
 | 
						if (strcmp(remote_str,local_str)==0){
 | 
				
			||||||
 | 
							cw_dbg(DBG_INFO,"Connection from %s: no NAT detected.",local_str);
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
						}		
 | 
				
			||||||
	/* otherwise ther must be something between AC and WTP */
 | 
						/* otherwise ther must be something between AC and WTP */
 | 
				
			||||||
 | 
						cw_dbg(DBG_INFO,"Connection from %s: NAT detected.",local_str);
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,36 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
#include "msgset.h"
 | 
					 | 
				
			||||||
#include "val.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
 | 
					 | 
				
			||||||
		uint8_t * elem_data, int elem_len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_dbg(DBG_X,"STRUCT KEY: %s",handler->key);
 | 
					 | 
				
			||||||
	stop();
 | 
					 | 
				
			||||||
/*	const char * key;
 | 
					 | 
				
			||||||
	char tmpkey[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (handler->mkkey != NULL){
 | 
					 | 
				
			||||||
		handler->mkkey(key,elem_data,elem_len, tmpkey);
 | 
					 | 
				
			||||||
		key = tmpkey;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else{
 | 
					 | 
				
			||||||
		key = handler->key;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//printf("CW_IN_GENERIC STRUCT: %s\n",key);	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!handler->type){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
					 | 
				
			||||||
		return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_ktv_read_struct(params->cfg,handler->type,key,elem_data,elem_len);
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	return CAPWAP_RESULT_SUCCESS;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -10,12 +10,14 @@
 | 
				
			|||||||
int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
 | 
					int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
 | 
				
			||||||
		uint8_t * elem_data, int elem_len)
 | 
							uint8_t * elem_data, int elem_len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						stop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
	char key[CW_CFG_MAX_KEY_LEN];
 | 
						char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
	int idx;
 | 
						int idx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_X,"Fix cw_in_idx_generic_struct");
 | 
						cw_dbg(DBG_X,"Fix cw_in_idx_generic_struct");
 | 
				
			||||||
	stop();
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (!handler->type){
 | 
						if (!handler->type){
 | 
				
			||||||
		cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
							cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
				
			||||||
@ -26,6 +28,6 @@ int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHand
 | 
				
			|||||||
	sprintf(key, handler->key, idx);
 | 
						sprintf(key, handler->key, idx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_ktv_read_struct(params->cfg,handler->type,key,elem_data+1,elem_len-1);
 | 
						cw_ktv_read_struct(params->cfg,handler->type,key,elem_data+1,elem_len-1);
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
	return CAPWAP_RESULT_SUCCESS;
 | 
						return CAPWAP_RESULT_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -26,15 +26,16 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	e = ie->type;
 | 
						e = ie->type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	for(i=0; e[i].name!=NULL; i++) {
 | 
						for(i=0; e[i].name!=NULL; i++) {
 | 
				
			||||||
		int b;
 | 
							int b;
 | 
				
			||||||
		sprintf(key,"%s/%s",handler->key,e[i].name);
 | 
							sprintf(key,"%s/%s",handler->key,e[i].name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cw_dbg(DBG_X,"Her is the Key: %s %s\n",key,e[i].name);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		b = cw_cfg_base_exists_l(params->cfg_list,handler->key);
 | 
							b = cw_cfg_base_exists(params->cfg_list[0],handler->key);
 | 
				
			||||||
		if (!b){
 | 
							if (!b){
 | 
				
			||||||
			stop();
 | 
								//stop();
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		start = params->msgset->header_len(handler);
 | 
							start = params->msgset->header_len(handler);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,48 +0,0 @@
 | 
				
			|||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
#include "msgset.h"
 | 
					 | 
				
			||||||
#include "val.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					 | 
				
			||||||
			, uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_dbg(DBG_X,"Key: %s",handler->key);
 | 
					 | 
				
			||||||
	stop();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int start;
 | 
					 | 
				
			||||||
	int len;
 | 
					 | 
				
			||||||
	cw_Val_t search, *result;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!handler->type){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	search.key = (char*)handler->key;
 | 
					 | 
				
			||||||
	result = mavl_get_first(params->cfg,&search);
 | 
					 | 
				
			||||||
	if (result == NULL ){
 | 
					 | 
				
			||||||
		if (params->elemdata->mand)
 | 
					 | 
				
			||||||
			cw_log(LOG_ERR,"Can't put mandatory message element %s, no data available",handler->name);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (strncmp(result->key,handler->key, strlen(handler->key))!=0){
 | 
					 | 
				
			||||||
		if (params->elemdata->mand)
 | 
					 | 
				
			||||||
			cw_log(LOG_ERR,"Can't put mandatory message element %s, no data available",handler->name);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	start = params->msgset->header_len(handler);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	len = cw_ktv_write_struct(params->cfg,
 | 
					 | 
				
			||||||
		params->cfg,
 | 
					 | 
				
			||||||
		handler->type,handler->key,dst+start);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return params->msgset->write_header(handler,dst,len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -7,7 +7,7 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	stop();
 | 
						stop();
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
	char key[CW_CFG_MAX_KEY_LEN];
 | 
						char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
	struct cw_Val * elem, search;
 | 
						struct cw_Val * elem, search;
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
@ -26,7 +26,7 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		sprintf(key,handler->key,i);
 | 
							sprintf(key,handler->key,i);
 | 
				
			||||||
		search.key=key;
 | 
							search.key=key;
 | 
				
			||||||
		/*elem = mavl_get(params->conn->local_cfg, &search);*/
 | 
							/ * elem = mavl_get(params->conn->local_cfg, &search); * /
 | 
				
			||||||
		elem = mavl_get_first(params->cfg,&search);
 | 
							elem = mavl_get_first(params->cfg,&search);
 | 
				
			||||||
		if(elem != NULL){
 | 
							if(elem != NULL){
 | 
				
			||||||
			printf("Elem key: %s\n",elem->key);
 | 
								printf("Elem key: %s\n",elem->key);
 | 
				
			||||||
@ -55,14 +55,16 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
/*	radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0);
 | 
					/ *	radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for(i=1;i<radios+1;i++){
 | 
						for(i=1;i<radios+1;i++){
 | 
				
			||||||
		l = cw_write_radio_element(handler,params,i,dst+len);
 | 
							l = cw_write_radio_element(handler,params,i,dst+len);
 | 
				
			||||||
		cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
 | 
							cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
 | 
				
			||||||
		len+=l;
 | 
							len+=l;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
*/
 | 
					* /
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return mdst-dst;
 | 
						return mdst-dst;
 | 
				
			||||||
 | 
						*/ return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -42,106 +42,8 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		cdst+=params->msgset->write_header(handler,cdst,l);
 | 
							cdst+=params->msgset->write_header(handler,cdst,l);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return cdst-dst;
 | 
						return cdst-dst;*/
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					 | 
				
			||||||
			, uint8_t * dst, int i, const char *current, const char * next, 
 | 
					 | 
				
			||||||
			int * stack)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char *sl;
 | 
					 | 
				
			||||||
	int l;
 | 
					 | 
				
			||||||
	char key[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
	int len;
 | 
					 | 
				
			||||||
	len = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf("Next: %s\n", next);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sl = strchr(next,'/');
 | 
					 | 
				
			||||||
	if (sl==NULL){
 | 
					 | 
				
			||||||
		cw_Val_t * result;
 | 
					 | 
				
			||||||
		sprintf(key,"%s/%s",current,next);
 | 
					 | 
				
			||||||
		result = cw_ktv_base_exists(params->cfg,key);
 | 
					 | 
				
			||||||
		if (result != NULL){
 | 
					 | 
				
			||||||
			int offset;
 | 
					 | 
				
			||||||
			int i,l;
 | 
					 | 
				
			||||||
			offset = params->msgset->header_len(handler);
 | 
					 | 
				
			||||||
			printf("Yea! We can do it: %s\n",result->key);
 | 
					 | 
				
			||||||
			for (i=0;i<stack[0];i++){
 | 
					 | 
				
			||||||
				printf("I=%i\n",stack[i+1]);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			l= cw_ktv_write_struct(params->cfg,params->cfg, 
 | 
					 | 
				
			||||||
				handler->type,key,dst+offset);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			printf("Write struct len %i\n",l);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			l=params->msgset->write_header(handler,dst,l);
 | 
					 | 
				
			||||||
			printf("header wr len %d\n",l);
 | 
					 | 
				
			||||||
			if (handler->patch){
 | 
					 | 
				
			||||||
				handler->patch(dst+offset,stack);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			return l;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	strcpy(key,current);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf("current is %s\n", current);	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (key[0!=0])
 | 
					 | 
				
			||||||
		strcat(key,"/");
 | 
					 | 
				
			||||||
	l = sl - next;
 | 
					 | 
				
			||||||
	strncat(key,next,l);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	printf("Here we are %s\n",key);
 | 
					 | 
				
			||||||
	cw_dbg_ktv_dump(params->cfg,DBG_INFO,"start"," ", "end" );
 | 
					 | 
				
			||||||
	i=-1;
 | 
					 | 
				
			||||||
	while(1){
 | 
					 | 
				
			||||||
		char basekey[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
		cw_Val_t * result;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		i = cw_ktv_idx_get_next(params->cfg,key,i+1);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (i==-1)
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		sprintf(basekey,"%s.%d",key,i);
 | 
					 | 
				
			||||||
		printf("Our basekey is %s\n",basekey);
 | 
					 | 
				
			||||||
		result = cw_ktv_base_exists(params->cfg,basekey);
 | 
					 | 
				
			||||||
		if (result == NULL){
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		stack[0]++;
 | 
					 | 
				
			||||||
		stack[stack[0]]=i;
 | 
					 | 
				
			||||||
		len += cw_out_traverse0(handler,params,dst+len,-1,basekey,next+l+1, stack);
 | 
					 | 
				
			||||||
		printf("Len is now %d\n", len);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return len;
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					 | 
				
			||||||
			, uint8_t * dst)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//char current[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
	//int stack[10];
 | 
					 | 
				
			||||||
	//stack[0]=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//current[0]=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	stop();
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	return cw_out_traverse0(handler,params,dst,-1,current,handler->key, stack);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -49,6 +49,8 @@ int cw_setup_dtls(struct cw_Conn *conn, cw_Cfg_t * cfg, const char *prefix,
 | 
				
			|||||||
	sprintf(key, "%s/%s", prefix, "ssl-cipher");
 | 
						sprintf(key, "%s/%s", prefix, "ssl-cipher");
 | 
				
			||||||
	conn->dtls_cipher = cw_cfg_get(cfg, key, default_cipher);
 | 
						conn->dtls_cipher = cw_cfg_get(cfg, key, default_cipher);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg(DBG_DTLS,"Using cipher: %s",conn->dtls_cipher);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sprintf(key, "%s/%s", prefix, "ssl-psk");
 | 
						sprintf(key, "%s/%s", prefix, "ssl-psk");
 | 
				
			||||||
	conn->dtls_psk = (bstr16_t)cw_cfg_get(cfg, key, NULL);
 | 
						conn->dtls_psk = (bstr16_t)cw_cfg_get(cfg, key, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										188
									
								
								src/cw/cw_type_array.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										188
									
								
								src/cw/cw_type_array.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,188 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					    This file is part of libcapwap.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    libcapwap 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 3 of the License, or
 | 
				
			||||||
 | 
					    (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cw.h"
 | 
				
			||||||
 | 
					#include "val.h"
 | 
				
			||||||
 | 
					#include "dbg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_Val_t *get(cw_Val_t * data, const uint8_t * src, int len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						data->type = &cw_type_byte;
 | 
				
			||||||
 | 
						data->val.byte = cw_get_byte(src);
 | 
				
			||||||
 | 
						return data;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int put(const cw_Val_t *data, uint8_t * dst)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cw_put_byte(dst, data->val.byte);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char * get_guardstr(int val, const cw_ValValRange_t * valrange)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (valrange==NULL)
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while(valrange->name!=NULL){
 | 
				
			||||||
 | 
							if(val>=valrange->min && val<=valrange->max)
 | 
				
			||||||
 | 
								return valrange->name;
 | 
				
			||||||
 | 
							valrange++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int to_str(const cw_Val_t *data, char *dst, int max_len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (data->valguard!=NULL){
 | 
				
			||||||
 | 
							const char * name;
 | 
				
			||||||
 | 
							name = get_guardstr(data->val.byte,data->valguard);
 | 
				
			||||||
 | 
							if (name != NULL){
 | 
				
			||||||
 | 
								return sprintf(dst,"%s",name);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
							/*if (max_len<3){
 | 
				
			||||||
 | 
								return 0;
 | 
				
			||||||
 | 
							}*/
 | 
				
			||||||
 | 
						return sprintf(dst, "%d", data->val.byte);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int get_guardval(const char *str, const cw_ValValRange_t * valrange)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						while(valrange->name!=NULL){
 | 
				
			||||||
 | 
							if(strcmp(str,valrange->name)==0)
 | 
				
			||||||
 | 
								return valrange->min;
 | 
				
			||||||
 | 
							valrange++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return -1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_Val_t *from_str(cw_Val_t * data, const char *src)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						data->type = &cw_type_byte;
 | 
				
			||||||
 | 
						if (data->valguard != NULL){
 | 
				
			||||||
 | 
							int rc;
 | 
				
			||||||
 | 
							rc = get_guardval(src,data->valguard);
 | 
				
			||||||
 | 
							if (rc != -1){
 | 
				
			||||||
 | 
								data->val.byte = rc;
 | 
				
			||||||
 | 
								return data;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data->val.byte = atoi(src);
 | 
				
			||||||
 | 
						return data;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int len (cw_Val_t * data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return sizeof(data->val.byte);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void * data(cw_Val_t * data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return &data->val.byte;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char * get_type_name(cw_Val_t *data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (data->valguard != NULL){
 | 
				
			||||||
 | 
							return CW_TYPE_STR->name;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return CW_TYPE_BYTE->name;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int cast(cw_Val_t * data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (strcmp(data->type->name,CW_TYPE_BYTE->name)==0)
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
						if (strcmp(data->type->name,CW_TYPE_STR->name)==0){
 | 
				
			||||||
 | 
							char *src = data->val.ptr;
 | 
				
			||||||
 | 
							CW_TYPE_BYTE->from_str(data,src);
 | 
				
			||||||
 | 
							free(src);
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						uint8_t n,i;
 | 
				
			||||||
 | 
						int l;
 | 
				
			||||||
 | 
						char skey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						const struct cw_ValArrayDef * def = param;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						const int (*fun)(cw_Cfg_t*,const char *k,const uint8_t *s,int len,const void *p,int *l) = def->get_count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						n = fun(cfg,key,src,len,param,&l);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (i=0; i<n && l<len; i++){
 | 
				
			||||||
 | 
							sprintf(skey,"%s.%d",key,i);
 | 
				
			||||||
 | 
					//		printf("SKEY: %s\n",skey);
 | 
				
			||||||
 | 
							l+=def->type->read(cfg,skey,src,len,def->param);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return l;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static 	int bwrite(cw_Cfg_t ** cfgs, const char *key, uint8_t *dst, const void * param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int i,l;
 | 
				
			||||||
 | 
						char skey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						const struct cw_ValArrayDef * def = param;
 | 
				
			||||||
 | 
						const int (*fun)(cw_Cfg_t**,const char *k, uint8_t *s,const void *p,int l) = def->put_count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						i=0,l=0;
 | 
				
			||||||
 | 
						do {
 | 
				
			||||||
 | 
							sprintf(skey,"%s.%d",key,i);
 | 
				
			||||||
 | 
					//		printf("iSKEY %s\n",skey);
 | 
				
			||||||
 | 
							i++;
 | 
				
			||||||
 | 
							if (cw_cfg_get_l(cfgs,skey,NULL)==NULL){
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							l+=def->type->write(cfgs,skey,dst,def->param);
 | 
				
			||||||
 | 
						}while(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	printf("LEN: %d (K: %s)\n",l,key);
 | 
				
			||||||
 | 
						fun(cfgs,key,dst,param,l);
 | 
				
			||||||
 | 
						return l;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const struct cw_Type cw_type_array = {
 | 
				
			||||||
 | 
						"Array",			/* name */
 | 
				
			||||||
 | 
						NULL,			/* del */
 | 
				
			||||||
 | 
						put,			/* put */
 | 
				
			||||||
 | 
						get,			/* get */
 | 
				
			||||||
 | 
						to_str,			/* to_str */
 | 
				
			||||||
 | 
						from_str,		/* from_str */ 
 | 
				
			||||||
 | 
						len,			/* len */
 | 
				
			||||||
 | 
						data,			/* data */
 | 
				
			||||||
 | 
						get_type_name,		/* get_type_name */
 | 
				
			||||||
 | 
						cast,
 | 
				
			||||||
 | 
						bread,
 | 
				
			||||||
 | 
						bwrite
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -81,6 +81,7 @@ static int write_struct(cw_Cfg_t ** cfgs,  const cw_ValStruct_t * stru, const ch
 | 
				
			|||||||
	int pos, i;
 | 
						int pos, i;
 | 
				
			||||||
	const char * result;
 | 
						const char * result;
 | 
				
			||||||
	int wrlen;
 | 
						int wrlen;
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_Val_t val;
 | 
						cw_Val_t val;
 | 
				
			||||||
	memset(&val,0,sizeof(cw_Val_t));
 | 
						memset(&val,0,sizeof(cw_Val_t));
 | 
				
			||||||
@ -100,7 +101,9 @@ static int write_struct(cw_Cfg_t ** cfgs,  const cw_ValStruct_t * stru, const ch
 | 
				
			|||||||
		else	
 | 
							else	
 | 
				
			||||||
			sprintf(key,"%s",pkey);
 | 
								sprintf(key,"%s",pkey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		result = cw_cfg_get_l(cfgs,key,NULL);
 | 
						//	result = cw_cfg_get_l(cfgs,key,NULL);
 | 
				
			||||||
 | 
							rc = cw_cfg_base_exists_l(cfgs,key);
 | 
				
			||||||
 | 
					//		printf("Base? :%s, %d\n",key,rc);
 | 
				
			||||||
		if(result) {
 | 
							if(result) {
 | 
				
			||||||
//			char s[2048];
 | 
					//			char s[2048];
 | 
				
			||||||
//			result->type->to_str(result,s,2048);
 | 
					//			result->type->to_str(result,s,2048);
 | 
				
			||||||
@ -108,9 +111,15 @@ static int write_struct(cw_Cfg_t ** cfgs,  const cw_ValStruct_t * stru, const ch
 | 
				
			|||||||
		}	
 | 
							}	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (result == NULL){
 | 
							if (!rc){
 | 
				
			||||||
			cw_log(LOG_ERR,"Can't put %s, no value found, filling wth zeros.",key);
 | 
								int l;
 | 
				
			||||||
			memset(dst+pos,0,stru[i].len);
 | 
								cw_log(LOG_ERR,"Can't put %s, no value found, filling with zeros.",key);
 | 
				
			||||||
 | 
								l = stru[i].len;
 | 
				
			||||||
 | 
								if (l==-1)
 | 
				
			||||||
 | 
									l = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								memset(dst+pos,0,l);
 | 
				
			||||||
 | 
								wrlen=l;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
			struct cw_Type * type;
 | 
								struct cw_Type * type;
 | 
				
			||||||
 | 
				
			|||||||
@ -8,55 +8,38 @@
 | 
				
			|||||||
int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
 | 
					int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
 | 
				
			||||||
                                 int subelem_id, const char * parent_key )
 | 
					                                 int subelem_id, const char * parent_key )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char key[256];
 | 
						char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
	uint32_t vendor;
 | 
						uint32_t vendor;
 | 
				
			||||||
	//bstr16_t version;
 | 
						bstr16_t version;
 | 
				
			||||||
	const char *vendor_s;
 | 
						const char *vendor_s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint8_t *d;
 | 
						uint8_t *d;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*        d += cw_put_dword(d, bstrv_get_vendor_id(v));
 | 
					 | 
				
			||||||
	d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v));
 | 
					 | 
				
			||||||
	d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	sprintf (key, "%s/%s", parent_key, CW_SKEY_VENDOR);
 | 
						sprintf (key, "%s/%s", parent_key, CW_SKEY_VENDOR);
 | 
				
			||||||
	vendor_s = cw_cfg_get_l (cfg_list, key, NULL);
 | 
						vendor_s = cw_cfg_get_l (cfg_list, key, NULL);
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (vendor_s == NULL) {
 | 
						if (vendor_s == NULL) {
 | 
				
			||||||
		cw_log (LOG_ERR, "Can't put subelem %s, no value of type Dword found.", key);
 | 
							cw_log (LOG_ERR, "Can't put subelem %s, no value found. Setting zero.", key);
 | 
				
			||||||
		return 0;
 | 
							vendor_s = "0";
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vendor = atoi(vendor_s);	
 | 
						vendor = atoi(vendor_s);	
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sprintf (key, "%s/%s", parent_key, CW_SKEY_VERSION);
 | 
						sprintf (key, "%s/%s", parent_key, CW_SKEY_VERSION);
 | 
				
			||||||
	cw_Val_t * val = cw_cfg_get_val_l(cfg_list, key, CW_TYPE_BSTR16);
 | 
						version = cw_cfg_get_bstr16_l(cfg_list,key,NULL);
 | 
				
			||||||
 | 
						if (version == NULL) {
 | 
				
			||||||
	//version = cw_cfg_get_bstr16 (cfg, key, NULL);
 | 
							cw_log (LOG_ERR, "Can't put subelem %s, no value found. Setting zero.", key);
 | 
				
			||||||
 | 
							version = bstr16_create_from_str("0.0.0.0");
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (val == NULL) {
 | 
					 | 
				
			||||||
		cw_log (LOG_ERR, "Can't put subelem %s, no value of type Bstr16 found.", key);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	d = dst;
 | 
						d = dst;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/* put vendor */
 | 
						/* put vendor */
 | 
				
			||||||
	d += cw_put_dword(d, vendor); //->type->put (vendor, d);
 | 
						d += cw_put_dword(d, vendor); 
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/* put version */
 | 
						/* put version */
 | 
				
			||||||
 | 
						d += cw_put_dword (d, (subelem_id << 16) | bstr16_len(version));
 | 
				
			||||||
 | 
						d += cw_put_bstr16(d, version);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	d += cw_put_dword (d, (subelem_id << 16) | val->type->len(val));
 | 
						free(version);
 | 
				
			||||||
//	d += cw_put_bstr16(d, version);
 | 
					 | 
				
			||||||
	d += val->type->put(val,d);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_val_destroy(val);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	free(version);
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return d-dst;
 | 
						return d-dst;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										24
									
								
								src/cw/dbg.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/cw/dbg.c
									
									
									
									
									
								
							@ -90,7 +90,8 @@ static struct cw_StrListElem theme0[] = {
 | 
				
			|||||||
	{DBG_RFC, ANSI_BRED},
 | 
						{DBG_RFC, ANSI_BRED},
 | 
				
			||||||
	{DBG_X, "\x1b[31m"},
 | 
						{DBG_X, "\x1b[31m"},
 | 
				
			||||||
	{DBG_WARN, ANSI_CYAN},
 | 
						{DBG_WARN, ANSI_CYAN},
 | 
				
			||||||
	{DBG_MOD, ANSI_WHITE},
 | 
						{DBG_MOD_DETAIL, ANSI_WHITE},
 | 
				
			||||||
 | 
						{DBG_MOD, ANSI_BBLACK ANSI_BOLD },
 | 
				
			||||||
//	{DBG_CFG_DMP, ANSI_BCYAN }, 
 | 
					//	{DBG_CFG_DMP, ANSI_BCYAN }, 
 | 
				
			||||||
	{DBG_CFG_UPDATES,ANSI_GREEN},	
 | 
						{DBG_CFG_UPDATES,ANSI_GREEN},	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -117,23 +118,24 @@ static struct cw_StrListElem color_off[] = {
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct cw_StrListElem prefix[] = {
 | 
					static struct cw_StrListElem prefix[] = {
 | 
				
			||||||
	{DBG_INFO, 		"Info -"},
 | 
						{DBG_INFO, 		"Info - "},
 | 
				
			||||||
	{DBG_PKT_IN, 		"Pkt In  -"},
 | 
						{DBG_PKT_IN, 		"Pkt In  - "},
 | 
				
			||||||
	{DBG_PKT_OUT, 		"Pkt Out -"},
 | 
						{DBG_PKT_OUT, 		"Pkt Out - "},
 | 
				
			||||||
	{DBG_MSG_IN, 		"Msg In  - "},
 | 
						{DBG_MSG_IN, 		"Msg In  - "},
 | 
				
			||||||
	{DBG_MSG_OUT,		"Msg Out - "},
 | 
						{DBG_MSG_OUT,		"Msg Out - "},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{DBG_ELEM_IN, 		"  Msg Element -"},
 | 
						{DBG_ELEM_IN, 		"  Msg Element - "},
 | 
				
			||||||
	{DBG_ELEM_OUT,		"  Msg Element -"},
 | 
						{DBG_ELEM_OUT,		"  Msg Element - "},
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	{DBG_MSG_ERR, 		"  Msg Error -"},
 | 
						{DBG_MSG_ERR, 		"  Msg Error - "},
 | 
				
			||||||
	{DBG_PKT_ERR, 		"  Pkt Error -"},
 | 
						{DBG_PKT_ERR, 		"  Pkt Error - "},
 | 
				
			||||||
	{DBG_ELEM_ERR, 		"  Elem Error -"},
 | 
						{DBG_ELEM_ERR, 		"  Elem Error - "},
 | 
				
			||||||
	{DBG_RFC, 		"  RFC -"},
 | 
						{DBG_RFC, 		"  RFC - "},
 | 
				
			||||||
	{DBG_DTLS, 		"DTLS - "},
 | 
						{DBG_DTLS, 		"DTLS - "},
 | 
				
			||||||
	{DBG_DTLS_DETAIL,	 "DTLS - "},
 | 
						{DBG_DTLS_DETAIL,	 "DTLS - "},
 | 
				
			||||||
	{DBG_WARN,	 	"  Warning - "},
 | 
						{DBG_WARN,	 	"Warning - "},
 | 
				
			||||||
	{DBG_MOD, 		"Mod - "},
 | 
						{DBG_MOD, 		"Mod - "},
 | 
				
			||||||
 | 
						{DBG_MOD_DETAIL,	"Mod - "},
 | 
				
			||||||
	{DBG_STATE, 		"STATEMACHINE - "},
 | 
						{DBG_STATE, 		"STATEMACHINE - "},
 | 
				
			||||||
	{DBG_CFG_UPDATES,	"Cfg - "},
 | 
						{DBG_CFG_UPDATES,	"Cfg - "},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -125,6 +125,9 @@ enum cw_dbg_levels{
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DBG_X		= (1<<30),
 | 
						DBG_X		= (1<<30),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DBG_MOD_DETAIL	= (1<<31),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DBG_ALL 	= (0x7fffffff),
 | 
						DBG_ALL 	= (0x7fffffff),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -65,6 +65,7 @@ struct cw_StrListElem cw_dbg_strings[] = {
 | 
				
			|||||||
	{ DBG_DTLS_DETAIL, 	"dtls_detail"},
 | 
						{ DBG_DTLS_DETAIL, 	"dtls_detail"},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ DBG_CFG_UPDATES, 	"cfg_updates" },
 | 
						{ DBG_CFG_UPDATES, 	"cfg_updates" },
 | 
				
			||||||
 | 
						{ DBG_X,		"x" },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
//	{DBG_CFG_DMP, "cfg_dmp" },
 | 
					//	{DBG_CFG_DMP, "cfg_dmp" },
 | 
				
			||||||
@ -121,7 +122,7 @@ struct cw_dbg_cfgstrs cw_dbg_cfgstrs[] = {
 | 
				
			|||||||
	{"elem_err",DBG_ELEM_ERR},
 | 
						{"elem_err",DBG_ELEM_ERR},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{"dtls",DBG_DTLS},
 | 
						{"dtls",DBG_DTLS},
 | 
				
			||||||
	{"dtls_dietail",DBG_DTLS_DETAIL},
 | 
						{"dtls_detail",DBG_DTLS_DETAIL},
 | 
				
			||||||
	{"dtls_bio",DBG_DTLS_BIO},
 | 
						{"dtls_bio",DBG_DTLS_BIO},
 | 
				
			||||||
	{"dtls_bio_dmp",DBG_DTLS_BIO_DMP},
 | 
						{"dtls_bio_dmp",DBG_DTLS_BIO_DMP},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -305,7 +305,10 @@ static unsigned int psk_server_cb(SSL *ssl,const char *identity, unsigned char *
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static unsigned int timer_cb(SSL *s, unsigned int timer_us)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return 5000000;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const SSL_METHOD * method, BIO_METHOD * bio)
 | 
					struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const SSL_METHOD * method, BIO_METHOD * bio)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -322,7 +325,7 @@ struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const
 | 
				
			|||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rc = SSL_CTX_get_security_level(d->ctx);
 | 
					//	rc = SSL_CTX_get_security_level(d->ctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SSL_CTX_set_security_level(d->ctx,0);
 | 
						SSL_CTX_set_security_level(d->ctx,0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -338,6 +341,8 @@ struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const
 | 
				
			|||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* set dtls psk if exists */
 | 
						/* set dtls psk if exists */
 | 
				
			||||||
/*	if (conn->dtls_psk)
 | 
					/*	if (conn->dtls_psk)
 | 
				
			||||||
		SSL_CTX_set_psk_server_callback( d->ctx, psk_server_cb);
 | 
							SSL_CTX_set_psk_server_callback( d->ctx, psk_server_cb);
 | 
				
			||||||
@ -456,6 +461,7 @@ struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const
 | 
				
			|||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DTLS_set_timer_cb(d->ssl,timer_cb);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	d->bio = BIO_new(bio);
 | 
						d->bio = BIO_new(bio);
 | 
				
			||||||
/*	d->bio->ptr = conn;*/
 | 
					/*	d->bio->ptr = conn;*/
 | 
				
			||||||
 | 
				
			|||||||
@ -27,6 +27,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "cw.h"
 | 
					#include "cw.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "capwap80211.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Format bytes as hex string.
 | 
					 * Format bytes as hex string.
 | 
				
			||||||
 * @param dst Destination buffer
 | 
					 * @param dst Destination buffer
 | 
				
			||||||
@ -87,4 +89,18 @@ int format_hdr_flags(char *dst, uint8_t * th)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char * cw_format_radio_information(char * dst, int ri)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char *d = dst;	
 | 
				
			||||||
 | 
						if (ri & CW_80211_RADIO_TYPE_A)
 | 
				
			||||||
 | 
							*d++='a';
 | 
				
			||||||
 | 
						if (ri & CW_80211_RADIO_TYPE_B)
 | 
				
			||||||
 | 
							*d++='b';
 | 
				
			||||||
 | 
						if (ri & CW_80211_RADIO_TYPE_G)
 | 
				
			||||||
 | 
							*d++='g';
 | 
				
			||||||
 | 
						if (ri & CW_80211_RADIO_TYPE_N)
 | 
				
			||||||
 | 
							*d++='n';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*d=0;
 | 
				
			||||||
 | 
						return dst;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -112,6 +112,9 @@ int cw_format_pkt_hdr(char *dst, int incomming, uint8_t * packet, int len,
 | 
				
			|||||||
		      struct sockaddr *from);
 | 
							      struct sockaddr *from);
 | 
				
			||||||
int cw_format_version(char *s, const uint8_t * version, int len);
 | 
					int cw_format_version(char *s, const uint8_t * version, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char * cw_format_radio_information(char * dst, int ri);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**@}*/
 | 
					/**@}*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -151,7 +151,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define LW_ELEM_CERTIFICATE				44
 | 
					#define LW_ELEM_CERTIFICATE				44
 | 
				
			||||||
#define LW_ELEM_WTP_BOARD_DATA				50
 | 
					#define LW_ELEM_WTP_BOARD_DATA				50
 | 
				
			||||||
#define LW_BCAST_SSID_MODE				51
 | 
					#define LWAPP_ELEM_BCAST_SSID_MODE			51
 | 
				
			||||||
#define LW_ELEM_WTP_MODE_AND_TYPE			54
 | 
					#define LW_ELEM_WTP_MODE_AND_TYPE			54
 | 
				
			||||||
#define LW_ELEM_QOS					57
 | 
					#define LW_ELEM_QOS					57
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -38,16 +38,16 @@ int cw_encode_elements(struct cw_ElemHandlerParams *params, mlist_t elements_lis
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
		if (!data->mand){
 | 
							if (!data->mand){
 | 
				
			||||||
			if (!cw_cfg_base_exists(params->cfg_list[0],handler->key)){
 | 
								if (!cw_cfg_base_exists(params->cfg_list[0],handler->key)){
 | 
				
			||||||
				cw_dbg(DBG_MSG_COMPOSE,"    Add Elem: %d %d %d %s - (skip)", 
 | 
									cw_dbg(DBG_MSG_COMPOSE,"    Add Elem: %d %d %d %s %s - (skip)", 
 | 
				
			||||||
						data->proto, data->vendor, data->id, handler->name);
 | 
											data->proto, data->vendor, data->id, handler->name, handler->key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		l = handler->put(handler,params,dst+len);
 | 
							l = handler->put(handler,params,dst+len);
 | 
				
			||||||
		cw_dbg(DBG_MSG_COMPOSE,"    Add Elem: %d %d %d %s - (%d bytes)", 
 | 
							cw_dbg(DBG_MSG_COMPOSE,"    Add Elem: %d %d %d %s - (%d bytes)", 
 | 
				
			||||||
@ -233,6 +233,10 @@ int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* check the length of the message */
 | 
						/* check the length of the message */
 | 
				
			||||||
	if (len < handler->min_len) {
 | 
						if (len < handler->min_len) {
 | 
				
			||||||
 | 
							if (!handler->flags || cw_dbg_is_level(DBG_ELEM_VNDR))
 | 
				
			||||||
 | 
								cw_dbg_elem(params->dbg_level, NULL, params->msgdata->type, handler,
 | 
				
			||||||
 | 
									    data, len);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		cw_dbg(DBG_ELEM_ERR,
 | 
							cw_dbg(DBG_ELEM_ERR,
 | 
				
			||||||
		       "%d (%s) message element too short, len=%d, min len=%d",
 | 
							       "%d (%s) message element too short, len=%d, min len=%d",
 | 
				
			||||||
		       handler->id, handler->name, len, handler->min_len);
 | 
							       handler->id, handler->name, len, handler->min_len);
 | 
				
			||||||
@ -246,6 +250,10 @@ int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (len > handler->max_len && handler->max_len) {
 | 
						if (len > handler->max_len && handler->max_len) {
 | 
				
			||||||
 | 
							if (!handler->flags || cw_dbg_is_level(DBG_ELEM_VNDR))
 | 
				
			||||||
 | 
								cw_dbg_elem(params->dbg_level, NULL, params->msgdata->type, handler,
 | 
				
			||||||
 | 
									    data, len);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
		cw_dbg(DBG_ELEM_ERR,
 | 
							cw_dbg(DBG_ELEM_ERR,
 | 
				
			||||||
		       "%d (%s) message element too big, len=%d, max len=%d",
 | 
							       "%d (%s) message element too big, len=%d, max len=%d",
 | 
				
			||||||
		       handler->id, handler->name, len, handler->max_len);
 | 
							       handler->id, handler->name, len, handler->max_len);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								src/cw/mod.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/cw/mod.c
									
									
									
									
									
								
							@ -139,14 +139,14 @@ struct cw_Mod *cw_mod_load(const char *mod_name, cw_Cfg_t * global_cfg, int role
 | 
				
			|||||||
	/* Search for the module in mods_loaded, to see if it is
 | 
						/* Search for the module in mods_loaded, to see if it is
 | 
				
			||||||
	 * already loaded or was statically linked */
 | 
						 * already loaded or was statically linked */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_MOD, "MOD: Load module '%s'", mod_name);
 | 
						cw_dbg(DBG_MOD, "Loading module '%s'.", mod_name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset(&search, 0, sizeof(search));
 | 
						memset(&search, 0, sizeof(search));
 | 
				
			||||||
	search.name = mod_name;
 | 
						search.name = mod_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mod = mavl_get_ptr(mods_loaded, &search);
 | 
						mod = mavl_get_ptr(mods_loaded, &search);
 | 
				
			||||||
	if (mod) {
 | 
						if (mod) {
 | 
				
			||||||
		cw_dbg(DBG_MOD, "MOD: Module already loaded '%s'", mod_name);
 | 
							cw_dbg(DBG_MOD, "Module already loaded: '%s'.", mod_name);
 | 
				
			||||||
		return mod;
 | 
							return mod;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -165,7 +165,7 @@ struct cw_Mod *cw_mod_load(const char *mod_name, cw_Cfg_t * global_cfg, int role
 | 
				
			|||||||
	if (filename == NULL)
 | 
						if (filename == NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_MOD, "MOD: loading module from file: %s", filename);
 | 
						cw_dbg(DBG_MOD, "Loading module from file: %s", filename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Open the DLL */
 | 
						/* Open the DLL */
 | 
				
			||||||
	handle = dlopen(filename, RTLD_NOW);
 | 
						handle = dlopen(filename, RTLD_NOW);
 | 
				
			||||||
@ -189,8 +189,11 @@ struct cw_Mod *cw_mod_load(const char *mod_name, cw_Cfg_t * global_cfg, int role
 | 
				
			|||||||
		goto errX;
 | 
							goto errX;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_MOD, "MOD: %s sucessfull loaded, calling init now.", filename);
 | 
						cw_dbg(DBG_MOD, "Module %s sucessfull loaded, calling init now.", filename);
 | 
				
			||||||
	mod->init(mod, global_cfg, role);
 | 
						if (!mod->init(mod, global_cfg, role)){
 | 
				
			||||||
 | 
							dlclose(handle);
 | 
				
			||||||
 | 
							mod=NULL;
 | 
				
			||||||
 | 
						}		
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
      errX:
 | 
					      errX:
 | 
				
			||||||
	free(filename);
 | 
						free(filename);
 | 
				
			||||||
 | 
				
			|||||||
@ -56,7 +56,7 @@ struct cw_Mod {
 | 
				
			|||||||
		int elems_len, struct sockaddr * from, int mode);
 | 
							int elems_len, struct sockaddr * from, int mode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct cw_MsgSet * (*register_messages)(struct cw_MsgSet * set, int mode);
 | 
						struct cw_MsgSet * (*register_messages)(struct cw_MsgSet * set, int mode );
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/** 
 | 
						/** 
 | 
				
			||||||
	 * Handle returned by dlopen, if this module was loaded 
 | 
						 * Handle returned by dlopen, if this module was loaded 
 | 
				
			||||||
 | 
				
			|||||||
@ -223,7 +223,7 @@ static int update_msgdata(struct cw_MsgSet *set, struct cw_MsgData *msgdata,
 | 
				
			|||||||
				break;
 | 
									break;
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			case CW_DELETE:
 | 
								case CW_DELETE:
 | 
				
			||||||
				cw_dbg(DBG_MOD, "  deleting message element %d %d %d - %s",
 | 
									cw_dbg(DBG_MOD_DETAIL, "  deleting message element %d %d %d - %s",
 | 
				
			||||||
				       elemdef->proto,
 | 
									       elemdef->proto,
 | 
				
			||||||
				       elemdef->vendor, elemdef->id, handler->name);
 | 
									       elemdef->vendor, elemdef->id, handler->name);
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
@ -248,11 +248,11 @@ static int update_msgdata(struct cw_MsgSet *set, struct cw_MsgData *msgdata,
 | 
				
			|||||||
		result = mavl_replace(msgdata->elements_tree, &ed, &replaced);
 | 
							result = mavl_replace(msgdata->elements_tree, &ed, &replaced);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!replaced) {
 | 
							if (!replaced) {
 | 
				
			||||||
			cw_dbg(DBG_MOD, "  adding message element %d %d %d - %s",
 | 
								cw_dbg(DBG_MOD_DETAIL, "  adding message element %d %d %d - %s",
 | 
				
			||||||
			       elemdef->proto,
 | 
								       elemdef->proto,
 | 
				
			||||||
			       elemdef->vendor, elemdef->id, handler->name);
 | 
								       elemdef->vendor, elemdef->id, handler->name);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			cw_dbg(DBG_MOD, "  replacing message element %d %d %d - %s",
 | 
								cw_dbg(DBG_MOD_DETAIL, "  replacing message element %d %d %d - %s",
 | 
				
			||||||
			       elemdef->proto,
 | 
								       elemdef->proto,
 | 
				
			||||||
			       elemdef->vendor, elemdef->id, handler->name);
 | 
								       elemdef->vendor, elemdef->id, handler->name);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -275,7 +275,7 @@ static int update_msgdata(struct cw_MsgSet *set, struct cw_MsgData *msgdata,
 | 
				
			|||||||
						    result->vendor, result->id);
 | 
											    result->vendor, result->id);
 | 
				
			||||||
		if (result->mand){
 | 
							if (result->mand){
 | 
				
			||||||
			mlist_append_ptr(msgdata->mand_keys,(void*)handler->key);
 | 
								mlist_append_ptr(msgdata->mand_keys,(void*)handler->key);
 | 
				
			||||||
			cw_dbg(DBG_MOD,"    Add mandatory key: %s",handler->key);
 | 
								cw_dbg(DBG_MOD_DETAIL,"    Add mandatory key: %s",handler->key);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		/*//printf("Have Result %d %d - %s\n",result->id,result->mand, handler->key);*/
 | 
							/*//printf("Have Result %d %d - %s\n",result->id,result->mand, handler->key);*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -294,7 +294,7 @@ int cw_msgset_add(struct cw_MsgSet *set,
 | 
				
			|||||||
	struct cw_MsgDef *msgdef;
 | 
						struct cw_MsgDef *msgdef;
 | 
				
			||||||
	/* Create mavl for all handlers */
 | 
						/* Create mavl for all handlers */
 | 
				
			||||||
	for (handler = handlers; handler->id; handler++) {
 | 
						for (handler = handlers; handler->id; handler++) {
 | 
				
			||||||
		cw_dbg(DBG_MOD, "Adding handler for element %d - %s - with key: %s",
 | 
							cw_dbg(DBG_MOD_DETAIL, "Adding handler for element %d - %s - with key: %s",
 | 
				
			||||||
		       handler->id, handler->name, handler->key);
 | 
							       handler->id, handler->name, handler->key);
 | 
				
			||||||
		mavl_replace(set->handlers_by_id, handler, NULL);
 | 
							mavl_replace(set->handlers_by_id, handler, NULL);
 | 
				
			||||||
		mavl_replace(set->handlers_by_key, handler, NULL);
 | 
							mavl_replace(set->handlers_by_key, handler, NULL);
 | 
				
			||||||
@ -339,7 +339,7 @@ int cw_msgset_add(struct cw_MsgSet *set,
 | 
				
			|||||||
		msg->receiver = msgdef->receiver;
 | 
							msg->receiver = msgdef->receiver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cw_dbg(DBG_MOD, "Add message Type:%d - %s ", msgdef->type, msgdef->name);
 | 
							cw_dbg(DBG_MOD_DETAIL, "Add message Type:%d - %s ", msgdef->type, msgdef->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		update_msgdata(set, msg, msgdef);
 | 
							update_msgdata(set, msg, msgdef);
 | 
				
			||||||
@ -376,7 +376,7 @@ int cw_msgset_add_states(struct cw_MsgSet * set, cw_StateMachineState_t * states
 | 
				
			|||||||
		else{
 | 
							else{
 | 
				
			||||||
			repstr = "Adding";
 | 
								repstr = "Adding";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		cw_dbg(DBG_MOD,"%s machine state : [%s->%s]",repstr,
 | 
							cw_dbg(DBG_MOD_DETAIL,"%s machine state : [%s->%s]",repstr,
 | 
				
			||||||
			cw_strstate(s->prevstate),
 | 
								cw_strstate(s->prevstate),
 | 
				
			||||||
			cw_strstate(s->state));
 | 
								cw_strstate(s->state));
 | 
				
			||||||
		s++;
 | 
							s++;
 | 
				
			||||||
@ -405,7 +405,9 @@ struct cw_MsgData *cw_msgset_get_msgdata(struct cw_MsgSet *set, int type)
 | 
				
			|||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
					//typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
					cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
				
			||||||
	cw_MsgCallbackFun fun)
 | 
						cw_MsgCallbackFun fun)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -420,5 +422,5 @@ cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
				
			|||||||
	return old_callback;
 | 
						return old_callback;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -146,9 +146,8 @@ struct cw_ElemHandler * cw_msgset_get_elemhandler(struct cw_MsgSet * set,
 | 
				
			|||||||
#define CW_MSGSET_POSTPROCESS	1
 | 
					#define CW_MSGSET_POSTPROCESS	1
 | 
				
			||||||
#define CW_MSGSET_PREPROCESS	2
 | 
					#define CW_MSGSET_PREPROCESS	2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
					//cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
				
			||||||
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
					//	cw_MsgCallbackFun fun);
 | 
				
			||||||
	cw_MsgCallbackFun fun);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -1,51 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef __RADIOINFO_H
 | 
					 | 
				
			||||||
#define __RADIOINFO_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "bstr.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct radioinfo{
 | 
					 | 
				
			||||||
	char set;
 | 
					 | 
				
			||||||
	int rid;
 | 
					 | 
				
			||||||
	uint32_t type;
 | 
					 | 
				
			||||||
	int admin_state;
 | 
					 | 
				
			||||||
	int state;
 | 
					 | 
				
			||||||
	int cause;
 | 
					 | 
				
			||||||
	bstr_t rmac;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uint16_t regDomain;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uint8_t country_str[4];
 | 
					 | 
				
			||||||
	uint8_t country_str2[4];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int cfp_period;
 | 
					 | 
				
			||||||
	int cfp_max_duration;
 | 
					 | 
				
			||||||
	int beacon_period;
 | 
					 | 
				
			||||||
	int dtim_period;
 | 
					 | 
				
			||||||
	int max_bssid;
 | 
					 | 
				
			||||||
	int occupancy_limit;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	bstr_t bssid;	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@ -1,89 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @file
 | 
					 | 
				
			||||||
 * @brief bstr_create_from_cfgstr function
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "bstr.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Create a bstr16_t string from a string read from config file.
 | 
					 | 
				
			||||||
 * 
 | 
					 | 
				
			||||||
 * @param s String from config file.
 | 
					 | 
				
			||||||
 * @return The create bstr_t string.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * The string from config file is an ASCII-text which is interpreted
 | 
					 | 
				
			||||||
 * as hexadecimal string if it starts with ".x"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @see bstr16_t
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
uint8_t * bstr16_create_from_cfgstr(const char * s)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int l = strlen(s);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (s[0]!='.')
 | 
					 | 
				
			||||||
		return bstr16_create((uint8_t*)s,l);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (l<=2)
 | 
					 | 
				
			||||||
		return bstr16_create((uint8_t*)s,l);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (s[1]=='.')
 | 
					 | 
				
			||||||
		return bstr16_create((uint8_t*)s+1,l-1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (s[1]=='x'){
 | 
					 | 
				
			||||||
		uint8_t * ns=0;
 | 
					 | 
				
			||||||
		int len=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		int ch,cl;
 | 
					 | 
				
			||||||
		const char *ss = s+2;
 | 
					 | 
				
			||||||
		int rc ;
 | 
					 | 
				
			||||||
		do {
 | 
					 | 
				
			||||||
			rc = sscanf(ss,"%01X",&ch);
 | 
					 | 
				
			||||||
			if (rc!=1)
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			ss++;
 | 
					 | 
				
			||||||
			rc = sscanf(ss,"%01X",&cl);
 | 
					 | 
				
			||||||
			if (rc!=1)
 | 
					 | 
				
			||||||
				cl=0;
 | 
					 | 
				
			||||||
			ss++;
 | 
					 | 
				
			||||||
			int c=(ch<<4) | cl;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			len++;
 | 
					 | 
				
			||||||
			ns = realloc(ns,len);
 | 
					 | 
				
			||||||
			ns[len-1]=c;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}while (rc==1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return bstr16_create(ns,len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,67 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "bstr.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Create a bstr1616_t string from a string read from config file.
 | 
					 | 
				
			||||||
 * 
 | 
					 | 
				
			||||||
 * @param s String from config file.
 | 
					 | 
				
			||||||
 * @return The create bstr16_t string.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * The string from config file is an ASCII-text which is interpreted
 | 
					 | 
				
			||||||
 * as hexadecimal string if it starts with ".x"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @see bstr16_t
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
uint8_t * bstr16cfgstr(const char * s)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int l = strlen(s);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (s[0]!='.')
 | 
					 | 
				
			||||||
		return bstr16_create((uint8_t*)s,l);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (l<=2)
 | 
					 | 
				
			||||||
		return bstr16_create((uint8_t*)s,l);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (s[1]=='.')
 | 
					 | 
				
			||||||
		return bstr16_create((uint8_t*)s+1,l-1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (s[1]=='x'){
 | 
					 | 
				
			||||||
		uint8_t * ns=0;
 | 
					 | 
				
			||||||
		int len=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		int ch,cl;
 | 
					 | 
				
			||||||
		const char *ss = s+2;
 | 
					 | 
				
			||||||
		int rc ;
 | 
					 | 
				
			||||||
		do {
 | 
					 | 
				
			||||||
			rc = sscanf(ss,"%01X",&ch);
 | 
					 | 
				
			||||||
			if (rc!=1)
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			ss++;
 | 
					 | 
				
			||||||
			rc = sscanf(ss,"%01X",&cl);
 | 
					 | 
				
			||||||
			if (rc!=1)
 | 
					 | 
				
			||||||
				cl=0;
 | 
					 | 
				
			||||||
			ss++;
 | 
					 | 
				
			||||||
			int c=(ch<<4) | cl;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			len++;
 | 
					 | 
				
			||||||
			ns = realloc(ns,len);
 | 
					 | 
				
			||||||
			ns[len-1]=c;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}while (rc==1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return bstr16_create(ns,len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,90 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @file
 | 
					 | 
				
			||||||
 * @brief bstr_create_from_cfgstr function
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "bstr.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Create a bstr_t string from a string read from config file.
 | 
					 | 
				
			||||||
 * 
 | 
					 | 
				
			||||||
 * @param s String from config file.
 | 
					 | 
				
			||||||
 * @return The create bstr_t string.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * The string from config file is an ASCII-text which is interpreted
 | 
					 | 
				
			||||||
 * as hexadecimal string if it starts with ".x"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @see bstr_t
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
uint8_t * bstr_create_from_cfgstr(const char * s)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int l = strlen(s);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (s[0]!='.')
 | 
					 | 
				
			||||||
		return bstr_create((uint8_t*)s,l);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (l<=2)
 | 
					 | 
				
			||||||
		return bstr_create((uint8_t*)s,l);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (s[1]=='.')
 | 
					 | 
				
			||||||
		return bstr_create((uint8_t*)s+1,l-1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (s[1]=='x'){
 | 
					 | 
				
			||||||
		uint8_t * ns=0;
 | 
					 | 
				
			||||||
		int len=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		int ch,cl;
 | 
					 | 
				
			||||||
		const char *ss = s+2;
 | 
					 | 
				
			||||||
		int rc ;
 | 
					 | 
				
			||||||
		do {
 | 
					 | 
				
			||||||
			rc = sscanf(ss,"%01X",&ch);
 | 
					 | 
				
			||||||
			if (rc!=1)
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			ss++;
 | 
					 | 
				
			||||||
			rc = sscanf(ss,"%01X",&cl);
 | 
					 | 
				
			||||||
			if (rc!=1)
 | 
					 | 
				
			||||||
				cl=0;
 | 
					 | 
				
			||||||
			ss++;
 | 
					 | 
				
			||||||
			int c=(ch<<4) | cl;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			len++;
 | 
					 | 
				
			||||||
			ns = realloc(ns,len);
 | 
					 | 
				
			||||||
			ns[len-1]=c;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}while (rc==1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return bstr_create(ns,len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,38 +0,0 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "bstr.h"
 | 
					 | 
				
			||||||
#include "cw_util.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int bstr_to_str(char *dst, bstr_t str,char * def)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (!str){
 | 
					 | 
				
			||||||
		if (!def) 
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		return sprintf(dst,"%s",def);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int printable = cw_is_printable(bstr_data(str),bstr_len(str));
 | 
					 | 
				
			||||||
	int l=bstr_len(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (printable){
 | 
					 | 
				
			||||||
		memcpy((char*)dst,bstr_data(str),l);
 | 
					 | 
				
			||||||
		*(dst+l)=0;
 | 
					 | 
				
			||||||
		return l;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
	int c=0;
 | 
					 | 
				
			||||||
	char *s = dst; 
 | 
					 | 
				
			||||||
	for (i=0; i<l; i++){
 | 
					 | 
				
			||||||
		if (!c){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			s += sprintf(s,"%02X",bstr_data(str)[i]);
 | 
					 | 
				
			||||||
			c=1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			s += sprintf(s,",%02X",bstr_data(str)[i]);
 | 
					 | 
				
			||||||
	}	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return s-dst;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,126 +0,0 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "capwap80211_types.h"
 | 
					 | 
				
			||||||
#include "dot11.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int to_str(void *item,char *dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	mbag_item_t *it= item;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uint8_t *data = (uint8_t*)it->u2.data;
 | 
					 | 
				
			||||||
	int n=*data;
 | 
					 | 
				
			||||||
	data++;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	char *d=dst;
 | 
					 | 
				
			||||||
	char *space="";
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
	for (i=0; i<n; i++){
 | 
					 | 
				
			||||||
		int val = data[i];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		d+=sprintf(d,"%s",space);
 | 
					 | 
				
			||||||
		if (val & 0x80){
 | 
					 | 
				
			||||||
			d+=sprintf(d,"*");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		d+=sprintf(d,"%0.1f",dot11_rate2float(val & 0x7f));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		space=" ";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return d-dst;	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct mbag_item *  from_str(const char *src)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	mbag_item_t * item = mbag_item_new(CAPWAP80211_TYPE_RATESET);
 | 
					 | 
				
			||||||
	if (!item)
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (strlen(src)==0)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uint8_t rates[64];
 | 
					 | 
				
			||||||
	int nrates =0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	const char *s = src;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	while (*s!=0){
 | 
					 | 
				
			||||||
		while (*s==' ') 
 | 
					 | 
				
			||||||
			s++;
 | 
					 | 
				
			||||||
		int m=0;
 | 
					 | 
				
			||||||
		if(*s=='*'){
 | 
					 | 
				
			||||||
			m=0x80;
 | 
					 | 
				
			||||||
			s++;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else{
 | 
					 | 
				
			||||||
			m=0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		float val;
 | 
					 | 
				
			||||||
		int n=sscanf(s,"%f",&val);
 | 
					 | 
				
			||||||
		if (n!=1)
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		int r = dot11_float2rate(val) | m;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		rates[nrates++]=r;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		while (*s!=0 && *s!=' ')
 | 
					 | 
				
			||||||
			s++;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uint8_t *data = malloc(nrates+1);
 | 
					 | 
				
			||||||
	*data=nrates;
 | 
					 | 
				
			||||||
	memcpy(data+1,rates,nrates);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	item->u2.data=data;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return item;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct mbag_item *  get(const uint8_t *src,int len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mbag_item_t * item = mbag_item_new(CAPWAP80211_TYPE_RATESET);
 | 
					 | 
				
			||||||
	if (!item)
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uint8_t *data = malloc(len+1);
 | 
					 | 
				
			||||||
	if (!data){
 | 
					 | 
				
			||||||
		free (item);
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	*data=len;
 | 
					 | 
				
			||||||
	memcpy(data+1,src,len);
 | 
					 | 
				
			||||||
	item->u2.data=data;
 | 
					 | 
				
			||||||
	return item;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static  int put(struct mbag_item *i,uint8_t *dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int l=*((uint8_t*)(i->u2.data));
 | 
					 | 
				
			||||||
	memcpy(dst,i->u2.data+1,l);
 | 
					 | 
				
			||||||
	return l;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const struct mbag_typedef capwap80211_type_rateset = {
 | 
					 | 
				
			||||||
	.name = "802.11 Rate Set",
 | 
					 | 
				
			||||||
	.del = free,
 | 
					 | 
				
			||||||
	.from_str = from_str,
 | 
					 | 
				
			||||||
	.to_str = to_str,
 | 
					 | 
				
			||||||
	.get = get,
 | 
					 | 
				
			||||||
	.put = put
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,59 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Add a Cisco AP Timesync message element to a buffer
 | 
					 | 
				
			||||||
 * @param dst destination buffer
 | 
					 | 
				
			||||||
 * @param time a unix timestamp
 | 
					 | 
				
			||||||
 * @param type of time
 | 
					 | 
				
			||||||
 * @return number of bytes put (5)
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_put_cisco_ap_timesync(uint8_t * dst, time_t time, uint8_t type)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_put_dword(dst , time);
 | 
					 | 
				
			||||||
	cw_put_byte(dst + 4, type);
 | 
					 | 
				
			||||||
	return 5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_addelem_cisco_ap_regulatory_domain(uint8_t *dst, struct radioinfo * ri){
 | 
					 | 
				
			||||||
	uint8_t *d=dst+10;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	d+=cw_put_byte(d,ri->rid);	// Band ID 
 | 
					 | 
				
			||||||
	d+=cw_put_byte(d,1);		// Set True/False 
 | 
					 | 
				
			||||||
	d+=cw_put_byte(d,ri->rid);	// Slot ID 
 | 
					 | 
				
			||||||
	d+=cw_put_word(d,ri->regDomain);
 | 
					 | 
				
			||||||
	return 5 + cw_put_elem_vendor_hdr(dst, CW_VENDOR_ID_CISCO, CW_CISCO_AP_REGULATORY_DOMAIN, 5);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** 
 | 
					 | 
				
			||||||
 * Add a Cisco Certificate payload message element
 | 
					 | 
				
			||||||
 * @param dst destination buffer
 | 
					 | 
				
			||||||
 * @param src pointer to DER certificate
 | 
					 | 
				
			||||||
 * @param len length of certificate
 | 
					 | 
				
			||||||
 * @return number of bytes put
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_addelem_cisco_certificate(uint8_t*dst,uint8_t*src,int len){
 | 
					 | 
				
			||||||
	int l = lw_put_certificate(dst+10,src,len);
 | 
					 | 
				
			||||||
	return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_CERTIFICATE,l);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_addelem_cisco_wtp_radio_cfg(uint8_t * dst,struct radioinfo *ri){
 | 
					 | 
				
			||||||
	int l = lw_put_80211_wtp_wlan_radio_configuration(dst+10,ri);
 | 
					 | 
				
			||||||
	return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_STATION_CFG,l);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_readelem_cisco_station_cfg(uint8_t *src,int len){
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	lw_readelem_
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,175 +0,0 @@
 | 
				
			|||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "radio.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_put_cisco_wtp_radio_cfg(uint8_t *dst, int rid, mbag_t radio)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_byte(dst,rid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_byte(dst+1,0); //?
 | 
					 | 
				
			||||||
	cw_put_word(dst+2,mbag_get_word(radio,CW_RADIO_OCCUPANCY_LIMIT,12));
 | 
					 | 
				
			||||||
	cw_put_byte(dst+4,mbag_get_byte(radio,CW_RADIO_CFP_PERIOD,8));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_word(dst+5,mbag_get_word(radio,CW_RADIO_CFP_MAX_DURATION,200));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	bstr_t	grmac = mbag_get_bstr(radio,CW_RADIO_BSSID,NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//printf("GRMAC: %d\n",bstr_len(grmac));
 | 
					 | 
				
			||||||
	if ( grmac) {
 | 
					 | 
				
			||||||
		if (bstr_len(grmac)!=6){
 | 
					 | 
				
			||||||
			cw_log(LOG_ERR,"Wrong bssid size");
 | 
					 | 
				
			||||||
exit(0);
 | 
					 | 
				
			||||||
			grmac =NULL;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	bstr_t rmac;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!grmac){
 | 
					 | 
				
			||||||
		uint8_t defrmac[]={0,0,0,0,0,0};
 | 
					 | 
				
			||||||
		rmac = bstr_create(defrmac,6);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		rmac = grmac;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_bstr(dst+7,rmac);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ( !grmac )
 | 
					 | 
				
			||||||
		free(rmac);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	cw_put_word(dst+13,0); // beacon period
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_data(dst+15,mbag_get_raw(radio,CW_RADIO_COUNTRY_STRING,"DE "),3);
 | 
					 | 
				
			||||||
	cw_put_data(dst+18,mbag_get_raw(radio,CW_RADIO_COUNTRY_STRING,"DE "),3);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_byte(dst+21,10); // gPeriod
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_dword(dst+22,0x3538);	// ?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_word(dst+26,0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 26+2; //+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,28);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_put_elem_cisco_ap_regulatory_domain(uint8_t *dst,int rid, mbag_t radio)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	//int l=0;
 | 
					 | 
				
			||||||
	uint8_t *d=dst+10;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	d+=cw_put_byte(d,rid);		//Band ID 
 | 
					 | 
				
			||||||
	d+=cw_put_byte(d,1);		// Set True/False 
 | 
					 | 
				
			||||||
	d+=cw_put_byte(d,rid);		//* Slot ID 
 | 
					 | 
				
			||||||
	d+=cw_put_word(d,mbag_get_word(radio,CW_RADIO_REG_DOMAIN,1));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 5 + cw_put_elem_vendor_hdr(dst, CW_VENDOR_ID_CISCO, CW_CISCO_AP_REGULATORY_DOMAIN, 5);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_put_elem_cisco_radio_cfg(uint8_t * dst,int rid, mbag_t radio)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int l = cw_put_cisco_wtp_radio_cfg(dst+10,rid,radio);
 | 
					 | 
				
			||||||
	return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,l);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_cisco_wtp_radio_cfg(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int l=0;
 | 
					 | 
				
			||||||
	MAVLITER_DEFINE(it,conn->radios);
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		struct mbag_item *i = mavliter_get(&it);
 | 
					 | 
				
			||||||
		if ( i->type != MBAG_MBAG ) {
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
//		l+=cw_put_elem_radio_info(dst+l,i->id,i->data);
 | 
					 | 
				
			||||||
		l+=cw_put_elem_cisco_radio_cfg(dst+l,i->u1.iid,i->u2.data);
 | 
					 | 
				
			||||||
		l+=cw_put_elem_cisco_ap_regulatory_domain(dst+l,i->u1.iid,i->u2.data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return l;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	MAVLITER_DEFINE
 | 
					 | 
				
			||||||
//	int l = cw_out_cisco_wtp_radio_cfg_(conn,a,dst,0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	return l+cw_out_cisco_wtp_radio_cfg_(conn,a,dst+l,1);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_in_cisco_radio_cfg(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
					 | 
				
			||||||
		  struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int rid = cw_get_byte(data);
 | 
					 | 
				
			||||||
	mbag_t radio = mbag_i_get_mbag(conn->radios,rid,NULL);
 | 
					 | 
				
			||||||
	if ( !radio){
 | 
					 | 
				
			||||||
		cw_dbg(DBG_ELEM_ERR,"Radio ID %d not defined",rid);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	printf("Here we are %d\n",rid);
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_radio_cisco_set_state(struct conn * conn, uint8_t *data, int len, int cause)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int rid = cw_get_byte(data);
 | 
					 | 
				
			||||||
	int state = cw_get_byte(data+1);
 | 
					 | 
				
			||||||
	if (rid != 255)
 | 
					 | 
				
			||||||
		return cw_radio_set_admin_state(conn->radios,rid,state,cause);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	MAVLITER_DEFINE(it,conn->radios);
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		mbag_item_t *i = mavliter_get(&it);
 | 
					 | 
				
			||||||
		cw_radio_set_admin_state(conn->radios,i->u1.iid,state,cause);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 1;	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_in_cisco_radio_administrative_state(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
					 | 
				
			||||||
		  struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return cw_radio_cisco_set_state(conn,data,len,-1);	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_in_cisco_radio_administrative_state_wtp(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
					 | 
				
			||||||
		  struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return cw_radio_cisco_set_state(conn,data,len,3);	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,33 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "conn.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "mavl.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
void conn_clear_upd(struct conn *conn, int merge)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (merge){
 | 
					 | 
				
			||||||
		mavl_merge(conn->config, conn->config_upd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		MAVLITER_DEFINE (it,conn->radios_upd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		mavliter_foreach(&it){
 | 
					 | 
				
			||||||
			struct mbag_item * ruitem = mavliter_get(&it);
 | 
					 | 
				
			||||||
			mavl_t radio_upd = ruitem->u2.data;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			mbag_t radio = mbag_i_get_mbag(conn->radios,ruitem->u1.iid,NULL);
 | 
					 | 
				
			||||||
			if (radio){
 | 
					 | 
				
			||||||
				mavl_merge(radio,radio_upd);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	mavl_del_all(conn->config_upd);
 | 
					 | 
				
			||||||
	mavl_del_all(conn->radios_upd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,26 +0,0 @@
 | 
				
			|||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_addelem_cisco_wtp_radio_cfg(uint8_t*dst,struct radioinfo *ri)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_put_byte(dst+10,ri->rid);
 | 
					 | 
				
			||||||
	cw_put_byte(dst+10+1,0);
 | 
					 | 
				
			||||||
	cw_put_word(dst+10+2,ri->occupancy_limit);
 | 
					 | 
				
			||||||
	cw_put_byte(dst+10+4,ri->cfp_period);
 | 
					 | 
				
			||||||
	cw_put_word(dst+10+5,ri->cfp_max_duration);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* XXX catch rmac shorter or longer than 6*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_bstr(dst+10+7,ri->rmac);	/* length MUST be 6 */
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	cw_put_word(dst+10+13,ri->beacon_period);
 | 
					 | 
				
			||||||
	cw_put_data(dst+10+15,ri->country_str,3);
 | 
					 | 
				
			||||||
	cw_put_data(dst+10+18,ri->country_str2,3);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_byte(dst+10+21,10); // gPeriod
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_put_dword(dst+10+22,0x3538);	// ?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	return 28+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,28);*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,18 +0,0 @@
 | 
				
			|||||||
#include "cw.h"
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
#include "cw_80211.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_in_80211_mac_operation(struct conn *conn, struct cw_action_in *a, uint8_t * data,
 | 
					 | 
				
			||||||
			 int len, struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int rid = cw_get_byte(data);
 | 
					 | 
				
			||||||
	mbag_t r = mbag_i_get_mbag(conn->radios,rid,NULL);
 | 
					 | 
				
			||||||
	if (!r){
 | 
					 | 
				
			||||||
		cw_dbg(DBG_ELEM_ERR,"Radio %d not defined. Can't set mac operation.");
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return cw_read_80211_mac_operation(data+2,r);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,38 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_in_cisco_image_identifier(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len,struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (len<a->min_len) {
 | 
					 | 
				
			||||||
		cw_dbg(DBG_ELEM_ERR,"Message element too short, %d < %d", len,a->min_len);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uint32_t vendor_id = cw_get_dword(data);
 | 
					 | 
				
			||||||
	int dstart;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	switch (vendor_id) {
 | 
					 | 
				
			||||||
		case CW_VENDOR_ID_ZYXEL:
 | 
					 | 
				
			||||||
		case CW_VENDOR_ID_CISCO:
 | 
					 | 
				
			||||||
		case CW_VENDOR_ID_FSF:
 | 
					 | 
				
			||||||
		case 0:
 | 
					 | 
				
			||||||
			dstart=4;
 | 
					 | 
				
			||||||
			len-=4;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			vendor_id=CW_VENDOR_ID_CISCO;
 | 
					 | 
				
			||||||
			dstart=0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	mbag_set(conn->remote,a->item_id,a->itemtype,data+dstart,len);
 | 
					 | 
				
			||||||
//	mbag_set_bstrv(conn->incomming,a->item_id,vendor_id,data+dstart,len);
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,22 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
#include "radio.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_in_radio_administrative_state(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
					 | 
				
			||||||
		  struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
/*	int rid = cw_get_byte(data);
 | 
					 | 
				
			||||||
	int state = cw_get_byte(data+1);
 | 
					 | 
				
			||||||
	return cw_radio_set_admin_state(conn->radios,rid,state,-1);
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,26 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
#include "radio.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_in_radio_administrative_state_wtp(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
					 | 
				
			||||||
		  struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!cw_in_radio_administrative_state(conn,a,data,len,from) ) 
 | 
					 | 
				
			||||||
		return 0; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,123 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw_util.h"
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
static void readsubelems_wtp_board_data(mbag_t itemstore, uint8_t * msgelem,
 | 
					 | 
				
			||||||
					int len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (len<4)
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int i = 0;
 | 
					 | 
				
			||||||
//	uint32_t val;
 | 
					 | 
				
			||||||
	do {
 | 
					 | 
				
			||||||
//		val = ntohl(*((uint32_t *) (msgelem + i)));
 | 
					 | 
				
			||||||
//		int subtype = (val >> 16) & 0xffff;
 | 
					 | 
				
			||||||
//		int sublen = val & 0xffff;
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
		int subtype = cw_get_word(msgelem+i);
 | 
					 | 
				
			||||||
		int sublen = cw_get_word(msgelem+i+2);
 | 
					 | 
				
			||||||
		i += 4;
 | 
					 | 
				
			||||||
		if (sublen + i > len) {
 | 
					 | 
				
			||||||
			cw_dbg(DBG_ELEM_ERR,
 | 
					 | 
				
			||||||
			       "WTP Board data sub-element too long, type=%d,len=%d",
 | 
					 | 
				
			||||||
			       subtype, sublen);
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		cw_dbg(DBG_SUBELEM, "board data sub-element, type=%d (%s), len=%d",
 | 
					 | 
				
			||||||
		       subtype, cw_strboardelem(subtype),sublen);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		cw_dbg_dmp(DBG_SUBELEM,msgelem+i,sublen,"Dump...");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		switch (subtype) {
 | 
					 | 
				
			||||||
			case CW_BOARDDATA_MODELNO:
 | 
					 | 
				
			||||||
				mbag_set_bstrn(itemstore,
 | 
					 | 
				
			||||||
						       CW_ITEM_WTP_BOARD_MODELNO,
 | 
					 | 
				
			||||||
						       msgelem + i, sublen);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			case CW_BOARDDATA_SERIALNO:
 | 
					 | 
				
			||||||
				mbag_set_bstrn(itemstore,
 | 
					 | 
				
			||||||
						       CW_ITEM_WTP_BOARD_SERIALNO,
 | 
					 | 
				
			||||||
						       msgelem + i, sublen);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			case CW_BOARDDATA_MACADDRESS:
 | 
					 | 
				
			||||||
				mbag_set_bstrn(itemstore,
 | 
					 | 
				
			||||||
						       CW_ITEM_WTP_BOARD_MACADDRESS,
 | 
					 | 
				
			||||||
						       msgelem + i, sublen);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			case CW_BOARDDATA_BOARDID:
 | 
					 | 
				
			||||||
				mbag_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_ID,
 | 
					 | 
				
			||||||
						       msgelem + i, sublen);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			case CW_BOARDDATA_REVISION:
 | 
					 | 
				
			||||||
				mbag_set_bstrn(itemstore,
 | 
					 | 
				
			||||||
						       CW_ITEM_WTP_BOARD_REVISION,
 | 
					 | 
				
			||||||
						       msgelem + i, sublen);
 | 
					 | 
				
			||||||
			default:
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		i += sublen;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	} while (i < len);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Parse a WTP Board Data messag element and put results to itemstore.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 /*
 | 
					 | 
				
			||||||
int cw_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8_t * data,
 | 
					 | 
				
			||||||
			 int len, struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (len < 4) {
 | 
					 | 
				
			||||||
		cw_dbg(DBG_ELEM_ERR,
 | 
					 | 
				
			||||||
		       "Discarding WTP_BOARD_DATA msgelem, wrong size, type=%d, len=%d",
 | 
					 | 
				
			||||||
		       a->elem_id, len);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mbag_t itemstore = conn->incomming;
 | 
					 | 
				
			||||||
	mbag_set_dword(itemstore, CW_ITEM_WTP_BOARD_VENDOR, cw_get_dword(data));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	readsubelems_wtp_board_data(itemstore, data + 4, len - 4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,36 +0,0 @@
 | 
				
			|||||||
#include "cw.h"
 | 
					 | 
				
			||||||
#include "capwap80211.h"
 | 
					 | 
				
			||||||
#include "radio.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_put_elem_80211_supported_rates(uint8_t*dst,int radio_id,mbag_t radio)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct mbag_item * sr = mbag_get(radio,CW_RADIO_SUPPORTED_RATES);
 | 
					 | 
				
			||||||
	if (!sr)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int n = cw_put_byte(dst+4,radio_id);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	n+=cw_put_mbag_item(dst+5,sr);
 | 
					 | 
				
			||||||
	return 5 + cw_put_elem_hdr(dst,CW_ELEM80211_SUPPORTED_RATES,5);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_80211_supported_rates(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int l=0;
 | 
					 | 
				
			||||||
	MAVLITER_DEFINE(it,conn->radios);
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		struct mbag_item *i = mavliter_get(&it);
 | 
					 | 
				
			||||||
		if ( i->type != MBAG_MBAG ) {
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		l+=cw_put_elem_80211_supported_rates(dst+l,i->u1.iid,i->u2.data);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return l;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,42 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "acpriolist.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_put_ac_name_with_priority(uint8_t *dst,cw_acprio_t * acprio)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int len = strlen(acprio->name);
 | 
					 | 
				
			||||||
	cw_put_byte(dst,acprio->prio);
 | 
					 | 
				
			||||||
	cw_put_data(dst+1,(uint8_t*)acprio->name,len);
 | 
					 | 
				
			||||||
	return len+1;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_ac_name_with_priority(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
/*	cw_acpriolist_t prios = mbag_get_mavl(conn->config,CW_ITEM_AC_NAME_WITH_PRIORITY);
 | 
					 | 
				
			||||||
	if (!prios)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	uint8_t *d = dst;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	MAVLITER_DEFINE(it,prios);
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		cw_acprio_t * ac = mavliter_get(&it);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		int l = cw_put_ac_name_with_priority(d+4,ac);
 | 
					 | 
				
			||||||
		d+=cw_put_elem_hdr(d,CW_ELEM_AC_NAME_WITH_PRIORITY,l)+l;		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return d-dst;
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,57 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @file 
 | 
					 | 
				
			||||||
 * @brief Implementation output handler of capwap cw_out_local_ip_address
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					 | 
				
			||||||
#include <sys/socket.h>
 | 
					 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
#include <arpa/inet.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
#include "conn.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Output handler for Capwap Local IP Address message element.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @param conn Connection object
 | 
					 | 
				
			||||||
 * @param action Pointer to action which called this handler
 | 
					 | 
				
			||||||
 * @param dst Destination buffer
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This handler determines the IP address from #conn->sock.
 | 
					 | 
				
			||||||
 * It can deal both with IPv4 and IPv6 sockets.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 /*
 | 
					 | 
				
			||||||
int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action,
 | 
					 | 
				
			||||||
				   uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return cw_put_local_ip_address(conn->sock,dst,CW_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS,CW_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,58 +0,0 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "sock.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "lwapp.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	mbag_item_t * item = mbag_get(conn->outgoing,CW_ITEM_IMAGE_FILEHANDLE);
 | 
					 | 
				
			||||||
	if (!item) {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't put element Image Data, no image filehandle found");
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	FILE *infile = item->u2.data;
 | 
					 | 
				
			||||||
	if (infile==NULL){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Image Data Request infile = NULL");
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	int bytes=0;
 | 
					 | 
				
			||||||
	switch ( conn->capwap_mode_out){
 | 
					 | 
				
			||||||
		case CW_MODE_CISCO:
 | 
					 | 
				
			||||||
			bytes = lw_put_image_data(dst+4,infile);
 | 
					 | 
				
			||||||
			if ( bytes != LW_BLOCKSIZE_IMAGE_DATA + 3) {
 | 
					 | 
				
			||||||
       		        	avltree_del(conn->outgoing, item);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			bytes = cw_put_image_data(dst+4,infile);
 | 
					 | 
				
			||||||
			if (dst[4] != 1){
 | 
					 | 
				
			||||||
       		        	avltree_del(conn->outgoing, item);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ( ferror(infile)){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERROR,"Aborting image data transfer: %s",strerror(errno));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return bytes + cw_put_elem_hdr(dst,a->elem_id,bytes);
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	 return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,50 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
#include "cw/dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_radio_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
cw_dbg(DBG_X,"Radio Generic out %s",a->item_id);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	int l=0;
 | 
					 | 
				
			||||||
	MAVLITER_DEFINE(it,conn->radios_upd);
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		struct mbag_item *radio = mavliter_get(&it);
 | 
					 | 
				
			||||||
		if ( radio->type != MBAG_MBAG ) {
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Size for msg elem header depends on 
 | 
					 | 
				
			||||||
		  // vendor specific payload 
 | 
					 | 
				
			||||||
		int start = a->vendor_id ? 10 : 4;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		uint8_t * d = dst+l;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		struct mbag_item * item = mbag_get(radio->u2.data,a->item_id);
 | 
					 | 
				
			||||||
		if (!item){
 | 
					 | 
				
			||||||
cw_dbg(DBG_X,"Not found! %s for rid %d",a->item_id,radio->u1.iid);
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		int len=0;
 | 
					 | 
				
			||||||
		len += cw_put_byte(d+start,radio->u1.iid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_dbg(DBG_X, "Radio generic out '%s' fro rid %d",a->item_id,radio->u1.iid);
 | 
					 | 
				
			||||||
		len += cw_put_mbag_item(d + start+1, item);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (a->vendor_id)
 | 
					 | 
				
			||||||
			l+= len + cw_put_elem_vendor_hdr(d, a->vendor_id, a->elem_id, len);
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			l += len + cw_put_elem_hdr(d, a->elem_id, len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return l;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,42 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "radio.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_put_elem_radio_info(uint8_t*dst,int radio_id,mbag_t radio)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_put_byte(dst+4,radio_id);
 | 
					 | 
				
			||||||
	cw_put_dword(dst+5,mbag_get_dword(radio,CW_RADIOITEM80211_WTP_RADIO_INFORMATION,0));
 | 
					 | 
				
			||||||
	return 5 + cw_put_elem_hdr(dst,CW_ELEM80211_WTP_RADIO_INFORMATION,5);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int l=0;
 | 
					 | 
				
			||||||
	MAVLITER_DEFINE(it,conn->radios);
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		struct mbag_item *i = mavliter_get(&it);
 | 
					 | 
				
			||||||
		if ( i->type != MBAG_MBAG ) {
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		l+=cw_put_elem_radio_info(dst+l,i->u1.iid,i->u2.data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return l;
 | 
					 | 
				
			||||||
	 
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,80 +0,0 @@
 | 
				
			|||||||
#include "log.h"
 | 
					 | 
				
			||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
#include "conn.h"
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define CW_MODE_CISCO 1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (capwap_mode==CW_MODE_CISCO){
 | 
					 | 
				
			||||||
		cw_put_word(dst,0x01);
 | 
					 | 
				
			||||||
		return 2;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int n=2;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	dst+=cw_put_byte(dst,n);	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
	for (i=0; i<n; i++){
 | 
					 | 
				
			||||||
		dst+=cw_put_byte(dst,0);
 | 
					 | 
				
			||||||
		dst+=cw_put_byte(dst,0);
 | 
					 | 
				
			||||||
		dst+=cw_put_byte(dst,0);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 3*n+1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mbag_t mbag = conn->config;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// XXX Dummy WTP Descriptor Header
 | 
					 | 
				
			||||||
	uint8_t *d = dst+4;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	d+=cw_put_byte(d,conn->radios->count);	//max radios
 | 
					 | 
				
			||||||
	d+=cw_put_byte(d,2);	//radios in use
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	d+=cw_put_encryption_subelems(d,conn->capwap_mode);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mbag_item_t * i;
 | 
					 | 
				
			||||||
	i = mbag_get(mbag,CW_ITEM_WTP_HARDWARE_VERSION);
 | 
					 | 
				
			||||||
/*	if ( i ) {	
 | 
					 | 
				
			||||||
	 	d += cw_put_version(d,CW_SUBELEM_WTP_HARDWARE_VERSION,i->u2.data);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "Can't send Hardware Version in WTP Descriptor, not set.");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	i = mbag_get(mbag,CW_ITEM_WTP_SOFTWARE_VERSION);
 | 
					 | 
				
			||||||
	if ( i ) {	
 | 
					 | 
				
			||||||
	 	d += cw_put_version(d,CW_SUBELEM_WTP_SOFTWARE_VERSION,i->u2.data);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "Can't send Software Version in WTP descriptor, not set.");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        i = mbag_get(mbag,CW_ITEM_WTP_BOOT_VERSION);
 | 
					 | 
				
			||||||
        if ( i ) {
 | 
					 | 
				
			||||||
                d += cw_put_version(d,CW_SUBELEM_WTP_BOOTLOADER_VERSION,i->u2.data);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
                cw_log(LOG_INFO, "Can't send Boot Version in WTP descriptor, not set.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        i = mbag_get(mbag,CW_ITEM_WTP_OTHER_VERSION);
 | 
					 | 
				
			||||||
        if ( i ) {
 | 
					 | 
				
			||||||
                d += cw_put_version(d,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION,i->u2.data);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
                cw_log(LOG_INFO, "Can't send Other Version in WTP descriptor, not set.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
*
 | 
					 | 
				
			||||||
//	int len = d-dst-4;
 | 
					 | 
				
			||||||
//	return len + cw_put_elem_hdr(dst,a->elem_id,len);
 | 
					 | 
				
			||||||
}	
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,56 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @file 
 | 
					 | 
				
			||||||
 * @brief Implementation output handler of capwap cw_out_local_ip_address
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <errno.h>
 | 
					 | 
				
			||||||
#include <sys/socket.h>
 | 
					 | 
				
			||||||
#include <netinet/in.h>
 | 
					 | 
				
			||||||
#include <arpa/inet.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
#include "conn.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Output handler for Capwap Local IP Address message element.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @param conn Connection object
 | 
					 | 
				
			||||||
 * @param action Pointer to action which called this handler
 | 
					 | 
				
			||||||
 * @param dst Destination buffer
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This handler determines the IP address from #conn->sock.
 | 
					 | 
				
			||||||
 * It can deal both with IPv4 and IPv6 sockets.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 /*
 | 
					 | 
				
			||||||
int cw_out_wtp_ip_address(struct conn *conn, struct cw_action_out *action,
 | 
					 | 
				
			||||||
				   uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return cw_put_local_ip_address(conn->sock,dst,CAPWAP_ELEM_WTP_IPV4_IP_ADDRESS,CAPWAP_ELEM_WTP_IPV6_IP_ADDRESS);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,65 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of actube.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    actube 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_out_wtp_reboot_statistics(struct conn *conn, struct cw_action_out *a,
 | 
					 | 
				
			||||||
				 uint8_t * dst)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!a->get) {
 | 
					 | 
				
			||||||
		cw_log(LOG_ERROR, "Can't set WTP resboot stats. No get method");
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct mbag_item *i = a->get(conn, a);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!i) {
 | 
					 | 
				
			||||||
		if (a->mand) {
 | 
					 | 
				
			||||||
			cw_log(LOG_ERR,
 | 
					 | 
				
			||||||
			       "Can't put mandatory element WTP_REBOOT_STATISTICS");
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mbag_t rs = (mbag_t) i->u2.data;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uint8_t *d = dst + 4;
 | 
					 | 
				
			||||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_COUNT, 0));
 | 
					 | 
				
			||||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_AC_INITIATED_COUNT, 0));
 | 
					 | 
				
			||||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_LINK_FAILURE_COUNT, 0));
 | 
					 | 
				
			||||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_SW_FAILURE_COUNT, 0));
 | 
					 | 
				
			||||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_HW_FAILURE_COUNT, 0));
 | 
					 | 
				
			||||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_OTHER_FAILURE_COUNT, 0));
 | 
					 | 
				
			||||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_UNKNOWN_FAILURE_COUNT, 0));
 | 
					 | 
				
			||||||
	d += cw_put_byte(d, mbag_get_byte(rs, CW_ITEM_REBOOT_LAST_FAILURE_TYPE, 255));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int l = d - dst - 4;
 | 
					 | 
				
			||||||
	return l + cw_put_elem_hdr(dst, a->elem_id, l);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,31 +0,0 @@
 | 
				
			|||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Put an cw_ac_stauts structure to a buffer
 | 
					 | 
				
			||||||
 * @param dst destination buffer
 | 
					 | 
				
			||||||
 * @param s #cw_ac_status to put
 | 
					 | 
				
			||||||
 * @return number of bytes put
 | 
					 | 
				
			||||||
 * This function is only useful (used) in conjunction with 
 | 
					 | 
				
			||||||
 * putting AC Descriptor message elements.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s, struct conn * conn)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	uint8_t *d;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	d = dst;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	d += cw_put_dword(d, (s->stations << 16) | (s->limit));
 | 
					 | 
				
			||||||
	d += cw_put_dword(d, (s->active_wtps << 16) | (s->max_wtps));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int security = 0;
 | 
					 | 
				
			||||||
	security |= conn->dtls_cert_file ? CAPWAP_FLAG_AC_SECURITY_X : 0;
 | 
					 | 
				
			||||||
	security |= conn->dtls_psk ? CAPWAP_FLAG_AC_SECURITY_S : 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	d += cw_put_dword(d,
 | 
					 | 
				
			||||||
			  (security << 24) | (s->rmac_field << 16) | (s->dtls_policy));
 | 
					 | 
				
			||||||
	return d - dst;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,96 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of actube.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    actube 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @file
 | 
					 | 
				
			||||||
 * @brief Implementation of cw_put_radio_operational_states
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "radio.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Put all radio operational states 
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
//int xxcw_put_radio_operational_states(struct xaaa * radios, uint8_t * dst, int *nerror, int d7mode)
 | 
					 | 
				
			||||||
//{/
 | 
					 | 
				
			||||||
	//uint8_t *d=dst;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Iterate through all radios and send the CW_RADIO_OPER_STATE item if found.
 | 
					 | 
				
			||||||
	   We assume, that any other processes, dealing with setting the 
 | 
					 | 
				
			||||||
	   the Radio Admin state, adds a CW_RADIO_OPER_STATE item to the radio, 
 | 
					 | 
				
			||||||
	   depending on results. */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	int nerror=0;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	*nerror=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	MAVLITER_DEFINE(it,radios);
 | 
					 | 
				
			||||||
//	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//		mbag_item_t * radioitem = mavliter_get(&it);
 | 
					 | 
				
			||||||
//		mbag_item_t *ositem = mbag_get(radioitem->u2.data,CW_RADIOITEM_OPER_STATE);
 | 
					 | 
				
			||||||
		//if (!ositem){
 | 
					 | 
				
			||||||
	//		(*nerror)++;
 | 
					 | 
				
			||||||
//			continue;//
 | 
					 | 
				
			||||||
//		}//
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* Put the radio ID */
 | 
					 | 
				
			||||||
//		cw_put_byte(d+4,radioitem->u1.iid);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		/* Get the operational state and cause */
 | 
					 | 
				
			||||||
//		uint16_t os = ositem->u2.word;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//		if ( d7mode ){//
 | 
					 | 
				
			||||||
			// Isolate Oper Sate from cause 
 | 
					 | 
				
			||||||
//			uint8_t o=os>>8; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//			/* Invert oper state for Cisco, if oper state is 2 or 1 */
 | 
					 | 
				
			||||||
//			if (o!=0 && o<=2) {
 | 
					 | 
				
			||||||
//				/*  2 becomes 1 and 1 becomes 2 */
 | 
					 | 
				
			||||||
//				os = (os & 0x00ff ) | ((3-o)<<8);
 | 
					 | 
				
			||||||
//			}
 | 
					 | 
				
			||||||
//		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//		/* Put oper state */
 | 
					 | 
				
			||||||
//		cw_put_word(d+5,os);
 | 
					 | 
				
			||||||
//		d+=3+cw_put_elem_hdr(d,CW_ELEM_RADIO_OPERATIONAL_STATE,3);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* delete the operational state item, so it won't be 
 | 
					 | 
				
			||||||
		   sent again, until it is set by a change through
 | 
					 | 
				
			||||||
		   Set Radio Admin State */
 | 
					 | 
				
			||||||
//		mbag_del(radioitem->u2.data,CW_RADIOITEM_OPER_STATE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	if (nerror) {
 | 
					 | 
				
			||||||
		if (a->mand) {
 | 
					 | 
				
			||||||
			cw_log(LOG_ERROR,"Could not send Radio Operational State for all radios. Sent %d out of %d.",
 | 
					 | 
				
			||||||
				conn->radios->count-nerror,conn->radios->count);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
//	return d-dst;
 | 
					 | 
				
			||||||
//}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,16 +0,0 @@
 | 
				
			|||||||
#include "cw.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_read_80211_mac_operation(uint8_t *data,mbag_t r)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	mbag_set_word( r, CW_RADIOITEM80211_RTS_THRESHOLD,cw_get_word(data) );
 | 
					 | 
				
			||||||
	mbag_set_byte( r, CW_RADIOITEM80211_SHORT_RETRY,cw_get_byte(data+2) );
 | 
					 | 
				
			||||||
	mbag_set_byte( r, CW_RADIOITEM80211_LONG_RETRY,cw_get_byte(data+3) );
 | 
					 | 
				
			||||||
	mbag_set_word( r, CW_RADIOITEM80211_FRAGMENTATION_THRESHOLD,cw_get_word(data+4) );
 | 
					 | 
				
			||||||
	mbag_set_dword( r, CW_RADIOITEM80211_TX_MSDU_LIFETIME,cw_get_dword(data+6) );
 | 
					 | 
				
			||||||
	mbag_set_dword( r, CW_RADIOITEM80211_RX_MSDU_LIFETIME,cw_get_dword(data+10) );
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,25 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "capwap_cisco.h"
 | 
					 | 
				
			||||||
#include "cw_log.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_readelem_cisco_wtp_radio_cfg(int elem_id,uint8_t *elem, int len,struct radioinfo *ri)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (elem_id != CW_CISCO_WTP_RADIO_CFG)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (len!=24){
 | 
					 | 
				
			||||||
		cw_dbg(DBG_ELEM,"LWAPP Radio Cfg element too short, %d < 21",len);
 | 
					 | 
				
			||||||
		return -1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	ri->rid = lw_get_byte(elem);
 | 
					 | 
				
			||||||
	ri->occupancy_limit = lw_get_word(elem+2);
 | 
					 | 
				
			||||||
	bstr_replace(&ri->bssid,bstr_create(elem+7,6));
 | 
					 | 
				
			||||||
	ri->beacon_period = lw_get_word(elem+13);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/	
 | 
					 | 
				
			||||||
@ -1,40 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @file
 | 
					 | 
				
			||||||
 * @brief Implnts send echo response
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Send an echo response message
 | 
					 | 
				
			||||||
 * @param conn connection, see #conn
 | 
					 | 
				
			||||||
 * @param seqnum sequence number to use
 | 
					 | 
				
			||||||
 * @param radioinfo radioinfo to use, should me NULL
 | 
					 | 
				
			||||||
 * @return 1=Success\nOtherwise Error.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_send_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct cwmsg * cwmsg = &conn->resp_msg;	
 | 
					 | 
				
			||||||
//	cwmsg_init(cwmsg,conn->resp_buffer,CW_MSG_ECHO_RESPONSE,seqnum,radioinfo);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	conn_send_response(conn,cwmsg,seqnum);
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,44 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
#include "conn.h"
 | 
					 | 
				
			||||||
#include "cwmsg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stdio.h> 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void cwmsg_addelem_mtu_discovery_padding(struct cwmsg * msg, struct conn* conn)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int len = conn->mtu - (msg->msgelems-msg->buffer+msg->pos)-4;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf("MTU discovery len %d %d and pos %d:\n",conn->mtu,len,msg->pos);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (len < 0 )
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	uint32_t val = CAPWAP_ELEM_MTU_DISCOVERY_PADDING<<16|len;
 | 
					 | 
				
			||||||
	*((uint32_t*)(msg->msgelems+msg->pos))=htonl(val);
 | 
					 | 
				
			||||||
	memset(msg->msgelems+4+msg->pos,0xff,len);	
 | 
					 | 
				
			||||||
	msg->pos+=4+len;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf("Nenpos = %d\n",msg->pos);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,63 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "lwapp_cisco.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const char * lw_cisco_id_to_str(int elem_id)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	switch (elem_id){
 | 
					 | 
				
			||||||
		case LW_CISCO_AP_LOGHOST_CONFIG:
 | 
					 | 
				
			||||||
			return "AP Loghost Config and Last Joined Controller";
 | 
					 | 
				
			||||||
		case LW_CISCO_PATH_MTU:
 | 
					 | 
				
			||||||
			return "Path MTU";
 | 
					 | 
				
			||||||
		case LW_CISCO_MWAR_HASH_VALUE:
 | 
					 | 
				
			||||||
			return "MWAR Hash Value";
 | 
					 | 
				
			||||||
		case LW_CISCO_MWAR_HASH_VALUE_1:
 | 
					 | 
				
			||||||
			return "MWAR Hah Value 1";			
 | 
					 | 
				
			||||||
		case LW_CISCO_AP_USERNAME_PASSWORD:
 | 
					 | 
				
			||||||
			return "AP Username and Password";
 | 
					 | 
				
			||||||
		case LW_CISCO_AC_IP_ADDR_WITH_INDEX:
 | 
					 | 
				
			||||||
			return "AC IP Addr with Index";
 | 
					 | 
				
			||||||
		case LW_CISCO_AP_SUBMODE:
 | 
					 | 
				
			||||||
			return "AP Submode";
 | 
					 | 
				
			||||||
		case LW_CISCO_SSC_HASH_VALIDATION:
 | 
					 | 
				
			||||||
			return "SSC Hash Validation";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case LW_CISCO_DOT11R_WLC_MAC_AND_IP:
 | 
					 | 
				
			||||||
			return "802.11r WLC MAC and IP";
 | 
					 | 
				
			||||||
		case LW_CISCO_AP_JOIN_IP_PREF_MODE:
 | 
					 | 
				
			||||||
			return "AP Join IP Pref Mode";
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
		case LW_CISCO_MCAST_MGID_INFO:
 | 
					 | 
				
			||||||
			return "MCAST MGID Info";
 | 
					 | 
				
			||||||
		case LW_CISCO_RADIO_MODULE_INFO:
 | 
					 | 
				
			||||||
			return "Radio Module Info";
 | 
					 | 
				
			||||||
		case LW_CISCO_TELNET_SSH:
 | 
					 | 
				
			||||||
			return "Telnet SSH";
 | 
					 | 
				
			||||||
		case LW_CISCO_AP_DTLS_DATA_CFG:
 | 
					 | 
				
			||||||
			return "AP DTLS Data Config";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case LW_CISCO_PRIMED_JOIN_TIMEOUT:
 | 
					 | 
				
			||||||
			return "Primed Join Timeout";			
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case LW_CISCO_PRIMED_DISCOVERY_TIMEOUT:
 | 
					 | 
				
			||||||
			return "Primed Discovery Timeout";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case LW_CISCO_RAD_EXTENDED_CONFIG:
 | 
					 | 
				
			||||||
			return "RAD Extended Config";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case LW_CISCO_MANAGER_IP_ADDR:
 | 
					 | 
				
			||||||
			return "Manager IP Address";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case LW_CISCO_ADD_WLAN:
 | 
					 | 
				
			||||||
			return "Add WLAN?";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case LW_CISCO_DELETE_WLAN:
 | 
					 | 
				
			||||||
			return "Delete WLAN?";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		default: 
 | 
					 | 
				
			||||||
			return "Unknown";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return "Unknown";
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,53 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "cw.h"
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
/*#include "stravltree.h"*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** 
 | 
					 | 
				
			||||||
 * @file 
 | 
					 | 
				
			||||||
 * @brief Implementation of LWAPP Vendor Specific Payload
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Default handler for LWAPP Vendor Specific Payload message elements.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 /*
 | 
					 | 
				
			||||||
int lw_in_vendor_specific(struct conn *conn, struct cw_action_in *a,
 | 
					 | 
				
			||||||
				  uint8_t * data, int len, struct sockaddr *from)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_action_in_t as, *af;
 | 
					 | 
				
			||||||
	as = *a;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	as.vendor_id = cw_get_dword(data);
 | 
					 | 
				
			||||||
	as.elem_id = cw_get_word(data + 4);
 | 
					 | 
				
			||||||
	as.proto = CW_ACTION_PROTO_LWAPP;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO XXXX
 | 
					 | 
				
			||||||
	//af = cw_actionlist_in_get(conn->actions->in, &as);
 | 
					 | 
				
			||||||
//	
 | 
					 | 
				
			||||||
	af = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!af) {
 | 
					 | 
				
			||||||
		cw_dbg(DBG_WARN,
 | 
					 | 
				
			||||||
		       "Can't handle Vendor Specific LWAPP Payload %s/%d, in msg %d (%s) in %s state.",
 | 
					 | 
				
			||||||
		       cw_strvendor(as.vendor_id), as.elem_id, as.msg_id,
 | 
					 | 
				
			||||||
		       cw_strmsg(as.msg_id), cw_strstate(as.capwap_state));
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (af->start) {
 | 
					 | 
				
			||||||
		int afrc = af->start(conn, af, data + 6, len - 6, from);
 | 
					 | 
				
			||||||
		if (af->mand && afrc) {
 | 
					 | 
				
			||||||
			// add found mandatory message element 
 | 
					 | 
				
			||||||
			   //to mand list 
 | 
					 | 
				
			||||||
// XXXX			stravltree_add(conn->mand, af->item_id); 
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return afrc;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,44 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    This file is part of libcapwap.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 3 of the License, or
 | 
					 | 
				
			||||||
    (at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    libcapwap 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @file
 | 
					 | 
				
			||||||
 * @brief Implementation of lw_put_cisco_path_mtu
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "lwapp_cisco.h"
 | 
					 | 
				
			||||||
#include "lw.h"
 | 
					 | 
				
			||||||
#include "vendors.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** 
 | 
					 | 
				
			||||||
 * Put message element data for Cisco vendor specific LWAPP message
 | 
					 | 
				
			||||||
 * Csico Path MTU.
 | 
					 | 
				
			||||||
 * @param dst destination buffer
 | 
					 | 
				
			||||||
 * @param max maximum MTU
 | 
					 | 
				
			||||||
 * @param padding number of bytes to append
 | 
					 | 
				
			||||||
 * @return number of bytes put to buffer 
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
int lw_put_cisco_path_mtu(uint8_t *dst, uint16_t max, uint16_t padding)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	lw_set_dword(dst,LW_VENDOR_ID_CISCO);
 | 
					 | 
				
			||||||
	lw_set_word(dst+4,LW_CISCO_PATH_MTU);
 | 
					 | 
				
			||||||
	lw_set_word(dst+6,max);
 | 
					 | 
				
			||||||
	lw_set_word(dst+8,padding+4);
 | 
					 | 
				
			||||||
	memset(dst+10,0,padding);
 | 
					 | 
				
			||||||
	return padding+10;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,32 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int mbag_get_upd(mbag_t b, mbag_t b_upd, const char *id, uint8_t *dst, int *found)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct mbag_item *i = mbag_get(b_upd, id);
 | 
					 | 
				
			||||||
	if (i) {
 | 
					 | 
				
			||||||
		if (!i->type->put ){
 | 
					 | 
				
			||||||
			cw_log(LOG_ERROR,"No put method for %s",i->type->name);
 | 
					 | 
				
			||||||
			return -1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		(*found)++;
 | 
					 | 
				
			||||||
		return i->type->put(i, dst);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	i = mbag_get(b,id);
 | 
					 | 
				
			||||||
	if (i) {
 | 
					 | 
				
			||||||
		if (!i->type->put){
 | 
					 | 
				
			||||||
			cw_log(LOG_ERROR,"No put method for %s",i->type->name);
 | 
					 | 
				
			||||||
			return -1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return i->type->put(i, dst);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return -1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,54 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
#include "radio.h"
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const char CW_RADIO_TYPE[]="radio_type";
 | 
					 | 
				
			||||||
const char CW_RADIO_REG_DOMAIN[]="reg_domain";
 | 
					 | 
				
			||||||
const char CW_RADIO_BSSID[]="bssid";
 | 
					 | 
				
			||||||
const char CW_RADIO_SHORT_PREAMBLE[]="short_preamble";
 | 
					 | 
				
			||||||
const char CW_RADIO_COUNTRY_STRING[]="country_string";
 | 
					 | 
				
			||||||
const char CW_RADIO_DECRYPTION_ERROR_REPORT_PERIOD[]="decryption_error_report_period";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const char CW_RADIO_SUPPORTED_RATES[]="supported_rates";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Cisco 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const char CW_RADIO_OCCUPANCY_LIMIT[]="occupancy_limit";
 | 
					 | 
				
			||||||
const char CW_RADIO_CFP_PERIOD[]="cfp_period";
 | 
					 | 
				
			||||||
const char CW_RADIO_CFP_MAX_DURATION[]="cfp_max_duration";
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct cw_itemdef xxxcapwap_radioitemdefs[] = {
 | 
					 | 
				
			||||||
//{CW_RADIO_ADMIN_STATE,CW_ITEM_NONE,MBAG_BYTE},
 | 
					 | 
				
			||||||
{CW_RADIO_TYPE,CW_ITEM_NONE,MTYPE_DWORD},
 | 
					 | 
				
			||||||
{CW_RADIO_DECRYPTION_ERROR_REPORT_PERIOD,CW_ITEM_NONE,MBAG_WORD},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{CW_RADIO_BSSID,CW_ITEM_NONE,MBAG_BSTR16},
 | 
					 | 
				
			||||||
{CW_RADIO_SUPPORTED_RATES,CW_ITEM_NONE,MBAG_DATA},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{CW_ITEM_NONE}
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_radio_set_all_admin_states(mbag_t radios,int state, int cause)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	MAVLITER_DEFINE(it,radios);
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		mbag_item_t *i = mavliter_get(&it);
 | 
					 | 
				
			||||||
		cw_radio_set_admin_state(radios,i->u1.iid,state,cause);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 1;	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,62 +0,0 @@
 | 
				
			|||||||
#ifndef __CW_RADIO_H
 | 
					 | 
				
			||||||
#define __CW_RADIO_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "conn.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
//extern const char CW_RADIO_ADMIN_STATE[];
 | 
					 | 
				
			||||||
//extern const char CW_RADIO_OPER_STATE[];
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern const char CW_RADIO_SUPPORTED_RATES[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern const char CW_RADIO_TYPE[];
 | 
					 | 
				
			||||||
extern const char CW_RADIO_REG_DOMAIN[];
 | 
					 | 
				
			||||||
extern const char CW_RADIO_BSSID[];
 | 
					 | 
				
			||||||
extern const char CW_RADIO_SHORT_PREAMBLE[];
 | 
					 | 
				
			||||||
extern const char CW_RADIO_COUNTRY_STRING[];
 | 
					 | 
				
			||||||
extern const char CW_RADIO_DECRYPTION_ERROR_REPORT_PERIOD[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Cisco */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern const char CW_RADIO_OCCUPANCY_LIMIT[];
 | 
					 | 
				
			||||||
extern const char CW_RADIO_CFP_PERIOD[];
 | 
					 | 
				
			||||||
extern const char CW_RADIO_CFP_MAX_DURATION[];
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
enum radiodata{
 | 
					 | 
				
			||||||
	CW_RADIO_ADMIN_STATE=10000,
 | 
					 | 
				
			||||||
	CW_RADIO_OPER_STATE,
 | 
					 | 
				
			||||||
	CW_RADIO_TYPE,
 | 
					 | 
				
			||||||
	CW_RADIO_REG_DOMAIN,
 | 
					 | 
				
			||||||
	CW_RADIO_BSSID,
 | 
					 | 
				
			||||||
	CW_RADIO_SHORT_PREAMBLE,
 | 
					 | 
				
			||||||
	CW_RADIO_COUNTRY_STRING,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	CW_RADIO_OCCUPANCY_LIMIT,
 | 
					 | 
				
			||||||
	CW_RADIO_CFP_PERIOD,
 | 
					 | 
				
			||||||
	CW_RADIO_CFP_MAX_DURATION
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}[];
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
int cw_radio_update_oper_states(mbag_t radios,int cause);
 | 
					 | 
				
			||||||
extern struct cw_itemdef capwap_radioitemdefs[];
 | 
					 | 
				
			||||||
extern int cw_radio_set_all_admin_states(mbag_t radios,int state, int cause);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_80211_supported_rates(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
							
								
								
									
										10
									
								
								src/cw/val.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/cw/val.h
									
									
									
									
									
								
							@ -157,6 +157,7 @@ extern const struct cw_Type cw_type_ipaddress;
 | 
				
			|||||||
extern const struct cw_Type cw_type_sysptr;
 | 
					extern const struct cw_Type cw_type_sysptr;
 | 
				
			||||||
extern const struct cw_Type cw_type_bool;
 | 
					extern const struct cw_Type cw_type_bool;
 | 
				
			||||||
extern const struct cw_Type cw_type_struct;
 | 
					extern const struct cw_Type cw_type_struct;
 | 
				
			||||||
 | 
					extern const struct cw_Type cw_type_array;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CW_TYPE_BYTE (&cw_type_byte)
 | 
					#define CW_TYPE_BYTE (&cw_type_byte)
 | 
				
			||||||
#define CW_TYPE_WORD (&cw_type_word)
 | 
					#define CW_TYPE_WORD (&cw_type_word)
 | 
				
			||||||
@ -168,6 +169,15 @@ extern const struct cw_Type cw_type_struct;
 | 
				
			|||||||
#define CW_TYPE_STR (&cw_type_str)
 | 
					#define CW_TYPE_STR (&cw_type_str)
 | 
				
			||||||
#define CW_TYPE_BOOL (&cw_type_bool)
 | 
					#define CW_TYPE_BOOL (&cw_type_bool)
 | 
				
			||||||
#define CW_TYPE_STRUCT (&cw_type_struct)
 | 
					#define CW_TYPE_STRUCT (&cw_type_struct)
 | 
				
			||||||
 | 
					#define CW_TYPE_ARRAY (&cw_type_array)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cw_ValArrayDef{
 | 
				
			||||||
 | 
						void * get_count;
 | 
				
			||||||
 | 
						void * put_count;
 | 
				
			||||||
 | 
						const struct cw_Type * type;
 | 
				
			||||||
 | 
						void *param;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
void cw_kvstore_mavl_delete(const void *data);
 | 
					void cw_kvstore_mavl_delete(const void *data);
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@ include ../../Defs.mak
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOURCES=\
 | 
					SOURCES=\
 | 
				
			||||||
	mod_capwap_ac.c \
 | 
						mod_capwap.c \
 | 
				
			||||||
	capwap_actions.c \
 | 
						capwap_actions.c \
 | 
				
			||||||
	capwap_in_wtp_board_data.c \
 | 
						capwap_in_wtp_board_data.c \
 | 
				
			||||||
	capwap_in_ac_descriptor.c \
 | 
						capwap_in_ac_descriptor.c \
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "mod_capwap.h"
 | 
					#include "mod_capwap.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cw/mavltypes.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
					static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -429,10 +428,13 @@ static struct cw_ElemHandler handlers[] = {
 | 
				
			|||||||
		CAPWAP_ELEM_RADIO_OPERATIONAL_STATE,		/* Element ID */
 | 
							CAPWAP_ELEM_RADIO_OPERATIONAL_STATE,		/* Element ID */
 | 
				
			||||||
		0, 0,						/* Vendor / Proto */
 | 
							0, 0,						/* Vendor / Proto */
 | 
				
			||||||
		3, 3,						/* min/max length */
 | 
							3, 3,						/* min/max length */
 | 
				
			||||||
		radio_operational_state,			/* type */
 | 
							CW_TYPE_STRUCT,					/* type */
 | 
				
			||||||
		"capwap/operational-state",			/* Key */
 | 
							"capwap/operational-state",			/* Key */
 | 
				
			||||||
		cw_in_radio_generic_struct,			/* get */
 | 
							cw_in_radio_generic,				/* get */
 | 
				
			||||||
		cw_out_radio_generic_struct			/* put */
 | 
							cw_out_radio_generic,				/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							radio_operational_state
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	,
 | 
						,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -34,7 +34,7 @@ int capwap_in_capwap_control_ip_address(struct cw_ElemHandler *eh,
 | 
				
			|||||||
	int idx;
 | 
						int idx;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	sprintf(key,"%s/address",eh->key);
 | 
						sprintf(key,"%s/address",eh->key);
 | 
				
			||||||
	idx = cw_cfg_get_next_index(params->cfg,key);
 | 
						idx = cw_cfg_get_new_index(params->cfg,key);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
/*	printf("SKEY is %s , idx: %d\n",key,idx);*/
 | 
					/*	printf("SKEY is %s , idx: %d\n",key,idx);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -37,11 +37,13 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	sprintf(key,"%s/%s",eh->key,CW_SKEY_MAX_RADIOS);
 | 
						sprintf(key,"%s/%s",eh->key,CW_SKEY_MAX_RADIOS);
 | 
				
			||||||
	val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
 | 
						val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
 | 
				
			||||||
	d+=cw_put_byte(d,val);
 | 
						if (val<0){
 | 
				
			||||||
	if (val<=0){
 | 
					 | 
				
			||||||
		cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", CW_SKEY_MAX_RADIOS);
 | 
							cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", CW_SKEY_MAX_RADIOS);
 | 
				
			||||||
		d+=cw_put_byte(d,0);
 | 
							d+=cw_put_byte(d,0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						else{
 | 
				
			||||||
 | 
							d+=cw_put_byte(d,val);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
 | 
						sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
 | 
				
			||||||
	val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
 | 
						val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
 | 
				
			||||||
@ -52,8 +54,6 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
 | 
				
			|||||||
	d+=cw_put_encryption_subelems(d,0);
 | 
						d+=cw_put_encryption_subelems(d,0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*cw_ktv_dump(params->conn->local_cfg,DBG_INFO,"*** ktv dump ***","","*** end of dump ***");*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* hardware version sub element */
 | 
						/* hardware version sub element */
 | 
				
			||||||
	sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
 | 
						sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
 | 
				
			||||||
	d+=cw_write_descriptor_subelem (d, params->cfg_list,
 | 
						d+=cw_write_descriptor_subelem (d, params->cfg_list,
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "mod_capwap.h"
 | 
					#include "mod_capwap.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int init(struct cw_Mod * mod, mavl_t global_cfg, int role)
 | 
					static int init(struct cw_Mod * mod, cw_Cfg_t * global_cfg, int role)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cw_dbg(DBG_INFO,"CAPWAP: Inititalizing mod_capwap.");
 | 
						cw_dbg(DBG_INFO,"CAPWAP: Inititalizing mod_capwap.");
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@ -30,7 +30,7 @@ static int init(struct cw_Mod * mod, mavl_t global_cfg, int role)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -51,7 +51,7 @@ int static setup_cfg(struct cw_Conn  * conn)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	stop();
 | 
					//	stop();
 | 
				
			||||||
//	cw_ktv_set_byte(conn->local_cfg,"ac-descriptor/security",security);
 | 
						cw_cfg_set_int(conn->local_cfg,"ac-descriptor/security",security);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -28,7 +28,36 @@ static cw_ValStruct_t capwap80211_antenna_stru[]={
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_ValStruct_t capwap80211_wtp_radio_cfg_stru[]={
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"short-preamble",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"num-of-bssids",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"dtim-period",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"bssid",6,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"beacon-period",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_STR,"country-string",2,-1,},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"country-string-attr",1,-1,},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"country-string-reserved",1,-1,},
 | 
				
			||||||
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct cw_ElemHandler handlers[] = {
 | 
					static struct cw_ElemHandler handlers[] = {
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							"IEEE 802.11 Add WLAN",				/* name */
 | 
				
			||||||
 | 
							CAPWAP80211_ELEM_ADD_WLAN,			/* Element ID */
 | 
				
			||||||
 | 
							0, 0,						/* Vendor / Proto */
 | 
				
			||||||
 | 
							3, 0,						/* min/max length */
 | 
				
			||||||
 | 
							CW_TYPE_STRUCT,					/* type */
 | 
				
			||||||
 | 
							"capwap80211",					/* Key */
 | 
				
			||||||
 | 
							cw_in_radio_generic,				/* get */
 | 
				
			||||||
 | 
							cw_out_radio_generic,				/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							capwap80211_antenna_stru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						,
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		"IEEE 802.11 WTP Radio Information",		/* name */
 | 
							"IEEE 802.11 WTP Radio Information",		/* name */
 | 
				
			||||||
		CAPWAP80211_ELEM_WTP_RADIO_INFORMATION,		/* Element ID */
 | 
							CAPWAP80211_ELEM_WTP_RADIO_INFORMATION,		/* Element ID */
 | 
				
			||||||
@ -66,6 +95,22 @@ static struct cw_ElemHandler handlers[] = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	,
 | 
						,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							"IEEE 802.11 WTP Radio Configuration",		/* name */
 | 
				
			||||||
 | 
							CAPWAP80211_ELEM_WTP_RADIO_CONFIGURATION,	/* Element ID */
 | 
				
			||||||
 | 
							0, 0,						/* Vendor / Proto */
 | 
				
			||||||
 | 
							16, 16,						/* min/max length */
 | 
				
			||||||
 | 
							CW_TYPE_STRUCT,					/* type */
 | 
				
			||||||
 | 
							"capwap80211/wtp-radio-config",				/* Key */
 | 
				
			||||||
 | 
							cw_in_radio_generic,				/* get */
 | 
				
			||||||
 | 
							cw_out_radio_generic,				/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							capwap80211_wtp_radio_cfg_stru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
							
 | 
				
			||||||
	{NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}
 | 
						{NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -14,11 +14,11 @@
 | 
				
			|||||||
static int init()
 | 
					static int init()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cw_dbg(DBG_INFO, "Initialiazing mod_capwap80211 ...");
 | 
						cw_dbg(DBG_INFO, "Initialiazing mod_capwap80211 ...");
 | 
				
			||||||
	return 0;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
 | 
					static int detect(struct cw_Conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
 | 
				
			||||||
		  struct sockaddr *from, int mode)
 | 
							  struct sockaddr *from, int mode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int wbid;
 | 
						int wbid;
 | 
				
			||||||
 | 
				
			|||||||
@ -3,8 +3,7 @@ include ../../Defs.mak
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOURCES=\
 | 
					SOURCES=\
 | 
				
			||||||
	mod_cisco_ac.c \
 | 
						mod_cisco.c \
 | 
				
			||||||
	cisco_actions.c \
 | 
					 | 
				
			||||||
	cisco_in_wtp_descriptor.c \
 | 
						cisco_in_wtp_descriptor.c \
 | 
				
			||||||
	cisco_out_wtp_descriptor.c \
 | 
						cisco_out_wtp_descriptor.c \
 | 
				
			||||||
	cisco_in_ac_descriptor.c\
 | 
						cisco_in_ac_descriptor.c\
 | 
				
			||||||
 | 
				
			|||||||
@ -37,7 +37,7 @@
 | 
				
			|||||||
#define CISCO_ELEM_RAD_NAME			LWAPP_ELEM_WTP_NAME			/* 5 */
 | 
					#define CISCO_ELEM_RAD_NAME			LWAPP_ELEM_WTP_NAME			/* 5 */
 | 
				
			||||||
#define	CW_CISCO_MWAR				LW_ELEM_AC_DESCRIPTOR			/* 6 */
 | 
					#define	CW_CISCO_MWAR				LW_ELEM_AC_DESCRIPTOR			/* 6 */
 | 
				
			||||||
#define CISCO_ELEM_ADD_WLAN			LW_ELEM_80211_ADD_WLAN			/* 7 */
 | 
					#define CISCO_ELEM_ADD_WLAN			LW_ELEM_80211_ADD_WLAN			/* 7 */
 | 
				
			||||||
#define CISCO_ELEM_WTP_RADIO_CONFIGURATION	8					/* 9 */
 | 
					#define CISCO_ELEM_WTP_RADIO_CONFIGURATION	8					/* 8 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_9				9					/* 9 */
 | 
					#define CISCO_ELEM_9				9					/* 9 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -47,14 +47,16 @@
 | 
				
			|||||||
#define CISCO_ELEM_TX_POWER			LW_ELEM_80211_TX_POWER			/* 12 */
 | 
					#define CISCO_ELEM_TX_POWER			LW_ELEM_80211_TX_POWER			/* 12 */
 | 
				
			||||||
#define CISCO_ELEM_TX_POWER_LEVELS		LW_ELEM_80211_TX_POWER_LEVELS		/* 13 */
 | 
					#define CISCO_ELEM_TX_POWER_LEVELS		LW_ELEM_80211_TX_POWER_LEVELS		/* 13 */
 | 
				
			||||||
#define CISCO_ELEM_DIRECT_SEQUENCE_CONTROL	LW_ELEM_DIRECT_SEQUENCE_CONTROL		/* 14 */
 | 
					#define CISCO_ELEM_DIRECT_SEQUENCE_CONTROL	LW_ELEM_DIRECT_SEQUENCE_CONTROL		/* 14 */
 | 
				
			||||||
#define CW_CISCO_SUPPORTED_RATES		LW_ELEM_80211_RATE_SET			/* 16 */
 | 
					#define CISCO_ELEM_SUPPORTED_RATES		LW_ELEM_80211_RATE_SET			/* 16 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_15				15					/* 15 */
 | 
					#define CISCO_ELEM_15				15					/* 15 */
 | 
				
			||||||
#define CISCO_ELEM_16				16					/* 16 */
 | 
					 | 
				
			||||||
#define CISCO_ELEM_19				19					/* 19 */
 | 
					#define CISCO_ELEM_19				19					/* 19 */
 | 
				
			||||||
#define CISCO_ELEM_22				22					/* 22 */
 | 
					#define CISCO_ELEM_22				22					/* 22 */
 | 
				
			||||||
#define CISCO_ELEM_24				24					/* 24 */
 | 
					#define CISCO_ELEM_24				24					/* 24 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define CISCO_ELEM_RRM_LOAD			25					/* 25 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CW_CISCO_80211_DELETE_WLAN		LW_ELEM_80211_DELETE_WLAN		/* 28 */
 | 
					#define CW_CISCO_80211_DELETE_WLAN		LW_ELEM_80211_DELETE_WLAN		/* 28 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CW_CISCO_MWAR_NAME			LW_ELEM_AC_NAME				/* 31 */
 | 
					#define CW_CISCO_MWAR_NAME			LW_ELEM_AC_NAME				/* 31 */
 | 
				
			||||||
@ -69,18 +71,19 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define CW_CISCO_CERTIFICATE			LW_ELEM_CERTIFICATE			/* 44 */
 | 
					#define CW_CISCO_CERTIFICATE			LW_ELEM_CERTIFICATE			/* 44 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_47				47					/* 47 */
 | 
					#define CISCO_ELEM_PERFORMANCE_PROFILE		47					/* 47 */
 | 
				
			||||||
#define CISCO_ELEM_48				48					/* 47 */
 | 
					#define CISCO_ELEM_SPAM_CFP_STATUS		48					/* 48 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_WTP_BOARD_DATA		LW_ELEM_WTP_BOARD_DATA			/* 50 */
 | 
					#define CISCO_ELEM_WTP_BOARD_DATA		LW_ELEM_WTP_BOARD_DATA			/* 50 */
 | 
				
			||||||
#define CW_CISCO_BCAST_SSID_MODE		LW_BCAST_SSID_MODE
 | 
					#define CISCO_ELEM_BCAST_SSID_MODE		LWAPP_ELEM_BCAST_SSID_MODE		/* 51 */
 | 
				
			||||||
#define CISCO_ELEM_AP_MODE_AND_TYPE		LW_ELEM_80211_WTP_MODE_AND_TYPE		/* 54 */
 | 
					#define CISCO_ELEM_AP_MODE_AND_TYPE		LW_ELEM_80211_WTP_MODE_AND_TYPE		/* 54 */
 | 
				
			||||||
#define CISCO_ELEM_AP_QOS			LW_ELEM_QOS				/* 57 */
 | 
					#define CISCO_ELEM_AP_QOS			LW_ELEM_QOS				/* 57 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CW_CISCO_AC_IPV4_LIST			LW_ELEM_AC_IPV4_LIST			/* 59 */
 | 
					#define CW_CISCO_AC_IPV4_LIST			LW_ELEM_AC_IPV4_LIST			/* 59 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_CAPWAP_TIMERS		LW_ELEM_LWAPP_TIMERS			/* 68 */
 | 
					#define CISCO_ELEM_CAPWAP_TIMERS		LW_ELEM_LWAPP_TIMERS			/* 68 */
 | 
				
			||||||
 | 
					#define CISCO_ELEM_CLIENT_AUTO_HANDOFF		72					/* 72 */
 | 
				
			||||||
#define CISCO_ELEM_81				81					/* 81 */
 | 
					#define CISCO_ELEM_81				81					/* 81 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_AP_STATIC_IP_ADDR		83
 | 
					#define CISCO_ELEM_AP_STATIC_IP_ADDR		83
 | 
				
			||||||
@ -102,7 +105,7 @@
 | 
				
			|||||||
#define CISCO_ELEM_RESET_BUTTON_STATE		128
 | 
					#define CISCO_ELEM_RESET_BUTTON_STATE		128
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_132				132					/* 132 */
 | 
					#define CISCO_ELEM_AP_DOT11H			132					/* 132 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_CHANNEL_POWER		134
 | 
					#define CISCO_ELEM_CHANNEL_POWER		134
 | 
				
			||||||
#define CISCO_ELEM_AP_CORE_DUMP			135
 | 
					#define CISCO_ELEM_AP_CORE_DUMP			135
 | 
				
			||||||
 | 
				
			|||||||
@ -258,6 +258,15 @@ static cw_ValStruct_t cisco_ap_power_injector_config[]={
 | 
				
			|||||||
	{NULL,NULL,0,0}
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_ValStruct_t cisco_ap_dot11h[]={
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"enable",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"count",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"mode",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"power",1,-1},
 | 
				
			||||||
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cisco_in_ap_regulatory_domain(struct cw_ElemHandler *eh, 
 | 
					int cisco_in_ap_regulatory_domain(struct cw_ElemHandler *eh, 
 | 
				
			||||||
		struct cw_ElemHandlerParams *params, 
 | 
							struct cw_ElemHandlerParams *params, 
 | 
				
			||||||
@ -267,7 +276,7 @@ int cisco_in_ap_regulatory_domain(struct cw_ElemHandler *eh,
 | 
				
			|||||||
	int idx;
 | 
						int idx;
 | 
				
			||||||
	void * type;
 | 
						void * type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	idx = cw_cfg_get_next_index(params->cfg,eh->key);
 | 
						idx = cw_cfg_get_new_index(params->cfg,eh->key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sprintf(key,"%s.%d",eh->key,idx);
 | 
						sprintf(key,"%s.%d",eh->key,idx);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@ -306,8 +315,10 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
 | 
				
			|||||||
		if(result->type->len(result)==4){
 | 
							if(result->type->len(result)==4){
 | 
				
			||||||
			uint32_t rv;
 | 
								uint32_t rv;
 | 
				
			||||||
			rv = cw_get_dword(result->type->data(result));
 | 
								rv = cw_get_dword(result->type->data(result));
 | 
				
			||||||
//cw_dbg(DBG_X,"Version is %08X",rv);			
 | 
					cw_dbg(DBG_X,"Version is %08X",rv);			
 | 
				
			||||||
			if (rv >= 0x07056600){
 | 
					//stop();
 | 
				
			||||||
 | 
					//			if (rv >= 0x07056600){
 | 
				
			||||||
 | 
								if (rv > 0x07036500){
 | 
				
			||||||
				type = cisco_ap_regulatory_domain5;
 | 
									type = cisco_ap_regulatory_domain5;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else{
 | 
								else{
 | 
				
			||||||
@ -371,7 +382,47 @@ static cw_ValStruct_t cisco_direct_sequence_control70[]={
 | 
				
			|||||||
	{NULL,NULL,0,0}
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int get_num_antennas70(cw_Cfg_t *cfg, 
 | 
				
			||||||
 | 
							const char * key, const uint8_t *src, int len, const void *param, int *l)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						*l=0;
 | 
				
			||||||
 | 
						return cw_get_byte(src-4);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int put_num_antennas70(cw_Cfg_t *cfg, 
 | 
				
			||||||
 | 
							const char * key, uint8_t *dst, const void *param, int l)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cw_put_byte((dst-4),l);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_ValValRange_t antenna_type[]={
 | 
				
			||||||
 | 
						{1,1,"1 - Internal Antenna"},
 | 
				
			||||||
 | 
						{2,2,"2 - External Antenna"},
 | 
				
			||||||
 | 
						{0,0,NULL}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cw_ValArrayDef ant_array = {
 | 
				
			||||||
 | 
						get_num_antennas70,
 | 
				
			||||||
 | 
						put_num_antennas70,
 | 
				
			||||||
 | 
						CW_TYPE_BYTE,
 | 
				
			||||||
 | 
						&antenna_type
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static cw_ValStruct_t cisco_antenna_payload70[]={
 | 
					static cw_ValStruct_t cisco_antenna_payload70[]={
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"diversity-selection",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"antenna-mode",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"antenna-cnt",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"unknown",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"802-11n-tx-antennas",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"802-11n-rx-antennas",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_ARRAY,"antenna",-1,-1,&ant_array},
 | 
				
			||||||
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					static cw_ValStruct_t cisco_antenna_payload73[]={
 | 
				
			||||||
	{CW_TYPE_BYTE,"diversity-selection",1,-1},
 | 
						{CW_TYPE_BYTE,"diversity-selection",1,-1},
 | 
				
			||||||
	{CW_TYPE_BYTE,"antenna-mode",1,-1},
 | 
						{CW_TYPE_BYTE,"antenna-mode",1,-1},
 | 
				
			||||||
	{CW_TYPE_BYTE,"number-of-antennas",1,-1},
 | 
						{CW_TYPE_BYTE,"number-of-antennas",1,-1},
 | 
				
			||||||
@ -383,6 +434,11 @@ static cw_ValStruct_t cisco_antenna_payload70[]={
 | 
				
			|||||||
	{CW_TYPE_BYTE,"antenna-2",1,-1},
 | 
						{CW_TYPE_BYTE,"antenna-2",1,-1},
 | 
				
			||||||
	{NULL,NULL,0,0}
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static cw_ValStruct_t cisco_wtp_radio_config70[]={
 | 
					static cw_ValStruct_t cisco_wtp_radio_config70[]={
 | 
				
			||||||
@ -390,7 +446,7 @@ static cw_ValStruct_t cisco_wtp_radio_config70[]={
 | 
				
			|||||||
	{CW_TYPE_WORD,"occupancy-limit",2,-1},
 | 
						{CW_TYPE_WORD,"occupancy-limit",2,-1},
 | 
				
			||||||
	{CW_TYPE_BYTE,"cfg-period",1,-1},
 | 
						{CW_TYPE_BYTE,"cfg-period",1,-1},
 | 
				
			||||||
	{CW_TYPE_WORD,"cfp-maximum-duration",2,-1},
 | 
						{CW_TYPE_WORD,"cfp-maximum-duration",2,-1},
 | 
				
			||||||
	{CW_TYPE_BSTR16,"bss-id",6,-1},
 | 
						{CW_TYPE_BSTR16,"bssid",6,-1},
 | 
				
			||||||
	{CW_TYPE_WORD,"beacon-period",2,-1},
 | 
						{CW_TYPE_WORD,"beacon-period",2,-1},
 | 
				
			||||||
	{CW_TYPE_STR,"country-str1",3,-1},
 | 
						{CW_TYPE_STR,"country-str1",3,-1},
 | 
				
			||||||
	{CW_TYPE_STR,"country-str2",3,-1},
 | 
						{CW_TYPE_STR,"country-str2",3,-1},
 | 
				
			||||||
@ -403,17 +459,18 @@ static cw_ValStruct_t cisco_wtp_radio_config70[]={
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static cw_ValStruct_t cisco_wtp_radio_config73[]={
 | 
					static cw_ValStruct_t cisco_wtp_radio_config73[]={
 | 
				
			||||||
	{CW_TYPE_BYTE,"cfg-type",1,-1},
 | 
						{CW_TYPE_BYTE,"@cisco/cfg-type",1,-1,cfg_type},
 | 
				
			||||||
	{CW_TYPE_WORD,"occupancy-limit",2,-1},
 | 
						{CW_TYPE_WORD,"@cisco/occupancy-limit",2,-1},
 | 
				
			||||||
	{CW_TYPE_BYTE,"cfg-period",1,-1},
 | 
						{CW_TYPE_BYTE,"@cisco/cfg-period",1,-1},
 | 
				
			||||||
	{CW_TYPE_WORD,"cfp-maximum-duration",2,-1},
 | 
						{CW_TYPE_WORD,"@cisco/cfp-maximum-duration",2,-1},
 | 
				
			||||||
	{CW_TYPE_BSTR16,"bss-id",6,-1},
 | 
						{CW_TYPE_BSTR16,"bssid",6,-1},
 | 
				
			||||||
	{CW_TYPE_WORD,"beacon-period",2,-1},
 | 
						{CW_TYPE_WORD,"beacon-period",2,-1},
 | 
				
			||||||
	{CW_TYPE_STR,"country-str1",3,-1},
 | 
						{CW_TYPE_STR,"@cisco/country-string",3,-1},
 | 
				
			||||||
	{CW_TYPE_STR,"country-str2",3,-1},
 | 
						{CW_TYPE_STR,"country-string",2,-1},
 | 
				
			||||||
	{CW_TYPE_BYTE,"gpr-period",1,-1},
 | 
						{CW_TYPE_BSTR16,"country-string-attr",1,-1},
 | 
				
			||||||
	{CW_TYPE_DWORD,"reg",4,-1},
 | 
						{CW_TYPE_BYTE,"@cisco/gpr-period",1,-1},
 | 
				
			||||||
	{CW_TYPE_BYTE,"max-stations",1,-1},
 | 
						{CW_TYPE_DWORD,"@cisco/reg",4,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"@cisco/max-stations",1,-1},
 | 
				
			||||||
	{NULL,NULL,0,0}
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -447,7 +504,61 @@ static cw_ValStruct_t cisco_lw_radio_module_info_stru[]={
 | 
				
			|||||||
	{CW_TYPE_STR,"name",21,-1},
 | 
						{CW_TYPE_STR,"name",21,-1},
 | 
				
			||||||
	{CW_TYPE_STR,"serial",11,-1},
 | 
						{CW_TYPE_STR,"serial",11,-1},
 | 
				
			||||||
	{CW_TYPE_STR,"type",25,-1},
 | 
						{CW_TYPE_STR,"type",25,-1},
 | 
				
			||||||
	{CW_TYPE_STR,"descr",126,-1},
 | 
						{CW_TYPE_STR,"descr",125,-1},
 | 
				
			||||||
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_ValStruct_t cisco_rrm_load_stru[]={
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"rx-load",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"tx-load",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"cca-load",1,-1},
 | 
				
			||||||
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_ValStruct_t cisco_performance_profile_stru[]={
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"cfg-type",1,-1,cfg_type},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"rf-busy-threshold",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"num-clients-threshold",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"bytes-per-sec",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"foreigh-threshold",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"rssi-threshold",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"min-perf-snr",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"excpection-level",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"min-num-clients",2,-1},
 | 
				
			||||||
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_ValStruct_t cisco_phy_ht_cap_stru[]={
 | 
				
			||||||
 | 
						{CW_TYPE_WORD,"ht-cap-info",2,-1},
 | 
				
			||||||
 | 
					/*	{CW_TYPE_WORD,"extendend-ht-cap-info",2,-1},*/
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"mcsrates-1",4,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"mcsrates-2",4,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"mcsrates-3",4,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"mcsrates-4",4,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"extended-ht-cap-info",2,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"tx-bf-cap",4,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"asel-cap",1,-1},
 | 
				
			||||||
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_ValStruct_t cisco_phy_ht_control_stru[]={
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"enable-ht",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"cfg-type",1,-1,cfg_type},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"current-freq",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"rest",4,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"frequency-bands-support",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"ti-threshold",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"flash-commit",1,-1},	//byte2
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"cur-freq-is-dfs-channel",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"channel-width",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"ext-channel",1,-1},
 | 
				
			||||||
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cw_ValStruct_t cisco_station_cfg_stru[]={
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"cfg-type",1,-1,cfg_type},
 | 
				
			||||||
 | 
						{CW_TYPE_BYTE,"current-freq",1,-1},
 | 
				
			||||||
 | 
						{CW_TYPE_BSTR16,"rest",-1,-1},
 | 
				
			||||||
	{NULL,NULL,0,0}
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -580,25 +691,25 @@ static cw_ValStruct_t cisco_add_wlan[]={
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static cw_ValStruct_t cisco_add_wlan70[]={
 | 
					static cw_ValStruct_t cisco_add_wlan70[]={
 | 
				
			||||||
	{CW_TYPE_BYTE,"radio-id",1,-1},
 | 
						{CW_TYPE_BYTE,"radio-id",1,-1},
 | 
				
			||||||
	{CW_TYPE_WORD,"wlan-capability",2,-1},
 | 
						{CW_TYPE_WORD,"capwap80211/capability",2,-1},
 | 
				
			||||||
	{CW_TYPE_BYTE,"wlan-id",1,4},
 | 
						{CW_TYPE_BYTE,"wlan-id",1,4},
 | 
				
			||||||
	{CW_TYPE_DWORD,"encryption-policy",4,5},
 | 
						{CW_TYPE_DWORD,"cisco/encryption-policy",4,5},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{CW_TYPE_BSTR16,"wep-key",13,9},
 | 
						{CW_TYPE_BSTR16,"cisco/wep-key",13,9},
 | 
				
			||||||
	{CW_TYPE_BYTE,"wep-key-index",1,41},
 | 
						{CW_TYPE_BYTE,"cisco/wep-key-index",1,41},
 | 
				
			||||||
	{CW_TYPE_BOOL,"wep-encryption",1,42},
 | 
						{CW_TYPE_BOOL,"cisco/wep-encryption",1,42},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{CW_TYPE_BYTE,"qos",1,324},
 | 
						{CW_TYPE_BYTE,"capwap80211/qos",1,324},
 | 
				
			||||||
	{CW_TYPE_WORD,"scan-defer-period",1,328},
 | 
						{CW_TYPE_WORD,"cisco/scan-defer-period",1,328},
 | 
				
			||||||
	{CW_TYPE_WORD,"scan-defer-time",1,330},
 | 
						{CW_TYPE_WORD,"cisco/scan-defer-time",1,330},
 | 
				
			||||||
	{CW_TYPE_BOOL,"broadcast-ssid",1,332},
 | 
						{CW_TYPE_BOOL,"cisco/broadcast-ssid",1,332},
 | 
				
			||||||
	{CW_TYPE_BOOL,"aironet-ie",1,333},
 | 
						{CW_TYPE_BOOL,"cisco/aironet-ie",1,333},
 | 
				
			||||||
	{CW_TYPE_BYTE,"hreap-local-switch",1,378},
 | 
						{CW_TYPE_BYTE,"cisco/hreap-local-switch",1,378},
 | 
				
			||||||
	{CW_TYPE_WORD,"session-timout",2,381},
 | 
						{CW_TYPE_WORD,"cisco/session-timout",2,381},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{CW_TYPE_BYTE, "dtim-period",1,440},
 | 
						{CW_TYPE_BYTE, "cisco/dtim-period",1,440},
 | 
				
			||||||
	{CW_TYPE_STR,"profile-name",30,441},
 | 
						{CW_TYPE_STR,"cisco/profile-name",30,441},
 | 
				
			||||||
	{CW_TYPE_STR, "ssid",33,474},
 | 
						{CW_TYPE_STR, "capwap80211/ssid",33,474},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	{NULL,NULL,0,0}
 | 
						{NULL,NULL,0,0}
 | 
				
			||||||
@ -653,10 +764,18 @@ static int cisco_add_wlan_mkkey70(const char *pkey, uint8_t*data, int len, char
 | 
				
			|||||||
        int wlan_id,radio_id;
 | 
					        int wlan_id,radio_id;
 | 
				
			||||||
        radio_id = cw_get_byte(data);
 | 
					        radio_id = cw_get_byte(data);
 | 
				
			||||||
        wlan_id = cw_get_byte(data+4);
 | 
					        wlan_id = cw_get_byte(data+4);
 | 
				
			||||||
        sprintf(dst,"radio.%d/wlan.%d/add-wlan",radio_id,wlan_id);
 | 
					        sprintf(dst,"radio.%d/wlan.%d",radio_id,wlan_id);
 | 
				
			||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int mkkey_sig_payload(const char *pkey, uint8_t*data, int len, char *dst)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        int id;
 | 
				
			||||||
 | 
					        id = cw_get_byte(data+4);
 | 
				
			||||||
 | 
					        sprintf(dst,"%s.%d",pkey,id);
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
static int cisco_patch_add_wlan70(uint8_t * data, void * st)
 | 
					static int cisco_patch_add_wlan70(uint8_t * data, void * st)
 | 
				
			||||||
@ -832,12 +951,12 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	,
 | 
						,
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		"RAD Name -> CAPWAP WTP Name",	/* name */
 | 
							"Cisco RAD Name",		/* name */
 | 
				
			||||||
		CISCO_ELEM_RAD_NAME,		/* Element ID */
 | 
							CISCO_ELEM_RAD_NAME,		/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,		/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,		/* Vendor / Proto */
 | 
				
			||||||
		1,512,				/* min/max length */
 | 
							1,512,				/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,			/* type */
 | 
							CW_TYPE_BSTR16,			/* type */
 | 
				
			||||||
		"capwap/wtp-name",		/* Key */
 | 
							"cisco/rad-name",		/* Key */
 | 
				
			||||||
		cw_in_generic,			/* get */
 | 
							cw_in_generic,			/* get */
 | 
				
			||||||
		cw_out_generic			/* put */
 | 
							cw_out_generic			/* put */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -1284,7 +1403,7 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		25,25,					/* min/max length */
 | 
							25,25,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_STRUCT,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/wtp-radio-config",		/* Key */
 | 
							"capwap80211/wtp-radio-config",		/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic,			/* put */
 | 
							cw_out_radio_generic,			/* put */
 | 
				
			||||||
		NULL,
 | 
							NULL,
 | 
				
			||||||
@ -1316,7 +1435,7 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		"Antenna Payload (v7.0)",		/* name */
 | 
							"Antenna Payload (v7.0)",		/* name */
 | 
				
			||||||
		CW_CISCO_ANTENNA_PAYLOAD,		/* Element ID */
 | 
							CW_CISCO_ANTENNA_PAYLOAD,		/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		9,9,					/* min/max length */
 | 
							9,100,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_STRUCT,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/antenna-payload",		/* Key */
 | 
							"cisco/antenna-payload",		/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
@ -1411,16 +1530,31 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco Elem 132",			/* name */
 | 
							"Cisco AP 802.11h",				/* name */
 | 
				
			||||||
		CISCO_ELEM_132,				/* Element ID */
 | 
							CISCO_ELEM_AP_DOT11H,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							5,5,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/elem132",				/* Key */
 | 
							"cisco/80211h",				/* Key */
 | 
				
			||||||
 | 
							cw_in_radio_generic,				/* get */
 | 
				
			||||||
 | 
							cw_out_radio_generic,				/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_ap_dot11h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{ 
 | 
				
			||||||
 | 
							"Cisco Boradcast SSID Mode",		/* name */
 | 
				
			||||||
 | 
							CISCO_ELEM_BCAST_SSID_MODE,		/* Element ID */
 | 
				
			||||||
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
 | 
							1,1,					/* min/max length */
 | 
				
			||||||
 | 
							CW_TYPE_BYTE,				/* type */
 | 
				
			||||||
 | 
							"cisco/bcast-ssid-mode",		/* Key */
 | 
				
			||||||
		cw_in_generic,				/* get */
 | 
							cw_in_generic,				/* get */
 | 
				
			||||||
		cw_out_generic				/* put */
 | 
							cw_out_generic				/* put */
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco Elem 33",			/* name */
 | 
							"Cisco Elem 33",			/* name */
 | 
				
			||||||
		CISCO_ELEM_33,				/* Element ID */
 | 
							CISCO_ELEM_33,				/* Element ID */
 | 
				
			||||||
@ -1431,6 +1565,17 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		cw_in_generic,				/* get */
 | 
							cw_in_generic,				/* get */
 | 
				
			||||||
		cw_out_generic				/* put */
 | 
							cw_out_generic				/* put */
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{ 
 | 
				
			||||||
 | 
							"Cisco - Client Auto Hand-Off",		/* name */
 | 
				
			||||||
 | 
							CISCO_ELEM_CLIENT_AUTO_HANDOFF,			/* Element ID */
 | 
				
			||||||
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
 | 
							1,1,					/* min/max length */
 | 
				
			||||||
 | 
							CW_TYPE_BYTE,				/* type */
 | 
				
			||||||
 | 
							"cisco/client-auto-handoff",			/* Key */
 | 
				
			||||||
 | 
							cw_in_generic,				/* get */
 | 
				
			||||||
 | 
							cw_out_generic				/* put */
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco Elem 15 - Channel Setting (?)",	/* name */
 | 
							"Cisco Elem 15 - Channel Setting (?)",	/* name */
 | 
				
			||||||
@ -1438,7 +1583,7 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							1,1024,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_STRUCT,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/elem15",				/* Key */
 | 
							"cisco/channel-setting",				/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic,			/* put */
 | 
							cw_out_radio_generic,			/* put */
 | 
				
			||||||
		NULL,
 | 
							NULL,
 | 
				
			||||||
@ -1448,8 +1593,8 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco Elem 16 ",		/* name */
 | 
							"Cisco - Supported Rates",		/* name */
 | 
				
			||||||
		CISCO_ELEM_16,				/* Element ID */
 | 
							CISCO_ELEM_SUPPORTED_RATES,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							1,1024,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,				/* type */
 | 
							CW_TYPE_BSTR16,				/* type */
 | 
				
			||||||
@ -1462,6 +1607,22 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{ 
 | 
				
			||||||
 | 
							"Cisco Elem 25 ",		/* name */
 | 
				
			||||||
 | 
							CISCO_ELEM_RRM_LOAD,				/* Element ID */
 | 
				
			||||||
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
 | 
							4,4,					/* min/max length */
 | 
				
			||||||
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
 | 
							"cisco/rrm",				/* Key */
 | 
				
			||||||
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
 | 
							cw_out_radio_generic,			/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_rrm_load_stru,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
@ -1520,12 +1681,12 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco Elem 48",			/* name */
 | 
							"Cisco - Spam CFP Status",		/* name */
 | 
				
			||||||
		CISCO_ELEM_48,				/* Element ID */
 | 
							CISCO_ELEM_SPAM_CFP_STATUS,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							2,2,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,				/* type */
 | 
							CW_TYPE_BOOL,				/* type */
 | 
				
			||||||
		"cisco/elem48",				/* Key */
 | 
							"cisco/spam-cfp-status",				/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic			/* put */
 | 
							cw_out_radio_generic			/* put */
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
@ -1547,21 +1708,21 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco LWAPP Elem 11",			/* name */
 | 
							"Cisco LWAPP AP MFP Cap. Sub-type",	/* name */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		CISCO_LWELEM_11,				/* Element ID */
 | 
							CISCO_LWELEM_AP_MFP_CAP_SUBTYPE,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							5,5,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,				/* type */
 | 
							CW_TYPE_DWORD,				/* type */
 | 
				
			||||||
		"cisco/lwelem11",			/* Key */
 | 
							"cisco/ap-mfp-cap-subtype",			/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic			/* put */
 | 
							cw_out_radio_generic			/* put */
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco LWAP Elem 14",			/* name */
 | 
							"Cisco AP MFP Config Subt.",			/* name */
 | 
				
			||||||
		CISCO_LWELEM_14,				/* Element ID */
 | 
							CISCO_LWELEM_AP_MFP_CONFIG_SUBTYPE,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							1,1024,					/* min/max length */
 | 
				
			||||||
@ -1574,43 +1735,52 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco LWAP Elem 27",			/* name */
 | 
							"Cisco LWAPP PHY HT Cap.",			/* name */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		CISCO_LWELEM_27,				/* Element ID */
 | 
							CISCO_LWELEM_PHY_HT_CAP,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							26,26,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/lwelem27",			/* Key */
 | 
							"cisco/phy-ht-cap",			/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic			/* put */
 | 
							cw_out_radio_generic,		/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_phy_ht_cap_stru,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco LWAP Elem 28",			/* name */
 | 
							"Cisco LWAPP Station Cfg 28 ???",			/* name */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		CISCO_LWELEM_28,				/* Element ID */
 | 
							CISCO_LWELEM_28,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							1,1024,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/lwelem28",			/* Key */
 | 
							"cisco/station-cfg",			/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic			/* put */
 | 
							cw_out_radio_generic,			 /* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_station_cfg_stru,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco LWAPP Elem 29",			/* name */
 | 
							"Cisco LWAPP PHY HT Control",		/* name */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		CISCO_LWELEM_29,				/* Element ID */
 | 
							CISCO_LWELEM_PHY_HT_CONTROL,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							1,1024,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/lwelem29",			/* Key */
 | 
							"cisco/phy-ht-control",			/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic			/* put */
 | 
							cw_out_radio_generic,			/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_phy_ht_control_stru
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1728,14 +1898,17 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
		"Cisco Elem 47",			/* name */
 | 
							"Cisco - Performance Profile",		/* name */
 | 
				
			||||||
		CISCO_ELEM_47,				/* Element ID */
 | 
							CISCO_ELEM_PERFORMANCE_PROFILE,				/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		1,1024,					/* min/max length */
 | 
							18,18,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BSTR16,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/elem47",				/* Key */
 | 
							"cisco/proformance-profile",		/* Key */
 | 
				
			||||||
		cw_in_radio_generic,			/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic			/* put */
 | 
							cw_out_radio_generic,			/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_performance_profile_stru
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1763,10 +1936,13 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		CISCO_ELEM_AP_QOS,			/* Element ID */
 | 
							CISCO_ELEM_AP_QOS,			/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		52,52,					/* min/max length */
 | 
							52,52,					/* min/max length */
 | 
				
			||||||
		cisco_ap_qos,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/ap-qos",				/* Key */
 | 
							"cisco/ap-qos",				/* Key */
 | 
				
			||||||
		cw_in_radio_generic_struct,		/* get */
 | 
							cw_in_radio_generic,		/* get */
 | 
				
			||||||
		cw_out_radio_generic_struct		/* put */
 | 
							cw_out_radio_generic, /* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_ap_qos,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
@ -1906,9 +2082,9 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		7,1117,					/* min/max length */
 | 
							7,1117,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_STRUCT,				/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"radio/wlan/add-wlan",			/* Key */
 | 
							"radio/wlan/",				/* Key */
 | 
				
			||||||
		cw_in_generic,				/* get */
 | 
							cw_in_generic,				/* get */
 | 
				
			||||||
		cw_out_traverse,			/* put */
 | 
							cw_out_generic_walk,			/* put */
 | 
				
			||||||
		cisco_add_wlan_mkkey70,
 | 
							cisco_add_wlan_mkkey70,
 | 
				
			||||||
		NULL, //		cisco_patch_add_wlan70
 | 
							NULL, //		cisco_patch_add_wlan70
 | 
				
			||||||
		cisco_add_wlan70
 | 
							cisco_add_wlan70
 | 
				
			||||||
@ -1920,12 +2096,13 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		CISCO_LWELEM_ADD_WLAN,			/* Element ID */
 | 
							CISCO_LWELEM_ADD_WLAN,			/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
				
			||||||
		7,1117,					/* min/max length */
 | 
							7,1117,					/* min/max length */
 | 
				
			||||||
		cisco_add_lwwlan,			/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"radio/wlan/add-lw-wlan",		/* Key */
 | 
							"radio/wlan/add-lw-wlan",		/* Key */
 | 
				
			||||||
		cw_in_generic_struct,			/* get */
 | 
							cw_in_generic,				/* get */
 | 
				
			||||||
		cw_out_traverse,			/* put */
 | 
							cw_out_traverse,			/* put */
 | 
				
			||||||
		cisoc_add_lwwlan_mkkey,
 | 
							cisoc_add_lwwlan_mkkey,
 | 
				
			||||||
		cisco_patch_add_lwwlan
 | 
							cisco_patch_add_lwwlan,
 | 
				
			||||||
 | 
							cisco_add_lwwlan,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	,
 | 
						,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2022,10 +2199,13 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		CISCO_LWELEM_RAD_EXTENDED_CONFIG,	/* Element ID */
 | 
							CISCO_LWELEM_RAD_EXTENDED_CONFIG,	/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
				
			||||||
		13,13,					/* min/max length */
 | 
							13,13,					/* min/max length */
 | 
				
			||||||
		cisco_rad_extended_config,		/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/rad-extended-config",		/* Key */
 | 
							"cisco/rad-extended-config",		/* Key */
 | 
				
			||||||
		cw_in_radio_generic_struct,		/* get */
 | 
							cw_in_radio_generic,		/* get */
 | 
				
			||||||
		cw_out_radio_generic_struct		/* put */
 | 
							cw_out_radio_generic,		/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_rad_extended_config,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -2069,6 +2249,21 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
		cw_out_generic					/* put */
 | 
							cw_out_generic					/* put */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	,
 | 
						,
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							"CISCO Sig Payload",				/* name */
 | 
				
			||||||
 | 
							CISCO_ELEM_SIG_PAYLOAD,				/* Element ID */
 | 
				
			||||||
 | 
							CW_VENDOR_ID_CISCO, 0,				/* Vendor / Proto */
 | 
				
			||||||
 | 
							1, 1024,					/* min/max length */
 | 
				
			||||||
 | 
							CW_TYPE_BSTR16,					/* type */
 | 
				
			||||||
 | 
							"cisco/sig-payload",				/* Key */
 | 
				
			||||||
 | 
							cw_in_generic,					/* get */
 | 
				
			||||||
 | 
							cw_out_generic,					/* put */
 | 
				
			||||||
 | 
							mkkey_sig_payload,				/* mkkey */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		"Dot11r WLC Mac And IP (Cisco)",		/* name */
 | 
							"Dot11r WLC Mac And IP (Cisco)",		/* name */
 | 
				
			||||||
@ -2128,11 +2323,20 @@ static struct cw_ElemHandler handlers70[] = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct cw_ElemDef discovery_request_elements[] ={
 | 
					static struct cw_ElemDef discovery_request_elements[] ={
 | 
				
			||||||
/*	{0,0,			CAPWAP_ELEM_WTP_DESCRIPTOR,	1, 0},*/
 | 
					
 | 
				
			||||||
	{0,0,			CAPWAP_ELEM_WTP_BOARD_DATA,	0, 0},
 | 
						/* This is Cisco's version of WTP Name msg elemnt. */
 | 
				
			||||||
	{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_RAD_NAME,			1, 0},
 | 
						{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_RAD_NAME,			1, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Cisco dosn't sends WTP radio information in discovery 
 | 
				
			||||||
 | 
						 * requests and no WTP Board Data element, so we make them 
 | 
				
			||||||
 | 
						 * non-mandatory here */
 | 
				
			||||||
 | 
						{0,0,			CAPWAP80211_ELEM_WTP_RADIO_INFORMATION,	0, 0},
 | 
				
			||||||
 | 
						{0,0,			CAPWAP_ELEM_WTP_BOARD_DATA,		0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Instead of WTP Board Data we get Board Data Options from 
 | 
				
			||||||
 | 
						 * Ciso's APs */
 | 
				
			||||||
	{0,CW_VENDOR_ID_CISCO,	CW_CISCO_BOARD_DATA_OPTIONS,		0, 0},
 | 
						{0,CW_VENDOR_ID_CISCO,	CW_CISCO_BOARD_DATA_OPTIONS,		0, 0},
 | 
				
			||||||
	{0,0,			CAPWAP80211_ELEM_WTP_RADIO_INFORMATION,	1, 0},
 | 
					
 | 
				
			||||||
	{0,0,0,00}
 | 
						{0,0,0,00}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -2146,16 +2350,16 @@ static struct cw_ElemDef discovery_response_elements[] ={
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*static uint16_t join_request_states[] = {CAPWAP_STATE_JOIN,0};*/
 | 
					 | 
				
			||||||
static struct cw_ElemDef join_request_elements[] ={
 | 
					static struct cw_ElemDef join_request_elements[] ={
 | 
				
			||||||
	{0,0,			CAPWAP_ELEM_WTP_IPV4_IP_ADDRESS,1,0},
 | 
						{0,0,			CAPWAP_ELEM_WTP_IPV4_IP_ADDRESS,	1, 0},
 | 
				
			||||||
	{0,0,			CAPWAP_ELEM_WTP_IPV6_IP_ADDRESS,1,0},
 | 
						{0,0,			CAPWAP_ELEM_WTP_IPV6_IP_ADDRESS,	1, 0},
 | 
				
			||||||
	{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_GROUP_NAME,		1, 0},
 | 
						{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_GROUP_NAME,		1, 0},
 | 
				
			||||||
	{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_MWAR_ADDR,			1, 0},
 | 
						{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_MWAR_ADDR,			1, 0},
 | 
				
			||||||
	{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE},
 | 
						{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_VENDOR_SPECIFIC,	0, CW_IGNORE},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	{0,CW_VENDOR_ID_CISCO,	CW_CISCO_BOARD_DATA_OPTIONS,		1, 0},
 | 
						{0,CW_VENDOR_ID_CISCO,	CW_CISCO_BOARD_DATA_OPTIONS,		1, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0,0,CAPWAP_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS,			0, CW_DELETE},
 | 
						{0,0,CAPWAP_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS,			0, CW_DELETE},
 | 
				
			||||||
	{0,0,CAPWAP_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS,			0, CW_DELETE},
 | 
						{0,0,CAPWAP_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS,			0, CW_DELETE},
 | 
				
			||||||
	{0,0,			CAPWAP_ELEM_ECN_SUPPORT,		0, CW_DELETE},
 | 
						{0,0,			CAPWAP_ELEM_ECN_SUPPORT,		0, CW_DELETE},
 | 
				
			||||||
@ -2190,26 +2394,29 @@ static struct cw_ElemDef configuration_status_request_elements[] ={
 | 
				
			|||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_15,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_15,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_16,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SUPPORTED_RATES,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_19,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_19,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_22,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_22,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_24,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_24,				0, 0},	
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_RRM_LOAD,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_33,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_33,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_39,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_39,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_47,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_BCAST_SSID_MODE,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_48,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_PERFORMANCE_PROFILE,				0, 0},	
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_CFP_STATUS,				0, 0},	
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_CLIENT_AUTO_HANDOFF,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_81,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_81,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_132,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_DOT11H,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_145,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_145,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_146,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_146,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_153,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_153,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_156,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_156,				0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_9,		0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_9,		0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_11,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_MFP_CAP_SUBTYPE,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_14,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_MFP_CONFIG_SUBTYPE,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_27,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_PHY_HT_CAP,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_28,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_28,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_29,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_PHY_HT_CONTROL,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_33,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_33,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_48,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_48,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_55,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_55,	0, 0},	
 | 
				
			||||||
@ -2237,21 +2444,21 @@ static struct cw_ElemDef configuration_status_request_elements[] ={
 | 
				
			|||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_REGULATORY_DOMAIN,	1, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_REGULATORY_DOMAIN,	1, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_MODEL,			1, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_MODEL,			1, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_RESET_BUTTON_STATE,		1, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_RESET_BUTTON_STATE,		1, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_WTP_RADIO_CONFIGURATION,	1, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_WTP_RADIO_CONFIGURATION,	0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CW_CISCO_ANTENNA_PAYLOAD,		1, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CW_CISCO_ANTENNA_PAYLOAD,		0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AC_NAME_WITH_INDEX,		0, CW_IGNORE},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AC_NAME_WITH_INDEX,		0, CW_IGNORE},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_CORE_DUMP,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_CORE_DUMP,		0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_VENUE_SETTINGS,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_VENUE_SETTINGS,		0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_MAC_OPERATION,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_MAC_OPERATION,		0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_TX_POWER,			1, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_TX_POWER,			0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_TX_POWER_LEVELS,		1, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_TX_POWER_LEVELS,		0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_CHANNEL_POWER,		1, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_CHANNEL_POWER,		0, 0},	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_USERNAME_PASSWORD,	1, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_USERNAME_PASSWORD,	0, 0},
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_LOGHOST_CONFIG,		1, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_LOGHOST_CONFIG,		1, 0},
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_TELNET_SSH,		1, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_TELNET_SSH,		1, 0},
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_SUBMODE,		1, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_SUBMODE,		1, 0},
 | 
				
			||||||
@ -2273,28 +2480,31 @@ static struct cw_ElemDef configuration_status_request_elements[] ={
 | 
				
			|||||||
static struct cw_ElemDef configuration_status_response_elements[] ={
 | 
					static struct cw_ElemDef configuration_status_response_elements[] ={
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_BCAST_SSID_MODE,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_15,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_15,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_16,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SUPPORTED_RATES,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_19,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_19,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_22,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_22,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_24,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_24,				0, 0},	
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_RRM_LOAD,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_33,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_33,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_39,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_39,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_47,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_PERFORMANCE_PROFILE,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_48,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_CFP_STATUS,				0, 0},	
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_CLIENT_AUTO_HANDOFF,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_81,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_81,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_132,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_DOT11H,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_145,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_145,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_146,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_146,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_153,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_153,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_156,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_156,				0, 0},	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_9,		0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_9,		0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_11,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_MFP_CAP_SUBTYPE,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_14,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_MFP_CONFIG_SUBTYPE,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_27,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_PHY_HT_CAP,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_28,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_28,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_29,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_PHY_HT_CONTROL,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_33,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_33,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_48,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_48,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_55,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_55,	0, 0},	
 | 
				
			||||||
@ -2312,7 +2522,7 @@ static struct cw_ElemDef configuration_status_response_elements[] ={
 | 
				
			|||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_MULTI_DOMAIN_CAPABILITY,	0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_MULTI_DOMAIN_CAPABILITY,	0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_WTP_RADIO_CONFIGURATION,	1, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_WTP_RADIO_CONFIGURATION,	1, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_DIRECT_SEQUENCE_CONTROL,	0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_DIRECT_SEQUENCE_CONTROL,	0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CW_CISCO_ANTENNA_PAYLOAD,		1, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CW_CISCO_ANTENNA_PAYLOAD,		0, 0},
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_LED_STATE_CONFIG,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_LED_STATE_CONFIG,		0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_LOG_FACILITY,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_LOG_FACILITY,		0, 0},
 | 
				
			||||||
@ -2332,31 +2542,41 @@ static struct cw_ElemDef configuration_status_response_elements[] ={
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*static uint16_t configuration_update_request_states[] = {CAPWAP_STATE_RUN,0};*/
 | 
					 | 
				
			||||||
static struct cw_ElemDef configuration_update_request_elements[] ={
 | 
					static struct cw_ElemDef configuration_update_request_elements[] ={
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{0, 0,			CAPWAP_ELEM_RADIO_ADMINISTRATIVE_STATE,	0, 0},
 | 
				
			||||||
 | 
						{0, 0,			CAPWAP_ELEM_RADIO_OPERATIONAL_STATE,	0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{0,CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_GROUP_NAME,	0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_BCAST_SSID_MODE,				0, 0},	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_15,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_15,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_16,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SUPPORTED_RATES,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_19,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_19,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_22,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_22,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_24,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_24,				0, 0},	
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_RRM_LOAD,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_33,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_33,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_39,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_39,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_47,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_PERFORMANCE_PROFILE,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_48,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_CFP_STATUS,				0, 0},	
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_CLIENT_AUTO_HANDOFF,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_81,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_81,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_132,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_DOT11H,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_145,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_145,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_146,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_146,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_153,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_153,				0, 0},	
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_156,				0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_156,				0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_9,		0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_9,		0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_11,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_MFP_CAP_SUBTYPE,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_14,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_AP_MFP_CONFIG_SUBTYPE,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_27,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_PHY_HT_CAP,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_28,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_28,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_29,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_PHY_HT_CONTROL,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_33,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_33,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_48,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_48,	0, 0},	
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_55,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_55,	0, 0},	
 | 
				
			||||||
@ -2388,7 +2608,7 @@ static struct cw_ElemDef configuration_update_request_elements[] ={
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_MIN_IOS_VERSION,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_MIN_IOS_VERSION,		0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_BACKUP_SOFTWARE_VERSION,	0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_BACKUP_SOFTWARE_VERSION,	0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_REGULATORY_DOMAIN,	0, 0},
 | 
					/*	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_REGULATORY_DOMAIN,	0, 0},*/
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_MODEL,			0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_MODEL,			0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_RESET_BUTTON_STATE,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_RESET_BUTTON_STATE,		0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_WTP_RADIO_CONFIGURATION,	0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_WTP_RADIO_CONFIGURATION,	0, 0},
 | 
				
			||||||
@ -2400,10 +2620,12 @@ static struct cw_ElemDef configuration_update_request_elements[] ={
 | 
				
			|||||||
//	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_VENUE_SETTINGS,		0, 0},
 | 
					//	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_AP_VENUE_SETTINGS,		0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_80211_ASSOC_LIMIT,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_80211_ASSOC_LIMIT,		0, 0},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SIG_TOGGLE,			0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SIG_TOGGLE,			0, 0},
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SIG_PAYLOAD,			0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_MAC_OPERATION,		0, 0},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_MAC_OPERATION,		0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_TX_POWER,			0, 0},	
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_TX_POWER,			0, 0},	
 | 
				
			||||||
/*	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_TX_POWER_LEVELS,		1, 0},	*/
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_TX_POWER_LEVELS,		0, 0},	
 | 
				
			||||||
/*	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_CHANNEL_POWER,		1, 0},	*/
 | 
					/*	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_CHANNEL_POWER,		1, 0},	*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2438,10 +2660,13 @@ static struct cw_ElemDef configuration_update_request_elements[] ={
 | 
				
			|||||||
static struct cw_ElemDef wtp_event_request_elements[] ={
 | 
					static struct cw_ElemDef wtp_event_request_elements[] ={
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE},
 | 
				
			||||||
	{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_ADD_WLAN,			0, CW_IGNORE},
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_ADD_WLAN,			0, CW_IGNORE},
 | 
				
			||||||
 | 
						{0, CW_VENDOR_ID_CISCO,	CISCO_ELEM_RRM_LOAD,				0, 0},	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_ADD_WLAN,			0, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_ADD_WLAN,			0, 0},
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_HARDWARE_INFO,			0, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_HARDWARE_INFO,			0, 0},
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_RADIO_MODULE_INFO,	0, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_RADIO_MODULE_INFO,	0, 0},
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_29,	0, 0},	
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_PHY_HT_CONTROL,	0, 0},	
 | 
				
			||||||
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_55,	0, 0},	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0,0,0,0,0}
 | 
						{0,0,0,0,0}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -2465,7 +2690,7 @@ static struct cw_ElemDef change_state_event_request_elements[] ={
 | 
				
			|||||||
	{0, 0,			CAPWAP_ELEM_RADIO_ADMINISTRATIVE_STATE,	1, 0},
 | 
						{0, 0,			CAPWAP_ELEM_RADIO_ADMINISTRATIVE_STATE,	1, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_HARDWARE_INFO,	1, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_HARDWARE_INFO,	1, 0},
 | 
				
			||||||
	{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_RADIO_MODULE_INFO,	1, 0},
 | 
						{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO,	CISCO_LWELEM_RADIO_MODULE_INFO,	0, 0},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0,0,0,0,0}
 | 
						{0,0,0,0,0}
 | 
				
			||||||
@ -2656,10 +2881,13 @@ static struct cw_ElemHandler handlers73[] = {
 | 
				
			|||||||
		CISCO_ELEM_WTP_RADIO_CONFIGURATION,	/* Element ID */
 | 
							CISCO_ELEM_WTP_RADIO_CONFIGURATION,	/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		27,27,					/* min/max length */
 | 
							27,27,					/* min/max length */
 | 
				
			||||||
		cisco_wtp_radio_config73,		/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/wtp-radio-config",		/* Key */
 | 
							"capwap80211/wtp-radio-config",		/* Key */
 | 
				
			||||||
		cw_in_radio_generic_struct,		/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic_struct		/* put */
 | 
							cw_out_radio_generic,			/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_wtp_radio_config73,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	,
 | 
						,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2689,10 +2917,13 @@ static struct cw_ElemHandler handlers75[] = {
 | 
				
			|||||||
		CISCO_ELEM_WTP_RADIO_CONFIGURATION,	/* Element ID */
 | 
							CISCO_ELEM_WTP_RADIO_CONFIGURATION,	/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		28,28,					/* min/max length */
 | 
							28,28,					/* min/max length */
 | 
				
			||||||
		cisco_wtp_radio_config75,		/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/wtp-radio-config",		/* Key */
 | 
							"capwap80211/wtp-radio-config",		/* Key */
 | 
				
			||||||
		cw_in_radio_generic_struct,		/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic_struct		/* put */
 | 
							cw_out_radio_generic,			/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_wtp_radio_config75,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	,
 | 
						,
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
@ -2700,10 +2931,13 @@ static struct cw_ElemHandler handlers75[] = {
 | 
				
			|||||||
		CISCO_ELEM_MAC_OPERATION,		/* Element ID */
 | 
							CISCO_ELEM_MAC_OPERATION,		/* Element ID */
 | 
				
			||||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
							CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
				
			||||||
		17,17,					/* min/max length */
 | 
							17,17,					/* min/max length */
 | 
				
			||||||
		cisco_mac_operation75,			/* type */
 | 
							CW_TYPE_STRUCT,				/* type */
 | 
				
			||||||
		"cisco/mac-operation",			/* Key */
 | 
							"cisco/mac-operation",			/* Key */
 | 
				
			||||||
		cw_in_radio_generic_struct,		/* get */
 | 
							cw_in_radio_generic,			/* get */
 | 
				
			||||||
		cw_out_radio_generic_struct		/* put */
 | 
							cw_out_radio_generic,			/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							cisco_mac_operation75,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{0,0,0,0,0,0,0,0}
 | 
						{0,0,0,0,0,0,0,0}
 | 
				
			||||||
@ -2756,6 +2990,24 @@ struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode){
 | 
				
			|||||||
        return set;
 | 
					        return set;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void update_msgset(struct cw_MsgSet *msgset, bstr_t version)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if(bstr16_len(version)==4){
 | 
				
			||||||
 | 
							uint32_t rv;
 | 
				
			||||||
 | 
							rv = cw_get_dword(bstr16_data(version));
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (rv >= 0x07030000){
 | 
				
			||||||
 | 
								cw_dbg(DBG_MOD, "CISCO - Loading messages for 0x%08X >= 0x07030000", rv);
 | 
				
			||||||
 | 
								cw_msgset_add(msgset,messages73, handlers73);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (rv >= 0x07056600){
 | 
				
			||||||
 | 
								cw_dbg(DBG_MOD, "CISCO - Loading messages for 0x.x%08X >= 0x07056600", rv);
 | 
				
			||||||
 | 
								cw_msgset_add(msgset,messages75, handlers75);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_ac_version(struct cw_ElemHandlerParams * params)
 | 
					static void set_ac_version(struct cw_ElemHandlerParams * params)
 | 
				
			||||||
@ -2772,36 +3024,23 @@ static void set_ac_version(struct cw_ElemHandlerParams * params)
 | 
				
			|||||||
	cw_cfg_set_bstr16(params->conn->local_cfg,"capwap/ac-descriptor/software/version",wtpver);
 | 
						cw_cfg_set_bstr16(params->conn->local_cfg,"capwap/ac-descriptor/software/version",wtpver);
 | 
				
			||||||
	cw_cfg_set_int(params->conn->local_cfg,"capwap/ac-descriptor/software/vendor",CW_VENDOR_ID_CISCO);
 | 
						cw_cfg_set_int(params->conn->local_cfg,"capwap/ac-descriptor/software/vendor",CW_VENDOR_ID_CISCO);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(bstr16_len(wtpver)==4){
 | 
						update_msgset(params->msgset,wtpver);
 | 
				
			||||||
		uint32_t rv;
 | 
					 | 
				
			||||||
		rv = cw_get_dword(bstr16_data(wtpver));
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (rv >= 0x07030000){
 | 
					 | 
				
			||||||
			cw_msgset_add(params->msgset,messages73, handlers73);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (rv >= 0x07056600){
 | 
					 | 
				
			||||||
			cw_msgset_add(params->msgset,messages75, handlers75);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	free(wtpver);
 | 
						free(wtpver);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int postprocess_discovery(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int postprocess_discovery(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
				
			||||||
//static int postprocess_discovery(struct cw_Conn *conn)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (params->conn->role == CW_ROLE_AC ){
 | 
						if (params->conn->role == CW_ROLE_AC ){
 | 
				
			||||||
		set_ac_version(params);
 | 
							set_ac_version(params);
 | 
				
			||||||
		cw_detect_nat(params);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
				
			||||||
//static int postprocess_join_request(struct cw_Conn *conn)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (postprocess_join_request_parent!=NULL){
 | 
						if (postprocess_join_request_parent!=NULL){
 | 
				
			||||||
		postprocess_join_request_parent(params,elems_ptr,elems_len);
 | 
							postprocess_join_request_parent(params,elems_ptr,elems_len);
 | 
				
			||||||
 | 
							cw_detect_nat(params);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	postprocess_discovery(params,elems_ptr,elems_len);
 | 
						postprocess_discovery(params,elems_ptr,elems_len);
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
@ -2816,13 +3055,14 @@ static int preprocess_join_request(struct cw_Conn *conn)
 | 
				
			|||||||
	if (conn->role != CW_ROLE_WTP)
 | 
						if (conn->role != CW_ROLE_WTP)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	use_ac_version = cw_cfg_get_bool(conn->global_cfg,"cisco/wtp-use-ac-version",0);
 | 
						use_ac_version = cw_cfg_get_bool(conn->global_cfg,"mod/cisco/wtp-use-ac-version",0);
 | 
				
			||||||
	if (use_ac_version){
 | 
						if (use_ac_version){
 | 
				
			||||||
		ver = cw_cfg_get_bstr16(conn->remote_cfg,"capwap/ac-descriptor/software/version",NULL );
 | 
							ver = cw_cfg_get_bstr16(conn->remote_cfg,"capwap/ac-descriptor/software/version",NULL );
 | 
				
			||||||
		if (ver != NULL){
 | 
							if (ver != NULL){
 | 
				
			||||||
			cw_cfg_set_bstr16(conn->local_cfg,"capwap/wtp-descriptor/software/version",ver);
 | 
								cw_cfg_set_bstr16(conn->local_cfg,"capwap/wtp-descriptor/software/version",ver);
 | 
				
			||||||
			cw_format_version(verstr,bstr16_data(ver),bstr16_len(ver));
 | 
								cw_format_version(verstr,bstr16_data(ver),bstr16_len(ver));
 | 
				
			||||||
			cw_dbg(DBG_INFO, "Cisco WTP - Using AC's software version: %s", verstr);
 | 
								cw_dbg(DBG_MOD, "CISCO WTP - Using AC's software version: %s", verstr);
 | 
				
			||||||
 | 
								update_msgset(conn->msgset,ver);
 | 
				
			||||||
			free(ver);
 | 
								free(ver);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
@ -2830,33 +3070,5 @@ static int preprocess_join_request(struct cw_Conn *conn)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
//	stop();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (use_ac_version){
 | 
					 | 
				
			||||||
		ver = cw_ktv_get(conn->remote_cfg,"ac-descriptor/software/version", CW_TYPE_BSTR16);
 | 
					 | 
				
			||||||
		cw_ktv_replace(conn->local_cfg,"wtp-descriptor/software/version",CW_TYPE_BSTR16, NULL,
 | 
					 | 
				
			||||||
			ver->type->data(ver),ver->type->len(ver));
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
		cw_format_version(verstr,ver->type->data(ver),ver->type->len(ver));
 | 
					 | 
				
			||||||
		cw_dbg(DBG_INFO, "Cisco WTP - Using AC's software version: %s", verstr);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else{
 | 
					 | 
				
			||||||
		ver = cw_ktv_get(conn->local_cfg,"wtp-descriptor/software/version", CW_TYPE_BSTR16);
 | 
					 | 
				
			||||||
		cw_format_version(verstr,ver->type->data(ver),ver->type->len(ver));
 | 
					 | 
				
			||||||
		cw_dbg(DBG_INFO, "Cisco - WTP Using own software version: %s", verstr);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if(ver->type->len(ver)==4){
 | 
					 | 
				
			||||||
		uint32_t rv;
 | 
					 | 
				
			||||||
		rv = cw_get_dword(ver->type->data(ver));
 | 
					 | 
				
			||||||
		if (rv >= 0x07056600){
 | 
					 | 
				
			||||||
			cw_msgset_add(conn->msgset,messages75, handlers75);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/	
 | 
					 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -26,19 +26,19 @@ cw_dbg(DBG_X,"NUM RADIOS: %d",radios);
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
			, uint8_t * dst)
 | 
								, uint8_t * dst)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (! (params->msgdata->type & 1) ){
 | 
						if (! (params->msgdata->type & 1) ){
 | 
				
			||||||
		int start = params->msgset->header_len(handler);
 | 
							int start = params->msgset->header_len(handler);
 | 
				
			||||||
		cw_put_byte(dst+start,0);
 | 
							cw_set_byte(dst+start,0);
 | 
				
			||||||
		cw_put_dword(dst+start+1,7);
 | 
							cw_set_dword(dst+start+1,7);
 | 
				
			||||||
		return params->msgset->write_header(handler,dst,5);
 | 
							return params->msgset->write_header(handler,dst,5);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return cw_out_radio_generic(handler,params,dst);	
 | 
						return cw_out_radio_generic(handler,params,dst);	
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -29,15 +29,16 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_LWELEM_9				9
 | 
					#define CISCO_LWELEM_9				9
 | 
				
			||||||
#define CISCO_LWELEM_11				11
 | 
					#define CISCO_LWELEM_AP_MFP_CAP_SUBTYPE		11
 | 
				
			||||||
#define CISCO_LWELEM_14				14
 | 
					#define CISCO_LWELEM_AP_MFP_CONFIG_SUBTYPE	14
 | 
				
			||||||
#define CISCO_LWELEM_AP_USERNAME_PASSWORD	18
 | 
					#define CISCO_LWELEM_AP_USERNAME_PASSWORD	18
 | 
				
			||||||
#define LW_CISCO_MANAGER_IP_ADDR		19
 | 
					#define LW_CISCO_MANAGER_IP_ADDR		19
 | 
				
			||||||
#define CISCO_LWELEM_DISCOVERY_PROTOCOL		20
 | 
					#define CISCO_LWELEM_DISCOVERY_PROTOCOL		20
 | 
				
			||||||
#define CISCO_LWELEM_RADIO_MODULE_INFO		21
 | 
					#define CISCO_LWELEM_RADIO_MODULE_INFO		21
 | 
				
			||||||
#define CISCO_LWELEM_27				27
 | 
					#define CISCO_LWELEM_PHY_HT_CAP			27
 | 
				
			||||||
 | 
					//#define CISCO_LWELEM_STATION_CFG		28
 | 
				
			||||||
#define CISCO_LWELEM_28				28
 | 
					#define CISCO_LWELEM_28				28
 | 
				
			||||||
#define CISCO_LWELEM_29				29
 | 
					#define CISCO_LWELEM_PHY_HT_CONTROL		29
 | 
				
			||||||
#define CISCO_LWELEM_AC_IP_ADDR_WITH_INDEX	32
 | 
					#define CISCO_LWELEM_AC_IP_ADDR_WITH_INDEX	32
 | 
				
			||||||
#define CISCO_LWELEM_33				33
 | 
					#define CISCO_LWELEM_33				33
 | 
				
			||||||
#define CISCO_LWELEM_AP_ETHERNET_PORT_SUBTYPE	34
 | 
					#define CISCO_LWELEM_AP_ETHERNET_PORT_SUBTYPE	34
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3487
									
								
								src/mod/cisco/mod_cisco.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3487
									
								
								src/mod/cisco/mod_cisco.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,266 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "cw/cw.h"
 | 
					 | 
				
			||||||
#include "cw/mod.h"
 | 
					 | 
				
			||||||
#include "cw/log.h"
 | 
					 | 
				
			||||||
#include "cw/dbg.h"
 | 
					 | 
				
			||||||
#include "cw/dtls.h"
 | 
					 | 
				
			||||||
#include "cw/cfg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*#include "mod_cisco.h"*/
 | 
					 | 
				
			||||||
/*#include "../modload.h"*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw/vendors.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "mod_cisco.h"
 | 
					 | 
				
			||||||
#include "capwap_cisco.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
extern int cisco_register_actions80211_ac(struct cw_actiondef *def);
 | 
					 | 
				
			||||||
extern int cisco_register_actions_ac(struct cw_actiondef *def);
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*mbag_t cisco_config = NULL;*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct cw_Mod * capwap_mod = NULL;
 | 
					 | 
				
			||||||
static struct cw_Mod * capwap80211_mod = NULL; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (handler->proto == 0){
 | 
					 | 
				
			||||||
		if (handler->vendor)
 | 
					 | 
				
			||||||
			return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return  len + cw_put_elem_hdr(dst, handler->id, len);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	/* put the lwap elem header */
 | 
					 | 
				
			||||||
	lw_set_dword(dst + 10, handler->vendor);
 | 
					 | 
				
			||||||
	lw_set_word(dst + 14, handler->id);
 | 
					 | 
				
			||||||
	return len + 6 + cw_put_elem_vendor_hdr(dst, handler->vendor, 
 | 
					 | 
				
			||||||
		CISCO_ELEM_SPAM_VENDOR_SPECIFIC, len+6);	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int header_len(struct cw_ElemHandler * handler)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (handler->proto==0) 
 | 
					 | 
				
			||||||
		return handler->vendor ? 10 : 4;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return 16;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO,"CISCO: Register messages");
 | 
					 | 
				
			||||||
	switch (mode) {
 | 
					 | 
				
			||||||
		case CW_MOD_MODE_CAPWAP:
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			capwap_mod->register_messages(set, CW_MOD_MODE_CAPWAP);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			capwap80211_mod->register_messages(set, CW_MOD_MODE_BINDINGS);
 | 
					 | 
				
			||||||
			cisco_register_msg_set(set,CW_MOD_MODE_CAPWAP);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			set->write_header = write_header;
 | 
					 | 
				
			||||||
		      	set->header_len = header_len;	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/*	cw_dbg(DBG_MOD,"Cisco: loading cisco message set");*/
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
/*			cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messages", 7);*/
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		case CW_MOD_MODE_BINDINGS:
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO,"CISCO: Done register messages");
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
static void errfunc(cfg_t *cfg, const char *fmt, va_list ap){
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (cfg && cfg->filename && cfg->line)
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "MOD Cisco cfg file in %s:%d: ", 
 | 
					 | 
				
			||||||
			cfg->filename, cfg->line);
 | 
					 | 
				
			||||||
	else if (cfg && cfg->filename)
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "MOD Cisco cfg file in %s:", cfg->filename);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int init(struct cw_Mod *mod, cw_Cfg_t * global_cfg, int role)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
/*	uint8_t * str;*/
 | 
					 | 
				
			||||||
	static char * hardware_version; /*strdup(".x01000001");*/
 | 
					 | 
				
			||||||
	static char * software_version; /* = NULL; */
 | 
					 | 
				
			||||||
/*	cfg_t *cfg;*/
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	int rc = 1;
 | 
					 | 
				
			||||||
/*	cfg_opt_t opts[] = {
 | 
					 | 
				
			||||||
		CFG_SIMPLE_STR("hardware_version", &hardware_version),
 | 
					 | 
				
			||||||
		CFG_SIMPLE_STR("software_version",&software_version),
 | 
					 | 
				
			||||||
		CFG_END()
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO, "CISCO: Initialiazing mod_cisco ...");
 | 
					 | 
				
			||||||
	cw_dbg(DBG_MOD, "CISCO: Loading base module: capwap");
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	capwap_mod = cw_mod_load("capwap",global_cfg,role);
 | 
					 | 
				
			||||||
	if (capwap_mod == NULL){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	capwap80211_mod = cw_mod_load("capwap80211", global_cfg,role);
 | 
					 | 
				
			||||||
	if (capwap_mod == NULL){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap80211");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	/*cisco_config = mbag_create();*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
	cfg = cfg_init(opts, CFGF_NONE);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	cfg_set_error_function(cfg, errfunc);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	char *filename = "cisco.conf";
 | 
					 | 
				
			||||||
	FILE * f = fopen(filename,"r");
 | 
					 | 
				
			||||||
	if (f){
 | 
					 | 
				
			||||||
		fclose(f);
 | 
					 | 
				
			||||||
		if (cfg_parse(cfg, filename)){
 | 
					 | 
				
			||||||
			rc = 0;
 | 
					 | 
				
			||||||
			goto errX;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	
 | 
					 | 
				
			||||||
	str = bstr_create_from_cfgstr(hardware_version);
 | 
					 | 
				
			||||||
	mbag_set_bstrv(cisco_config, CW_ITEM_AC_HARDWARE_VERSION, 
 | 
					 | 
				
			||||||
		CW_VENDOR_ID_CISCO, 
 | 
					 | 
				
			||||||
		bstr_data(str),bstr_len(str)
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
	free(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (software_version){
 | 
					 | 
				
			||||||
		str = bstr_create_from_cfgstr(software_version);
 | 
					 | 
				
			||||||
		mbag_set_bstrv(cisco_config, CW_ITEM_AC_SOFTWARE_VERSION, 
 | 
					 | 
				
			||||||
			CW_VENDOR_ID_CISCO, 
 | 
					 | 
				
			||||||
			bstr_data(str),bstr_len(str)
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		free(str);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
/*errX:*/
 | 
					 | 
				
			||||||
	if (hardware_version)
 | 
					 | 
				
			||||||
		free (hardware_version);
 | 
					 | 
				
			||||||
	if (software_version)
 | 
					 | 
				
			||||||
		free(software_version);
 | 
					 | 
				
			||||||
	return rc;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int detect(struct cw_Conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
 | 
					 | 
				
			||||||
		  struct sockaddr *from, int mode)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int offset = cw_get_hdr_msg_offset(rawmsg);
 | 
					 | 
				
			||||||
	const uint8_t *msg_ptr = rawmsg + offset;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	const uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
 | 
					 | 
				
			||||||
	const uint8_t *elem;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* To detect a Cisco AP we look for any vendor 
 | 
					 | 
				
			||||||
	 * specific payload Cisco identifier */
 | 
					 | 
				
			||||||
	cw_foreach_elem(elem, elems_ptr, elems_len) {
 | 
					 | 
				
			||||||
		int id = cw_get_elem_id(elem);
 | 
					 | 
				
			||||||
		if (id == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
 | 
					 | 
				
			||||||
			uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
 | 
					 | 
				
			||||||
			if (vendor_id == CW_VENDOR_ID_CISCO) {
 | 
					 | 
				
			||||||
/*				//              conn->actions = &actions;*/
 | 
					 | 
				
			||||||
				if (mode == CW_MOD_MODE_CAPWAP) {
 | 
					 | 
				
			||||||
					cw_dbg(DBG_MOD, "CISCO capwap detected: yes");
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					cw_dbg(DBG_MOD, "CISCO bindings detected: yes");
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				return 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (mode == CW_MOD_MODE_CAPWAP) {
 | 
					 | 
				
			||||||
		cw_dbg(DBG_MOD, "CISCO capwap detected: no");
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		cw_dbg(DBG_MOD, "CISCO bindings detected: no");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
static struct cw_Mod capwap_ac = {
 | 
					 | 
				
			||||||
	.name = "cisco",
 | 
					 | 
				
			||||||
	.init = init,
 | 
					 | 
				
			||||||
	.detect = detect,
 | 
					 | 
				
			||||||
//	.register_actions = register_actions,
 | 
					 | 
				
			||||||
	.register_messages = register_messages
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int static setup_cfg(struct cw_Conn  * conn)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int security;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	conn->write_header=write_header;
 | 
					 | 
				
			||||||
//	conn->header_len=header_len;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	security = cw_setup_dtls(conn,conn->global_cfg,"cisco",CAPWAP_CIPHER);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (conn->role == CW_ROLE_AC){
 | 
					 | 
				
			||||||
		cw_cfg_set_int(conn->local_cfg,"capwap/ac-descriptor/security",security);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//		if (conn->default_cfg==NULL){
 | 
					 | 
				
			||||||
//			conn->default_cfg=cw_cfg_create();
 | 
					 | 
				
			||||||
//		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct cw_Mod mod_cisco = {
 | 
					 | 
				
			||||||
	"cisco",			/* name */
 | 
					 | 
				
			||||||
	init,				/* init */
 | 
					 | 
				
			||||||
	detect,				/* detect */
 | 
					 | 
				
			||||||
	register_messages,		/* register_messages */
 | 
					 | 
				
			||||||
	NULL,				/* dll_handle */
 | 
					 | 
				
			||||||
	NULL,				/* data */
 | 
					 | 
				
			||||||
	setup_cfg			/* setup_cfg */
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
struct cw_Mod *mod_cisco()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return &cisco_data;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user