csp_cmp.h
Go to the documentation of this file.
1 /*
2 Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
3 Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
4 Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
5 
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10 
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15 
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
27 #ifndef _CSP_CMP_H_
28 #define _CSP_CMP_H_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <stdint.h>
35 #include <csp/csp.h>
36 #include <csp/arch/csp_clock.h>
37 
38 #define CSP_CMP_REQUEST 0x00
39 #define CSP_CMP_REPLY 0xff
40 
41 #define CSP_CMP_IDENT 1
42 #define CSP_CMP_IDENT_REV_LEN 20
43 #define CSP_CMP_IDENT_DATE_LEN 12
44 #define CSP_CMP_IDENT_TIME_LEN 9
45 #define CSP_CMP_ROUTE_SET 2
46 #define CSP_CMP_ROUTE_IFACE_LEN 11
47 #define CSP_CMP_IF_STATS 3
48 #define CSP_CMP_PEEK 4
49 #define CSP_CMP_PEEK_MAX_LEN 200
50 #define CSP_CMP_POKE 5
51 #define CSP_CMP_POKE_MAX_LEN 200
52 #define CSP_CMP_CLOCK 6
53 
55  uint8_t type;
56  uint8_t code;
57  union {
58  struct {
64  } ident;
65  struct {
66  uint8_t dest_node;
67  uint8_t next_hop_mac;
69  } route_set;
70  struct __attribute__((__packed__)) {
72  uint32_t tx;
73  uint32_t rx;
74  uint32_t tx_error;
75  uint32_t rx_error;
76  uint32_t drop;
77  uint32_t autherr;
78  uint32_t frame;
79  uint32_t txbytes;
80  uint32_t rxbytes;
81  uint32_t irq;
82  } if_stats;
83  struct {
84  uint32_t addr;
85  uint8_t len;
87  } peek;
88  struct {
89  uint32_t addr;
90  uint8_t len;
92  } poke;
94  };
95 } __attribute__ ((packed));
96 
97 #define CMP_SIZE(_memb) (sizeof(((struct csp_cmp_message *)0)->_memb) + sizeof(uint8_t) + sizeof(uint8_t))
98 
99 int csp_cmp(uint8_t node, uint32_t timeout, uint8_t code, int membsize, struct csp_cmp_message *msg);
100 
101 #define CMP_MESSAGE(_code, _memb) \
102 static inline int csp_cmp_##_memb(uint8_t node, uint32_t timeout, struct csp_cmp_message *msg) { \
103  return csp_cmp(node, timeout, _code, CMP_SIZE(_memb), msg); \
104 }
105 
112 
113 #ifdef __cplusplus
114 } /* extern "C" */
115 #endif
116 
117 #endif // _CSP_CMP_H_
118 
119 /* @} */
uint8_t code
Definition: csp_cmp.h:56
uint32_t txbytes
Definition: csp_cmp.h:79
char time[CSP_CMP_IDENT_TIME_LEN]
Definition: csp_cmp.h:63
struct csp_cmp_message::@0::@4 if_stats
char revision[CSP_CMP_IDENT_REV_LEN]
Definition: csp_cmp.h:61
#define CSP_CMP_CLOCK
Definition: csp_cmp.h:52
#define CSP_CMP_IDENT_REV_LEN
Definition: csp_cmp.h:42
uint32_t autherr
Definition: csp_cmp.h:77
uint8_t type
Definition: csp_cmp.h:55
uint8_t dest_node
Definition: csp_cmp.h:66
uint32_t tx
Definition: csp_cmp.h:72
Definition: csp_clock.h:36
#define CSP_CMP_IF_STATS
Definition: csp_cmp.h:47
uint32_t tx_error
Definition: csp_cmp.h:74
uint32_t frame
Definition: csp_cmp.h:78
#define CSP_CMP_IDENT
Definition: csp_cmp.h:41
#define CSP_CMP_IDENT_TIME_LEN
Definition: csp_cmp.h:44
uint32_t rx
Definition: csp_cmp.h:73
#define CSP_CMP_PEEK
Definition: csp_cmp.h:48
#define CSP_HOSTNAME_LEN
Definition: csp_types.h:220
#define CSP_CMP_ROUTE_SET
Definition: csp_cmp.h:45
#define CMP_MESSAGE(_code, _memb)
Definition: csp_cmp.h:101
char interface[CSP_CMP_ROUTE_IFACE_LEN]
Definition: csp_cmp.h:68
#define CSP_MODEL_LEN
Definition: csp_types.h:221
uint8_t len
Definition: csp_cmp.h:85
uint32_t irq
Definition: csp_cmp.h:81
csp_timestamp_t clock
Definition: csp_cmp.h:93
Definition: csp_cmp.h:54
struct csp_cmp_message::@0::@2 ident
struct csp_cmp_message::@0::@5 peek
char model[CSP_MODEL_LEN]
Definition: csp_cmp.h:60
uint32_t drop
Definition: csp_cmp.h:76
#define CSP_CMP_POKE_MAX_LEN
Definition: csp_cmp.h:51
#define CSP_CMP_POKE
Definition: csp_cmp.h:50
uint32_t rxbytes
Definition: csp_cmp.h:80
#define CSP_CMP_IDENT_DATE_LEN
Definition: csp_cmp.h:43
uint32_t addr
Definition: csp_cmp.h:84
char date[CSP_CMP_IDENT_DATE_LEN]
Definition: csp_cmp.h:62
#define CSP_CMP_ROUTE_IFACE_LEN
Definition: csp_cmp.h:46
uint8_t next_hop_mac
Definition: csp_cmp.h:67
#define CSP_CMP_PEEK_MAX_LEN
Definition: csp_cmp.h:49
struct csp_cmp_message::@0::@6 poke
char data[CSP_CMP_PEEK_MAX_LEN]
Definition: csp_cmp.h:86
int csp_cmp(uint8_t node, uint32_t timeout, uint8_t code, int membsize, struct csp_cmp_message *msg)
char hostname[CSP_HOSTNAME_LEN]
Definition: csp_cmp.h:59
uint32_t rx_error
Definition: csp_cmp.h:75
struct csp_cmp_message::@0::@3 route_set