diff options
Diffstat (limited to 'src/pkt.h')
-rw-r--r-- | src/pkt.h | 89 |
1 files changed, 44 insertions, 45 deletions
@@ -49,9 +49,9 @@ #include <stdint.h> #ifndef __MINGW32__ -#define __PTATTR__ __attribute__ ((packed)) +#define __PTATTR__ __attribute__((packed)) #else -#define __PTATTR__ __attribute__ ((packed, gcc_struct)) +#define __PTATTR__ __attribute__((packed, gcc_struct)) #endif #ifdef WIN32 @@ -60,9 +60,9 @@ typedef int socklen_t; typedef uint32_t in_addr_t; #define ETH_ALEN 6 /* Octets in one ethernet addr */ struct ether_header { - uint8_t ether_dhost[ETH_ALEN]; /* destination eth addr */ - uint8_t ether_shost[ETH_ALEN]; /* source ether addr */ - uint16_t ether_type; /* packet type ID field */ + uint8_t ether_dhost[ETH_ALEN]; /* destination eth addr */ + uint8_t ether_shost[ETH_ALEN]; /* source ether addr */ + uint16_t ether_type; /* packet type ID field */ } __PTATTR__; #endif /* WIN32 */ @@ -75,24 +75,24 @@ struct ether_header { * in packets from the client to the proxy. */ typedef struct { - /** magic number, used to identify ptunnel packets. */ - uint32_t magic; - /** destination IP and port (used by proxy to figure */ - uint32_t dst_ip; - /** out where to tunnel to) */ - uint32_t dst_port; - /** current connection state; see constants above. */ - uint32_t state; - /** sequence number of last packet received from other end */ - uint32_t ack; - /** length of data buffer */ - uint32_t data_len; - /** sequence number of this packet */ - uint16_t seq_no; - /** id number, used to separate different tunnels from each other */ - uint16_t id_no; - /** optional data buffer */ - char data[0]; + /** magic number, used to identify ptunnel packets. */ + uint32_t magic; + /** destination IP and port (used by proxy to figure */ + uint32_t dst_ip; + /** out where to tunnel to) */ + uint32_t dst_port; + /** current connection state; see constants above. */ + uint32_t state; + /** sequence number of last packet received from other end */ + uint32_t ack; + /** length of data buffer */ + uint32_t data_len; + /** sequence number of this packet */ + uint16_t seq_no; + /** id number, used to separate different tunnels from each other */ + uint16_t id_no; + /** optional data buffer */ + char data[0]; } __PTATTR__ ping_tunnel_pkt_t; /** ip_packet_t: This is basically my own definition of the IP packet, which @@ -100,17 +100,17 @@ typedef struct { * (or even the RFC) for info on the contents of this packet. */ typedef struct { - uint8_t vers_ihl; - uint8_t tos; - uint16_t pkt_len; - uint16_t id; - uint16_t flags_frag_offset; - uint8_t ttl; - uint8_t proto; // 1 for ICMP - uint16_t checksum; - uint32_t src_ip; - uint32_t dst_ip; - char data[0]; + uint8_t vers_ihl; + uint8_t tos; + uint16_t pkt_len; + uint16_t id; + uint16_t flags_frag_offset; + uint8_t ttl; + uint8_t proto; // 1 for ICMP + uint16_t checksum; + uint32_t src_ip; + uint32_t dst_ip; + char data[0]; } __PTATTR__ ip_packet_t; /** icmp_echo_packet_t: This is the definition of a standard ICMP header. The @@ -123,25 +123,24 @@ typedef struct { * taken care of by the OS. */ typedef struct { - uint8_t type; - uint8_t code; - uint16_t checksum; - uint16_t identifier; - uint16_t seq; - char data[0]; + uint8_t type; + uint8_t code; + uint16_t checksum; + uint16_t identifier; + uint16_t seq; + char data[0]; } __PTATTR__ icmp_echo_packet_t; typedef struct forward_desc_t forward_desc_t; typedef struct icmp_desc_t icmp_desc_t; typedef struct proxy_desc_t proxy_desc_t; +void handle_packet(char * buf, unsigned bytes, int is_pcap, struct sockaddr_in * addr, int icmp_sock); -void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *addr, int icmp_sock); +void handle_data(icmp_echo_packet_t * pkt, int total_len, proxy_desc_t * cur, int handle_extended_options); -void handle_data(icmp_echo_packet_t *pkt, int total_len, proxy_desc_t *cur, int handle_extended_options); +void handle_extended_options(proxy_desc_t * cur); -void handle_extended_options(proxy_desc_t *cur); - -void handle_ack(uint32_t seq_no, proxy_desc_t *cur); +void handle_ack(uint32_t seq_no, proxy_desc_t * cur); #endif |