blob: 92a4371ed65cf3b575cdcfa6f2fc09022f01cefb [file] [log] [blame]
Pier Ventre10bd8d12016-11-26 21:05:22 -08001/*
2 * Copyright 2016-present Open Networking Laboratory
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
17package org.onosproject.segmentrouting;
18
19import org.onosproject.incubator.net.neighbour.NeighbourMessageContext;
20import org.onosproject.incubator.net.neighbour.NeighbourMessageHandler;
21import org.onosproject.net.host.HostService;
22import org.slf4j.Logger;
23import org.slf4j.LoggerFactory;
24
25/**
26 * This handler deals with the ICMPv6 Echo protocol
27 * and ICMPv6 ND protocol.
28 */
29public class SegmentRoutingNeighbourHandler implements NeighbourMessageHandler {
30
31 private static Logger log = LoggerFactory.getLogger(SegmentRoutingNeighbourHandler.class);
32 private SegmentRoutingManager manager;
33
34 /**
35 * Create a segment routing neighbour handler.
36 *
37 * @param segmentRoutingManager the segment routing manager
38 */
39 public SegmentRoutingNeighbourHandler(SegmentRoutingManager segmentRoutingManager) {
40 this.manager = segmentRoutingManager;
41 }
42
43 /*
44 * We use this method to handle the NDP messages
45 */
46 @Override
47 public void handleMessage(NeighbourMessageContext context, HostService hostService) {
48 log.debug("Received a {} packet {}", context.protocol(), context.packet());
49 switch (context.protocol()) {
50 case ARP:
51 if (this.manager.arpHandler != null) {
52 this.manager.arpHandler.processPacketIn(context, hostService);
53 }
54 break;
55 case NDP:
56 if (this.manager.icmpHandler != null) {
57 this.manager.icmpHandler.processPacketIn(context);
58 }
59 break;
60 default:
61 log.warn("Unknown protocol", context.protocol());
62 }
63 }
64
65
66}