GNRC communication interface¶
Generic interface for IPC communication between GNRC modules.
The idea of this interface is that it provides every network module with a basic set of commands to communicate with its neighboring modules. In this model every module runs in its own thread and communication is done using the GNRC communication interface.
-
int
gnrc_netapi_send(kernel_types.h::kernel_pid_tpid,include/net/gnrc/pkt.h::gnrc_pktsnip_t* pkt)¶ Shortcut function for sending
netapi.h::GNRC_NETAPI_MSG_TYPE_SNDmessages.Parameters
pid: PID of the targeted network module pkt: pointer into the packet buffer holding the data to send Return values
- 1 if packet was successfully delivered
- -1 on error (invalid PID or no space in queue)
-
int
gnrc_netapi_dispatch(nettype.h::gnrc_nettype_ttype, uint32_t demux_ctx, uint16_t cmd,include/net/gnrc/pkt.h::gnrc_pktsnip_t* pkt)¶ Sends
cmdto all subscribers to (type,demux_ctx).Parameters
type: protocol type of the targeted network module. demux_ctx: demultiplexing context for type.cmd: command for all subscribers pkt: pointer into the packet buffer holding the data to send Return values
- Number of subscribers to (
type,demux_ctx).
- Number of subscribers to (
-
int
gnrc_netapi_dispatch_send(nettype.h::gnrc_nettype_ttype, uint32_t demux_ctx,include/net/gnrc/pkt.h::gnrc_pktsnip_t* pkt)¶ Sends a
netapi.h::GNRC_NETAPI_MSG_TYPE_SNDcommand to all subscribers to (type,demux_ctx).Parameters
type: protocol type of the targeted network module. demux_ctx: demultiplexing context for type.pkt: pointer into the packet buffer holding the data to send Return values
- Number of subscribers to (
type,demux_ctx).
- Number of subscribers to (
-
int
gnrc_netapi_receive(kernel_types.h::kernel_pid_tpid,include/net/gnrc/pkt.h::gnrc_pktsnip_t* pkt)¶ Shortcut function for sending
netapi.h::GNRC_NETAPI_MSG_TYPE_RCVmessages.Parameters
pid: PID of the targeted network module pkt: pointer into the packet buffer holding the received data Return values
- 1 if packet was successfully delivered
- -1 on error (invalid PID or no space in queue)
-
int
gnrc_netapi_dispatch_receive(nettype.h::gnrc_nettype_ttype, uint32_t demux_ctx,include/net/gnrc/pkt.h::gnrc_pktsnip_t* pkt)¶ Sends a
netapi.h::GNRC_NETAPI_MSG_TYPE_RCVcommand to all subscribers to (type,demux_ctx).Parameters
type: protocol type of the targeted network module. demux_ctx: demultiplexing context for type.pkt: pointer into the packet buffer holding the data to send Return values
- Number of subscribers to (
type,demux_ctx).
- Number of subscribers to (
-
int
gnrc_netapi_get(kernel_types.h::kernel_pid_tpid,netopt.h::netopt_topt, uint16_t context, void * data,msp430_types.h::size_tmax_len)¶ Shortcut function for sending
netapi.h::GNRC_NETAPI_MSG_TYPE_GETmessages and parsing the returnednetapi.h::GNRC_NETAPI_MSG_TYPE_ACKmessage.Parameters
pid: PID of the targeted network module opt: option to get context: (optional) context to the given option data: pointer to buffer for reading the option’s value max_len: maximum number of bytes that fit into dataReturn values
- value returned by the
netapi.h::GNRC_NETAPI_MSG_TYPE_ACKmessage i.e. the actual length of the resulting data on success, a negative errno on error. The actual error value is for the implementation to decide but should be sensible to indicate what went wrong.
- value returned by the
-
int
gnrc_netapi_set(kernel_types.h::kernel_pid_tpid,netopt.h::netopt_topt, uint16_t context, const void * data,msp430_types.h::size_tdata_len)¶ Shortcut function for sending
netapi.h::GNRC_NETAPI_MSG_TYPE_SETmessages and parsing the returnednetapi.h::GNRC_NETAPI_MSG_TYPE_ACKmessage.Parameters
pid: PID of the targeted network module opt: option to set context: (optional) context to the given option data: data to set the given option to data_len: size of dataReturn values
- value returned by the
netapi.h::GNRC_NETAPI_MSG_TYPE_ACKmessage i.e. 0 on success, a negative errno on error. The actual error value is for the implementation to decide but should be sensible to indicate what went wrong.
- value returned by the
-
GNRC_NETAPI_MSG_TYPE_RCV¶ Messaging / IPC type for passing a Packet up the network stack
1
(0x0201)
-
GNRC_NETAPI_MSG_TYPE_SND¶ Messaging / IPC type for passing a Packet down the network stack
1
(0x0202)
-
GNRC_NETAPI_MSG_TYPE_SET¶ Messaging / IPC type for setting options of network modules
1
(0x0203)
-
GNRC_NETAPI_MSG_TYPE_GET¶ Messaging / IPC type for getting options from network modules
1
(0x0204)
-
GNRC_NETAPI_MSG_TYPE_ACK¶ Messaging / IPC type for replying to get and set option messages
1
(0x0205)
-
struct
gnrc_netapi_opt_t¶ Data structure to be send for setting (
netapi.h::GNRC_NETAPI_MSG_TYPE_SET) and getting (netapi.h::GNRC_NETAPI_MSG_TYPE_GET) options.-
netopt.h::netopt_topt¶ the option to get/set
-
uint16_t
context¶ (optional) context for that option
-
void *
data¶ data to set or buffer to read into
-
uint16_t
data_len¶ size of the data / the buffer
-