1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef NET_COLO_H
16#define NET_COLO_H
17
18#include "qemu/jhash.h"
19#include "qemu/timer.h"
20#include "net/eth.h"
21
22#define HASHTABLE_MAX_SIZE 16384
23
24#ifndef IPPROTO_DCCP
25#define IPPROTO_DCCP 33
26#endif
27
28#ifndef IPPROTO_SCTP
29#define IPPROTO_SCTP 132
30#endif
31
32#ifndef IPPROTO_UDPLITE
33#define IPPROTO_UDPLITE 136
34#endif
35
36typedef struct Packet {
37 void *data;
38 union {
39 uint8_t *network_header;
40 struct ip *ip;
41 };
42 uint8_t *transport_header;
43 int size;
44
45 int64_t creation_ms;
46
47 uint32_t vnet_hdr_len;
48 uint32_t tcp_seq;
49 uint32_t tcp_ack;
50
51 uint32_t seq_end;
52 uint8_t header_size;
53 uint16_t payload_size;
54
55 uint16_t offset;
56 uint8_t flags;
57} Packet;
58
59typedef struct ConnectionKey {
60
61 struct in_addr src;
62 struct in_addr dst;
63 uint16_t src_port;
64 uint16_t dst_port;
65 uint8_t ip_proto;
66} QEMU_PACKED ConnectionKey;
67
68typedef struct Connection {
69
70 GQueue primary_list;
71
72 GQueue secondary_list;
73
74 bool processing;
75 uint8_t ip_proto;
76
77 uint32_t compare_seq;
78
79 uint32_t pack;
80
81 uint32_t sack;
82
83 uint32_t offset;
84
85 int tcp_state;
86 uint32_t fin_ack_seq;
87} Connection;
88
89uint32_t connection_key_hash(const void *opaque);
90int connection_key_equal(const void *opaque1, const void *opaque2);
91int parse_packet_early(Packet *pkt);
92void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *pkt);
93void fill_connection_key(Packet *pkt, ConnectionKey *key);
94void reverse_connection_key(ConnectionKey *key);
95Connection *connection_new(ConnectionKey *key);
96void connection_destroy(void *opaque);
97Connection *connection_get(GHashTable *connection_track_table,
98 ConnectionKey *key,
99 GQueue *conn_list);
100bool connection_has_tracked(GHashTable *connection_track_table,
101 ConnectionKey *key);
102void connection_hashtable_reset(GHashTable *connection_track_table);
103Packet *packet_new(const void *data, int size, int vnet_hdr_len);
104void packet_destroy(void *opaque, void *user_data);
105
106#endif
107