Misc ...
FossilOrigin-Name: 968d10c26f0cd7ba32e00b75d6af37d689aade5c2098caa9e2113bc3df285fb1
This commit is contained in:
parent
2adfefefaa
commit
3c831ae8b1
@ -110,7 +110,9 @@ static void wtpman_run_discovery(void *arg)
|
||||
|
||||
struct conn * conn = wtpman->conn;
|
||||
|
||||
conn->strict_capwap=0;
|
||||
conn->strict_capwap=1;
|
||||
conn->strict_hdr=1;
|
||||
|
||||
conn->capwap_mode=CW_MODE_CIPWAP;
|
||||
|
||||
|
||||
@ -300,7 +302,8 @@ static int wtpman_join(void *arg, time_t timer)
|
||||
|
||||
struct conn * conn = wtpman->conn;
|
||||
|
||||
conn->strict_capwap=0;
|
||||
conn->strict_capwap=1;
|
||||
conn->strict_hdr=1;
|
||||
conn->capwap_mode=CW_MODE_CIPWAP;
|
||||
|
||||
|
||||
|
@ -20,37 +20,42 @@ endif
|
||||
|
||||
NAME=libcapwap.a
|
||||
|
||||
SOCKOBJS=sock_create.o sock_copyaddr.o sock_strtoaddr.o sock_cmpaddr.o sock_addrlen.o \
|
||||
sock_mwait.o sock_addrtostr.o \
|
||||
sock_setport.o \
|
||||
sock_getport.o \
|
||||
sock_getifaddr.o \
|
||||
sock_getifhwaddr.o \
|
||||
sock_hwaddrtostr.o \
|
||||
sock_set_recvtimeout.o \
|
||||
sock_getbroadcastaddr.o \
|
||||
sock_addrinit.o \
|
||||
sock_set_dontfrag.o \
|
||||
sock_get_primary_if.o \
|
||||
sock_receive.o \
|
||||
SOCKOBJS=\
|
||||
sock_create.o\
|
||||
sock_copyaddr.o\
|
||||
sock_strtoaddr.o\
|
||||
sock_cmpaddr.o\
|
||||
sock_addrlen.o \
|
||||
sock_mwait.o\
|
||||
sock_addrtostr.o \
|
||||
sock_setport.o \
|
||||
sock_getport.o \
|
||||
sock_getifaddr.o \
|
||||
sock_getifhwaddr.o \
|
||||
sock_hwaddrtostr.o \
|
||||
sock_set_recvtimeout.o \
|
||||
sock_getbroadcastaddr.o \
|
||||
sock_addrinit.o \
|
||||
sock_set_dontfrag.o \
|
||||
sock_get_primary_if.o \
|
||||
sock_receive.o \
|
||||
|
||||
|
||||
LOGOBJS=log.o \
|
||||
log_syslog.o \
|
||||
log_file.o \
|
||||
cw_dbg_elem.o \
|
||||
dbg_strings.o
|
||||
dbg_strings.o\
|
||||
dbg.o
|
||||
|
||||
|
||||
|
||||
|
||||
WTPINFOOBJS = wtpinfo_set_location.o \
|
||||
WTPINFOOBJS =\
|
||||
wtpinfo_set_location.o \
|
||||
wtpinfo_print.o
|
||||
|
||||
UTILOBJS= \
|
||||
cw_setstr.o \
|
||||
cw_is_printable.o \
|
||||
cw_rand.o \
|
||||
cw_foreach_msgelem.o \
|
||||
avltree.o \
|
||||
avltree_get_node.o \
|
||||
avltree_get.o \
|
||||
@ -66,6 +71,7 @@ UTILOBJS= \
|
||||
cw_format_version.o \
|
||||
send.o
|
||||
|
||||
# cw_foreach_msgelem.o \
|
||||
|
||||
|
||||
# LWAPP objs
|
||||
@ -102,7 +108,6 @@ CAPWAPOBJS= \
|
||||
lwmsg_init.o \
|
||||
wtpinfo_lwreadelem_wtp_descriptor.o \
|
||||
hdr_print.o \
|
||||
cwmsg_addelem_vendor_cisco_mwar_addr.o \
|
||||
cw_cisco_id_to_str.o\
|
||||
cw_strlist_get_str.o \
|
||||
cw_strlist_get_id.o \
|
||||
@ -133,12 +138,12 @@ CAPWAPOBJS= \
|
||||
cw_in_capwap_control_ipv4_address.o\
|
||||
strheap.o \
|
||||
cw_check_missing_mand.o \
|
||||
dbg.o \
|
||||
md5sum.o \
|
||||
format.o \
|
||||
|
||||
|
||||
#acinfo.o \
|
||||
# cwmsg_addelem_vendor_cisco_mwar_addr.o \
|
||||
# cwsend_unknow_response.o \
|
||||
cw_send_configuration_update_response.o \
|
||||
cwsend_echo_request.o \
|
||||
@ -207,6 +212,7 @@ cw_readelem_maximum_message_length.o \
|
||||
cwsend_discovery_response.o \
|
||||
cw_readelem_cisco_wtp_radio_cfg.o \
|
||||
cw_addelem_cisco_wtp_radio_cfg.o \
|
||||
conn_prepare_request.o \
|
||||
|
||||
#cw_ianavendoridtostr.o \
|
||||
#cwmsg_addelem_result_code.o \
|
||||
@ -260,7 +266,6 @@ endif
|
||||
DTLSOBJS+=dtls_bio.o
|
||||
|
||||
CONNOBJS= conn_create.o \
|
||||
conn_send_packet.o \
|
||||
conn_process_packet.o \
|
||||
conn_q_add_packet.o \
|
||||
conn_q_get_packet.o \
|
||||
@ -269,21 +274,23 @@ CONNOBJS= conn_create.o \
|
||||
conn_destroy.o \
|
||||
connlist.o \
|
||||
conn_create_noq.o \
|
||||
conn_send_response.o \
|
||||
conn_prepare_configuration_update_request.o \
|
||||
cw_prepare_configuration_status_request.o \
|
||||
cw_prepare_change_state_event_request.o \
|
||||
conn_prepare_request.o \
|
||||
conn_init.o \
|
||||
conn_send_msg.o
|
||||
conn_send_packet.o \
|
||||
|
||||
# conn_send_msg.o
|
||||
#conn_get_message.o \
|
||||
# conn_send_response.o \
|
||||
# cw_prepare_configuration_status_request.o \
|
||||
# cw_prepare_change_state_event_request.o \
|
||||
conn_prepare_configuration_update_request.o \
|
||||
|
||||
|
||||
|
||||
BSTROBJS= bstr_create.o \
|
||||
bstr_create_from_cfgstr.o \
|
||||
bstr_replace.o \
|
||||
bstr_to_str.o
|
||||
bstr_to_str.o \
|
||||
bstr16cfgstr.o
|
||||
|
||||
|
||||
FRAGOBJS=fragman.o
|
||||
|
@ -124,6 +124,7 @@ static inline uint8_t * vendorstr_create(uint32_t vendor_id, uint8_t *data, uint
|
||||
|
||||
}
|
||||
|
||||
uint8_t * bstr16cfgstr(const char * s);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -22,13 +22,16 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef __CAPWAP_H
|
||||
#define __CAPWAP_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "conn.h"
|
||||
@ -36,13 +39,23 @@
|
||||
#include "lwapp.h"
|
||||
#include "strlist.h"
|
||||
|
||||
|
||||
|
||||
/* capwap version and iana number */
|
||||
|
||||
/**
|
||||
*@defgroup CAPWAPConstants CAPWAP Constants
|
||||
*@{
|
||||
*/
|
||||
|
||||
/** CAPWAP Version */
|
||||
#define CAPWAP_VERSION ((uint8_t)0)
|
||||
#define CWIANA_ENTERPRISE_NUMBER 0 /* for capwap base the number */
|
||||
|
||||
#define CWIANA_ENTERPRISE_NUMBER 0
|
||||
|
||||
/* ports */
|
||||
/** CAPWAP Control Port*/
|
||||
#define CAPWAP_CONTROL_PORT 5246
|
||||
/** CAPWAP Control Port as String */
|
||||
#define CAPWAP_CONTROL_PORT_STR "5246"
|
||||
|
||||
|
||||
@ -60,6 +73,7 @@ enum capwap_states {
|
||||
CW_STATE_RUN
|
||||
};
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
||||
/* transport header flags */
|
||||
@ -117,8 +131,65 @@ struct capwap_ctrlhdr
|
||||
//extern int capwap_parse_trnsprthdr(struct capwap_trnsprthdr * cwh,uint8_t *msg, int msglen);
|
||||
//extern int capwap_parse_ctrlhdr(struct capwap_ctrlhdr * ch,uint8_t * msg, int len);
|
||||
|
||||
/* CAPWAP message types as defined in RFC 5416 */
|
||||
/**
|
||||
*@defgroup CAPWAPMessages CAPWAP Messages
|
||||
*@{
|
||||
*/
|
||||
|
||||
/**
|
||||
* CAPWAP message types as defined in RFC 5416
|
||||
*/
|
||||
typedef enum {
|
||||
|
||||
/**Discovery Request */
|
||||
CW_MSG_DISCOVERY_REQUEST = 1,
|
||||
/** DIscovery Response */
|
||||
CW_MSG_DISCOVERY_RESPONSE = 2,
|
||||
CW_MSG_JOIN_REQUEST = 3,
|
||||
CW_MSG_JOIN_RESPONSE = 4,
|
||||
|
||||
CW_MSG_CONFIGURATION_STATUS_REQUEST = 5,
|
||||
CW_MSG_CONFIGURATION_STATUS_RESPONSE = 6,
|
||||
|
||||
CW_MSG_CONFIGURATION_UPDATE_REQUEST = 7,
|
||||
CW_MSG_CONFIGURATION_UPDATE_RESPONSE = 8,
|
||||
|
||||
CW_MSG_WTP_EVENT_REQUEST = 9,
|
||||
CW_MSG_WTP_EVENT_RESPONSE = 10,
|
||||
|
||||
CW_MSG_CHANGE_STATE_EVENT_REQUEST = 11,
|
||||
CW_MSG_CHANGE_STATE_EVENT_RESPONSE = 12,
|
||||
|
||||
CW_MSG_ECHO_REQUEST = 13,
|
||||
CW_MSG_ECHO_RESPONSE = 14,
|
||||
|
||||
CW_MSG_IMAGE_DATA_REQUEST = 15,
|
||||
CW_MSG_IMAGE_DATA_RESPONSE = 16,
|
||||
|
||||
CW_MSG_RESET_REQUEST = 17,
|
||||
CW_MSG_RESET_RESPONSE = 18,
|
||||
|
||||
CW_MSG_PRIMARY_DISCOVERY_REQUEST = 19,
|
||||
CW_MSG_PRIMARY_DISCOVERY_RESPONSE = 20,
|
||||
|
||||
CW_MSG_DATA_TRANSFER_REQUEST = 21,
|
||||
CW_MSG_DATA_TRANSFER_RESPONSE = 22,
|
||||
|
||||
CW_MSG_CLEAR_CONFIGURATION_REQUEST = 23,
|
||||
CW_MSG_CLEAR_CONFIGURATION_RESPONSE = 24,
|
||||
|
||||
CW_STATION_CONFIGURATION_REQUEST = 25,
|
||||
CW_STATION_CONFIGURATION_RESPONSE = 26,
|
||||
|
||||
CW_MSG_MAXMSG = 26
|
||||
|
||||
}cw_msg_t;
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#define CW_MSG_DISCOVERY_REQUEST 1
|
||||
#define CW_MSG_DISCOVERY_RESPONSE 2
|
||||
#define CW_MSG_JOIN_REQUEST 3
|
||||
@ -158,7 +229,7 @@ struct capwap_ctrlhdr
|
||||
#define CW_STATION_CONFIGURATION_RESPONSE 26
|
||||
|
||||
#define CW_MSG_MAXMSG 26
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* CAPWAP message elements as defined in RFC 5415
|
||||
@ -813,28 +884,13 @@ extern int cw_send_configuration_update_response(struct conn *conn, int seqnum,
|
||||
|
||||
|
||||
/* cwmsg methods */
|
||||
/*
|
||||
static inline int cw_addelem_result_code(uint8_t * dst, uint32_t code)
|
||||
{
|
||||
cw_put_dword(dst + 4, code);
|
||||
return 4 + cw_put_elem_hdr(dst, CW_ELEM_RESULT_CODE, 4);
|
||||
}
|
||||
|
||||
|
||||
#define cwmsg_addelem_vendor_specific_payload(cwmsg,vendor_id, type, data,len) \
|
||||
(cwmsg)->pos+=cw_addelem_vendor_specific_payload((cwmsg)->msgelems+(cwmsg)->pos,vendor_id,type,data,len)
|
||||
|
||||
#define cwmsg_addelem_ac_name(cwmsg,name) \
|
||||
(cwmsg)->pos+=cw_addelem_ac_name((cwmsg)->msgelems+(cwmsg)->pos,name)
|
||||
|
||||
#define cwmsg_addelem_session_id(cwmsg,sessid) \
|
||||
(cwmsg)->pos+=cw_addelem_session_id((cwmsg)->msgelems+(cwmsg)->pos,sessid)
|
||||
|
||||
#define cwmsg_addelem_result_code(cwmsg,code) \
|
||||
(cwmsg)->pos+=cw_addelem_result_code((cwmsg)->msgelems+(cwmsg)->pos,code)
|
||||
|
||||
#define cwmsg_addelem_radio_operational_state(cwmsg,ri) \
|
||||
(cwmsg)->pos+=cw_addelem_radio_operational_state((cwmsg)->msgelems+(cwmsg)->pos,ri)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* Message to text stuff */
|
||||
@ -853,11 +909,29 @@ extern struct cw_str capwap_strings_result[];
|
||||
#define cw_strvendor(id) cw_strlist_get_str(capwap_strings_vendor,id)
|
||||
#define cw_strresult(id) cw_strlist_get_str(capwap_strings_result,(id))
|
||||
|
||||
|
||||
/*
|
||||
#define cw_strrc(rc) \
|
||||
((rc)<0 ? ((rc)!=EAGAIN ? strerror(errno):"Timed out"): cw_strresult(rc))
|
||||
#define cw_strerror(rc) cw_strrc(rc)
|
||||
*/
|
||||
|
||||
static inline const char * cw_strerror(rc) {
|
||||
if (rc<0){
|
||||
if (errno==EAGAIN)
|
||||
return "Timed out";
|
||||
return strerror(errno);
|
||||
}
|
||||
return cw_strresult(rc);
|
||||
}
|
||||
#define cw_strrc cw_strerror
|
||||
|
||||
static inline int cw_rcok(int rc)
|
||||
{
|
||||
if (rc==0 || rc==2){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@
|
||||
cw_in_generic, 0, /* start/end callback */ \
|
||||
CW_ITEMTYPE_DATA, /* Type of element */ \
|
||||
CW_ITEM_AC_DESCRIPTOR, /* ID to use store */ \
|
||||
6, 6 /* min/max length */
|
||||
12, 8192 /* min/max length */
|
||||
|
||||
|
||||
#define CW_ACTION_IN_RESULT_CODE \
|
||||
|
@ -212,6 +212,21 @@ cw_action_out_t capwap_actions_ac_out[] = {
|
||||
,
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------------
|
||||
* Image Data Response OUT
|
||||
*/
|
||||
{CW_MSG_CONFIGURATION_STATUS_RESPONSE, CW_ITEM_NONE}
|
||||
,
|
||||
|
||||
/* Result Code */
|
||||
{CW_MSG_CONFIGURATION_STATUS_RESPONSE, CW_ITEM_RESULT_CODE, 0,
|
||||
CW_ELEM_RESULT_CODE, NULL,cw_out_generic, cw_out_get_outgoing, 1}
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------------
|
||||
* Image Data Request OUT
|
||||
*/
|
||||
|
@ -40,12 +40,12 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
|
||||
cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F,1);
|
||||
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
|
||||
|
||||
|
||||
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,mtu,(struct sockaddr*)&conn->addr);
|
||||
//XXX
|
||||
{
|
||||
char h[200];
|
||||
hdr_print(h,ptr,mtu);
|
||||
cw_dbg(DBG_PKT_OUT,"Sending capwap packet to %s:\n%s",sock_addr2str(&conn->addr),h);
|
||||
// char h[200];
|
||||
// hdr_print(h,ptr,mtu);
|
||||
// cw_dbg(DBG_PKT_OUT,"Sending capwap packet to %s:\n%s",sock_addr2str(&conn->addr),h);
|
||||
}
|
||||
// cw_dbg_dmp(DBG_PKT_DMP,ptr,mtu,"Sending packet ...");
|
||||
|
||||
@ -100,6 +100,7 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
|
||||
|
||||
|
||||
//printf("Send packet len %p %d\n",ptr,packetlen);
|
||||
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,packetlen,(struct sockaddr*)&conn->addr);
|
||||
|
||||
return conn->write(conn,ptr,packetlen-0);
|
||||
}
|
||||
|
@ -10,11 +10,11 @@
|
||||
int cw_in_generic(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);
|
||||
cw_dbg(DBG_ELEM_ERR,"%d (%s) message element too short, lan=%d, min len=%d", a->elem_id, cw_strelemp(conn->actions,a->elem_id),len,a->min_len);
|
||||
return 0;
|
||||
}
|
||||
if (len>a->max_len) {
|
||||
cw_dbg(DBG_ELEM_ERR,"Message element too big, %d > %d", len,a->max_len);
|
||||
cw_dbg(DBG_ELEM_ERR,"%d (%s) message element too big, len=%d, max len=%d", a->elem_id, cw_strelemp(conn->actions,a->elem_id),len,a->max_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -45,5 +45,4 @@ int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t *
|
||||
|
||||
int len = d-dst-4;
|
||||
return len + cw_put_elem_hdr(dst,a->elem_id,len);
|
||||
|
||||
}
|
||||
|
@ -447,10 +447,10 @@ void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int msgelem,
|
||||
}
|
||||
|
||||
|
||||
if (!cw_dbg_is_level(DBG_ELEM_DMP))
|
||||
if (!cw_dbg_is_level(DBG_ELEM_DMP)){
|
||||
cw_dbg(DBG_ELEM, "%d (%s), len=%d",
|
||||
msgelem, elemname, len);
|
||||
|
||||
}
|
||||
else{
|
||||
char *dmp = cw_dbg_mkdmp(msgbuf,len);
|
||||
|
||||
|
@ -58,9 +58,8 @@ void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup DebugOptions Dbug Options
|
||||
* @defgroup DebugOptions Debug Options
|
||||
* @{
|
||||
*/
|
||||
|
||||
@ -158,7 +157,10 @@ extern struct cw_str cw_dbg_strings[];
|
||||
|
||||
|
||||
|
||||
#define cw_dbg(type,...) cw_dbg_colored(type,__FILE__,__LINE__,__VA_ARGS__)
|
||||
#define cw_dbg(type,...)\
|
||||
if (cw_dbg_is_level(type)) cw_dbg_colored(type,__FILE__,__LINE__,__VA_ARGS__)
|
||||
|
||||
|
||||
#define cw_dbg_dmp(type,...) cw_dbg_dmp_(type,__FILE__,__LINE__,__VA_ARGS__)
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "log.h"
|
||||
#include "dbg.h"
|
||||
|
||||
|
||||
#include "sock.h"
|
||||
|
||||
int dtls_gnutls_connect(struct conn *conn)
|
||||
{
|
||||
@ -34,7 +34,7 @@ int dtls_gnutls_connect(struct conn *conn)
|
||||
}
|
||||
|
||||
|
||||
cw_dbg(DBG_DTLS,"DTLS - Handshake successful");
|
||||
cw_dbg(DBG_DTLS,"Handshake with %s successful",sock_addr2str(&conn->addr));
|
||||
|
||||
conn->dtls_data=d;
|
||||
conn->read = dtls_gnutls_read;
|
||||
|
@ -22,8 +22,6 @@ static inline void cw_itemstore_del_data(void *e)
|
||||
break;
|
||||
case CW_ITEMTYPE_AVLTREE:
|
||||
avltree_destroy(item->data);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +242,6 @@ void *cw_item_get_data_ptr(struct cw_item *item)
|
||||
|
||||
}
|
||||
return item->data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
/**
|
||||
* Item types supported in item store
|
||||
*/
|
||||
enum cw_cfgtem_types {
|
||||
typedef enum {
|
||||
CW_ITEMTYPE_NONE = 0,
|
||||
CW_ITEMTYPE_BYTE,
|
||||
CW_ITEMTYPE_WORD,
|
||||
@ -45,7 +45,7 @@ enum cw_cfgtem_types {
|
||||
CW_ITEMTYPE_AVLTREE,
|
||||
CW_ITEMTYPE_FUN,
|
||||
|
||||
};
|
||||
} cw_itemtype_t;
|
||||
|
||||
struct cw_item {
|
||||
uint32_t id;
|
||||
@ -136,4 +136,8 @@ int cw_itemstore_set_fun(cw_itemstore_t s, uint32_t id,
|
||||
int cw_itemstore_set(cw_itemstore_t itemstore, uint32_t item_id, int item_type,
|
||||
uint8_t * data, int len);
|
||||
|
||||
struct cw_item *cw_item_create(cw_itemstore_t s, uint32_t id);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -19,6 +19,8 @@
|
||||
/**
|
||||
*@file
|
||||
*@brief Implements lw_checksum.
|
||||
*@addtogroup LWAPPFunctions
|
||||
*@{
|
||||
*/
|
||||
|
||||
#include "lwapp.h"
|
||||
@ -50,3 +52,8 @@ uint16_t lw_checksum(uint8_t * d, int len)
|
||||
return (~sum) & 0xffff;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
||||
|
@ -173,6 +173,12 @@
|
||||
|
||||
/* useful macros and inline functions */
|
||||
|
||||
/**
|
||||
* @defgroup LWAPPFunctions LWAPP Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#define lw_foreach_elem(d,msg,len) for(d=msg; d<msg+len; d=d+3+LWMSGELEM_GET_LEN(d))
|
||||
|
||||
|
||||
@ -231,6 +237,9 @@ static inline int lw_put_elem_hdr(uint8_t *dst,uint8_t type,uint16_t len)
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
||||
extern int lw_put_sockaddr(uint8_t *dst, struct sockaddr_storage *addr);
|
||||
|
||||
|
||||
|
@ -3,9 +3,76 @@
|
||||
#include "conn.h"
|
||||
#include "capwap.h"
|
||||
#include "log.h"
|
||||
#include "dbg.h"
|
||||
#include "sock.h"
|
||||
#include "timer.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
|
||||
{
|
||||
|
||||
int packetlen = cw_get_hdr_msg_total_len(rawmsg);
|
||||
|
||||
cw_dbg_msg(DBG_MSG_OUT, conn,rawmsg, packetlen,(struct sockaddr*)&conn->addr);
|
||||
|
||||
|
||||
/* Zyxel doesn't count msg element length from
|
||||
behind seqnum */
|
||||
if (conn->capwap_mode == CW_MODE_ZYXEL){
|
||||
// XXX val-=3;
|
||||
}
|
||||
|
||||
|
||||
uint8_t * ptr = rawmsg;
|
||||
|
||||
int fragoffset = 0;
|
||||
|
||||
int hlen = cw_get_hdr_hlen(rawmsg)*4;
|
||||
|
||||
int mtu = conn->mtu;
|
||||
|
||||
while (packetlen>mtu){
|
||||
cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F,1);
|
||||
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
|
||||
|
||||
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,mtu,(struct sockaddr*)&conn->addr);
|
||||
|
||||
if (conn->write(conn,ptr,mtu)<0)
|
||||
return -1;
|
||||
|
||||
// XXX Fragmentation stuff..
|
||||
ptr +=mtu-hlen;
|
||||
fragoffset+=(mtu-hlen)/8;
|
||||
|
||||
packetlen-=mtu-hlen;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (fragoffset)
|
||||
cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F | CW_FLAG_HDR_L,1);
|
||||
else
|
||||
cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F,0);
|
||||
|
||||
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
|
||||
|
||||
|
||||
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,packetlen,(struct sockaddr*)&conn->addr);
|
||||
|
||||
return conn->write(conn,ptr,packetlen-0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int cw_send_request(struct conn *conn,int msg_id)
|
||||
{
|
||||
cw_init_request(conn, msg_id);
|
||||
@ -13,8 +80,6 @@ int cw_send_request(struct conn *conn,int msg_id)
|
||||
return 0;
|
||||
conn_send_msg(conn, conn->req_buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
int i;
|
||||
int rc=-1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
This file is part of libcapwap.
|
||||
Tis 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
|
||||
@ -50,7 +50,7 @@
|
||||
|
||||
/**
|
||||
* Define a clock variable to measure runtime (not CPU runtime, but
|
||||
* ralt time). This variable can be used with #cw_clock_start
|
||||
* real time). This variable can be used with #cw_clock_start
|
||||
* and #cw_clock_lap.
|
||||
*
|
||||
* @param c name of the variable
|
||||
|
@ -20,14 +20,15 @@ ifndef ARCH
|
||||
endif
|
||||
|
||||
|
||||
CFLAGS += -O0 -Wall -g
|
||||
#CFLAGS += -Os -Wall
|
||||
LDFLAGS += -L../../src/capwap/$(ARCH)
|
||||
#CFLAGS += -O0 -Wall -g
|
||||
CFLAGS += -Os -Wall
|
||||
LDFLAGS += -L../contrib/jsmn -L../../src/capwap/$(ARCH)
|
||||
|
||||
|
||||
LIBS+=-lcapwap
|
||||
LIBS+=-lnl-3
|
||||
LIBS+=-lnl-genl-3
|
||||
LIBS+=-ljsmn
|
||||
|
||||
CONFOBJS = wtp_conf.o
|
||||
|
||||
@ -71,7 +72,7 @@ CFLAGS += $(HA_INCS)
|
||||
|
||||
#CFLAGS += -I../src
|
||||
#CFLAGS += -I../src/utils
|
||||
CFLAGS += -I../../src -I /usr/local/include
|
||||
CFLAGS += -I../../src -I /usr/local/include -I ../contrib/jsmn
|
||||
|
||||
#CFLAGS += -I/usr/local/include
|
||||
|
||||
@ -80,6 +81,7 @@ CFLAGS += -I../../src -I /usr/local/include
|
||||
|
||||
OBJS += wtp_main.o
|
||||
OBJS += image_update.o
|
||||
OBJS += cfg.o
|
||||
|
||||
|
||||
#OBJS += wtp_conf.o
|
||||
|
@ -166,17 +166,13 @@ int run_join(struct conn * conn)
|
||||
|
||||
int rc = cw_send_request(conn,CW_MSG_JOIN_REQUEST);
|
||||
|
||||
if (rc >=0 ) {
|
||||
cw_dbg(DBG_ELEM,"Join Result: %d - %s",rc,cw_strresult(rc));
|
||||
|
||||
}
|
||||
if (rc != 0 && rc != 2) {
|
||||
cw_log(LOG_ERR,"Can't Join AC at %s, AC returned code: %d - %s.",
|
||||
sock_addr2str(&conn->addr),
|
||||
rc,cw_strresult(rc));
|
||||
if (!cw_rcok(rc) ) {
|
||||
cw_log(LOG_ERR,"Can't Join AC at %s: %d - %s.",
|
||||
sock_addr2str(&conn->addr),rc,cw_strerror(rc));
|
||||
return 0;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_ELEM,"Join Result: %d - %s",rc,cw_strresult(rc));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -196,7 +192,7 @@ int join()
|
||||
avliter_foreach(&ii){
|
||||
cw_acip_t * ip = avliter_get(&ii);
|
||||
|
||||
cw_dbg(DBG_ELEM,"Going to join CAWAP controller on %s",sock_addr2str(&ip->ip));
|
||||
cw_dbg(DBG_INFO,"Going to join CAWAP controller on %s",sock_addr2str(&ip->ip));
|
||||
|
||||
int rc = run_join_d((struct sockaddr*)&ip->ip);
|
||||
if (!rc)
|
||||
|
@ -9,6 +9,7 @@ extern int sulking_state();
|
||||
extern int join();
|
||||
extern int discovery();
|
||||
extern int image_update();
|
||||
extern int setup_conf(struct conn * conn);
|
||||
|
||||
|
||||
struct conn * get_conn();
|
||||
|
@ -15,6 +15,13 @@
|
||||
|
||||
#include "capwap/dbg.h"
|
||||
|
||||
#include "jsmn.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** The one and only connection object */
|
||||
@ -23,6 +30,9 @@ struct cw_actiondef capwap_actions;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@ -55,6 +65,10 @@ int main()
|
||||
conn->incomming = cw_itemstore_create();
|
||||
conn->local = cw_itemstore_create();
|
||||
|
||||
|
||||
// setup_conf(conn);
|
||||
|
||||
|
||||
cw_itemstore_t board_data = cw_itemstore_create();
|
||||
cw_itemstore_set_dword(board_data, CW_ITEM_WTP_BOARD_VENDOR, conf_vendor_id);
|
||||
|
||||
@ -65,6 +79,7 @@ int main()
|
||||
bstr_data(conf_serial_no), bstr_len(conf_serial_no));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cw_itemstore_set_avltree(conn->outgoing, CW_ITEM_WTP_BOARD_DATA, board_data);
|
||||
|
Loading…
Reference in New Issue
Block a user