Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 1 | /* |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 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.opencord.dhcpl2relay; |
| 17 | |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 18 | import static org.onlab.packet.DHCP.DHCPOptionCode.OptionCode_MessageType; |
| 19 | import static org.onlab.packet.MacAddress.valueOf; |
| 20 | import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY; |
| 21 | |
| 22 | import java.nio.ByteBuffer; |
| 23 | import java.util.ArrayList; |
| 24 | import java.util.Arrays; |
| 25 | import java.util.Dictionary; |
| 26 | import java.util.List; |
| 27 | import java.util.Map; |
| 28 | import java.util.Optional; |
| 29 | import java.util.Set; |
| 30 | import java.util.concurrent.atomic.AtomicReference; |
| 31 | import java.util.stream.Collectors; |
| 32 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 33 | import org.apache.felix.scr.annotations.Activate; |
| 34 | import org.apache.felix.scr.annotations.Component; |
| 35 | import org.apache.felix.scr.annotations.Deactivate; |
| 36 | import org.apache.felix.scr.annotations.Modified; |
| 37 | import org.apache.felix.scr.annotations.Property; |
| 38 | import org.apache.felix.scr.annotations.Reference; |
| 39 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 40 | import org.apache.felix.scr.annotations.Service; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 41 | import org.onlab.packet.DHCP; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 42 | import org.onlab.packet.DHCPPacketType; |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 43 | import org.onlab.packet.Ethernet; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 44 | import org.onlab.packet.IPv4; |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 45 | import org.onlab.packet.IpAddress; |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 46 | import org.onlab.packet.MacAddress; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 47 | import org.onlab.packet.TpPort; |
| 48 | import org.onlab.packet.UDP; |
| 49 | import org.onlab.packet.VlanId; |
Jonathan Hart | edbf642 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 50 | import org.onlab.packet.dhcp.DhcpOption; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 51 | import org.onlab.util.Tools; |
| 52 | import org.onosproject.cfg.ComponentConfigService; |
| 53 | import org.onosproject.core.ApplicationId; |
| 54 | import org.onosproject.core.CoreService; |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 55 | import org.onosproject.event.AbstractListenerManager; |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 56 | import org.onosproject.mastership.MastershipEvent; |
| 57 | import org.onosproject.mastership.MastershipListener; |
| 58 | import org.onosproject.mastership.MastershipService; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 59 | import org.onosproject.net.AnnotationKeys; |
| 60 | import org.onosproject.net.ConnectPoint; |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 61 | import org.onosproject.net.Device; |
| 62 | import org.onosproject.net.DeviceId; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 63 | import org.onosproject.net.Host; |
| 64 | import org.onosproject.net.Port; |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 65 | import org.onosproject.net.PortNumber; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 66 | import org.onosproject.net.config.ConfigFactory; |
| 67 | import org.onosproject.net.config.NetworkConfigEvent; |
| 68 | import org.onosproject.net.config.NetworkConfigListener; |
| 69 | import org.onosproject.net.config.NetworkConfigRegistry; |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 70 | import org.onosproject.net.device.DeviceEvent; |
| 71 | import org.onosproject.net.device.DeviceListener; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 72 | import org.onosproject.net.device.DeviceService; |
| 73 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 74 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 75 | import org.onosproject.net.flow.TrafficSelector; |
| 76 | import org.onosproject.net.flow.TrafficTreatment; |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 77 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 78 | import org.onosproject.net.host.HostService; |
| 79 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 80 | import org.onosproject.net.packet.OutboundPacket; |
| 81 | import org.onosproject.net.packet.PacketContext; |
| 82 | import org.onosproject.net.packet.PacketPriority; |
| 83 | import org.onosproject.net.packet.PacketProcessor; |
| 84 | import org.onosproject.net.packet.PacketService; |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 85 | import org.opencord.dhcpl2relay.packet.DhcpOption82; |
Gamze Abaka | c806c6c | 2018-12-03 12:49:46 +0000 | [diff] [blame] | 86 | import org.opencord.sadis.BaseInformationService; |
| 87 | import org.opencord.sadis.SadisService; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 88 | import org.opencord.sadis.SubscriberAndDeviceInformation; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 89 | import org.osgi.service.component.ComponentContext; |
| 90 | import org.slf4j.Logger; |
| 91 | import org.slf4j.LoggerFactory; |
| 92 | |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 93 | import com.google.common.collect.ImmutableSet; |
| 94 | import com.google.common.collect.Lists; |
| 95 | import com.google.common.collect.Maps; |
| 96 | import com.google.common.collect.Sets; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * DHCP Relay Agent Application Component. |
| 100 | */ |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 101 | @Service |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 102 | @Component(immediate = true) |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 103 | public class DhcpL2Relay |
| 104 | extends AbstractListenerManager<DhcpL2RelayEvent, DhcpL2RelayListener> |
| 105 | implements DhcpL2RelayService { |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 106 | |
| 107 | public static final String DHCP_L2RELAY_APP = "org.opencord.dhcpl2relay"; |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 108 | private static final String HOST_LOC_PROVIDER = |
| 109 | "org.onosproject.provider.host.impl.HostLocationProvider"; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 110 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 111 | private final InternalConfigListener cfgListener = |
| 112 | new InternalConfigListener(); |
| 113 | |
| 114 | private final Set<ConfigFactory> factories = ImmutableSet.of( |
| 115 | new ConfigFactory<ApplicationId, DhcpL2RelayConfig>(APP_SUBJECT_FACTORY, |
| 116 | DhcpL2RelayConfig.class, |
| 117 | "dhcpl2relay") { |
| 118 | @Override |
| 119 | public DhcpL2RelayConfig createConfig() { |
| 120 | return new DhcpL2RelayConfig(); |
| 121 | } |
| 122 | } |
| 123 | ); |
| 124 | |
| 125 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 126 | protected NetworkConfigRegistry cfgService; |
| 127 | |
| 128 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 129 | protected CoreService coreService; |
| 130 | |
| 131 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 132 | protected PacketService packetService; |
| 133 | |
| 134 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 135 | protected HostService hostService; |
| 136 | |
| 137 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 138 | protected ComponentConfigService componentConfigService; |
| 139 | |
| 140 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Gamze Abaka | c806c6c | 2018-12-03 12:49:46 +0000 | [diff] [blame] | 141 | protected SadisService sadisService; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 142 | |
| 143 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 144 | protected DeviceService deviceService; |
| 145 | |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 146 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 147 | protected MastershipService mastershipService; |
| 148 | |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 149 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 150 | protected FlowObjectiveService flowObjectiveService; |
| 151 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 152 | @Property(name = "option82", boolValue = true, |
| 153 | label = "Add option 82 to relayed packets") |
| 154 | protected boolean option82 = true; |
| 155 | |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 156 | @Property(name = "enableDhcpBroadcastReplies", boolValue = false, |
Amit Ghosh | 2095dc6 | 2017-09-25 20:56:55 +0100 | [diff] [blame] | 157 | label = "Ask the DHCP Server to send back replies as L2 broadcast") |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 158 | protected boolean enableDhcpBroadcastReplies = false; |
| 159 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 160 | private DhcpRelayPacketProcessor dhcpRelayPacketProcessor = |
| 161 | new DhcpRelayPacketProcessor(); |
| 162 | |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 163 | private InnerMastershipListener changeListener = new InnerMastershipListener(); |
| 164 | private InnerDeviceListener deviceListener = new InnerDeviceListener(); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 165 | |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 166 | // connect points to the DHCP server |
| 167 | Set<ConnectPoint> dhcpConnectPoints; |
| 168 | private AtomicReference<ConnectPoint> dhcpServerConnectPoint = new AtomicReference<>(); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 169 | private MacAddress dhcpConnectMac = MacAddress.BROADCAST; |
| 170 | private ApplicationId appId; |
| 171 | |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 172 | static Map<String, DhcpAllocationInfo> allocationMap = Maps.newConcurrentMap(); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 173 | private boolean modifyClientPktsSrcDstMac = false; |
| 174 | //Whether to use the uplink port of the OLTs to send/receive messages to the DHCP server |
| 175 | private boolean useOltUplink = false; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 176 | |
Gamze Abaka | c806c6c | 2018-12-03 12:49:46 +0000 | [diff] [blame] | 177 | private BaseInformationService<SubscriberAndDeviceInformation> subsService; |
| 178 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 179 | @Activate |
| 180 | protected void activate(ComponentContext context) { |
| 181 | //start the dhcp relay agent |
| 182 | appId = coreService.registerApplication(DHCP_L2RELAY_APP); |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 183 | // ensure that host-learning via dhcp includes IP addresses |
| 184 | componentConfigService.preSetProperty(HOST_LOC_PROVIDER, |
| 185 | "useDhcp", Boolean.TRUE.toString()); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 186 | componentConfigService.registerProperties(getClass()); |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 187 | eventDispatcher.addSink(DhcpL2RelayEvent.class, listenerRegistry); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 188 | |
| 189 | cfgService.addListener(cfgListener); |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 190 | mastershipService.addListener(changeListener); |
| 191 | deviceService.addListener(deviceListener); |
| 192 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 193 | factories.forEach(cfgService::registerConfigFactory); |
| 194 | //update the dhcp server configuration. |
| 195 | updateConfig(); |
| 196 | //add the packet services. |
| 197 | packetService.addProcessor(dhcpRelayPacketProcessor, |
| 198 | PacketProcessor.director(0)); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 199 | if (context != null) { |
| 200 | modified(context); |
| 201 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 202 | |
Gamze Abaka | c806c6c | 2018-12-03 12:49:46 +0000 | [diff] [blame] | 203 | subsService = sadisService.getSubscriberInfoService(); |
| 204 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 205 | log.info("DHCP-L2-RELAY Started"); |
| 206 | } |
| 207 | |
| 208 | @Deactivate |
| 209 | protected void deactivate() { |
| 210 | cfgService.removeListener(cfgListener); |
| 211 | factories.forEach(cfgService::unregisterConfigFactory); |
| 212 | packetService.removeProcessor(dhcpRelayPacketProcessor); |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 213 | cancelDhcpPktsFromServer(); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 214 | |
| 215 | componentConfigService.unregisterProperties(getClass(), false); |
Deepa Vaddireddy | 77a6ac7 | 2017-09-20 20:36:52 +0530 | [diff] [blame] | 216 | deviceService.removeListener(deviceListener); |
| 217 | mastershipService.removeListener(changeListener); |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 218 | eventDispatcher.removeSink(DhcpL2RelayEvent.class); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 219 | log.info("DHCP-L2-RELAY Stopped"); |
| 220 | } |
| 221 | |
| 222 | @Modified |
| 223 | protected void modified(ComponentContext context) { |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 224 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 225 | Dictionary<?, ?> properties = context.getProperties(); |
| 226 | |
| 227 | Boolean o = Tools.isPropertyEnabled(properties, "option82"); |
| 228 | if (o != null) { |
| 229 | option82 = o; |
| 230 | } |
Amit Ghosh | 2095dc6 | 2017-09-25 20:56:55 +0100 | [diff] [blame] | 231 | |
| 232 | o = Tools.isPropertyEnabled(properties, "enableDhcpBroadcastReplies"); |
| 233 | if (o != null) { |
| 234 | enableDhcpBroadcastReplies = o; |
| 235 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Checks if this app has been configured. |
| 240 | * |
| 241 | * @return true if all information we need have been initialized |
| 242 | */ |
| 243 | private boolean configured() { |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 244 | if (!useOltUplink) { |
| 245 | return dhcpServerConnectPoint.get() != null; |
| 246 | } |
| 247 | return true; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 248 | } |
| 249 | |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 250 | /** |
| 251 | * Selects a connect point through an available device for which it is the master. |
| 252 | */ |
| 253 | private void selectServerConnectPoint() { |
| 254 | synchronized (this) { |
| 255 | dhcpServerConnectPoint.set(null); |
| 256 | if (dhcpConnectPoints != null) { |
| 257 | // find a connect point through a device for which we are master |
| 258 | for (ConnectPoint cp: dhcpConnectPoints) { |
| 259 | if (mastershipService.isLocalMaster(cp.deviceId())) { |
| 260 | if (deviceService.isAvailable(cp.deviceId())) { |
| 261 | dhcpServerConnectPoint.set(cp); |
| 262 | } |
| 263 | log.info("DHCP connectPoint selected is {}", cp); |
| 264 | break; |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | log.info("DHCP Server connectPoint is {}", dhcpServerConnectPoint.get()); |
| 270 | |
| 271 | if (dhcpServerConnectPoint.get() == null) { |
| 272 | log.error("Master of none, can't relay DHCP Message to server"); |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * Updates the network configuration. |
| 279 | */ |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 280 | private void updateConfig() { |
| 281 | DhcpL2RelayConfig cfg = cfgService.getConfig(appId, DhcpL2RelayConfig.class); |
| 282 | if (cfg == null) { |
| 283 | log.warn("Dhcp Server info not available"); |
| 284 | return; |
| 285 | } |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 286 | |
| 287 | dhcpConnectPoints = Sets.newConcurrentHashSet(cfg.getDhcpServerConnectPoint()); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 288 | modifyClientPktsSrcDstMac = cfg.getModifySrcDstMacAddresses(); |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 289 | boolean prevUseOltUplink = useOltUplink; |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 290 | useOltUplink = cfg.getUseOltUplinkForServerPktInOut(); |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 291 | |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 292 | if (useOltUplink) { |
| 293 | for (ConnectPoint cp : getUplinkPortsOfOlts()) { |
| 294 | log.debug("requestDhcpPackets: ConnectPoint: {}", cp); |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 295 | requestDhcpPacketsFromConnectPoint(cp, null); |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 296 | } |
| 297 | // check if previous config was different and so trap flows may |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 298 | // need to be removed from other places like AGG switches |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 299 | if (!prevUseOltUplink) { |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 300 | addOrRemoveDhcpTrapFromServer(false); |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 301 | } |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 302 | } else { |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 303 | // uplink on AGG switch |
| 304 | addOrRemoveDhcpTrapFromServer(true); |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 305 | } |
| 306 | } |
| 307 | |
| 308 | private void cancelDhcpPktsFromServer() { |
| 309 | if (useOltUplink) { |
| 310 | for (ConnectPoint cp : getUplinkPortsOfOlts()) { |
| 311 | log.debug("cancelDhcpPackets: ConnectPoint: {}", cp); |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 312 | cancelDhcpPacketsFromConnectPoint(cp, null); |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 313 | } |
| 314 | } else { |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 315 | // uplink on AGG switch |
| 316 | addOrRemoveDhcpTrapFromServer(false); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 317 | } |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 320 | /** |
| 321 | * Used to add or remove DHCP trap flow for packets received from DHCP server. |
| 322 | * Typically used on a non OLT device, like an AGG switch. When adding, a |
| 323 | * new dhcp server connect point is selected from the configured options. |
| 324 | * |
| 325 | * @param add true if dhcp trap flow is to be added, false to remove the |
| 326 | * trap flow |
| 327 | */ |
| 328 | private void addOrRemoveDhcpTrapFromServer(boolean add) { |
| 329 | if (add) { |
| 330 | selectServerConnectPoint(); |
| 331 | log.debug("dhcp server connect point: " + dhcpServerConnectPoint); |
| 332 | } |
| 333 | if (dhcpServerConnectPoint.get() == null) { |
| 334 | log.warn("No dhcpServer connectPoint found, cannot {} dhcp trap flows", |
| 335 | (add) ? "install" : "remove"); |
| 336 | return; |
| 337 | } |
| 338 | if (add) { |
| 339 | log.info("Adding trap to dhcp server connect point: " |
| 340 | + dhcpServerConnectPoint); |
| 341 | requestDhcpPacketsFromConnectPoint(dhcpServerConnectPoint.get(), |
| 342 | Optional.of(PacketPriority.HIGH1)); |
| 343 | } else { |
| 344 | log.info("Removing trap from dhcp server connect point: " |
| 345 | + dhcpServerConnectPoint); |
| 346 | cancelDhcpPacketsFromConnectPoint(dhcpServerConnectPoint.get(), |
| 347 | Optional.of(PacketPriority.HIGH1)); |
| 348 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | /** |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 352 | * Returns all the uplink ports of OLTs configured in SADIS. |
| 353 | * Only ports visible in ONOS and for which this instance is master |
| 354 | * are returned |
| 355 | */ |
| 356 | private List<ConnectPoint> getUplinkPortsOfOlts() { |
| 357 | List<ConnectPoint> cps = new ArrayList<>(); |
| 358 | |
| 359 | // find all the olt devices and if their uplink ports are visible |
| 360 | Iterable<Device> devices = deviceService.getDevices(); |
| 361 | for (Device d : devices) { |
| 362 | // check if this device is provisioned in Sadis |
| 363 | |
| 364 | log.debug("getUplinkPortsOfOlts: Checking mastership of {}", d); |
| 365 | // do only for devices for which we are the master |
| 366 | if (!mastershipService.isLocalMaster(d.id())) { |
| 367 | continue; |
| 368 | } |
| 369 | |
| 370 | String devSerialNo = d.serialNumber(); |
| 371 | SubscriberAndDeviceInformation deviceInfo = subsService.get(devSerialNo); |
| 372 | log.debug("getUplinkPortsOfOlts: Found device: {}", deviceInfo); |
| 373 | if (deviceInfo != null) { |
| 374 | // check if the uplink port with that number is available on the device |
| 375 | PortNumber pNum = PortNumber.portNumber(deviceInfo.uplinkPort()); |
| 376 | Port port = deviceService.getPort(d.id(), pNum); |
| 377 | log.debug("getUplinkPortsOfOlts: Found port: {}", port); |
| 378 | if (port != null) { |
| 379 | cps.add(new ConnectPoint(d.id(), pNum)); |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | return cps; |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Returns whether the passed port is the uplink port of the olt device. |
| 388 | */ |
| 389 | private boolean isUplinkPortOfOlt(DeviceId dId, Port p) { |
| 390 | log.debug("isUplinkPortOfOlt: DeviceId: {} Port: {}", dId, p); |
| 391 | // do only for devices for which we are the master |
| 392 | if (!mastershipService.isLocalMaster(dId)) { |
| 393 | return false; |
| 394 | } |
| 395 | |
| 396 | Device d = deviceService.getDevice(dId); |
| 397 | SubscriberAndDeviceInformation deviceInfo = subsService.get(d.serialNumber()); |
| 398 | |
| 399 | if (deviceInfo != null) { |
| 400 | return (deviceInfo.uplinkPort() == p.number().toLong()); |
| 401 | } |
| 402 | |
| 403 | return false; |
| 404 | } |
| 405 | |
| 406 | /** |
| 407 | * Returns the connectPoint which is the uplink port of the OLT. |
| 408 | */ |
| 409 | private ConnectPoint getUplinkConnectPointOfOlt(DeviceId dId) { |
| 410 | |
| 411 | Device d = deviceService.getDevice(dId); |
| 412 | SubscriberAndDeviceInformation deviceInfo = subsService.get(d.serialNumber()); |
| 413 | log.debug("getUplinkConnectPointOfOlt DeviceId: {} devInfo: {}", dId, deviceInfo); |
| 414 | if (deviceInfo != null) { |
| 415 | PortNumber pNum = PortNumber.portNumber(deviceInfo.uplinkPort()); |
| 416 | Port port = deviceService.getPort(d.id(), pNum); |
| 417 | if (port != null) { |
| 418 | return new ConnectPoint(d.id(), pNum); |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | return null; |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Request DHCP packet from particular connect point via PacketService. |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 427 | * Optionally provide a priority for the trap flow. If no such priority is |
| 428 | * provided, the default priority will be used. |
| 429 | * |
| 430 | * @param cp the connect point to trap dhcp packets from |
| 431 | * @param priority of the trap flow, null to use default priority |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 432 | */ |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 433 | private void requestDhcpPacketsFromConnectPoint(ConnectPoint cp, |
| 434 | Optional<PacketPriority> priority) { |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 435 | TrafficSelector.Builder selectorServer = DefaultTrafficSelector.builder() |
| 436 | .matchEthType(Ethernet.TYPE_IPV4) |
| 437 | .matchInPort(cp.port()) |
| 438 | .matchIPProtocol(IPv4.PROTOCOL_UDP) |
| 439 | .matchUdpSrc(TpPort.tpPort(UDP.DHCP_SERVER_PORT)); |
| 440 | packetService.requestPackets(selectorServer.build(), |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 441 | priority.isPresent() ? priority.get() : PacketPriority.CONTROL, |
| 442 | appId, Optional.of(cp.deviceId())); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | /** |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 446 | * Cancel DHCP packet from particular connect point via PacketService. If |
| 447 | * the request was made with a specific packet priority, then the same |
| 448 | * priority should be used in this call. |
| 449 | * |
| 450 | * @param cp the connect point for the trap flow |
| 451 | * @param priority with which the trap flow was requested; if request |
| 452 | * priority was not specified, this param should also be null |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 453 | */ |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 454 | private void cancelDhcpPacketsFromConnectPoint(ConnectPoint cp, |
| 455 | Optional<PacketPriority> priority) { |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 456 | TrafficSelector.Builder selectorServer = DefaultTrafficSelector.builder() |
| 457 | .matchEthType(Ethernet.TYPE_IPV4) |
| 458 | .matchInPort(cp.port()) |
| 459 | .matchIPProtocol(IPv4.PROTOCOL_UDP) |
| 460 | .matchUdpSrc(TpPort.tpPort(UDP.DHCP_SERVER_PORT)); |
| 461 | packetService.cancelPackets(selectorServer.build(), |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 462 | priority.isPresent() ? priority.get() : PacketPriority.CONTROL, |
| 463 | appId, Optional.of(cp.deviceId())); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 464 | } |
| 465 | |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 466 | public static Map<String, DhcpAllocationInfo> allocationMap() { |
| 467 | return allocationMap; |
| 468 | } |
| 469 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 470 | private SubscriberAndDeviceInformation getDevice(PacketContext context) { |
| 471 | String serialNo = deviceService.getDevice(context.inPacket(). |
| 472 | receivedFrom().deviceId()).serialNumber(); |
| 473 | |
| 474 | return subsService.get(serialNo); |
| 475 | } |
| 476 | |
| 477 | private SubscriberAndDeviceInformation getDevice(ConnectPoint cp) { |
| 478 | String serialNo = deviceService.getDevice(cp.deviceId()). |
| 479 | serialNumber(); |
| 480 | |
| 481 | return subsService.get(serialNo); |
| 482 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 483 | |
| 484 | private MacAddress relayAgentMacAddress(PacketContext context) { |
| 485 | |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 486 | SubscriberAndDeviceInformation device = this.getDevice(context); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 487 | if (device == null) { |
| 488 | log.warn("Device not found for {}", context.inPacket(). |
| 489 | receivedFrom()); |
| 490 | return null; |
| 491 | } |
| 492 | |
| 493 | return device.hardwareIdentifier(); |
| 494 | } |
| 495 | |
| 496 | private String nasPortId(PacketContext context) { |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 497 | return nasPortId(context.inPacket().receivedFrom()); |
| 498 | } |
| 499 | |
| 500 | private String nasPortId(ConnectPoint cp) { |
| 501 | Port p = deviceService.getPort(cp); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 502 | return p.annotations().value(AnnotationKeys.PORT_NAME); |
| 503 | } |
| 504 | |
| 505 | private SubscriberAndDeviceInformation getSubscriber(PacketContext context) { |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 506 | return subsService.get(nasPortId(context)); |
| 507 | } |
| 508 | |
| 509 | private VlanId cTag(PacketContext context) { |
| 510 | SubscriberAndDeviceInformation sub = getSubscriber(context); |
| 511 | if (sub == null) { |
| 512 | log.warn("Subscriber info not found for {}", context.inPacket(). |
| 513 | receivedFrom()); |
| 514 | return VlanId.NONE; |
| 515 | } |
| 516 | return sub.cTag(); |
| 517 | } |
| 518 | |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 519 | private VlanId cTag(ConnectPoint cp) { |
| 520 | String portId = nasPortId(cp); |
| 521 | SubscriberAndDeviceInformation sub = subsService.get(portId); |
| 522 | if (sub == null) { |
| 523 | log.warn("Subscriber info not found for {} looking for C-TAG", cp); |
| 524 | return VlanId.NONE; |
| 525 | } |
| 526 | return sub.cTag(); |
| 527 | } |
| 528 | |
| 529 | private VlanId sTag(ConnectPoint cp) { |
| 530 | String portId = nasPortId(cp); |
| 531 | SubscriberAndDeviceInformation sub = subsService.get(portId); |
| 532 | if (sub == null) { |
| 533 | log.warn("Subscriber info not found for {} looking for S-TAG", cp); |
| 534 | return VlanId.NONE; |
| 535 | } |
| 536 | return sub.sTag(); |
| 537 | } |
| 538 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 539 | private VlanId sTag(PacketContext context) { |
| 540 | SubscriberAndDeviceInformation sub = getSubscriber(context); |
| 541 | if (sub == null) { |
| 542 | log.warn("Subscriber info not found for {}", context.inPacket(). |
| 543 | receivedFrom()); |
| 544 | return VlanId.NONE; |
| 545 | } |
| 546 | return sub.sTag(); |
| 547 | } |
| 548 | |
| 549 | private class DhcpRelayPacketProcessor implements PacketProcessor { |
| 550 | |
| 551 | @Override |
| 552 | public void process(PacketContext context) { |
| 553 | if (!configured()) { |
| 554 | log.warn("Missing DHCP relay config. Abort packet processing"); |
| 555 | return; |
| 556 | } |
| 557 | |
| 558 | // process the packet and get the payload |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 559 | Ethernet packet = context.inPacket().parsed(); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 560 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 561 | if (packet == null) { |
| 562 | log.warn("Packet is null"); |
| 563 | return; |
| 564 | } |
| 565 | |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 566 | if (packet.getEtherType() == Ethernet.TYPE_IPV4) { |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 567 | IPv4 ipv4Packet = (IPv4) packet.getPayload(); |
| 568 | |
| 569 | if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_UDP) { |
| 570 | UDP udpPacket = (UDP) ipv4Packet.getPayload(); |
| 571 | if (udpPacket.getSourcePort() == UDP.DHCP_CLIENT_PORT || |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 572 | udpPacket.getSourcePort() == UDP.DHCP_SERVER_PORT) { |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 573 | DHCP dhcpPayload = (DHCP) udpPacket.getPayload(); |
| 574 | //This packet is dhcp. |
| 575 | processDhcpPacket(context, packet, dhcpPayload); |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | //forward the packet to ConnectPoint where the DHCP server is attached. |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 582 | private void forwardPacket(Ethernet packet, PacketContext context) { |
| 583 | ConnectPoint toSendTo = null; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 584 | |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 585 | if (!useOltUplink) { |
| 586 | toSendTo = dhcpServerConnectPoint.get(); |
| 587 | } else { |
| 588 | toSendTo = getUplinkConnectPointOfOlt(context.inPacket(). |
| 589 | receivedFrom().deviceId()); |
| 590 | } |
| 591 | |
| 592 | if (toSendTo != null) { |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 593 | TrafficTreatment t = DefaultTrafficTreatment.builder() |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 594 | .setOutput(toSendTo.port()).build(); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 595 | OutboundPacket o = new DefaultOutboundPacket( |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 596 | toSendTo.deviceId(), t, |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 597 | ByteBuffer.wrap(packet.serialize())); |
| 598 | if (log.isTraceEnabled()) { |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 599 | log.trace("Relaying packet to dhcp server at {} {}", |
| 600 | toSendTo, packet); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 601 | } |
| 602 | packetService.emit(o); |
| 603 | } else { |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 604 | log.error("No connect point to send msg to DHCP Server"); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 605 | } |
| 606 | } |
| 607 | |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 608 | // get the type of the DHCP packet |
| 609 | private DHCPPacketType getDhcpPacketType(DHCP dhcpPayload) { |
| 610 | |
Jonathan Hart | edbf642 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 611 | for (DhcpOption option : dhcpPayload.getOptions()) { |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 612 | if (option.getCode() == OptionCode_MessageType.getValue()) { |
| 613 | byte[] data = option.getData(); |
| 614 | return DHCPPacketType.getType(data[0]); |
| 615 | } |
| 616 | } |
| 617 | return null; |
| 618 | } |
| 619 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 620 | //process the dhcp packet before sending to server |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 621 | private void processDhcpPacket(PacketContext context, Ethernet packet, |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 622 | DHCP dhcpPayload) { |
| 623 | if (dhcpPayload == null) { |
| 624 | log.warn("DHCP payload is null"); |
| 625 | return; |
| 626 | } |
| 627 | |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 628 | DHCPPacketType incomingPacketType = getDhcpPacketType(dhcpPayload); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 629 | |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 630 | log.info("Received DHCP Packet of type {} from {}", |
| 631 | incomingPacketType, context.inPacket().receivedFrom()); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 632 | |
| 633 | switch (incomingPacketType) { |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 634 | case DHCPDISCOVER: |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 635 | Ethernet ethernetPacketDiscover = |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 636 | processDhcpPacketFromClient(context, packet); |
| 637 | if (ethernetPacketDiscover != null) { |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 638 | forwardPacket(ethernetPacketDiscover, context); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 639 | } |
| 640 | break; |
| 641 | case DHCPOFFER: |
| 642 | //reply to dhcp client. |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 643 | Ethernet ethernetPacketOffer = |
| 644 | processDhcpPacketFromServer(context, packet); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 645 | if (ethernetPacketOffer != null) { |
| 646 | sendReply(ethernetPacketOffer, dhcpPayload); |
| 647 | } |
| 648 | break; |
| 649 | case DHCPREQUEST: |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 650 | Ethernet ethernetPacketRequest = |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 651 | processDhcpPacketFromClient(context, packet); |
| 652 | if (ethernetPacketRequest != null) { |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 653 | forwardPacket(ethernetPacketRequest, context); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 654 | } |
| 655 | break; |
| 656 | case DHCPACK: |
| 657 | //reply to dhcp client. |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 658 | Ethernet ethernetPacketAck = |
| 659 | processDhcpPacketFromServer(context, packet); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 660 | if (ethernetPacketAck != null) { |
| 661 | sendReply(ethernetPacketAck, dhcpPayload); |
| 662 | } |
| 663 | break; |
| 664 | default: |
| 665 | break; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 666 | } |
| 667 | } |
| 668 | |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 669 | private Ethernet processDhcpPacketFromClient(PacketContext context, |
| 670 | Ethernet ethernetPacket) { |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 671 | if (log.isTraceEnabled()) { |
| 672 | log.trace("DHCP packet received from client at {} {}", |
| 673 | context.inPacket().receivedFrom(), ethernetPacket); |
| 674 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 675 | |
| 676 | MacAddress relayAgentMac = relayAgentMacAddress(context); |
| 677 | if (relayAgentMac == null) { |
| 678 | log.warn("RelayAgent MAC not found "); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 679 | return null; |
| 680 | } |
| 681 | |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 682 | Ethernet etherReply = ethernetPacket; |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 683 | |
| 684 | IPv4 ipv4Packet = (IPv4) etherReply.getPayload(); |
| 685 | UDP udpPacket = (UDP) ipv4Packet.getPayload(); |
| 686 | DHCP dhcpPacket = (DHCP) udpPacket.getPayload(); |
| 687 | |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 688 | if (enableDhcpBroadcastReplies) { |
| 689 | // We want the reply to come back as a L2 broadcast |
| 690 | dhcpPacket.setFlags((short) 0x8000); |
| 691 | } |
| 692 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 693 | MacAddress clientMac = MacAddress.valueOf(dhcpPacket.getClientHardwareAddress()); |
| 694 | IpAddress clientIp = IpAddress.valueOf(dhcpPacket.getClientIPAddress()); |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 695 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 696 | SubscriberAndDeviceInformation entry = getSubscriber(context); |
| 697 | if (entry == null) { |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 698 | log.warn("Dropping packet as subscriber entry is not available"); |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 699 | return null; |
| 700 | } |
| 701 | |
| 702 | DhcpAllocationInfo info = new DhcpAllocationInfo( |
| 703 | context.inPacket().receivedFrom(), dhcpPacket.getPacketType(), |
| 704 | entry.nasPortId(), clientMac, clientIp); |
| 705 | |
| 706 | allocationMap.put(entry.nasPortId(), info); |
| 707 | |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 708 | post(new DhcpL2RelayEvent(DhcpL2RelayEvent.Type.UPDATED, info, |
| 709 | context.inPacket().receivedFrom())); |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 710 | |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 711 | if (option82) { |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 712 | DHCP dhcpPacketWithOption82 = addOption82(dhcpPacket, entry); |
| 713 | udpPacket.setPayload(dhcpPacketWithOption82); |
| 714 | } |
| 715 | |
| 716 | ipv4Packet.setPayload(udpPacket); |
| 717 | etherReply.setPayload(ipv4Packet); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 718 | if (modifyClientPktsSrcDstMac) { |
| 719 | etherReply.setSourceMACAddress(relayAgentMac); |
| 720 | etherReply.setDestinationMACAddress(dhcpConnectMac); |
| 721 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 722 | |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 723 | etherReply.setPriorityCode(ethernetPacket.getPriorityCode()); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 724 | etherReply.setVlanID(cTag(context).toShort()); |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 725 | etherReply.setQinQTPID(Ethernet.TYPE_VLAN); |
| 726 | etherReply.setQinQVID(sTag(context).toShort()); |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 727 | log.info("Finished processing packet.. relaying to dhcpServer"); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 728 | return etherReply; |
| 729 | } |
| 730 | |
| 731 | //build the DHCP offer/ack with proper client port. |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 732 | private Ethernet processDhcpPacketFromServer(PacketContext context, |
| 733 | Ethernet ethernetPacket) { |
| 734 | if (log.isTraceEnabled()) { |
| 735 | log.trace("DHCP packet received from server at {} {}", |
| 736 | context.inPacket().receivedFrom(), ethernetPacket); |
| 737 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 738 | // get dhcp header. |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 739 | Ethernet etherReply = (Ethernet) ethernetPacket.clone(); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 740 | IPv4 ipv4Packet = (IPv4) etherReply.getPayload(); |
| 741 | UDP udpPacket = (UDP) ipv4Packet.getPayload(); |
| 742 | DHCP dhcpPayload = (DHCP) udpPacket.getPayload(); |
| 743 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 744 | MacAddress dstMac = valueOf(dhcpPayload.getClientHardwareAddress()); |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 745 | ConnectPoint subsCp = getConnectPointOfClient(dstMac); |
Amit Ghosh | 2095dc6 | 2017-09-25 20:56:55 +0100 | [diff] [blame] | 746 | // If we can't find the subscriber, can't process further |
| 747 | if (subsCp == null) { |
| 748 | return null; |
| 749 | } |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 750 | // if it's an ACK packet store the information for display purpose |
| 751 | if (getDhcpPacketType(dhcpPayload) == DHCPPacketType.DHCPACK) { |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 752 | |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 753 | String portId = nasPortId(subsCp); |
| 754 | SubscriberAndDeviceInformation sub = subsService.get(portId); |
| 755 | if (sub != null) { |
Jonathan Hart | edbf642 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 756 | List<DhcpOption> options = dhcpPayload.getOptions(); |
| 757 | List<DhcpOption> circuitIds = options.stream() |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 758 | .filter(option -> option.getCode() == DHCP.DHCPOptionCode.OptionCode_CircuitID.getValue()) |
| 759 | .collect(Collectors.toList()); |
| 760 | |
| 761 | String circuitId = "None"; |
| 762 | if (circuitIds.size() == 1) { |
Amit Ghosh | 2095dc6 | 2017-09-25 20:56:55 +0100 | [diff] [blame] | 763 | byte[] array = circuitIds.get(0).getData(); |
| 764 | |
| 765 | try { |
| 766 | // we leave the first two bytes as they are the id and length |
| 767 | circuitId = new String(Arrays.copyOfRange(array, 2, array.length), "UTF-8"); |
| 768 | } catch (Exception e) { } |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | IpAddress ip = IpAddress.valueOf(dhcpPayload.getYourIPAddress()); |
| 772 | |
| 773 | //storeDHCPAllocationInfo |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 774 | DhcpAllocationInfo info = new DhcpAllocationInfo(subsCp, |
| 775 | dhcpPayload.getPacketType(), circuitId, dstMac, ip); |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 776 | |
| 777 | allocationMap.put(sub.nasPortId(), info); |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 778 | |
| 779 | post(new DhcpL2RelayEvent(DhcpL2RelayEvent.Type.UPDATED, info, subsCp)); |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 780 | } |
| 781 | } // end storing of info |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 782 | |
| 783 | // we leave the srcMac from the original packet |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 784 | etherReply.setDestinationMACAddress(dstMac); |
| 785 | etherReply.setQinQVID(sTag(subsCp).toShort()); |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 786 | etherReply.setPriorityCode(ethernetPacket.getPriorityCode()); |
| 787 | etherReply.setVlanID((cTag(subsCp).toShort())); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 788 | |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 789 | if (option82) { |
| 790 | udpPacket.setPayload(removeOption82(dhcpPayload)); |
| 791 | } else { |
| 792 | udpPacket.setPayload(dhcpPayload); |
| 793 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 794 | ipv4Packet.setPayload(udpPacket); |
| 795 | etherReply.setPayload(ipv4Packet); |
| 796 | |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 797 | log.info("Finished processing packet.. relaying to client"); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 798 | return etherReply; |
| 799 | } |
| 800 | |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 801 | /* |
| 802 | * Get ConnectPoint of the Client based on it's MAC address |
| 803 | */ |
| 804 | private ConnectPoint getConnectPointOfClient(MacAddress dstMac) { |
| 805 | Set<Host> hosts = hostService.getHostsByMac(dstMac); |
| 806 | if (hosts == null || hosts.isEmpty()) { |
| 807 | log.warn("Cannot determine host for DHCP client: {}. Aborting " |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 808 | + "relay for dhcp packet from server", |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 809 | dstMac); |
| 810 | return null; |
| 811 | } |
| 812 | for (Host h : hosts) { |
| 813 | // if more than one, |
| 814 | // find the connect point which has an valid entry in SADIS |
| 815 | ConnectPoint cp = new ConnectPoint(h.location().deviceId(), |
| 816 | h.location().port()); |
| 817 | |
| 818 | if (sTag(cp) != VlanId.NONE) { |
| 819 | return cp; |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | return null; |
| 824 | } |
| 825 | |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 826 | //send the response to the requester host. |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 827 | private void sendReply(Ethernet ethPacket, DHCP dhcpPayload) { |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 828 | MacAddress descMac = valueOf(dhcpPayload.getClientHardwareAddress()); |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 829 | ConnectPoint subCp = getConnectPointOfClient(descMac); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 830 | |
| 831 | // Send packet out to requester if the host information is available |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 832 | if (subCp != null) { |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 833 | log.info("Sending DHCP packet to client at {}", subCp); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 834 | TrafficTreatment t = DefaultTrafficTreatment.builder() |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 835 | .setOutput(subCp.port()).build(); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 836 | OutboundPacket o = new DefaultOutboundPacket( |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 837 | subCp.deviceId(), t, ByteBuffer.wrap(ethPacket.serialize())); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 838 | if (log.isTraceEnabled()) { |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 839 | log.trace("Relaying packet to dhcp client at {} {}", subCp, |
| 840 | ethPacket); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 841 | } |
| 842 | packetService.emit(o); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 843 | } else { |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 844 | log.error("Dropping DHCP packet because can't find host for {}", descMac); |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 845 | } |
| 846 | } |
| 847 | } |
| 848 | |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 849 | private DHCP addOption82(DHCP dhcpPacket, SubscriberAndDeviceInformation entry) { |
| 850 | log.debug("option82data {} ", entry); |
| 851 | |
Jonathan Hart | edbf642 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 852 | List<DhcpOption> options = Lists.newArrayList(dhcpPacket.getOptions()); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 853 | DhcpOption82 option82 = new DhcpOption82(); |
| 854 | option82.setAgentCircuitId(entry.circuitId()); |
| 855 | option82.setAgentRemoteId(entry.remoteId()); |
Jonathan Hart | edbf642 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 856 | DhcpOption option = new DhcpOption() |
Deepa Vaddireddy | 5f278d6 | 2017-08-30 05:59:39 +0530 | [diff] [blame] | 857 | .setCode(DHCP.DHCPOptionCode.OptionCode_CircuitID.getValue()) |
| 858 | .setData(option82.toByteArray()) |
| 859 | .setLength(option82.length()); |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 860 | |
| 861 | options.add(options.size() - 1, option); |
| 862 | dhcpPacket.setOptions(options); |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 863 | |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 864 | return dhcpPacket; |
| 865 | |
| 866 | } |
| 867 | |
| 868 | private DHCP removeOption82(DHCP dhcpPacket) { |
Jonathan Hart | edbf642 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 869 | List<DhcpOption> options = dhcpPacket.getOptions(); |
| 870 | List<DhcpOption> newoptions = options.stream() |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 871 | .filter(option -> option.getCode() != DHCP.DHCPOptionCode.OptionCode_CircuitID.getValue()) |
| 872 | .collect(Collectors.toList()); |
| 873 | |
| 874 | return dhcpPacket.setOptions(newoptions); |
| 875 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 876 | /** |
| 877 | * Listener for network config events. |
| 878 | */ |
| 879 | private class InternalConfigListener implements NetworkConfigListener { |
| 880 | |
| 881 | @Override |
| 882 | public void event(NetworkConfigEvent event) { |
| 883 | |
| 884 | if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED || |
| 885 | event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) && |
| 886 | event.configClass().equals(DhcpL2RelayConfig.class)) { |
| 887 | updateConfig(); |
| 888 | log.info("Reconfigured"); |
| 889 | } |
| 890 | } |
| 891 | } |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 892 | |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 893 | /** |
| 894 | * Handles Mastership changes for the devices which connect |
| 895 | * to the DHCP server. |
| 896 | */ |
| 897 | private class InnerMastershipListener implements MastershipListener { |
| 898 | @Override |
| 899 | public void event(MastershipEvent event) { |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 900 | if (!useOltUplink) { |
| 901 | if (dhcpServerConnectPoint.get() != null && |
| 902 | dhcpServerConnectPoint.get().deviceId(). |
| 903 | equals(event.subject())) { |
| 904 | log.trace("Mastership Event recevived for {}", event.subject()); |
| 905 | // mastership of the device for our connect point has changed |
| 906 | // reselect |
| 907 | selectServerConnectPoint(); |
| 908 | } |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 909 | } |
| 910 | } |
| 911 | } |
Deepa vaddireddy | 0060f53 | 2017-08-04 06:46:05 +0000 | [diff] [blame] | 912 | |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 913 | /** |
| 914 | * Handles Device status change for the devices which connect |
| 915 | * to the DHCP server. |
| 916 | */ |
| 917 | private class InnerDeviceListener implements DeviceListener { |
| 918 | @Override |
| 919 | public void event(DeviceEvent event) { |
Saurav Das | 15626a0 | 2018-09-27 18:36:45 -0700 | [diff] [blame] | 920 | if (log.isTraceEnabled() && |
| 921 | !event.type().equals(DeviceEvent.Type.PORT_STATS_UPDATED)) { |
| 922 | log.trace("Device Event received for {} event {}", |
| 923 | event.subject(), event.type()); |
| 924 | } |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 925 | if (!useOltUplink) { |
| 926 | if (dhcpServerConnectPoint.get() == null) { |
| 927 | switch (event.type()) { |
| 928 | case DEVICE_ADDED: |
| 929 | case DEVICE_AVAILABILITY_CHANGED: |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 930 | // some device is available check if we can get a |
| 931 | // connect point we can use |
| 932 | addOrRemoveDhcpTrapFromServer(true); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 933 | break; |
| 934 | default: |
| 935 | break; |
| 936 | } |
| 937 | return; |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 938 | } |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 939 | if (dhcpServerConnectPoint.get().deviceId(). |
| 940 | equals(event.subject().id())) { |
| 941 | switch (event.type()) { |
| 942 | case DEVICE_AVAILABILITY_CHANGED: |
| 943 | case DEVICE_REMOVED: |
| 944 | case DEVICE_SUSPENDED: |
| 945 | // state of our device has changed, check if we need |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 946 | // to re-select a connectpoint |
| 947 | addOrRemoveDhcpTrapFromServer(true); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 948 | break; |
| 949 | default: |
| 950 | break; |
| 951 | } |
| 952 | } |
| 953 | } else { |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 954 | switch (event.type()) { |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 955 | case PORT_ADDED: |
Saurav Das | b4e3e10 | 2018-10-02 15:31:17 -0700 | [diff] [blame] | 956 | if (useOltUplink && isUplinkPortOfOlt(event.subject().id(), event.port())) { |
Saurav Das | b14f08a | 2019-02-22 16:34:15 -0800 | [diff] [blame^] | 957 | requestDhcpPacketsFromConnectPoint( |
| 958 | new ConnectPoint(event.subject().id(), event.port().number()), |
| 959 | null); |
Amit Ghosh | 83c8c89 | 2017-11-09 11:08:27 +0000 | [diff] [blame] | 960 | } |
Amit Ghosh | 8951f04 | 2017-08-10 13:48:10 +0100 | [diff] [blame] | 961 | break; |
| 962 | default: |
| 963 | break; |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | } |
Amit Ghosh | 47243cb | 2017-07-26 05:08:53 +0100 | [diff] [blame] | 968 | } |