| 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_TCP_H |
| 20 | #define DATA_STRUCTURES_TCP_H |
| 21 | |
| 22 | #include <glib.h> |
| 23 | #include <stdbool.h> |
| 24 | #include <stdint.h> |
| 25 | |
| 26 | #include <ltt/ltt.h> |
| 27 | |
| 28 | typedef struct |
| 29 | { |
| 30 | uint32_t saddr, daddr; |
| 31 | uint16_t source, dest; |
| 32 | } ConnectionKey; |
| 33 | |
| 34 | typedef struct |
| 35 | { |
| 36 | ConnectionKey connectionKey; |
| 37 | uint8_t ihl; |
| 38 | uint16_t tot_len; |
| 39 | uint32_t seq, ack_seq; |
| 40 | uint8_t doff; |
| 41 | uint8_t ack, rst, syn, fin; |
| 42 | } PacketKey; |
| 43 | |
| 44 | typedef struct |
| 45 | { |
| 46 | // lttng metainformation |
| 47 | unsigned long traceNum; |
| 48 | LttCycleCount tsc; |
| 49 | |
| 50 | // kernel metainformation |
| 51 | void* skb; |
| 52 | |
| 53 | // packet header fields |
| 54 | PacketKey* packetKey; |
| 55 | } NetEvent; |
| 56 | |
| 57 | typedef struct |
| 58 | { |
| 59 | NetEvent* inE, * outE; |
| 60 | GQueue* acks; |
| 61 | } Packet; |
| 62 | |
| 63 | typedef struct |
| 64 | { |
| 65 | double drift, offset; |
| 66 | } Factors; |
| 67 | |
| 68 | typedef enum |
| 69 | { |
| 70 | OUT, |
| 71 | IN |
| 72 | } EventType; |
| 73 | |
| 74 | |
| 75 | void convertIP(char* const str, const uint32_t addr); |
| 76 | void printPacket(const Packet* const packet); |
| 77 | |
| 78 | // ConnectionKey-related functions |
| 79 | bool connectionKeyEqual(const ConnectionKey* const a, const ConnectionKey* |
| 80 | const b); |
| 81 | |
| 82 | // NetEvent-related functions |
| 83 | void destroyNetEvent(NetEvent* const event); |
| 84 | |
| 85 | // Packet-related functions |
| 86 | bool isAcking(const Packet* const ackPacket, const Packet* const ackedPacket); |
| 87 | void destroyPacket(Packet* const packet); |
| 88 | |
| 89 | // ConnectionKey-related Glib functions |
| 90 | guint ghfConnectionKeyHash(gconstpointer key); |
| 91 | gboolean gefConnectionKeyEqual(gconstpointer a, gconstpointer b); |
| 92 | void gdnConnectionKeyDestroy(gpointer data); |
| 93 | |
| 94 | // PacketKey-related Glib functions |
| 95 | guint ghfPacketKeyHash(gconstpointer key); |
| 96 | gboolean gefPacketKeyEqual(gconstpointer a, gconstpointer b); |
| 97 | |
| 98 | // NetEvent-related Glib functions |
| 99 | void gdnDestroyNetEvent(gpointer data); |
| 100 | |
| 101 | // Packet-related Glib functions |
| 102 | void gdnPacketListDestroy(gpointer data); |
| 103 | void gfPacketDestroy(gpointer data, gpointer user_data); |
| 104 | gint gcfPacketAckCompare(gconstpointer a, gconstpointer b); |
| 105 | |
| 106 | #endif |