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.

Topics

 Callback extension
 Callback extension for GNRC communication interface.
 
 Mailbox IPC extension
 Mailbox IPC extension for GNRC communication interface
 
 Notification events for network APIs.
 Network event notification types.
 

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/set option, and notify messages
 
#define GNRC_NETAPI_MSG_TYPE_NOTIFY   (0x0207)
 Messaging / IPC type for sending a general event notifications to one or more subscribers
 

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).
 
int gnrc_netapi_notify (gnrc_nettype_t type, uint32_t demux_ctx, netapi_notify_t event, void *data, size_t data_len)
 Sends a GNRC_NETAPI_MSG_TYPE_NOTIFY 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/set option, and notify 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_NOTIFY

#define GNRC_NETAPI_MSG_TYPE_NOTIFY   (0x0207)

Messaging / IPC type for sending a general event notifications to one or more subscribers

This sends back a GNRC_NETAPI_MSG_TYPE_ACK, so it should be used with msg_send_receive().

Definition at line 101 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 236 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 188 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 257 of file netapi.h.

◆ gnrc_netapi_notify()

int gnrc_netapi_notify ( gnrc_nettype_t type,
uint32_t demux_ctx,
netapi_notify_t event,
void * data,
size_t data_len )

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

Note
This blocks the sender until all registered subscribers have ack'ed the notification or sending has failed. The data can be freed after the function returned.
Parameters
[in]typeType of the targeted network module.
[in]demux_ctxDemultiplexing context for type.
[in]eventNotification event type.
[in]dataData associated with the event.
[in]data_lenSize of data.
Returns
Number of subscribers to (type, demux_ctx).

◆ 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 221 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 160 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 279 of file netapi.h.