-
Notifications
You must be signed in to change notification settings - Fork 17
/
intrace.h
87 lines (73 loc) · 1.99 KB
/
intrace.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
*
* intrace
*
* author: R. Swiecki <robert@swiecki.net>
*/
#ifndef _INTRACE_H_
#define _INTRACE_H_
#include <config.h>
#include <sys/param.h>
#include <sys/types.h>
#include <stdbool.h>
#include <pthread.h>
#include <stdint.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
enum fMode {
ANY = 0,
IPV4 = 1,
IPV6 = 2
};
typedef struct {
pthread_mutex_t mutex;
char *hostname;
uint16_t port;
size_t paylSz;
struct in_addr rip;
struct in_addr lip;
struct in6_addr rip6;
struct in6_addr lip6;
uint16_t rport;
uint16_t lport;
uint32_t seq;
uint32_t ack;
enum fMode familyMode;
bool isIPv6;
int maxhop;
int cnt;
int if_index;
struct {
int rcvSocketTCP;
int rcvSocketICMP;
struct in_addr ip_trace[MAX_HOPS + 1];
struct in_addr icmp_trace[MAX_HOPS + 1];
struct in6_addr ip_trace6[MAX_HOPS + 1];
struct in6_addr icmp_trace6[MAX_HOPS + 1];
int16_t proto[MAX_HOPS + 1];
} listener;
struct {
int sndSocket;
} sender;
} intrace_t;
#define _IT_AF(i) (i->isIPv6 ? AF_INET6 : AF_INET)
#define _IT_IPPROTO(i) (i->isIPv6 ? IPPROTO_IPV6 : IPPROTO_IP)
#define _IT_PKTINFO(i) (i->isIPv6 ? IPV6_RECVPKTINFO : IP_PKTINFO)
#define _IT_ICMPPROTO(i) (i->isIPv6 ? IPPROTO_ICMPV6 : IPPROTO_ICMP)
#define _IT_LIP(i) (i->isIPv6 ? (void*)i->lip6.s6_addr : (void*)&i->lip.s_addr)
#define _IT_RIP(i) (i->isIPv6 ? (void*)i->rip6.s6_addr : (void*)&i->rip.s_addr)
#define _IT_TRACE_IP(i, d) (i->isIPv6 ? (void*)i->listener.ip_trace6[d].s6_addr : (void*)&i->listener.ip_trace[d].s_addr)
#define _IT_TRACE_ICMP(i, d) (i->isIPv6 ? (void*)i->listener.icmp_trace6[d].s6_addr : (void*)&i->listener.icmp_trace[d].s_addr)
#define _IT_IPSTR(i) (i->isIPv6 ? "IPv6" : "IPv4" )
#define _IT_IPCMP(i, f, s) (!memcmp(f, s, i->isIPv6 ? 16 : 4))
#define _IT_ISANY(i, a) (!memcmp(a, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", i->isIPv6 ? 16 : 4))
#include <errors.h>
#include <debug.h>
#include <threads.h>
#include <sender.h>
#include <listener.h>
#include <display.h>
#include <ipv4.h>
#include <ipv6.h>
#endif