Digi XBee(R) ANSI C Host Library
secure_session.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Digi International Inc.,
3  * All rights not expressly granted are reserved.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
7  * You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * Digi International Inc., 9350 Excelsior Blvd., Suite 700, Hopkins, MN 55343
10  * ===========================================================================
11  */
12 
22 #ifndef XBEE_SECURE_SESSION_H
23 #define XBEE_SECURE_SESSION_H
24 
25 #include "xbee/platform.h"
26 #include "xbee/device.h"
27 #include "wpan/types.h"
28 
30 
36 #define XBEE_CMD_ATSA_REMOTE_AT (1<<1)
38 
40 #define XBEE_CMD_ATSA_SERIAL_DATA (1<<2)
41 
44 #define XBEE_FRAME_SECURE_SESSION_REQ 0x2E
46 
48 typedef XBEE_PACKED(xbee_header_secure_session_req_t, {
50  uint8_t frame_type;
51 
53  addr64 remote_addr_be;
54 
56  uint8_t options;
57 
60  uint16_t timeout_be;
61 
62  // header followed by variable-length password
64 
70 #define XBEE_SS_REQ_OPT_CLIENT_LOGIN (0)
72 
74 #define XBEE_SS_REQ_OPT_CLIENT_LOGOUT (1<<0)
75 
78 #define XBEE_SS_REQ_OPT_SERVER_TERMINATION (1<<1)
79 
81 #define XBEE_SS_REQ_OPT_TIMEOUT_FIXED (0)
82 
84 #define XBEE_SS_REQ_OPT_TIMEOUT_INTER_PACKET (1<<2)
85 
92 #define XBEE_SS_REQ_TIMEOUT_UNITS_PER_SEC 10
94 
96 #define XBEE_SS_REQ_TIMEOUT_MAX (30 * 60 * XBEE_SS_REQ_TIMEOUT_UNITS_PER_SEC)
97 
99 #define XBEE_SS_REQ_TIMEOUT_YIELDING 0x0000
100 
128  const addr64 *dest_be,
129  uint8_t options,
130  uint16_t timeout_ds,
131  const char *password);
132 
133 
135 #define XBEE_FRAME_SECURE_SESSION_RESP 0xAE
136 
138 typedef XBEE_PACKED(xbee_frame_secure_session_resp_t, {
140  uint8_t frame_type;
141 
143  uint8_t type;
144 
146  addr64 remote_addr_be;
147 
149  uint8_t status;
150 
152 
158 #define XBEE_SS_RESP_TYPE_LOGIN 0x00
160 
162 #define XBEE_SS_RESP_TYPE_LOGOUT 0x01
163 
171 #define XBEE_SS_RESP_STATUS_SUCCESS 0x00
173 
175 #define XBEE_SS_RESP_STATUS_INVALID_PW 0x01
176 
178 #define XBEE_SS_RESP_STATUS_BUSY 0x02
179 
181 #define XBEE_SS_RESP_STATUS_INVALID_ARG 0x03
182 
184 #define XBEE_SS_RESP_STATUS_NO_SESSION 0x04
185 
187 #define XBEE_SS_RESP_STATUS_TIMEOUT 0x05
188 
190 #define XBEE_SS_RESP_STATUS_NO_MEMORY 0x06
191 
193 #define XBEE_SS_RESP_STATUS_IN_PROGRESS 0x07
194 
196 #define XBEE_SS_RESP_STATUS_NO_PASSWORD 0x08
197 
199 #define XBEE_SS_RESP_STATUS_NO_RESPONSE 0x09
200 
202 #define XBEE_SS_RESP_STATUS_BAD_FRAME 0x0A
203 
205 #define XBEE_SS_RESP_STATUS_SRP_WRONG_WAY 0x80
206 
208 #define XBEE_SS_RESP_STATUS_SRP_UNEXPECTED 0x81
209 
211 #define XBEE_SS_RESP_STATUS_SRP_MISORDERED 0x82
212 
214 #define XBEE_SS_RESP_STATUS_SRP_BAD_FRAME 0x83
215 
217 #define XBEE_SS_RESP_STATUS_SRP_BAD_PROTOCOL 0x84
218 
220 #define XBEE_SS_RESP_STATUS_UNDEFINED 0xFF
221 
225  const void FAR *payload,
226  uint16_t length,
227  void FAR *context);
228 
229 #define XBEE_FRAME_DUMP_SS_RESP \
230  { XBEE_FRAME_SECURE_SESSION_RESP, 0, \
231  xbee_frame_dump_secure_session_resp, NULL }
232 
234 #define XBEE_MODEM_STATUS_IS_SS(code) \
235  (code >= XBEE_MODEM_STATUS_SS_ESTABLISHED \
236  && code <= XBEE_MODEM_STATUS_SS_AUTH_FAILED)
237 
239 typedef XBEE_PACKED(xbee_frame_xms_ss_established_t, {
241  uint8_t frame_type;
242 
244  uint8_t status_code;
245 
247  addr64 remote_addr_be;
248 
250  uint8_t options;
251 
253  uint16_t timeout_be;
255 
257 typedef XBEE_PACKED(xbee_frame_xms_ss_ended_t, {
259  uint8_t frame_type;
260 
262  uint8_t status_code;
263 
265  addr64 remote_addr_be;
266 
268  uint8_t reason;
270 
277 #define XBEE_SS_END_REASON_REMOTE_TERM 0x00
279 #define XBEE_SS_END_REASON_TIMED_OUT 0x01
281 #define XBEE_SS_END_REASON_BAD_ENCRYPT_CTR 0x02
283 #define XBEE_SS_END_REASON_ENCRYPT_CTR_OVERFLOW 0x03
286 #define XBEE_SS_END_REASON_REMOTE_NO_MEMORY 0x04
288 
291 typedef XBEE_PACKED(xbee_frame_xms_ss_auth_failed_t, {
293  uint8_t frame_type;
294 
296  uint8_t status_code;
297 
299  addr64 remote_addr_be;
300 
302  uint8_t error;
304 
306  const void FAR *payload,
307  uint16_t length,
308  void FAR *context);
309 
311 
312 #endif // XBEE_SECURE_SESSION_H
313 
WPAN datatypes and support functions, valid for ZigBee and DigiMesh.
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
int xbee_frame_dump_ext_mod_status_ss(xbee_dev_t *xbee, const void FAR *payload, uint16_t length, void FAR *context)
Dump a parsed Extended Modem Status frame for a Secure Session code.
Definition: xbee_secure_session.c:65
Frame format for Extended Modem Status: Secure Session Ended.
Definition: secure_session.h:257
Frame format for the header of Secure Session Control frame.
Definition: secure_session.h:63
#define XBEE_BEGIN_DECLS
Macro defined to.
Definition: platform.h:41
Common header for Hardware Abstraction Layer.
int xbee_frame_dump_secure_session_resp(xbee_dev_t *xbee, const void FAR *payload, uint16_t length, void FAR *context)
Dump a parsed Secure Session Response frame.
Definition: xbee_secure_session.c:141
Frame format for Extended Modem Status: Secure Session Auth Failed.
Definition: secure_session.h:291
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
Frame format for Secure Session Response.
Definition: secure_session.h:138
unsigned char uint8_t
8-bit unsigned integer
Definition: platform_config.h:39
Typedef used to hold a 64-bit IEEE address, represented as 8 bytes, 4 16-bit values or 2 32-bit value...
Definition: types.h:34
Definition: device.h:361
#define XBEE_END_DECLS
Macro defined to.
Definition: platform.h:42
Frame format for Extended Modem Status: Secure Session Established.
Definition: secure_session.h:239
int xbee_secure_session_request(xbee_dev_t *xbee, const addr64 *dest_be, uint8_t options, uint16_t timeout_ds, const char *password)
Send a Secure Session Request (0x2A) frame.
Definition: xbee_secure_session.c:27