blob: 5c74bd5266b8f809a797868a5d63de4a139fce67 [file] [log] [blame]
Ben Menchaca84f36632014-02-28 20:57:38 +00001/*
2 **************************************************************************
3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
4 * 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
65int ecm_tracker_data_total = 0; /* Data total for all skb list instances */
66int ecm_tracker_data_buffer_total = 0; /* Data buffer total allocated for all skb list instances */
67int ecm_tracker_data_limit = ECM_TRACKER_GLOBAL_DATA_LIMIT_DEFAULT;
68int ecm_tracker_data_buffer_limit = ECM_TRACKER_GLOBAL_DATA_BUFFER_LIMIT_DEFAULT;
69 /* Tracked limit for data across all instances */
70spinlock_t ecm_tracker_lock; /* Global lock for the tracker globals */
71
72struct ecm_tracker_ip_protocols;
73
74typedef 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);
75 /* 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 */
76
77/*
78 * Forward references for the header helpers
79 */
80static 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);
81static 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);
82static 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);
83static 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 +000084static 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);
85#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +000086static 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);
87static 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 +000088static 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);
89static 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 +000090#endif
Ben Menchaca84f36632014-02-28 20:57:38 +000091
92/*
93 * struct ecm_tracker_ip_protocols_known[]
94 * A list of protocols known to the tracker and which it will record the location of in its ecm_tracker_ip_header.
95 *
96 * This is especially important for IPv6 which can have multiple headers in its packet.
97 */
98static struct ecm_tracker_ip_protocols {
99 uint8_t ip_protocol; /* The IP protocol we want to detect and record its information */
100 ecm_tracker_ip_protocol_type_t ecm_ip_protocol; /* The ECM Tracker protocol identifier equivalent */
101 char *name; /* Visual name of the protocol */
102 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. */
103} ecm_tracker_ip_protocols_known[256] =
104{
Gareth Williams8ac34292015-03-17 14:06:58 +0000105#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000106 {0, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_HBH, "ipv6_hbh", ecm_tracker_ip_header_helper_ipv6_generic},
Gareth Williams8ac34292015-03-17 14:06:58 +0000107#else
108 {0, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "0", ecm_tracker_ip_header_helper_unknown},
109#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000110 {1, ECM_TRACKER_IP_PROTOCOL_TYPE_ICMP, "icmp", ecm_tracker_ip_header_helper_icmp},
111 {2, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "2", ecm_tracker_ip_header_helper_unknown},
112 {3, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "3", ecm_tracker_ip_header_helper_unknown},
113 {4, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "4", ecm_tracker_ip_header_helper_unknown},
114 {5, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "5", ecm_tracker_ip_header_helper_unknown},
115 {6, ECM_TRACKER_IP_PROTOCOL_TYPE_TCP, "tcp", ecm_tracker_ip_header_helper_tcp},
116 {7, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "7", ecm_tracker_ip_header_helper_unknown},
117 {8, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "8", ecm_tracker_ip_header_helper_unknown},
118 {9, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "9", ecm_tracker_ip_header_helper_unknown},
119 {10, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "10", ecm_tracker_ip_header_helper_unknown},
120 {11, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "11", ecm_tracker_ip_header_helper_unknown},
121 {12, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "12", ecm_tracker_ip_header_helper_unknown},
122 {13, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "13", ecm_tracker_ip_header_helper_unknown},
123 {14, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "14", ecm_tracker_ip_header_helper_unknown},
124 {15, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "15", ecm_tracker_ip_header_helper_unknown},
125 {16, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "16", ecm_tracker_ip_header_helper_unknown},
126 {17, ECM_TRACKER_IP_PROTOCOL_TYPE_UDP, "udp", ecm_tracker_ip_header_helper_udp},
127 {18, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "18", ecm_tracker_ip_header_helper_unknown},
128 {19, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "19", ecm_tracker_ip_header_helper_unknown},
129 {20, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "20", ecm_tracker_ip_header_helper_unknown},
130 {21, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "21", ecm_tracker_ip_header_helper_unknown},
131 {22, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "22", ecm_tracker_ip_header_helper_unknown},
132 {23, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "23", ecm_tracker_ip_header_helper_unknown},
133 {24, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "24", ecm_tracker_ip_header_helper_unknown},
134 {25, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "25", ecm_tracker_ip_header_helper_unknown},
135 {26, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "26", ecm_tracker_ip_header_helper_unknown},
136 {27, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "27", ecm_tracker_ip_header_helper_unknown},
137 {28, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "28", ecm_tracker_ip_header_helper_unknown},
138 {29, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "29", ecm_tracker_ip_header_helper_unknown},
139 {30, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "30", ecm_tracker_ip_header_helper_unknown},
140 {31, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "31", ecm_tracker_ip_header_helper_unknown},
141 {32, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "32", ecm_tracker_ip_header_helper_unknown},
142 {33, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "33", ecm_tracker_ip_header_helper_unknown},
143 {34, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "34", ecm_tracker_ip_header_helper_unknown},
144 {35, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "35", ecm_tracker_ip_header_helper_unknown},
145 {36, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "36", ecm_tracker_ip_header_helper_unknown},
146 {37, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "37", ecm_tracker_ip_header_helper_unknown},
147 {38, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "38", ecm_tracker_ip_header_helper_unknown},
148 {39, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "39", ecm_tracker_ip_header_helper_unknown},
149 {40, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "40", ecm_tracker_ip_header_helper_unknown},
150 {41, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "41", ecm_tracker_ip_header_helper_unknown},
151 {42, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "42", ecm_tracker_ip_header_helper_unknown},
Gareth Williams8ac34292015-03-17 14:06:58 +0000152#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000153 {43, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_ROUTING, "ipv6_routing", ecm_tracker_ip_header_helper_ipv6_generic},
154 {44, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_FRAGMENT, "ipv6_fragment", ecm_tracker_ip_header_helper_ipv6_fragment},
Gareth Williams8ac34292015-03-17 14:06:58 +0000155#else
156 {43, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "43", ecm_tracker_ip_header_helper_unknown},
157 {44, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "44", ecm_tracker_ip_header_helper_unknown},
158#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000159 {45, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "45", ecm_tracker_ip_header_helper_unknown},
160 {46, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "46", ecm_tracker_ip_header_helper_unknown},
161 {47, ECM_TRACKER_IP_PROTOCOL_TYPE_GRE, "gre", ecm_tracker_ip_header_helper_gre},
162 {48, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "48", ecm_tracker_ip_header_helper_unknown},
163 {49, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "49", ecm_tracker_ip_header_helper_unknown},
164 {50, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "50", ecm_tracker_ip_header_helper_unknown},
Gareth Williams8ac34292015-03-17 14:06:58 +0000165#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000166 {51, ECM_TRACKER_IP_PROTOCOL_TYPE_AH, "ah", ecm_tracker_ip_header_helper_ah},
Gareth Williams8ac34292015-03-17 14:06:58 +0000167#else
168 {51, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "51", ecm_tracker_ip_header_helper_unknown},
169#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000170 {52, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "52", ecm_tracker_ip_header_helper_unknown},
171 {53, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "53", ecm_tracker_ip_header_helper_unknown},
172 {54, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "54", ecm_tracker_ip_header_helper_unknown},
173 {55, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "55", ecm_tracker_ip_header_helper_unknown},
Gareth Williams8ac34292015-03-17 14:06:58 +0000174#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000175 {56, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_ICMP, "ipv6_icmp", ecm_tracker_ip_header_helper_ipv6_icmp},
Gareth Williams8ac34292015-03-17 14:06:58 +0000176#else
177 {56, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "56", ecm_tracker_ip_header_helper_unknown},
178#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000179 {57, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "57", ecm_tracker_ip_header_helper_unknown},
180 {58, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "58", ecm_tracker_ip_header_helper_unknown},
181 {59, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "59", ecm_tracker_ip_header_helper_unknown},
Gareth Williams8ac34292015-03-17 14:06:58 +0000182#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000183 {60, ECM_TRACKER_IP_PROTOCOL_TYPE_IPV6_DO, "ipv6_do", ecm_tracker_ip_header_helper_ipv6_generic},
Gareth Williams8ac34292015-03-17 14:06:58 +0000184#else
185 {60, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "60", ecm_tracker_ip_header_helper_unknown},
186#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000187 {61, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "61", ecm_tracker_ip_header_helper_unknown},
188 {62, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "62", ecm_tracker_ip_header_helper_unknown},
189 {63, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "63", ecm_tracker_ip_header_helper_unknown},
190 {64, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "64", ecm_tracker_ip_header_helper_unknown},
191 {65, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "65", ecm_tracker_ip_header_helper_unknown},
192 {66, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "66", ecm_tracker_ip_header_helper_unknown},
193 {67, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "67", ecm_tracker_ip_header_helper_unknown},
194 {68, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "68", ecm_tracker_ip_header_helper_unknown},
195 {69, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "69", ecm_tracker_ip_header_helper_unknown},
196 {70, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "70", ecm_tracker_ip_header_helper_unknown},
197 {71, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "71", ecm_tracker_ip_header_helper_unknown},
198 {72, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "72", ecm_tracker_ip_header_helper_unknown},
199 {73, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "73", ecm_tracker_ip_header_helper_unknown},
200 {74, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "74", ecm_tracker_ip_header_helper_unknown},
201 {75, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "75", ecm_tracker_ip_header_helper_unknown},
202 {76, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "76", ecm_tracker_ip_header_helper_unknown},
203 {77, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "77", ecm_tracker_ip_header_helper_unknown},
204 {78, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "78", ecm_tracker_ip_header_helper_unknown},
205 {79, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "79", ecm_tracker_ip_header_helper_unknown},
206 {80, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "80", ecm_tracker_ip_header_helper_unknown},
207 {81, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "81", ecm_tracker_ip_header_helper_unknown},
208 {82, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "82", ecm_tracker_ip_header_helper_unknown},
209 {83, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "83", ecm_tracker_ip_header_helper_unknown},
210 {84, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "84", ecm_tracker_ip_header_helper_unknown},
211 {85, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "85", ecm_tracker_ip_header_helper_unknown},
212 {86, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "86", ecm_tracker_ip_header_helper_unknown},
213 {87, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "87", ecm_tracker_ip_header_helper_unknown},
214 {88, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "88", ecm_tracker_ip_header_helper_unknown},
215 {89, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "89", ecm_tracker_ip_header_helper_unknown},
216 {90, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "90", ecm_tracker_ip_header_helper_unknown},
217 {91, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "91", ecm_tracker_ip_header_helper_unknown},
218 {92, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "92", ecm_tracker_ip_header_helper_unknown},
219 {93, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "93", ecm_tracker_ip_header_helper_unknown},
220 {94, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "94", ecm_tracker_ip_header_helper_unknown},
221 {95, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "95", ecm_tracker_ip_header_helper_unknown},
222 {96, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "96", ecm_tracker_ip_header_helper_unknown},
223 {97, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "97", ecm_tracker_ip_header_helper_unknown},
224 {98, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "98", ecm_tracker_ip_header_helper_unknown},
225 {99, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "99", ecm_tracker_ip_header_helper_unknown},
226 {100, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "100", ecm_tracker_ip_header_helper_unknown},
227 {101, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "101", ecm_tracker_ip_header_helper_unknown},
228 {102, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "102", ecm_tracker_ip_header_helper_unknown},
229 {103, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "103", ecm_tracker_ip_header_helper_unknown},
230 {104, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "104", ecm_tracker_ip_header_helper_unknown},
231 {105, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "105", ecm_tracker_ip_header_helper_unknown},
232 {106, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "106", ecm_tracker_ip_header_helper_unknown},
233 {107, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "107", ecm_tracker_ip_header_helper_unknown},
234 {108, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "108", ecm_tracker_ip_header_helper_unknown},
235 {109, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "109", ecm_tracker_ip_header_helper_unknown},
236 {110, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "110", ecm_tracker_ip_header_helper_unknown},
237 {111, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "111", ecm_tracker_ip_header_helper_unknown},
238 {112, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "112", ecm_tracker_ip_header_helper_unknown},
239 {113, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "113", ecm_tracker_ip_header_helper_unknown},
240 {114, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "114", ecm_tracker_ip_header_helper_unknown},
241 {115, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "115", ecm_tracker_ip_header_helper_unknown},
242 {116, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "116", ecm_tracker_ip_header_helper_unknown},
243 {117, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "117", ecm_tracker_ip_header_helper_unknown},
244 {118, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "118", ecm_tracker_ip_header_helper_unknown},
245 {119, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "119", ecm_tracker_ip_header_helper_unknown},
246 {120, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "120", ecm_tracker_ip_header_helper_unknown},
247 {121, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "121", ecm_tracker_ip_header_helper_unknown},
248 {122, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "122", ecm_tracker_ip_header_helper_unknown},
249 {123, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "123", ecm_tracker_ip_header_helper_unknown},
250 {124, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "124", ecm_tracker_ip_header_helper_unknown},
251 {125, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "125", ecm_tracker_ip_header_helper_unknown},
252 {126, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "126", ecm_tracker_ip_header_helper_unknown},
253 {127, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "127", ecm_tracker_ip_header_helper_unknown},
254 {128, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "128", ecm_tracker_ip_header_helper_unknown},
255 {129, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "129", ecm_tracker_ip_header_helper_unknown},
256 {130, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "130", ecm_tracker_ip_header_helper_unknown},
257 {131, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "131", ecm_tracker_ip_header_helper_unknown},
258 {132, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "132", ecm_tracker_ip_header_helper_unknown},
259 {133, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "133", ecm_tracker_ip_header_helper_unknown},
260 {134, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "134", ecm_tracker_ip_header_helper_unknown},
261 {135, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "135", ecm_tracker_ip_header_helper_unknown},
262 {136, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "136", ecm_tracker_ip_header_helper_unknown},
263 {137, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "137", ecm_tracker_ip_header_helper_unknown},
264 {138, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "138", ecm_tracker_ip_header_helper_unknown},
265 {139, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "139", ecm_tracker_ip_header_helper_unknown},
266 {140, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "140", ecm_tracker_ip_header_helper_unknown},
267 {141, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "141", ecm_tracker_ip_header_helper_unknown},
268 {142, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "142", ecm_tracker_ip_header_helper_unknown},
269 {143, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "143", ecm_tracker_ip_header_helper_unknown},
270 {144, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "144", ecm_tracker_ip_header_helper_unknown},
271 {145, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "145", ecm_tracker_ip_header_helper_unknown},
272 {146, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "146", ecm_tracker_ip_header_helper_unknown},
273 {147, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "147", ecm_tracker_ip_header_helper_unknown},
274 {148, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "148", ecm_tracker_ip_header_helper_unknown},
275 {149, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "149", ecm_tracker_ip_header_helper_unknown},
276 {150, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "150", ecm_tracker_ip_header_helper_unknown},
277 {151, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "151", ecm_tracker_ip_header_helper_unknown},
278 {152, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "152", ecm_tracker_ip_header_helper_unknown},
279 {153, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "153", ecm_tracker_ip_header_helper_unknown},
280 {154, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "154", ecm_tracker_ip_header_helper_unknown},
281 {155, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "155", ecm_tracker_ip_header_helper_unknown},
282 {156, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "156", ecm_tracker_ip_header_helper_unknown},
283 {157, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "157", ecm_tracker_ip_header_helper_unknown},
284 {158, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "158", ecm_tracker_ip_header_helper_unknown},
285 {159, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "159", ecm_tracker_ip_header_helper_unknown},
286 {160, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "160", ecm_tracker_ip_header_helper_unknown},
287 {161, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "161", ecm_tracker_ip_header_helper_unknown},
288 {162, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "162", ecm_tracker_ip_header_helper_unknown},
289 {163, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "163", ecm_tracker_ip_header_helper_unknown},
290 {164, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "164", ecm_tracker_ip_header_helper_unknown},
291 {165, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "165", ecm_tracker_ip_header_helper_unknown},
292 {166, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "166", ecm_tracker_ip_header_helper_unknown},
293 {167, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "167", ecm_tracker_ip_header_helper_unknown},
294 {168, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "168", ecm_tracker_ip_header_helper_unknown},
295 {169, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "169", ecm_tracker_ip_header_helper_unknown},
296 {170, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "170", ecm_tracker_ip_header_helper_unknown},
297 {171, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "171", ecm_tracker_ip_header_helper_unknown},
298 {172, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "172", ecm_tracker_ip_header_helper_unknown},
299 {173, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "173", ecm_tracker_ip_header_helper_unknown},
300 {174, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "174", ecm_tracker_ip_header_helper_unknown},
301 {175, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "175", ecm_tracker_ip_header_helper_unknown},
302 {176, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "176", ecm_tracker_ip_header_helper_unknown},
303 {177, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "177", ecm_tracker_ip_header_helper_unknown},
304 {178, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "178", ecm_tracker_ip_header_helper_unknown},
305 {179, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "179", ecm_tracker_ip_header_helper_unknown},
306 {180, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "180", ecm_tracker_ip_header_helper_unknown},
307 {181, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "181", ecm_tracker_ip_header_helper_unknown},
308 {182, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "182", ecm_tracker_ip_header_helper_unknown},
309 {183, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "183", ecm_tracker_ip_header_helper_unknown},
310 {184, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "184", ecm_tracker_ip_header_helper_unknown},
311 {185, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "185", ecm_tracker_ip_header_helper_unknown},
312 {186, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "186", ecm_tracker_ip_header_helper_unknown},
313 {187, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "187", ecm_tracker_ip_header_helper_unknown},
314 {188, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "188", ecm_tracker_ip_header_helper_unknown},
315 {189, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "189", ecm_tracker_ip_header_helper_unknown},
316 {190, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "190", ecm_tracker_ip_header_helper_unknown},
317 {191, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "191", ecm_tracker_ip_header_helper_unknown},
318 {192, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "192", ecm_tracker_ip_header_helper_unknown},
319 {193, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "193", ecm_tracker_ip_header_helper_unknown},
320 {194, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "194", ecm_tracker_ip_header_helper_unknown},
321 {195, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "195", ecm_tracker_ip_header_helper_unknown},
322 {196, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "196", ecm_tracker_ip_header_helper_unknown},
323 {197, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "197", ecm_tracker_ip_header_helper_unknown},
324 {198, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "198", ecm_tracker_ip_header_helper_unknown},
325 {199, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "199", ecm_tracker_ip_header_helper_unknown},
326 {200, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "200", ecm_tracker_ip_header_helper_unknown},
327 {201, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "201", ecm_tracker_ip_header_helper_unknown},
328 {202, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "202", ecm_tracker_ip_header_helper_unknown},
329 {203, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "203", ecm_tracker_ip_header_helper_unknown},
330 {204, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "204", ecm_tracker_ip_header_helper_unknown},
331 {205, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "205", ecm_tracker_ip_header_helper_unknown},
332 {206, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "206", ecm_tracker_ip_header_helper_unknown},
333 {207, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "207", ecm_tracker_ip_header_helper_unknown},
334 {208, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "208", ecm_tracker_ip_header_helper_unknown},
335 {209, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "209", ecm_tracker_ip_header_helper_unknown},
336 {210, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "210", ecm_tracker_ip_header_helper_unknown},
337 {211, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "211", ecm_tracker_ip_header_helper_unknown},
338 {212, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "212", ecm_tracker_ip_header_helper_unknown},
339 {213, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "213", ecm_tracker_ip_header_helper_unknown},
340 {214, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "214", ecm_tracker_ip_header_helper_unknown},
341 {215, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "215", ecm_tracker_ip_header_helper_unknown},
342 {216, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "216", ecm_tracker_ip_header_helper_unknown},
343 {217, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "217", ecm_tracker_ip_header_helper_unknown},
344 {218, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "218", ecm_tracker_ip_header_helper_unknown},
345 {219, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "219", ecm_tracker_ip_header_helper_unknown},
346 {220, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "220", ecm_tracker_ip_header_helper_unknown},
347 {221, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "221", ecm_tracker_ip_header_helper_unknown},
348 {222, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "222", ecm_tracker_ip_header_helper_unknown},
349 {223, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "223", ecm_tracker_ip_header_helper_unknown},
350 {224, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "224", ecm_tracker_ip_header_helper_unknown},
351 {225, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "225", ecm_tracker_ip_header_helper_unknown},
352 {226, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "226", ecm_tracker_ip_header_helper_unknown},
353 {227, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "227", ecm_tracker_ip_header_helper_unknown},
354 {228, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "228", ecm_tracker_ip_header_helper_unknown},
355 {229, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "229", ecm_tracker_ip_header_helper_unknown},
356 {230, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "230", ecm_tracker_ip_header_helper_unknown},
357 {231, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "231", ecm_tracker_ip_header_helper_unknown},
358 {232, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "232", ecm_tracker_ip_header_helper_unknown},
359 {233, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "233", ecm_tracker_ip_header_helper_unknown},
360 {234, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "234", ecm_tracker_ip_header_helper_unknown},
361 {235, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "235", ecm_tracker_ip_header_helper_unknown},
362 {236, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "236", ecm_tracker_ip_header_helper_unknown},
363 {237, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "237", ecm_tracker_ip_header_helper_unknown},
364 {238, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "238", ecm_tracker_ip_header_helper_unknown},
365 {239, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "239", ecm_tracker_ip_header_helper_unknown},
366 {240, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "240", ecm_tracker_ip_header_helper_unknown},
367 {241, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "241", ecm_tracker_ip_header_helper_unknown},
368 {242, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "242", ecm_tracker_ip_header_helper_unknown},
369 {243, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "243", ecm_tracker_ip_header_helper_unknown},
370 {244, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "244", ecm_tracker_ip_header_helper_unknown},
371 {245, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "245", ecm_tracker_ip_header_helper_unknown},
372 {246, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "246", ecm_tracker_ip_header_helper_unknown},
373 {247, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "247", ecm_tracker_ip_header_helper_unknown},
374 {248, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "248", ecm_tracker_ip_header_helper_unknown},
375 {249, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "249", ecm_tracker_ip_header_helper_unknown},
376 {250, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "250", ecm_tracker_ip_header_helper_unknown},
377 {251, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "251", ecm_tracker_ip_header_helper_unknown},
378 {252, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "252", ecm_tracker_ip_header_helper_unknown},
379 {253, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "253", ecm_tracker_ip_header_helper_unknown},
380 {254, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "254", ecm_tracker_ip_header_helper_unknown},
381 {255, ECM_TRACKER_IP_PROTOCOL_TYPE_UNKNOWN, "255", ecm_tracker_ip_header_helper_unknown}
382};
383
Nicolas Costa1d9eb992014-05-15 10:01:03 -0500384static char *ecm_tracker_sender_state_strings[] = {
385 "Unknown",
386 "Establishing",
387 "Established",
388 "Closing",
389 "Closed",
390 "Fault"
391};
392
393static char *ecm_tracker_connection_state_strings[] = {
394 "Establishing",
395 "Established",
396 "Closing",
397 "Closed",
398 "Fault"
399};
400
Ben Menchaca84f36632014-02-28 20:57:38 +0000401/*
402 * ecm_tracker_ip_check_header_and_read()
Gareth Williams8ac34292015-03-17 14:06:58 +0000403 * Check that we have a complete network-level IP header, check it and return true if so.
Ben Menchaca84f36632014-02-28 20:57:38 +0000404 */
405bool ecm_tracker_ip_check_header_and_read(struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb)
406{
Matthew McClintock0ffc52e2014-09-19 14:41:23 -0500407 struct iphdr *v4_hdr = NULL;
Gareth Williams8ac34292015-03-17 14:06:58 +0000408 uint16_t remain;
409#ifdef ECM_IPV6_ENABLE
Matthew McClintock0ffc52e2014-09-19 14:41:23 -0500410 struct ipv6hdr *v6_hdr = NULL;
Ben Menchaca84f36632014-02-28 20:57:38 +0000411 int16_t this_header;
412 uint32_t offset;
Gareth Williams8ac34292015-03-17 14:06:58 +0000413#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000414
415 memset(ip_hdr, 0, sizeof(*ip_hdr));
416
417 ip_hdr->skb = skb;
418
419 /*
Gareth Williams8ac34292015-03-17 14:06:58 +0000420 * What version of IP header are we dealing with?
Ben Menchaca84f36632014-02-28 20:57:38 +0000421 */
422 v4_hdr = skb_header_pointer(skb, 0, sizeof(struct iphdr), &ip_hdr->h.v4_hdr);
423 if (v4_hdr && (v4_hdr->version == 4)) {
424 DEBUG_TRACE("%p: skb: %p is ipv4\n", ip_hdr, skb);
425 ip_hdr->is_v4 = true;
Gareth Williams8ac34292015-03-17 14:06:58 +0000426 goto version_check_done;
Ben Menchaca84f36632014-02-28 20:57:38 +0000427 }
428
Gareth Williams8ac34292015-03-17 14:06:58 +0000429#ifdef ECM_IPV6_ENABLE
430 /*
431 * Try V6
432 */
433 DEBUG_TRACE("skb: %p contains no v4 header\n", skb);
434 v6_hdr = skb_header_pointer(skb, 0, sizeof(struct ipv6hdr), &ip_hdr->h.v6_hdr);
435 if (!v6_hdr || (v6_hdr->version != 6)) {
436 DEBUG_TRACE("skb: %p contains no v6 header\n", skb);
437 return false;
438 }
439 DEBUG_TRACE("%p: skb: %p is ipv6\n", ip_hdr, skb);
440 ip_hdr->is_v4 = false;
441#else
442 DEBUG_TRACE("skb: %p Other IP header versions unsupported\n", skb);
443 return false;
444#endif
445
446version_check_done:
Ben Menchaca84f36632014-02-28 20:57:38 +0000447 if (ip_hdr->is_v4) {
448 uint8_t protocol;
449 int16_t next_unused;
450 ecm_tracker_ip_protocol_type_t ecm_ip_protocol;
451 struct ecm_tracker_ip_protocols *etip;
452 struct ecm_tracker_ip_protocol_header *etiph;
453
454 DEBUG_TRACE("%p: skb: %p ipv4\n", ip_hdr, skb);
455
456 /*
457 * Process IPv4
458 */
459 ECM_NIN4_ADDR_TO_IP_ADDR(ip_hdr->src_addr, v4_hdr->saddr);
460 ECM_NIN4_ADDR_TO_IP_ADDR(ip_hdr->dest_addr, v4_hdr->daddr);
461 ip_hdr->ip_header_length = v4_hdr->ihl;
462 ip_hdr->ip_header_length <<= 2;
463 if (ip_hdr->ip_header_length < 20) {
464 DEBUG_WARN("%p: v4 invalid ip hdr len %d\n", skb, ip_hdr->ip_header_length);
465 return false;
466 }
467 ip_hdr->total_length = ntohs(v4_hdr->tot_len);
468 if (skb->len < ip_hdr->total_length) {
469 DEBUG_WARN("%p: v4 invalid total len: %u skb len: %u\n", skb, ip_hdr->total_length, skb->len);
470 return false;
471 }
472 remain = ip_hdr->total_length - ip_hdr->ip_header_length;
473
474 /*
475 * Fragmented?
476 */
477 ip_hdr->fragmented = (ntohs(v4_hdr->frag_off) & 0x3fff)? true : false;
478
479 /*
Gareth Williams8932a912014-06-11 18:06:25 -0700480 * DS field
481 */
482 ip_hdr->ds = ipv4_get_dsfield(v4_hdr);
483
484 /*
Ben Menchaca84f36632014-02-28 20:57:38 +0000485 * Get the protocol and where the header info will be stored
486 */
487 protocol = v4_hdr->protocol;
488 ip_hdr->protocol = (int)v4_hdr->protocol;
489 etip = &ecm_tracker_ip_protocols_known[protocol]; /* Get header helper */
490 ecm_ip_protocol = etip->ecm_ip_protocol;
491 etiph = &ip_hdr->headers[ecm_ip_protocol]; /* Get where the header detail is stored in ip_hdr->headers[] */
492
493 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: "
494 ECM_IP_ADDR_DOT_FMT ", dest addr: " ECM_IP_ADDR_DOT_FMT "\n",
495 ip_hdr,
496 skb,
497 skb->len,
498 ip_hdr->ip_header_length,
499 ip_hdr->total_length,
500 remain,
501 ip_hdr->fragmented,
502 ip_hdr->protocol,
503 ecm_ip_protocol,
504 ECM_IP_ADDR_TO_DOT(ip_hdr->src_addr),
505 ECM_IP_ADDR_TO_DOT(ip_hdr->dest_addr));
506
507 /*
508 * Populate protocol detail
509 * IPv4 can only have one.
510 */
511 if (!etip->header_helper(
512 etip,
513 etiph,
514 ip_hdr,
515 skb,
516 (uint8_t)ip_hdr->protocol,
517 ecm_ip_protocol,
518 ip_hdr->ip_header_length,
519 remain,
520 &next_unused)) {
521 DEBUG_WARN("%p: v4 header helper failed for: %u\n", skb, protocol);
522 return false;
523 }
Nicolas Costa585002e2014-05-15 09:46:04 -0500524
Ben Menchaca84f36632014-02-28 20:57:38 +0000525 return true;
526 }
527
Gareth Williams8ac34292015-03-17 14:06:58 +0000528#ifndef ECM_IPV6_ENABLE
529 return false;
530#else
Ben Menchaca84f36632014-02-28 20:57:38 +0000531 /*
532 * IPv6
533 */
534 ECM_NIN6_ADDR_TO_IP_ADDR(ip_hdr->src_addr, v6_hdr->saddr);
535 ECM_NIN6_ADDR_TO_IP_ADDR(ip_hdr->dest_addr, v6_hdr->daddr);
536 ip_hdr->ip_header_length = 40;
537 remain = ntohs(v6_hdr->payload_len);
538 ip_hdr->total_length = remain + 40;
539 if (skb->len < ip_hdr->total_length) {
540 DEBUG_WARN("%p: v6 invalid total len: %u skb len: %u\n", skb, ip_hdr->total_length, skb->len);
541 return false;
542 }
543
544 /*
Gareth Williams8932a912014-06-11 18:06:25 -0700545 * DS field
546 */
547 ip_hdr->ds = ipv6_get_dsfield(v6_hdr);
548
549 /*
Ben Menchaca84f36632014-02-28 20:57:38 +0000550 * Process headers until we run out of space, error, or we get the no next header marker for v6 (protocol 59).
551 */
552 offset = 40;
553 this_header = (int16_t)v6_hdr->nexthdr;
554 while ((remain > 0) && (this_header >= 0) && (this_header != 59)) {
555 struct ecm_tracker_ip_protocols *etip;
556 struct ecm_tracker_ip_protocol_header *etiph;
557 ecm_tracker_ip_protocol_type_t ecm_ip_protocol;
558 int16_t next_header;
559
560 etip = &ecm_tracker_ip_protocols_known[this_header]; /* Get header helper */
561 ecm_ip_protocol = etip->ecm_ip_protocol;
562 etiph = &ip_hdr->headers[ecm_ip_protocol]; /* Get where the header detail is stored in ip_hdr->headers[] */
563
564 /*
565 * If this IP header has already been seen then we abort
566 */
567 if (etiph->size) {
568 DEBUG_WARN("v6 skb: %p, protocol: %d already seen at offset: %u, size: %u\n",
569 skb, this_header, etiph->offset, etiph->size);
570 return false;
571 }
572 if (!etip->header_helper(
573 etip,
574 etiph,
575 ip_hdr,
576 skb,
577 (uint8_t)this_header,
578 ecm_ip_protocol,
579 offset,
580 remain,
581 &next_header)) {
582 DEBUG_WARN("%p: v6 header helper failed for: %d\n", skb, this_header);
583 return false;
584 }
585
586 offset += etiph->size;
587 DEBUG_ASSERT(remain >= etiph->size, "v6 remain: %u goes negative after header size: %u", remain, etiph->size);
588 remain -= etiph->size;
589
590 this_header = next_header;
591 }
592
593 /*
594 * Generally the last protocol seen is the upper layer protocol
595 */
596 ip_hdr->protocol = (int)this_header;
597
Gareth Williams8ac34292015-03-17 14:06:58 +0000598 return true;
599#endif
Ben Menchaca84f36632014-02-28 20:57:38 +0000600}
601EXPORT_SYMBOL(ecm_tracker_ip_check_header_and_read);
602
Gareth Williams8ac34292015-03-17 14:06:58 +0000603#ifdef ECM_IPV6_ENABLE
Ben Menchaca84f36632014-02-28 20:57:38 +0000604/*
605 * ecm_tracker_ip_header_helper_ipv6_generic()
606 * Interpret a Generic IPv6 extension header
607 */
608static 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,
609 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)
610{
611 struct ipv6_gen_hdr {
612 uint8_t next_protocol;
613 uint8_t header_ext_len;
614 } gen_header_buffer;
615 struct ipv6_gen_hdr *gen_header;
616 uint16_t hdr_size;
617
618 /*
619 * At least 8 bytes
620 */
621 if (remain < 8) {
622 return false;
623 }
624
625 gen_header = skb_header_pointer(skb, offset, sizeof(struct ipv6_gen_hdr), &gen_header_buffer);
626 if (!gen_header) {
627 return false;
628 }
629 hdr_size = gen_header->header_ext_len;
630 hdr_size <<= 3;
631 hdr_size += 8;
632 if (remain < hdr_size) {
633 DEBUG_WARN("IPv6 extension: %p packet remain: %u too small for tcp header: %u\n", skb, remain, hdr_size);
634 return false;
635 }
636 if (unlikely(ip_hdr->total_length < (offset + hdr_size))) {
637 DEBUG_WARN("TCP packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
638 return false;
639 }
640
641 etiph->protocol_number = protocol;
642 etiph->header_size = hdr_size;
643 etiph->size = hdr_size;
644 etiph->offset = offset;
645
646 *next_hdr = (int16_t)gen_header->next_protocol;
Nicolas Costa585002e2014-05-15 09:46:04 -0500647 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000648}
649
650/*
651 * ecm_tracker_ip_header_helper_ipv6_fragment()
652 * Interpret a Generic IPv6 fragment header
653 */
654static 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,
655 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)
656{
657 struct ipv6_gen_hdr {
658 uint8_t next_protocol;
659 uint8_t reserved;
660 } gen_header_buffer;
661 struct ipv6_gen_hdr *gen_header;
662
663 /*
664 * At least 8 bytes
665 */
666 if (remain < 8) {
667 return false;
668 }
669
670 gen_header = skb_header_pointer(skb, offset, sizeof(struct ipv6_gen_hdr), &gen_header_buffer);
671 if (!gen_header) {
672 return false;
673 }
674 if (unlikely(ip_hdr->total_length < (offset + 8))) {
675 DEBUG_WARN("TCP packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + 8);
676 return false;
677 }
678
679 /*
680 * The very presence of a fragmemt header says it's fragmented
681 */
682 ip_hdr->fragmented = true;
683
684 etiph->protocol_number = protocol;
685 etiph->header_size = 8;
686 etiph->size = 8;
687 etiph->offset = offset;
688
689 *next_hdr = (int16_t)gen_header->next_protocol;
Nicolas Costa585002e2014-05-15 09:46:04 -0500690 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000691}
692
693/*
Gareth Williams8ac34292015-03-17 14:06:58 +0000694 * ecm_tracker_ip_header_helper_ah()
695 * Interpret an Authentication Header
696 */
697static 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,
698 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)
699{
700 struct ah_gen_hdr {
701 uint8_t next_protocol;
702 uint8_t header_len;
703 } gen_header_buffer;
704 struct ah_gen_hdr *gen_header;
705 uint16_t hdr_size;
706
707 /*
708 * At least 8 bytes
709 */
710 if (remain < 8) {
711 return false;
712 }
713
714 gen_header = skb_header_pointer(skb, offset, sizeof(struct ah_gen_hdr), &gen_header_buffer);
715 if (!gen_header) {
716 return false;
717 }
718
719 hdr_size = gen_header->header_len + 2;
720 hdr_size <<= 2;
721
722 if (!ip_hdr->is_v4) {
723 /*
724 * hdr_size needs to be a multiple of 8 in a v6 frame
725 */
726 if (hdr_size % 8) {
727 DEBUG_WARN("AH packet %p not multiple of 8 for v6 frame: %u\n", skb, hdr_size);
728 return false;
729 }
730 }
731
732 if (remain < hdr_size) {
733 DEBUG_WARN("AH packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
734 return false;
735 }
736 if (unlikely(ip_hdr->total_length < (offset + hdr_size))) {
737 DEBUG_WARN("AH packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
738 return false;
739 }
740
741 /*
742 * What header follows this one?
743 */
744 *next_hdr = gen_header->next_protocol;
745
746 etiph->protocol_number = protocol;
747 etiph->header_size = hdr_size;
748 etiph->size = hdr_size;
749 etiph->offset = offset;
750 return true;
751}
752
753/*
754 * ecm_tracker_ip_header_helper_ipv6_icmp()
755 * Interpret a ICMP V6 header
756 */
757static 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,
758 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)
759{
760 if (remain < 4) {
761 DEBUG_WARN("v6 icmp: %p too small: %u\n", skb, remain);
762 return false;
763 }
764
765 etiph->protocol_number = protocol;
766 etiph->header_size = 4;
767 etiph->size = remain;
768 etiph->offset = offset;
769
770 /*
771 * There is no header following a V6 ICMP header
772 */
773 *next_hdr = -1;
774 return true;
775}
776
777#endif
778
779/*
Ben Menchaca84f36632014-02-28 20:57:38 +0000780 * ecm_tracker_ip_header_helper_tcp()
781 * Interpret a TCP header
782 */
783static 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,
784 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)
785{
786 struct tcphdr tcp_header_buffer;
787 struct tcphdr *tcp_header;
788 uint16_t hdr_size;
789
790 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);
791
792 if (remain < 20) {
793 return false;
794 }
795
796 tcp_header = skb_header_pointer(skb, offset, sizeof(struct tcphdr), &tcp_header_buffer);
797 if (!tcp_header) {
798 return false;
799 }
800 hdr_size = tcp_header->doff;
801 hdr_size <<= 2;
802 if (hdr_size < 20) {
803 return false;
804 }
805 if (remain < hdr_size) {
806 DEBUG_WARN("TCP packet: %p packet remain: %u too small for tcp header: %u\n", skb, remain, hdr_size);
807 return false;
808 }
809 if (unlikely(ip_hdr->total_length < (offset + hdr_size))) {
810 DEBUG_WARN("TCP packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
811 return false;
812 }
813
814 etiph->protocol_number = protocol;
815 etiph->header_size = hdr_size;
816 etiph->size = remain;
817 etiph->offset = offset;
818
819 /*
820 * There is no header following a TCP header
821 */
822 *next_hdr = -1;
Nicolas Costa585002e2014-05-15 09:46:04 -0500823 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000824}
825
826/*
827 * ecm_tracker_ip_header_helper_gre()
828 * Interpret a GRE header
829 */
830static 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,
831 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)
832{
833 uint32_t gre_hdr_buffer;
834 uint32_t *gre_hdr_ptr;
835 uint32_t gre_hdr;
836 uint16_t hdr_size;
837
838 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);
839
840 if (remain < 4) {
841 return false;
842 }
843
844 gre_hdr_ptr = skb_header_pointer(skb, offset, sizeof(gre_hdr_buffer), &gre_hdr_buffer);
845 if (!gre_hdr_ptr) {
846 return false;
847 }
848 gre_hdr = ntohl(*gre_hdr_ptr);
849 hdr_size = 4;
850 if (gre_hdr & 0x80000000) {
851 /*
852 * Checksum
853 */
854 hdr_size += 4;
855 }
856 if (gre_hdr & 0x20000000) {
857 /*
858 * Key
859 */
860 hdr_size += 4;
861 }
862 if (gre_hdr & 0x10000000) {
863 /*
864 * Sequence
865 */
866 hdr_size += 4;
867 }
868 if (remain < hdr_size) {
869 DEBUG_WARN("GRE packet: %p packet remain: %u too small for tcp header: %u\n", skb, remain, hdr_size);
870 return false;
871 }
872 if (unlikely(ip_hdr->total_length < (offset + hdr_size))) {
873 DEBUG_WARN("GRE packet %p too short (total_length: %u, require: %u)\n", skb, ip_hdr->total_length, offset + hdr_size);
874 return false;
875 }
876
877 etiph->protocol_number = protocol;
878 etiph->header_size = hdr_size;
879 etiph->size = remain;
880 etiph->offset = offset;
881
882 /*
883 * There is no header following a GRE header
884 */
885 *next_hdr = -1;
Nicolas Costa585002e2014-05-15 09:46:04 -0500886 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000887}
888
889/*
Ben Menchaca84f36632014-02-28 20:57:38 +0000890 * ecm_tracker_ip_header_helper_udp()
891 * Interpret a UDP header
892 */
893static 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,
894 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)
895{
896 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);
897
898 DEBUG_TRACE("udp helper skb: %p, protocol: %u, ecm_ip_proto: %d, offset: %u, remain: %u\n", skb, protocol, ecm_ip_protocol, offset, remain);
899 if (remain < 8) {
900 DEBUG_TRACE("not enough UDP header: %u\n", remain);
901 return false;
902 }
903
904 etiph->protocol_number = protocol;
905 etiph->header_size = 8;
906 etiph->size = remain;
907 etiph->offset = offset;
908
909 /*
910 * There is no header following a UDP header
911 */
912 *next_hdr = -1;
Nicolas Costa585002e2014-05-15 09:46:04 -0500913 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000914}
915
916/*
917 * ecm_tracker_ip_header_helper_unknown()
918 * Interpret a unknown header
919 */
920static 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,
921 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)
922{
923 /*
924 * There is no header following an unknown header
925 */
926 *next_hdr = -1;
927 etiph->protocol_number = protocol;
928 etiph->header_size = remain;
929 etiph->size = remain;
930 etiph->offset = offset;
Nicolas Costa585002e2014-05-15 09:46:04 -0500931 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +0000932}
933
934/*
935 * ecm_tracker_ip_header_helper_icmp()
936 * Interpret a ICMP V4 header
937 */
938static 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,
939 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)
940{
941 struct icmphdr icmp_header_buffer;
942 struct icmphdr *icmp_header;
943
944 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);
945
946 if (remain < 8) {
947 return false;
948 }
949
950 icmp_header = skb_header_pointer(skb, offset, sizeof(struct icmphdr), &icmp_header_buffer);
951 if (!icmp_header) {
952 return false;
953 }
954 switch(icmp_header->type) {
955 case ICMP_SOURCE_QUENCH:
956 case ICMP_REDIRECT:
957 case ICMP_TIME_EXCEEDED:
958 case ICMP_DEST_UNREACH:
959 /*
960 * Should be at least our 8 bytes and minimum 20 bytes for an IP header.
961 * NOTE: We are not looking at options that extend this header!
962 */
963 if (remain < 28) {
964 DEBUG_WARN("icmp skb: %p type: %u too small: %u\n", skb, icmp_header->type, remain);
965 return false;
966 }
967 etiph->header_size = 8;
968 etiph->size = remain;
969 break;
970
971 case ICMP_ADDRESS:
972 case ICMP_ADDRESSREPLY:
973 case ICMP_TIMESTAMP:
974 if (remain < 12) {
975 DEBUG_WARN("icmp skb: %p type: %u too small: %u\n", skb, icmp_header->type, remain);
976 return false;
977 }
978 etiph->header_size = 12;
979 etiph->size = remain;
980 break;
981 case ICMP_TIMESTAMPREPLY:
982 if (remain < 20) {
983 DEBUG_WARN("icmp skb: %p type: %u too small: %u\n", skb, icmp_header->type, remain);
984 return false;
985 }
986 etiph->header_size = 20;
987 etiph->size = remain;
988 break;
989 case ICMP_PARAMETERPROB:
990 case ICMP_INFO_REQUEST:
991 case ICMP_INFO_REPLY:
992 default:
993 etiph->header_size = 8;
994 etiph->size = remain;
995 }
996 etiph->protocol_number = protocol;
997 etiph->offset = offset;
998
999 /*
1000 * There is no header following a ICMP header
1001 */
1002 *next_hdr = -1;
Nicolas Costa585002e2014-05-15 09:46:04 -05001003 return true;
Ben Menchaca84f36632014-02-28 20:57:38 +00001004}
1005
1006/*
Ben Menchaca84f36632014-02-28 20:57:38 +00001007 * ecm_tracker_data_limit_set()
1008 * Set global tracked data limit
1009 */
1010void ecm_tracker_data_limit_set(uint32_t limit)
1011{
1012 int data_limit = (int)limit;
1013 DEBUG_ASSERT(data_limit > 0, "Invalid limit %d\n", data_limit);
1014 spin_lock_bh(&ecm_tracker_lock);
1015 ecm_tracker_data_limit = data_limit;
1016 spin_unlock_bh(&ecm_tracker_lock);
1017}
1018EXPORT_SYMBOL(ecm_tracker_data_limit_set);
1019
1020/*
1021 * ecm_tracker_data_limit_get()
1022 * Return global tracked data limit
1023 */
1024uint32_t ecm_tracker_data_limit_get(void)
1025{
1026 uint32_t data_total;
1027 spin_lock_bh(&ecm_tracker_lock);
1028 data_total = (uint32_t)ecm_tracker_data_limit;
1029 spin_unlock_bh(&ecm_tracker_lock);
1030 return data_total;
1031}
1032EXPORT_SYMBOL(ecm_tracker_data_limit_get);
1033
1034/*
1035 * ecm_tracker_data_total_get()
1036 * Return global tracked data quantity
1037 */
1038uint32_t ecm_tracker_data_total_get(void)
1039{
1040 uint32_t data_total;
1041 spin_lock_bh(&ecm_tracker_lock);
1042 data_total = (uint32_t)ecm_tracker_data_total;
1043 spin_unlock_bh(&ecm_tracker_lock);
1044 return data_total;
1045}
1046EXPORT_SYMBOL(ecm_tracker_data_total_get);
1047
1048/*
1049 * ecm_tracker_data_buffer_total_get()
1050 * Return global tracked data buffer size
1051 */
1052uint32_t ecm_tracker_data_buffer_total_get(void)
1053{
1054 uint32_t data_buffer_total;
1055 spin_lock_bh(&ecm_tracker_lock);
1056 data_buffer_total = (uint32_t)ecm_tracker_data_buffer_total;
1057 spin_unlock_bh(&ecm_tracker_lock);
1058 return data_buffer_total;
1059}
1060EXPORT_SYMBOL(ecm_tracker_data_buffer_total_get);
1061
1062/*
1063 * ecm_tracker_data_total_increase()
1064 * Increase global tracked data quantity
1065 *
1066 * If this function returns false then the increase has been denied and tracking of that data should not occur.
1067 * Therefore call this function BEFORE tracking the actual data.
1068 */
1069bool ecm_tracker_data_total_increase(uint32_t n, uint32_t data_buffer_size)
1070{
1071 spin_lock_bh(&ecm_tracker_lock);
1072
1073 /*
1074 * Would we exceed our global limit?
1075 */
1076 DEBUG_ASSERT((ecm_tracker_data_total + (int)n) > 0, "bad total\n");
1077 if (((ecm_tracker_data_buffer_total + data_buffer_size) > ecm_tracker_data_buffer_limit)
1078 || ((ecm_tracker_data_total + n) > ecm_tracker_data_limit)) {
1079 spin_unlock_bh(&ecm_tracker_lock);
1080 return false;
1081 }
1082 ecm_tracker_data_buffer_total += data_buffer_size;
1083 ecm_tracker_data_total += (int)n;
1084 spin_unlock_bh(&ecm_tracker_lock);
1085 return true;
1086}
1087EXPORT_SYMBOL(ecm_tracker_data_total_increase);
1088
1089/*
1090 * ecm_tracker_data_total_decrease()
1091 * Decrease global tracked data quantity
1092 */
1093void ecm_tracker_data_total_decrease(uint32_t n, uint32_t data_buffer_size)
1094{
1095 spin_lock_bh(&ecm_tracker_lock);
1096 ecm_tracker_data_total -= (int)n;
1097 ecm_tracker_data_buffer_total -= data_buffer_size;
1098 DEBUG_ASSERT(ecm_tracker_data_total >= 0, "bad total\n");
1099 DEBUG_ASSERT(ecm_tracker_data_buffer_total >= 0, "bad total\n");
1100 spin_unlock_bh(&ecm_tracker_lock);
1101}
1102EXPORT_SYMBOL(ecm_tracker_data_total_decrease);
1103
1104/*
1105 * ecm_tracker_module_get()
1106 * Take a reference to the module
1107 */
1108void ecm_tracker_module_get(void)
1109{
1110 try_module_get(THIS_MODULE);
1111}
1112EXPORT_SYMBOL(ecm_tracker_module_get);
1113
1114/*
1115 * ecm_tracker_module_put()
1116 * Release a reference to the module
1117 */
1118void ecm_tracker_module_put(void)
1119{
1120 module_put(THIS_MODULE);
1121}
1122EXPORT_SYMBOL(ecm_tracker_module_put);
1123
Nicolas Costa1d9eb992014-05-15 10:01:03 -05001124const char *
1125ecm_tracker_sender_state_to_string(enum ecm_tracker_sender_states s)
1126{
1127 return ecm_tracker_sender_state_strings[s];
1128}
1129EXPORT_SYMBOL(ecm_tracker_sender_state_to_string);
1130
1131const char *
1132ecm_tracker_connection_state_to_string(enum ecm_tracker_connection_states s)
1133{
1134 return ecm_tracker_connection_state_strings[s];
1135}
1136EXPORT_SYMBOL(ecm_tracker_connection_state_to_string);
1137
Ben Menchaca84f36632014-02-28 20:57:38 +00001138/*
1139 * ecm_tracker_init()
1140 */
Nicolas Costaf46c33b2014-05-15 10:02:00 -05001141int ecm_tracker_init(void)
Ben Menchaca84f36632014-02-28 20:57:38 +00001142{
1143 DEBUG_INFO("Tracker Module init\n");
1144 spin_lock_init(&ecm_tracker_lock);
1145 return 0;
1146}
Nicolas Costaf46c33b2014-05-15 10:02:00 -05001147EXPORT_SYMBOL(ecm_tracker_init);
Ben Menchaca84f36632014-02-28 20:57:38 +00001148
1149/*
1150 * ecm_tracker_exit()
1151 */
Nicolas Costaf46c33b2014-05-15 10:02:00 -05001152void ecm_tracker_exit(void)
Ben Menchaca84f36632014-02-28 20:57:38 +00001153{
1154 DEBUG_INFO("Tracker Module exit\n");
1155}
Nicolas Costaf46c33b2014-05-15 10:02:00 -05001156EXPORT_SYMBOL(ecm_tracker_exit);