gnrc_sock_internal.h
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright (C) 2016 Martine Lenders <mlenders@inf.fu-berlin.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_gnrc_sock GNRC-specific implementation of the sock API
* @ingroup net_gnrc
* @brief Provides an implementation of the @ref net_sock by the
* @ref net_gnrc
*
* @{
*
* @file
* @brief GNRC-specific types and function definitions
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef GNRC_SOCK_INTERNAL_H_
#define GNRC_SOCK_INTERNAL_H_
#include <stdbool.h>
#include <stdint.h>
#include "mbox.h"
#include "net/af.h"
#include "net/gnrc.h"
#include "net/gnrc/netreg.h"
#include "net/sock/ip.h"
#include "sock_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Internal helper functions for GNRC
* @internal
* @{
*/
/**
* @brief Checks if address family is not supported
* @internal
*/
static inline bool gnrc_af_not_supported(int af)
{
/* TODO: add AF_INET support */
return (af != AF_INET6);
}
/**
* @brief Check if end point points to any address
* @internal
*/
static inline bool gnrc_ep_addr_any(const sock_ip_ep_t *ep)
{
assert(ep != NULL);
const uint8_t *p = (uint8_t *)&ep->addr;
for (uint8_t i = 0; i < sizeof(ep->addr); i++) {
if (p[i] != 0) {
return false;
}
}
return true;
}
/**
* @brief Create a sock internally
* @internal
*/
void gnrc_sock_create(gnrc_sock_reg_t *reg, gnrc_nettype_t type, uint32_t demux_ctx);
/**
* @brief Receive a packet internally
* @internal
*/
ssize_t gnrc_sock_recv(gnrc_sock_reg_t *reg, gnrc_pktsnip_t **pkt, uint32_t timeout,
sock_ip_ep_t *remote);
/**
* @brief Send a packet internally
* @internal
*/
ssize_t gnrc_sock_send(gnrc_pktsnip_t *payload, sock_ip_ep_t *local,
const sock_ip_ep_t *remote, uint8_t nh);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* GNRC_SOCK_INTERNAL_H_ */
/** @} */