1 | #ifndef _RT_PROTOCOL_H |
---|
2 | #define _RT_PROTOCOL_H |
---|
3 | |
---|
4 | #include "libtrace.h" |
---|
5 | #include <time.h> |
---|
6 | |
---|
7 | #define CAPTURE_PORT 3434 |
---|
8 | #define COLLECTOR_PORT 3435 |
---|
9 | |
---|
10 | #define RT_MAX_HDR_SIZE 256 |
---|
11 | #define MAX_SEQUENCE 2147483647 |
---|
12 | |
---|
13 | /* Procedure for adding new RT control types |
---|
14 | * ------------------------------------------- |
---|
15 | * |
---|
16 | * Add type to the enum list |
---|
17 | * Add a struct below (even if it is empty - wrap it in an #if 0) |
---|
18 | * Update rt_get_capture_length |
---|
19 | * If type is intended to be sent TO clients, update rt_read_packet |
---|
20 | * Otherwise, update server implementations e.g. WDCAP |
---|
21 | * |
---|
22 | * Procedure for adding new RT data types |
---|
23 | * ---------------------------------------- |
---|
24 | * |
---|
25 | * If you are adding a new format: |
---|
26 | * RT_DATA_(new format) must be equal to RT_DATA_SIMPLE + |
---|
27 | * TRACE_FORMAT_(new_format) |
---|
28 | * Add a new dummy trace type to the rt_format_t structure |
---|
29 | * Set the dummy trace to NULL in rt_init_input |
---|
30 | * Update rt_set_format |
---|
31 | * |
---|
32 | * If you are adding a new PCAP DLT type: |
---|
33 | * RT_DATA_PCAP_(new DLT) must be equal to RT_DATA_PCAP + (DLT value) |
---|
34 | * |
---|
35 | */ |
---|
36 | |
---|
37 | typedef struct fifo_info { |
---|
38 | uint64_t in; |
---|
39 | uint64_t out; |
---|
40 | uint64_t ack; |
---|
41 | uint64_t length; |
---|
42 | uint64_t used; |
---|
43 | } fifo_info_t; |
---|
44 | |
---|
45 | /** RT packet header */ |
---|
46 | typedef struct rt_header { |
---|
47 | libtrace_rt_types_t type; |
---|
48 | uint16_t length; |
---|
49 | uint32_t sequence; |
---|
50 | } rt_header_t; |
---|
51 | |
---|
52 | /* TODO: Reorganise this struct once more hello info is added */ |
---|
53 | /** RT Hello packet sub-header */ |
---|
54 | typedef struct rt_hello { |
---|
55 | uint8_t reliable; |
---|
56 | } rt_hello_t; |
---|
57 | |
---|
58 | #if 0 |
---|
59 | typedef struct rt_start { |
---|
60 | |
---|
61 | } rt_start_t; |
---|
62 | #endif |
---|
63 | |
---|
64 | /** RT Ack sub-header */ |
---|
65 | typedef struct rt_ack { |
---|
66 | uint32_t sequence; |
---|
67 | } rt_ack_t; |
---|
68 | |
---|
69 | /** RT Status sub-header */ |
---|
70 | typedef struct rt_status { |
---|
71 | fifo_info_t fifo_status; |
---|
72 | } rt_status_t; |
---|
73 | |
---|
74 | #if 0 |
---|
75 | typedef struct rt_duck { |
---|
76 | /*duckinf_t duck; */ |
---|
77 | } rt_duck_t; |
---|
78 | #endif |
---|
79 | |
---|
80 | #if 0 |
---|
81 | typedef struct rt_end_data { |
---|
82 | |
---|
83 | } rt_end_data_t; |
---|
84 | #endif |
---|
85 | |
---|
86 | #if 0 |
---|
87 | typedef struct rt_close { |
---|
88 | |
---|
89 | } rt_close_t; |
---|
90 | #endif |
---|
91 | |
---|
92 | /** Connection denied reasons */ |
---|
93 | enum rt_conn_denied_t { |
---|
94 | RT_DENY_WRAPPER =1, |
---|
95 | RT_DENY_FULL =2, |
---|
96 | RT_DENY_AUTH =3 |
---|
97 | }; |
---|
98 | |
---|
99 | /** RT Denied Connection sub-header */ |
---|
100 | typedef struct rt_deny_conn { |
---|
101 | enum rt_conn_denied_t reason; |
---|
102 | } rt_deny_conn_t; |
---|
103 | |
---|
104 | #if 0 |
---|
105 | typedef struct rt_pause { |
---|
106 | |
---|
107 | } rt_pause_t; |
---|
108 | #endif |
---|
109 | |
---|
110 | #if 0 |
---|
111 | typedef struct rt_pause_ack { |
---|
112 | |
---|
113 | } rt_pause_ack_t; |
---|
114 | #endif |
---|
115 | |
---|
116 | #if 0 |
---|
117 | typedef struct rt_option { |
---|
118 | |
---|
119 | } rt_option_t; |
---|
120 | #endif |
---|
121 | |
---|
122 | #if 0 |
---|
123 | typedef struct rt_keychange { |
---|
124 | |
---|
125 | } rt_keychange_t; |
---|
126 | #endif |
---|
127 | |
---|
128 | /** Specifications of duck structures - duck2_4 and duck2_5 match Endace's |
---|
129 | * duck_inf and duckinf_t respectively */ |
---|
130 | |
---|
131 | /** DAG 2.4 DUCK */ |
---|
132 | typedef struct duck2_4 { |
---|
133 | uint32_t Command; |
---|
134 | uint32_t Config; |
---|
135 | uint32_t Clock_Inc; |
---|
136 | uint32_t Clock_Wrap; |
---|
137 | uint32_t DDS_Rate; |
---|
138 | uint32_t Crystal_Freq; |
---|
139 | uint32_t Synth_Freq; |
---|
140 | uint32_t Sync_Rate; |
---|
141 | uint64_t Last_Ticks; |
---|
142 | uint32_t Resyncs; |
---|
143 | uint32_t Bad_Diffs; |
---|
144 | uint32_t Bad_Offs; |
---|
145 | uint32_t Bad_Pulses; |
---|
146 | uint32_t Worst_Error; |
---|
147 | uint32_t Worst_Off; |
---|
148 | uint32_t Off_Limit; |
---|
149 | uint32_t Off_Damp; |
---|
150 | uint32_t Pulses; |
---|
151 | uint32_t Single_Pulses_Missing; |
---|
152 | uint32_t Longest_Pulse_Missing; |
---|
153 | uint32_t Health; |
---|
154 | uint32_t Sickness; |
---|
155 | int32_t Error; |
---|
156 | int32_t Offset; |
---|
157 | uint32_t Stat_Start; |
---|
158 | uint32_t Stat_End; |
---|
159 | uint32_t Set_Duck_Field; |
---|
160 | } PACKED duck2_4_t; |
---|
161 | |
---|
162 | /** DAG 2.5 DUCK */ |
---|
163 | typedef struct duck2_5 { |
---|
164 | uint32_t Crystal_Freq; |
---|
165 | uint32_t Synth_Freq; |
---|
166 | uint64_t Last_Ticks; |
---|
167 | uint32_t Resyncs; |
---|
168 | uint32_t Bad_Pulses; |
---|
169 | uint32_t Worst_Freq_Err; |
---|
170 | uint32_t Worst_Phase_Err; |
---|
171 | uint32_t Health_Thresh; |
---|
172 | uint32_t Pulses; |
---|
173 | uint32_t Single_Pulses_Missing; |
---|
174 | uint32_t Longest_Pulse_Missing; |
---|
175 | uint32_t Health; |
---|
176 | uint32_t Sickness; |
---|
177 | int32_t Freq_Err; |
---|
178 | int32_t Phase_Err; |
---|
179 | uint32_t Set_Duck_Field; |
---|
180 | uint32_t Stat_Start; |
---|
181 | uint32_t Stat_End; |
---|
182 | uint64_t Last_TSC; |
---|
183 | } PACKED duck2_5_t; |
---|
184 | |
---|
185 | /* |
---|
186 | typedef struct rt_duck_2_4 { |
---|
187 | duck2_4_t duck; |
---|
188 | } rt_duck_2_4_t; |
---|
189 | |
---|
190 | typedef struct rt_duck_2_5 { |
---|
191 | duck2_5_t duck; |
---|
192 | } rt_duck_2_5_t; |
---|
193 | */ |
---|
194 | |
---|
195 | #endif |
---|