blob: 7c6d0163cc885b715427e1239b7f829231709c66 [file] [log] [blame]
Jian Li7d361572017-01-13 11:39:37 +09001/*
2 * Copyright 2017-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 */
16package org.onosproject.provider.lisp.mapping.impl;
17
18import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
21import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
23import org.onosproject.lisp.ctl.LispController;
24import org.onosproject.lisp.ctl.LispMessageListener;
25import org.onosproject.lisp.ctl.LispRouterId;
26import org.onosproject.lisp.ctl.LispRouterListener;
27import org.onosproject.lisp.msg.protocols.LispMessage;
28import org.onosproject.net.provider.AbstractProvider;
29import org.onosproject.net.provider.ProviderId;
30import org.slf4j.Logger;
31import org.slf4j.LoggerFactory;
32
33/**
34 * Provider which uses a LISP controller to manage EID-RLOC mapping.
35 */
36@Component(immediate = true)
37public class LispMappingProvider extends AbstractProvider {
38
39 private static final Logger log = LoggerFactory.getLogger(LispMappingProvider.class);
40
41 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
42 protected LispController controller;
43
44 private static final String SCHEME_NAME = "lisp";
45 private static final String MAPPING_PROVIDER_PACKAGE =
46 "org.onosproject.lisp.provider.mapping";
47
48 private final InternalMappingProvider listener = new InternalMappingProvider();
49
50 /**
51 * Creates a LISP mapping provider with the supplier identifier.
52 */
53 public LispMappingProvider() {
54 super(new ProviderId(SCHEME_NAME, MAPPING_PROVIDER_PACKAGE));
55 }
56
57 @Activate
58 public void activate() {
59
60 // listens all LISP router related events
61 controller.addRouterListener(listener);
62
63 // listens all LISP control message
64 controller.addMessageListener(listener);
65
66 log.info("Started");
67 }
68
69 @Deactivate
70 public void deactivate() {
71
72 // stops listening all LISP router related events
73 controller.removeRouterListener(listener);
74
75 // stops listening all LISP control messages
76 controller.removeMessageListener(listener);
77
78 log.info("Stopped");
79 }
80
81 /**
82 * A listener for LISP router events and control messages.
83 */
84 private class InternalMappingProvider implements LispRouterListener,
85 LispMessageListener {
86
87 @Override
88 public void routerAdded(LispRouterId routerId) {
89
90 }
91
92 @Override
93 public void routerRemoved(LispRouterId routerId) {
94
95 }
96
97 @Override
98 public void routerChanged(LispRouterId routerId) {
99
100 }
101
102 @Override
103 public void handleIncomingMessage(LispRouterId routerId, LispMessage msg) {
104
105 }
106
107 @Override
108 public void handleOutgoingMessage(LispRouterId routerId, LispMessage msg) {
109
110 }
111 }
112}