Annotation of embedaddon/mtr/packet/probe_cygwin.h, revision 1.1.1.2

1.1       misho       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: 
1.1.1.2 ! misho      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.
1.1       misho      17: */
                     18: 
                     19: #ifndef PROBE_CYGWIN_H
                     20: #define PROBE_CYGWIN_H
                     21: 
                     22: #include <arpa/inet.h>
                     23: #include <windows.h>
                     24: #include <iphlpapi.h>
                     25: #include <icmpapi.h>
                     26: 
                     27: /*
                     28:     This should be in the Windows headers, but is missing from
                     29:     Cygwin's Windows headers.
                     30: */
                     31: typedef struct icmpv6_echo_reply_lh {
                     32:     /*
                     33:        Although Windows uses an IPV6_ADDRESS_EX here, we are using uint8_t
                     34:        fields to avoid structure padding differences between gcc and
                     35:        Visual C++.  (gcc wants to align the flow info to a 4 byte boundary,
                     36:        and Windows uses it unaligned.)
                     37:      */
                     38:     uint8_t PortBits[2];
                     39:     uint8_t FlowInfoBits[4];
                     40:     uint8_t AddressBits[16];
                     41:     uint8_t ScopeIdBits[4];
                     42: 
                     43:     ULONG Status;
                     44:     unsigned int RoundTripTime;
                     45: } ICMPV6_ECHO_REPLY,
                     46: *PICMPV6_ECHO_REPLY;
                     47: 
                     48: /*
                     49:        Windows requires an echo reply structure for each in-flight
                     50:        ICMP probe.
                     51: */
                     52: struct probe_platform_t {
                     53:     /*
                     54:        We need a backpointer to the net_state because of the way
                     55:        IcmpSendEcho2 passes our context.
                     56:      */
                     57:     struct net_state_t *net_state;
                     58: 
                     59:     /*  IP version (4 or 6) used for the probe  */
                     60:     int ip_version;
                     61: };
                     62: 
                     63: /*  A Windows HANDLE for the ICMP session  */
                     64: struct net_state_platform_t {
                     65:     HANDLE icmp4;
                     66:     HANDLE icmp6;
1.1.1.2 ! misho      67:     bool ip4_socket_raw;
        !            68:     bool ip6_socket_raw;
        !            69: 
        !            70:     HANDLE thread_in_pipe_read_handle;
        !            71:     int thread_in_pipe_read, thread_in_pipe_write;
        !            72:     int thread_out_pipe_read, thread_out_pipe_write;
        !            73: };
        !            74: 
        !            75: /*
        !            76:     A request object passed between the main thread and the ICMP
        !            77:     service thread representing an outstanding probe.
        !            78: */
        !            79: struct icmp_thread_request_t {
        !            80:     /*
        !            81:         net_state and probe are const to avoid race conditions between
        !            82:         the main thread and the ICMP service thread.  They are to be
        !            83:         considered read-only on the ICMP service thread.
        !            84:     */
        !            85:     const struct net_state_t *net_state;
        !            86:     const struct probe_t *probe;
        !            87: 
        !            88:     /*  Parameters for the probe request  */
        !            89:     int ip_version;
        !            90:     int ttl;
        !            91:     int timeout;
        !            92:     int packet_size;
        !            93:     int bit_pattern;
        !            94: 
        !            95:     /*  Source and destination for the probe  */
        !            96:     struct sockaddr_storage dest_sockaddr;
        !            97:     struct sockaddr_storage src_sockaddr;
        !            98: 
        !            99:     /*  Scratch space used by the ICMP.DLL API  */
        !           100:     union {
        !           101:         ICMP_ECHO_REPLY *reply4;
        !           102:         ICMPV6_ECHO_REPLY *reply6;
        !           103:     };
        !           104: 
        !           105:     /*  Probe results  */
        !           106:     int icmp_type;
        !           107:     int reply_status;
        !           108:     int round_trip_us;
        !           109: 
        !           110:     /*  The remote address responding to the probe  */
        !           111:     struct sockaddr_storage remote_addr;
1.1       misho     112: };
                    113: 
                    114: #endif

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