Loading...
Searching...
No Matches
GNRC communication interface

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

Detailed Description

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.

Modules

 Callback extension
 Callback extension for GNRC communication interface.
 
 Mailbox IPC extension
 Mailbox IPC extension for GNRC communication interface
 

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
 
#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_recv (kernel_pid_t pid, gnrc_pktsnip_t *pkt, uint16_t type)
 Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SND or GNRC_NETAPI_MSG_TYPE_RCV messages.
 
int _gnrc_netapi_get_set (kernel_pid_t pid, netopt_t opt, uint16_t context, void *data, size_t data_len, uint16_t type)
 Shortcut function for sending GNRC_NETAPI_MSG_TYPE_GET or GNRC_NETAPI_MSG_TYPE_SET messages and parsing the returned GNRC_NETAPI_MSG_TYPE_ACK message.
 
static int gnrc_netapi_send (kernel_pid_t pid, gnrc_pktsnip_t *pkt)
 Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SND messages.
 
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).
 
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).
 
static int gnrc_netapi_receive (kernel_pid_t pid, gnrc_pktsnip_t *pkt)
 Shortcut function for sending GNRC_NETAPI_MSG_TYPE_RCV messages.
 
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).
 
static 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.
 
static int gnrc_netapi_set (kernel_pid_t pid, netopt_t opt, uint16_t context, const 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.
 

Macro Definition Documentation

◆ GNRC_NETAPI_MSG_TYPE_ACK

#define GNRC_NETAPI_MSG_TYPE_ACK   (0x0205)

Messaging / IPC type for replying to get and set option messages

Definition at line 94 of file netapi.h.

◆ GNRC_NETAPI_MSG_TYPE_GET

#define GNRC_NETAPI_MSG_TYPE_GET   (0x0204)

Messaging / IPC type for getting options from network modules

Definition at line 89 of file netapi.h.

◆ GNRC_NETAPI_MSG_TYPE_RCV

#define GNRC_NETAPI_MSG_TYPE_RCV   (0x0201)

Messaging / IPC type for passing a Packet up the network stack

Definition at line 74 of file netapi.h.

◆ GNRC_NETAPI_MSG_TYPE_SET

#define GNRC_NETAPI_MSG_TYPE_SET   (0x0203)

Messaging / IPC type for setting options of network modules

Definition at line 84 of file netapi.h.

◆ GNRC_NETAPI_MSG_TYPE_SND

#define GNRC_NETAPI_MSG_TYPE_SND   (0x0202)

Messaging / IPC type for passing a Packet down the network stack

Definition at line 79 of file netapi.h.

Function Documentation

◆ _gnrc_netapi_get_set()

int _gnrc_netapi_get_set ( kernel_pid_t  pid,
netopt_t  opt,
uint16_t  context,
void *  data,
size_t  data_len,
uint16_t  type 
)

Shortcut function for sending GNRC_NETAPI_MSG_TYPE_GET or GNRC_NETAPI_MSG_TYPE_SET messages and parsing the returned GNRC_NETAPI_MSG_TYPE_ACK message.

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]data_len(maximum) number of bytes in data
[in]typetype of the message to send. Must be either GNRC_NETAPI_MSG_TYPE_GET or GNRC_NETAPI_MSG_TYPE_SET
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.

◆ _gnrc_netapi_send_recv()

int _gnrc_netapi_send_recv ( kernel_pid_t  pid,
gnrc_pktsnip_t pkt,
uint16_t  type 
)

Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SND or GNRC_NETAPI_MSG_TYPE_RCV messages.

Parameters
[in]pidPID of the targeted network module
[in]pktpointer into the packet buffer holding the data to send
[in]typetype of the message to send. Must be either GNRC_NETAPI_MSG_TYPE_SND or GNRC_NETAPI_MSG_TYPE_RCV
Returns
1 if packet was successfully delivered
-1 on error (invalid PID or no space in queue)

◆ gnrc_netapi_dispatch()

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).

Parameters
[in]typeprotocol type 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).

◆ gnrc_netapi_dispatch_receive()

static int gnrc_netapi_dispatch_receive ( gnrc_nettype_t  type,
uint32_t  demux_ctx,
gnrc_pktsnip_t pkt 
)
inlinestatic

Sends a GNRC_NETAPI_MSG_TYPE_RCV command to all subscribers to (type, demux_ctx).

Parameters
[in]typeprotocol type 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 211 of file netapi.h.

◆ gnrc_netapi_dispatch_send()

static int gnrc_netapi_dispatch_send ( gnrc_nettype_t  type,
uint32_t  demux_ctx,
gnrc_pktsnip_t pkt 
)
inlinestatic

Sends a GNRC_NETAPI_MSG_TYPE_SND command to all subscribers to (type, demux_ctx).

Parameters
[in]typeprotocol type 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 181 of file netapi.h.

◆ gnrc_netapi_get()

static int gnrc_netapi_get ( kernel_pid_t  pid,
netopt_t  opt,
uint16_t  context,
void *  data,
size_t  max_len 
)
inlinestatic

Shortcut function for sending GNRC_NETAPI_MSG_TYPE_GET messages and parsing the returned GNRC_NETAPI_MSG_TYPE_ACK message.

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.

Definition at line 232 of file netapi.h.

◆ gnrc_netapi_receive()

static int gnrc_netapi_receive ( kernel_pid_t  pid,
gnrc_pktsnip_t pkt 
)
inlinestatic

Shortcut function for sending GNRC_NETAPI_MSG_TYPE_RCV messages.

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)

Definition at line 196 of file netapi.h.

◆ gnrc_netapi_send()

static int gnrc_netapi_send ( kernel_pid_t  pid,
gnrc_pktsnip_t pkt 
)
inlinestatic

Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SND messages.

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)

Definition at line 153 of file netapi.h.

◆ gnrc_netapi_set()

static int gnrc_netapi_set ( kernel_pid_t  pid,
netopt_t  opt,
uint16_t  context,
const void *  data,
size_t  data_len 
)
inlinestatic

Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SET messages and parsing the returned GNRC_NETAPI_MSG_TYPE_ACK message.

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.

Definition at line 254 of file netapi.h.