GNRC communication interface

Generic interface for IPC communication between GNRC modules. More...

Detailed Description

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.

Modules

 Callback extension
 Callback extension for GNRC communication interface.
 
 Mailbox IPC extension
 Mailbox IPC extension for GNRC communication interface
 
 NETAPI test framework
 This provides a framework to test the GNRC communication interface IPC calls.
 

Files

file  netapi.h
 Generic interface to communicate with GNRC modules.
 

Data Structures

struct  gnrc_netapi_opt_t
 Data structure to be send for setting (GNRC_NETAPI_MSG_TYPE_SET) and getting (GNRC_NETAPI_MSG_TYPE_GET) options. More...
 

Macros

#define GNRC_NETAPI_MSG_TYPE_RCV   (0x0201)
 Messaging / IPC type for passing a Packet up the network stack More...
 
#define GNRC_NETAPI_MSG_TYPE_SND   (0x0202)
 Messaging / IPC type for passing a Packet down the network stack
 
#define GNRC_NETAPI_MSG_TYPE_SET   (0x0203)
 Messaging / IPC type for setting options of network modules
 
#define GNRC_NETAPI_MSG_TYPE_GET   (0x0204)
 Messaging / IPC type for getting options from network modules
 
#define GNRC_NETAPI_MSG_TYPE_ACK   (0x0205)
 Messaging / IPC type for replying to get and set option messages
 

Functions

int gnrc_netapi_send (kernel_pid_t pid, gnrc_pktsnip_t *pkt)
 Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SND messages. More...
 
int gnrc_netapi_dispatch (gnrc_nettype_t type, uint32_t demux_ctx, uint16_t cmd, gnrc_pktsnip_t *pkt)
 Sends cmd to all subscribers to (type, demux_ctx). More...
 
static int gnrc_netapi_dispatch_send (gnrc_nettype_t type, uint32_t demux_ctx, gnrc_pktsnip_t *pkt)
 Sends a GNRC_NETAPI_MSG_TYPE_SND command to all subscribers to (type, demux_ctx). More...
 
int gnrc_netapi_receive (kernel_pid_t pid, gnrc_pktsnip_t *pkt)
 Shortcut function for sending GNRC_NETAPI_MSG_TYPE_RCV messages. More...
 
static int gnrc_netapi_dispatch_receive (gnrc_nettype_t type, uint32_t demux_ctx, gnrc_pktsnip_t *pkt)
 Sends a GNRC_NETAPI_MSG_TYPE_RCV command to all subscribers to (type, demux_ctx). More...
 
int gnrc_netapi_get (kernel_pid_t pid, netopt_t opt, uint16_t context, void *data, size_t max_len)
 Shortcut function for sending GNRC_NETAPI_MSG_TYPE_GET messages and parsing the returned GNRC_NETAPI_MSG_TYPE_ACK message. More...
 
int gnrc_netapi_set (kernel_pid_t pid, netopt_t opt, uint16_t context, void *data, size_t data_len)
 Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SET messages and parsing the returned GNRC_NETAPI_MSG_TYPE_ACK message. More...
 

Macro Definition Documentation

#define GNRC_NETAPI_MSG_TYPE_RCV   (0x0201)

Function Documentation

int gnrc_netapi_dispatch ( gnrc_nettype_t  type,
uint32_t  demux_ctx,
uint16_t  cmd,
gnrc_pktsnip_t pkt 
)
Parameters
[in]typetype of the targeted network module.
[in]demux_ctxdemultiplexing context for type.
[in]cmdcommand for all subscribers
[in]pktpointer into the packet buffer holding the data to send
Returns
Number of subscribers to (type, demux_ctx).
static int gnrc_netapi_dispatch_receive ( gnrc_nettype_t  type,
uint32_t  demux_ctx,
gnrc_pktsnip_t pkt 
)
inlinestatic
Parameters
[in]typetype of the targeted network module.
[in]demux_ctxdemultiplexing context for type.
[in]pktpointer into the packet buffer holding the data to send
Returns
Number of subscribers to (type, demux_ctx).

Definition at line 167 of file netapi.h.

static int gnrc_netapi_dispatch_send ( gnrc_nettype_t  type,
uint32_t  demux_ctx,
gnrc_pktsnip_t pkt 
)
inlinestatic
Parameters
[in]typetype of the targeted network module.
[in]demux_ctxdemultiplexing context for type.
[in]pktpointer into the packet buffer holding the data to send
Returns
Number of subscribers to (type, demux_ctx).

Definition at line 140 of file netapi.h.

int gnrc_netapi_get ( kernel_pid_t  pid,
netopt_t  opt,
uint16_t  context,
void *  data,
size_t  max_len 
)
Parameters
[in]pidPID of the targeted network module
[in]optoption to get
[in]context(optional) context to the given option
[in]datapointer to buffer for reading the option's value
[in]max_lenmaximum number of bytes that fit into data
Returns
value returned by the GNRC_NETAPI_MSG_TYPE_ACK message 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.
int gnrc_netapi_receive ( kernel_pid_t  pid,
gnrc_pktsnip_t pkt 
)
Parameters
[in]pidPID of the targeted network module
[in]pktpointer into the packet buffer holding the received data
Returns
1 if packet was successfully delivered
-1 on error (invalid PID or no space in queue)
int gnrc_netapi_send ( kernel_pid_t  pid,
gnrc_pktsnip_t pkt 
)
Parameters
[in]pidPID of the targeted network module
[in]pktpointer into the packet buffer holding the data to send
Returns
1 if packet was successfully delivered
-1 on error (invalid PID or no space in queue)
int gnrc_netapi_set ( kernel_pid_t  pid,
netopt_t  opt,
uint16_t  context,
void *  data,
size_t  data_len 
)
Parameters
[in]pidPID of the targeted network module
[in]optoption to set
[in]context(optional) context to the given option
[in]datadata to set the given option to
[in]data_lensize of data
Returns
value returned by the GNRC_NETAPI_MSG_TYPE_ACK message 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.