mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 17:52:47 +01:00
tools/zep_dispatch: add function to get payload from ZEP frame
This commit is contained in:
parent
9827e573c0
commit
34ae8db68b
33
dist/tools/zep_dispatch/zep_parser.c
vendored
33
dist/tools/zep_dispatch/zep_parser.c
vendored
@ -13,6 +13,39 @@
|
|||||||
|
|
||||||
#define SOCKET_ZEP_V2_TYPE_HELLO (255)
|
#define SOCKET_ZEP_V2_TYPE_HELLO (255)
|
||||||
|
|
||||||
|
const void *zep_get_payload(const void *buffer, size_t *len)
|
||||||
|
{
|
||||||
|
const void *payload;
|
||||||
|
const zep_v2_data_hdr_t *zep = buffer;
|
||||||
|
|
||||||
|
if (*len == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zep->hdr.preamble[0] != 'E') || (zep->hdr.preamble[1] != 'X')) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zep->hdr.version != 2) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (zep->type) {
|
||||||
|
case ZEP_V2_TYPE_DATA:
|
||||||
|
payload = (zep_v2_data_hdr_t *)zep + 1;
|
||||||
|
break;
|
||||||
|
case ZEP_V2_TYPE_ACK:
|
||||||
|
payload = (zep_v2_ack_hdr_t *)zep + 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*len = zep->length - IEEE802154_FCS_LEN;
|
||||||
|
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
bool zep_parse_mac(const void *buffer, size_t len, void *out, uint8_t *out_len)
|
bool zep_parse_mac(const void *buffer, size_t len, void *out, uint8_t *out_len)
|
||||||
{
|
{
|
||||||
const void *payload;
|
const void *payload;
|
||||||
|
11
dist/tools/zep_dispatch/zep_parser.h
vendored
11
dist/tools/zep_dispatch/zep_parser.h
vendored
@ -15,6 +15,17 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the payload of a ZEP frame
|
||||||
|
*
|
||||||
|
* @param[in] buffer ZEP frame
|
||||||
|
* @param[in, out] len size of buffer, will contain size of payload
|
||||||
|
*
|
||||||
|
* @return pointer to payload on success
|
||||||
|
* NULL if no payload was found
|
||||||
|
*/
|
||||||
|
const void *zep_get_payload(const void *buffer, size_t *len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parse l2 source address of a ZEP frame
|
* @brief Parse l2 source address of a ZEP frame
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user