David K. Bainbridge | d77028f | 2017-08-01 12:47:55 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 4d08470 | 2017-08-03 22:45:58 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
David K. Bainbridge | d77028f | 2017-08-01 12:47:55 -0700 | [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 | */ |
developer | e400c58 | 2020-03-24 19:42:08 +0100 | [diff] [blame] | 16 | package org.opencord.igmpproxy.impl; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 17 | |
| 18 | import org.onlab.packet.Ethernet; |
| 19 | import org.onlab.packet.IGMP; |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 20 | import org.onlab.packet.IGMP.IGMPv2; |
| 21 | import org.onlab.packet.IGMP.IGMPv3; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 22 | import org.onlab.packet.IGMPMembership; |
| 23 | import org.onlab.packet.IGMPQuery; |
| 24 | import org.onlab.packet.IPv4; |
| 25 | import org.onlab.packet.Ip4Address; |
| 26 | import org.onlab.packet.MacAddress; |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 27 | import org.onlab.packet.VlanId; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 28 | import org.onosproject.net.DeviceId; |
| 29 | import org.onosproject.net.PortNumber; |
| 30 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 31 | import org.onosproject.net.flow.TrafficTreatment; |
| 32 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 33 | import org.onosproject.net.packet.OutboundPacket; |
| 34 | import org.onosproject.net.packet.PacketService; |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 35 | import org.opencord.igmpproxy.IgmpLeadershipService; |
developer | e400c58 | 2020-03-24 19:42:08 +0100 | [diff] [blame] | 36 | import org.opencord.igmpproxy.IgmpStatisticsService; |
Deepa Vaddireddy | ca7b25d | 2017-09-28 13:47:18 +0000 | [diff] [blame] | 37 | import org.slf4j.Logger; |
| 38 | import org.slf4j.LoggerFactory; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 39 | |
| 40 | import java.nio.ByteBuffer; |
| 41 | |
| 42 | /** |
| 43 | * Message encode and send interface for igmpproxy. |
| 44 | */ |
| 45 | public final class IgmpSender { |
| 46 | static final String V3_REPORT_ADDRESS = "224.0.0.22"; |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 47 | static final String V2_LEAVE_DST = "224.0.0.2"; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 48 | static final String MAC_ADDRESS = "DE:AD:BE:EF:BA:11"; |
| 49 | static final short DEFAULT_MVLAN = 4000; |
| 50 | static final byte DEFAULT_COS = 7; |
| 51 | static final int DEFAULT_MEX_RESP = 10; |
| 52 | static final byte[] RA_BYTES = {(byte) 0x94, (byte) 0x04, (byte) 0x00, (byte) 0x00}; |
| 53 | |
| 54 | private static IgmpSender instance = null; |
| 55 | private PacketService packetService; |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 56 | private IgmpLeadershipService igmpLeadershipService; |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 57 | private IgmpStatisticsService igmpStatisticsService; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 58 | private boolean withRAUplink = true; |
| 59 | private boolean withRADownlink = false; |
| 60 | private short mvlan = DEFAULT_MVLAN; |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 61 | private short mvlanInner = VlanId.NONE.toShort(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 62 | private byte igmpCos = DEFAULT_COS; |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 63 | private byte igmpUniCos = DEFAULT_COS; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 64 | private int maxResp = DEFAULT_MEX_RESP; |
Deepa Vaddireddy | ca7b25d | 2017-09-28 13:47:18 +0000 | [diff] [blame] | 65 | private Logger log = LoggerFactory.getLogger(getClass()); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 66 | |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 67 | private IgmpSender(PacketService packetService, IgmpLeadershipService igmpLeadershipService, |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 68 | IgmpStatisticsService igmpStatisticsService) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 69 | this.packetService = packetService; |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 70 | this.igmpLeadershipService = igmpLeadershipService; |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 71 | this.igmpStatisticsService = igmpStatisticsService; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 72 | } |
| 73 | |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 74 | public static void init(PacketService packetService, IgmpLeadershipService igmpLeadershipService, |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 75 | IgmpStatisticsService igmpStatisticsService) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 76 | instance = new IgmpSender(packetService, igmpLeadershipService, igmpStatisticsService); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | public static IgmpSender getInstance() { |
| 80 | return instance; |
| 81 | } |
| 82 | |
| 83 | public void setWithRAUplink(boolean withRaUplink) { |
| 84 | this.withRAUplink = withRaUplink; |
| 85 | } |
| 86 | |
| 87 | public void setWithRADownlink(boolean withRADownlink) { |
| 88 | this.withRADownlink = withRADownlink; |
| 89 | } |
| 90 | |
| 91 | public void setMvlan(short mvlan) { |
| 92 | this.mvlan = mvlan; |
| 93 | } |
| 94 | |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 95 | public void setMvlanInner(short mvlanInner) { |
| 96 | this.mvlanInner = mvlanInner; |
| 97 | } |
| 98 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 99 | public void setIgmpCos(byte igmpCos) { |
| 100 | this.igmpCos = igmpCos; |
| 101 | } |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 102 | public void setIgmpUniCos(byte igmpUniCos) { |
| 103 | this.igmpUniCos = igmpUniCos; |
| 104 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 105 | |
| 106 | public void setMaxResp(int maxResp) { |
| 107 | this.maxResp = maxResp; |
| 108 | } |
| 109 | |
| 110 | public Ethernet buildIgmpV3Join(Ip4Address groupIp, Ip4Address sourceIp) { |
| 111 | IGMPMembership igmpMembership = new IGMPMembership(groupIp); |
| 112 | igmpMembership.setRecordType(IGMPMembership.CHANGE_TO_EXCLUDE_MODE); |
| 113 | |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 114 | return buildIgmpPacket(IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT, groupIp, igmpMembership, |
| 115 | sourceIp, false, mvlan, mvlanInner, igmpCos); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 116 | } |
| 117 | |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 118 | public Ethernet buildIgmpV2Join(Ip4Address groupIp, Ip4Address sourceIp) { |
| 119 | IGMPMembership igmpMembership = new IGMPMembership(groupIp); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 120 | return buildIgmpPacket(IGMP.TYPE_IGMPV2_MEMBERSHIP_REPORT, groupIp, igmpMembership, |
| 121 | sourceIp, true, mvlan, mvlanInner, igmpCos); |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | public Ethernet buildIgmpV2ResponseQuery(Ip4Address groupIp, Ip4Address sourceIp) { |
| 125 | return buildIgmpV2Join(groupIp, sourceIp); |
| 126 | } |
| 127 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 128 | public Ethernet buildIgmpV3ResponseQuery(Ip4Address groupIp, Ip4Address sourceIp) { |
| 129 | IGMPMembership igmpMembership = new IGMPMembership(groupIp); |
| 130 | igmpMembership.setRecordType(IGMPMembership.MODE_IS_EXCLUDE); |
| 131 | |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 132 | return buildIgmpPacket(IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT, groupIp, igmpMembership, |
| 133 | sourceIp, false, mvlan, mvlanInner, igmpCos); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | public Ethernet buildIgmpV3Leave(Ip4Address groupIp, Ip4Address sourceIp) { |
| 137 | IGMPMembership igmpMembership = new IGMPMembership(groupIp); |
| 138 | igmpMembership.setRecordType(IGMPMembership.CHANGE_TO_INCLUDE_MODE); |
| 139 | |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 140 | return buildIgmpPacket(IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT, groupIp, igmpMembership, |
| 141 | sourceIp, false, mvlan, mvlanInner, igmpCos); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 142 | } |
| 143 | |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 144 | public Ethernet buildIgmpV2Leave(Ip4Address groupIp, Ip4Address sourceIp) { |
| 145 | IGMPMembership igmpMembership = new IGMPMembership(groupIp); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 146 | return buildIgmpPacket(IGMP.TYPE_IGMPV2_LEAVE_GROUP, groupIp, igmpMembership, |
| 147 | sourceIp, true, mvlan, mvlanInner, igmpCos); |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 148 | } |
| 149 | |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 150 | public Ethernet buildIgmpV2Query(Ip4Address groupIp, Ip4Address sourceIp, short vlan) { |
| 151 | return buildIgmpPacket(IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY, groupIp, null, |
| 152 | sourceIp, true, vlan, VlanId.NONE.toShort(), igmpUniCos); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 153 | } |
| 154 | |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 155 | public Ethernet buildIgmpV3Query(Ip4Address groupIp, Ip4Address sourceIp, short vlan) { |
| 156 | return buildIgmpPacket(IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY, groupIp, null, |
| 157 | sourceIp, false, vlan, VlanId.NONE.toShort(), igmpUniCos); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 158 | } |
| 159 | |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 160 | protected Ethernet buildIgmpPacket(byte type, Ip4Address groupIp, IGMPMembership igmpMembership, |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 161 | Ip4Address sourceIp, boolean isV2Query, short vlan, |
| 162 | short innerVlan, byte igmpCos) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 163 | |
| 164 | IGMP igmpPacket; |
| 165 | if (isV2Query) { |
| 166 | igmpPacket = new IGMP.IGMPv2(); |
| 167 | } else { |
| 168 | igmpPacket = new IGMP.IGMPv3(); |
| 169 | } |
| 170 | |
| 171 | IPv4 ip4Packet = new IPv4(); |
| 172 | Ethernet ethPkt = new Ethernet(); |
Esin Karaman | 45d2d6a | 2020-05-04 12:27:55 +0000 | [diff] [blame] | 173 | ethPkt.setPad(true); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 174 | |
| 175 | igmpPacket.setIgmpType(type); |
| 176 | |
| 177 | switch (type) { |
| 178 | case IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY: |
| 179 | igmpPacket.setMaxRespCode((byte) (maxResp * 10)); |
| 180 | IGMPQuery igmpQuery = new IGMPQuery(groupIp, 0); |
| 181 | |
| 182 | igmpPacket.addGroup(igmpQuery); |
| 183 | ip4Packet.setDestinationAddress(groupIp.toInt()); |
| 184 | if (withRADownlink) { |
| 185 | ip4Packet.setOptions(RA_BYTES); |
| 186 | } |
| 187 | break; |
| 188 | |
| 189 | case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: |
| 190 | if (igmpMembership == null) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 191 | log.debug("Igmp membership is not found. igmp-type {} ", type); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 192 | return null; |
| 193 | } |
| 194 | igmpPacket.addGroup(igmpMembership); |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 195 | ip4Packet.setDestinationAddress(Ip4Address.valueOf(V3_REPORT_ADDRESS).toInt()); |
| 196 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 197 | if (withRAUplink) { |
| 198 | ip4Packet.setOptions(RA_BYTES); |
| 199 | } |
| 200 | break; |
| 201 | |
| 202 | case IGMP.TYPE_IGMPV2_MEMBERSHIP_REPORT: |
| 203 | case IGMP.TYPE_IGMPV2_LEAVE_GROUP: |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 204 | if (igmpMembership == null) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 205 | log.debug("Igmp membership is not found. igmp-type {} ", type); |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 206 | return null; |
| 207 | } |
| 208 | igmpPacket.addGroup(igmpMembership); |
| 209 | int dst = (type == IGMP.TYPE_IGMPV2_MEMBERSHIP_REPORT ? |
| 210 | groupIp.toInt() : |
| 211 | Ip4Address.valueOf(V2_LEAVE_DST).toInt()); |
| 212 | ip4Packet.setDestinationAddress(dst); |
| 213 | break; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 214 | default: |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 215 | log.debug("Unknown igmp type: {} ", type); |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 216 | igmpStatisticsService.getIgmpStats().increaseUnknownIgmpTypePacketsRxCounter(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 217 | return null; |
| 218 | } |
| 219 | |
| 220 | igmpPacket.setParent(ip4Packet); |
| 221 | ip4Packet.setSourceAddress(sourceIp.toInt()); |
| 222 | ip4Packet.setProtocol(IPv4.PROTOCOL_IGMP); |
| 223 | ip4Packet.setPayload(igmpPacket); |
| 224 | ip4Packet.setParent(ethPkt); |
| 225 | ip4Packet.setTtl((byte) 0x78); |
| 226 | |
| 227 | ethPkt.setDestinationMACAddress(multiaddToMac(ip4Packet.getDestinationAddress())); |
| 228 | ethPkt.setSourceMACAddress(MAC_ADDRESS); |
| 229 | ethPkt.setEtherType(Ethernet.TYPE_IPV4); |
| 230 | ethPkt.setPayload(ip4Packet); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 231 | ethPkt.setVlanID(vlan); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 232 | ethPkt.setPriorityCode(igmpCos); |
| 233 | |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame^] | 234 | if (innerVlan != VlanId.NONE.toShort()) { |
| 235 | ethPkt.setQinQTPID(Ethernet.TYPE_VLAN); |
| 236 | ethPkt.setQinQVID(vlan); |
| 237 | ethPkt.setVlanID(innerVlan); |
| 238 | ethPkt.setQinQPriorityCode(igmpCos); |
| 239 | } |
| 240 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 241 | return ethPkt; |
| 242 | } |
| 243 | |
| 244 | private MacAddress multiaddToMac(int multiaddress) { |
| 245 | byte[] b = new byte[3]; |
| 246 | b[0] = (byte) (multiaddress & 0xff); |
| 247 | b[1] = (byte) (multiaddress >> 8 & 0xff); |
| 248 | b[2] = (byte) (multiaddress >> 16 & 0x7f); |
| 249 | byte[] macByte = {0x01, 0x00, 0x5e, b[2], b[1], b[0]}; |
| 250 | |
| 251 | MacAddress mac = MacAddress.valueOf(macByte); |
| 252 | return mac; |
| 253 | } |
| 254 | |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 255 | public void sendIgmpPacketUplink(Ethernet ethPkt, DeviceId deviceId, PortNumber upLinkPort) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 256 | if (!igmpLeadershipService.isLocalLeader(deviceId)) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 257 | return; |
| 258 | } |
| 259 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 260 | if (IgmpManager.connectPointMode) { |
Deepa Vaddireddy | ca7b25d | 2017-09-28 13:47:18 +0000 | [diff] [blame] | 261 | if (IgmpManager.connectPoint == null) { |
| 262 | log.warn("cannot find a connectPoint to send the packet uplink"); |
| 263 | return; |
| 264 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 265 | sendIgmpPacket(ethPkt, IgmpManager.connectPoint.deviceId(), IgmpManager.connectPoint.port()); |
| 266 | } else { |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 267 | sendIgmpPacket(ethPkt, deviceId, upLinkPort); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
| 271 | public void sendIgmpPacket(Ethernet ethPkt, DeviceId deviceId, PortNumber portNumber) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 272 | if (!igmpLeadershipService.isLocalLeader(deviceId)) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 273 | return; |
| 274 | } |
| 275 | |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 276 | IPv4 ipv4Pkt = (IPv4) ethPkt.getPayload(); |
| 277 | IGMP igmp = (IGMP) ipv4Pkt.getPayload(); |
| 278 | // We are checking the length of packets. Right now the counter value will be 0 because of internal translation |
| 279 | // As packet length will always be valid |
| 280 | // This counter will be useful in future if we change the procedure to generate the packets. |
| 281 | if ((igmp.getIgmpType() == IGMP.TYPE_IGMPV2_MEMBERSHIP_REPORT |
| 282 | || igmp.getIgmpType() == IGMP.TYPE_IGMPV2_LEAVE_GROUP) && igmp.serialize().length < IGMPv2.HEADER_LENGTH) { |
| 283 | igmpStatisticsService.getIgmpStats().increaseInvalidIgmpLength(); |
| 284 | } else if (igmp.getIgmpType() == IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT |
| 285 | && igmp.serialize().length < IGMPv3.MINIMUM_HEADER_LEN) { |
| 286 | igmpStatisticsService.getIgmpStats().increaseInvalidIgmpLength(); |
| 287 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 288 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() |
| 289 | .setOutput(portNumber).build(); |
| 290 | OutboundPacket packet = new DefaultOutboundPacket(deviceId, |
| 291 | treatment, ByteBuffer.wrap(ethPkt.serialize())); |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 292 | igmpStatisticsService.getIgmpStats().increaseValidIgmpPacketCounter(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 293 | packetService.emit(packet); |
| 294 | |
| 295 | } |
| 296 | } |