From 62623efc5b700d58335fa994d2e2725863527575 Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Thu, 14 Jan 2016 04:42:05 +0200 Subject: Adding option to pass NAT info in TCP ACK of first SYN --- src/rx_check_header.h | 116 ++------------------------------------------------ 1 file changed, 3 insertions(+), 113 deletions(-) (limited to 'src/rx_check_header.h') diff --git a/src/rx_check_header.h b/src/rx_check_header.h index 54af2451..95dc60ad 100755 --- a/src/rx_check_header.h +++ b/src/rx_check_header.h @@ -1,12 +1,10 @@ -#ifndef RX_CHECK_HEADER -#define RX_CHECK_HEADER /* Hanoh Haim Cisco Systems, Inc. */ /* -Copyright (c) 2015-2015 Cisco Systems, Inc. +Copyright (c) 2015-2016 Cisco Systems, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -21,15 +19,14 @@ See the License for the specific language governing permissions and limitations under the License. */ +#ifndef RX_CHECK_HEADER +#define RX_CHECK_HEADER #include #include #include #include - -#include "os_time.h" - #define RX_CHECK_LEN (sizeof(struct CRx_check_header)) // IPv4 option type: @@ -103,113 +100,6 @@ public: void dump(FILE *fd); }; - -class CNatOption { -public: - enum { - noIPV4_OPTION = 0x10, /* dummy IPV4 option */ - noOPTION_LEN = 0x8, - noIPV4_MAGIC = 0xEE, - noIPV4_MAGIC_RX = 0xED, - - noIPV6_OPTION_LEN = (noOPTION_LEN/8)-1, - noIPV6_OPTION = 0x3C, /*IPv6-Opts Destination Options for IPv6 RFC 2460*/ - }; - void set_option_type(uint8_t id){ - u.m_data[0]=id; - } - uint8_t get_option_type(){ - return (u.m_data[0]); - } - - void set_option_len(uint8_t len){ - u.m_data[1]=len; - } - uint8_t get_option_len(){ - return ( u.m_data[1]); - } - - void set_thread_id(uint8_t thread_id){ - u.m_data[3]=thread_id; - } - uint8_t get_thread_id(){ - return (u.m_data[3]); - } - - void set_magic(uint8_t magic){ - u.m_data[2]=magic; - } - - uint8_t get_magic(){ - return (u.m_data[2]); - } - - void set_rx_check(bool enable){ - if (enable) { - set_magic(CNatOption::noIPV4_MAGIC_RX); - }else{ - set_magic(CNatOption::noIPV4_MAGIC); - } - } - bool is_rx_check(){ - if (get_magic() ==CNatOption::noIPV4_MAGIC_RX) { - return(true); - }else{ - return (false); - } - } - - - void set_fid(uint32_t fid){ - u.m_data_uint32[1]=fid; - } - uint32_t get_fid(){ - return (u.m_data_uint32[1]); - } - - bool is_valid_ipv4_magic_op0(void){ - return ( ( PKT_NTOHL( u.m_data_uint32[0] )& 0xFFFFFF00 ) == - (CNatOption::noIPV4_OPTION <<24) + (CNatOption::noOPTION_LEN<<16) + (CNatOption::noIPV4_MAGIC<<8) ?true:false); - } - - bool is_valid_ipv4_magic_op1(void){ - return ( ( PKT_NTOHL( u.m_data_uint32[0] )& 0xFFFFFF00 ) == - (CNatOption::noIPV4_OPTION <<24) + (CNatOption::noOPTION_LEN<<16) + (CNatOption::noIPV4_MAGIC_RX<<8) ?true:false); - } - - bool is_valid_ipv4_magic(void){ - return (is_valid_ipv4_magic_op0() ||is_valid_ipv4_magic_op1() ); - } - - - bool is_valid_ipv6_magic(void){ - return ( ( PKT_NTOHL( u.m_data_uint32[0] )& 0x00FFFF00 ) == - (CNatOption::noIPV6_OPTION_LEN<<16) + (CNatOption::noIPV4_MAGIC<<8) ?true:false); - - } - - void set_init_ipv4_header(){ - set_option_type(CNatOption::noIPV4_OPTION); - set_option_len(CNatOption::noOPTION_LEN); - set_magic(CNatOption::noIPV4_MAGIC); - } - - void set_init_ipv6_header(void){ - set_option_len(noIPV6_OPTION_LEN); - set_magic(CNatOption::noIPV4_MAGIC); - } - - void dump(FILE *fd); - - -private: - union u_ { - uint8_t m_data[8]; - uint32_t m_data_uint32[2]; - } u; -}; - - #endif -- cgit 1.2.3-korg