Make the synchronization module interfaces more generic
[lttv.git] / lttv / lttv / sync / data_structures.h
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19 #ifndef DATA_STRUCTURES_H
20 #define DATA_STRUCTURES_H
21
22 #include <glib.h>
23 #include <stdbool.h>
24 #include <stdint.h>
25
26 #include <ltt/ltt.h>
27
28 // Stage 1 to 2: These structures are passed from processing to matching modules
29 // TCP events
30 typedef struct
31 {
32 uint32_t saddr, daddr;
33 uint16_t source, dest;
34 } ConnectionKey;
35
36 typedef struct
37 {
38 ConnectionKey connectionKey;
39 uint8_t ihl;
40 uint16_t tot_len;
41 uint32_t seq, ack_seq;
42 uint8_t doff;
43 uint8_t ack, rst, syn, fin;
44 } SegmentKey;
45
46 enum Direction
47 {
48 OUT,
49 IN,
50 };
51
52 typedef struct
53 {
54 enum Direction direction;
55 SegmentKey* segmentKey;
56 } TCPEvent;
57
58 // UDP events
59 typedef struct
60 {
61 uint32_t saddr, daddr;
62 uint8_t dataKey[8];
63 } DatagramKey;
64
65 typedef struct
66 {
67 enum Direction direction;
68 DatagramKey* datagramKey;
69 bool unicast;
70 } UDPEvent;
71
72 typedef struct _Event
73 {
74 unsigned long traceNum;
75 uint64_t time;
76
77 // specific event structures and functions could be in separate files and
78 // type could be an int
79 enum {TCP, UDP} type;
80 // event could be a void*, this union is to avoid having to cast
81 union {
82 TCPEvent* tcpEvent;
83 UDPEvent* udpEvent;
84 } event;
85
86 void (*destroy)(struct _Event* const event);
87 } Event;
88
89 // Stage 2 to 3: These structures are passed from matching to analysis modules
90 typedef struct _Message
91 {
92 Event* inE, * outE;
93
94 void (*print)(const struct _Message* const message);
95 } Message;
96
97 typedef struct
98 {
99 Message* message;
100 GQueue* acks;
101 } Exchange;
102
103 typedef struct
104 {
105 GQueue* events;
106 } Broadcast;
107
108 // One set of factors for each trace, this is the result of synchronization
109 typedef struct
110 {
111 double drift, offset;
112 } Factors;
113
114
115 // ConnectionKey-related functions
116 guint ghfConnectionKeyHash(gconstpointer key);
117
118 gboolean gefConnectionKeyEqual(gconstpointer a, gconstpointer b);
119 bool connectionKeyEqual(const ConnectionKey* const a, const ConnectionKey*
120 const b);
121
122 void gdnConnectionKeyDestroy(gpointer data);
123
124 // SegmentKey-related functions
125 guint ghfSegmentKeyHash(gconstpointer key);
126 gboolean gefSegmentKeyEqual(gconstpointer a, gconstpointer b);
127
128 // Event-related functions
129 void gdnDestroyEvent(gpointer data);
130 void destroyEvent(Event* const event);
131 void destroyTCPEvent(Event* const event);
132 void destroyUDPEvent(Event* const event);
133
134 // Message-related functions
135 void printTCPSegment(const Message* const segment);
136 void convertIP(char* const str, const uint32_t addr);
137
138 gint gcfTCPSegmentAckCompare(gconstpointer a, gconstpointer b);
139 bool isAcking(const Message* const ackSegment, const Message* const ackedSegment);
140
141 void gdnTCPSegmentListDestroy(gpointer data);
142 void gfTCPSegmentDestroy(gpointer data, gpointer user_data);
143 void destroyTCPSegment(Message* const segment);
144
145 // Exchange-related functions
146 void destroyTCPExchange(Exchange* const exchange);
147 #endif
This page took 0.031892 seconds and 4 git commands to generate.