Network protocol registry¶
Registry to receive messages of a specified protocol type by GNRC.
-
GNRC_NETREG_ENTRY_INIT_PID
( demux_ctx, pid)¶ Initializes a netreg entry statically with PID.
1
{ NULL, demux_ctx, { pid } }
Parameters
demux_ctx: The netreg.h::gnrc_netreg_entry::demux_ctx
for the netreg entrypid: The PID of the registering thread Return values
- An initialized netreg entry
-
GNRC_NETREG_ENTRY_INIT_MBOX
( demux_ctx, mbox)¶ Initializes a netreg entry statically with mbox.
1 2 3
{ NULL, demux_ctx, \ GNRC_NETREG_TYPE_MBOX, \ { .mbox = mbox } }
Parameters
demux_ctx: The netreg.h::gnrc_netreg_entry::demux_ctx
for the netreg entrymbox: Target mailbox for the registry entry Note
Only available with Mailbox IPC extension.
Return values
- An initialized netreg entry
-
GNRC_NETREG_ENTRY_INIT_CB
( demux_ctx, cbd)¶ Initializes a netreg entry statically with callback.
1 2 3
{ NULL, demux_ctx, \ GNRC_NETREG_TYPE_CB, \ { .cbd = cbd } }
Parameters
demux_ctx: The netreg.h::gnrc_netreg_entry::demux_ctx
for the netreg entrycbd: Target callback for the registry entry Note
Only available with Callback extension.
Return values
- An initialized netreg entry
-
void
gnrc_netreg_entry_init_pid
(netreg.h::gnrc_netreg_entry_t
* entry, uint32_t demux_ctx,kernel_types.h::kernel_pid_t
pid)¶ Initializes a netreg entry dynamically with PID.
Parameters
entry: A netreg entry demux_ctx: The netreg.h::gnrc_netreg_entry::demux_ctx
for the netreg entrypid: The PID of the registering thread
-
void
gnrc_netreg_entry_init_mbox
(netreg.h::gnrc_netreg_entry_t
* entry, uint32_t demux_ctx, mbox_t * mbox)¶ Initializes a netreg entry dynamically with mbox.
Parameters
entry: A netreg entry demux_ctx: The netreg.h::gnrc_netreg_entry::demux_ctx
for the netreg entrymbox: Target mailbox for the registry entry Note
Only available with Mailbox IPC extension.
-
void
gnrc_netreg_entry_init_cb
(netreg.h::gnrc_netreg_entry_t
* entry, uint32_t demux_ctx, gnrc_netreg_entry_cbd_t * cbd)¶ Initializes a netreg entry dynamically with callback.
Parameters
entry: A netreg entry demux_ctx: The netreg.h::gnrc_netreg_entry::demux_ctx
for the netreg entrycbd: Target callback for the registry entry Note
Only available with Callback extension.
-
enum
gnrc_netreg_type_t
¶ - GNRC_NETREG_TYPE_DEFAULT
= 0
Use default IPC for netapi operations.
Note
Implicitly chosen without
gnrc_netapi_mbox
andgnrc_netapi_callbacks
modules.- GNRC_NETREG_TYPE_MBOX
Use centralized IPC for netapi operations.
Note
Only available with
gnrc_netapi_mbox
module.- GNRC_NETREG_TYPE_CB
Use function callbacks for netapi operations.
Note
Only available with
gnrc_netapi_callbacks
module.
- GNRC_NETREG_TYPE_DEFAULT
-
void(*
gnrc_netreg_entry_cb_t
()¶ Packet handler callback for netreg entries with callback.
Note
Only available with Callback extension.
Parameters
cmd: GNRC communication interface command type. Must be either netapi.h::GNRC_NETAPI_MSG_TYPE_SND
ornetapi.h::GNRC_NETAPI_MSG_TYPE_RCV
pkt: The packet to handle. ctx: Application context.
-
struct gnrc_netreg_entry
gnrc_netreg_entry_t
¶ Entry to the Network protocol registry.
-
void
gnrc_netreg_init
(void)¶ Initializes module.
-
int
gnrc_netreg_register
(nettype.h::gnrc_nettype_t
type,netreg.h::gnrc_netreg_entry_t
* entry)¶ Registers a thread to the registry.
The semantics are: Thread
netreg.h::gnrc_netreg_entry::pid
is interested in packets of protocoltype
with contextnetreg.h::gnrc_netreg_entry::demux_ctx
.Parameters
Return values
- 0 on success
- -EINVAL if
type
was < GNRC_NETTYPE_UNDEF or >= GNRC_NETTYPE_NUMOF
-
void
gnrc_netreg_unregister
(nettype.h::gnrc_nettype_t
type,netreg.h::gnrc_netreg_entry_t
* entry)¶ Removes a thread from the registry.
Parameters
type: Type of the protocol. entry: An entry you want to remove from the registry.
-
netreg.h::gnrc_netreg_entry_t
*gnrc_netreg_lookup
(nettype.h::gnrc_nettype_t
type, uint32_t demux_ctx)¶ Searches for entries with given parameters in the registry and returns the first found.
Parameters
type: Type of the protocol. demux_ctx: The demultiplexing context for the registered thread. See netreg.h::gnrc_netreg_entry::demux_ctx
.Return values
- The first entry fitting the given parameters on success
- NULL if no entry can be found.
-
int
gnrc_netreg_num
(nettype.h::gnrc_nettype_t
type, uint32_t demux_ctx)¶ Returns number of entries with the same
netreg.h::gnrc_netreg_entry::type
andnetreg.h::gnrc_netreg_entry::demux_ctx
.Parameters
type: Type of the protocol. demux_ctx: The demultiplexing context for the registered thread. See netreg.h::gnrc_netreg_entry::demux_ctx
.Return values
- Number of entries with the same
netreg.h::gnrc_netreg_entry::type
andnetreg.h::gnrc_netreg_entry::demux_ctx
as the given parameters.
- Number of entries with the same
-
netreg.h::gnrc_netreg_entry_t
*gnrc_netreg_getnext
(netreg.h::gnrc_netreg_entry_t
* entry)¶ Returns the next entry after
entry
with the samenetreg.h::gnrc_netreg_entry::type
andnetreg.h::gnrc_netreg_entry::demux_ctx
as the given entry.Parameters
entry: A registry entry retrieved by netreg.h::gnrc_netreg_lookup()
ornetreg.h::gnrc_netreg_getnext()
. Must not be NULL.Return values
- The next entry after
entry
fitting the given parameters on success - NULL if no entry new entry can be found.
- The next entry after
-
int
gnrc_netreg_calc_csum
(include/net/gnrc/pkt.h::gnrc_pktsnip_t
* hdr,include/net/gnrc/pkt.h::gnrc_pktsnip_t
* pseudo_hdr)¶ Calculates the checksum for a header.
Parameters
hdr: The header the checksum should be calculated for. pseudo_hdr: The header the pseudo header shall be generated from. NULL if none is needed. Return values
- 0, on success.
- -EINVAL, if
pseudo_hdr
is NULL but a pseudo header was required. - -ENOENT, if Network protocol registry does not know how to calculate checksum for
include/net/gnrc/pkt.h::gnrc_pktsnip::type
ofhdr
.
-
GNRC_NETREG_DEMUX_CTX_ALL
¶ Demux context value to get all packets of a certain type.
1
(0xffff0000)
-
struct
gnrc_netreg_entry_cbd_t
¶ Callback + Context descriptor.
Note
Only available with Callback extension.
-
netreg.h::gnrc_netreg_entry_cb_t
cb
¶ the callback
-
void *
ctx
¶ application context for the callback
-
-
struct
gnrc_netreg_entry
¶ Entry to the Network protocol registry.
-
struct gnrc_netreg_entry *
next
¶ next element in list
-
uint32_t
demux_ctx
¶ The demultiplexing context for the registering thread.
This can be defined by the network protocol themselves. E. g. protocol numbers / next header numbers in IPv4/IPv6, ports in UDP/TCP, or similar.
-
netreg.h::gnrc_netreg_type_t
type
¶ Type of the registry entry.
Note
Only available with Mailbox IPC extension or Callback extension.
-
kernel_types.h::kernel_pid_t
pid
¶ The PID of the registering thread.
-
mbox_t *
mbox
¶ Target mailbox for the registry entry.
Note
Only available with Mailbox IPC extension.
-
gnrc_netreg_entry_cbd_t *
cbd
¶ Target callback for the registry entry.
Note
Only available with Callback extension.
-
union gnrc_netreg_entry::@191
target
¶ Target for the registry entry.
-
struct gnrc_netreg_entry *