moved local_cfg, remote_cfg ... to cw_ElemData struct

shell
7u83 6 months ago
parent 6ac1c87b2f
commit b894c00a7e
  1. 1
      src/Defs.mak
  2. 9
      src/ac/Makefile
  3. 4
      src/ac/ac.conf
  4. 3
      src/ac/ac.h
  5. 1
      src/ac/ac_global.c
  6. 4
      src/ac/ac_main.c
  7. 5
      src/ac/conf.c
  8. 14
      src/ac/config.ktv
  9. 4
      src/ac/dataman.c
  10. 2
      src/ac/db.h
  11. 6
      src/ac/discovery_cache.c
  12. 1
      src/ac/wtpman.c
  13. 11
      src/cw/Makefile
  14. 2
      src/cw/conn.h
  15. 4
      src/cw/conn_create.c
  16. 3
      src/cw/conn_create_noq.c
  17. 12
      src/cw/conn_process_packet.c
  18. 2
      src/cw/conn_send_msg.c
  19. 2
      src/cw/cw.h
  20. 2
      src/cw/cw_in_generic.c
  21. 2
      src/cw/cw_in_generic_struct.c
  22. 2
      src/cw/cw_in_generic_with_index.c
  23. 2
      src/cw/cw_in_idx_generic.c
  24. 2
      src/cw/cw_in_idx_generic_struct.c
  25. 2
      src/cw/cw_in_radio_generic_struct.c
  26. 3
      src/cw/cw_ktv_add.c
  27. 10
      src/cw/cw_out_generic.c
  28. 10
      src/cw/cw_out_generic_indexed_enum.c
  29. 10
      src/cw/cw_out_generic_struct.c
  30. 6
      src/cw/cw_out_generic_with_index.c
  31. 8
      src/cw/cw_out_idx_generic_struct.c
  32. 4
      src/cw/cw_out_radio_generic.c
  33. 24
      src/cw/cw_out_radio_generic_struct.c
  34. 6
      src/cw/cw_process_element.c
  35. 16
      src/cw/cw_put_msg.c
  36. 2
      src/cw/cw_read_ac_descriptor.c
  37. 2
      src/cw/cw_read_radio_generic.c
  38. 2
      src/cw/cw_read_wtp_descriptor.c
  39. 8
      src/cw/cw_write_header.c
  40. 13
      src/cw/cw_write_radio_element.c
  41. 4
      src/cw/dtls_bio.c
  42. 2
      src/cw/dtls_openssl.h
  43. 2
      src/cw/ktv.h
  44. 2
      src/cw/msgset.c
  45. 7
      src/cw/msgset.h
  46. 2
      src/cw/netconn.c
  47. 4
      src/cw/send.c
  48. 3
      src/lib.mk
  49. 7
      src/mod/Makefile
  50. 1
      src/mod/capwap/Makefile
  51. 1
      src/mod/capwap/capwap_actions_ac.c
  52. 2
      src/mod/capwap/capwap_in_ac_descriptor.c
  53. 8
      src/mod/capwap/capwap_in_capwap_control_ip_address.c
  54. 2
      src/mod/capwap/capwap_in_mtu_discovery_padding.c
  55. 4
      src/mod/capwap/capwap_in_vendor_specific_payload.c
  56. 3
      src/mod/capwap/capwap_in_wtp_board_data.c
  57. 3
      src/mod/capwap/capwap_in_wtp_descriptor.c
  58. 10
      src/mod/capwap/capwap_out_ac_descriptor.c
  59. 6
      src/mod/capwap/capwap_out_capwap_control_ip_address.c
  60. 3
      src/mod/capwap/capwap_out_capwap_local_ip_address.c
  61. 3
      src/mod/capwap/capwap_out_wtp_board_data.c
  62. 15
      src/mod/capwap/capwap_out_wtp_descriptor.c
  63. 3
      src/mod/cisco/capwap_cisco.h
  64. 46
      src/mod/cisco/cisco_actions_ac.c
  65. 2
      src/mod/cisco/cisco_in_ac_descriptor.c
  66. 4
      src/mod/cisco/cisco_in_spam_vendor_specific.c
  67. 2
      src/mod/cisco/cisco_in_wtp_descriptor.c
  68. 10
      src/mod/cisco/cisco_out_ac_descriptor.c
  69. 2
      src/mod/cisco/cisco_out_ap_timesync.c
  70. 4
      src/mod/cisco/cisco_out_capwap_local_ip_address.c
  71. 4
      src/mod/cisco/cisco_out_lw_path_mtu.c
  72. 4
      src/mod/cisco/cisco_out_radio_generic.c
  73. 10
      src/mod/cisco/cisco_out_wtp_descriptor.c
  74. 1
      src/mod/cisco/lwapp_cisco.h
  75. 1
      src/mod/cisco/mod_cisco.h
  76. 147
      src/wtp/cisco.ktv
  77. 2
      src/wtp/configure.c
  78. 8
      src/wtp/run.c
  79. 3
      src/wtp/wtp_main.c
  80. 10
      ssl/mkcert.sh
  81. 2
      ssl/mkciscoimport.sh
  82. 10
      ssl/mkrootca.sh
  83. 2
      ssl/openssl-crt.cnf
  84. 2
      ssl/openssl-int.cnf
  85. 2
      ssl/openssl.cnf
  86. 2
      tools/indent.sh

@ -3,6 +3,7 @@
ARCH!=uname -m
KERNEL!=uname -s
-include LocalDefs.mak
#.endif

@ -12,21 +12,22 @@ OBJS = \
shell.o\
PRG=actube
LIBPATH=-L../../lib/$(ARCH)/ -L/usr/local/lib -L/usr/lib
LIBPATH=-L../../lib/Linux/$(ARCH)/ -L/usr/local/lib -L/usr/lib
LIBS+=-lmavl
LIBS+=-lcw
LIBS+=-lrt
LIBS+=-lpthread
LIBS+=-lconfuse
LIBS+=-lsqlite3
LIBS+=-lc
LIBS+=-lnettle
LIBS+=$(OPENSSL_LIBS)
INCL_DIRS=-I../ -I/usr/local/include -I./
INCL_DIRS=-I../ -I/usr/local/include -I./ -I/home/tube/v/rsrch/libmavl/
#FLAGS=-DWITH_IPV6 -DWITH_OPENSSL -DSYS_ARCH="$(ARCH)" -DSYS_ARCH="XXX"
FLAGS=-DWITH_IPV6 -DWITH_OPENSSL -DSYS_ARCH='"$(ARCH)"'
FLAGS=-DWITH_IPV6 -DUSE_OPENSSL -DSYS_ARCH='"$(ARCH)"'
.c.o:
@echo " $(CC) "$<

@ -184,7 +184,7 @@ ssl_key="../../ssl/certs/ac-cisco.key"
# SSL certificate that will be sent to the client
#
# Default:
ssl_cert="../../ssl/certs/ac-cisco.pem"
ssl_cert="../../ssl/certs/ac-xcisco.pem"
# dtls_verify_peer
@ -242,4 +242,4 @@ ssl_cert="../../ssl/certs/ac-cisco.pem"
mods = { cisco, capwap, capwap80211 }
#, capwap80211 }
mods_dir = ../../lib
mods_dir = ../../lib/Linux/x86_64/

@ -1,7 +1,8 @@
#ifndef __ACTUBE_AC_H
#define __ACTUBE_AC_H
#include "cw/mavl.h"
#include "mavl.h"
#include "cw/mavltypes.h"
extern mavl_t actube_global_cfg;

@ -13,6 +13,7 @@
#include "wtpman.h"
#include "discovery_cache.h"
#include "cw/mavltypes.h"
mavl_t actube_global_cfg;

@ -157,6 +157,7 @@ int mycmp (void *e1, void *e2)
return 0;
}
/*
void mavl_walk (struct mavlnode * node)
{
struct mykv * kv;
@ -175,6 +176,7 @@ void mavl_walk (struct mavlnode * node)
mavl_walk (node->right);
}
*/
/*
int stcmp (const void * sa1, const void *sa2)
@ -246,7 +248,7 @@ int main (int argc, char *argv[])
/* create types tree with default types */
types_tree = cw_ktv_create_types_tree();
for (ti=CW_KTV_STD_TYPES;*ti;ti++){
mavl_add_ptr(types_tree,*ti);
mavl_insert_ptr(types_tree,*ti);
}
global_cfg = cw_ktv_create();

@ -37,6 +37,8 @@
#include "conf.h"
#include "ac.h"
#include "cw/mavltypes.h"
uint8_t conf_macaddress[12];
uint8_t conf_macaddress_len = 0;
@ -393,7 +395,8 @@ int init_bcast_addrs()
if (!conf_ipv4)
return 1;
t = mavl_create_str();
/*t = mavl_create_ptr(); */
t = mavl_create_ptr(mavl_cmpstr,mavl_freeptr);
if (t==NULL)
return 0;

@ -29,7 +29,7 @@ ac-descriptor/software/vendor :Dword: 4232704
ac-descriptor/software/version :Bstr16: .x07036500
ac-descriptor/station-limit :Word: 1000
ac-descriptor/stations :Word: 0
capwap-control-ip-address/address.0 :IPAddress: 192.168.0.29
capwap-control-ip-address/address.0 :IPAddress: 192.168.0.14
#capwap-control-ip-address/address.0 :IPAddress: 192.168.42.51
capwap-control-ip-address/wtps.0 :Word: 2
cisco/mwar-type :Byte: 0
@ -37,24 +37,28 @@ maximum-message-length :Word: 4096
radio/0/wtp-radio-information :Dword: 7
result-code :Dword: 0
cisco/ap-telnet-ssh/ssh :Bool: true
cisco/ap-telnet-ssh/telnet :Bool: true
ac-name:Bstr16:"X1"
#capwap-control-ip-address/address.0:IPAddress:1192.168.0.14
capwap-control-ip-address/address.0:IPAddress:192.168.0.29
capwap-control-ip-address/address.0:IPAddress:192.168.0.14
#capwap-control-ip-address/address.0:IPAddress:192.168.0.131
#capwap-control-ip-address/address.1:IPAddress:2a00:c1a0:48c6:4a00:9965:1b6e:aca3:1398
capwap-control-ip-address/wtps.0:Word:0
#capwap-control-ip-address/wtps.1:Word:11
#cisco/ssl-keyfile:Str:"../../ssl/certs/ac.key"
#cisco/ssl-certfile:Str:"../../ssl/certs/ac.crt"
#cisco/ssl-keyfile:Str:"../../ssl/certs/ac-cisco.key"
#cisco/ssl-certfile:Str:"../../ssl/certs/ac-cisco.pem"
#cisco/ssl-keyfile:Str:"../../ssl/certs/int-ca.key"
#cisco/ssl-certfile:Str:"../../ssl/certs/int-ca.crt"
cisco/ssl-keyfile:Str:"../../ssl/intermediate-ca/int-ca.key"
cisco/ssl-certfile:Str:"../../ssl/intermediate-ca/int-ca.crt"
#cisco/ssl-keyfile:Str:"../../ssl/intermediate-ca/cisco-ac-int-ca.key"
#cisco/ssl-certfile:Str:"../../ssl/intermediate-ca/cisco-ac-int-ca.crt"
cisco/ssl-cipher:Str:DEFAULT:!ECDH
#cisco/ssl-cipher:Str:+DHE-RSA:+AES-256-CBC:+AES-128-CBC:+SHA1
cisco/ssl-dhbits:Word:2048
@ -107,7 +111,7 @@ radio.1/cisco/multi-domain-capability/max-tx-power-level :Word: 20
radio.1/cisco/multi-domain-capability/number-of-channels :Word: 4
radio.1/cisco/multi-domain-capability/reserved :Byte: 1
radio.1/cisco/wtp-radio-config/beacon-period :Word: 100
radio.1/cisco/wtp-radio-config/bss-id :Bstr16: .x04fe7f499b90
radio.1/cisco/wtp-radio-config/bss-id :Bstr16: .x05fe7f499b90
radio.1/cisco/wtp-radio-config/cfg-period :Byte: 4
radio.1/cisco/wtp-radio-config/cfg-type :Byte: 1
radio.1/cisco/wtp-radio-config/cfp-maximum-duration :Word: 60

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "cw/mavl.h"
#include "mavl.h"
#include "cw/sock.h"
#include "cw/timer.h"
#include "cw/cw.h"
@ -86,7 +86,7 @@ struct dataman *dataman_list_add(struct dataman *dm)
{
cw_dbg(DBG_X,"Adding dataman %p\n",dm);
return mavl_add(dataman_list, dm,NULL);
return mavl_insert(dataman_list, dm,NULL);
}

@ -1,7 +1,7 @@
#ifndef CW_MAVL_H
#define CW_MAVL_H
#include "cw/mavl.h"
#include "mavl.h"
extern void db_ping();
extern void db_ping_wtp(const char *wtpid,const char *acid);

@ -2,7 +2,7 @@
#include "cw/sock.h"
#include "cw/mlist.h"
#include "cw/mavl.h"
#include "mavl.h"
#include "cw/mod.h"
#include "discovery_cache.h"
@ -125,8 +125,8 @@ void discovery_cache_add(struct cw_DiscoveryCache *cache,
cache->ctrhi++;
}
mavl_add_ptr(cache->byaddr,cur);
mavl_add_ptr(cache->byaddrp,cur);
mavl_insert_ptr(cache->byaddr,cur);
mavl_insert_ptr(cache->byaddrp,cur);
cache->qpos++;
if (cache->qpos>=cache->len)

@ -148,6 +148,7 @@ static int wtpman_dtls_setup(void *arg)
cw_dbg(DBG_DTLS, "DTLS session established with %s, %s",
sock_addr2str_p(&wtpman->conn->addr,sock_buf), dtls_get_cipher(wtpman->conn,cipherstr));
return 1;
}

@ -1,8 +1,9 @@
include ../Defs.mak
MFDEPS=../Defs.mak ../LocalDefs.mak
CWSRC=\
cw_write_header.c\
cw_check_missing_mand.c\
cw_clock_lap.c\
cw_dbg_elem.c\
@ -63,6 +64,7 @@ CWSRC=\
cw_strlist_get_id.c\
cw_strlist_get_str.c\
cw_type_bstr16.c\
cw_type_bwstr.c\
cw_type_byte.c\
cw_type_bool.c\
cw_type_str.c\
@ -166,7 +168,6 @@ MISCSRC=\
bstr_create.c\
bstr_create_from_str.c\
bstr_replace.c\
bstrv_create.c\
capwap_inline.c\
capwap_strings_board.c\
capwap_strings_elem80211.c\
@ -182,6 +183,7 @@ MISCSRC=\
connlist.c\
conn_prepare_image_data_request.c\
conn_process_packet.c\
cw_decode_msg.c \
conn_q_add_packet.c\
conn_q_get_packet.c\
conn_q_wait_packet.c\
@ -218,11 +220,10 @@ MAVLSRC=\
mavl_get_ptr.c\
mavl_insert_ptr.c\
mavl_replace.c\
mavl_merge.c\
mavliter_get_ptr.c\
mavl_cmpstr.c\
mavl_freeptr.c \
mavl_merge.c\
DTLSSRC += dtls_openssl.c \
@ -256,7 +257,7 @@ SNAME := $(LIBARCHDIR)/libcw.a
DNAME := $(LIBARCHDIR)/libcw.so
CFLAGS+=-fPIC -DUSE_OPENSSL -I../contrib/openssl-1.1.1f/include/ -O0
CFLAGS+=-g -I/home/tube/v/rsrch/libmavl
CFLAGS+=-g
all: $(SNAME) $(DNAME)
static: $(SNAME)

@ -203,7 +203,7 @@ struct conn {
int dtls_verify_peer;
int dtls_mtu;
uint8_t dtls_buffer[2048];
uint8_t dtls_buffer[4096];
int dtls_buffer_len;
int dtls_buffer_pos;

@ -90,7 +90,7 @@ struct conn * conn_create(int sock, struct sockaddr * addr, int qsize)
/* conn->send_data_packet = conn_send_data_packet;*/
conn->last_seqnum_received=-1;
conn->mtu=1500;
conn->mtu=500;
conn->cur_packet=0;
@ -102,7 +102,7 @@ struct conn * conn_create(int sock, struct sockaddr * addr, int qsize)
/* conn->write_data = conn->send_data_packet; */
conn->dtls_mtu = 1500;
conn->dtls_mtu = 500;
return conn;
}

@ -67,7 +67,8 @@ struct conn * conn_create_noq(int sock, struct sockaddr * addr)
/* misc settings */
conn->last_seqnum_received=-1;
conn->mtu=1500;
conn->mtu=480;
conn->dtls_mtu=500;
conn->cur_packet=0;

@ -333,7 +333,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
ui = message->states;
for (ui=message->states; ui->state; ui++){
printf("Comparing %d and %d\n", conn->capwap_state, ui->state);
/* printf("Comparing %d and %d\n", conn->capwap_state, ui->state);*/
if(ui->state==conn->capwap_state){
break;
}
@ -398,7 +398,15 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
params.conn=conn;
/* params.conn=conn;*/
params.local_cfg=conn->local_cfg;
params.remote_cfg=conn->remote_cfg;
params.default_cfg=conn->default_cfg;
params.global_cfg=conn->global_cfg;
params.msgset=conn->msgset;
params.from=from;
params.msgdata=message;
params.mand_found=mand_found;

@ -30,7 +30,7 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
hlen = cw_get_hdr_hlen(rawmsg)*4;
mtu = conn->mtu;
mtu = 440;
mtu = 9440;
mtu = mtu >> 3;
mtu = mtu << 3;

@ -547,6 +547,8 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout);
char *cw_strdup(const char *s);
int cw_stricmp(char const *a, char const *b);
int cw_write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len);
int cw_header_len(struct cw_ElemHandler * handler);
/**
*@}

@ -14,7 +14,7 @@ int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams *
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
}
result = cw_ktv_add(params->conn->remote_cfg, handler->key,
result = cw_ktv_add(params->remote_cfg, handler->key,
handler->type,NULL, elem_data,elem_len);
params->elem=result;

@ -27,7 +27,7 @@ int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
}
cw_ktv_read_struct(params->conn->remote_cfg,handler->type,key,elem_data,elem_len);
cw_ktv_read_struct(params->remote_cfg,handler->type,key,elem_data,elem_len);
return CAPWAP_RESULT_SUCCESS;
}

@ -9,6 +9,6 @@ int cw_in_generic_with_index(struct cw_ElemHandler *eh,
idx = cw_get_byte(data);
sprintf(key,"%s.%d",eh->key,idx);
cw_ktv_add(params->conn->remote_cfg,key,eh->type,NULL,data+1,len-1);
cw_ktv_add(params->remote_cfg,key,eh->type,NULL,data+1,len-1);
return 1;
}

@ -16,7 +16,7 @@ int cw_in_idx_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerPara
idx=cw_get_byte(elem_data);
sprintf(key,handler->key,idx);
result = cw_ktv_add(params->conn->remote_cfg, key,
result = cw_ktv_add(params->remote_cfg, key,
handler->type, NULL, elem_data+1,elem_len-1);
params->elem=result;

@ -19,7 +19,7 @@ int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHand
idx = cw_get_byte(elem_data);
sprintf(key, handler->key, idx);
cw_ktv_read_struct(params->conn->remote_cfg,handler->type,key,elem_data+1,elem_len-1);
cw_ktv_read_struct(params->remote_cfg,handler->type,key,elem_data+1,elem_len-1);
return CAPWAP_RESULT_SUCCESS;
}

@ -19,7 +19,7 @@ int cw_in_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHa
radio = cw_get_byte(elem_data);
sprintf(key,"radio.%d/%s",radio,handler->key);
cw_ktv_read_struct(params->conn->remote_cfg,handler->type,key,elem_data+1,elem_len-1);
cw_ktv_read_struct(params->remote_cfg,handler->type,key,elem_data+1,elem_len-1);
/*params->elem=result;*/

@ -10,7 +10,6 @@ cw_KTV_t * cw_ktv_add(mavl_t kvtstore, const char *key, const struct cw_Type *ty
{
cw_KTV_t mdata, *mresult;
int exists;
printf("KTV ADD: %s\n",key);
mdata.key=cw_strdup(key);
mdata.valguard=valguard;
@ -30,8 +29,6 @@ printf("KTV ADD: %s\n",key);
return NULL;
}
printf("MAVLCOUNT: %d - %s\n",kvtstore->count, mdata.key);
mavl_del(kvtstore,&mdata);
mresult = mavl_insert(kvtstore, &mdata, &exists);
if (exists){

@ -19,7 +19,7 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
/* search.key=(char*)handler->key;
elem = mavl_get(params->conn->local_cfg, &search);
*/
elem = cw_ktv_get(params->conn->local_cfg,handler->key,NULL);
elem = cw_ktv_get(params->local_cfg,handler->key,NULL);
/* if (elem == NULL && params->conn->default_cfg !=NULL)
elem = mavl_get(params->conn->default_cfg, &search);
@ -49,7 +49,7 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
/* Size for msg elem header depends on
vendor specific payload */
/* start = handler->vendor ? 10 : 4; */
start = params->conn->header_len(handler);
start = cw_header_len(handler);
if (cw_ktv_cast(elem,handler->type)==NULL){
cw_log(LOG_ERR,"Can't put element '%s'- can't cast from %s to %s for key: %s", handler->name,
@ -67,9 +67,11 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
l = len + cw_put_elem_hdr(dst, handler->id, len); */
l = params->conn->write_header(handler,dst,len);
l = cw_write_header(handler,dst,len);
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,handler,dst,l);
/* cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);*/
return l;
}

@ -22,10 +22,10 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
for(i=0; e[i].name!=NULL; i++) {
sprintf(key,"%s/%s",handler->key,e[i].name);
result = cw_ktv_base_exists(params->conn->local_cfg,key);
result = cw_ktv_base_exists(params->local_cfg,key);
if (result==NULL)
continue;
start = params->conn->header_len(handler);
start = cw_header_len(handler);
len = 0;
if (ie->idxpos==0)
len = 1;
@ -33,7 +33,7 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
if (e[i].fun_out==NULL)
len += result->type->put(result,ob+start+len);
else
len += cw_ktv_write_struct(params->conn->local_cfg,
len += cw_ktv_write_struct(params->local_cfg,
NULL,e[i].type,key,ob+start+len);
/* thandler.type=e[i].type;
@ -44,7 +44,7 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
if (ie->idxpos==len)
len++;
ob += params->conn->write_header(handler,ob,len);
ob += cw_write_header(handler,ob,len);
@ -52,4 +52,4 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
return ob-dst;
}
}

@ -17,7 +17,7 @@ int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandler
}
search.key = (char*)handler->key;
result = mavl_get_first(params->conn->local_cfg,&search);
result = mavl_get_first(params->local_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);
@ -30,12 +30,12 @@ int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandler
return 0;
}
start = params->conn->header_len(handler);
start = cw_header_len(handler);
len = cw_ktv_write_struct(params->conn->local_cfg,
params->conn->default_cfg,
len = cw_ktv_write_struct(params->local_cfg,
params->default_cfg,
handler->type,handler->key,dst+start);
return params->conn->write_header(handler,dst,len);
return cw_write_header(handler,dst,len);
}

@ -18,18 +18,18 @@ int cw_out_generic_with_index(struct cw_ElemHandler * eh,
do {
sprintf(key,"%s.%d",eh->key,idx);
search.key=key;
result = mavl_get_first(params->conn->local_cfg,&search);
result = mavl_get_first(params->local_cfg,&search);
if (result==NULL)
break;
if (strncmp(result->key,key,strlen(key))!=0)
break;
start = params->conn->header_len(eh);
start = cw_header_len(eh);
len = cw_put_byte(ob+start,idx);
len += result->type->put(result,ob+start+len);
ob += params->conn->write_header(eh,ob,len);
ob += cw_write_header(eh,ob,len);
idx++;

@ -24,7 +24,7 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
sprintf(key,handler->key,i);
search.key=key;
/*elem = mavl_get(params->conn->local_cfg, &search);*/
elem = mavl_get_first(params->conn->local_cfg,&search);
elem = mavl_get_first(params->local_cfg,&search);
if(elem != NULL){
printf("Elem key: %s\n",elem->key);
}
@ -40,12 +40,12 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
printf("Here we are '%s'! --> %d\n",key,idx);
len =0;
start = mdst + params->conn->header_len(handler);
start = mdst + cw_header_len(handler);
len += cw_put_byte(start+len,idx);
len += cw_ktv_write_struct(params->conn->local_cfg,NULL, handler->type,key,start+len);
len += cw_ktv_write_struct(params->local_cfg,NULL, handler->type,key,start+len);
mdst += params->conn->write_header(handler,mdst,len);
mdst += cw_write_header(handler,mdst,len);
i=idx+1;

@ -20,11 +20,11 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
idx++;
}
*/
radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0);
radios = cw_ktv_get_byte(params->local_cfg,"wtp-descriptor/max-radios",0);
for(i=0;i<radios;i++){
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,NULL,params->msgdata->type,handler,dst,l);
len+=l;
}
return len;

@ -14,19 +14,19 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
cdst = dst;
offset = params->conn->header_len(handler);
offset = cw_header_len(handler);
i=-1;
while(1){
char basekey[CW_KTV_MAX_KEY_LEN];
cw_KTV_t * result;
i = cw_ktv_idx_get_next(params->conn->local_cfg,"radio",i+1);
i = cw_ktv_idx_get_next(params->local_cfg,"radio",i+1);
if (i==-1)
break;
sprintf(basekey,"radio.%d/%s",i,handler->key);
result = cw_ktv_base_exists(params->conn->local_cfg,basekey);
result = cw_ktv_base_exists(params->local_cfg,basekey);
if (result == NULL){
continue;
}
@ -34,10 +34,10 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
l=0;
l+=cw_put_byte(cdst+offset+l,i);
l+= cw_ktv_write_struct(params->conn->local_cfg,NULL, handler->type,basekey,cdst+offset+l);
l+= cw_ktv_write_struct(params->local_cfg,NULL, handler->type,basekey,cdst+offset+l);
cdst+=params->conn->write_header(handler,cdst,l);
cdst+=cw_write_header(handler,cdst,l);
}
return cdst-dst;
}
@ -57,21 +57,21 @@ int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParam
if (sl==NULL){
cw_KTV_t * result;
sprintf(key,"%s/%s",current,next);
result = cw_ktv_base_exists(params->conn->local_cfg,key);
result = cw_ktv_base_exists(params->local_cfg,key);
if (result != NULL){
int offset;
int i,l;
offset = params->conn->header_len(handler);
offset = cw_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->conn->local_cfg,params->conn->default_cfg,
l= cw_ktv_write_struct(params->local_cfg,params->default_cfg,
handler->type,key,dst+offset);
printf("Write struct len %i\n",l);
l=params->conn->write_header(handler,dst,l);
l=cw_write_header(handler,dst,l);
printf("header wr len %d\n",l);
if (handler->patch){
handler->patch(dst+offset,stack);
@ -91,18 +91,18 @@ int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParam
printf("Here we are %s\n",key);
cw_dbg_ktv_dump(params->conn->local_cfg,DBG_INFO,"start"," ", "end" );
cw_dbg_ktv_dump(params->local_cfg,DBG_INFO,"start"," ", "end" );
i=-1;
while(1){
char basekey[CW_KTV_MAX_KEY_LEN];
cw_KTV_t * result;
i = cw_ktv_idx_get_next(params->conn->local_cfg,key,i+1);
i = cw_ktv_idx_get_next(params->local_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->conn->local_cfg,basekey);
result = cw_ktv_base_exists(params->local_cfg,basekey);
if (result == NULL){
continue;
}

@ -23,7 +23,7 @@ int cw_process_element(struct cw_ElemHandlerParams *params, int proto, int vendo
params->elem=NULL;
/* try to retrieve a handler for this message element */
handler = cw_msgset_get_elemhandler(params->conn->msgset,proto, vendor, elem_id);
handler = cw_msgset_get_elemhandler(params->msgset,proto, vendor, elem_id);
if (!handler) {
cw_dbg(DBG_ELEM_ERR, "Unrecognized message element: %d, ignoring",
@ -65,7 +65,9 @@ int cw_process_element(struct cw_ElemHandlerParams *params, int proto, int vendo
return -1;
}
cw_dbg_elem(DBG_ELEM_IN, params->conn, params->msgdata->type, handler,
/*cw_dbg_elem(DBG_ELEM_IN, params->conn, params->msgdata->type, handler,
data,len);*/
cw_dbg_elem(DBG_ELEM_IN, NULL, params->msgdata->type, handler,
data,len);
if (handler->get == NULL){

@ -77,7 +77,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
data = mlistelem_dataptr(elem);
handler = cw_msgset_get_elemhandler(conn->msgset,data->proto,data->vendor,data->id);
/* printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name);*/
printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name);
if (handler==NULL){
cw_log(LOG_ERR,"Can't put message element %d %d %d, no handler defined.",
data->proto,data->vendor,data->id);
@ -94,7 +94,15 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
continue;
}
params.conn=conn;
/* params.conn=conn;*/
params.local_cfg=conn->local_cfg;
params.remote_cfg=conn->remote_cfg;
params.default_cfg=conn->default_cfg;
params.global_cfg=conn->global_cfg;
params.msgset=conn->msgset;
params.elemdata = data;
params.elem=NULL;
params.msgdata=msg;
@ -107,10 +115,10 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
}
l = handler->put(handler,&params,dst+len);
/* if(l>0)
cw_dbg_elem(DBG_ELEM_OUT,conn,type,handler,dst+len,l);
if (strlen(details)){
* if (strlen(details)){
cw_dbg(DBG_ELEM_DETAIL," %s",params.debug_details);
}
*/ len += l;

@ -32,7 +32,7 @@ int cw_read_ac_descriptor(mavl_t store,
struct cw_DescriptorSubelemDef *allowed)
{
cw_ktv_read_struct(params->conn->remote_cfg,acstatus,eh->key,data,len);
cw_ktv_read_struct(params->remote_cfg,acstatus,eh->key,data,len);
if (!allowed)
allowed=allowed_default;

@ -21,7 +21,7 @@ int cw_in_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerPa
radio=cw_get_byte(elem_data);
sprintf(key,"radio.%d/%s",radio,handler->key);
result = cw_ktv_add(params->conn->remote_cfg, key,
result = cw_ktv_add(params->remote_cfg, key,
handler->type, NULL, elem_data+1,elem_len-1);
params->elem=result;

@ -29,7 +29,7 @@ int cw_read_wtp_descriptor(mavl_t cfg, struct conn *conn,
/* Get number of encryption elements */
ncrypt = cw_get_byte(data + 2);
if (ncrypt == 0) {
if (conn->strict_capwap) {
if (0 /*conn->strict_capwap*/) {
cw_dbg(DBG_ELEM_ERR,
"Bad WTP Descriptor, number of encryption elements is 0.");
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;

@ -1,4 +1,4 @@
#include "conn.h"
#include "msgset.h"
#include "cw.h"
@ -10,3 +10,9 @@ int cw_write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
return len + cw_put_elem_hdr(dst, handler->id, len);
}
int cw_header_len(struct cw_ElemHandler * handler)
{
return handler->vendor ? 10 : 4;
}

@ -10,15 +10,15 @@ int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandle
uint8_t * d;
len =0;
sprintf(key,"radio.%d/%s",idx,handler->key);
/*printf("Looking for key: %s\n",key);*/
printf("Looking for readio key: %s\n",key);
search.key=key;
elem = mavl_get(params->conn->local_cfg, &search);
elem = mavl_get(params->local_cfg, &search);
if (elem==NULL){
printf("Nothing found\n");
return 0;
}
@ -27,14 +27,17 @@ int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandle
d = handler->vendor ? dst+10 : dst+4;
/* put radio id */
printf("Putting put byte index: %d\n",idx);
len += cw_put_byte(d+len,idx);
len += ((const cw_Type_t*)(handler->type))->put(elem,d+len);
/* l = len + cw_put_elem_hdr(dst, handler->id, len);*/
/* if (handler->vendor)
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);
}

@ -41,7 +41,7 @@ int dtls_bio_read(struct conn *conn, char *out, int maxlen)
{
int ret;
if (conn->dtls_buffer_len == 0) {
int len = conn->recv_packet(conn, conn->dtls_buffer, 2048);
int len = conn->recv_packet(conn, conn->dtls_buffer, 4096);
if (len < 4)
return 0;
conn->dtls_buffer_len = len - 4;
@ -77,7 +77,7 @@ int dtls_bio_read(struct conn *conn, char *out, int maxlen)
*/
int dtls_bio_write(struct conn *conn, const char *data, int len)
{
uint8_t buffer[2048];
uint8_t buffer[4096];
int rc;
*((uint32_t *) buffer) = htonl(1 << 24);
memcpy(buffer + 4, data, len);

@ -38,7 +38,7 @@ struct dtls_openssl_data{
SSL_CTX * ctx;
SSL * ssl;
BIO * bio;
uint8_t buffer[2048];
uint8_t buffer[4096];
int len;
int pos;
};

@ -147,6 +147,7 @@ extern const struct cw_Type cw_type_byte;
extern const struct cw_Type cw_type_word;
extern const struct cw_Type cw_type_dword;
extern const struct cw_Type cw_type_bstr16;
extern const struct cw_Type cw_type_bwstr;
extern const struct cw_Type cw_type_str;
extern const struct cw_Type cw_type_ipaddress;
extern const struct cw_Type cw_type_sysptr;
@ -156,6 +157,7 @@ extern const struct cw_Type cw_type_bool;
#define CW_TYPE_WORD (&cw_type_word)
#define CW_TYPE_DWORD (&cw_type_dword)
#define CW_TYPE_BSTR16 (&cw_type_bstr16)
#define CW_TYPE_BWSTR (&cw_type_bwstr)
#define CW_TYPE_IPADDRESS (&cw_type_ipaddress)
#define CW_TYPE_SYSPTR (&cw_type_sysptr)
#define CW_TYPE_STR (&cw_type_str)

@ -295,8 +295,6 @@ int cw_msgset_add(struct cw_MsgSet *set,
/* add the message */
search.type = msgdef->type;
printf("Msg type name %s\n",msgdef->name);
msg = mavl_insert(set->msgdata, &search, &exists);
if (msg == NULL) {
cw_log(LOG_ERR, "Can't create messae");

@ -31,13 +31,18 @@ struct cw_ElemData{
};
struct cw_ElemHandlerParams {
struct conn * conn;
/* struct conn * conn;*/
struct cw_MsgData * msgdata;
struct cw_ElemData * elemdata;
struct sockaddr *from;
mavl_t mand_found;
cw_KTV_t * elem;
char * debug_details;
mavl_t remote_cfg;
mavl_t local_cfg;
mavl_t default_cfg;
mavl_t global_cfg;
struct cw_MsgSet * msgset;
};

@ -201,7 +201,7 @@ int netconn_send_capwap_msg(struct netconn * nc, uint8_t *rawmsg, int msglen)
/* int mtu = nc->mtu; */
int mtu = 1400;
int mtu = 400;
while (msglen>mtu){
cw_set_hdr_flags(rawmsg,CAPWAP_FLAG_HDR_F,1);

@ -91,7 +91,7 @@ int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
}
#define MAX_MTU 1500
#define MAX_MTU 9500
int
cw_send_msg( struct conn * conn, uint8_t *msg)
{
@ -155,7 +155,7 @@ cw_send_msg( struct conn * conn, uint8_t *msg)
cw_set_dword(buf+4, conn->fragid<<16 | fragoffset<<3 );
cw_dbg_pkt(DBG_PKT_OUT,conn,buf,packetlen,(struct sockaddr*)&conn->addr);
cw_dbg_pkt(DBG_PKT_OUT,conn,buf,msglen+hlen,(struct sockaddr*)&conn->addr);
return conn->write(conn,buf,msglen + hlen);

@ -1,3 +1,4 @@
MF=Mf-$(KERNEL)-$(ARCH).mk
LIBTARGET=$(OBJDIR)/$(PROG)
@ -14,7 +15,7 @@ $(DNAME): $(MF) $(SOURCES)
@mkdir -p $(LIBARCHDIR)
@$(MAKE) -f $(MF) $(DNAME)
$(MF): Makefile
$(MF): Makefile $(MFDEPS)
@rm -f $(MF)
@echo "CFLAGS=$(CFLAGS)" >> $(MF)
@echo "LDFLAGS=$(LDFLAGS)" >> $(MF)

@ -1,9 +1,8 @@
include ../Config.mak
all:
$(MAKE) -C capwap
$(MAKE) -C capwap80211
$(MAKE) -C cisco
$(MAKE) -C fortinet
# $(MAKE) -C fortinet
# $(CC) -c modload_ac.c -I../
# $(CC) -c modload_wtp.c -I../
@ -11,5 +10,5 @@ clean:
$(MAKE) -C capwap clean
$(MAKE) -C capwap80211 clean
$(MAKE) -C cisco clean
$(MAKE) -C fortinet clean
rm *.o
# $(MAKE) -C fortinet clean
rm -f *.o

@ -30,6 +30,7 @@ DNAME := $(LIBARCHDIR)/mod_capwap.so
CFLAGS+=-fPIC
CFLAGS+= -I ../../ -I../ -I../../include
CFLAGS+=$(INC2)
all: $(SNAME) $(DNAME)
static: $(SNAME)

@ -549,6 +549,7 @@ static struct cw_ElemDef change_state_event_request_elements[] ={
static cw_State_t change_state_event_response_states[] = {
{CAPWAP_STATE_JOIN,CAPWAP_STATE_JOIN},
{CAPWAP_STATE_RUN,CAPWAP_STATE_RUN},
{0,0}
};
static struct cw_ElemDef change_state_event_response_elements[] ={

@ -16,6 +16,6 @@ int capwap_in_ac_descriptor(struct cw_ElemHandler *eh,
};
return cw_read_ac_descriptor(params->conn->remote_cfg,eh,params,data,len,allowed);
return cw_read_ac_descriptor(params->remote_cfg,eh,params,data,len,allowed);
}

@ -20,7 +20,7 @@
* @file
* @brief Implements cw_in_capwap_control_ip_address
*/
#include "cw/conn.h"
#include "mod_capwap.h"
@ -32,15 +32,15 @@ int capwap_in_capwap_control_ip_address(struct cw_ElemHandler *eh,
int idx;
sprintf(key,"%s/address",eh->key);
idx = cw_ktv_idx_get(params->conn->remote_cfg,key);
idx = cw_ktv_idx_get(params->remote_cfg,key);
/* printf("SKEY is %s , idx: %d\n",key,idx);*/
sprintf(key,"%s/address.%d",eh->key,idx+1);
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_IPADDRESS,NULL,data,len-2);
cw_ktv_add(params->remote_cfg,key,CW_TYPE_IPADDRESS,NULL,data,len-2);
sprintf(key,"%s/wtps.%d",eh->key,idx+1);
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_WORD,NULL,data+len-2,2);
cw_ktv_add(params->remote_cfg,key,CW_TYPE_WORD,NULL,data+len-2,2);
/* if (handler-id == CW_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS) {
struct sockaddr_in addr;