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