From e49c629b22cc1eea89be4dbf6ef039706c143ab9 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Thu, 14 Dec 2017 15:42:19 +0100 Subject: ptunnel-ng: * fixed opt type for `-p` * `-l` argument is required * exported packet structs from ptunnel.h to pkt.h --- ptunnel.h | 83 +-------------------------------------------------------------- 1 file changed, 1 insertion(+), 82 deletions(-) (limited to 'ptunnel.h') diff --git a/ptunnel.h b/ptunnel.h index 67f479d..1e4ccc1 100644 --- a/ptunnel.h +++ b/ptunnel.h @@ -70,17 +70,7 @@ #include #include -#ifdef WIN32 -#include -typedef int socklen_t; -typedef uint32_t in_addr_t; -#define ETH_ALEN 6 /* Octets in one ethernet addr */ -struct ether_header { - u_int8_t ether_dhost[ETH_ALEN]; /* destination eth addr */ - u_int8_t ether_shost[ETH_ALEN]; /* source ether addr */ - u_int16_t ether_type; /* packet type ID field */ -}; -#endif /* WIN32 */ +#include "pkt.h" enum { kMode_forward = 0, // Ping tunnel's operating mode (client) @@ -169,77 +159,6 @@ enum { kDNS_port = 53, }; -// Resend packets after this interval (in seconds) -#define kResend_interval 1.5 - -/* ping_tunnel_pkt_t: This data structure represents the header of a ptunnel - packet, consisting of a magic number, the tunnel's destination IP and port, - as well as some other fields. Note that the dest IP and port is only valid - in packets from the client to the proxy. -*/ -typedef struct { - uint32_t - magic, // magic number, used to identify ptunnel packets. - dst_ip, // destination IP and port (used by proxy to figure - dst_port, // out where to tunnel to) - state, // current connection state; see constants above. - ack, // sequence number of last packet received from other end - data_len; // length of data buffer - uint16_t - seq_no, // sequence number of this packet - id_no; // id number, used to separate different tunnels from each other - char - data[0]; // optional data buffer -} __attribute__ ((packed)) ping_tunnel_pkt_t; - - -/* ip_packet_t: This is basically my own definition of the IP packet, which - of course complies with the official definition ;) See any good book on IP - (or even the RFC) for info on the contents of this packet. -*/ -typedef struct { - uint8_t - vers_ihl, - tos; - uint16_t - pkt_len, - id, - flags_frag_offset; - uint8_t - ttl, - proto; // 1 for ICMP - uint16_t - checksum; - uint32_t - src_ip, - dst_ip; - char - data[0]; -} __attribute__ ((packed)) ip_packet_t; - - -/* icmp_echo_packet_t: This is the definition of a standard ICMP header. The - ptunnel packets are constructed as follows: - [ ip header (20 bytes) ] - [ icmp header (8 bytes) ] - [ ptunnel header (28 bytes) ] - - We actually only create the ICMP and ptunnel headers, the IP header is - taken care of by the OS. -*/ -typedef struct { - uint8_t - type, - code; - uint16_t - checksum, - identifier, - seq; - char - data[0]; -} __attribute__ ((packed)) icmp_echo_packet_t; - - /* pt_thread_info_t: A simple (very simple, in fact) structure that allows us to pass an arbitrary number of params to the threads we create. Currently, that's just one single parameter: The socket which the thread should listen -- cgit v1.2.3