No more calculations with IANA numbers. All is defined in capwap.h

FossilOrigin-Name: 6cd95910201e86eb361b13ac221a0b90c3415a5831c3d112f22b73386cc4529e
This commit is contained in:
7u83@mail.ru 2014-07-24 21:54:53 +00:00
parent b1b5d52b6f
commit 4fe23c48cc
1 changed files with 12 additions and 6 deletions

View File

@ -13,7 +13,9 @@ static int cwrmsg_init_ctrlhdr(struct cwrmsg * cwrmsg, uint8_t * msg, int len)
uint32_t val; uint32_t val;
val = ntohl(*((uint32_t*)(msg+0))); val = ntohl(*((uint32_t*)(msg+0)));
cwrmsg->type = ntohl(*((uint32_t*)(msg)))-CWIANA_ENTERPRISE_NUMBER*256;
cwrmsg->type = ntohl(*((uint32_t*)(msg)));
val = ntohl(*((uint32_t*)(msg+4))); val = ntohl(*((uint32_t*)(msg+4)));
cwrmsg->seqnum = CW_GET_DWORD_BITS(val,0,8); cwrmsg->seqnum = CW_GET_DWORD_BITS(val,0,8);
@ -36,7 +38,6 @@ static int process_message(struct conn * conn,struct cwrmsg *cwrmsg,int (*cb)(vo
/* It's a response message, no further examination required. */ /* It's a response message, no further examination required. */
// conn->process_message(conn->pmsgarg,cwrmsg); // conn->process_message(conn->pmsgarg,cwrmsg);
cb(cbarg,cwrmsg); cb(cbarg,cwrmsg);
return 0; return 0;
} }
@ -85,7 +86,7 @@ void conn_process_packet(struct conn * conn, uint8_t *packet, int len,int (*cb)(
if (len<8){ if (len<8){
/* packet too short */ /* packet too short */
cw_log_debug0("Discarding packet, packet too short, len=%d",len); cw_log_debug1("Discarding packet, packet too short, len=%d",len);
return; return;
} }
@ -94,10 +95,12 @@ void conn_process_packet(struct conn * conn, uint8_t *packet, int len,int (*cb)(
int preamble = val >> 24; int preamble = val >> 24;
if ( (preamble & 0xf0) != CW_VERSION){ if ( (preamble & 0xf0) != CW_VERSION){
/* wrong version */ /* wrong version */
cw_log_debug0("Discarding packet, wrong version, version=%d",preamble&0xf0); cw_log_debug1("Discarding packet, wrong version, version=%d",preamble&0xf0);
return; return;
} }
if (preamble & 0xf ) { if (preamble & 0xf ) {
/* decode dtls */ /* decode dtls */
return; return;
@ -105,9 +108,10 @@ void conn_process_packet(struct conn * conn, uint8_t *packet, int len,int (*cb)(
int hlen = 4*((val >> 19) & 0x1f); int hlen = 4*((val >> 19) & 0x1f);
int payloadlen = len - hlen; int payloadlen = len - hlen;
if (payloadlen<0){ if (payloadlen<0){
cw_log_debug0("Discarding packet, hlen greater than len, hlen=%d",hlen); cw_log_debug1("Discarding packet, hlen greater than len, hlen=%d",hlen);
/* EINVAL */ /* EINVAL */
return; return;
} }
@ -126,8 +130,9 @@ void conn_process_packet(struct conn * conn, uint8_t *packet, int len,int (*cb)(
} }
cwrmsg.rmac = packet+8; cwrmsg.rmac = packet+8;
} }
else else{
cwrmsg.rmac=NULL; cwrmsg.rmac=NULL;
}
#endif #endif
@ -146,6 +151,7 @@ void conn_process_packet(struct conn * conn, uint8_t *packet, int len,int (*cb)(
} }
cwrmsg_init_ctrlhdr(&cwrmsg,packet+hlen,len-hlen); //f+4,*(uint32_t*)f); cwrmsg_init_ctrlhdr(&cwrmsg,packet+hlen,len-hlen); //f+4,*(uint32_t*)f);
process_message(conn,&cwrmsg,cb,cbarg); //packet,f+4,*(int32_t*)f); process_message(conn,&cwrmsg,cb,cbarg); //packet,f+4,*(int32_t*)f);
return; return;
} }