blob: 4d90ada8fad00dedcfe17dc23f9074b4c04ab239 [file] [log] [blame]
Harshada Chaundkardcd1b142019-03-25 17:27:44 -04001/*
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 */
16package org.onosproject.net.packet.packetfilter;
17
18import org.onlab.packet.Ethernet;
19import org.onlab.packet.ICMP6;
20import org.onlab.packet.IPv6;
21import org.onosproject.net.packet.PacketContext;
22import org.onosproject.net.packet.PacketInClassifier;
23
24public class NSPacketClassifier implements PacketInClassifier {
25
26 @Override
27 public boolean match(PacketContext packet) {
28
29 Ethernet eth = packet.inPacket().parsed();
30
31 if (eth.getEtherType() == Ethernet.TYPE_IPV6) {
32 IPv6 ipv6Packet = (IPv6) eth.getPayload();
33 if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_ICMP6) {
34 ICMP6 icmp6 = (ICMP6) ipv6Packet.getPayload();
35 if (icmp6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) {
36 return true;
37 }
38 }
39 }
40 return false;
41 }
42}