File: probe_unix.h

package info (click to toggle)
mtr 0.95-1.1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 900 kB
  • sloc: ansic: 10,325; python: 572; makefile: 164; sh: 141
file content (120 lines) | stat: -rw-r--r-- 3,386 bytes parent folder | download | duplicates (2)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
    mtr  --  a network diagnostic tool
    Copyright (C) 2016  Matt Kimball

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License version 2 as
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef PROBE_UNIX_H
#define PROBE_UNIX_H

#ifndef IPPROTO_SCTP
// Needed for Netbsd.
#define IPPROTO_SCTP           132             /* SCTP */
#endif

/*  The range of local port numbers to use for probes  */
#define MIN_PORT 33000
#define MAX_PORT 65535

/*  We need to track the transmission and timeouts on Unix systems  */
struct probe_platform_t {
    /*  The socket for the outgoing connection  (used by TCP probes)  */
    int socket;

    /*  The time at which the probe is considered lost  */
    struct timeval timeout_time;

    /*  The time at which the probe was sent  */
    struct timeval departure_time;
};

/*  We'll use rack sockets to send and receive probes on Unix systems  */
struct net_state_platform_t {
    /*  true if we were successful at opening IPv4 sockets  */
    bool ip4_present;

    /*  true if we were successful at opening IPv6 sockets  */
    bool ip6_present;

    /* true if ipv4 socket is raw socket */
    bool ip4_socket_raw;

    /* true if ipv6 socket is raw socket */
    bool ip6_socket_raw;

    /*  Socket used to send raw IPv4 packets  */
    int ip4_send_socket;

    /*  Socket used to receive IPv4 ICMP replies  */
    int ip4_recv_socket;

    /*  Socket used to probe byte order */
    int ip4_tmp_icmp_socket;

    /*  Socket used to tx & rx non-raw IPv4 icmp packets */
    int ip4_txrx_icmp_socket;

    /*  Socket used to send IPv4 udp packets and receive icmp err packets */
    int ip4_txrx_udp_socket;

    /*  Send socket for ICMPv6 packets  */
    int icmp6_send_socket;

    /*  Send socket for UDPv6 packets  */
    int udp6_send_socket;

    /*  Receive socket for IPv6 packets  */
    int ip6_recv_socket;

    /*  Socket used to tx & rx non-raw IPv6 icmp packets */
    int ip6_txrx_icmp_socket;

    /*  Socket used to send IPv6 udp packets and receive icmp err packets */
    int ip6_txrx_udp_socket;

    /*
       true if we should encode the IP header length in host order.
       (as opposed to network order)
     */
    bool ip_length_host_order;

    /*  true if the operating system supports SCTP sockets  */
    bool sctp_support;

    /*  The next port number to use when creating a new probe  */
    int next_sequence;
};

struct net_state_t;
struct probe_t;
struct mpls_label_t;

void set_socket_nonblocking(
    int socket);

void receive_probe(
    struct net_state_t *net_state,
    struct probe_t *probe,
    int icmp_type,
    const struct sockaddr_storage *remote_addr,
    struct timeval *timestamp,
    int mpls_count,
    struct mpls_label_t *mpls);

int gather_probe_sockets(
    const struct net_state_t *net_state,
    fd_set * write_set);

#endif