The friendly Operating System for the Internet of Things
netapi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
58 #ifndef GNRC_NETAPI_H
59 #define GNRC_NETAPI_H
60 
61 #include "thread.h"
62 #include "net/netopt.h"
63 #include "net/gnrc/nettype.h"
64 #include "net/gnrc/pkt.h"
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
73 #define GNRC_NETAPI_MSG_TYPE_RCV (0x0201)
74 
78 #define GNRC_NETAPI_MSG_TYPE_SND (0x0202)
79 
83 #define GNRC_NETAPI_MSG_TYPE_SET (0x0203)
84 
88 #define GNRC_NETAPI_MSG_TYPE_GET (0x0204)
89 
93 #define GNRC_NETAPI_MSG_TYPE_ACK (0x0205)
94 
99 typedef struct {
101  uint16_t context;
102  void *data;
103  uint16_t data_len;
105 
116 
127 int gnrc_netapi_dispatch(gnrc_nettype_t type, uint32_t demux_ctx, uint16_t cmd,
128  gnrc_pktsnip_t *pkt);
129 
140 static inline int gnrc_netapi_dispatch_send(gnrc_nettype_t type, uint32_t demux_ctx,
141  gnrc_pktsnip_t *pkt)
142 {
143  return gnrc_netapi_dispatch(type, demux_ctx, GNRC_NETAPI_MSG_TYPE_SND, pkt);
144 }
145 
156 
167 static inline int gnrc_netapi_dispatch_receive(gnrc_nettype_t type, uint32_t demux_ctx,
168  gnrc_pktsnip_t *pkt)
169 {
170  return gnrc_netapi_dispatch(type, demux_ctx, GNRC_NETAPI_MSG_TYPE_RCV, pkt);
171 }
172 
188 int gnrc_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context,
189  void *data, size_t max_len);
190 
206 int gnrc_netapi_set(kernel_pid_t pid, netopt_t opt, uint16_t context,
207  void *data, size_t data_len);
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* GNRC_NETAPI_H */
214 
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).
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
General definitions for network packets and their helper functions.
Data structure to be send for setting (GNRC_NETAPI_MSG_TYPE_SET) and getting (GNRC_NETAPI_MSG_TYPE_GE...
Definition: netapi.h:99
void * data
data to set or buffer to read into
Definition: netapi.h:102
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). ...
Definition: netapi.h:140
int gnrc_netapi_receive(kernel_pid_t pid, gnrc_pktsnip_t *pkt)
Shortcut function for sending GNRC_NETAPI_MSG_TYPE_RCV messages.
netopt_t opt
the option to get/set
Definition: netapi.h:100
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). ...
Definition: netapi.h:167
uint16_t context
(optional) context for that option
Definition: netapi.h:101
Threading API.
netopt_t
Global list of configuration options available throughout the network stack, e.g. ...
Definition: netopt.h:36
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_...
uint16_t data_len
size of the data / the buffer
Definition: netapi.h:103
#define GNRC_NETAPI_MSG_TYPE_RCV
Messaging / IPC type for passing a Packet up the network stack
Definition: netapi.h:73
Definition of global configuration options.
int gnrc_netapi_send(kernel_pid_t pid, gnrc_pktsnip_t *pkt)
Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SND messages.
#define GNRC_NETAPI_MSG_TYPE_SND
Messaging / IPC type for passing a Packet down the network stack
Definition: netapi.h:78
Type to represent parts (either headers or payload) of a packet, called snips.
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition: nettype.h:42
Protocol type definitions.
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_...