actube/src/capwap/cwmsg_addelem_mtu_discovery_padding.c
7u83@mail.ru 2bae9358d7 Initial commit
FossilOrigin-Name: c53d95729c009f8f80a7d63847cef7668ff73f8af0523ab65f7734696f85399c
2014-07-11 20:12:11 +00:00

20 lines
427 B
C

#include <string.h>
#include "capwap.h"
#include "conn.h"
#include "cwmsg.h"
void cwmsg_addelem_mtu_discovery_padding(struct cwmsg * msg, struct conn* conn)
{
int len = conn->mtu - (msg->msgelems-msg->buffer+msg->pos)-4;
if (len < 0 )
return;
uint32_t val = CWMSGELEM_MTU_DISCOVERY_PADDING<<16|len;
*((uint32_t*)(msg->msgelems+msg->pos))=htonl(val);
memset(msg->msgelems+4+msg->pos,0xff,len);
msg->pos+=4+len;
}