Make the synchronization module interfaces more generic
[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
28// Stage 1 to 2: These structures are passed from processing to matching modules
29// TCP events
30typedef struct
31{
32 uint32_t saddr, daddr;
33 uint16_t source, dest;
34} ConnectionKey;
35
36typedef 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
46enum Direction
47{
48 OUT,
49 IN,
50};
51
52typedef struct
53{
54 enum Direction direction;
55 SegmentKey* segmentKey;
56} TCPEvent;
57
58// UDP events
59typedef struct
60{
61 uint32_t saddr, daddr;
62 uint8_t dataKey[8];
63} DatagramKey;
64
65typedef struct
66{
67 enum Direction direction;
68 DatagramKey* datagramKey;
69 bool unicast;
70} UDPEvent;
71
72typedef 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
90typedef struct _Message
91{
92 Event* inE, * outE;
93
94 void (*print)(const struct _Message* const message);
95} Message;
96
97typedef struct
98{
99 Message* message;
100 GQueue* acks;
101} Exchange;
102
103typedef struct
104{
105 GQueue* events;
106} Broadcast;
107
108// One set of factors for each trace, this is the result of synchronization
109typedef struct
110{
111 double drift, offset;
112} Factors;
113
114
115// ConnectionKey-related functions
116guint ghfConnectionKeyHash(gconstpointer key);
117
118gboolean gefConnectionKeyEqual(gconstpointer a, gconstpointer b);
119bool connectionKeyEqual(const ConnectionKey* const a, const ConnectionKey*
120 const b);
121
122void gdnConnectionKeyDestroy(gpointer data);
123
124// SegmentKey-related functions
125guint ghfSegmentKeyHash(gconstpointer key);
126gboolean gefSegmentKeyEqual(gconstpointer a, gconstpointer b);
127
128// Event-related functions
129void gdnDestroyEvent(gpointer data);
130void destroyEvent(Event* const event);
131void destroyTCPEvent(Event* const event);
132void destroyUDPEvent(Event* const event);
133
134// Message-related functions
135void printTCPSegment(const Message* const segment);
136void convertIP(char* const str, const uint32_t addr);
137
138gint gcfTCPSegmentAckCompare(gconstpointer a, gconstpointer b);
139bool isAcking(const Message* const ackSegment, const Message* const ackedSegment);
140
141void gdnTCPSegmentListDestroy(gpointer data);
142void gfTCPSegmentDestroy(gpointer data, gpointer user_data);
143void destroyTCPSegment(Message* const segment);
144
145// Exchange-related functions
146void destroyTCPExchange(Exchange* const exchange);
147#endif
This page took 0.030859 seconds and 4 git commands to generate.