blob: cc815da73e548b5166183e2b47983a60de1f1fd5 [file] [log] [blame]
Pier Ventre735b8c82016-12-02 08:16:05 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Pier Ventre735b8c82016-12-02 08:16:05 -08003 *
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
Ray Milkeyb65d7842017-08-03 16:28:24 -070019import org.onosproject.net.neighbour.NeighbourMessageContext;
20import org.onosproject.net.neighbour.NeighbourMessageHandler;
Pier Ventre735b8c82016-12-02 08:16:05 -080021import 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) {
Saurav Das76ae6812017-03-15 15:15:14 -070045 log.trace("Received a {} packet {}", context.protocol(), context.packet());
Pier Ventre735b8c82016-12-02 08:16:05 -080046 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}