Moved some functions from lwapp.h to lw.h, capwap.h to cw.h ...
FossilOrigin-Name: 8b6f76655e93cdb212b833ec890772b57e53723cf30b4fa9635130701890b0f2
This commit is contained in:
63
src/cw/lw.h
63
src/cw/lw.h
@ -57,6 +57,69 @@
|
||||
#define lw_get_dword(src) \
|
||||
(ntohl( *((uint32_t*)(src))))
|
||||
|
||||
|
||||
|
||||
|
||||
/* the following functions are defined as static inline and not as
|
||||
macro to avoid any side effects */
|
||||
|
||||
|
||||
/**
|
||||
* Put some bytes to an output buffer
|
||||
* @param dst Destination
|
||||
* @param data Data to put
|
||||
* @len length of data (iini bytes)
|
||||
* @return The number of bytes put
|
||||
*/
|
||||
static inline int lw_put_data(uint8_t*dst,const uint8_t*data,uint16_t len)
|
||||
{
|
||||
memcpy(dst,data,len);
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a #bstr_t to an output buffer
|
||||
* @param dst Destination
|
||||
* @param b bstr to put
|
||||
* @return The number of bytes put
|
||||
*/
|
||||
static inline int lw_put_bstr(uint8_t * dst, const bstr_t b){
|
||||
lw_put_data(dst,bstr_data(b),bstr_len(b));
|
||||
return bstr_len(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a #bstr16_t to an output buffer
|
||||
* @param dst Destination
|
||||
* @param b bstr16 to put
|
||||
* @return The number of bytes put
|
||||
*/
|
||||
static inline int lw_put_bstr16(uint8_t * dst, const bstr16_t b){
|
||||
lw_put_data(dst,bstr16_data(b),bstr16_len(b));
|
||||
return bstr16_len(b);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put a string to an output buffer
|
||||
* @param dst Output buffer
|
||||
* @param str zero-terminated string to put
|
||||
* @return number of bytes put
|
||||
*/
|
||||
static inline int lw_put_str(uint8_t*dst,const uint8_t *str) {
|
||||
return lw_put_data(dst,str,strlen((char*)str));
|
||||
}
|
||||
|
||||
|
||||
static inline int lw_put_elem_hdr(uint8_t *dst,uint8_t type,uint16_t len)
|
||||
{
|
||||
*dst=type;
|
||||
*((uint16_t*)(dst+1)) = htons(len);
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user