zep.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 
21 #ifndef NET_ZEP_H
22 #define NET_ZEP_H
23 
24 #include <stdint.h>
25 
26 #include "byteorder.h"
27 #include "net/ntp_packet.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define ZEP_PORT_DEFAULT (17754)
38 #define ZEP_V2_TYPE_DATA (1)
39 
43 #define ZEP_V2_TYPE_ACK (2)
44 
48 #define ZEP_LENGTH_MASK (0x7f)
49 
53 typedef struct __attribute__((packed)) {
54  char preamble[2];
55  uint8_t version;
56 } zep_hdr_t;
57 
62 typedef struct __attribute__((packed)) {
64  uint8_t chan;
66  uint8_t lqi_mode;
67  uint8_t lqi_val;
68  uint8_t resv[7];
69  uint8_t length;
70 } zep_v1_hdr_t;
71 
76 typedef struct __attribute__((packed)) {
78  uint8_t type;
79  uint8_t chan;
81  uint8_t lqi_mode;
82  uint8_t lqi_val;
85  uint8_t resv[10];
86  uint8_t length;
88 
93 typedef struct __attribute__((packed)) {
95  uint8_t type;
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* NET_ZEP_H */
Functions to work with different byte orders.
NTP packet definitions.
NTP timestamp.
Definition: ntp_packet.h:73
ZEP header definition.
Definition: zep.h:53
uint8_t version
Protocol Version (must be 1 or 2)
Definition: zep.h:55
ZEPv1 header definition.
Definition: zep.h:62
uint8_t lqi_mode
CRC/LQI Mode (0: append LQI to frame, 1: append FCS)
Definition: zep.h:66
uint8_t lqi_val
LQI value.
Definition: zep.h:67
network_uint16_t dev
device ID
Definition: zep.h:65
zep_hdr_t hdr
common header fields
Definition: zep.h:63
uint8_t chan
channel ID
Definition: zep.h:64
uint8_t length
length of the frame
Definition: zep.h:69
ZEPv2 header definition (type == Ack)
Definition: zep.h:93
network_uint32_t seq
Sequence number.
Definition: zep.h:96
zep_hdr_t hdr
common header fields
Definition: zep.h:94
uint8_t type
type (must be ZEP_V2_TYPE_ACK)
Definition: zep.h:95
ZEPv2 header definition (type == Data)
Definition: zep.h:76
ntp_timestamp_t time
NTP timestamp.
Definition: zep.h:83
uint8_t chan
channel ID
Definition: zep.h:79
zep_hdr_t hdr
common header fields
Definition: zep.h:77
uint8_t type
type (must be ZEP_V2_TYPE_DATA)
Definition: zep.h:78
uint8_t lqi_val
LQI value.
Definition: zep.h:82
network_uint16_t dev
device ID
Definition: zep.h:80
uint8_t length
length of the frame
Definition: zep.h:86
network_uint32_t seq
Sequence number.
Definition: zep.h:84
uint8_t lqi_mode
CRC/LQI Mode.
Definition: zep.h:81
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:74
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:84