Do not use LttCycleCount elsewhere than in processing_lttv
[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
27 enum Direction
28 {
29 OUT,
30 IN,
31 };
32
33 enum EventType
34 {
35 TCP,
36 UDP,
37 TYPE_COUNT // This must be the last field
38 };
39
40 // Stage 1 to 2: These structures are passed from processing to matching modules
41 // TCP events
42 typedef struct
43 {
44 uint32_t saddr, daddr;
45 uint16_t source, dest;
46 } ConnectionKey;
47
48 typedef struct
49 {
50 ConnectionKey connectionKey;
51 uint8_t ihl;
52 uint16_t tot_len;
53 uint32_t seq, ack_seq;
54 uint8_t doff;
55 uint8_t ack, rst, syn, fin;
56 } SegmentKey;
57
58 typedef struct
59 {
60 enum Direction direction;
61 SegmentKey* segmentKey;
62 } TCPEvent;
63
64 // UDP events
65 typedef struct
66 {
67 uint32_t saddr, daddr;
68 uint16_t source, dest;
69 uint16_t ulen;
70 uint8_t dataKey[8];
71 } DatagramKey;
72
73 typedef struct
74 {
75 enum Direction direction;
76 DatagramKey* datagramKey;
77 bool unicast;
78 } UDPEvent;
79
80 typedef struct
81 {
82 uint32_t seconds;
83 uint32_t nanosec;
84 } WallTime;
85
86 typedef struct _Event
87 {
88 unsigned long traceNum;
89 uint64_t cpuTime;
90 WallTime wallTime;
91
92 // specific event structures and functions could be in separate files and
93 // type could be an int
94 enum EventType type;
95 // event could be a void*, this union is to avoid having to cast
96 union {
97 TCPEvent* tcpEvent;
98 UDPEvent* udpEvent;
99 } event;
100
101 void (*copy)(const struct _Event* const event, struct _Event** const newEvent);
102 void (*destroy)(struct _Event* const event);
103 } Event;
104
105 // Stage 2 to 3: These structures are passed from matching to analysis modules
106 typedef struct _Message
107 {
108 Event* inE, * outE;
109
110 void (*print)(const struct _Message* const message);
111 } Message;
112
113 typedef struct
114 {
115 Message* message;
116 GQueue* acks;
117 } Exchange;
118
119 typedef struct
120 {
121 GQueue* events;
122 } Broadcast;
123
124 // One set of factors for each trace, this is the result of synchronization
125 typedef struct
126 {
127 double drift, offset;
128 } Factors;
129
130
131 // ConnectionKey-related functions
132 guint ghfConnectionKeyHash(gconstpointer key);
133
134 gboolean gefConnectionKeyEqual(gconstpointer a, gconstpointer b);
135 bool connectionKeyEqual(const ConnectionKey* const a, const ConnectionKey*
136 const b);
137
138 void gdnConnectionKeyDestroy(gpointer data);
139
140 // SegmentKey-related functions
141 guint ghfSegmentKeyHash(gconstpointer key);
142 gboolean gefSegmentKeyEqual(gconstpointer a, gconstpointer b);
143
144 // DatagramKey-related functions
145 guint ghfDatagramKeyHash(gconstpointer key);
146 gboolean gefDatagramKeyEqual(gconstpointer a, gconstpointer b);
147 void gdnDestroyDatagramKey(gpointer data);
148
149 // Event-related functions
150 void gdnDestroyEvent(gpointer data);
151 void copyEvent(const Event* const event, Event** const newEvent);
152 void copyTCPEvent(const Event* const event, Event** const newEvent);
153 void copyUDPEvent(const Event* const event, Event** const newEvent);
154 void destroyEvent(Event* const event);
155 void destroyTCPEvent(Event* const event);
156 void destroyUDPEvent(Event* const event);
157 void gfDestroyEvent(gpointer data, gpointer user_data);
158 double wallTimeSub(const WallTime const* tA, const WallTime const* tB);
159
160 // Message-related functions
161 void printTCPSegment(const Message* const segment);
162 void convertIP(char* const str, const uint32_t addr);
163
164 gint gcfTCPSegmentAckCompare(gconstpointer a, gconstpointer b);
165 bool isAcking(const Message* const ackSegment, const Message* const ackedSegment);
166
167 void gdnTCPSegmentListDestroy(gpointer data);
168 void gfTCPSegmentDestroy(gpointer data, gpointer user_data);
169 void destroyTCPSegment(Message* const segment);
170
171 // Exchange-related functions
172 void destroyTCPExchange(Exchange* const exchange);
173
174 // Broadcast-related functions
175 void gdnDestroyBroadcast(gpointer data);
176 void destroyBroadcast(Broadcast* const broadcast);
177
178 #endif
This page took 0.032337 seconds and 4 git commands to generate.