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