blob: 3ace9e3a148ff86fc66c46b4e51bb7b1e62e675f [file] [log] [blame]
Ben Menchaca84f36632014-02-28 20:57:38 +00001/*
2 **************************************************************************
Gareth Williams88be3722015-03-23 19:51:01 +00003 * Copyright (c) 2014, 2015, The Linux Foundation. All rights reserved.
Ben Menchaca84f36632014-02-28 20:57:38 +00004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
Murat Sezginb3731e82014-11-26 12:20:59 -080017#include <linux/version.h>
Ben Menchaca84f36632014-02-28 20:57:38 +000018#include <linux/types.h>
19#include <linux/ip.h>
20#include <linux/tcp.h>
21#include <linux/module.h>
22#include <linux/skbuff.h>
23#include <linux/icmp.h>
24#include <linux/sysctl.h>
25#include <linux/kthread.h>
Murat Sezgin1f381852014-11-20 09:51:07 -080026#include <linux/device.h>
Ben Menchaca84f36632014-02-28 20:57:38 +000027#include <linux/fs.h>
28#include <linux/pkt_sched.h>
29#include <linux/string.h>
30#include <net/route.h>
31#include <net/ip.h>
32#include <net/tcp.h>
33#include <asm/unaligned.h>
34#include <asm/uaccess.h> /* for put_user */
35#include <net/ipv6.h>
36#include <linux/inet.h>
37#include <linux/in.h>
38#include <linux/udp.h>
39#include <linux/tcp.h>
40
41#include <linux/netfilter_ipv4.h>
42#include <linux/netfilter_bridge.h>
43#include <net/netfilter/nf_conntrack.h>
44#include <net/netfilter/nf_conntrack_helper.h>
45#include <net/netfilter/nf_conntrack_l4proto.h>
46#include <net/netfilter/nf_conntrack_l3proto.h>
47#include <net/netfilter/nf_conntrack_core.h>
48#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
49#include <net/netfilter/ipv4/nf_defrag_ipv4.h>
50
51/*
52 * Debug output levels
53 * 0 = OFF
54 * 1 = ASSERTS / ERRORS
55 * 2 = 1 + WARN
56 * 3 = 2 + INFO
57 * 4 = 3 + TRACE
58 */
59#define DEBUG_LEVEL ECM_TRACKER_DEBUG_LEVEL
60
61#include "ecm_types.h"
62#include "ecm_db_types.h"
63#include "ecm_tracker.h"
64
Gareth Williams88be3722015-03-23 19:51:01 +000065#ifdef ECM_TRACKER_DPI_SUPPORT_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +000066int ecm_tracker_data_total = 0; /* Data total for all skb list instances */
67int ecm_tracker_data_buffer_total = 0; /* Data buffer total allocated for all skb list instances */
68int ecm_tracker_data_limit = ECM_TRACKER_GLOBAL_DATA_LIMIT_DEFAULT;
69int ecm_tracker_data_buffer_limit = ECM_TRACKER_GLOBAL_DATA_BUFFER_LIMIT_DEFAULT;
70 /* Tracked limit for data across all instances */
Murat Sezgin8c345822015-05-27 15:35:38 -070071static DEFINE_SPINLOCK(ecm_tracker_lock); /* Global lock for the tracker globals */
Gareth Williams88be3722015-03-23 19:51:01 +000072#endif
Ben Menchaca84f36632014-02-28 20:57:38 +000073
74struct ecm_tracker_ip_protocols;
75
76typedef bool (*ecm_tracker_ip_header_helper_method_t)(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
77 /* A header helper method is used to inspect a protocol header, determine if it is valid, its size etc. and where any next header will be esp. important for IPv6 */
78
79/*
80 * Forward references for the header helpers
81 */
82static bool ecm_tracker_ip_header_helper_tcp(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
83static bool ecm_tracker_ip_header_helper_udp(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
84static bool ecm_tracker_ip_header_helper_icmp(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
85static bool ecm_tracker_ip_header_helper_unknown(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
Gareth Williams8ac34292015-03-17 14:06:58 +000086static bool ecm_tracker_ip_header_helper_gre(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
87#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +000088static bool ecm_tracker_ip_header_helper_ipv6_generic(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
89static bool ecm_tracker_ip_header_helper_ipv6_fragment(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
Ben Menchaca84f36632014-02-28 20:57:38 +000090static bool ecm_tracker_ip_header_helper_ah(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
91static bool ecm_tracker_ip_header_helper_ipv6_icmp(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr);
Gareth Williams8ac34292015-03-17 14:06:58 +000092#endif
Ben Menchaca84f36632014-02-28 20:57:38 +000093
94/*
95 * struct ecm_tracker_ip_protocols_known[]
96 * A list of protocols known to the tracker and which it will record the location of in its ecm_tracker_ip_header.
97 *
98 * This is especially important for IPv6 which can have multiple headers in its packet.
99 */
100static struct ecm_tracker_ip_protocols {
101 uint8_t ip_protocol; /* The IP protocol we want to detect and record its information */
102 ecm_tracker_ip_protocol_type_t ecm_ip_protocol; /* The ECM Tracker protocol identifier equivalent */
103 char *name; /* Visual name of the protocol */
104 ecm_tracker_ip_header_helper_method_t header_helper; /* A function used to help process the header, e.g. its size etc. When a NULL helper is located, header processing stops. */
105} ecm_tracker_ip_protocols_known[256] =
106{
Gareth Williams8ac34292015-03-17 14:06:58 +0000107#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000108 {0, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_HBH, "ipv6_hbh", ecm_tracker_ip_header_helper_ipv6_generic},
Gareth Williams8ac34292015-03-17 14:06:58 +0000109#else
110 {0, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "0", ecm_tracker_ip_header_helper_unknown},
111#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000112 {1, ECM_TRACKER_IP_PROTOCOL_TYPE_ICMP, "icmp", ecm_tracker_ip_header_helper_icmp},
113 {2, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "2", ecm_tracker_ip_header_helper_unknown},
114 {3, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "3", ecm_tracker_ip_header_helper_unknown},
115 {4, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "4", ecm_tracker_ip_header_helper_unknown},
116 {5, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "5", ecm_tracker_ip_header_helper_unknown},
117 {6, ECM_TRACKER_IP_PROTOCOL_TYPE_TCP, "tcp", ecm_tracker_ip_header_helper_tcp},
118 {7, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "7", ecm_tracker_ip_header_helper_unknown},
119 {8, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "8", ecm_tracker_ip_header_helper_unknown},
120 {9, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "9", ecm_tracker_ip_header_helper_unknown},
121 {10, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "10", ecm_tracker_ip_header_helper_unknown},
122 {11, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "11", ecm_tracker_ip_header_helper_unknown},
123 {12, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "12", ecm_tracker_ip_header_helper_unknown},
124 {13, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "13", ecm_tracker_ip_header_helper_unknown},
125 {14, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "14", ecm_tracker_ip_header_helper_unknown},
126 {15, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "15", ecm_tracker_ip_header_helper_unknown},
127 {16, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "16", ecm_tracker_ip_header_helper_unknown},
128 {17, ECM_TRACKER_IP_PROTOCOL_TYPE_UDP, "udp", ecm_tracker_ip_header_helper_udp},
129 {18, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "18", ecm_tracker_ip_header_helper_unknown},
130 {19, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "19", ecm_tracker_ip_header_helper_unknown},
131 {20, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "20", ecm_tracker_ip_header_helper_unknown},
132 {21, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "21", ecm_tracker_ip_header_helper_unknown},
133 {22, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "22", ecm_tracker_ip_header_helper_unknown},
134 {23, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "23", ecm_tracker_ip_header_helper_unknown},
135 {24, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "24", ecm_tracker_ip_header_helper_unknown},
136 {25, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "25", ecm_tracker_ip_header_helper_unknown},
137 {26, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "26", ecm_tracker_ip_header_helper_unknown},
138 {27, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "27", ecm_tracker_ip_header_helper_unknown},
139 {28, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "28", ecm_tracker_ip_header_helper_unknown},
140 {29, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "29", ecm_tracker_ip_header_helper_unknown},
141 {30, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "30", ecm_tracker_ip_header_helper_unknown},
142 {31, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "31", ecm_tracker_ip_header_helper_unknown},
143 {32, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "32", ecm_tracker_ip_header_helper_unknown},
144 {33, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "33", ecm_tracker_ip_header_helper_unknown},
145 {34, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "34", ecm_tracker_ip_header_helper_unknown},
146 {35, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "35", ecm_tracker_ip_header_helper_unknown},
147 {36, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "36", ecm_tracker_ip_header_helper_unknown},
148 {37, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "37", ecm_tracker_ip_header_helper_unknown},
149 {38, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "38", ecm_tracker_ip_header_helper_unknown},
150 {39, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "39", ecm_tracker_ip_header_helper_unknown},
151 {40, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "40", ecm_tracker_ip_header_helper_unknown},
152 {41, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "41", ecm_tracker_ip_header_helper_unknown},
153 {42, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "42", ecm_tracker_ip_header_helper_unknown},
Gareth Williams8ac34292015-03-17 14:06:58 +0000154#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000155 {43, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_ROUTING, "ipv6_routing", ecm_tracker_ip_header_helper_ipv6_generic},
156 {44, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_FRAGMENT, "ipv6_fragment", ecm_tracker_ip_header_helper_ipv6_fragment},
Gareth Williams8ac34292015-03-17 14:06:58 +0000157#else
158 {43, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "43", ecm_tracker_ip_header_helper_unknown},
159 {44, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "44", ecm_tracker_ip_header_helper_unknown},
160#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000161 {45, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "45", ecm_tracker_ip_header_helper_unknown},
162 {46, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "46", ecm_tracker_ip_header_helper_unknown},
163 {47, ECM_TRACKER_IP_PROTOCOL_TYPE_GRE, "gre", ecm_tracker_ip_header_helper_gre},
164 {48, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "48", ecm_tracker_ip_header_helper_unknown},
165 {49, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "49", ecm_tracker_ip_header_helper_unknown},
166 {50, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "50", ecm_tracker_ip_header_helper_unknown},
Gareth Williams8ac34292015-03-17 14:06:58 +0000167#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000168 {51, ECM_TRACKER_IP_PROTOCOL_TYPE_AH, "ah", ecm_tracker_ip_header_helper_ah},
Gareth Williams8ac34292015-03-17 14:06:58 +0000169#else
170 {51, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "51", ecm_tracker_ip_header_helper_unknown},
171#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000172 {52, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "52", ecm_tracker_ip_header_helper_unknown},
173 {53, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "53", ecm_tracker_ip_header_helper_unknown},
174 {54, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "54", ecm_tracker_ip_header_helper_unknown},
175 {55, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "55", ecm_tracker_ip_header_helper_unknown},
Gareth Williams8ac34292015-03-17 14:06:58 +0000176#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000177 {56, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_ICMP, "ipv6_icmp", ecm_tracker_ip_header_helper_ipv6_icmp},
Gareth Williams8ac34292015-03-17 14:06:58 +0000178#else
179 {56, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "56", ecm_tracker_ip_header_helper_unknown},
180#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000181 {57, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "57", ecm_tracker_ip_header_helper_unknown},
182 {58, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "58", ecm_tracker_ip_header_helper_unknown},
183 {59, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "59", ecm_tracker_ip_header_helper_unknown},
Gareth Williams8ac34292015-03-17 14:06:58 +0000184#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000185 {60, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_DO, "ipv6_do", ecm_tracker_ip_header_helper_ipv6_generic},
Gareth Williams8ac34292015-03-17 14:06:58 +0000186#else
187 {60, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "60", ecm_tracker_ip_header_helper_unknown},
188#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000189 {61, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "61", ecm_tracker_ip_header_helper_unknown},
190 {62, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "62", ecm_tracker_ip_header_helper_unknown},
191 {63, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "63", ecm_tracker_ip_header_helper_unknown},
192 {64, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "64", ecm_tracker_ip_header_helper_unknown},
193 {65, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "65", ecm_tracker_ip_header_helper_unknown},
194 {66, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "66", ecm_tracker_ip_header_helper_unknown},
195 {67, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "67", ecm_tracker_ip_header_helper_unknown},
196 {68, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "68", ecm_tracker_ip_header_helper_unknown},
197 {69, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "69", ecm_tracker_ip_header_helper_unknown},
198 {70, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "70", ecm_tracker_ip_header_helper_unknown},
199 {71, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "71", ecm_tracker_ip_header_helper_unknown},
200 {72, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "72", ecm_tracker_ip_header_helper_unknown},
201 {73, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "73", ecm_tracker_ip_header_helper_unknown},
202 {74, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "74", ecm_tracker_ip_header_helper_unknown},
203 {75, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "75", ecm_tracker_ip_header_helper_unknown},
204 {76, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "76", ecm_tracker_ip_header_helper_unknown},
205 {77, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "77", ecm_tracker_ip_header_helper_unknown},
206 {78, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "78", ecm_tracker_ip_header_helper_unknown},
207 {79, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "79", ecm_tracker_ip_header_helper_unknown},
208 {80, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "80", ecm_tracker_ip_header_helper_unknown},
209 {81, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "81", ecm_tracker_ip_header_helper_unknown},
210 {82, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "82", ecm_tracker_ip_header_helper_unknown},
211 {83, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "83", ecm_tracker_ip_header_helper_unknown},
212 {84, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "84", ecm_tracker_ip_header_helper_unknown},
213 {85, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "85", ecm_tracker_ip_header_helper_unknown},
214 {86, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "86", ecm_tracker_ip_header_helper_unknown},
215 {87, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "87", ecm_tracker_ip_header_helper_unknown},
216 {88, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "88", ecm_tracker_ip_header_helper_unknown},
217 {89, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "89", ecm_tracker_ip_header_helper_unknown},
218 {90, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "90", ecm_tracker_ip_header_helper_unknown},
219 {91, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "91", ecm_tracker_ip_header_helper_unknown},
220 {92, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "92", ecm_tracker_ip_header_helper_unknown},
221 {93, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "93", ecm_tracker_ip_header_helper_unknown},
222 {94, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "94", ecm_tracker_ip_header_helper_unknown},
223 {95, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "95", ecm_tracker_ip_header_helper_unknown},
224 {96, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "96", ecm_tracker_ip_header_helper_unknown},
225 {97, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "97", ecm_tracker_ip_header_helper_unknown},
226 {98, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "98", ecm_tracker_ip_header_helper_unknown},
227 {99, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "99", ecm_tracker_ip_header_helper_unknown},
228 {100, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "100", ecm_tracker_ip_header_helper_unknown},
229 {101, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "101", ecm_tracker_ip_header_helper_unknown},
230 {102, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "102", ecm_tracker_ip_header_helper_unknown},
231 {103, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "103", ecm_tracker_ip_header_helper_unknown},
232 {104, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "104", ecm_tracker_ip_header_helper_unknown},
233 {105, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "105", ecm_tracker_ip_header_helper_unknown},
234 {106, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "106", ecm_tracker_ip_header_helper_unknown},
235 {107, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "107", ecm_tracker_ip_header_helper_unknown},
236 {108, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "108", ecm_tracker_ip_header_helper_unknown},
237 {109, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "109", ecm_tracker_ip_header_helper_unknown},
238 {110, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "110", ecm_tracker_ip_header_helper_unknown},
239 {111, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "111", ecm_tracker_ip_header_helper_unknown},
240 {112, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "112", ecm_tracker_ip_header_helper_unknown},
241 {113, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "113", ecm_tracker_ip_header_helper_unknown},
242 {114, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "114", ecm_tracker_ip_header_helper_unknown},
243 {115, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "115", ecm_tracker_ip_header_helper_unknown},
244 {116, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "116", ecm_tracker_ip_header_helper_unknown},
245 {117, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "117", ecm_tracker_ip_header_helper_unknown},
246 {118, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "118", ecm_tracker_ip_header_helper_unknown},
247 {119, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "119", ecm_tracker_ip_header_helper_unknown},
248 {120, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "120", ecm_tracker_ip_header_helper_unknown},
249 {121, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "121", ecm_tracker_ip_header_helper_unknown},
250 {122, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "122", ecm_tracker_ip_header_helper_unknown},
251 {123, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "123", ecm_tracker_ip_header_helper_unknown},
252 {124, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "124", ecm_tracker_ip_header_helper_unknown},
253 {125, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "125", ecm_tracker_ip_header_helper_unknown},
254 {126, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "126", ecm_tracker_ip_header_helper_unknown},
255 {127, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "127", ecm_tracker_ip_header_helper_unknown},
256 {128, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "128", ecm_tracker_ip_header_helper_unknown},
257 {129, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "129", ecm_tracker_ip_header_helper_unknown},
258 {130, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "130", ecm_tracker_ip_header_helper_unknown},
259 {131, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "131", ecm_tracker_ip_header_helper_unknown},
260 {132, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "132", ecm_tracker_ip_header_helper_unknown},
261 {133, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "133", ecm_tracker_ip_header_helper_unknown},
262 {134, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "134", ecm_tracker_ip_header_helper_unknown},
263 {135, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "135", ecm_tracker_ip_header_helper_unknown},
264 {136, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "136", ecm_tracker_ip_header_helper_unknown},
265 {137, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "137", ecm_tracker_ip_header_helper_unknown},
266 {138, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "138", ecm_tracker_ip_header_helper_unknown},
267 {139, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "139", ecm_tracker_ip_header_helper_unknown},
268 {140, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "140", ecm_tracker_ip_header_helper_unknown},
269 {141, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "141", ecm_tracker_ip_header_helper_unknown},
270 {142, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "142", ecm_tracker_ip_header_helper_unknown},
271 {143, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "143", ecm_tracker_ip_header_helper_unknown},
272 {144, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "144", ecm_tracker_ip_header_helper_unknown},
273 {145, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "145", ecm_tracker_ip_header_helper_unknown},
274 {146, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "146", ecm_tracker_ip_header_helper_unknown},
275 {147, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "147", ecm_tracker_ip_header_helper_unknown},
276 {148, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "148", ecm_tracker_ip_header_helper_unknown},
277 {149, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "149", ecm_tracker_ip_header_helper_unknown},
278 {150, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "150", ecm_tracker_ip_header_helper_unknown},
279 {151, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "151", ecm_tracker_ip_header_helper_unknown},
280 {152, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "152", ecm_tracker_ip_header_helper_unknown},
281 {153, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "153", ecm_tracker_ip_header_helper_unknown},
282 {154, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "154", ecm_tracker_ip_header_helper_unknown},
283 {155, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "155", ecm_tracker_ip_header_helper_unknown},
284 {156, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "156", ecm_tracker_ip_header_helper_unknown},
285 {157, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "157", ecm_tracker_ip_header_helper_unknown},
286 {158, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "158", ecm_tracker_ip_header_helper_unknown},
287 {159, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "159", ecm_tracker_ip_header_helper_unknown},
288 {160, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "160", ecm_tracker_ip_header_helper_unknown},
289 {161, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "161", ecm_tracker_ip_header_helper_unknown},
290 {162, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "162", ecm_tracker_ip_header_helper_unknown},
291 {163, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "163", ecm_tracker_ip_header_helper_unknown},
292 {164, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "164", ecm_tracker_ip_header_helper_unknown},
293 {165, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "165", ecm_tracker_ip_header_helper_unknown},
294 {166, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "166", ecm_tracker_ip_header_helper_unknown},
295 {167, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "167", ecm_tracker_ip_header_helper_unknown},
296 {168, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "168", ecm_tracker_ip_header_helper_unknown},
297 {169, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "169", ecm_tracker_ip_header_helper_unknown},
298 {170, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "170", ecm_tracker_ip_header_helper_unknown},
299 {171, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "171", ecm_tracker_ip_header_helper_unknown},
300 {172, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "172", ecm_tracker_ip_header_helper_unknown},
301 {173, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "173", ecm_tracker_ip_header_helper_unknown},
302 {174, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "174", ecm_tracker_ip_header_helper_unknown},
303 {175, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "175", ecm_tracker_ip_header_helper_unknown},
304 {176, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "176", ecm_tracker_ip_header_helper_unknown},
305 {177, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "177", ecm_tracker_ip_header_helper_unknown},
306 {178, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "178", ecm_tracker_ip_header_helper_unknown},
307 {179, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "179", ecm_tracker_ip_header_helper_unknown},
308 {180, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "180", ecm_tracker_ip_header_helper_unknown},
309 {181, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "181", ecm_tracker_ip_header_helper_unknown},
310 {182, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "182", ecm_tracker_ip_header_helper_unknown},
311 {183, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "183", ecm_tracker_ip_header_helper_unknown},
312 {184, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "184", ecm_tracker_ip_header_helper_unknown},
313 {185, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "185", ecm_tracker_ip_header_helper_unknown},
314 {186, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "186", ecm_tracker_ip_header_helper_unknown},
315 {187, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "187", ecm_tracker_ip_header_helper_unknown},
316 {188, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "188", ecm_tracker_ip_header_helper_unknown},
317 {189, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "189", ecm_tracker_ip_header_helper_unknown},
318 {190, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "190", ecm_tracker_ip_header_helper_unknown},
319 {191, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "191", ecm_tracker_ip_header_helper_unknown},
320 {192, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "192", ecm_tracker_ip_header_helper_unknown},
321 {193, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "193", ecm_tracker_ip_header_helper_unknown},
322 {194, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "194", ecm_tracker_ip_header_helper_unknown},
323 {195, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "195", ecm_tracker_ip_header_helper_unknown},
324 {196, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "196", ecm_tracker_ip_header_helper_unknown},
325 {197, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "197", ecm_tracker_ip_header_helper_unknown},
326 {198, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "198", ecm_tracker_ip_header_helper_unknown},
327 {199, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "199", ecm_tracker_ip_header_helper_unknown},
328 {200, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "200", ecm_tracker_ip_header_helper_unknown},
329 {201, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "201", ecm_tracker_ip_header_helper_unknown},
330 {202, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "202", ecm_tracker_ip_header_helper_unknown},
331 {203, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "203", ecm_tracker_ip_header_helper_unknown},
332 {204, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "204", ecm_tracker_ip_header_helper_unknown},
333 {205, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "205", ecm_tracker_ip_header_helper_unknown},
334 {206, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "206", ecm_tracker_ip_header_helper_unknown},
335 {207, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "207", ecm_tracker_ip_header_helper_unknown},
336 {208, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "208", ecm_tracker_ip_header_helper_unknown},
337 {209, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "209", ecm_tracker_ip_header_helper_unknown},
338 {210, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "210", ecm_tracker_ip_header_helper_unknown},
339 {211, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "211", ecm_tracker_ip_header_helper_unknown},
340 {212, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "212", ecm_tracker_ip_header_helper_unknown},
341 {213, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "213", ecm_tracker_ip_header_helper_unknown},
342 {214, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "214", ecm_tracker_ip_header_helper_unknown},
343 {215, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "215", ecm_tracker_ip_header_helper_unknown},
344 {216, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "216", ecm_tracker_ip_header_helper_unknown},
345 {217, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "217", ecm_tracker_ip_header_helper_unknown},
346 {218, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "218", ecm_tracker_ip_header_helper_unknown},
347 {219, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "219", ecm_tracker_ip_header_helper_unknown},
348 {220, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "220", ecm_tracker_ip_header_helper_unknown},
349 {221, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "221", ecm_tracker_ip_header_helper_unknown},
350 {222, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "222", ecm_tracker_ip_header_helper_unknown},
351 {223, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "223", ecm_tracker_ip_header_helper_unknown},
352 {224, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "224", ecm_tracker_ip_header_helper_unknown},
353 {225, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "225", ecm_tracker_ip_header_helper_unknown},
354 {226, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "226", ecm_tracker_ip_header_helper_unknown},
355 {227, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "227", ecm_tracker_ip_header_helper_unknown},
356 {228, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "228", ecm_tracker_ip_header_helper_unknown},
357 {229, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "229", ecm_tracker_ip_header_helper_unknown},
358 {230, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "230", ecm_tracker_ip_header_helper_unknown},
359 {231, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "231", ecm_tracker_ip_header_helper_unknown},
360 {232, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "232", ecm_tracker_ip_header_helper_unknown},
361 {233, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "233", ecm_tracker_ip_header_helper_unknown},
362 {234, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "234", ecm_tracker_ip_header_helper_unknown},
363 {235, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "235", ecm_tracker_ip_header_helper_unknown},
364 {236, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "236", ecm_tracker_ip_header_helper_unknown},
365 {237, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "237", ecm_tracker_ip_header_helper_unknown},
366 {238, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "238", ecm_tracker_ip_header_helper_unknown},
367 {239, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "239", ecm_tracker_ip_header_helper_unknown},
368 {240, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "240", ecm_tracker_ip_header_helper_unknown},
369 {241, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "241", ecm_tracker_ip_header_helper_unknown},
370 {242, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "242", ecm_tracker_ip_header_helper_unknown},
371 {243, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "243", ecm_tracker_ip_header_helper_unknown},
372 {244, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "244", ecm_tracker_ip_header_helper_unknown},
373 {245, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "245", ecm_tracker_ip_header_helper_unknown},
374 {246, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "246", ecm_tracker_ip_header_helper_unknown},
375 {247, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "247", ecm_tracker_ip_header_helper_unknown},
376 {248, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "248", ecm_tracker_ip_header_helper_unknown},
377 {249, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "249", ecm_tracker_ip_header_helper_unknown},
378 {250, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "250", ecm_tracker_ip_header_helper_unknown},
379 {251, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "251", ecm_tracker_ip_header_helper_unknown},
380 {252, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "252", ecm_tracker_ip_header_helper_unknown},
381 {253, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "253", ecm_tracker_ip_header_helper_unknown},
382 {254, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "254", ecm_tracker_ip_header_helper_unknown},
383 {255, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "255", ecm_tracker_ip_header_helper_unknown}
384};
385
Nicolas Costa1d9eb992014-05-15 10:01:03 -0500386static char *ecm_tracker_sender_state_strings[] = {
387 "Unknown",
388 "Establishing",
389 "Established",
390 "Closing",
391 "Closed",
392 "Fault"
393};
394
395static char *ecm_tracker_connection_state_strings[] = {
396 "Establishing",
397 "Established",
398 "Closing",
399 "Closed",
400 "Fault"
401};
402
Ben Menchaca84f36632014-02-28 20:57:38 +0000403/*
404 * ecm_tracker_ip_check_header_and_read()
Gareth Williams8ac34292015-03-17 14:06:58 +0000405 * Check that we have a complete network-level IP header, check it and return true if so.
Ben Menchaca84f36632014-02-28 20:57:38 +0000406 */
407bool ecm_tracker_ip_check_header_and_read(struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb)
408{
Matthew McClintock0ffc52e2014-09-19 14:41:23 -0500409 struct iphdr *v4_hdr = NULL;
Gareth Williams8ac34292015-03-17 14:06:58 +0000410 uint16_t remain;
411#ifdef ECM_IPV6_ENABLE
Matthew McClintock0ffc52e2014-09-19 14:41:23 -0500412 struct ipv6hdr *v6_hdr = NULL;
Ben Menchaca84f36632014-02-28 20:57:38 +0000413 int16_t this_header;
414 uint32_t offset;
Gareth Williams8ac34292015-03-17 14:06:58 +0000415#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000416
417 memset(ip_hdr, 0, sizeof(*ip_hdr));
418
419 ip_hdr->skb = skb;
420
421 /*
Gareth Williams8ac34292015-03-17 14:06:58 +0000422 * What version of IP header are we dealing with?
Ben Menchaca84f36632014-02-28 20:57:38 +0000423 */
424 v4_hdr = skb_header_pointer(skb, 0, sizeof(struct iphdr), &ip_hdr->h.v4_hdr);
425 if (v4_hdr && (v4_hdr->version == 4)) {
426 DEBUG_TRACE("%p: skb: %p is ipv4\n", ip_hdr, skb);
427 ip_hdr->is_v4 = true;
Gareth Williams8ac34292015-03-17 14:06:58 +0000428 goto version_check_done;
Ben Menchaca84f36632014-02-28 20:57:38 +0000429 }
430
Gareth Williams8ac34292015-03-17 14:06:58 +0000431#ifdef ECM_IPV6_ENABLE
432 /*
433 * Try V6
434 */
435 DEBUG_TRACE("skb: %p contains no v4 header\n", skb);
436 v6_hdr = skb_header_pointer(skb, 0, sizeof(struct ipv6hdr), &ip_hdr->h.v6_hdr);
437 if (!v6_hdr || (v6_hdr->version != 6)) {
438 DEBUG_TRACE("skb: %p contains no v6 header\n", skb);
439 return false;
440 }
441 DEBUG_TRACE("%p: skb: %p is ipv6\n", ip_hdr, skb);
442 ip_hdr->is_v4 = false;
443#else
444 DEBUG_TRACE("skb: %p Other IP header versions unsupported\n", skb);
445 return false;
446#endif
447
448version_check_done:
Ben Menchaca84f36632014-02-28 20:57:38 +0000449 if (ip_hdr->is_v4) {
450 uint8_t protocol;
451 int16_t next_unused;
452 ecm_tracker_ip_protocol_type_t ecm_ip_protocol;
453 struct ecm_tracker_ip_protocols *etip;
454 struct ecm_tracker_ip_protocol_header *etiph;
455
456 DEBUG_TRACE("%p: skb: %p ipv4\n", ip_hdr, skb);
457
458 /*
459 * Process IPv4
460 */
461 ECM_NIN4_ADDR_TO_IP_ADDR(ip_hdr->src_addr, v4_hdr->saddr);
462 ECM_NIN4_ADDR_TO_IP_ADDR(ip_hdr->dest_addr, v4_hdr->daddr);
463 ip_hdr->ip_header_length = v4_hdr->ihl;
464 ip_hdr->ip_header_length <<= 2;
465 if (ip_hdr->ip_header_length < 20) {
466 DEBUG_WARN("%p: v4 invalid ip hdr len %d\n", skb, ip_hdr->ip_header_length);
467 return false;
468 }
469 ip_hdr->total_length = ntohs(v4_hdr->tot_len);
470 if (skb->len < ip_hdr->total_length) {
471 DEBUG_WARN("%p: v4 invalid total len: %u skb len: %u\n", skb, ip_hdr->total_length, skb->len);
472 return false;
473 }
474 remain = ip_hdr->total_length - ip_hdr->ip_header_length;
475
476 /*
477 * Fragmented?
478 */
479 ip_hdr->fragmented = (ntohs(v4_hdr->frag_off) & 0x3fff)? true : false;
480
481 /*
Gareth Williams8932a912014-06-11 18:06:25 -0700482 * DS field
483 */
484 ip_hdr->ds = ipv4_get_dsfield(v4_hdr);
485
486 /*
Ben Menchaca84f36632014-02-28 20:57:38 +0000487 * Get the protocol and where the header info will be stored
488 */
489 protocol = v4_hdr->protocol;
490 ip_hdr->protocol = (int)v4_hdr->protocol;
491 etip = &ecm_tracker_ip_protocols_known[protocol]; /* Get header helper */
492 ecm_ip_protocol = etip->ecm_ip_protocol;
493 etiph = &ip_hdr->headers[ecm_ip_protocol]; /* Get where the header detail is stored in ip_hdr->headers[] */
494
495 DEBUG_TRACE("%p: v4 skb: %p, len: %d, ip_header_length: %u, total_length: %u, remain: %u, fragmented: %04x, protocol: %u, ecm_ip_protocol: %d src_addr: "
496 ECM_IP_ADDR_DOT_FMT ", dest addr: " ECM_IP_ADDR_DOT_FMT "\n",
497 ip_hdr,
498 skb,
499 skb->len,
500 ip_hdr->ip_header_length,
501 ip_hdr->total_length,
502 remain,
503 ip_hdr->fragmented,
504 ip_hdr->protocol,
505 ecm_ip_protocol,
506 ECM_IP_ADDR_TO_DOT(ip_hdr->src_addr),
507 ECM_IP_ADDR_TO_DOT(ip_hdr->dest_addr));
508
509 /*
510 * Populate protocol detail
511 * IPv4 can only have one.
512 */
513 if (!etip->header_helper(
514 etip,
515 etiph,
516 ip_hdr,
517 skb,
518 (uint8_t)ip_hdr->protocol,
519 ecm_ip_protocol,
520 ip_hdr->ip_header_length,
521 remain,
522 &next_unused)) {
523 DEBUG_WARN("%p: v4 header helper failed for: %u\n", skb, protocol);
524 return false;
525 }
Nicolas Costa585002e2014-05-15 09:46:04 -0500526
Ben Menchaca84f36632014-02-28 20:57:38 +0000527 return true;
528 }
529
Gareth Williams8ac34292015-03-17 14:06:58 +0000530#ifndef ECM_IPV6_ENABLE
531 return false;
532#else
Ben Menchaca84f36632014-02-28 20:57:38 +0000533 /*
534 * IPv6
535 */
536 ECM_NIN6_ADDR_TO_IP_ADDR(ip_hdr->src_addr, v6_hdr->saddr);
537 ECM_NIN6_ADDR_TO_IP_ADDR(ip_hdr->dest_addr, v6_hdr->daddr);
538 ip_hdr->ip_header_length = 40;
539 remain = ntohs(v6_hdr->payload_len);
540 ip_hdr->total_length = remain + 40;
541 if (skb->len < ip_hdr->total_length) {
542 DEBUG_WARN("%p: v6 invalid total len: %u skb len: %u\n", skb, ip_hdr->total_length, skb->len);
543 return false;
544 }
545
546 /*
Gareth Williams8932a912014-06-11 18:06:25 -0700547 * DS field
548 */
549 ip_hdr->ds = ipv6_get_dsfield(v6_hdr);
550
551 /*
Ben Menchaca84f36632014-02-28 20:57:38 +0000552 * Process headers until we run out of space, error, or we get the no next header marker for v6 (protocol 59).
553 */
554 offset = 40;
555 this_header = (int16_t)v6_hdr->nexthdr;
556 while ((remain > 0) && (this_header >= 0) && (this_header != 59)) {
557 struct ecm_tracker_ip_protocols *etip;
558 struct ecm_tracker_ip_protocol_header *etiph;
559 ecm_tracker_ip_protocol_type_t ecm_ip_protocol;
560 int16_t next_header;
561
562 etip = &ecm_tracker_ip_protocols_known[this_header]; /* Get header helper */
563 ecm_ip_protocol = etip->ecm_ip_protocol;
564 etiph = &ip_hdr->headers[ecm_ip_protocol]; /* Get where the header detail is stored in ip_hdr->headers[] */
565
566 /*
567 * If this IP header has already been seen then we abort
568 */
569 if (etiph->size) {
570 DEBUG_WARN("v6 skb: %p, protocol: %d already seen at offset: %u, size: %u\n",
571 skb, this_header, etiph->offset, etiph->size);
572 return false;
573 }
574 if (!etip->header_helper(
575 etip,
576 etiph,
577 ip_hdr,
578 skb,
579 (uint8_t)this_header,
580 ecm_ip_protocol,
581 offset,
582 remain,
583 &next_header)) {
584 DEBUG_WARN("%p: v6 header helper failed for: %d\n", skb, this_header);
585 return false;
586 }
587
588 offset += etiph->size;
589 DEBUG_ASSERT(remain >= etiph->size, "v6 remain: %u goes negative after header size: %u", remain, etiph->size);
590 remain -= etiph->size;
591
592 this_header = next_header;
593 }
594
595 /*
596 * Generally the last protocol seen is the upper layer protocol
597 */
598 ip_hdr->protocol = (int)this_header;
599
Gareth Williams8ac34292015-03-17 14:06:58 +0000600 return true;
601#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000602}
603EXPORT_SYMBOL(ecm_tracker_ip_check_header_and_read);
604
Gareth Williams8ac34292015-03-17 14:06:58 +0000605#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000606/*
607 * ecm_tracker_ip_header_helper_ipv6_generic()
608 * Interpret a Generic IPv6 extension header
609 */
610static bool ecm_tracker_ip_header_helper_ipv6_generic(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
611 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
612{
613 struct ipv6_gen_hdr {
614 uint8_t next_protocol;
615 uint8_t header_ext_len;
616 } gen_header_buffer;
617 struct ipv6_gen_hdr *gen_header;
618 uint16_t hdr_size;
619
620 /*
621 * At least 8 bytes
622 */
623 if (remain < 8) {
624 return false;
625 }
626
627 gen_header = skb_header_pointer(skb, offset, sizeof(struct ipv6_gen_hdr), &gen_header_buffer);
628 if (!gen_header) {
629 return false;
630 }
631 hdr_size = gen_header->header_ext_len;
632 hdr_size <<= 3;
633 hdr_size += 8;
634 if (remain < hdr_size) {
635 DEBUG_WARN("IPv6 extension: %p packet remain: %u too small for tcp header: %u\n", skb, remain, hdr_size);
636 return false;
637 }
638 if (unlikely(ip_hdr->total_length < (offset + hdr_size))) {
639 DEBUG_WARN("TCP packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
640 return false;
641 }
642
643 etiph->protocol_number = protocol;
644 etiph->header_size = hdr_size;
645 etiph->size = hdr_size;
646 etiph->offset = offset;
647
648 *next_hdr = (int16_t)gen_header->next_protocol;
Nicolas Costa585002e2014-05-15 09:46:04 -0500649 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000650}
651
652/*
653 * ecm_tracker_ip_header_helper_ipv6_fragment()
654 * Interpret a Generic IPv6 fragment header
655 */
656static bool ecm_tracker_ip_header_helper_ipv6_fragment(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
657 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
658{
659 struct ipv6_gen_hdr {
660 uint8_t next_protocol;
661 uint8_t reserved;
662 } gen_header_buffer;
663 struct ipv6_gen_hdr *gen_header;
664
665 /*
666 * At least 8 bytes
667 */
668 if (remain < 8) {
669 return false;
670 }
671
672 gen_header = skb_header_pointer(skb, offset, sizeof(struct ipv6_gen_hdr), &gen_header_buffer);
673 if (!gen_header) {
674 return false;
675 }
676 if (unlikely(ip_hdr->total_length < (offset + 8))) {
677 DEBUG_WARN("TCP packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + 8);
678 return false;
679 }
680
681 /*
682 * The very presence of a fragmemt header says it's fragmented
683 */
684 ip_hdr->fragmented = true;
685
686 etiph->protocol_number = protocol;
687 etiph->header_size = 8;
688 etiph->size = 8;
689 etiph->offset = offset;
690
691 *next_hdr = (int16_t)gen_header->next_protocol;
Nicolas Costa585002e2014-05-15 09:46:04 -0500692 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000693}
694
695/*
Gareth Williams8ac34292015-03-17 14:06:58 +0000696 * ecm_tracker_ip_header_helper_ah()
697 * Interpret an Authentication Header
698 */
699static bool ecm_tracker_ip_header_helper_ah(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
700 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
701{
702 struct ah_gen_hdr {
703 uint8_t next_protocol;
704 uint8_t header_len;
705 } gen_header_buffer;
706 struct ah_gen_hdr *gen_header;
707 uint16_t hdr_size;
708
709 /*
710 * At least 8 bytes
711 */
712 if (remain < 8) {
713 return false;
714 }
715
716 gen_header = skb_header_pointer(skb, offset, sizeof(struct ah_gen_hdr), &gen_header_buffer);
717 if (!gen_header) {
718 return false;
719 }
720
721 hdr_size = gen_header->header_len + 2;
722 hdr_size <<= 2;
723
724 if (!ip_hdr->is_v4) {
725 /*
726 * hdr_size needs to be a multiple of 8 in a v6 frame
727 */
728 if (hdr_size % 8) {
729 DEBUG_WARN("AH packet %p not multiple of 8 for v6 frame: %u\n", skb, hdr_size);
730 return false;
731 }
732 }
733
734 if (remain < hdr_size) {
735 DEBUG_WARN("AH packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
736 return false;
737 }
738 if (unlikely(ip_hdr->total_length < (offset + hdr_size))) {
739 DEBUG_WARN("AH packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
740 return false;
741 }
742
743 /*
744 * What header follows this one?
745 */
746 *next_hdr = gen_header->next_protocol;
747
748 etiph->protocol_number = protocol;
749 etiph->header_size = hdr_size;
750 etiph->size = hdr_size;
751 etiph->offset = offset;
752 return true;
753}
754
755/*
756 * ecm_tracker_ip_header_helper_ipv6_icmp()
757 * Interpret a ICMP V6 header
758 */
759static bool ecm_tracker_ip_header_helper_ipv6_icmp(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
760 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
761{
762 if (remain < 4) {
763 DEBUG_WARN("v6 icmp: %p too small: %u\n", skb, remain);
764 return false;
765 }
766
767 etiph->protocol_number = protocol;
768 etiph->header_size = 4;
769 etiph->size = remain;
770 etiph->offset = offset;
771
772 /*
773 * There is no header following a V6 ICMP header
774 */
775 *next_hdr = -1;
776 return true;
777}
778
779#endif
780
781/*
Ben Menchaca84f36632014-02-28 20:57:38 +0000782 * ecm_tracker_ip_header_helper_tcp()
783 * Interpret a TCP header
784 */
785static bool ecm_tracker_ip_header_helper_tcp(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
786 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
787{
788 struct tcphdr tcp_header_buffer;
789 struct tcphdr *tcp_header;
790 uint16_t hdr_size;
791
792 DEBUG_ASSERT((protocol == IPPROTO_TCP) && (ecm_ip_protocol == ECM_TRACKER_IP_PROTOCOL_TYPE_TCP), "Bad protocol: %u or ecm_ip_protocol: %d", protocol, ecm_ip_protocol);
793
794 if (remain < 20) {
795 return false;
796 }
797
798 tcp_header = skb_header_pointer(skb, offset, sizeof(struct tcphdr), &tcp_header_buffer);
799 if (!tcp_header) {
800 return false;
801 }
802 hdr_size = tcp_header->doff;
803 hdr_size <<= 2;
804 if (hdr_size < 20) {
805 return false;
806 }
807 if (remain < hdr_size) {
808 DEBUG_WARN("TCP packet: %p packet remain: %u too small for tcp header: %u\n", skb, remain, hdr_size);
809 return false;
810 }
811 if (unlikely(ip_hdr->total_length < (offset + hdr_size))) {
812 DEBUG_WARN("TCP packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
813 return false;
814 }
815
816 etiph->protocol_number = protocol;
817 etiph->header_size = hdr_size;
818 etiph->size = remain;
819 etiph->offset = offset;
820
821 /*
822 * There is no header following a TCP header
823 */
824 *next_hdr = -1;
Nicolas Costa585002e2014-05-15 09:46:04 -0500825 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000826}
827
828/*
829 * ecm_tracker_ip_header_helper_gre()
830 * Interpret a GRE header
831 */
832static bool ecm_tracker_ip_header_helper_gre(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
833 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
834{
835 uint32_t gre_hdr_buffer;
836 uint32_t *gre_hdr_ptr;
837 uint32_t gre_hdr;
838 uint16_t hdr_size;
839
840 DEBUG_ASSERT((protocol == IPPROTO_GRE) && (ecm_ip_protocol == ECM_TRACKER_IP_PROTOCOL_TYPE_GRE), "Bad protocol: %u or ecm_ip_protocol: %d", protocol, ecm_ip_protocol);
841
842 if (remain < 4) {
843 return false;
844 }
845
846 gre_hdr_ptr = skb_header_pointer(skb, offset, sizeof(gre_hdr_buffer), &gre_hdr_buffer);
847 if (!gre_hdr_ptr) {
848 return false;
849 }
850 gre_hdr = ntohl(*gre_hdr_ptr);
851 hdr_size = 4;
852 if (gre_hdr & 0x80000000) {
853 /*
854 * Checksum
855 */
856 hdr_size += 4;
857 }
858 if (gre_hdr & 0x20000000) {
859 /*
860 * Key
861 */
862 hdr_size += 4;
863 }
864 if (gre_hdr & 0x10000000) {
865 /*
866 * Sequence
867 */
868 hdr_size += 4;
869 }
870 if (remain < hdr_size) {
871 DEBUG_WARN("GRE packet: %p packet remain: %u too small for tcp header: %u\n", skb, remain, hdr_size);
872 return false;
873 }
874 if (unlikely(ip_hdr->total_length < (offset + hdr_size))) {
875 DEBUG_WARN("GRE packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
876 return false;
877 }
878
879 etiph->protocol_number = protocol;
880 etiph->header_size = hdr_size;
881 etiph->size = remain;
882 etiph->offset = offset;
883
884 /*
885 * There is no header following a GRE header
886 */
887 *next_hdr = -1;
Nicolas Costa585002e2014-05-15 09:46:04 -0500888 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000889}
890
891/*
Ben Menchaca84f36632014-02-28 20:57:38 +0000892 * ecm_tracker_ip_header_helper_udp()
893 * Interpret a UDP header
894 */
895static bool ecm_tracker_ip_header_helper_udp(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
896 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
897{
898 DEBUG_ASSERT((protocol == IPPROTO_UDP) && (ecm_ip_protocol == ECM_TRACKER_IP_PROTOCOL_TYPE_UDP), "Bad protocol: %u or ecm_ip_protocol: %d", protocol, ecm_ip_protocol);
899
900 DEBUG_TRACE("udp helper skb: %p, protocol: %u, ecm_ip_proto: %d, offset: %u, remain: %u\n", skb, protocol, ecm_ip_protocol, offset, remain);
901 if (remain < 8) {
902 DEBUG_TRACE("not enough UDP header: %u\n", remain);
903 return false;
904 }
905
906 etiph->protocol_number = protocol;
907 etiph->header_size = 8;
908 etiph->size = remain;
909 etiph->offset = offset;
910
911 /*
912 * There is no header following a UDP header
913 */
914 *next_hdr = -1;
Nicolas Costa585002e2014-05-15 09:46:04 -0500915 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000916}
917
918/*
919 * ecm_tracker_ip_header_helper_unknown()
920 * Interpret a unknown header
921 */
922static bool ecm_tracker_ip_header_helper_unknown(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
923 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
924{
925 /*
926 * There is no header following an unknown header
927 */
928 *next_hdr = -1;
929 etiph->protocol_number = protocol;
930 etiph->header_size = remain;
931 etiph->size = remain;
932 etiph->offset = offset;
Nicolas Costa585002e2014-05-15 09:46:04 -0500933 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000934}
935
936/*
937 * ecm_tracker_ip_header_helper_icmp()
938 * Interpret a ICMP V4 header
939 */
940static bool ecm_tracker_ip_header_helper_icmp(struct ecm_tracker_ip_protocols *etip, struct ecm_tracker_ip_protocol_header *etiph, struct ecm_tracker_ip_header *ip_hdr,
941 struct sk_buff *skb, uint8_t protocol, ecm_tracker_ip_protocol_type_t ecm_ip_protocol, uint32_t offset, uint32_t remain, int16_t *next_hdr)
942{
943 struct icmphdr icmp_header_buffer;
944 struct icmphdr *icmp_header;
945
946 DEBUG_ASSERT((protocol == IPPROTO_ICMP) && (ecm_ip_protocol == ECM_TRACKER_IP_PROTOCOL_TYPE_ICMP), "Bad protocol: %u or ecm_ip_protocol: %d", protocol, ecm_ip_protocol);
947
948 if (remain < 8) {
949 return false;
950 }
951
952 icmp_header = skb_header_pointer(skb, offset, sizeof(struct icmphdr), &icmp_header_buffer);
953 if (!icmp_header) {
954 return false;
955 }
956 switch(icmp_header->type) {
957 case ICMP_SOURCE_QUENCH:
958 case ICMP_REDIRECT:
959 case ICMP_TIME_EXCEEDED:
960 case ICMP_DEST_UNREACH:
961 /*
962 * Should be at least our 8 bytes and minimum 20 bytes for an IP header.
963 * NOTE: We are not looking at options that extend this header!
964 */
965 if (remain < 28) {
966 DEBUG_WARN("icmp skb: %p type: %u too small: %u\n", skb, icmp_header->type, remain);
967 return false;
968 }
969 etiph->header_size = 8;
970 etiph->size = remain;
971 break;
972
973 case ICMP_ADDRESS:
974 case ICMP_ADDRESSREPLY:
975 case ICMP_TIMESTAMP:
976 if (remain < 12) {
977 DEBUG_WARN("icmp skb: %p type: %u too small: %u\n", skb, icmp_header->type, remain);
978 return false;
979 }
980 etiph->header_size = 12;
981 etiph->size = remain;
982 break;
983 case ICMP_TIMESTAMPREPLY:
984 if (remain < 20) {
985 DEBUG_WARN("icmp skb: %p type: %u too small: %u\n", skb, icmp_header->type, remain);
986 return false;
987 }
988 etiph->header_size = 20;
989 etiph->size = remain;
990 break;
991 case ICMP_PARAMETERPROB:
992 case ICMP_INFO_REQUEST:
993 case ICMP_INFO_REPLY:
994 default:
995 etiph->header_size = 8;
996 etiph->size = remain;
997 }
998 etiph->protocol_number = protocol;
999 etiph->offset = offset;
1000
1001 /*
1002 * There is no header following a ICMP header
1003 */
1004 *next_hdr = -1;
Nicolas Costa585002e2014-05-15 09:46:04 -05001005 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +00001006}
1007
Gareth Williams88be3722015-03-23 19:51:01 +00001008#ifdef ECM_TRACKER_DPI_SUPPORT_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +00001009/*
Ben Menchaca84f36632014-02-28 20:57:38 +00001010 * ecm_tracker_data_limit_set()
1011 * Set global tracked data limit
1012 */
1013void ecm_tracker_data_limit_set(uint32_t limit)
1014{
1015 int data_limit = (int)limit;
1016 DEBUG_ASSERT(data_limit > 0, "Invalid limit %d\n", data_limit);
1017 spin_lock_bh(&ecm_tracker_lock);
1018 ecm_tracker_data_limit = data_limit;
1019 spin_unlock_bh(&ecm_tracker_lock);
1020}
1021EXPORT_SYMBOL(ecm_tracker_data_limit_set);
1022
1023/*
1024 * ecm_tracker_data_limit_get()
1025 * Return global tracked data limit
1026 */
1027uint32_t ecm_tracker_data_limit_get(void)
1028{
1029 uint32_t data_total;
1030 spin_lock_bh(&ecm_tracker_lock);
1031 data_total = (uint32_t)ecm_tracker_data_limit;
1032 spin_unlock_bh(&ecm_tracker_lock);
1033 return data_total;
1034}
1035EXPORT_SYMBOL(ecm_tracker_data_limit_get);
1036
1037/*
1038 * ecm_tracker_data_total_get()
1039 * Return global tracked data quantity
1040 */
1041uint32_t ecm_tracker_data_total_get(void)
1042{
1043 uint32_t data_total;
1044 spin_lock_bh(&ecm_tracker_lock);
1045 data_total = (uint32_t)ecm_tracker_data_total;
1046 spin_unlock_bh(&ecm_tracker_lock);
1047 return data_total;
1048}
1049EXPORT_SYMBOL(ecm_tracker_data_total_get);
1050
1051/*
1052 * ecm_tracker_data_buffer_total_get()
1053 * Return global tracked data buffer size
1054 */
1055uint32_t ecm_tracker_data_buffer_total_get(void)
1056{
1057 uint32_t data_buffer_total;
1058 spin_lock_bh(&ecm_tracker_lock);
1059 data_buffer_total = (uint32_t)ecm_tracker_data_buffer_total;
1060 spin_unlock_bh(&ecm_tracker_lock);
1061 return data_buffer_total;
1062}
1063EXPORT_SYMBOL(ecm_tracker_data_buffer_total_get);
1064
1065/*
1066 * ecm_tracker_data_total_increase()
1067 * Increase global tracked data quantity
1068 *
1069 * If this function returns false then the increase has been denied and tracking of that data should not occur.
1070 * Therefore call this function BEFORE tracking the actual data.
1071 */
1072bool ecm_tracker_data_total_increase(uint32_t n, uint32_t data_buffer_size)
1073{
1074 spin_lock_bh(&ecm_tracker_lock);
1075
1076 /*
1077 * Would we exceed our global limit?
1078 */
1079 DEBUG_ASSERT((ecm_tracker_data_total + (int)n) > 0, "bad total\n");
1080 if (((ecm_tracker_data_buffer_total + data_buffer_size) > ecm_tracker_data_buffer_limit)
1081 || ((ecm_tracker_data_total + n) > ecm_tracker_data_limit)) {
1082 spin_unlock_bh(&ecm_tracker_lock);
1083 return false;
1084 }
1085 ecm_tracker_data_buffer_total += data_buffer_size;
1086 ecm_tracker_data_total += (int)n;
1087 spin_unlock_bh(&ecm_tracker_lock);
1088 return true;
1089}
1090EXPORT_SYMBOL(ecm_tracker_data_total_increase);
1091
1092/*
1093 * ecm_tracker_data_total_decrease()
1094 * Decrease global tracked data quantity
1095 */
1096void ecm_tracker_data_total_decrease(uint32_t n, uint32_t data_buffer_size)
1097{
1098 spin_lock_bh(&ecm_tracker_lock);
1099 ecm_tracker_data_total -= (int)n;
1100 ecm_tracker_data_buffer_total -= data_buffer_size;
1101 DEBUG_ASSERT(ecm_tracker_data_total >= 0, "bad total\n");
1102 DEBUG_ASSERT(ecm_tracker_data_buffer_total >= 0, "bad total\n");
1103 spin_unlock_bh(&ecm_tracker_lock);
1104}
1105EXPORT_SYMBOL(ecm_tracker_data_total_decrease);
Gareth Williams88be3722015-03-23 19:51:01 +00001106#endif
Ben Menchaca84f36632014-02-28 20:57:38 +00001107
1108/*
1109 * ecm_tracker_module_get()
1110 * Take a reference to the module
1111 */
1112void ecm_tracker_module_get(void)
1113{
1114 try_module_get(THIS_MODULE);
1115}
1116EXPORT_SYMBOL(ecm_tracker_module_get);
1117
1118/*
1119 * ecm_tracker_module_put()
1120 * Release a reference to the module
1121 */
1122void ecm_tracker_module_put(void)
1123{
1124 module_put(THIS_MODULE);
1125}
1126EXPORT_SYMBOL(ecm_tracker_module_put);
1127
Gareth Williams88be3722015-03-23 19:51:01 +00001128/*
1129 * ecm_tracker_sender_state_to_string()
1130 * Convert a sender state to a string equivalent
1131 */
1132const char *ecm_tracker_sender_state_to_string(enum ecm_tracker_sender_states s)
Nicolas Costa1d9eb992014-05-15 10:01:03 -05001133{
1134 return ecm_tracker_sender_state_strings[s];
1135}
1136EXPORT_SYMBOL(ecm_tracker_sender_state_to_string);
1137
Gareth Williams88be3722015-03-23 19:51:01 +00001138/*
1139 * ecm_tracker_connection_state_to_string()
1140 * Convert a connection state to its string equivalent
1141 */
1142const char *ecm_tracker_connection_state_to_string(enum ecm_tracker_connection_states s)
Nicolas Costa1d9eb992014-05-15 10:01:03 -05001143{
1144 return ecm_tracker_connection_state_strings[s];
1145}
1146EXPORT_SYMBOL(ecm_tracker_connection_state_to_string);