-
Notifications
You must be signed in to change notification settings - Fork 2k
/
socket_zep.h
140 lines (130 loc) · 4.53 KB
/
socket_zep.h
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* 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 drivers_socket_zep Socket-based ZEP
* @ingroup drivers_netdev
* @brief UDP socket-based IEEE 802.15.4 device over ZEP
*
* @see @ref net_zep for protocol definitions
*
* This ZEP implementation can send a dummy HELLO packet on startup.
* This is used to make dispatchers aware of the node.
* To enable this behavior, add
*
* ```
* USEMODULE += socket_zep_hello
* ```
*
* to your Makefile.
*
* A ZEP dispatcher can just drop those packets (ZEP type 0xFF) if it
* chooses to parse the ZEP header.
*
* The header of the HELLO packet will look like this:
*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Preamble (EX) | Version (2) | Type (255) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* + +
* | |
* + Reserved (0) +
* | |
* + +
* | |
* + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | | 'H' | 'E' | 'L' |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | 'L' | 'O' | 0 | 0 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | 0 | 0 | 0 | 0 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* @{
*
* @file
* @brief Socket ZEP definitions
*
* @author Martine Lenders <m.lenders@fu-berlin.de>
*/
#ifndef SOCKET_ZEP_H
#define SOCKET_ZEP_H
#include "net/netdev.h"
#include "net/netdev/ieee802154.h"
#include "net/ieee802154/radio.h"
#include "net/zep.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief ZEP device initialization parameters
*/
typedef struct {
char *local_addr; /**< local address string */
char *local_port; /**< local address string */
char *remote_addr; /**< remote address string */
char *remote_port; /**< local address string */
} socket_zep_params_t;
/**
* @brief ZEP device state
*/
typedef struct {
/**
* @brief command line parameters
*/
const socket_zep_params_t *params;
int sock_fd; /**< socket fd */
uint32_t seq; /**< ZEP sequence number */
/**
* @brief Receive buffer
*/
uint8_t rcv_buf[sizeof(zep_v2_data_hdr_t) + IEEE802154_FRAME_LEN_MAX];
/**
* @brief Send buffer
*/
uint8_t snd_buf[sizeof(zep_v2_data_hdr_t) + IEEE802154_FRAME_LEN_MAX];
uint8_t snd_len; /**< bytes to send */
uint16_t pan_id; /**< PAN ID of the ZEP network */
uint16_t chan; /**< virtual radio channel */
/**
* @brief Short address of the virtual radio
*/
uint8_t addr_short[IEEE802154_SHORT_ADDRESS_LEN];
/**
* @brief Long address of the virtual radio
*/
uint8_t addr_long[IEEE802154_LONG_ADDRESS_LEN];
ieee802154_filter_mode_t filter_mode; /**< frame filter mode */
ieee802154_trx_state_t state; /**< radio state */
bool send_hello; /**< send HELLO packet on connect */
} socket_zep_t;
/**
* @brief Setup socket_zep_t structure
*
* @param[in] dev the preallocated socket_zep_t device handle to setup
* @param[in] params initialization parameters
*/
void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params);
/**
* @brief Cleanup socket resources
*
* @param dev the socket_zep device handle to cleanup
*/
void socket_zep_cleanup(socket_zep_t *dev);
/**
* @brief Setup socket ZEP in order to be used with the IEEE 802.15.4 Radio HAL
*
* @param[in] dev pointer to the socket ZEP instance
* @param[in] hal pointer to the HAL descriptor associated to the device
*/
void socket_zep_hal_setup(socket_zep_t *dev, ieee802154_dev_t *hal);
#ifdef __cplusplus
}
#endif
#endif /* SOCKET_ZEP_H */
/** @} */