4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 3ac4bf7 was
02bd77e,
checked in by Shane Alcock <salcock@…>, 15 years ago
|
Added a rudimentary traceflow tool to libtrace - it is certainly in need of a bit of work - a manpage and some proper usage help would be a good start
|
-
Property mode set to
100644
|
File size:
1.8 KB
|
Line | |
---|
1 | #ifndef CONNID_H |
---|
2 | #define CONNID_H |
---|
3 | |
---|
4 | #include <sys/socket.h> |
---|
5 | #include <netinet/in.h> |
---|
6 | #include <arpa/inet.h> |
---|
7 | #include <string.h> |
---|
8 | |
---|
9 | uint32_t connid_next = 0; |
---|
10 | |
---|
11 | |
---|
12 | class Connid { |
---|
13 | private: |
---|
14 | int cmp(const Connid &b) const { |
---|
15 | |
---|
16 | |
---|
17 | if (port_b != b.port_b) |
---|
18 | return port_b - b.port_b; |
---|
19 | if (port_a != b.port_a) |
---|
20 | return port_a - b.port_a; |
---|
21 | |
---|
22 | if (ip_b != b.ip_b) |
---|
23 | return (ip_b < b.ip_b); |
---|
24 | |
---|
25 | if (ip_b < b.ip_b) return -1; |
---|
26 | if (ip_b > b.ip_b) return 1; |
---|
27 | if (ip_a < b.ip_a) return -1; |
---|
28 | if (ip_a > b.ip_a) return 1; |
---|
29 | |
---|
30 | return proto - b.proto; |
---|
31 | } |
---|
32 | uint32_t ip_a; |
---|
33 | uint32_t ip_b; |
---|
34 | uint16_t port_a; |
---|
35 | uint16_t port_b; |
---|
36 | uint8_t proto; |
---|
37 | uint32_t id_num; |
---|
38 | public: |
---|
39 | Connid() { |
---|
40 | ip_a = 0; |
---|
41 | ip_b = 0; |
---|
42 | port_a = 0; |
---|
43 | port_b = 0; |
---|
44 | proto = 0; |
---|
45 | id_num = connid_next; |
---|
46 | connid_next ++; |
---|
47 | } |
---|
48 | Connid(uint32_t ip_src, uint32_t ip_dst, uint16_t port_src, |
---|
49 | uint16_t port_dst, uint8_t protocol) { |
---|
50 | ip_a = ip_src; |
---|
51 | ip_b = ip_dst; |
---|
52 | port_a = port_src; |
---|
53 | port_b = port_dst; |
---|
54 | proto = protocol; |
---|
55 | id_num = connid_next; |
---|
56 | connid_next ++; |
---|
57 | } |
---|
58 | |
---|
59 | bool operator<(const Connid &b) const { |
---|
60 | |
---|
61 | if (port_b != b.port_b) |
---|
62 | return port_b < b.port_b; |
---|
63 | if (port_a != b.port_a) |
---|
64 | return port_a < b.port_a; |
---|
65 | |
---|
66 | if (ip_b != b.ip_b) |
---|
67 | return (ip_b < b.ip_b); |
---|
68 | |
---|
69 | if (ip_a != b.ip_a) |
---|
70 | return ip_a < b.ip_a; |
---|
71 | |
---|
72 | return proto < b.proto; |
---|
73 | |
---|
74 | } |
---|
75 | |
---|
76 | uint32_t get_id_num() const { |
---|
77 | return id_num; |
---|
78 | } |
---|
79 | |
---|
80 | char *get_server_ip_str() const { |
---|
81 | struct in_addr inp; |
---|
82 | inp.s_addr = ip_a; |
---|
83 | return inet_ntoa(inp); |
---|
84 | } |
---|
85 | |
---|
86 | char *get_client_ip_str() const { |
---|
87 | struct in_addr inp; |
---|
88 | inp.s_addr = ip_b; |
---|
89 | return inet_ntoa(inp); |
---|
90 | } |
---|
91 | |
---|
92 | uint16_t get_server_port() const { |
---|
93 | return port_a; |
---|
94 | } |
---|
95 | |
---|
96 | uint16_t get_client_port() const { |
---|
97 | return port_b; |
---|
98 | } |
---|
99 | |
---|
100 | uint8_t get_protocol() const { |
---|
101 | return proto; |
---|
102 | } |
---|
103 | |
---|
104 | }; |
---|
105 | |
---|
106 | |
---|
107 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.