blob: f170fae2b8612b6dc3fc46dbfaec445e02143bd6 [file] [log] [blame]
Pier Ventreb6b81d52016-12-02 08:16:05 -08001/*
Brian O'Connor0947d7e2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Pier Ventreb6b81d52016-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 Milkey2a31aeb2017-08-03 16:28:24 -070019import org.onosproject.net.neighbour.NeighbourMessageContext;
20import org.onosproject.net.neighbour.NeighbourMessageHandler;
Pier Ventreb6b81d52016-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 Dase6c448a2018-01-18 12:07:33 -080045 log.trace("Received {} packet on {}: {}", context.protocol(),
46 context.inPort(), context.packet());
Pier Ventreb6b81d52016-12-02 08:16:05 -080047 switch (context.protocol()) {
48 case ARP:
49 if (this.manager.arpHandler != null) {
50 this.manager.arpHandler.processPacketIn(context, hostService);
51 }
52 break;
53 case NDP:
54 if (this.manager.icmpHandler != null) {
55 this.manager.icmpHandler.processPacketIn(context, hostService);
56 }
57 break;
58 default:
59 log.warn("Unknown protocol", context.protocol());
60 }
61 }
62
63
64}