Fix control & data keep alive message
This commit is contained in:
parent
b99a52ee9d
commit
96eda13334
@ -148,7 +148,7 @@ int capwap_parsing_packet(struct capwap_packet_rxmng* rxmngpacket, struct capwap
|
||||
memcpy(&rxmngpacket->readpos, &rxmngpacket->readbodypos, sizeof(struct read_block_from_pos));
|
||||
|
||||
if (rxmngpacket->isctrlpacket) {
|
||||
unsigned short bodylength = rxmngpacket->ctrlmsg.length;
|
||||
unsigned short bodylength = rxmngpacket->ctrlmsg.length - CAPWAP_CONTROL_MESSAGE_MIN_LENGTH;
|
||||
while (bodylength > 0) {
|
||||
uint16_t type;
|
||||
uint16_t msglength;
|
||||
@ -435,12 +435,7 @@ int capwap_parsing_packet(struct capwap_packet_rxmng* rxmngpacket, struct capwap
|
||||
uint16_t type;
|
||||
uint16_t msglength;
|
||||
struct capwap_message_elements_ops* read_ops;
|
||||
unsigned short bodylength = rxmngpacket->datamsg.length;
|
||||
|
||||
if (!bodylength) {
|
||||
/* TODO */
|
||||
return 1;
|
||||
}
|
||||
unsigned short bodylength = rxmngpacket->datamsg.length - CAPWAP_DATA_MESSAGE_KEEPALIVE_MIN_LENGTH;
|
||||
|
||||
/* Get type and length */
|
||||
rxmngpacket->readerpacketallowed = sizeof(struct capwap_message_element);
|
||||
|
@ -410,7 +410,7 @@ static int capwap_fragment_write_block_from_pos(struct capwap_packet_txmng* txmn
|
||||
fragmentpacket->offset = available + packetpos;
|
||||
if (txmngpacket->isctrlpacket) {
|
||||
txmngpacket->ctrlmsg->length = htons(ntohs(txmngpacket->ctrlmsg->length) + (fragmentpacket->offset - oldoffset));
|
||||
} else {
|
||||
} else if (IS_FLAG_K_HEADER(txmngpacket->header)) {
|
||||
txmngpacket->datamsg->length = htons(ntohs(txmngpacket->datamsg->length) + (fragmentpacket->offset - oldoffset));
|
||||
}
|
||||
}
|
||||
@ -557,7 +557,7 @@ struct capwap_packet_txmng* capwap_packet_txmng_create_ctrl_message(struct capwa
|
||||
txmngpacket->ctrlmsg = (struct capwap_control_message*)&fragmentpacket->buffer[fragmentpacket->offset];
|
||||
txmngpacket->ctrlmsg->type = htonl(type);
|
||||
txmngpacket->ctrlmsg->seq = seq;
|
||||
txmngpacket->ctrlmsg->length = 0;
|
||||
txmngpacket->ctrlmsg->length = htons(CAPWAP_CONTROL_MESSAGE_MIN_LENGTH); /* sizeof(Msg Element Length) + sizeof(Flags) */
|
||||
txmngpacket->ctrlmsg->flags = 0;
|
||||
|
||||
/* Prepare for save capwap element */
|
||||
@ -593,14 +593,13 @@ struct capwap_packet_txmng* capwap_packet_txmng_create_data_message(struct capwa
|
||||
fragmentpacket = (struct capwap_fragment_packet_item*)txmngpacket->fragmentlist->last->item;
|
||||
ASSERT((fragmentpacket->offset + sizeof(struct capwap_data_message)) < fragmentpacket->size);
|
||||
|
||||
/* Create message */
|
||||
/* */
|
||||
txmngpacket->isctrlpacket = 0;
|
||||
|
||||
txmngpacket->datamsg = (struct capwap_data_message*)&fragmentpacket->buffer[fragmentpacket->offset];
|
||||
txmngpacket->datamsg->length = 0;
|
||||
|
||||
/* Prepare for save frame */
|
||||
fragmentpacket->offset += sizeof(struct capwap_data_message);
|
||||
if (IS_FLAG_K_HEADER(data)) {
|
||||
txmngpacket->datamsg = (struct capwap_data_message*)&fragmentpacket->buffer[fragmentpacket->offset];
|
||||
txmngpacket->datamsg->length = CAPWAP_DATA_MESSAGE_KEEPALIVE_MIN_LENGTH;
|
||||
fragmentpacket->offset += sizeof(struct capwap_data_message);
|
||||
}
|
||||
|
||||
return txmngpacket;
|
||||
}
|
||||
@ -834,7 +833,7 @@ static void capwap_packet_rxmng_complete(struct capwap_packet_rxmng* rxmngpacket
|
||||
rxmngpacket->read_ops.read_u8((capwap_message_elements_handle)rxmngpacket, &rxmngpacket->ctrlmsg.seq);
|
||||
rxmngpacket->read_ops.read_u16((capwap_message_elements_handle)rxmngpacket, &rxmngpacket->ctrlmsg.length);
|
||||
rxmngpacket->read_ops.read_u8((capwap_message_elements_handle)rxmngpacket, &rxmngpacket->ctrlmsg.flags);
|
||||
} else {
|
||||
} else if (IS_FLAG_K_HEADER(rxmngpacket->header)) {
|
||||
rxmngpacket->readerpacketallowed = sizeof(struct capwap_data_message);
|
||||
rxmngpacket->read_ops.read_u16((capwap_message_elements_handle)rxmngpacket, &rxmngpacket->datamsg.length);
|
||||
}
|
||||
|
@ -118,6 +118,8 @@ struct capwap_message_element {
|
||||
#define CAPWAP_LAST_MESSAGE_TYPE 26
|
||||
|
||||
/* Control Message */
|
||||
#define CAPWAP_CONTROL_MESSAGE_MIN_LENGTH 3
|
||||
|
||||
struct capwap_control_message {
|
||||
uint32_t type;
|
||||
uint8_t seq;
|
||||
@ -126,7 +128,9 @@ struct capwap_control_message {
|
||||
int8_t elements[0];
|
||||
} STRUCT_PACKED;
|
||||
|
||||
/* Data Message */
|
||||
/* Data Message Keep-Alive*/
|
||||
#define CAPWAP_DATA_MESSAGE_KEEPALIVE_MIN_LENGTH 2
|
||||
|
||||
struct capwap_data_message {
|
||||
uint16_t length;
|
||||
int8_t elements[0];
|
||||
|
Loading…
Reference in New Issue
Block a user