Refactoring ...
FossilOrigin-Name: 29a45fd6c217dc9d1d0f050cfc636be7ae4b6473631bb0ab14493e0395f0e3a9
This commit is contained in:
parent
f866dc6b25
commit
94dce70a75
@ -146,13 +146,13 @@
|
||||
|
||||
#define CAPWAP_MSG_CONFIGURATION_UPDATE_RESPONSE 8
|
||||
|
||||
#define CW_MSG_WTP_EVENT_REQUEST 9
|
||||
#define CAPWAP_MSG_WTP_EVENT_REQUEST 9
|
||||
#define CW_MSG_WTP_EVENT_RESPONSE 10
|
||||
|
||||
#define CW_MSG_CHANGE_STATE_EVENT_REQUEST 11
|
||||
#define CW_MSG_CHANGE_STATE_EVENT_RESPONSE 12
|
||||
|
||||
#define CW_MSG_ECHO_REQUEST 13
|
||||
#define CAPWAP_MSG_ECHO_REQUEST 13
|
||||
#define CW_MSG_ECHO_RESPONSE 14
|
||||
|
||||
#define CW_MSG_IMAGE_DATA_REQUEST 15
|
||||
@ -253,7 +253,7 @@
|
||||
* The WTP Descriptor message element conteins information
|
||||
* about the WTP */
|
||||
#define CAPWAP_ELEM_WTP_DESCRIPTOR 39
|
||||
#define CW_ELEM_WTP_FALLBACK 40
|
||||
#define CAPWAP_ELEM_WTP_FALLBACK 40
|
||||
#define CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE 41
|
||||
#define CW_ELEM_RESERVED_42 42
|
||||
#define CW_ELEM_RESERVED_43 43
|
||||
|
@ -47,7 +47,7 @@ struct cw_strlist_elem capwap_strings_elem[] = {
|
||||
{CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, "Vendor Specific Payload"},
|
||||
{CAPWAP_ELEM_WTP_BOARD_DATA, "WTP Board Data"},
|
||||
{CAPWAP_ELEM_WTP_DESCRIPTOR, "WTP Descriptor"},
|
||||
{CW_ELEM_WTP_FALLBACK, "WTP Fallback"},
|
||||
{CAPWAP_ELEM_WTP_FALLBACK, "WTP Fallback"},
|
||||
{CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE, "WTP Frame Tunnel Mode"},
|
||||
{CW_ELEM_RESERVED_42, "Reserved 42"},
|
||||
{CW_ELEM_RESERVED_43, "Reserved 43"},
|
||||
|
@ -34,11 +34,11 @@ struct cw_strlist_elem capwap_strings_msg[] = {
|
||||
{ CAPWAP_MSG_CONFIGURATION_STATUS_RESPONSE,"Configuration Status Response"},
|
||||
{ CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST,"Configuration Update Request"},
|
||||
{ CAPWAP_MSG_CONFIGURATION_UPDATE_RESPONSE,"Configuration Update Response"},
|
||||
{ CW_MSG_WTP_EVENT_REQUEST,"WTP Event Request"},
|
||||
{ CAPWAP_MSG_WTP_EVENT_REQUEST,"WTP Event Request"},
|
||||
{ CW_MSG_WTP_EVENT_RESPONSE,"WTP Event Response"},
|
||||
{ CW_MSG_CHANGE_STATE_EVENT_REQUEST,"Change State Event Request"},
|
||||
{ CW_MSG_CHANGE_STATE_EVENT_RESPONSE,"Change State Event Response"},
|
||||
{ CW_MSG_ECHO_REQUEST,"Echo Request"},
|
||||
{ CAPWAP_MSG_ECHO_REQUEST,"Echo Request"},
|
||||
{ CW_MSG_ECHO_RESPONSE,"Echo Response"},
|
||||
{ CW_MSG_IMAGE_DATA_REQUEST,"Image Data Request"},
|
||||
{ CW_MSG_IMAGE_DATA_RESPONSE,"Image Data Response"},
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "mod.h"
|
||||
#include "message_set.h"
|
||||
|
||||
|
||||
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
|
||||
|
||||
|
||||
@ -44,22 +45,25 @@ int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
|
||||
*/
|
||||
void cw_init_response(struct conn *conn, uint8_t * req)
|
||||
{
|
||||
uint8_t *buffer = conn->resp_buffer;
|
||||
int shbytes = cw_get_hdr_msg_offset(req);
|
||||
int dhbytes;
|
||||
uint8_t *buffer;
|
||||
int shbytes, dhbytes;
|
||||
uint8_t *msgptr, *dmsgptr;
|
||||
|
||||
buffer = conn->resp_buffer;
|
||||
shbytes = cw_get_hdr_msg_offset(req);
|
||||
|
||||
memcpy(buffer, req, shbytes);
|
||||
|
||||
|
||||
cw_set_hdr_rmac(buffer, conn->base_rmac);
|
||||
/*
|
||||
// cw_set_hdr_hlen(buffer, 2);
|
||||
// cw_set_hdr_flags(buffer, CW_FLAG_HDR_M, 1);
|
||||
|
||||
|
||||
*/
|
||||
|
||||
dhbytes = cw_get_hdr_msg_offset(buffer);
|
||||
|
||||
uint8_t *msgptr = req + shbytes;
|
||||
uint8_t *dmsgptr = buffer + dhbytes;
|
||||
msgptr = req + shbytes;
|
||||
dmsgptr = buffer + dhbytes;
|
||||
|
||||
cw_set_msg_type(dmsgptr, cw_get_msg_type(msgptr) + 1);
|
||||
cw_set_msg_seqnum(dmsgptr, cw_get_msg_seqnum(msgptr));
|
||||
@ -69,7 +73,8 @@ void cw_init_response(struct conn *conn, uint8_t * req)
|
||||
void cw_init_request(struct conn *conn, int msg_id)
|
||||
{
|
||||
uint8_t *buffer = conn->req_buffer;
|
||||
|
||||
uint8_t *msgptr;
|
||||
|
||||
/* zero the first 8 bytes */
|
||||
cw_put_dword(buffer + 0, 0);
|
||||
cw_put_dword(buffer + 4, 0);
|
||||
@ -78,15 +83,16 @@ void cw_init_request(struct conn *conn, int msg_id)
|
||||
cw_set_hdr_preamble(buffer, CAPWAP_VERSION << 4 | 0);
|
||||
|
||||
cw_set_hdr_rmac(buffer, conn->base_rmac);
|
||||
/*
|
||||
//cw_set_hdr_hlen(buffer, 2);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
cw_set_hdr_wbid(buffer, conn->wbid);
|
||||
cw_set_hdr_rid(buffer, 0);
|
||||
|
||||
|
||||
uint8_t *msgptr = cw_get_hdr_msg_offset(buffer) + buffer;
|
||||
msgptr = cw_get_hdr_msg_offset(buffer) + buffer;
|
||||
cw_set_msg_type(msgptr, msg_id);
|
||||
cw_set_msg_flags(msgptr, 0);
|
||||
cw_set_msg_elems_len(msgptr, 0);
|
||||
@ -131,12 +137,15 @@ int cw_send_response(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
*/
|
||||
int cw_send_error_response(struct conn *conn, uint8_t * rawmsg, uint32_t result_code)
|
||||
{
|
||||
uint8_t *out,*dst;
|
||||
int l;
|
||||
|
||||
cw_init_response(conn, rawmsg);
|
||||
|
||||
uint8_t *out = conn->resp_buffer;
|
||||
out = conn->resp_buffer;
|
||||
|
||||
uint8_t *dst = cw_get_hdr_msg_elems_ptr(out);
|
||||
int l = cw_put_elem_result_code(dst, result_code);
|
||||
dst = cw_get_hdr_msg_elems_ptr(out);
|
||||
l = cw_put_elem_result_code(dst, result_code);
|
||||
|
||||
cw_set_msg_elems_len(out + cw_get_hdr_msg_offset(out), l);
|
||||
|
||||
|
@ -43,17 +43,13 @@ extern int cw_foreach_msgelem(uint8_t * msgelems, int len,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//#define cw_timer_start(t) (time(NULL)+t)
|
||||
//#define cw_timer_timeout(t) (time(NULL)>t ? 1 : 0)
|
||||
|
||||
|
||||
/** Generic macro to isolate bits from a dword */
|
||||
#define cw_get_dword_bits(src,start,len) ((~(0xFFFFFFFF<<len)) & (src >> (32 - start - len)))
|
||||
|
||||
|
||||
/* functions used to "rfc-verify" message elements */
|
||||
|
||||
/*
|
||||
//void cw_mand_elem_found(int *l,int type);
|
||||
//int cw_is_missing_mand_elems(int *l);
|
||||
//void cw_get_missing_mand_elems(char *dst, int *l);
|
||||
@ -61,5 +57,6 @@ extern int cw_foreach_msgelem(uint8_t * msgelems, int len,
|
||||
|
||||
|
||||
//extern const char * cw_msgtostr(int type);
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
@ -458,8 +458,7 @@ void cw_dbg_pkt_nc(int level, struct netconn *nc, uint8_t * packet, int len,
|
||||
|
||||
|
||||
|
||||
void cw_dbg_dmp_(int level, const char *file, int line,
|
||||
const uint8_t * data, int len, const char *format, ...)
|
||||
void cw_dbg_dmp_(int level, const uint8_t * data, int len, const char *format, ...)
|
||||
{
|
||||
if (!cw_dbg_is_level(level))
|
||||
return;
|
||||
@ -596,7 +595,7 @@ void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int msgelem,
|
||||
}
|
||||
|
||||
|
||||
void cw_dbg_colored(int level, const char *file, int line, const char *format, ...)
|
||||
void cw_dbg_colored(int level, const char *format, ...)
|
||||
{
|
||||
|
||||
if (!(cw_dbg_is_level(level)))
|
||||
|
20
src/cw/dbg.h
20
src/cw/dbg.h
@ -45,11 +45,11 @@ void cw_dbg_elem_(struct conn * conn, int msg, int msgelem, const uint8_t * msgb
|
||||
void cw_dbg_missing_mand(int level,struct conn *conn,cw_action_in_t ** ml,int n,cw_action_in_t *a);
|
||||
void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len);
|
||||
|
||||
|
||||
/*
|
||||
#define DBGX(f,...) cw_dbg(DBG_X,f,__VA_ARGS__) //cw_dbg(DBG_X, f ,__VA_ARGS__)
|
||||
//#define DBGX(f,...) cw_dbg(DBG_X, f)
|
||||
//#define DBGX(f,...) printf("hallo\n")
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -95,19 +95,15 @@ extern uint32_t cw_dbg_opt_level;
|
||||
extern struct cw_strlist_elem cw_dbg_strings[];
|
||||
|
||||
|
||||
#define cw_dbg cw_dbg_colored
|
||||
|
||||
|
||||
#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__)
|
||||
*/
|
||||
#define cw_dbg_dmp cw_dbg_dmp_
|
||||
|
||||
|
||||
void cw_dbg_colored(int level, const char *file, int line, const char *format, ...);
|
||||
void cw_dbg_dmp_(int level, const char *file, int line,
|
||||
const uint8_t * data, int len, const char *format, ...);
|
||||
void cw_dbg_colored(int level, const char *format, ...);
|
||||
void cw_dbg_dmp_(int level, const uint8_t * data, int len, const char *format, ...);
|
||||
|
||||
|
||||
extern void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int msgelem,
|
||||
|
@ -255,7 +255,7 @@ static cw_action_in_t actions_in[] = {
|
||||
{
|
||||
.capwap_state = CW_STATE_CONFIGURE,
|
||||
.msg_id = CAPWAP_MSG_CONFIGURATION_STATUS_RESPONSE,
|
||||
.elem_id = CW_ELEM_WTP_FALLBACK,
|
||||
.elem_id = CAPWAP_ELEM_WTP_FALLBACK,
|
||||
.item_id = CW_ITEM_WTP_FALLBACK,
|
||||
.start = cw_in_generic2,
|
||||
.min_len = 1,
|
||||
@ -710,7 +710,7 @@ static cw_action_out_t actions_out[] = {
|
||||
|
||||
/* Echo Request */
|
||||
{
|
||||
.msg_id = CW_MSG_ECHO_REQUEST,
|
||||
.msg_id = CAPWAP_MSG_ECHO_REQUEST,
|
||||
}
|
||||
,
|
||||
|
||||
|
@ -142,7 +142,7 @@ int run()
|
||||
|
||||
}
|
||||
if (rc<0 && errno == EAGAIN){
|
||||
rc = cw_send_request(conn,CW_MSG_ECHO_REQUEST);
|
||||
rc = cw_send_request(conn,CAPWAP_MSG_ECHO_REQUEST);
|
||||
|
||||
if (!cw_rcok(rc)) {
|
||||
cw_log(LOG_ERR,"Error in run state: %d %s",rc,cw_strrc(rc));
|
||||
|
Loading…
Reference in New Issue
Block a user