Message Handling
[DES-SERT Library]
EXTERNAL / PUBLIC. More...
![]() |
Defines | |
#define | DESSERT_FLAG_SPARSE 0x1 |
flag for dessert_msg.flags - message len is hlen+plen if not set buffer len is assumed as DESSERT_MAXFRAMELEN + DESSERT_MSGPROCLEN | |
#define | DESSERT_LFLAG_SRC_SELF 0x0002 |
flag for dessert_msg_proc.lflags - l25 src is one of our interfaces | |
#define | DESSERT_LFLAG_DST_MULTICAST 0x0004 |
flag for dessert_msg_proc.lflags - l25 dst is multicast address | |
#define | DESSERT_LFLAG_DST_SELF 0x0008 |
flag for dessert_msg_proc.lflags - l25 dst is one of our interfaces | |
#define | DESSERT_LFLAG_DST_BROADCAST 0x0010 |
flag for dessert_msg_proc.lflags - l25 dst is broadcast | |
#define | DESSERT_LFLAG_PREVHOP_SELF 0x0020 |
flag for dessert_msg_proc.lflags - l2 src is one of our interfaces | |
#define | DESSERT_LFLAG_NEXTHOP_SELF 0x0040 |
flag for dessert_msg_proc.lflags - l2 dst is one of our interfaces | |
#define | DESSERT_LFLAG_NEXTHOP_BROADCAST 0x0080 |
flag for dessert_msg_proc.lflags - l2 dst is broadcast | |
#define | DESSERT_LFLAG_DST_SELF_OVERHEARD 0x0100 |
flag for dessert_msg_proc.lflags - l25 dst is one of our interfaces, but we received the message not via the indented interface, e.g. | |
#define | DESSERT_LFLAG_NEXTHOP_SELF_OVERHEARD 0x0200 |
flag for dessert_msg_proc.lflags - l2 dst is one of our interfaces, but we received the message not via the indented interface, e.g. | |
#define | DESSERT_EXTLEN (sizeof(struct dessert_ext) - DESSERT_MAXEXTDATALEN) |
length of dessert_ext header | |
#define | DESSERT_MSG_TRACE_HOST (ETHER_ADDR_LEN) |
packet tracing flag - only record hosts | |
#define | DESSERT_MSG_TRACE_IFACE (3*ETHER_ADDR_LEN) |
packet tracing flag - record interfaces | |
Enumerations | |
enum | dessert_extensions { DESSERT_EXT_ANY = 0x00, DESSERT_EXT_ETH = 0x01, DESSERT_EXT_TRACE_REQ = 0x02, DESSERT_EXT_TRACE_RPL = 0x03, DESSERT_EXT_PING = 0x04, DESSERT_EXT_PONG = 0x05, DESSERT_EXT_USER = 0x40 } |
Reserved extension type values. More... | |
Functions | |
int | dessert_msg_new (dessert_msg_t **msgout) |
creates a new dessert_msg_t and initializes it. | |
int | dessert_msg_clone (dessert_msg_t **msgnew, const dessert_msg_t *msgold, uint8_t sparse) |
generates a copy of a dessert_msg | |
int | dessert_msg_check (const dessert_msg_t *msg, size_t len) |
checks whether a dessert_msg is consistent | |
void | dessert_msg_dump (const dessert_msg_t *msg, size_t len, char *buf, size_t blen) |
dump a dessert_msg_t to a string | |
void | dessert_msg_destroy (dessert_msg_t *msg) |
free a dessert_msg | |
int | dessert_msg_ethencap (const struct ether_header *eth, size_t eth_len, dessert_msg_t **msgout) |
creates a new dessert_msg from an ethernet frame. | |
int | dessert_msg_ethdecap (const dessert_msg_t *msg, struct ether_header **ethout) |
extracts an ethernet frame from a dessert_msg | |
struct ether_header * | dessert_msg_getl25ether (const dessert_msg_t *msg) |
get the ether_header sent as DESSERT_EXT_ETH in a dessert_msg | |
int | dessert_msg_ipencap (const uint8_t *ip, size_t len, dessert_msg_t **msgout) |
creates a new dessert_msg from an ip datagram. | |
int | dessert_msg_ipdecap (const dessert_msg_t *msg, uint8_t **ip) |
extract an ip datagram from a dessert_msg | |
int | dessert_msg_proc_clone (dessert_msg_proc_t **procnew, const dessert_msg_proc_t *procold) |
generates a copy of a dessert_msg_proc | |
void | dessert_msg_proc_dump (const dessert_msg_t *msg, size_t len, const dessert_msg_proc_t *proc, char *buf, size_t blen) |
dump a dessert_msg_t to a string | |
void | dessert_msg_proc_destroy (dessert_msg_proc_t *proc) |
free a dessert_prc_msg | |
int | dessert_msg_addpayload (dessert_msg_t *msg, void **payload, int len) |
add or replace payload to a dessert_msg | |
int | dessert_msg_getpayload (dessert_msg_t *msg, void **payload) |
Retrieves a pointer to the payload of a dessert message msg. | |
int | dessert_msg_addext (dessert_msg_t *msg, dessert_ext_t **ext, uint8_t type, size_t len) |
add an extension record to a dessert_msg | |
int | dessert_msg_delext (dessert_msg_t *msg, dessert_ext_t *ext) |
remove an extension record from a dessert_msg | |
int | dessert_msg_resizeext (dessert_msg_t *msg, dessert_ext_t *ext, size_t new_len) |
Resizes a given extension record ext within in a dessert message msg to the new length new_len. | |
int | dessert_msg_getext (const dessert_msg_t *msg, dessert_ext_t **ext, uint8_t type, int index) |
get an specific or all extensions | |
int | dessert_msg_get_ext_count (const dessert_msg_t *msg, uint8_t type) |
get an specific or all extensions | |
int | dessert_msg_dump_cb (dessert_msg_t *msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *iface, dessert_frameid_t id) |
dump a dessert_msg_t to debug log | |
int | dessert_msg_check_cb (dessert_msg_t *msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *iface, dessert_frameid_t id) |
callback that checks whether a dessert_msg is consistent | |
int | dessert_msg_trace_cb (dessert_msg_t *msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *iface, dessert_frameid_t id) |
check if the message carries a trace extension and add the current trace info if iface is NULL, the packet is ignored | |
int | dessert_msg_ifaceflags_cb (dessert_msg_t *msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *riface, dessert_frameid_t id) |
callback to set the local processing flags in dessert_msg_proc_t on an arriving dessert_msg_t |
Detailed Description
EXTERNAL / PUBLIC.
Define Documentation
#define DESSERT_LFLAG_DST_SELF_OVERHEARD 0x0100 |
flag for dessert_msg_proc.lflags - l25 dst is one of our interfaces, but we received the message not via the indented interface, e.g.
we overheard it
#define DESSERT_LFLAG_NEXTHOP_SELF_OVERHEARD 0x0200 |
flag for dessert_msg_proc.lflags - l2 dst is one of our interfaces, but we received the message not via the indented interface, e.g.
we overheard it
Enumeration Type Documentation
enum dessert_extensions |
Reserved extension type values.
- Enumerator:
DESSERT_EXT_ANY dessert_ext type wildcard - any extension
DESSERT_EXT_ETH ethernet header
DESSERT_EXT_TRACE_REQ route trace request: A -> B
DESSERT_EXT_TRACE_RPL route trace reply: B -> A
DESSERT_EXT_PING ping packet
DESSERT_EXT_PONG pong packet
DESSERT_EXT_USER first dessert_ext type for usage by the user
Function Documentation
int dessert_msg_addext | ( | dessert_msg_t * | msg, | |
dessert_ext_t ** | ext, | |||
uint8_t | type, | |||
size_t | len | |||
) |
add an extension record to a dessert_msg
- *msg the message the extension should be added to
- **ext (out) the extension pointer to the reserved extension space
- type the type of the extension
- len the length of the ext data (without 2 byte extension header)
- Returns:
- DESSERT_OK on success,

int dessert_msg_addpayload | ( | dessert_msg_t * | msg, | |
void ** | payload, | |||
int | len | |||
) |
add or replace payload to a dessert_msg
- *msg the message the payload should be added to
- **payload (out) the pointer to place the payload
- len the length of the payload
- Returns:
- DESSERT_OK on success, DESSERT_ERR otherwise

int dessert_msg_check | ( | const dessert_msg_t * | msg, | |
size_t | len | |||
) |
checks whether a dessert_msg is consistent
- msg the message to be checked
- len the length of the buffer
- Returns:
- DESSERT_OK on success
- -1 of the message is too large for the buffer
- -2 if the message was not intended to this daemon
- -3 if some extension is not consistent DESCRIPTION:

int dessert_msg_check_cb | ( | dessert_msg_t * | msg, | |
size_t | len, | |||
dessert_msg_proc_t * | proc, | |||
const dessert_meshif_t * | iface, | |||
dessert_frameid_t | id | |||
) |
callback that checks whether a dessert_msg is consistent
- *msg dessert_msg_t frame received
- len length of ethernet frame received
- *iface interface received packet on
- Returns:
- DESSERT_MSG_KEEP if message is valid, DESSERT_MSG_DROP otherwise
int dessert_msg_clone | ( | dessert_msg_t ** | msgnew, | |
const dessert_msg_t * | msgold, | |||
uint8_t | sparse | |||
) |
generates a copy of a dessert_msg
- **msgnew (out) pointer to return message address
- *msgold pointer to the message to clone
- sparse whether to allocate DESSERT_MAXFRAMELEN or only hlen+plen
- Returns:
- DESSERT_OK on success, -errno otherwise

int dessert_msg_delext | ( | dessert_msg_t * | msg, | |
dessert_ext_t * | ext | |||
) |
remove an extension record from a dessert_msg
- *msg the message the extension should be added to
- *ext (out) the extension pointer to the extension to be removed
- Returns:
- DESSERT_OK on success,
void dessert_msg_destroy | ( | dessert_msg_t * | msg | ) |
void dessert_msg_dump | ( | const dessert_msg_t * | msg, | |
size_t | len, | |||
char * | buf, | |||
size_t | blen | |||
) |
dump a dessert_msg_t to a string
- *msg the message to be dumped
- len the length of the buffer
- *buf text output buffer
- blen text output buffer length
int dessert_msg_dump_cb | ( | dessert_msg_t * | msg, | |
size_t | len, | |||
dessert_msg_proc_t * | proc, | |||
const dessert_meshif_t * | iface, | |||
dessert_frameid_t | id | |||
) |
dump a dessert_msg_t to debug log
- *msg dessert_msg_t frame received
- len length of ethernet frame received
- *iface interface received packet on
- Returns:
- DESSERT_MSG_KEEP always
int dessert_msg_ethdecap | ( | const dessert_msg_t * | msg, | |
struct ether_header ** | ethout | |||
) |
extracts an ethernet frame from a dessert_msg
- *msg pointer to dessert_msg message to decapsulate
- **ethout (out) pointer to return ethernet message
- Returns:
- eth_len on success, -1 otherwise

int dessert_msg_ethencap | ( | const struct ether_header * | eth, | |
size_t | eth_len, | |||
dessert_msg_t ** | msgout | |||
) |
creates a new dessert_msg from an ethernet frame.
- *eth ethernet frame to encapsulate
- len length of the ethernet frame
- **msgout (out) pointer to return message address
- Returns:
- DESSERT_OK on success, -errno otherwise
int dessert_msg_get_ext_count | ( | const dessert_msg_t * | msg, | |
uint8_t | type | |||
) |
get an specific or all extensions
- *msg the message
- type type of the ext to retrieve - use DESSERT_EXT_ANY to get any ext
- Returns:
- 0 if the message has no such extension,
- count of extensions of that type
int dessert_msg_getext | ( | const dessert_msg_t * | msg, | |
dessert_ext_t ** | ext, | |||
uint8_t | type, | |||
int | index | |||
) |
get an specific or all extensions
- *msg the message
- **ext (out) pointer to extracted extension sets *ext=NULL if extension not found may be NULL in this case only count/existence matters
- type type of the ext to retrieve - use DESSERT_EXT_ANY to get any ext
- index the index of the extension of that type, starting with 0
- Returns:
- 0 if the message has no such extension,
- count of extensions of that type if count > index
- -count of extensions of that type if count <= index

struct ether_header* dessert_msg_getl25ether | ( | const dessert_msg_t * | msg | ) | [read] |
get the ether_header sent as DESSERT_EXT_ETH in a dessert_msg
- *msg the message
- Returns:
- pointer to ether_header data, NULL if DESSERT_EXT_ETH not present

int dessert_msg_getpayload | ( | dessert_msg_t * | msg, | |
void ** | payload | |||
) |
Retrieves a pointer to the payload of a dessert message msg.
- Parameters:
-
[in] *msg the message the payload should be retrieved from [out] **payload the pointer to place the payload in
- Returns:
- the length of the payload in bytes if any, 0 otherwise
int dessert_msg_ifaceflags_cb | ( | dessert_msg_t * | msg, | |
size_t | len, | |||
dessert_msg_proc_t * | proc, | |||
const dessert_meshif_t * | riface, | |||
dessert_frameid_t | id | |||
) |
callback to set the local processing flags in dessert_msg_proc_t on an arriving dessert_msg_t
- *msg dessert_msg_t frame received
- len length of ethernet frame received
- *iface interface received packet on ®return DESSERT_MSG_KEEP or DESSERT_MSG_NEEDMSGPROC
int dessert_msg_ipdecap | ( | const dessert_msg_t * | msg, | |
uint8_t ** | ip | |||
) |
extract an ip datagram from a dessert_msg
- *msg pointer to dessert_msg message to decapsulate
- **ip (out) pointer to return datagram
- Returns:
- len of datagram on success, -1 otherwise

int dessert_msg_ipencap | ( | const uint8_t * | ip, | |
size_t | len, | |||
dessert_msg_t ** | msgout | |||
) |
creates a new dessert_msg from an ip datagram.
- *ip datagram to encapsulate
- len length of the datagram
- **msgout (out) pointer to return message address
- Returns:
- DESSERT_OK on success, -errno otherwise
int dessert_msg_new | ( | dessert_msg_t ** | msgout | ) |
creates a new dessert_msg_t and initializes it.
- **msgout (out) pointer to return message address
- Returns:
- 0 on success, -errno on error

int dessert_msg_proc_clone | ( | dessert_msg_proc_t ** | procnew, | |
const dessert_msg_proc_t * | procold | |||
) |
generates a copy of a dessert_msg_proc
- **procnew (out) pointer to return message address
- *procold pointer to the message to clone
- Returns:
- DESSERT_OK on success, -errno otherwise
void dessert_msg_proc_destroy | ( | dessert_msg_proc_t * | proc | ) |
free a dessert_prc_msg
- *proc processing buffer to free
void dessert_msg_proc_dump | ( | const dessert_msg_t * | msg, | |
size_t | len, | |||
const dessert_msg_proc_t * | proc, | |||
char * | buf, | |||
size_t | blen | |||
) |
dump a dessert_msg_t to a string
- *msg the message to be dumped
- len the length of the buffer
- *proc the processing buffer
- *buf text output buffer
- blen text output buffer length

int dessert_msg_resizeext | ( | dessert_msg_t * | msg, | |
dessert_ext_t * | ext, | |||
size_t | new_len | |||
) |
Resizes a given extension record ext within in a dessert message msg to the new length new_len.
- Parameters:
-
[in] *msg the message [in] *ext the extension record [in] new_len the new length of the extension record
- Return values:
-
DESSERT_OK on success
DESCRIPTION:
int dessert_msg_trace_cb | ( | dessert_msg_t * | msg, | |
size_t | len, | |||
dessert_msg_proc_t * | proc, | |||
const dessert_meshif_t * | iface, | |||
dessert_frameid_t | id | |||
) |
check if the message carries a trace extension and add the current trace info if iface is NULL, the packet is ignored
- *msg dessert_msg_t frame received
- len length of ethernet frame received
- *iface interface received packet on ®return DESSERT_MSG_KEEP always