netapi.h

Generic interface to communicate with GNRC modules.

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)
int gnrc_netapi_send(kernel_types.h::kernel_pid_t pid, include/net/gnrc/pkt.h::gnrc_pktsnip_t * pkt)

Shortcut function for sending netapi.h::GNRC_NETAPI_MSG_TYPE_SND messages.

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_t type, uint32_t demux_ctx, uint16_t cmd, include/net/gnrc/pkt.h::gnrc_pktsnip_t * pkt)

Sends cmd to 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).
int gnrc_netapi_dispatch_send(nettype.h::gnrc_nettype_t type, uint32_t demux_ctx, include/net/gnrc/pkt.h::gnrc_pktsnip_t * pkt)

Sends a netapi.h::GNRC_NETAPI_MSG_TYPE_SND command 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).
int gnrc_netapi_receive(kernel_types.h::kernel_pid_t pid, include/net/gnrc/pkt.h::gnrc_pktsnip_t * pkt)

Shortcut function for sending netapi.h::GNRC_NETAPI_MSG_TYPE_RCV messages.

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_t type, uint32_t demux_ctx, include/net/gnrc/pkt.h::gnrc_pktsnip_t * pkt)

Sends a netapi.h::GNRC_NETAPI_MSG_TYPE_RCV command 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).
int gnrc_netapi_get(kernel_types.h::kernel_pid_t pid, netopt.h::netopt_t opt, uint16_t context, void * data, msp430_types.h::size_t max_len)

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

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 data

Return values

  • value returned by the netapi.h::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_set(kernel_types.h::kernel_pid_t pid, netopt.h::netopt_t opt, uint16_t context, const void * data, msp430_types.h::size_t data_len)

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

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 data

Return values

  • value returned by the netapi.h::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.
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_t opt

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