blob: 27533ec2bac061b90c666d694c562df18a7e9b33 [file] [log] [blame]
Jian Lic4b4b582016-12-21 02:49:32 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Jian Lic4b4b582016-12-21 02:49:32 +09003 *
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.provider.lisp.message.impl;
17
Ray Milkeyd84f89b2018-08-17 14:54:17 -070018import org.osgi.service.component.annotations.Activate;
19import org.osgi.service.component.annotations.Component;
20import org.osgi.service.component.annotations.Deactivate;
21import org.osgi.service.component.annotations.Reference;
22import org.osgi.service.component.annotations.ReferenceCardinality;
Jian Lic4b4b582016-12-21 02:49:32 +090023import org.onlab.metrics.MetricsService;
24import org.onosproject.lisp.ctl.LispController;
25import org.onosproject.lisp.ctl.LispMessageListener;
26import org.onosproject.lisp.ctl.LispRouterId;
27import org.onosproject.lisp.ctl.LispRouterListener;
28import org.onosproject.lisp.msg.protocols.LispMessage;
29import org.onosproject.net.provider.AbstractProvider;
30import org.onosproject.net.provider.ProviderId;
31import org.slf4j.Logger;
32import org.slf4j.LoggerFactory;
33
34/**
35 * Provider which uses an LISP controller to detect device.
36 */
37@Component(immediate = true)
38public class LispMessageProvider extends AbstractProvider {
39
40 private static final Logger log = LoggerFactory.getLogger(LispMessageProvider.class);
41
Ray Milkeyd84f89b2018-08-17 14:54:17 -070042 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Jian Lic4b4b582016-12-21 02:49:32 +090043 protected LispController controller;
44
Ray Milkeyd84f89b2018-08-17 14:54:17 -070045 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Jian Lic4b4b582016-12-21 02:49:32 +090046 protected MetricsService metricsService;
47
48 private static final String SCHEME_NAME = "lisp";
49 private static final String MESSAGE_PROVIDER_PACKAGE =
50 "org.onosproject.lisp.provider.message";
51
52 private final InternalDeviceProvider routerListener = new InternalDeviceProvider();
53
54 private final InternalControlMessageListener messageListener =
55 new InternalControlMessageListener();
56
57 /**
58 * Creates a LISP device provider with the supplier identifier.
59 */
60 public LispMessageProvider() {
61 super(new ProviderId(SCHEME_NAME, MESSAGE_PROVIDER_PACKAGE));
62 }
63
64 @Activate
65 public void activate() {
66
67 // listens all LISP router related events
68 controller.addRouterListener(routerListener);
69
70 // listens all LISP control messages
71 controller.addMessageListener(messageListener);
72
73 attachRouters();
74
75 log.info("Started");
76 }
77
78 @Deactivate
79 public void deactivate() {
80
81 detachRouters();
82
83 // stops listening all LISP router related events
84 controller.removeRouterListener(routerListener);
85
86 // stops listening all LISP control messages
87 controller.removeMessageListener(messageListener);
88
89 log.info("Stopped");
90 }
91
92 /**
93 * Attaches all discovered LISP router to listen the router events.
94 */
95 private void attachRouters() {
96
97 }
98
99 /**
100 * Detaches all LISP routers from listener.
101 */
102 private void detachRouters() {
103
104 }
105
106 /**
107 * A routerListener for LISP router agent.
108 */
109 private class InternalDeviceProvider implements LispRouterListener {
110
111 @Override
112 public void routerAdded(LispRouterId routerId) {
113 }
114
115 @Override
116 public void routerRemoved(LispRouterId routerId) {
117 }
118
119 @Override
120 public void routerChanged(LispRouterId routerId) {
121 }
122 }
123
124 /**
125 * A routerListener for all LISP control messages.
126 */
127 private class InternalControlMessageListener implements LispMessageListener {
128
129 @Override
130 public void handleIncomingMessage(LispRouterId routerId, LispMessage msg) {
131 }
132
133 @Override
134 public void handleOutgoingMessage(LispRouterId routerId, LispMessage msg) {
135 }
136 }
137}