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