summaryrefslogtreecommitdiffstats
path: root/src/nat_check.h
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-12-21 15:36:35 +0200
committerIdo Barnea <ibarnea@cisco.com>2016-12-22 10:18:40 +0200
commite528048b2a9c99899cf1f69a2c11f51a383384db (patch)
treeac62991d084126877afe505de4dfbd58ddedefe1 /src/nat_check.h
parent1eea3fc8a3721b10e062401f7e47ccf18e59fbe5 (diff)
Support for UDP with --learn_mode 1 and 3 (TCP ACK) using IP_ID
Signed-off-by: Ido Barnea <ibarnea@cisco.com>
Diffstat (limited to 'src/nat_check.h')
-rwxr-xr-xsrc/nat_check.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/nat_check.h b/src/nat_check.h
index 538cf888..2af0a936 100755
--- a/src/nat_check.h
+++ b/src/nat_check.h
@@ -33,7 +33,8 @@ limitations under the License.
// 2msec timeout
#define MAX_TIME_MSG_IN_QUEUE_SEC ( 0.002 )
-#define NAT_FLOW_ID_MASK 0x00ffffff
+#define NAT_FLOW_ID_MASK_TCP_ACK 0x00ffffff
+#define NAT_FLOW_ID_MASK_IP_ID 0x000001ff
class CNatOption {
public:
@@ -78,8 +79,9 @@ public:
return (u.m_data[2]);
}
+ // Used when doing NAT using IP option
void set_fid(uint32_t fid) {
- u.m_data_uint32[1] = fid & NAT_FLOW_ID_MASK;
+ u.m_data_uint32[1] = fid & NAT_FLOW_ID_MASK_TCP_ACK;
}
uint32_t get_fid() {
@@ -225,9 +227,14 @@ public:
void Dump(FILE *fd);
void DumpShort(FILE *fd);
static inline uint32_t calc_tcp_ack_val(uint32_t fid, uint8_t thread_id) {
- return ((fid & NAT_FLOW_ID_MASK) << 8) | thread_id;
+ return ((fid & NAT_FLOW_ID_MASK_TCP_ACK) << 8) | thread_id;
+ }
+ static inline uint16_t calc_ip_id_val(uint32_t fid, uint8_t thread_id) {
+ // MSB bit == 1 signals this is latency packet
+ return ((fid & NAT_FLOW_ID_MASK_IP_ID) << 6) | (thread_id & 0x3f) | 0x8000;
}
void get_info_from_tcp_ack(uint32_t tcp_ack, uint32_t &fid, uint8_t &thread_id);
+ void get_info_from_ip_id(uint16_t ip_id, uint32_t &fid, uint8_t &thread_id);
private:
CNatPerThreadInfo * get_thread_info(uint8_t thread_id);
void flush_node(CNatPerThreadInfo * thread_info);