blob: 4eaac4ecf8aa0ce697797b9f38f294164ab6e6ce [file] [log] [blame]
Pier Ventreb6b81d52016-12-02 08:16:05 -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 dispatches to the appropriate handlers the
27 * neighbour discovery protocols.
28 */
29public class SegmentRoutingNeighbourDispatcher implements NeighbourMessageHandler {
30
31 private static Logger log = LoggerFactory.getLogger(SegmentRoutingNeighbourDispatcher.class);
32 private SegmentRoutingManager manager;
33
34 /**
35 * Create a segment routing neighbour dispatcher.
36 *
37 * @param segmentRoutingManager the segment routing manager
38 */
39 public SegmentRoutingNeighbourDispatcher(SegmentRoutingManager segmentRoutingManager) {
40 this.manager = segmentRoutingManager;
41 }
42
43 @Override
44 public void handleMessage(NeighbourMessageContext context, HostService hostService) {
45 log.debug("Received a {} packet {}", context.protocol(), context.packet());
46 switch (context.protocol()) {
47 case ARP:
48 if (this.manager.arpHandler != null) {
49 this.manager.arpHandler.processPacketIn(context, hostService);
50 }
51 break;
52 case NDP:
53 if (this.manager.icmpHandler != null) {
54 this.manager.icmpHandler.processPacketIn(context, hostService);
55 }
56 break;
57 default:
58 log.warn("Unknown protocol", context.protocol());
59 }
60 }
61
62
63}