File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / mtr / packet / probe_unix.h
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Sep 27 11:18:58 2023 UTC (9 months ago) by misho
Branches: mtr, MAIN
CVS tags: v0_95, HEAD
Version 0.95

    1: /*
    2:     mtr  --  a network diagnostic tool
    3:     Copyright (C) 2016  Matt Kimball
    4: 
    5:     This program is free software; you can redistribute it and/or modify
    6:     it under the terms of the GNU General Public License version 2 as
    7:     published by the Free Software Foundation.
    8: 
    9:     This program is distributed in the hope that it will be useful,
   10:     but WITHOUT ANY WARRANTY; without even the implied warranty of
   11:     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12:     GNU General Public License for more details.
   13: 
   14:     You should have received a copy of the GNU General Public License along
   15:     with this program; if not, write to the Free Software Foundation, Inc.,
   16:     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   17: */
   18: 
   19: #ifndef PROBE_UNIX_H
   20: #define PROBE_UNIX_H
   21: 
   22: #ifndef IPPROTO_SCTP
   23: // Needed for Netbsd.
   24: #define IPPROTO_SCTP           132             /* SCTP */
   25: #endif
   26: 
   27: /*  The range of local port numbers to use for probes  */
   28: #define MIN_PORT 33000
   29: #define MAX_PORT 65535
   30: 
   31: /*  We need to track the transmission and timeouts on Unix systems  */
   32: struct probe_platform_t {
   33:     /*  The socket for the outgoing connection  (used by TCP probes)  */
   34:     int socket;
   35: 
   36:     /*  The time at which the probe is considered lost  */
   37:     struct timeval timeout_time;
   38: 
   39:     /*  The time at which the probe was sent  */
   40:     struct timeval departure_time;
   41: };
   42: 
   43: /*  We'll use rack sockets to send and receive probes on Unix systems  */
   44: struct net_state_platform_t {
   45:     /*  true if we were successful at opening IPv4 sockets  */
   46:     bool ip4_present;
   47: 
   48:     /*  true if we were successful at opening IPv6 sockets  */
   49:     bool ip6_present;
   50: 
   51:     /* true if ipv4 socket is raw socket */
   52:     bool ip4_socket_raw;
   53: 
   54:     /* true if ipv6 socket is raw socket */
   55:     bool ip6_socket_raw;
   56: 
   57:     /*  Socket used to send raw IPv4 packets  */
   58:     int ip4_send_socket;
   59: 
   60:     /*  Socket used to receive IPv4 ICMP replies  */
   61:     int ip4_recv_socket;
   62: 
   63:     /*  Socket used to probe byte order */
   64:     int ip4_tmp_icmp_socket;
   65: 
   66:     /*  Socket used to tx & rx non-raw IPv4 icmp packets */
   67:     int ip4_txrx_icmp_socket;
   68: 
   69:     /*  Socket used to send IPv4 udp packets and receive icmp err packets */
   70:     int ip4_txrx_udp_socket;
   71: 
   72:     /*  Send socket for ICMPv6 packets  */
   73:     int icmp6_send_socket;
   74: 
   75:     /*  Send socket for UDPv6 packets  */
   76:     int udp6_send_socket;
   77: 
   78:     /*  Receive socket for IPv6 packets  */
   79:     int ip6_recv_socket;
   80: 
   81:     /*  Socket used to tx & rx non-raw IPv6 icmp packets */
   82:     int ip6_txrx_icmp_socket;
   83: 
   84:     /*  Socket used to send IPv6 udp packets and receive icmp err packets */
   85:     int ip6_txrx_udp_socket;
   86: 
   87:     /*
   88:        true if we should encode the IP header length in host order.
   89:        (as opposed to network order)
   90:      */
   91:     bool ip_length_host_order;
   92: 
   93:     /*  true if the operating system supports SCTP sockets  */
   94:     bool sctp_support;
   95: 
   96:     /*  The next port number to use when creating a new probe  */
   97:     int next_sequence;
   98: };
   99: 
  100: struct net_state_t;
  101: struct probe_t;
  102: struct mpls_label_t;
  103: 
  104: void set_socket_nonblocking(
  105:     int socket);
  106: 
  107: void receive_probe(
  108:     struct net_state_t *net_state,
  109:     struct probe_t *probe,
  110:     int icmp_type,
  111:     const struct sockaddr_storage *remote_addr,
  112:     struct timeval *timestamp,
  113:     int mpls_count,
  114:     struct mpls_label_t *mpls);
  115: 
  116: int gather_probe_sockets(
  117:     const struct net_state_t *net_state,
  118:     fd_set * write_set);
  119: 
  120: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>