1 | #ifndef _RT_PROTOCOL_H |
---|
2 | #define _RT_PROTOCOL_H |
---|
3 | |
---|
4 | #include "libtrace.h" |
---|
5 | #ifdef HAVE_PCAP |
---|
6 | #include <pcap.h> |
---|
7 | #endif |
---|
8 | |
---|
9 | #define CAPTURE_PORT 3434 |
---|
10 | #define COLLECTOR_PORT 3435 |
---|
11 | |
---|
12 | #define RT_MAX_HDR_SIZE 256 |
---|
13 | #define MAX_SEQUENCE 2147483647 |
---|
14 | |
---|
15 | #define RT_DATA_SIMPLE 1000 |
---|
16 | #define RT_DATA_PCAP 2000 |
---|
17 | |
---|
18 | /* Procedure for adding new RT control types |
---|
19 | * ------------------------------------------- |
---|
20 | * |
---|
21 | * Add type to the enum list |
---|
22 | * Add a struct below (even if it is empty) |
---|
23 | * Update rt_get_capture_length |
---|
24 | * If type is intended to be sent TO clients, update rt_read_packet |
---|
25 | * Otherwise, update server implementations e.g. WDCAP |
---|
26 | * |
---|
27 | * Procedure for adding new RT data types |
---|
28 | * ---------------------------------------- |
---|
29 | * |
---|
30 | * If you are adding a new format: |
---|
31 | * RT_DATA_(new format) must be equal to RT_DATA_SIMPLE + |
---|
32 | * TRACE_FORMAT_(new_format) |
---|
33 | * Add a new dummy trace type to the rt_format_t structure |
---|
34 | * Set the dummy trace to NULL in rt_init_input |
---|
35 | * Update rt_set_format |
---|
36 | * |
---|
37 | * If you are adding a new PCAP DLT type: |
---|
38 | * RT_DATA_PCAP_(new DLT) must be equal to RT_DATA_PCAP + (DLT value) |
---|
39 | * |
---|
40 | */ |
---|
41 | |
---|
42 | /* Type field definitions */ |
---|
43 | enum rt_field_t { |
---|
44 | RT_HELLO =1, /* Connection accepted */ |
---|
45 | RT_START =2, /* Request for data transmission to begin */ |
---|
46 | RT_ACK =3, /* Data acknowledgement */ |
---|
47 | RT_STATUS =4, /* Fifo status packet */ |
---|
48 | RT_DUCK =5, /* Dag duck info packet */ |
---|
49 | RT_END_DATA =6, /* Server is exiting message */ |
---|
50 | RT_CLOSE =7, /* Client is exiting message */ |
---|
51 | RT_DENY_CONN =8, /* Connection has been denied */ |
---|
52 | RT_PAUSE =9, /* Request server to suspend sending data */ |
---|
53 | RT_PAUSE_ACK =10, /* Server is paused message */ |
---|
54 | RT_OPTION =11, /* Option request */ |
---|
55 | RT_KEYCHANGE =12, /* Anonymisation key has changed */ |
---|
56 | |
---|
57 | RT_DATA_ERF =RT_DATA_SIMPLE + TRACE_FORMAT_ERF, |
---|
58 | RT_DATA_WAG =RT_DATA_SIMPLE + TRACE_FORMAT_WAG, |
---|
59 | RT_DATA_LEGACY_ATM =RT_DATA_SIMPLE + TRACE_FORMAT_LEGACY_ATM, |
---|
60 | RT_DATA_LEGACY_POS =RT_DATA_SIMPLE + TRACE_FORMAT_LEGACY_POS, |
---|
61 | RT_DATA_LEGACY_ETH =RT_DATA_SIMPLE + TRACE_FORMAT_LEGACY_ETH, |
---|
62 | RT_DATA_LINUX_NATIVE =RT_DATA_SIMPLE + TRACE_FORMAT_LINUX_NATIVE, |
---|
63 | |
---|
64 | #ifdef HAVE_PCAP |
---|
65 | RT_DATA_PCAP_NULL =RT_DATA_PCAP + DLT_NULL, |
---|
66 | RT_DATA_PCAP_EN10MB =RT_DATA_PCAP + DLT_EN10MB, |
---|
67 | RT_DATA_PCAP_ATM_RFC1483 =RT_DATA_PCAP + DLT_ATM_RFC1483, |
---|
68 | RT_DATA_PCAP_IEEE802_11 =RT_DATA_PCAP + DLT_IEEE802_11, |
---|
69 | #ifdef DLT_LINUX_SLL |
---|
70 | RT_DATA_PCAP_LINUX_SLL =RT_DATA_PCAP + DLT_LINUX_SLL, |
---|
71 | #endif |
---|
72 | #ifdef DLT_PFLOG |
---|
73 | RT_DATA_PCAP_PFLOG =RT_DATA_PCAP + DLT_PFLOG, |
---|
74 | #endif |
---|
75 | #endif |
---|
76 | RT_LAST = 3000 |
---|
77 | }; |
---|
78 | |
---|
79 | typedef struct fifo_info { |
---|
80 | uint64_t in; |
---|
81 | uint64_t out; |
---|
82 | uint64_t ack; |
---|
83 | uint64_t length; |
---|
84 | uint64_t used; |
---|
85 | } fifo_info_t; |
---|
86 | |
---|
87 | /* RT packet header */ |
---|
88 | typedef struct rt_header { |
---|
89 | enum rt_field_t type; |
---|
90 | uint16_t length; |
---|
91 | uint32_t sequence; |
---|
92 | } rt_header_t; |
---|
93 | |
---|
94 | /* TODO: Reorganise this struct once more hello info is added */ |
---|
95 | typedef struct rt_hello { |
---|
96 | uint8_t reliable; |
---|
97 | } rt_hello_t; |
---|
98 | |
---|
99 | #if 0 |
---|
100 | typedef struct rt_start { |
---|
101 | |
---|
102 | } rt_start_t; |
---|
103 | #endif |
---|
104 | |
---|
105 | typedef struct rt_ack { |
---|
106 | uint32_t sequence; |
---|
107 | } rt_ack_t; |
---|
108 | |
---|
109 | typedef struct rt_status { |
---|
110 | fifo_info_t fifo_status; |
---|
111 | } rt_status_t; |
---|
112 | |
---|
113 | #if 0 |
---|
114 | typedef struct rt_duck { |
---|
115 | /*duckinf_t duck; */ |
---|
116 | } rt_duck_t; |
---|
117 | #endif |
---|
118 | |
---|
119 | #if 0 |
---|
120 | typedef struct rt_end_data { |
---|
121 | |
---|
122 | } rt_end_data_t; |
---|
123 | #endif |
---|
124 | |
---|
125 | #if 0 |
---|
126 | typedef struct rt_close { |
---|
127 | |
---|
128 | } rt_close_t; |
---|
129 | #endif |
---|
130 | |
---|
131 | /* Connection denied reasons */ |
---|
132 | enum rt_conn_denied_t { |
---|
133 | RT_DENY_WRAPPER =1, |
---|
134 | RT_DENY_FULL =2, |
---|
135 | RT_DENY_AUTH =3 |
---|
136 | }; |
---|
137 | |
---|
138 | typedef struct rt_deny_conn { |
---|
139 | enum rt_conn_denied_t reason; |
---|
140 | } rt_deny_conn_t; |
---|
141 | |
---|
142 | #if 0 |
---|
143 | typedef struct rt_pause { |
---|
144 | |
---|
145 | } rt_pause_t; |
---|
146 | #endif |
---|
147 | |
---|
148 | #if 0 |
---|
149 | typedef struct rt_pause_ack { |
---|
150 | |
---|
151 | } rt_pause_ack_t; |
---|
152 | #endif |
---|
153 | |
---|
154 | #if 0 |
---|
155 | typedef struct rt_option { |
---|
156 | |
---|
157 | } rt_option_t; |
---|
158 | #endif |
---|
159 | |
---|
160 | #if 0 |
---|
161 | typedef struct rt_keychange { |
---|
162 | |
---|
163 | } rt_keychange_t; |
---|
164 | #endif |
---|
165 | |
---|
166 | #endif |
---|