Work on join
FossilOrigin-Name: c917b9235f3d4c90452f961176a838f732e4e8b6569cab820a0232fc316bd84e
This commit is contained in:
parent
087f40afac
commit
d04e106dcd
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CodeLite_Workspace Name="actube" Database="">
|
<CodeLite_Workspace Name="actube" Database="">
|
||||||
<Project Name="ac" Path="ac.project" Active="No"/>
|
<Project Name="ac" Path="ac.project" Active="Yes"/>
|
||||||
<Project Name="wtp" Path="wtp.project" Active="Yes"/>
|
<Project Name="wtp" Path="wtp.project" Active="No"/>
|
||||||
<Project Name="mod_cipwap" Path="mod_cipwap.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_capwap" Path="mod_capwap.project" Active="No"/>
|
||||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
||||||
|
@ -8,10 +8,11 @@ include ../Macros.mak
|
|||||||
|
|
||||||
|
|
||||||
LIBARCHDIR=../../lib/$(ARCH)
|
LIBARCHDIR=../../lib/$(ARCH)
|
||||||
|
INCL= -I/usr/local/include -I../
|
||||||
|
LDFLAGS+=-L$(LIBARCHDIR)
|
||||||
|
#CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 $(INCL) -I../ -DSYS_ARCH=\"${ARCH}\"
|
||||||
|
|
||||||
LDFLAGS+=-g -L/usr/local/lib -L$(LIBARCHDIR)
|
CFLAGS+=-DSYS_ARCH=\"$(ARCH)\"
|
||||||
CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
|
|
||||||
|
|
||||||
|
|
||||||
#LIBS+=-lcapwap
|
#LIBS+=-lcapwap
|
||||||
#LIBS+=-lcapwap80211
|
#LIBS+=-lcapwap80211
|
||||||
@ -92,7 +93,11 @@ clean:
|
|||||||
clean_deps:
|
clean_deps:
|
||||||
$(AC_DEPS)
|
$(AC_DEPS)
|
||||||
|
|
||||||
deps: $(AC_SRC)
|
deps:
|
||||||
$(LD) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null
|
echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > .depend
|
||||||
|
# makedepend $(AC_SRC) -f.depend -p$(OBJDIR)/
|
||||||
|
makedepend *.c -f.depend
|
||||||
|
|
||||||
|
|
||||||
-include $(AC_DEPS)
|
-include $(AC_DEPS)
|
||||||
|
|
||||||
|
197
src/ac/wtpman.c
197
src/ac/wtpman.c
@ -21,7 +21,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h> // sleep
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
#include "cw/capwap.h"
|
#include "cw/capwap.h"
|
||||||
@ -119,6 +119,7 @@ static void wtpman_run_discovery(void *arg)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
int xprocess_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
int xprocess_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
||||||
struct sockaddr *from)
|
struct sockaddr *from)
|
||||||
{
|
{
|
||||||
@ -132,6 +133,7 @@ int xprocess_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
|||||||
return process_message(conn, rawmsg, rawlen, from);
|
return process_message(conn, rawmsg, rawlen, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
static int wtpman_establish_dtls(void *arg)
|
static int wtpman_establish_dtls(void *arg)
|
||||||
@ -291,106 +293,6 @@ static void wtpman_image_data(struct wtpman *wtpman)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void config_to_sql(struct conn *conn)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
// XXX for the moment we use just the IP adress as ID
|
|
||||||
char *wtp_id = sock_addr2str(&conn->addr);
|
|
||||||
|
|
||||||
// cw_dbg(DBG_X, "WTPID: %s\n", wtp_id);
|
|
||||||
|
|
||||||
MAVLITER_DEFINE(it, conn->incomming);
|
|
||||||
mavliter_foreach(&it) {
|
|
||||||
mbag_item_t *i = mavliter_get(&it);
|
|
||||||
|
|
||||||
const struct cw_itemdef *cwi =
|
|
||||||
cw_itemdef_get(conn->actions->items, i->id, NULL);
|
|
||||||
|
|
||||||
cw_dbg(DBG_X,"ID GOT: %s",i->id);
|
|
||||||
|
|
||||||
if (cwi) {
|
|
||||||
DBGX("SQL ID %s,%s", i->id, cwi->id);
|
|
||||||
DBGX("SQL Type %s,Typecwd %s", i->type->name, cwi->type->name);
|
|
||||||
|
|
||||||
// printf("%s != %s ?\n",i->type->name,cwi->type->name);
|
|
||||||
char str[256];
|
|
||||||
if (i->type->to_str) {
|
|
||||||
i->type->to_str(i, str);
|
|
||||||
db_put_wtp_prop(wtp_id, cwi->id, cwi->sub_id, str);
|
|
||||||
} else {
|
|
||||||
cw_log(LOG_ERR, "Can't converto to str for %s", cwi->id,
|
|
||||||
cwi->sub_id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// DBGX("ID %d",i->id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void xradio_to_sql(struct conn *conn, char *wtp_id, int rid, int radio)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
MAVLITER_DEFINE(it, radio);
|
|
||||||
mavliter_foreach(&it) {
|
|
||||||
mbag_item_t *i = mavliter_get(&it);
|
|
||||||
|
|
||||||
const struct cw_itemdef *cwi =
|
|
||||||
cw_itemdef_get(conn->actions->radioitems, i->id, NULL);
|
|
||||||
if (cwi) {
|
|
||||||
char str[4096];
|
|
||||||
if (i->type->to_str) {
|
|
||||||
i->type->to_str(i, str);
|
|
||||||
// printf("I would put RID: %d, %s=>%s\n",rid,cwi->id,str);
|
|
||||||
|
|
||||||
char srid[6];
|
|
||||||
sprintf(srid,"%d",rid);
|
|
||||||
|
|
||||||
db_put_radio_prop(wtp_id,srid,cwi->id,cwi->sub_id,str);
|
|
||||||
|
|
||||||
// db_put_wtp_prop(wtp_id, cwi->id, cwi->sub_id, str);
|
|
||||||
} else {
|
|
||||||
cw_log(LOG_ERR, "Can't converto to str for %s", cwi->id,
|
|
||||||
cwi->sub_id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// DBGX("ID %d",i->id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// int rid = ((struct mbag_item*)mavliter_get(&it))->iid;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void radios_to_sql(struct conn *conn)
|
|
||||||
{
|
|
||||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
char *wtp_id = sock_addr2str(&conn->addr,sock_buf);
|
|
||||||
MAVLITER_DEFINE(it, conn->radios);
|
|
||||||
mavliter_foreach(&it) {
|
|
||||||
struct mbag_item * i = mavliter_get(&it);
|
|
||||||
int rid = i->u1.iid;
|
|
||||||
|
|
||||||
radio_to_sql(conn,wtp_id,rid,i->u2.data);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -418,15 +320,6 @@ void wtpman_run_data(void *wtpman_arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int msg_end_handler(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
|
||||||
int len, struct sockaddr *from)
|
|
||||||
{
|
|
||||||
/* if (a->msg_id ==CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST) {
|
|
||||||
props_to_sql(conn,conn->incomming,0);
|
|
||||||
radios_to_sql(conn);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void wtpman_run(void *arg)
|
static void wtpman_run(void *arg)
|
||||||
@ -518,7 +411,7 @@ static void wtpman_run(void *arg)
|
|||||||
// radios_to_sql(conn);
|
// radios_to_sql(conn);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
conn->msg_end=msg_end_handler;
|
/*conn->msg_end=msg_end_handler;*/
|
||||||
/* The main run loop */
|
/* The main run loop */
|
||||||
reset_echointerval_timer(wtpman);
|
reset_echointerval_timer(wtpman);
|
||||||
|
|
||||||
@ -733,14 +626,19 @@ void wtpman_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int nodtls = 0;
|
|
||||||
|
|
||||||
|
|
||||||
void wtpman_start(struct wtpman *wtpman, int dtlsmode)
|
void wtpman_start(struct wtpman *wtpman, int dtlsmode)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run,
|
||||||
|
(void *) wtpman);
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
if (dtlsmode) {
|
if (dtlsmode) {
|
||||||
cw_dbg(DBG_INFO, "Starting wtpman in DTLS mode");
|
cw_dbg(DBG_INFO, "Starting wtpman in DTLS mode");
|
||||||
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run_dtls,
|
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run_dtls,
|
||||||
@ -759,80 +657,11 @@ void wtpman_start(struct wtpman *wtpman, int dtlsmode)
|
|||||||
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run_discovery,
|
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run_discovery,
|
||||||
(void *) wtpman);
|
(void *) wtpman);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wtpman_lw_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
// uint8_t * m = packet+12;
|
|
||||||
// int l = LWTH_GET_LENGTH(packet+6);
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8_t *msg = packet + 12;
|
|
||||||
|
|
||||||
|
|
||||||
int msgtype = LWMSG_GET_TYPE(msg);
|
|
||||||
int msglen = LWMSG_GET_LEN(msg);
|
|
||||||
printf("Type is %d, Len is %d\n", msgtype, msglen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// uint8_t *msgdata = LWMSG_GET_DATA(msg);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
int c=0;
|
|
||||||
while (c < msglen){
|
|
||||||
int eltype = LWMSGELEM_GET_TYPE(data);
|
|
||||||
int ellen = LWMSGELEM_GET_LEN(data);
|
|
||||||
printf ("ELEM TYPE: %d, LEN: %d\n",eltype,ellen);
|
|
||||||
c+=ellen+3;
|
|
||||||
data=data+ellen+3;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*//uint8_t *data;*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
lw_foreach_msgelem(data,msgdata,msglen){
|
|
||||||
int eltype = LWMSGELEM_GET_TYPE(data);
|
|
||||||
int ellen = LWMSGELEM_GET_LEN(data);
|
|
||||||
uint8_t * eldata = LWMSGELEM_GET_DATA(data);
|
|
||||||
|
|
||||||
wtpinfo_lwreadelem_wtp_descriptor(&wtpman->wtpinfo,eltype,eldata,ellen);
|
|
||||||
|
|
||||||
printf ("ELEM TYPE: %d, LEN: %d\n",eltype,ellen);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
// char wi[4096];
|
|
||||||
// wtpinfo_print(wi, &wtpman->wtpinfo);
|
|
||||||
// printf("WTPINFO: \n%s\n", wi);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// char buffer[2048];
|
|
||||||
// struct lwmsg lwmsg;
|
|
||||||
// lwmsg_init(&lwmsg, buffer,conf_macaddress,LWMSG_DISCOVERY_RESPONSE,conn_get_next_seqnum(wtpman->conn));
|
|
||||||
|
|
||||||
// conn_send_packet(wtpman->conn,buffer,60);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void wtpman_lw_start(struct wtpman *wtpman)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
@ -14,12 +14,6 @@
|
|||||||
struct wtpman{
|
struct wtpman{
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
|
||||||
/* packet queue */
|
|
||||||
/* uint8_t * q[WTPMAN_QSIZE];
|
|
||||||
int qrpos;
|
|
||||||
int qwpos;
|
|
||||||
sem_t q_sem;
|
|
||||||
*/
|
|
||||||
struct conn * conn;
|
struct conn * conn;
|
||||||
|
|
||||||
|
|
||||||
@ -29,9 +23,6 @@ struct wtpman{
|
|||||||
uint8_t * session_id;
|
uint8_t * session_id;
|
||||||
uint8_t wtp_mactype;
|
uint8_t wtp_mactype;
|
||||||
|
|
||||||
/* //struct wtpinfo wtpinfo;*/
|
|
||||||
|
|
||||||
|
|
||||||
int socklistindex;
|
int socklistindex;
|
||||||
int connected;
|
int connected;
|
||||||
|
|
||||||
@ -51,9 +42,9 @@ struct wtp{
|
|||||||
//extern void wtpman_run(void *arg);
|
//extern void wtpman_run(void *arg);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern struct wtpman * wtpman_create();
|
struct wtpman * wtpman_create();
|
||||||
|
|
||||||
extern struct wtpman * wtpman_create(int socklistindex,struct sockaddr * srcaddr);
|
struct wtpman * wtpman_create(int socklistindex,struct sockaddr * srcaddr);
|
||||||
|
|
||||||
extern void wtpman_addpacket(struct wtpman * wtpman,uint8_t *packet,int len);
|
extern void wtpman_addpacket(struct wtpman * wtpman,uint8_t *packet,int len);
|
||||||
extern void wtpman_destroy(struct wtpman * wtpman);
|
extern void wtpman_destroy(struct wtpman * wtpman);
|
||||||
|
@ -38,7 +38,6 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
CWSRC=\
|
CWSRC=\
|
||||||
cw_addelem_capwap_local_ip_addr.c\
|
|
||||||
cw_check_missing_mand.c\
|
cw_check_missing_mand.c\
|
||||||
cw_clock_lap.c\
|
cw_clock_lap.c\
|
||||||
cw_dbg_elem.c\
|
cw_dbg_elem.c\
|
||||||
|
@ -1,81 +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 <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "capwap.h"
|
|
||||||
#include "cwmsg.h"
|
|
||||||
#include "conn.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
uint8_t * cw_addelem(uint8_t * buf,int type, uint8_t *elem, int len)
|
|
||||||
{
|
|
||||||
uint32_t val = type<<16|len;
|
|
||||||
*((uint32_t*)(buf))=htonl(val);
|
|
||||||
buf+=4;
|
|
||||||
memcpy(buf,elem,len);
|
|
||||||
return buf+len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void cw_addelem_capwap_local_ip_addr(struct cwmsg *msg, int sock, int cw_mode)
|
|
||||||
{
|
|
||||||
struct sockaddr_storage a;
|
|
||||||
socklen_t alen = sizeof(struct sockaddr_storage);
|
|
||||||
getsockname (sock,(struct sockaddr *)&a,&alen);
|
|
||||||
|
|
||||||
int cw_mode = cwmsg->capwap_mode;
|
|
||||||
|
|
||||||
switch (((struct sockaddr*)&a)->sa_family){
|
|
||||||
case AF_INET:
|
|
||||||
{
|
|
||||||
struct sockaddr_in * sain = (struct sockaddr_in*)&a;
|
|
||||||
int id;
|
|
||||||
if (cw_mode == CWMODE_CISCO)
|
|
||||||
id = CWMSGELEM_WTP_IPV4_IP_ADDR;
|
|
||||||
else
|
|
||||||
id = CWMSGELEM_CAPWAP_LOCAL_IPV4_ADDRESS;
|
|
||||||
|
|
||||||
cwmsg_addelem(msg,id,(uint8_t*)&sain->sin_addr,4);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case AF_INET6:
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
if (cw_mode == CWMODE_CISCO)
|
|
||||||
id = CWMSGELEM_WTP_IPV6_IP_ADDR;
|
|
||||||
else
|
|
||||||
id = CWMSGELEM_CAPWAP_LOCAL_IPV6_ADDRESS;
|
|
||||||
struct sockaddr_in6 * sain = (struct sockaddr_in6*)&a;
|
|
||||||
return cwmsg_addelem(msg,id,(uint8_t*)&sain->sin6_addr,16);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
Loading…
Reference in New Issue
Block a user