2015-03-23 22:31:59 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "lwapp.h"
|
|
|
|
#include "lwapp_cisco.h"
|
2018-03-03 17:42:28 +01:00
|
|
|
#include "mbag.h"
|
2016-03-04 21:01:38 +01:00
|
|
|
#include "lw.h"
|
2016-03-28 10:47:20 +02:00
|
|
|
#include "vendors.h"
|
2015-03-23 22:31:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int lw_addelem(uint8_t*dst, uint8_t type, uint8_t *msgelem, uint16_t len)
|
|
|
|
{
|
|
|
|
*dst = type;
|
|
|
|
*((uint16_t*)(dst+1)) = htons(len);
|
|
|
|
memcpy(dst,msgelem,len);
|
|
|
|
return len+3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int lw_addelem_vendor_specific(uint8_t *dst,uint32_t vendor_id,uint16_t elem_id, uint8_t *value, int len)
|
|
|
|
{
|
|
|
|
lw_put_dword(dst+3,vendor_id);
|
|
|
|
lw_put_word(dst+7,elem_id);
|
|
|
|
memcpy(dst+9,value,len);
|
|
|
|
int l = len+9;
|
|
|
|
*dst=LW_ELEM_VENDOR_SPECIFIC;
|
|
|
|
lw_put_word(dst+1,l);
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the vendor specific elem Cisco Padding
|
|
|
|
* @param dst destination
|
|
|
|
*/
|
|
|
|
int lw_addelem_cisco_padding(uint8_t *dst, int len)
|
|
|
|
{
|
2016-03-28 10:47:20 +02:00
|
|
|
lw_put_dword(dst+3,LW_VENDOR_ID_CISCO);
|
2015-03-28 12:51:34 +01:00
|
|
|
lw_put_word(dst+7,LW_CISCO_PATH_MTU);
|
2015-03-23 22:31:59 +01:00
|
|
|
lw_put_word(dst+9,len);
|
|
|
|
memset(dst+11,0,len);
|
|
|
|
return lw_put_elem_hdr(dst,LW_ELEM_VENDOR_SPECIFIC,11+len);
|
|
|
|
}
|
|
|
|
|
2015-03-24 20:14:26 +01:00
|
|
|
/*
|
2015-03-23 22:31:59 +01:00
|
|
|
int lw_put_cisco_path_mtu(uint8_t *dst, uint16_t max, uint16_t padding)
|
|
|
|
{
|
|
|
|
lw_put_dword(dst,LW_VENDOR_CISCO);
|
|
|
|
lw_put_word(dst+4,LW_ELEM_CISCO_PATH_MTU);
|
|
|
|
lw_put_word(dst+6,max);
|
|
|
|
lw_put_word(dst+8,padding+4);
|
|
|
|
memset(dst+10,0,padding);
|
|
|
|
return padding+10;
|
|
|
|
}
|
2015-03-24 20:14:26 +01:00
|
|
|
*/
|
2015-03-23 22:31:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
int lw_addelem_cisco_path_mtu(uint8_t *dst,uint16_t max, uint16_t padding)
|
|
|
|
{
|
|
|
|
lw_put_cisco_path_mtu(dst+3,max,padding);
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|