Skip to Content
[CAIDA - Cooperative Association for Internet Data Analysis logo]
The Cooperative Association for Internet Data Analysis
corsaro_int.h
Go to the documentation of this file.
1 /*
2  * corsaro
3  *
4  * Alistair King, CAIDA, UC San Diego
5  * corsaro-info@caida.org
6  *
7  * Copyright (C) 2012 The Regents of the University of California.
8  *
9  * This file is part of corsaro.
10  *
11  * corsaro is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * corsaro is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with corsaro. If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #ifndef __CORSARO_INT_H
27 #define __CORSARO_INT_H
28 
29 #include "config.h"
30 
31 #include "corsaro.h"
32 
33 #include "corsaro_file.h"
34 #include "corsaro_plugin.h"
35 
44 /* GCC optimizations */
45 #if __GNUC__ >= 3
46 # define DEPRECATED __attribute__((deprecated))
47 # define SIMPLE_FUNCTION __attribute__((pure))
48 # define UNUSED __attribute__((unused))
49 # define PACKED __attribute__((packed))
50 # define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
51 #else
52 # define DEPRECATED
53 # define SIMPLE_FUNCTION
54 # define UNUSED
55 # define PACKED
56 # define PRINTF(formatpos,argpos)
57 #endif
58 
67 typedef enum corsaro_magic
68  {
70  CORSARO_MAGIC = 0x45444752,
72  CORSARO_MAGIC_HEADER = 0x48454144,
74  CORSARO_MAGIC_INTERVAL = 0x494E5452,
75  /* corsaro data block magic number - "DATA" */
76  CORSARO_MAGIC_DATA = 0x44415441,
77  /* corsaro trailer magic number - "FOOT" */
78  CORSARO_MAGIC_TRAILER = 0x464F4F54
80 
86 {
88  uint32_t corsaro_magic;
90  uint32_t magic;
92  uint8_t version_major;
94  uint8_t version_minor;
96  uint32_t local_init_time;
98  uint16_t interval_length;
100  uint16_t traceuri_len;
102  uint8_t *traceuri;
104  uint16_t plugin_cnt;
106  uint16_t *plugin_ids;
107 } PACKED;
108 
114 {
116  uint32_t corsaro_magic;
118  uint32_t magic;
120  uint64_t packet_cnt;
128  uint32_t runtime;
129 } PACKED;
130 
150 {
152  uint32_t corsaro_magic;
154  uint32_t magic;
156  uint16_t number;
158  uint32_t time;
159 } PACKED;
160 
166 {
168  uint32_t corsaro_magic;
170  uint32_t magic;
172  uint16_t plugin_id;
173 } PACKED;
174 
178 #define CORSARO_INTERVAL_DEFAULT 60
179 
187 typedef struct corsaro_packet_state
188 {
190  uint8_t flags;
192  uint32_t asn;
194 
196 enum
197  {
198  CORSARO_PACKET_STATE_FLAG_BACKSCATTER = 0x01
199  };
200 
203 {
207  libtrace_packet_t *ltpacket;
208 };
209 
211 #define LT_PKT(corsaro_packet) (corsaro_packet->ltpacket)
212 
214 struct corsaro
215 {
217  struct timeval init_time;
218 
220  char *uridata;
221 
223  char *monitorname;
224 
226  char *template;
227 
230 
233 
236 
239 
242 
245 
247  /* this is what gets passed to any function relating to plugin management */
249 
251  int interval;
252 
255 
257  uint32_t next_report;
258 
260  struct timeval first_ts;
261 
263  struct timeval last_ts;
264 
266  uint64_t packet_cnt;
267 
269  int started;
270 
271 };
272 
275 {
277  char *uridata;
278 
281 
284 
286  /* this is what gets passed to any function relating to plugin management */
288 
291 
293  int started;
294 
295 };
296 
298 #define CORSARO_IN_RECORD_DEFAULT_BUFFER_LEN LIBTRACE_PACKET_BUFSIZE+1024
299 
302 {
305 
307  uint8_t *buffer;
308 
310  size_t buffer_len;
311 
314 
315 };
316 
317 #endif /* __CORSARO_INT_H */