netreg.h¶
Definitions to register network protocol PIDs to use with GNRC communication interface.
-
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_ctxfor 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_ctxfor 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_ctxfor 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_tpid)¶ Initializes a netreg entry dynamically with PID.
Parameters
entry: A netreg entry demux_ctx: The netreg.h::gnrc_netreg_entry::demux_ctxfor 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_ctxfor 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_ctxfor the netreg entrycbd: Target callback for the registry entry Note
Only available with Callback extension.
-
GNRC_NETREG_DEMUX_CTX_ALL¶ Demux context value to get all packets of a certain type.
1
(0xffff0000)
-
enum
gnrc_netreg_type_t¶ - GNRC_NETREG_TYPE_DEFAULT
= 0 Use default IPC for netapi operations.
Note
Implicitly chosen without
gnrc_netapi_mboxandgnrc_netapi_callbacksmodules.- GNRC_NETREG_TYPE_MBOX
Use centralized IPC for netapi operations.
Note
Only available with
gnrc_netapi_mboxmodule.- GNRC_NETREG_TYPE_CB
Use function callbacks for netapi operations.
Note
Only available with
gnrc_netapi_callbacksmodule.
- 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_SNDornetapi.h::GNRC_NETAPI_MSG_TYPE_RCVpkt: 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_ttype,netreg.h::gnrc_netreg_entry_t* entry)¶ Registers a thread to the registry.
The semantics are: Thread
netreg.h::gnrc_netreg_entry::pidis interested in packets of protocoltypewith contextnetreg.h::gnrc_netreg_entry::demux_ctx.Parameters
Return values
- 0 on success
- -EINVAL if
typewas < GNRC_NETTYPE_UNDEF or >= GNRC_NETTYPE_NUMOF
-
void
gnrc_netreg_unregister(nettype.h::gnrc_nettype_ttype,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_ttype, 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_ttype, uint32_t demux_ctx)¶ Returns number of entries with the same
netreg.h::gnrc_netreg_entry::typeandnetreg.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::typeandnetreg.h::gnrc_netreg_entry::demux_ctxas 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
entrywith the samenetreg.h::gnrc_netreg_entry::typeandnetreg.h::gnrc_netreg_entry::demux_ctxas 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
entryfitting 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_hdris 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::typeofhdr.
-
struct
gnrc_netreg_entry_cbd_t¶ Callback + Context descriptor.
Note
Only available with Callback extension.
-
netreg.h::gnrc_netreg_entry_cb_tcb¶ 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_ttype¶ Type of the registry entry.
Note
Only available with Mailbox IPC extension or Callback extension.
-
kernel_types.h::kernel_pid_tpid¶ 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 *