Harshada Chaundkar | dcd1b14 | 2019-03-25 17:27:44 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.packetthrottle; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableMap; |
| 19 | import org.osgi.service.component.annotations.Modified; |
| 20 | import org.osgi.service.component.annotations.Reference; |
| 21 | import org.osgi.service.component.annotations.ReferenceCardinality; |
| 22 | import org.osgi.service.component.annotations.Component; |
| 23 | import org.osgi.service.component.annotations.Activate; |
| 24 | import org.osgi.service.component.annotations.Deactivate; |
| 25 | import org.onosproject.cfg.ComponentConfigService; |
| 26 | import org.onosproject.net.packet.PacketInFilter; |
| 27 | import org.onosproject.net.packet.PacketService; |
| 28 | import org.onosproject.net.packet.packetfilter.DefaultPacketInFilter; |
| 29 | import org.onosproject.net.packet.packetfilter.ArpPacketClassifier; |
| 30 | import org.onosproject.net.packet.packetfilter.Dhcp6IndirectPacketClassifier; |
| 31 | import org.onosproject.net.packet.packetfilter.Dhcp6DirectPacketClassifier; |
| 32 | import org.onosproject.net.packet.packetfilter.DhcpPacketClassifier; |
| 33 | import org.onosproject.net.packet.packetfilter.NAPacketClassifier; |
| 34 | import org.onosproject.net.packet.packetfilter.NSPacketClassifier; |
| 35 | import org.onosproject.net.packet.packetfilter.IcmpPacketClassifier; |
| 36 | import org.onosproject.net.packet.packetfilter.Icmp6PacketClassifier; |
| 37 | import org.onosproject.packetthrottle.api.PacketThrottleService; |
| 38 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_PPS_ARP; |
| 39 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PPS_ARP_DEFAULT; |
| 40 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_PPS_DHCP; |
| 41 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PPS_DHCP_DEFAULT; |
| 42 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_PPS_NS; |
| 43 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PPS_NS_DEFAULT; |
| 44 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_PPS_NA; |
| 45 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PPS_NA_DEFAULT; |
| 46 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_PPS_DHCP6_DIRECT; |
| 47 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PPS_DHCP6_DIRECT_DEFAULT; |
| 48 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_PPS_DHCP6_INDIRECT; |
| 49 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PPS_DHCP6_INDIRECT_DEFAULT; |
| 50 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_PPS_ICMP; |
| 51 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PPS_ICMP_DEFAULT; |
| 52 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_PPS_ICMP6; |
| 53 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PPS_ICMP6_DEFAULT; |
| 54 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_SIZE_ARP_MS; |
| 55 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_SIZE_ARP_MS_DEFAULT; |
| 56 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_SIZE_DHCP_MS; |
| 57 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_SIZE_DHCP_MS_DEFAULT; |
| 58 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_SIZE_NA_MS; |
| 59 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_SIZE_NA_MS_DEFAULT; |
| 60 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_SIZE_NS_MS; |
| 61 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_SIZE_NS_MS_DEFAULT; |
| 62 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_SIZE_DHCP6_DIRECT_MS; |
| 63 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_SIZE_DHCP6_DIRECT_MS_DEFAULT; |
| 64 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_SIZE_DHCP6_INDIRECT_MS; |
| 65 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_SIZE_DHCP6_INDIRECT_MS_DEFAULT; |
| 66 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_SIZE_ICMP_MS; |
| 67 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_SIZE_ICMP_MS_DEFAULT; |
| 68 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_SIZE_ICMP6_MS; |
| 69 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_SIZE_ICMP6_MS_DEFAULT; |
| 70 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_GUARD_TIME_ARP_SEC; |
| 71 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.GUARD_TIME_ARP_SEC_DEFAULT; |
| 72 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_GUARD_TIME_DHCP_SEC; |
| 73 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.GUARD_TIME_DHCP_SEC_DEFAULT; |
| 74 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_GUARD_TIME_NS_SEC; |
| 75 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.GUARD_TIME_NS_SEC_DEFAULT; |
| 76 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_GUARD_TIME_NA_SEC; |
| 77 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.GUARD_TIME_NA_SEC_DEFAULT; |
| 78 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_GUARD_TIME_DHCP6_DIRECT_SEC; |
| 79 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.GUARD_TIME_DHCP6_DIRECT_SEC_DEFAULT; |
| 80 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_GUARD_TIME_DHCP6_INDIRECT_SEC; |
| 81 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.GUARD_TIME_DHCP6_INDIRECT_SEC_DEFAULT; |
| 82 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_GUARD_TIME_ICMP_SEC; |
| 83 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.GUARD_TIME_ICMP_SEC_DEFAULT; |
| 84 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_GUARD_TIME_ICMP6_SEC; |
| 85 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.GUARD_TIME_ICMP6_SEC_DEFAULT; |
| 86 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_THRES_ARP; |
| 87 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_THRES_ARP_DEFAULT; |
| 88 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_THRES_DHCP; |
| 89 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_THRES_DHCP_DEFAULT; |
| 90 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_THRES_NS; |
| 91 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_THRES_NS_DEFAULT; |
| 92 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_THRES_NA; |
| 93 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_THRES_NA_DEFAULT; |
| 94 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_THRES_DHCP6_DIRECT; |
| 95 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_THRES_DHCP6_DIRECT_DEFAULT; |
| 96 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_THRES_DHCP6_INDIRECT; |
| 97 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_THRES_DHCP6_INDIRECT_DEFAULT; |
| 98 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_THRES_ICMP; |
| 99 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_THRES_ICMP_DEFAULT; |
| 100 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.PROP_WIN_THRES_ICMP6; |
| 101 | import static org.onosproject.packetthrottle.OsgiPropertyConstants.WIN_THRES_ICMP6_DEFAULT; |
| 102 | |
| 103 | import org.osgi.service.component.ComponentContext; |
| 104 | import org.slf4j.Logger; |
| 105 | import org.slf4j.LoggerFactory; |
| 106 | |
| 107 | import java.util.Dictionary; |
| 108 | import java.util.HashMap; |
| 109 | import java.util.Map; |
| 110 | |
| 111 | import static com.google.common.base.Strings.isNullOrEmpty; |
| 112 | import static org.onlab.util.Tools.get; |
| 113 | |
| 114 | /** |
| 115 | * Manage the packet throttle for various type of packets. |
| 116 | */ |
| 117 | @Component( |
| 118 | immediate = true, |
| 119 | service = PacketThrottleService.class, |
| 120 | property = { |
| 121 | PROP_PPS_ARP + ":Integer=" + PPS_ARP_DEFAULT, |
| 122 | PROP_PPS_DHCP + ":Integer=" + PPS_DHCP_DEFAULT, |
| 123 | PROP_PPS_NS + ":Integer=" + PPS_NS_DEFAULT, |
| 124 | PROP_PPS_NA + ":Integer=" + PPS_NA_DEFAULT, |
| 125 | PROP_PPS_DHCP6_DIRECT + ":Integer=" + PPS_DHCP6_DIRECT_DEFAULT, |
| 126 | PROP_PPS_DHCP6_INDIRECT + ":Integer=" + PPS_DHCP6_INDIRECT_DEFAULT, |
| 127 | PROP_PPS_ICMP + ":Integer=" + PPS_ICMP_DEFAULT, |
| 128 | PROP_PPS_ICMP6 + ":Integer=" + PPS_ICMP6_DEFAULT, |
| 129 | PROP_WIN_SIZE_ARP_MS + ":Integer=" + WIN_SIZE_ARP_MS_DEFAULT, |
| 130 | PROP_WIN_SIZE_DHCP_MS + ":Integer=" + WIN_SIZE_DHCP_MS_DEFAULT, |
| 131 | PROP_WIN_SIZE_NA_MS + ":Integer=" + WIN_SIZE_NA_MS_DEFAULT, |
| 132 | PROP_WIN_SIZE_NS_MS + ":Integer=" + WIN_SIZE_NS_MS_DEFAULT, |
| 133 | PROP_WIN_SIZE_DHCP6_DIRECT_MS + ":Integer=" + WIN_SIZE_DHCP6_DIRECT_MS_DEFAULT, |
| 134 | PROP_WIN_SIZE_DHCP6_INDIRECT_MS + ":Integer=" + WIN_SIZE_DHCP6_INDIRECT_MS_DEFAULT, |
| 135 | PROP_WIN_SIZE_ICMP_MS + ":Integer=" + WIN_SIZE_ICMP_MS_DEFAULT, |
| 136 | PROP_WIN_SIZE_ICMP6_MS + ":Integer=" + WIN_SIZE_ICMP6_MS_DEFAULT, |
| 137 | PROP_GUARD_TIME_ARP_SEC + ":Integer=" + GUARD_TIME_ARP_SEC_DEFAULT, |
| 138 | PROP_GUARD_TIME_DHCP_SEC + ":Integer=" + GUARD_TIME_DHCP_SEC_DEFAULT, |
| 139 | PROP_GUARD_TIME_NS_SEC + ":Integer=" + GUARD_TIME_NS_SEC_DEFAULT, |
| 140 | PROP_GUARD_TIME_NA_SEC + ":Integer=" + GUARD_TIME_NA_SEC_DEFAULT, |
| 141 | PROP_GUARD_TIME_DHCP6_DIRECT_SEC + ":Integer=" + GUARD_TIME_DHCP6_DIRECT_SEC_DEFAULT, |
| 142 | PROP_GUARD_TIME_DHCP6_INDIRECT_SEC + ":Integer=" + GUARD_TIME_DHCP6_INDIRECT_SEC_DEFAULT, |
| 143 | PROP_GUARD_TIME_ICMP_SEC + ":Integer=" + GUARD_TIME_ICMP_SEC_DEFAULT, |
| 144 | PROP_GUARD_TIME_ICMP6_SEC + ":Integer=" + GUARD_TIME_ICMP6_SEC_DEFAULT, |
| 145 | PROP_WIN_THRES_ARP + ":Integer=" + WIN_THRES_ARP_DEFAULT, |
| 146 | PROP_WIN_THRES_DHCP + ":Integer=" + WIN_THRES_DHCP_DEFAULT, |
| 147 | PROP_WIN_THRES_NS + ":Integer=" + WIN_THRES_NS_DEFAULT, |
| 148 | PROP_WIN_THRES_NA + ":Integer=" + WIN_THRES_NA_DEFAULT, |
| 149 | PROP_WIN_THRES_DHCP6_DIRECT + ":Integer=" + WIN_THRES_DHCP6_DIRECT_DEFAULT, |
| 150 | PROP_WIN_THRES_DHCP6_INDIRECT + ":Integer=" + WIN_THRES_DHCP6_INDIRECT_DEFAULT, |
| 151 | PROP_WIN_THRES_ICMP + ":Integer=" + WIN_THRES_ICMP_DEFAULT, |
| 152 | PROP_WIN_THRES_ICMP6 + ":Integer=" + WIN_THRES_ICMP6_DEFAULT |
| 153 | } |
| 154 | ) |
| 155 | public class PacketThrottleManager implements PacketThrottleService { |
| 156 | |
| 157 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 158 | |
| 159 | protected static final String ARP_FILTER = "arpFilter"; |
| 160 | protected static final String DHCP_FILTER = "dhcpFilter"; |
| 161 | protected static final String NS_FILTER = "nsFilter"; |
| 162 | protected static final String NA_FILTER = "naFilter"; |
| 163 | protected static final String DHCP6_DIRECT_FILTER = "dhcp6DirectFilter"; |
| 164 | protected static final String DHCP6_INDIRECT_FILTER = "dhcp6IndirectFilter"; |
| 165 | protected static final String ICMP_FILTER = "icmpFilter"; |
| 166 | protected static final String ICMP6_FILTER = "icmp6Filter"; |
| 167 | |
| 168 | |
| 169 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 170 | PacketService packetService; |
| 171 | |
| 172 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 173 | protected ComponentConfigService configService; |
| 174 | |
| 175 | /** |
| 176 | * Parameter to set packet per second rate for all filter types. |
| 177 | */ |
| 178 | |
| 179 | private int ppsArp = PPS_ARP_DEFAULT; |
| 180 | |
| 181 | private int ppsDhcp = PPS_DHCP_DEFAULT; |
| 182 | |
| 183 | private int ppsNs = PPS_NS_DEFAULT; |
| 184 | |
| 185 | private int ppsNa = PPS_NA_DEFAULT; |
| 186 | |
| 187 | private int ppsDhcp6Direct = PPS_DHCP6_DIRECT_DEFAULT; |
| 188 | |
| 189 | private int ppsDhcp6Indirect = PPS_DHCP6_INDIRECT_DEFAULT; |
| 190 | |
| 191 | private int ppsIcmp = PPS_ICMP_DEFAULT; |
| 192 | |
| 193 | private int ppsIcmp6 = PPS_ICMP6_DEFAULT; |
| 194 | |
| 195 | |
| 196 | /** |
| 197 | * Parameter to set window size in milli seconds to check overflow of packets. |
| 198 | */ |
| 199 | |
| 200 | private int winSizeArp = WIN_SIZE_ARP_MS_DEFAULT; |
| 201 | |
| 202 | private int winSizeDhcp = WIN_SIZE_DHCP_MS_DEFAULT; |
| 203 | |
| 204 | private int winSizeNs = WIN_SIZE_NS_MS_DEFAULT; |
| 205 | |
| 206 | private int winSizeNa = WIN_SIZE_NA_MS_DEFAULT; |
| 207 | |
| 208 | private int winSizeDhcp6Direct = WIN_SIZE_DHCP6_DIRECT_MS_DEFAULT; |
| 209 | |
| 210 | private int winSizeDhcp6Indirect = WIN_SIZE_DHCP6_INDIRECT_MS_DEFAULT; |
| 211 | |
| 212 | private int winSizeIcmp = WIN_SIZE_ICMP_MS_DEFAULT; |
| 213 | |
| 214 | private int winSizeIcmp6 = WIN_SIZE_ICMP6_MS_DEFAULT; |
| 215 | |
| 216 | /** |
| 217 | * Time duration for which no more packets will be processed for a given filter type |
| 218 | * provided consecutive overflow windows happens. |
| 219 | */ |
| 220 | |
| 221 | |
| 222 | private int guardTimeArp = GUARD_TIME_ARP_SEC_DEFAULT; |
| 223 | |
| 224 | private int guardTimeDhcp = GUARD_TIME_DHCP_SEC_DEFAULT; |
| 225 | |
| 226 | private int guardTimeNs = GUARD_TIME_NS_SEC_DEFAULT; |
| 227 | |
| 228 | private int guardTimeNa = GUARD_TIME_NA_SEC_DEFAULT; |
| 229 | |
| 230 | private int guardTimeDhcp6Direct = GUARD_TIME_DHCP6_DIRECT_SEC_DEFAULT; |
| 231 | |
| 232 | private int guardTimeDhcp6Indirect = GUARD_TIME_DHCP6_INDIRECT_SEC_DEFAULT; |
| 233 | |
| 234 | private int guardTimeIcmp = GUARD_TIME_ICMP_SEC_DEFAULT; |
| 235 | |
| 236 | private int guardTimeIcmp6 = GUARD_TIME_ICMP6_SEC_DEFAULT; |
| 237 | |
| 238 | /** |
| 239 | * Consecutive overflow window threshold. |
| 240 | */ |
| 241 | |
| 242 | |
| 243 | private int winThresArp = WIN_THRES_ARP_DEFAULT; |
| 244 | |
| 245 | private int winThresDhcp = WIN_THRES_DHCP_DEFAULT; |
| 246 | |
| 247 | private int winThresNs = WIN_THRES_NS_DEFAULT; |
| 248 | |
| 249 | private int winThresNa = WIN_THRES_NA_DEFAULT; |
| 250 | |
| 251 | private int winThresDhcp6Direct = WIN_THRES_DHCP6_DIRECT_DEFAULT; |
| 252 | |
| 253 | private int winThresDhcp6Indirect = WIN_THRES_DHCP6_INDIRECT_DEFAULT; |
| 254 | |
| 255 | private int winThresIcmp = WIN_THRES_ICMP_DEFAULT; |
| 256 | |
| 257 | private int winThresIcmp6 = WIN_THRES_ICMP6_DEFAULT; |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | private Map<String, PacketInFilter> mapCounterFilter = new HashMap<>(); |
| 263 | |
| 264 | @Activate |
| 265 | protected void activate() { |
| 266 | log.info("Started"); |
| 267 | configService.registerProperties(getClass()); |
| 268 | createAllFilters(); |
| 269 | } |
| 270 | |
| 271 | @Deactivate |
| 272 | protected void deactivate() { |
| 273 | configService.unregisterProperties(getClass(), false); |
| 274 | removeAllFilters(); |
| 275 | log.info("Stopped"); |
| 276 | } |
| 277 | |
| 278 | private void checkChangeInPps(ComponentContext context) { |
| 279 | Dictionary<?, ?> properties = context.getProperties(); |
| 280 | int newPpsArp, newPpsDhcp, newPpsNs, newPpsNa, newPpsDhcp6Direct; |
| 281 | int newPpsDhcp6Indirect, newPpsIcmp, newPpsIcmp6; |
| 282 | try { |
| 283 | String s = get(properties, PROP_PPS_ARP); |
| 284 | newPpsArp = isNullOrEmpty(s) ? ppsArp : Integer.parseInt(s.trim()); |
| 285 | |
| 286 | s = get(properties, PROP_PPS_DHCP); |
| 287 | newPpsDhcp = isNullOrEmpty(s) ? ppsDhcp : Integer.parseInt(s.trim()); |
| 288 | |
| 289 | s = get(properties, PROP_PPS_NS); |
| 290 | newPpsNs = isNullOrEmpty(s) ? ppsNs : Integer.parseInt(s.trim()); |
| 291 | |
| 292 | s = get(properties, PROP_PPS_NA); |
| 293 | newPpsNa = isNullOrEmpty(s) ? ppsNa : Integer.parseInt(s.trim()); |
| 294 | |
| 295 | s = get(properties, PROP_PPS_DHCP6_DIRECT); |
| 296 | newPpsDhcp6Direct = isNullOrEmpty(s) ? ppsDhcp6Direct : Integer.parseInt(s.trim()); |
| 297 | |
| 298 | s = get(properties, PROP_PPS_DHCP6_INDIRECT); |
| 299 | newPpsDhcp6Indirect = isNullOrEmpty(s) ? ppsDhcp6Indirect : Integer.parseInt(s.trim()); |
| 300 | |
| 301 | s = get(properties, PROP_PPS_ICMP); |
| 302 | newPpsIcmp = isNullOrEmpty(s) ? ppsIcmp : Integer.parseInt(s.trim()); |
| 303 | |
| 304 | s = get(properties, PROP_PPS_ICMP6); |
| 305 | newPpsIcmp6 = isNullOrEmpty(s) ? ppsIcmp6 : Integer.parseInt(s.trim()); |
| 306 | } catch (NumberFormatException | ClassCastException e) { |
| 307 | newPpsArp = PPS_ARP_DEFAULT; |
| 308 | newPpsDhcp = PPS_DHCP_DEFAULT; |
| 309 | newPpsNs = PPS_NS_DEFAULT; |
| 310 | newPpsNa = PPS_NA_DEFAULT; |
| 311 | newPpsDhcp6Direct = PPS_DHCP6_DIRECT_DEFAULT; |
| 312 | newPpsDhcp6Indirect = PPS_DHCP6_INDIRECT_DEFAULT; |
| 313 | newPpsIcmp = PPS_ICMP_DEFAULT; |
| 314 | newPpsIcmp6 = PPS_ICMP6_DEFAULT; |
| 315 | } |
| 316 | if (newPpsArp != ppsArp) { |
| 317 | ppsArp = newPpsArp; |
| 318 | mapCounterFilter.get(ARP_FILTER).setPps(ppsArp); |
| 319 | } |
| 320 | if (newPpsDhcp != ppsDhcp) { |
| 321 | ppsDhcp = newPpsDhcp; |
| 322 | mapCounterFilter.get(DHCP_FILTER).setPps(ppsDhcp); |
| 323 | } |
| 324 | if (newPpsNs != ppsNs) { |
| 325 | ppsNs = newPpsNs; |
| 326 | mapCounterFilter.get(NS_FILTER).setPps(ppsNs); |
| 327 | } |
| 328 | if (newPpsNa != ppsNa) { |
| 329 | ppsNa = newPpsNa; |
| 330 | mapCounterFilter.get(NA_FILTER).setPps(ppsNa); |
| 331 | } |
| 332 | if (newPpsDhcp6Direct != ppsDhcp6Direct) { |
| 333 | ppsDhcp6Direct = newPpsDhcp6Direct; |
| 334 | mapCounterFilter.get(DHCP6_DIRECT_FILTER).setPps(ppsDhcp6Direct); |
| 335 | } |
| 336 | if (newPpsDhcp6Indirect != ppsDhcp6Indirect) { |
| 337 | ppsDhcp6Indirect = newPpsDhcp6Indirect; |
| 338 | mapCounterFilter.get(DHCP6_INDIRECT_FILTER).setPps(ppsDhcp6Indirect); |
| 339 | } |
| 340 | if (newPpsIcmp != ppsIcmp) { |
| 341 | ppsIcmp = newPpsIcmp; |
| 342 | mapCounterFilter.get(ICMP_FILTER).setPps(ppsIcmp); |
| 343 | } |
| 344 | if (newPpsIcmp6 != ppsIcmp6) { |
| 345 | ppsIcmp6 = newPpsIcmp6; |
| 346 | mapCounterFilter.get(ICMP6_FILTER).setPps(ppsIcmp6); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | private void checkChangeInWinSize(ComponentContext context) { |
| 351 | Dictionary<?, ?> properties = context.getProperties(); |
| 352 | |
| 353 | int newWinSizeArp, newWinSizeDhcp, newWinSizeNs, newWinSizeNa; |
| 354 | int newWinSizeDhcp6Direct, newWinSizeDhcp6Indirect, newWinSizeIcmp, newWinSizeIcmp6; |
| 355 | try { |
| 356 | String s = get(properties, PROP_WIN_SIZE_ARP_MS); |
| 357 | newWinSizeArp = isNullOrEmpty(s) ? winSizeArp : Integer.parseInt(s.trim()); |
| 358 | |
| 359 | s = get(properties, PROP_WIN_SIZE_DHCP_MS); |
| 360 | newWinSizeDhcp = isNullOrEmpty(s) ? winSizeDhcp : Integer.parseInt(s.trim()); |
| 361 | |
| 362 | s = get(properties, PROP_WIN_SIZE_NS_MS); |
| 363 | newWinSizeNs = isNullOrEmpty(s) ? winSizeNs : Integer.parseInt(s.trim()); |
| 364 | |
| 365 | s = get(properties, PROP_WIN_SIZE_NA_MS); |
| 366 | newWinSizeNa = isNullOrEmpty(s) ? winSizeNa : Integer.parseInt(s.trim()); |
| 367 | |
| 368 | s = get(properties, PROP_WIN_SIZE_DHCP6_DIRECT_MS); |
| 369 | newWinSizeDhcp6Direct = isNullOrEmpty(s) ? winSizeDhcp6Direct : Integer.parseInt(s.trim()); |
| 370 | |
| 371 | s = get(properties, PROP_WIN_SIZE_DHCP6_INDIRECT_MS); |
| 372 | newWinSizeDhcp6Indirect = isNullOrEmpty(s) ? winSizeDhcp6Indirect : Integer.parseInt(s.trim()); |
| 373 | |
| 374 | s = get(properties, PROP_WIN_SIZE_ICMP_MS); |
| 375 | newWinSizeIcmp = isNullOrEmpty(s) ? winSizeIcmp : Integer.parseInt(s.trim()); |
| 376 | |
| 377 | s = get(properties, PROP_WIN_SIZE_ICMP6_MS); |
| 378 | newWinSizeIcmp6 = isNullOrEmpty(s) ? winSizeIcmp6 : Integer.parseInt(s.trim()); |
| 379 | } catch (NumberFormatException | ClassCastException e) { |
| 380 | newWinSizeArp = WIN_SIZE_ARP_MS_DEFAULT; |
| 381 | newWinSizeDhcp = WIN_SIZE_DHCP_MS_DEFAULT; |
| 382 | newWinSizeNs = WIN_SIZE_NS_MS_DEFAULT; |
| 383 | newWinSizeNa = WIN_SIZE_NA_MS_DEFAULT; |
| 384 | newWinSizeDhcp6Direct = WIN_SIZE_DHCP6_DIRECT_MS_DEFAULT; |
| 385 | newWinSizeDhcp6Indirect = WIN_SIZE_DHCP6_INDIRECT_MS_DEFAULT; |
| 386 | newWinSizeIcmp = WIN_SIZE_ICMP_MS_DEFAULT; |
| 387 | newWinSizeIcmp6 = WIN_SIZE_ICMP6_MS_DEFAULT; |
| 388 | } |
| 389 | if (newWinSizeArp != winSizeArp) { |
| 390 | winSizeArp = newWinSizeArp; |
| 391 | mapCounterFilter.get(ARP_FILTER).setWinSize(winSizeArp); |
| 392 | } |
| 393 | if (newWinSizeDhcp != winSizeDhcp) { |
| 394 | winSizeDhcp = newWinSizeDhcp; |
| 395 | mapCounterFilter.get(DHCP_FILTER).setWinSize(winSizeDhcp); |
| 396 | } |
| 397 | if (newWinSizeNs != winSizeNs) { |
| 398 | winSizeNs = newWinSizeNs; |
| 399 | mapCounterFilter.get(NS_FILTER).setWinSize(winSizeNs); |
| 400 | } |
| 401 | if (newWinSizeNa != winSizeNa) { |
| 402 | winSizeNa = newWinSizeNa; |
| 403 | mapCounterFilter.get(NA_FILTER).setWinSize(winSizeNa); |
| 404 | } |
| 405 | if (newWinSizeDhcp6Direct != winSizeDhcp6Direct) { |
| 406 | winSizeDhcp6Direct = newWinSizeDhcp6Direct; |
| 407 | mapCounterFilter.get(DHCP6_DIRECT_FILTER).setWinSize(winSizeDhcp6Direct); |
| 408 | } |
| 409 | if (newWinSizeDhcp6Indirect != winSizeDhcp6Indirect) { |
| 410 | winSizeDhcp6Indirect = newWinSizeDhcp6Indirect; |
| 411 | mapCounterFilter.get(DHCP6_INDIRECT_FILTER).setWinSize(winSizeDhcp6Indirect); |
| 412 | } |
| 413 | if (newWinSizeIcmp != winSizeIcmp) { |
| 414 | winSizeIcmp = newWinSizeIcmp; |
| 415 | mapCounterFilter.get(ICMP_FILTER).setWinSize(winSizeIcmp); |
| 416 | } |
| 417 | if (newWinSizeIcmp6 != winSizeIcmp6) { |
| 418 | winSizeIcmp6 = newWinSizeIcmp6; |
| 419 | mapCounterFilter.get(ICMP6_FILTER).setWinSize(winSizeIcmp6); |
| 420 | } |
| 421 | |
| 422 | } |
| 423 | |
| 424 | private void checkChangeInGuardTime(ComponentContext context) { |
| 425 | Dictionary<?, ?> properties = context.getProperties(); |
| 426 | int newGuardTimeArp, newGuardTimeDhcp, newGuardTimeNs, newGuardTimeNa; |
| 427 | int newGuardTimeDhcp6Direct, newGuardTimeDhcp6Indirect, newGuardTimeIcmp, newGuardTimeIcmp6; |
| 428 | try { |
| 429 | String s = get(properties, PROP_GUARD_TIME_ARP_SEC); |
| 430 | newGuardTimeArp = isNullOrEmpty(s) ? guardTimeArp : Integer.parseInt(s.trim()); |
| 431 | |
| 432 | s = get(properties, PROP_GUARD_TIME_DHCP_SEC); |
| 433 | newGuardTimeDhcp = isNullOrEmpty(s) ? guardTimeDhcp : Integer.parseInt(s.trim()); |
| 434 | |
| 435 | s = get(properties, PROP_GUARD_TIME_NS_SEC); |
| 436 | newGuardTimeNs = isNullOrEmpty(s) ? guardTimeNs : Integer.parseInt(s.trim()); |
| 437 | |
| 438 | s = get(properties, PROP_GUARD_TIME_NA_SEC); |
| 439 | newGuardTimeNa = isNullOrEmpty(s) ? guardTimeNa : Integer.parseInt(s.trim()); |
| 440 | |
| 441 | s = get(properties, PROP_GUARD_TIME_DHCP6_DIRECT_SEC); |
| 442 | newGuardTimeDhcp6Direct = isNullOrEmpty(s) ? guardTimeDhcp6Direct : Integer.parseInt(s.trim()); |
| 443 | |
| 444 | s = get(properties, PROP_GUARD_TIME_DHCP6_INDIRECT_SEC); |
| 445 | newGuardTimeDhcp6Indirect = isNullOrEmpty(s) ? guardTimeDhcp6Indirect : Integer.parseInt(s.trim()); |
| 446 | |
| 447 | s = get(properties, PROP_GUARD_TIME_ICMP_SEC); |
| 448 | newGuardTimeIcmp = isNullOrEmpty(s) ? guardTimeIcmp : Integer.parseInt(s.trim()); |
| 449 | |
| 450 | s = get(properties, PROP_GUARD_TIME_ICMP6_SEC); |
| 451 | newGuardTimeIcmp6 = isNullOrEmpty(s) ? guardTimeIcmp6 : Integer.parseInt(s.trim()); |
| 452 | } catch (NumberFormatException | ClassCastException e) { |
| 453 | |
| 454 | newGuardTimeArp = GUARD_TIME_ARP_SEC_DEFAULT; |
| 455 | newGuardTimeDhcp = GUARD_TIME_DHCP_SEC_DEFAULT; |
| 456 | newGuardTimeNs = GUARD_TIME_NS_SEC_DEFAULT; |
| 457 | newGuardTimeNa = GUARD_TIME_NA_SEC_DEFAULT; |
| 458 | newGuardTimeDhcp6Direct = GUARD_TIME_DHCP6_DIRECT_SEC_DEFAULT; |
| 459 | newGuardTimeDhcp6Indirect = GUARD_TIME_DHCP6_INDIRECT_SEC_DEFAULT; |
| 460 | newGuardTimeIcmp = GUARD_TIME_ICMP_SEC_DEFAULT; |
| 461 | newGuardTimeIcmp6 = GUARD_TIME_ICMP6_SEC_DEFAULT; |
| 462 | } |
| 463 | if (newGuardTimeArp != guardTimeArp) { |
| 464 | guardTimeArp = newGuardTimeArp; |
| 465 | mapCounterFilter.get(ARP_FILTER).setGuardTime(guardTimeArp); |
| 466 | } |
| 467 | if (newGuardTimeDhcp != guardTimeDhcp) { |
| 468 | guardTimeDhcp = newGuardTimeDhcp; |
| 469 | mapCounterFilter.get(DHCP_FILTER).setGuardTime(guardTimeDhcp); |
| 470 | } |
| 471 | if (newGuardTimeNs != guardTimeNs) { |
| 472 | guardTimeNs = newGuardTimeNs; |
| 473 | mapCounterFilter.get(NS_FILTER).setGuardTime(guardTimeNs); |
| 474 | } |
| 475 | if (newGuardTimeNa != guardTimeNa) { |
| 476 | guardTimeNa = newGuardTimeNa; |
| 477 | mapCounterFilter.get(NA_FILTER).setGuardTime(guardTimeNa); |
| 478 | } |
| 479 | if (newGuardTimeDhcp6Direct != guardTimeDhcp6Direct) { |
| 480 | guardTimeDhcp6Direct = newGuardTimeDhcp6Direct; |
| 481 | mapCounterFilter.get(DHCP6_DIRECT_FILTER).setGuardTime(guardTimeDhcp6Direct); |
| 482 | } |
| 483 | if (newGuardTimeDhcp6Indirect != guardTimeDhcp6Indirect) { |
| 484 | guardTimeDhcp6Indirect = newGuardTimeDhcp6Indirect; |
| 485 | mapCounterFilter.get(DHCP6_INDIRECT_FILTER).setGuardTime(guardTimeDhcp6Indirect); |
| 486 | } |
| 487 | if (newGuardTimeIcmp != guardTimeIcmp) { |
| 488 | guardTimeIcmp = newGuardTimeIcmp; |
| 489 | mapCounterFilter.get(ICMP_FILTER).setGuardTime(guardTimeIcmp); |
| 490 | } |
| 491 | if (newGuardTimeIcmp6 != guardTimeIcmp6) { |
| 492 | guardTimeIcmp6 = newGuardTimeIcmp6; |
| 493 | mapCounterFilter.get(ICMP6_FILTER).setGuardTime(guardTimeIcmp6); |
| 494 | } |
| 495 | |
| 496 | |
| 497 | } |
| 498 | |
| 499 | private void checkChangeInWinThres(ComponentContext context) { |
| 500 | Dictionary<?, ?> properties = context.getProperties(); |
| 501 | |
| 502 | int newWinThresArp, newWinThresDhcp, newWinThresNs, newWinThresNa; |
| 503 | int newWinThresDhcp6Direct, newWinThresDhcp6Indirect, newWinThresIcmp, newWinThresIcmp6; |
| 504 | try { |
| 505 | |
| 506 | String s = get(properties, PROP_WIN_THRES_ARP); |
| 507 | newWinThresArp = isNullOrEmpty(s) ? winThresArp : Integer.parseInt(s.trim()); |
| 508 | |
| 509 | s = get(properties, PROP_WIN_THRES_DHCP); |
| 510 | newWinThresDhcp = isNullOrEmpty(s) ? winThresDhcp : Integer.parseInt(s.trim()); |
| 511 | |
| 512 | s = get(properties, PROP_WIN_THRES_NS); |
| 513 | newWinThresNs = isNullOrEmpty(s) ? winThresNs : Integer.parseInt(s.trim()); |
| 514 | |
| 515 | s = get(properties, PROP_WIN_THRES_NA); |
| 516 | newWinThresNa = isNullOrEmpty(s) ? winThresNa : Integer.parseInt(s.trim()); |
| 517 | |
| 518 | s = get(properties, PROP_WIN_THRES_DHCP6_DIRECT); |
| 519 | newWinThresDhcp6Direct = isNullOrEmpty(s) ? winThresDhcp6Direct : Integer.parseInt(s.trim()); |
| 520 | |
| 521 | s = get(properties, PROP_WIN_THRES_DHCP6_INDIRECT); |
| 522 | newWinThresDhcp6Indirect = isNullOrEmpty(s) ? winThresDhcp6Indirect : Integer.parseInt(s.trim()); |
| 523 | |
| 524 | s = get(properties, PROP_WIN_THRES_ICMP); |
| 525 | newWinThresIcmp = isNullOrEmpty(s) ? winThresIcmp : Integer.parseInt(s.trim()); |
| 526 | |
| 527 | s = get(properties, PROP_WIN_THRES_ICMP6); |
| 528 | newWinThresIcmp6 = isNullOrEmpty(s) ? winThresIcmp6 : Integer.parseInt(s.trim()); |
| 529 | |
| 530 | } catch (NumberFormatException | ClassCastException e) { |
| 531 | newWinThresArp = WIN_THRES_ARP_DEFAULT; |
| 532 | newWinThresDhcp = WIN_THRES_DHCP_DEFAULT; |
| 533 | newWinThresNs = WIN_THRES_NS_DEFAULT; |
| 534 | newWinThresNa = WIN_THRES_NA_DEFAULT; |
| 535 | newWinThresDhcp6Direct = WIN_THRES_DHCP6_DIRECT_DEFAULT; |
| 536 | newWinThresDhcp6Indirect = WIN_THRES_DHCP6_INDIRECT_DEFAULT; |
| 537 | newWinThresIcmp = WIN_THRES_ICMP_DEFAULT; |
| 538 | newWinThresIcmp6 = WIN_THRES_ICMP6_DEFAULT; |
| 539 | |
| 540 | } |
| 541 | |
| 542 | if (newWinThresArp != winThresArp) { |
| 543 | winThresArp = newWinThresArp; |
| 544 | mapCounterFilter.get(ARP_FILTER).setWinThres(winThresArp); |
| 545 | } |
| 546 | if (newWinThresDhcp != winThresDhcp) { |
| 547 | winThresDhcp = newWinThresDhcp; |
| 548 | mapCounterFilter.get(DHCP_FILTER).setWinThres(winThresDhcp); |
| 549 | } |
| 550 | if (newWinThresNs != winThresNs) { |
| 551 | winThresNs = newWinThresNs; |
| 552 | mapCounterFilter.get(NS_FILTER).setWinThres(winThresNs); |
| 553 | } |
| 554 | if (newWinThresNa != winThresNa) { |
| 555 | winThresNa = newWinThresNa; |
| 556 | mapCounterFilter.get(NA_FILTER).setWinThres(winThresNa); |
| 557 | } |
| 558 | if (newWinThresDhcp6Direct != winThresDhcp6Direct) { |
| 559 | winThresDhcp6Direct = newWinThresDhcp6Direct; |
| 560 | mapCounterFilter.get(DHCP6_DIRECT_FILTER).setWinThres(winThresDhcp6Direct); |
| 561 | } |
| 562 | if (newWinThresDhcp6Indirect != winThresDhcp6Indirect) { |
| 563 | winThresDhcp6Indirect = newWinThresDhcp6Indirect; |
| 564 | mapCounterFilter.get(DHCP6_INDIRECT_FILTER).setWinThres(winThresDhcp6Indirect); |
| 565 | } |
| 566 | if (newWinThresIcmp != winThresIcmp) { |
| 567 | winThresIcmp = newWinThresIcmp; |
| 568 | mapCounterFilter.get(ICMP_FILTER).setWinThres(winThresIcmp); |
| 569 | } |
| 570 | if (newWinThresIcmp6 != winThresIcmp6) { |
| 571 | winThresIcmp6 = newWinThresIcmp6; |
| 572 | mapCounterFilter.get(ICMP6_FILTER).setWinThres(winThresIcmp6); |
| 573 | } |
| 574 | |
| 575 | } |
| 576 | |
| 577 | @Modified |
| 578 | private void modified(ComponentContext context) { |
| 579 | if (context == null) { |
| 580 | log.info("Default config"); |
| 581 | return; |
| 582 | } |
| 583 | |
| 584 | checkChangeInPps(context); |
| 585 | checkChangeInWinSize(context); |
| 586 | checkChangeInGuardTime(context); |
| 587 | checkChangeInWinThres(context); |
| 588 | |
| 589 | log.info("Reconfigured ppsArp: {} ppsDhcp: {} ppsNs: {} ppsNa: {} " + |
| 590 | "ppsDhcp6Direct: {} ppsDhcp6Indirect: {} ppsIcmp: {} ppsIcmp6: {}", |
| 591 | ppsArp, ppsDhcp, ppsNs, ppsNa, ppsDhcp6Direct, ppsDhcp6Indirect, |
| 592 | ppsIcmp, ppsIcmp6); |
| 593 | |
| 594 | log.info("Reconfigured winSizeArp: {} winSizeDhcp: {} winSizeNs: {} winSizeNa: {} " + |
| 595 | "winSizeDhcp6Direct: {} winSizeDhcp6Indirect: {} winSizeIcmp: {} winSizeIcmp6: {}", |
| 596 | winSizeArp, winSizeDhcp, winSizeNs, winSizeNa, winSizeDhcp6Direct, |
| 597 | winSizeDhcp6Indirect, winSizeIcmp, winSizeIcmp6); |
| 598 | |
| 599 | log.info("Reconfigured guardTimeArp: {} guardTimeDhcp: {} guardTimeNs: {} guardTimeNa: {} " + |
| 600 | "guardTimeDhcp6Direct: {} guardTimeDhcp6Indirect: {} guardTimeIcmp: {} guardTimeIcmp6: {}", |
| 601 | guardTimeArp, guardTimeDhcp, guardTimeNs, guardTimeNa, guardTimeDhcp6Direct, |
| 602 | guardTimeDhcp6Indirect, guardTimeIcmp, guardTimeIcmp6); |
| 603 | |
| 604 | log.info("Reconfigured winThresArp: {} winThresDhcp: {} winThresNs: {} winThresNa: {} " + |
| 605 | "winThresDhcp6Direct: {} winThresDhcp6Indirect: {} winThresIcmp: {} winThresIcmp6: {}", |
| 606 | winThresArp, winThresDhcp, winThresNs, winThresNa, winThresDhcp6Direct, |
| 607 | winThresDhcp6Indirect, winThresIcmp, winThresIcmp6); |
| 608 | } |
| 609 | |
| 610 | /** |
| 611 | * Create all required filters. |
| 612 | */ |
| 613 | private void createAllFilters() { |
| 614 | DefaultPacketInFilter filter; |
| 615 | ArpPacketClassifier arp = new ArpPacketClassifier(); |
| 616 | filter = new DefaultPacketInFilter(ppsArp, winSizeArp, guardTimeArp, winThresArp, ARP_FILTER, arp); |
| 617 | packetService.addFilter(filter); |
| 618 | mapCounterFilter.put(filter.name(), filter); |
| 619 | DhcpPacketClassifier dhcp4 = new DhcpPacketClassifier(); |
| 620 | filter = new DefaultPacketInFilter(ppsDhcp, winSizeDhcp, guardTimeDhcp, winThresDhcp, DHCP_FILTER, dhcp4); |
| 621 | packetService.addFilter(filter); |
| 622 | mapCounterFilter.put(filter.name(), filter); |
| 623 | Dhcp6DirectPacketClassifier dhcp6Direct = new Dhcp6DirectPacketClassifier(); |
| 624 | filter = new DefaultPacketInFilter(ppsDhcp6Direct, winSizeDhcp6Direct, guardTimeDhcp6Direct, |
| 625 | winThresDhcp6Direct, DHCP6_DIRECT_FILTER, dhcp6Direct); |
| 626 | packetService.addFilter(filter); |
| 627 | mapCounterFilter.put(filter.name(), filter); |
| 628 | Dhcp6IndirectPacketClassifier dhcp6Indirect = new Dhcp6IndirectPacketClassifier(); |
| 629 | filter = new DefaultPacketInFilter(ppsDhcp6Direct, winSizeDhcp6Direct, guardTimeDhcp6Direct, |
| 630 | winThresDhcp6Direct, DHCP6_INDIRECT_FILTER, dhcp6Indirect); |
| 631 | packetService.addFilter(filter); |
| 632 | mapCounterFilter.put(filter.name(), filter); |
| 633 | NAPacketClassifier na = new NAPacketClassifier(); |
| 634 | filter = new DefaultPacketInFilter(ppsNa, winSizeNa, guardTimeNa, winThresNa, NA_FILTER, na); |
| 635 | packetService.addFilter(filter); |
| 636 | mapCounterFilter.put(filter.name(), filter); |
| 637 | NSPacketClassifier ns = new NSPacketClassifier(); |
| 638 | filter = new DefaultPacketInFilter(ppsNs, winSizeNs, guardTimeNs, winThresNs, NS_FILTER, ns); |
| 639 | packetService.addFilter(filter); |
| 640 | mapCounterFilter.put(filter.name(), filter); |
| 641 | IcmpPacketClassifier icmp = new IcmpPacketClassifier(); |
| 642 | filter = new DefaultPacketInFilter(ppsIcmp, winSizeIcmp, guardTimeIcmp, winThresIcmp, ICMP_FILTER, icmp); |
| 643 | packetService.addFilter(filter); |
| 644 | mapCounterFilter.put(filter.name(), filter); |
| 645 | Icmp6PacketClassifier icmp6 = new Icmp6PacketClassifier(); |
| 646 | filter = new DefaultPacketInFilter(ppsIcmp6, winSizeIcmp6, guardTimeIcmp6, winThresIcmp6, ICMP6_FILTER, icmp6); |
| 647 | packetService.addFilter(filter); |
| 648 | mapCounterFilter.put(filter.name(), filter); |
| 649 | } |
| 650 | |
| 651 | /** |
| 652 | * Delete all the filters. |
| 653 | */ |
| 654 | private void removeAllFilters() { |
| 655 | packetService.clearFilters(); |
| 656 | mapCounterFilter.clear(); |
| 657 | } |
| 658 | |
| 659 | @Override |
| 660 | public Map<String, PacketInFilter> filterMap() { |
| 661 | return ImmutableMap.copyOf(mapCounterFilter); |
| 662 | } |
| 663 | |
| 664 | |
| 665 | |
| 666 | } |