Work on join with DTLS

FossilOrigin-Name: 555c5e22a849ebc1ec62ef358a31c32cd2dbb1af099224897ef5c803370b543b
This commit is contained in:
7u83@mail.ru 2018-04-01 11:59:36 +00:00
parent 5b62365285
commit 087f40afac
8 changed files with 47 additions and 10 deletions

View File

@ -34,5 +34,6 @@ WITH_OPENSSL=1
#
LIBDIR=lib
OPTFLAGS := -g -O0
CFLAGS := -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE=1 -pedantic -std=c90 -Wall

View File

@ -20,25 +20,25 @@ endif
ifeq ($(CC),clang)
LDFLAGS += -g -L/usr/local/lib
CFLAGS += -fPIC -g -O0 -D_REENTRANT -I /usr/local/include -I../
CFLAGS += -fPIC $(OPTFLAGS) -D_REENTRANT -I /usr/local/include -I../
LD = clang
endif
ifeq ($(CC),gcc)
LDFLAGS += -g -L/usr/local/lib
CFLAGS += -fPIC -g -O0 -D_REENTRANT -I /usr/local/include -I../
CFLAGS += -fPIC $(OPTFLAGS) -D_REENTRANT -I /usr/local/include -I../
LD = gcc
endif
ifeq ($(CC),tcc)
LDFLAGS += -g -L/usr/local/lib
CFLAGS += -Wall -Wunusupported -Wimplicit-function-declaration -I /usr/local/include -I../
CFLAGS += -Wall $(OPTFLAGS) -Wunusupported -Wimplicit-function-declaration -I /usr/local/include -I../
LD = tcc
endif
ifeq ($(CC),cc)
LDFLAGS += -g -L/usr/local/lib
CFLAGS += -fPIC -g -O0 -D_REENTRANT -I /usr/local/include -I../
CFLAGS += -fPIC $(OPTFLAGS) -D_REENTRANT -I /usr/local/include -I../
LD = cc
endif

View File

@ -1,7 +1,8 @@
capwap/ac-descriptor/hardware/version:Bstr16: "ACTube 1.0"
capwap/ac-descriptor/hardware/vendor:Bastr16: 12346
capwap/ssl-cert:Bstr16: "/usr/local/etc/ssl/tube.ssl"
capwap/ssl-key:Bstr16: "/usr/local/etc/key"
capwap/ssl-cert:Str: "/usr/local/etc/ssl/tube.ssl"
capwap/ssl-key:Str: "/usr/local/etc/key"
ac-descriptor/stations:Word:05
ac-descriptor/station-limit:Word:6
ac-descriptor/active-wtps:Word:7

View File

@ -47,6 +47,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
int static setup_cfg(struct conn * conn)
{
int security;
security = cw_setup_dtls(conn,conn->local_cfg,"capwap",CAPWAP_CIPHER);
cw_ktv_set_byte(conn->local_cfg,"ac-descriptor/security",security);

View File

@ -191,6 +191,16 @@ static struct cw_Mod capwap_ac = {
};
*/
int static setup_cfg(struct conn * conn)
{
int security;
security = cw_setup_dtls(conn,conn->local_cfg,"cisco",CAPWAP_CIPHER);
cw_ktv_set_byte(conn->local_cfg,"ac-descriptor/security",security);
return 0;
}
struct cw_Mod mod_cisco = {
"cisco", /* name */
@ -198,7 +208,8 @@ struct cw_Mod mod_cisco = {
detect, /* detect */
register_messages, /* register_messages */
NULL, /* dll_handle */
NULL /* data */
NULL, /* data */
setup_cfg /* setup_cfg */
};

View File

@ -4,6 +4,8 @@
capwap/ssl-certfile:Str:"../../ssl/certs/wtp.crt"
capwap/ssl-keyfile:Str:"../../ssl/certs/wtp.key"
cisco/ssl-certfile:Str:"../../ssl/certs/wtp.crt"
cisco/ssl-keyfile:Str:"../../ssl/certs/wtp.key"
discovery-type:Byte:0
wtp-frame-tunnel-mode:Byte:1

View File

@ -103,12 +103,23 @@ int run_join_d(struct conn * conn, struct sockaddr *sa)
{
char addrstr[SOCK_ADDR_BUFSIZE];
int sockfd;
int rsec,lsec;
lsec = cw_ktv_get_byte(conn->local_cfg,"ac-descriptor/security",0);
rsec = cw_ktv_get_byte(conn->remote_cfg,"ac-descriptor/security",0);
if ((lsec & rsec) == 0){
cw_log(LOG_ERR, "Can't establish DTLS with AC, my sec: %d, remote sec %d",lsec,rsec);
return 0;
}
/* struct conn *conn = get_conn();*/
conn->capwap_state = CAPWAP_STATE_JOIN;
sockfd = socket(sa->sa_family, SOCK_DGRAM, 0);
if (sockfd == -1) {
cw_log(LOG_ERR, "Can't create socket: %s\n", strerror(errno));
@ -218,8 +229,6 @@ int run_join(struct conn *conn)
return 1;
}
int join(struct conn * conn, struct cw_DiscoveryResult * dis)
{
@ -232,6 +241,7 @@ int join(struct conn * conn, struct cw_DiscoveryResult * dis)
char * rk;
char ipstr[100];
char ac_name[CAPWAP_MAX_AC_NAME_LEN];
struct sockaddr_storage sockaddr;
val = mavliter_get(&ii);
rk = val->key;
@ -248,7 +258,16 @@ int join(struct conn * conn, struct cw_DiscoveryResult * dis)
strcpy(ac_name,"");
}
cw_dbg(DBG_INFO, "Going to join CAPWAP controller '%s' at %s.",ac_name,ipstr);
conn->remote_cfg=rcfg;
/*cw_dbg_ktv_dump(conn->local_cfg,DBG_INFO,"remopte ac","preifx**: ","bottom");
*/
sock_strtoaddr(ipstr,(struct sockaddr*)(&sockaddr));
run_join_d(conn,(struct sockaddr*)(&sockaddr));
}

View File

@ -159,6 +159,8 @@ int main (int argc, char **argv)
mod->setup_cfg(conn);
}
/*cw_dbg_ktv_dump(conn->local_cfg,DBG_INFO,"head","BREP: ","bot");*/