-
Notifications
You must be signed in to change notification settings - Fork 14
/
trace.h
95 lines (87 loc) · 2.78 KB
/
trace.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
88
89
90
91
92
93
94
95
/****************************************************************************
Program: $Id: $
Date: $Date: $
Description: trace structures
****************************************************************************/
/* Payload for IPv6 Yarrp probes */
struct ypayload {
uint32_t id; /* "yrp6" = 0x79 72 70 36 */
struct in6_addr target; /* v6 target address, to detect spoofed responses */
uint8_t instance; /* instance */
uint8_t ttl; /* sent TTL */
uint16_t fudge; /* make chksum constant */
uint32_t diff; /* elapsed time */
};
class Traceroute {
public:
Traceroute(YarrpConfig *config, Stats *stats);
virtual ~Traceroute();
void addTree(Patricia *_tree) {
tree = _tree;
}
void addStats(Stats *_stats) {
stats = _stats;
}
void initHisto(uint8_t);
void dumpHisto();
uint32_t elapsed();
void lock();
void unlock();
virtual void probe(uint32_t, int) {};
virtual void probe(struct sockaddr_in *, int) {};
virtual void probePrint(struct in_addr *, int) {};
virtual void probe(struct in6_addr, int) {};
virtual void probePrint(struct in6_addr, int) {};
public:
Patricia *tree;
Stats *stats;
YarrpConfig *config;
vector<TTLHisto *> ttlhisto;
protected:
int sndsock; /* raw socket descriptor */
int payloadlen;
int packlen;
pthread_t recv_thread;
pthread_mutex_t recv_lock;
uint16_t dstport;
struct timeval start;
struct timeval now;
};
class Traceroute4 : public Traceroute {
public:
Traceroute4(YarrpConfig *config, Stats *stats);
virtual ~Traceroute4();
struct sockaddr_in *getSource() { return &source; }
void probe(const char *, int);
void probe(uint32_t, int);
void probe(struct sockaddr_in *, int);
void probePrint(struct in_addr *, int);
private:
void probeUDP(struct sockaddr_in *, int);
void probeTCP(struct sockaddr_in *, int);
void probeICMP(struct sockaddr_in *, int);
struct ip *outip;
struct sockaddr_in source;
char addrstr[INET_ADDRSTRLEN];
};
class Traceroute6 : public Traceroute {
public:
Traceroute6(YarrpConfig *config, Stats *stats);
virtual ~Traceroute6();
struct sockaddr_in6 *getSource() { return &source6; }
void probe(struct in6_addr, int);
void probePrint(struct in6_addr, int);
void probe(void *, struct in6_addr, int);
private:
void make_transport(int);
void make_frag_eh(uint8_t);
void make_hbh_eh(uint8_t);
struct ip6_hdr *outip;
uint8_t *frame;
int pcount;
uint8_t tc = 0; /* traffic class which we always set to 0 */
uint32_t flow = 0; /* flow label which we always set to 0 */
struct sockaddr_in6 source6;
struct ypayload *payload;
char addrstr[INET6_ADDRSTRLEN];
};