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