[ONOS-4170] LSP-DB sync
Change-Id: Icda3afd9cca8d1fb8c58b44da6bc26064b300388
Showing
27 changed files
with
561 additions
and
18 deletions
... | @@ -30,6 +30,9 @@ import java.util.concurrent.Executors; | ... | @@ -30,6 +30,9 @@ import java.util.concurrent.Executors; |
30 | import java.util.concurrent.ScheduledExecutorService; | 30 | import java.util.concurrent.ScheduledExecutorService; |
31 | import java.util.concurrent.TimeUnit; | 31 | import java.util.concurrent.TimeUnit; |
32 | 32 | ||
33 | +import org.onlab.packet.Ethernet; | ||
34 | +import org.onlab.packet.IPv4; | ||
35 | + | ||
33 | import org.apache.felix.scr.annotations.Activate; | 36 | import org.apache.felix.scr.annotations.Activate; |
34 | import org.apache.felix.scr.annotations.Component; | 37 | import org.apache.felix.scr.annotations.Component; |
35 | import org.apache.felix.scr.annotations.Deactivate; | 38 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -38,6 +41,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -38,6 +41,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
38 | import org.apache.felix.scr.annotations.Service; | 41 | import org.apache.felix.scr.annotations.Service; |
39 | import org.onlab.packet.IpAddress; | 42 | import org.onlab.packet.IpAddress; |
40 | import org.onlab.packet.IpPrefix; | 43 | import org.onlab.packet.IpPrefix; |
44 | +import org.onlab.packet.TCP; | ||
41 | import org.onlab.util.Bandwidth; | 45 | import org.onlab.util.Bandwidth; |
42 | import org.onosproject.core.ApplicationId; | 46 | import org.onosproject.core.ApplicationId; |
43 | import org.onosproject.core.CoreService; | 47 | import org.onosproject.core.CoreService; |
... | @@ -139,6 +143,7 @@ public class PceManager implements PceService { | ... | @@ -139,6 +143,7 @@ public class PceManager implements PceService { |
139 | private static final String TRUE = "true"; | 143 | private static final String TRUE = "true"; |
140 | private static final String FALSE = "false"; | 144 | private static final String FALSE = "false"; |
141 | private static final String END_OF_SYNC_IP_PREFIX = "0.0.0.0/32"; | 145 | private static final String END_OF_SYNC_IP_PREFIX = "0.0.0.0/32"; |
146 | + public static final int PCEP_PORT = 4189; | ||
142 | 147 | ||
143 | private IdGenerator localLspIdIdGen; | 148 | private IdGenerator localLspIdIdGen; |
144 | protected DistributedSet<Short> localLspIdFreeList; | 149 | protected DistributedSet<Short> localLspIdFreeList; |
... | @@ -635,7 +640,7 @@ public class PceManager implements PceService { | ... | @@ -635,7 +640,7 @@ public class PceManager implements PceService { |
635 | LinkEvent linkEvent = (LinkEvent) e; | 640 | LinkEvent linkEvent = (LinkEvent) e; |
636 | if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) { | 641 | if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) { |
637 | tunnelService.queryTunnel(MPLS).forEach(t -> { | 642 | tunnelService.queryTunnel(MPLS).forEach(t -> { |
638 | - if (t.path().links().contains(((Link) e.subject()))) { | 643 | + if (t.path().links().contains((e.subject()))) { |
639 | // Check whether this ONOS instance is master for ingress device if yes, | 644 | // Check whether this ONOS instance is master for ingress device if yes, |
640 | // recompute and send update | 645 | // recompute and send update |
641 | checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t); | 646 | checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t); |
... | @@ -949,12 +954,30 @@ public class PceManager implements PceService { | ... | @@ -949,12 +954,30 @@ public class PceManager implements PceService { |
949 | public void process(PacketContext context) { | 954 | public void process(PacketContext context) { |
950 | // Stop processing if the packet has been handled, since we | 955 | // Stop processing if the packet has been handled, since we |
951 | // can't do any more to it. | 956 | // can't do any more to it. |
952 | - | ||
953 | if (context.isHandled()) { | 957 | if (context.isHandled()) { |
954 | return; | 958 | return; |
955 | } | 959 | } |
956 | 960 | ||
957 | InboundPacket pkt = context.inPacket(); | 961 | InboundPacket pkt = context.inPacket(); |
962 | + if (pkt == null) { | ||
963 | + return; | ||
964 | + } | ||
965 | + | ||
966 | + Ethernet ethernet = pkt.parsed(); | ||
967 | + if (ethernet == null || ethernet.getEtherType() != Ethernet.TYPE_IPV4) { | ||
968 | + return; | ||
969 | + } | ||
970 | + | ||
971 | + IPv4 ipPacket = (IPv4) ethernet.getPayload(); | ||
972 | + if (ipPacket == null || ipPacket.getProtocol() != IPv4.PROTOCOL_TCP) { | ||
973 | + return; | ||
974 | + } | ||
975 | + | ||
976 | + TCP tcp = (TCP) ipPacket.getPayload(); | ||
977 | + if (tcp == null || tcp.getDestinationPort() != PCEP_PORT) { | ||
978 | + return; | ||
979 | + } | ||
980 | + | ||
958 | syncLabelDb(pkt.receivedFrom().deviceId()); | 981 | syncLabelDb(pkt.receivedFrom().deviceId()); |
959 | } | 982 | } |
960 | } | 983 | } | ... | ... |
... | @@ -26,7 +26,6 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; | ... | @@ -26,7 +26,6 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; |
26 | import static org.onosproject.net.MastershipRole.MASTER; | 26 | import static org.onosproject.net.MastershipRole.MASTER; |
27 | 27 | ||
28 | import java.net.URISyntaxException; | 28 | import java.net.URISyntaxException; |
29 | -import java.nio.ByteBuffer; | ||
30 | import java.util.Collection; | 29 | import java.util.Collection; |
31 | import java.util.Collections; | 30 | import java.util.Collections; |
32 | import java.util.HashMap; | 31 | import java.util.HashMap; |
... | @@ -44,6 +43,7 @@ import org.onlab.junit.TestUtils; | ... | @@ -44,6 +43,7 @@ import org.onlab.junit.TestUtils; |
44 | import org.onlab.junit.TestUtils.TestUtilsException; | 43 | import org.onlab.junit.TestUtils.TestUtilsException; |
45 | import org.onlab.packet.Ethernet; | 44 | import org.onlab.packet.Ethernet; |
46 | import org.onlab.packet.IPv4; | 45 | import org.onlab.packet.IPv4; |
46 | +import org.onlab.packet.TCP; | ||
47 | import org.onlab.util.Bandwidth; | 47 | import org.onlab.util.Bandwidth; |
48 | import org.onosproject.common.DefaultTopologyGraph; | 48 | import org.onosproject.common.DefaultTopologyGraph; |
49 | import org.onosproject.core.ApplicationId; | 49 | import org.onosproject.core.ApplicationId; |
... | @@ -112,6 +112,7 @@ import org.onosproject.pce.util.FlowObjServiceAdapter; | ... | @@ -112,6 +112,7 @@ import org.onosproject.pce.util.FlowObjServiceAdapter; |
112 | import org.onosproject.store.service.TestStorageService; | 112 | import org.onosproject.store.service.TestStorageService; |
113 | 113 | ||
114 | import com.google.common.collect.ImmutableSet; | 114 | import com.google.common.collect.ImmutableSet; |
115 | +import static org.onosproject.pce.pceservice.PceManager.PCEP_PORT; | ||
115 | 116 | ||
116 | /** | 117 | /** |
117 | * Tests the functions of PceManager. | 118 | * Tests the functions of PceManager. |
... | @@ -675,21 +676,18 @@ public class PceManagerTest { | ... | @@ -675,21 +676,18 @@ public class PceManagerTest { |
675 | * Tests packet in to trigger label DB sync. | 676 | * Tests packet in to trigger label DB sync. |
676 | */ | 677 | */ |
677 | @Test | 678 | @Test |
678 | - public void packetProcessingTest() throws URISyntaxException { | 679 | + public void packetProcessingTest1() throws URISyntaxException { |
679 | 680 | ||
680 | build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc. | 681 | build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc. |
681 | 682 | ||
682 | - final int srcHost = 2; | ||
683 | - final int dstHost = 5; | ||
684 | - | ||
685 | LabelResourceId node1Label = LabelResourceId.labelResourceId(5200); | 683 | LabelResourceId node1Label = LabelResourceId.labelResourceId(5200); |
686 | LabelResourceId node2Label = LabelResourceId.labelResourceId(5201); | 684 | LabelResourceId node2Label = LabelResourceId.labelResourceId(5201); |
687 | 685 | ||
688 | pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label); | 686 | pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label); |
689 | pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label); | 687 | pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label); |
690 | 688 | ||
691 | - ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(srcHost)); | 689 | + ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1)); |
692 | - ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(dstHost)); | 690 | + ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2)); |
693 | 691 | ||
694 | Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT) | 692 | Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT) |
695 | .providerId(new ProviderId("eth", "1")).build(); | 693 | .providerId(new ProviderId("eth", "1")).build(); |
... | @@ -697,24 +695,66 @@ public class PceManagerTest { | ... | @@ -697,24 +695,66 @@ public class PceManagerTest { |
697 | LabelResourceId link1Label = LabelResourceId.labelResourceId(5204); | 695 | LabelResourceId link1Label = LabelResourceId.labelResourceId(5204); |
698 | pceManager.pceStore.addAdjLabel(link1, link1Label); | 696 | pceManager.pceStore.addAdjLabel(link1, link1Label); |
699 | 697 | ||
700 | - Ethernet eth; | 698 | + TCP tcp = new TCP(); |
701 | - IPv4 ipv4; | 699 | + tcp.setDestinationPort(PCEP_PORT); |
700 | + | ||
701 | + IPv4 ipv4 = new IPv4(); | ||
702 | + ipv4.setProtocol(IPv4.PROTOCOL_TCP); | ||
703 | + ipv4.setPayload(tcp); | ||
702 | 704 | ||
703 | - ipv4 = new IPv4(); | 705 | + Ethernet eth = new Ethernet(); |
704 | - eth = new Ethernet(); | ||
705 | eth.setEtherType(Ethernet.TYPE_IPV4); | 706 | eth.setEtherType(Ethernet.TYPE_IPV4); |
706 | eth.setPayload(ipv4); | 707 | eth.setPayload(ipv4); |
707 | 708 | ||
708 | - eth.setSourceMACAddress("00:00:00:10:00:0" + srcHost).setDestinationMACAddress("00:00:00:10:00:0" + dstHost); | 709 | + InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(), |
709 | - | 710 | + PortNumber.portNumber(PCEP_PORT)), |
710 | - InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(), PortNumber.portNumber(srcHost)), | 711 | + eth, null); |
711 | - eth, ByteBuffer.wrap(eth.serialize())); | ||
712 | 712 | ||
713 | pktProcessor.process(new MockPcepPacketContext(inPkt, null)); | 713 | pktProcessor.process(new MockPcepPacketContext(inPkt, null)); |
714 | assertThat(flowsDownloaded, is(4)); | 714 | assertThat(flowsDownloaded, is(4)); |
715 | } | 715 | } |
716 | 716 | ||
717 | /** | 717 | /** |
718 | + * Tests faulty packet in to trigger label DB sync. | ||
719 | + */ | ||
720 | + @Test | ||
721 | + public void packetProcessingTest2() throws URISyntaxException { | ||
722 | + | ||
723 | + build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc. | ||
724 | + | ||
725 | + LabelResourceId node1Label = LabelResourceId.labelResourceId(5200); | ||
726 | + LabelResourceId node2Label = LabelResourceId.labelResourceId(5201); | ||
727 | + | ||
728 | + pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label); | ||
729 | + pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label); | ||
730 | + | ||
731 | + ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1)); | ||
732 | + ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2)); | ||
733 | + | ||
734 | + Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT) | ||
735 | + .providerId(new ProviderId("eth", "1")).build(); | ||
736 | + | ||
737 | + LabelResourceId link1Label = LabelResourceId.labelResourceId(5204); | ||
738 | + pceManager.pceStore.addAdjLabel(link1, link1Label); | ||
739 | + | ||
740 | + TCP tcp = new TCP(); // Not set the pcep port. | ||
741 | + IPv4 ipv4 = new IPv4(); | ||
742 | + ipv4.setProtocol(IPv4.PROTOCOL_TCP); | ||
743 | + ipv4.setPayload(tcp); | ||
744 | + | ||
745 | + Ethernet eth = new Ethernet(); | ||
746 | + eth.setEtherType(Ethernet.TYPE_IPV4); | ||
747 | + eth.setPayload(ipv4); | ||
748 | + | ||
749 | + InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(), | ||
750 | + PortNumber.portNumber(PCEP_PORT)), | ||
751 | + eth, null); | ||
752 | + | ||
753 | + pktProcessor.process(new MockPcepPacketContext(inPkt, null)); | ||
754 | + assertThat(flowsDownloaded, is(0)); | ||
755 | + } | ||
756 | + | ||
757 | + /** | ||
718 | * Tests tunnel events added and removed. | 758 | * Tests tunnel events added and removed. |
719 | */ | 759 | */ |
720 | @Test | 760 | @Test | ... | ... |
... | @@ -2,6 +2,7 @@ COMPILE_DEPS = [ | ... | @@ -2,6 +2,7 @@ COMPILE_DEPS = [ |
2 | '//lib:CORE_DEPS', | 2 | '//lib:CORE_DEPS', |
3 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', | 3 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', |
4 | '//apps/pcep-api:onos-apps-pcep-api', | 4 | '//apps/pcep-api:onos-apps-pcep-api', |
5 | + '//incubator/api:onos-incubator-api', | ||
5 | ] | 6 | ] |
6 | 7 | ||
7 | osgi_jar_with_tests ( | 8 | osgi_jar_with_tests ( | ... | ... |
... | @@ -52,5 +52,9 @@ | ... | @@ -52,5 +52,9 @@ |
52 | <groupId>org.onosproject</groupId> | 52 | <groupId>org.onosproject</groupId> |
53 | <artifactId>onlab-misc</artifactId> | 53 | <artifactId>onlab-misc</artifactId> |
54 | </dependency> | 54 | </dependency> |
55 | + <dependency> | ||
56 | + <groupId>org.onosproject</groupId> | ||
57 | + <artifactId>onos-incubator-api</artifactId> | ||
58 | + </dependency> | ||
55 | </dependencies> | 59 | </dependencies> |
56 | </project> | 60 | </project> | ... | ... |
... | @@ -19,6 +19,7 @@ import java.util.List; | ... | @@ -19,6 +19,7 @@ import java.util.List; |
19 | 19 | ||
20 | import org.onosproject.pcepio.protocol.PcepFactory; | 20 | import org.onosproject.pcepio.protocol.PcepFactory; |
21 | import org.onosproject.pcepio.protocol.PcepMessage; | 21 | import org.onosproject.pcepio.protocol.PcepMessage; |
22 | +import org.onosproject.pcepio.protocol.PcepStateReport; | ||
22 | 23 | ||
23 | /** | 24 | /** |
24 | * Represents to provider facing side of a path computation client(pcc). | 25 | * Represents to provider facing side of a path computation client(pcc). |
... | @@ -165,4 +166,34 @@ public interface PcepClient { | ... | @@ -165,4 +166,34 @@ public interface PcepClient { |
165 | * @return delegation flag | 166 | * @return delegation flag |
166 | */ | 167 | */ |
167 | Boolean delegationInfo(LspKey lspKey); | 168 | Boolean delegationInfo(LspKey lspKey); |
169 | + | ||
170 | + /** | ||
171 | + * Creates a temporary cache to hold report messages received during LSPDB sync. | ||
172 | + * | ||
173 | + * @param pccId PCC id which is the key to store report messages | ||
174 | + */ | ||
175 | + void initializeSyncMsgList(PccId pccId); | ||
176 | + | ||
177 | + /** | ||
178 | + * Returns the list of report messages received during LSPDB sync. | ||
179 | + * | ||
180 | + * @param pccId PCC id which is the key for all the report messages | ||
181 | + * @return list of report messages received during LSPDB sync | ||
182 | + */ | ||
183 | + List<PcepStateReport> getSyncMsgList(PccId pccId); | ||
184 | + | ||
185 | + /** | ||
186 | + * Removes the list of report messages received during LSPDB sync. | ||
187 | + * | ||
188 | + * @param pccId PCC id which is the key for all the report messages | ||
189 | + */ | ||
190 | + void removeSyncMsgList(PccId pccId); | ||
191 | + | ||
192 | + /** | ||
193 | + * Adds report message received during LSPDB sync into temporary cache. | ||
194 | + * | ||
195 | + * @param pccId PCC id which is the key to store report messages | ||
196 | + * @param rptMsg the report message to be stored | ||
197 | + */ | ||
198 | + void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg); | ||
168 | } | 199 | } | ... | ... |
... | @@ -85,6 +85,20 @@ public interface PcepClientController { | ... | @@ -85,6 +85,20 @@ public interface PcepClientController { |
85 | void removeNodeListener(PcepNodeListener listener); | 85 | void removeNodeListener(PcepNodeListener listener); |
86 | 86 | ||
87 | /** | 87 | /** |
88 | + * Register a listener for packet events. | ||
89 | + * | ||
90 | + * @param listener the listener to notify | ||
91 | + */ | ||
92 | + void addPacketListener(PcepPacketListener listener); | ||
93 | + | ||
94 | + /** | ||
95 | + * Unregister a packet listener. | ||
96 | + * | ||
97 | + * @param listener the listener to unregister | ||
98 | + */ | ||
99 | + void removePacketListener(PcepPacketListener listener); | ||
100 | + | ||
101 | + /** | ||
88 | * Send a message to a particular pcc client. | 102 | * Send a message to a particular pcc client. |
89 | * | 103 | * |
90 | * @param pccId the id of the client to send message. | 104 | * @param pccId the id of the client to send message. | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.pcep.controller; | 16 | package org.onosproject.pcep.controller; |
17 | 17 | ||
18 | +import org.onosproject.incubator.net.tunnel.Tunnel; | ||
18 | import org.onosproject.pcepio.protocol.PcepMessage; | 19 | import org.onosproject.pcepio.protocol.PcepMessage; |
19 | /** | 20 | /** |
20 | * Notifies providers about PCEP message events. | 21 | * Notifies providers about PCEP message events. |
... | @@ -28,4 +29,21 @@ public interface PcepEventListener { | ... | @@ -28,4 +29,21 @@ public interface PcepEventListener { |
28 | * @param msg the message | 29 | * @param msg the message |
29 | */ | 30 | */ |
30 | void handleMessage(PccId pccId, PcepMessage msg); | 31 | void handleMessage(PccId pccId, PcepMessage msg); |
32 | + | ||
33 | + /** | ||
34 | + * Handles end of LSPDB sync actions. | ||
35 | + * | ||
36 | + * @param tunnel the tunnel on which action needs to be taken | ||
37 | + * @param endOfSyncAction the action that needs to be taken for the tunnel | ||
38 | + */ | ||
39 | + void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction); | ||
40 | + | ||
41 | + /** | ||
42 | + * Handles sending PCEP message to client on end of LSPDB sync. | ||
43 | + * | ||
44 | + * @param pccId id of the pcc | ||
45 | + * @param msg the message to be sent | ||
46 | + * @param endOfSyncAction the action that needs to be taken in the message | ||
47 | + */ | ||
48 | + void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction); | ||
31 | } | 49 | } | ... | ... |
1 | +/* | ||
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 | +package org.onosproject.pcep.controller; | ||
17 | + | ||
18 | +/** | ||
19 | + * Representation of actions to be taken for LSPs on end of LSP-DB sync. | ||
20 | + */ | ||
21 | +public enum PcepLspSyncAction { | ||
22 | + | ||
23 | + /** | ||
24 | + * Specifies that delete message for PCE intiiated tunnel should be sent. | ||
25 | + */ | ||
26 | + SEND_DELETE(0), | ||
27 | + | ||
28 | + /** | ||
29 | + * Specifies that update message should be sent. | ||
30 | + */ | ||
31 | + SEND_UPDATE(1), | ||
32 | + | ||
33 | + /** | ||
34 | + * Specifies that the tunnel should be removed from PCE. | ||
35 | + */ | ||
36 | + REMOVE(2), | ||
37 | + | ||
38 | + /** | ||
39 | + * Specifies that the status of the tunnel should be set as unstable. | ||
40 | + */ | ||
41 | + UNSTABLE(3); | ||
42 | + | ||
43 | + int value; | ||
44 | + | ||
45 | + /** | ||
46 | + * Assigns val with the value for actions to be taken for LSPs on end of LSP-DB sync. | ||
47 | + * | ||
48 | + * @param val sync status | ||
49 | + */ | ||
50 | + PcepLspSyncAction(int val) { | ||
51 | + value = val; | ||
52 | + } | ||
53 | +} |
1 | +/* | ||
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 | +package org.onosproject.pcep.controller; | ||
17 | + | ||
18 | +public interface PcepPacketListener { | ||
19 | + | ||
20 | + void sendPacketIn(PccId pccId); | ||
21 | + | ||
22 | +} |
... | @@ -73,4 +73,12 @@ public interface PcepAgent { | ... | @@ -73,4 +73,12 @@ public interface PcepAgent { |
73 | * @param pccId PCEP client ID | 73 | * @param pccId PCEP client ID |
74 | */ | 74 | */ |
75 | void deleteNode(PccId pccId); | 75 | void deleteNode(PccId pccId); |
76 | + | ||
77 | + /** | ||
78 | + * Analyzes report messages received during LSP DB sync again tunnel store and takes necessary actions. | ||
79 | + * | ||
80 | + * @param pccId the id of pcc client | ||
81 | + * @return success or failure | ||
82 | + */ | ||
83 | + boolean analyzeSyncMsgList(PccId pccId); | ||
76 | } | 84 | } | ... | ... |
... | @@ -2,6 +2,7 @@ COMPILE_DEPS = [ | ... | @@ -2,6 +2,7 @@ COMPILE_DEPS = [ |
2 | '//lib:CORE_DEPS', | 2 | '//lib:CORE_DEPS', |
3 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', | 3 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', |
4 | '//protocols/pcep/api:onos-protocols-pcep-api', | 4 | '//protocols/pcep/api:onos-protocols-pcep-api', |
5 | + '//incubator/api:onos-incubator-api', | ||
5 | ] | 6 | ] |
6 | 7 | ||
7 | osgi_jar_with_tests ( | 8 | osgi_jar_with_tests ( | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -19,6 +19,8 @@ package org.onosproject.pcep.controller.impl; | ... | @@ -19,6 +19,8 @@ package org.onosproject.pcep.controller.impl; |
19 | import java.net.InetSocketAddress; | 19 | import java.net.InetSocketAddress; |
20 | import java.net.SocketAddress; | 20 | import java.net.SocketAddress; |
21 | import java.util.Collections; | 21 | import java.util.Collections; |
22 | +import java.util.HashMap; | ||
23 | +import java.util.LinkedList; | ||
22 | import java.util.List; | 24 | import java.util.List; |
23 | import java.util.Map; | 25 | import java.util.Map; |
24 | import java.util.concurrent.RejectedExecutionException; | 26 | import java.util.concurrent.RejectedExecutionException; |
... | @@ -36,6 +38,7 @@ import org.onosproject.pcep.controller.driver.PcepClientDriver; | ... | @@ -36,6 +38,7 @@ import org.onosproject.pcep.controller.driver.PcepClientDriver; |
36 | import org.onosproject.pcepio.protocol.PcepFactories; | 38 | import org.onosproject.pcepio.protocol.PcepFactories; |
37 | import org.onosproject.pcepio.protocol.PcepFactory; | 39 | import org.onosproject.pcepio.protocol.PcepFactory; |
38 | import org.onosproject.pcepio.protocol.PcepMessage; | 40 | import org.onosproject.pcepio.protocol.PcepMessage; |
41 | +import org.onosproject.pcepio.protocol.PcepStateReport; | ||
39 | import org.onosproject.pcepio.protocol.PcepVersion; | 42 | import org.onosproject.pcepio.protocol.PcepVersion; |
40 | import org.slf4j.Logger; | 43 | import org.slf4j.Logger; |
41 | import org.slf4j.LoggerFactory; | 44 | import org.slf4j.LoggerFactory; |
... | @@ -70,6 +73,7 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -70,6 +73,7 @@ public class PcepClientImpl implements PcepClientDriver { |
70 | private byte sessionId; | 73 | private byte sessionId; |
71 | private PcepPacketStatsImpl pktStats; | 74 | private PcepPacketStatsImpl pktStats; |
72 | private Map<LspKey, Boolean> lspDelegationInfo; | 75 | private Map<LspKey, Boolean> lspDelegationInfo; |
76 | + private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>(); | ||
73 | 77 | ||
74 | @Override | 78 | @Override |
75 | public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) { | 79 | public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) { |
... | @@ -192,7 +196,14 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -192,7 +196,14 @@ public class PcepClientImpl implements PcepClientDriver { |
192 | 196 | ||
193 | @Override | 197 | @Override |
194 | public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { | 198 | public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { |
199 | + | ||
200 | + PcepSyncStatus syncOldStatus = labelDbSyncStatus(); | ||
195 | this.labelDbSyncStatus = syncStatus; | 201 | this.labelDbSyncStatus = syncStatus; |
202 | + | ||
203 | + if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) { | ||
204 | + // Perform end of LSP DB sync actions. | ||
205 | + this.agent.analyzeSyncMsgList(pccId); | ||
206 | + } | ||
196 | } | 207 | } |
197 | 208 | ||
198 | @Override | 209 | @Override |
... | @@ -254,6 +265,29 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -254,6 +265,29 @@ public class PcepClientImpl implements PcepClientDriver { |
254 | } | 265 | } |
255 | 266 | ||
256 | @Override | 267 | @Override |
268 | + public void initializeSyncMsgList(PccId pccId) { | ||
269 | + List<PcepStateReport> rptMsgList = new LinkedList<>(); | ||
270 | + sycRptCache.put(pccId, rptMsgList); | ||
271 | + } | ||
272 | + | ||
273 | + @Override | ||
274 | + public List<PcepStateReport> getSyncMsgList(PccId pccId) { | ||
275 | + return sycRptCache.get(pccId); | ||
276 | + } | ||
277 | + | ||
278 | + @Override | ||
279 | + public void removeSyncMsgList(PccId pccId) { | ||
280 | + sycRptCache.remove(pccId); | ||
281 | + } | ||
282 | + | ||
283 | + @Override | ||
284 | + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) { | ||
285 | + List<PcepStateReport> rptMsgList = sycRptCache.get(pccId); | ||
286 | + rptMsgList.add(rptMsg); | ||
287 | + sycRptCache.put(pccId, rptMsgList); | ||
288 | + } | ||
289 | + | ||
290 | + @Override | ||
257 | public boolean isOptical() { | 291 | public boolean isOptical() { |
258 | return false; | 292 | return false; |
259 | } | 293 | } | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.provider.pcep.tunnel.impl; | 16 | +package org.onosproject.pcep.controller.impl; |
17 | 17 | ||
18 | import org.onosproject.incubator.net.tunnel.Tunnel.State; | 18 | import org.onosproject.incubator.net.tunnel.Tunnel.State; |
19 | 19 | ||
... | @@ -51,6 +51,7 @@ public enum PcepLspStatus { | ... | @@ -51,6 +51,7 @@ public enum PcepLspStatus { |
51 | * Returns the applicable PCEP LSP status corresponding to ONOS tunnel state. | 51 | * Returns the applicable PCEP LSP status corresponding to ONOS tunnel state. |
52 | * | 52 | * |
53 | * @param tunnelState ONOS tunnel state | 53 | * @param tunnelState ONOS tunnel state |
54 | + * @return LSP status as per protocol | ||
54 | */ | 55 | */ |
55 | public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) { | 56 | public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) { |
56 | 57 | ||
... | @@ -76,6 +77,7 @@ public enum PcepLspStatus { | ... | @@ -76,6 +77,7 @@ public enum PcepLspStatus { |
76 | * Returns the applicable ONOS tunnel state corresponding to PCEP LSP status. | 77 | * Returns the applicable ONOS tunnel state corresponding to PCEP LSP status. |
77 | * | 78 | * |
78 | * @param lspState PCEP LSP status | 79 | * @param lspState PCEP LSP status |
80 | + * @return tunnel state | ||
79 | */ | 81 | */ |
80 | public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) { | 82 | public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) { |
81 | 83 | ... | ... |
... | @@ -57,6 +57,10 @@ public class PcepMetricObjectVer1 implements PcepMetricObject { | ... | @@ -57,6 +57,10 @@ public class PcepMetricObjectVer1 implements PcepMetricObject { |
57 | public static final int BFLAG_RESET = 0; | 57 | public static final int BFLAG_RESET = 0; |
58 | public static final byte CFLAG_CHECK = 0x02; | 58 | public static final byte CFLAG_CHECK = 0x02; |
59 | 59 | ||
60 | + public static final byte IGP_METRIC = 0x01; | ||
61 | + public static final byte TE_METRIC = 0x02; | ||
62 | + public static final byte HOP_COUNT_METRIC = 0x03; | ||
63 | + | ||
60 | static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS, | 64 | static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS, |
61 | METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, | 65 | METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, |
62 | METRIC_OBJ_MINIMUM_LENGTH); | 66 | METRIC_OBJ_MINIMUM_LENGTH); | ... | ... |
providers/pcep/packet/pom.xml
0 → 100644
1 | +<!-- | ||
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 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
17 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
18 | + <modelVersion>4.0.0</modelVersion> | ||
19 | + <parent> | ||
20 | + <groupId>org.onosproject</groupId> | ||
21 | + <artifactId>onos-pcep-providers</artifactId> | ||
22 | + <version>1.7.0-SNAPSHOT</version> | ||
23 | + <relativePath>../pom.xml</relativePath> | ||
24 | + </parent> | ||
25 | + <artifactId>onos-pcep-provider-packet</artifactId> | ||
26 | + <packaging>bundle</packaging> | ||
27 | + <description>PCEP packet provider</description> | ||
28 | + <dependencies> | ||
29 | + <dependency> | ||
30 | + <groupId>org.onosproject</groupId> | ||
31 | + <artifactId>onos-pcep-controller-api</artifactId> | ||
32 | + </dependency> | ||
33 | + </dependencies> | ||
34 | +</project> |
1 | +package org.onosproject.provider.pcep.packet.impl; | ||
2 | + | ||
3 | +import static org.slf4j.LoggerFactory.getLogger; | ||
4 | + | ||
5 | +import org.apache.felix.scr.annotations.Activate; | ||
6 | +import org.apache.felix.scr.annotations.Component; | ||
7 | +import org.apache.felix.scr.annotations.Deactivate; | ||
8 | +import org.apache.felix.scr.annotations.Reference; | ||
9 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
10 | +import org.apache.felix.scr.annotations.Service; | ||
11 | +import org.onlab.packet.Ethernet; | ||
12 | +import org.onlab.packet.IPv4; | ||
13 | +import org.onlab.packet.TCP; | ||
14 | +import org.onosproject.net.AnnotationKeys; | ||
15 | +import org.onosproject.net.ConnectPoint; | ||
16 | +import org.onosproject.net.Device; | ||
17 | +import org.onosproject.net.DeviceId; | ||
18 | +import org.onosproject.net.PortNumber; | ||
19 | +import org.onosproject.net.device.DeviceService; | ||
20 | +import org.onosproject.net.packet.DefaultInboundPacket; | ||
21 | +import org.onosproject.net.packet.DefaultPacketContext; | ||
22 | +import org.onosproject.net.packet.InboundPacket; | ||
23 | +import org.onosproject.net.packet.OutboundPacket; | ||
24 | +import org.onosproject.net.packet.PacketProvider; | ||
25 | +import org.onosproject.net.packet.PacketProviderRegistry; | ||
26 | +import org.onosproject.net.packet.PacketProviderService; | ||
27 | +import org.onosproject.net.provider.AbstractProvider; | ||
28 | +import org.onosproject.net.provider.ProviderId; | ||
29 | +import org.onosproject.pcep.controller.PccId; | ||
30 | +import org.onosproject.pcep.controller.PcepClientController; | ||
31 | +import org.onosproject.pcep.controller.PcepPacketListener; | ||
32 | +import org.slf4j.Logger; | ||
33 | + | ||
34 | +/** | ||
35 | + * Provider which uses an PCEP controller to process packets. | ||
36 | + */ | ||
37 | +@Component(immediate = true) | ||
38 | +@Service | ||
39 | +public class PcepPacketProvider extends AbstractProvider implements PacketProvider { | ||
40 | + | ||
41 | + private static final Logger log = getLogger(PcepPacketProvider.class); | ||
42 | + static final String PROVIDER_ID = "org.onosproject.provider.packet.pcep"; | ||
43 | + | ||
44 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
45 | + protected PacketProviderRegistry packetProviderRegistry; | ||
46 | + | ||
47 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
48 | + protected PcepClientController pcepClientController; | ||
49 | + | ||
50 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
51 | + protected DeviceService deviceService; | ||
52 | + | ||
53 | + PacketProviderService packetProviderService; | ||
54 | + | ||
55 | + private InnerPacketProvider listener = new InnerPacketProvider(); | ||
56 | + public static final String LSRID = "lsrId"; | ||
57 | + public static final int PCEP_PORT = 4189; | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a Packet provider. | ||
61 | + */ | ||
62 | + public PcepPacketProvider() { | ||
63 | + super(new ProviderId("pcep", PROVIDER_ID)); | ||
64 | + } | ||
65 | + | ||
66 | + @Activate | ||
67 | + public void activate() { | ||
68 | + packetProviderService = packetProviderRegistry.register(this); | ||
69 | + pcepClientController.addPacketListener(listener); | ||
70 | + log.info("Started"); | ||
71 | + } | ||
72 | + | ||
73 | + @Deactivate | ||
74 | + public void deactivate() { | ||
75 | + packetProviderRegistry.unregister(this); | ||
76 | + pcepClientController.removePacketListener(listener); | ||
77 | + log.info("Stopped"); | ||
78 | + } | ||
79 | + | ||
80 | + private class InnerPacketProvider implements PcepPacketListener { | ||
81 | + @Override | ||
82 | + public void sendPacketIn(PccId pccId) { | ||
83 | + TCP tcp = new TCP(); | ||
84 | + // Set the well known PCEP port. To be used to decide to process/discard the packet while processing. | ||
85 | + tcp.setDestinationPort(PCEP_PORT); | ||
86 | + | ||
87 | + IPv4 ipv4 = new IPv4(); | ||
88 | + ipv4.setProtocol(IPv4.PROTOCOL_TCP); | ||
89 | + ipv4.setPayload(tcp); | ||
90 | + | ||
91 | + Ethernet eth = new Ethernet(); | ||
92 | + eth.setEtherType(Ethernet.TYPE_IPV4); | ||
93 | + eth.setPayload(ipv4); | ||
94 | + | ||
95 | + // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID. | ||
96 | + String lsrId = String.valueOf(pccId.ipAddress()); | ||
97 | + DeviceId pccDeviceId = null; | ||
98 | + | ||
99 | + // Find PCC deviceID from lsrId stored as annotations | ||
100 | + Iterable<Device> devices = deviceService.getAvailableDevices(); | ||
101 | + for (Device dev : devices) { | ||
102 | + if ("L3".equals(dev.annotations().value(AnnotationKeys.TYPE)) | ||
103 | + && lsrId.equals(dev.annotations().value(LSRID))) { | ||
104 | + pccDeviceId = dev.id(); | ||
105 | + break; | ||
106 | + } | ||
107 | + } | ||
108 | + | ||
109 | + if (pccDeviceId == null) { | ||
110 | + return; | ||
111 | + } | ||
112 | + | ||
113 | + InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId, | ||
114 | + PortNumber.portNumber(PCEP_PORT)), | ||
115 | + eth, null); | ||
116 | + | ||
117 | + packetProviderService.processPacket(new PcepPacketContext(inPkt, null)); | ||
118 | + } | ||
119 | + } | ||
120 | + | ||
121 | + // Minimal PacketContext to make core and applications happy. | ||
122 | + private final class PcepPacketContext extends DefaultPacketContext { | ||
123 | + private PcepPacketContext(InboundPacket inPkt, OutboundPacket outPkt) { | ||
124 | + super(System.currentTimeMillis(), inPkt, outPkt, false); | ||
125 | + } | ||
126 | + | ||
127 | + @Override | ||
128 | + public void send() { | ||
129 | + // We don't send anything out. | ||
130 | + return; | ||
131 | + } | ||
132 | + } | ||
133 | + | ||
134 | + @Override | ||
135 | + public void emit(OutboundPacket packet) { | ||
136 | + // Nothing to emit | ||
137 | + return; | ||
138 | + | ||
139 | + } | ||
140 | +} |
providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/package-info.java
0 → 100644
1 | +/* | ||
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 | +/** | ||
17 | + *Provider that uses PCEP controller as a means to send packets. | ||
18 | + */ | ||
19 | +package org.onosproject.provider.pcep.packet.impl; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -28,5 +28,6 @@ | ... | @@ -28,5 +28,6 @@ |
28 | <module>topology</module> | 28 | <module>topology</module> |
29 | <module>tunnel</module> | 29 | <module>tunnel</module> |
30 | <module>app</module> | 30 | <module>app</module> |
31 | + <module>packet</module> | ||
31 | </modules> | 32 | </modules> |
32 | </project> | 33 | </project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -31,6 +31,7 @@ import org.onosproject.pcep.controller.PcepSyncStatus; | ... | @@ -31,6 +31,7 @@ import org.onosproject.pcep.controller.PcepSyncStatus; |
31 | import org.onosproject.pcepio.protocol.PcepFactories; | 31 | import org.onosproject.pcepio.protocol.PcepFactories; |
32 | import org.onosproject.pcepio.protocol.PcepFactory; | 32 | import org.onosproject.pcepio.protocol.PcepFactory; |
33 | import org.onosproject.pcepio.protocol.PcepMessage; | 33 | import org.onosproject.pcepio.protocol.PcepMessage; |
34 | +import org.onosproject.pcepio.protocol.PcepStateReport; | ||
34 | import org.onosproject.pcepio.protocol.PcepVersion; | 35 | import org.onosproject.pcepio.protocol.PcepVersion; |
35 | 36 | ||
36 | /** | 37 | /** |
... | @@ -161,4 +162,28 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -161,4 +162,28 @@ public class PcepClientAdapter implements PcepClient { |
161 | public Boolean delegationInfo(LspKey lspKey) { | 162 | public Boolean delegationInfo(LspKey lspKey) { |
162 | return lspDelegationInfo.get(lspKey); | 163 | return lspDelegationInfo.get(lspKey); |
163 | } | 164 | } |
165 | + | ||
166 | + @Override | ||
167 | + public void initializeSyncMsgList(PccId pccId) { | ||
168 | + // TODO Auto-generated method stub | ||
169 | + | ||
170 | + } | ||
171 | + | ||
172 | + @Override | ||
173 | + public List<PcepStateReport> getSyncMsgList(PccId pccId) { | ||
174 | + // TODO Auto-generated method stub | ||
175 | + return null; | ||
176 | + } | ||
177 | + | ||
178 | + @Override | ||
179 | + public void removeSyncMsgList(PccId pccId) { | ||
180 | + // TODO Auto-generated method stub | ||
181 | + | ||
182 | + } | ||
183 | + | ||
184 | + @Override | ||
185 | + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) { | ||
186 | + // TODO Auto-generated method stub | ||
187 | + | ||
188 | + } | ||
164 | } | 189 | } | ... | ... |
... | @@ -32,6 +32,7 @@ import org.onosproject.pcep.controller.PcepClientController; | ... | @@ -32,6 +32,7 @@ import org.onosproject.pcep.controller.PcepClientController; |
32 | import org.onosproject.pcep.controller.PcepClientListener; | 32 | import org.onosproject.pcep.controller.PcepClientListener; |
33 | import org.onosproject.pcep.controller.PcepEventListener; | 33 | import org.onosproject.pcep.controller.PcepEventListener; |
34 | import org.onosproject.pcep.controller.PcepNodeListener; | 34 | import org.onosproject.pcep.controller.PcepNodeListener; |
35 | +import org.onosproject.pcep.controller.PcepPacketListener; | ||
35 | import org.onosproject.pcep.controller.driver.PcepAgent; | 36 | import org.onosproject.pcep.controller.driver.PcepAgent; |
36 | import org.onosproject.pcepio.protocol.PcepError; | 37 | import org.onosproject.pcepio.protocol.PcepError; |
37 | import org.onosproject.pcepio.protocol.PcepErrorInfo; | 38 | import org.onosproject.pcepio.protocol.PcepErrorInfo; |
... | @@ -280,5 +281,23 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -280,5 +281,23 @@ public class PcepClientControllerAdapter implements PcepClientController { |
280 | l.deleteNode(pccId); | 281 | l.deleteNode(pccId); |
281 | } | 282 | } |
282 | } | 283 | } |
284 | + | ||
285 | + @Override | ||
286 | + public boolean analyzeSyncMsgList(PccId pccId) { | ||
287 | + // TODO Auto-generated method stub | ||
288 | + return false; | ||
289 | + } | ||
290 | + } | ||
291 | + | ||
292 | + @Override | ||
293 | + public void addPacketListener(PcepPacketListener listener) { | ||
294 | + // TODO Auto-generated method stub | ||
295 | + | ||
296 | + } | ||
297 | + | ||
298 | + @Override | ||
299 | + public void removePacketListener(PcepPacketListener listener) { | ||
300 | + // TODO Auto-generated method stub | ||
301 | + | ||
283 | } | 302 | } |
284 | } | 303 | } | ... | ... |
... | @@ -6,6 +6,7 @@ COMPILE_DEPS = [ | ... | @@ -6,6 +6,7 @@ COMPILE_DEPS = [ |
6 | '//incubator/api:onos-incubator-api', | 6 | '//incubator/api:onos-incubator-api', |
7 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', | 7 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', |
8 | '//protocols/pcep/api:onos-protocols-pcep-api', | 8 | '//protocols/pcep/api:onos-protocols-pcep-api', |
9 | + '//protocols/pcep/ctl:onos-protocols-pcep-ctl', | ||
9 | ] | 10 | ] |
10 | 11 | ||
11 | TEST_DEPS = [ | 12 | TEST_DEPS = [ | ... | ... |
... | @@ -50,5 +50,10 @@ | ... | @@ -50,5 +50,10 @@ |
50 | <version>${project.version} </version> | 50 | <version>${project.version} </version> |
51 | <scope>test</scope> | 51 | <scope>test</scope> |
52 | </dependency> | 52 | </dependency> |
53 | + <dependency> | ||
54 | + <groupId>org.onosproject</groupId> | ||
55 | + <artifactId>onos-pcep-controller-impl</artifactId> | ||
56 | + <version>${project.version} </version> | ||
57 | + </dependency> | ||
53 | </dependencies> | 58 | </dependencies> |
54 | </project> | 59 | </project> | ... | ... |
This diff is collapsed. Click to expand it.
providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java
... | @@ -18,6 +18,7 @@ package org.onosproject.provider.pcep.tunnel.impl; | ... | @@ -18,6 +18,7 @@ package org.onosproject.provider.pcep.tunnel.impl; |
18 | import static org.junit.Assert.assertNotNull; | 18 | import static org.junit.Assert.assertNotNull; |
19 | 19 | ||
20 | import java.util.HashMap; | 20 | import java.util.HashMap; |
21 | +import java.util.LinkedList; | ||
21 | import java.util.List; | 22 | import java.util.List; |
22 | import java.util.Map; | 23 | import java.util.Map; |
23 | import java.util.concurrent.RejectedExecutionException; | 24 | import java.util.concurrent.RejectedExecutionException; |
... | @@ -31,6 +32,7 @@ import org.onosproject.pcep.controller.PcepSyncStatus; | ... | @@ -31,6 +32,7 @@ import org.onosproject.pcep.controller.PcepSyncStatus; |
31 | import org.onosproject.pcepio.protocol.PcepFactories; | 32 | import org.onosproject.pcepio.protocol.PcepFactories; |
32 | import org.onosproject.pcepio.protocol.PcepFactory; | 33 | import org.onosproject.pcepio.protocol.PcepFactory; |
33 | import org.onosproject.pcepio.protocol.PcepMessage; | 34 | import org.onosproject.pcepio.protocol.PcepMessage; |
35 | +import org.onosproject.pcepio.protocol.PcepStateReport; | ||
34 | import org.onosproject.pcepio.protocol.PcepVersion; | 36 | import org.onosproject.pcepio.protocol.PcepVersion; |
35 | 37 | ||
36 | /** | 38 | /** |
... | @@ -49,6 +51,7 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -49,6 +51,7 @@ public class PcepClientAdapter implements PcepClient { |
49 | private PcepSyncStatus lspDbSyncStatus; | 51 | private PcepSyncStatus lspDbSyncStatus; |
50 | private PcepSyncStatus labelDbSyncStatus; | 52 | private PcepSyncStatus labelDbSyncStatus; |
51 | private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>(); | 53 | private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>(); |
54 | + private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>(); | ||
52 | 55 | ||
53 | /** | 56 | /** |
54 | * Initialize instance with specified parameters. | 57 | * Initialize instance with specified parameters. |
... | @@ -161,4 +164,27 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -161,4 +164,27 @@ public class PcepClientAdapter implements PcepClient { |
161 | public Boolean delegationInfo(LspKey lspKey) { | 164 | public Boolean delegationInfo(LspKey lspKey) { |
162 | return lspDelegationInfo.get(lspKey); | 165 | return lspDelegationInfo.get(lspKey); |
163 | } | 166 | } |
167 | + | ||
168 | + @Override | ||
169 | + public void initializeSyncMsgList(PccId pccId) { | ||
170 | + List<PcepStateReport> rptMsgList = new LinkedList<>(); | ||
171 | + sycRptCache.put(pccId, rptMsgList); | ||
172 | + } | ||
173 | + | ||
174 | + @Override | ||
175 | + public List<PcepStateReport> getSyncMsgList(PccId pccId) { | ||
176 | + return sycRptCache.get(pccId); | ||
177 | + } | ||
178 | + | ||
179 | + @Override | ||
180 | + public void removeSyncMsgList(PccId pccId) { | ||
181 | + sycRptCache.remove(pccId); | ||
182 | + } | ||
183 | + | ||
184 | + @Override | ||
185 | + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) { | ||
186 | + List<PcepStateReport> rptMsgList = sycRptCache.get(pccId); | ||
187 | + rptMsgList.add(rptMsg); | ||
188 | + sycRptCache.put(pccId, rptMsgList); | ||
189 | + } | ||
164 | } | 190 | } | ... | ... |
... | @@ -30,6 +30,7 @@ import org.onosproject.pcep.controller.PcepClientController; | ... | @@ -30,6 +30,7 @@ import org.onosproject.pcep.controller.PcepClientController; |
30 | import org.onosproject.pcep.controller.PcepClientListener; | 30 | import org.onosproject.pcep.controller.PcepClientListener; |
31 | import org.onosproject.pcep.controller.PcepEventListener; | 31 | import org.onosproject.pcep.controller.PcepEventListener; |
32 | import org.onosproject.pcep.controller.PcepNodeListener; | 32 | import org.onosproject.pcep.controller.PcepNodeListener; |
33 | +import org.onosproject.pcep.controller.PcepPacketListener; | ||
33 | import org.onosproject.pcep.controller.driver.PcepAgent; | 34 | import org.onosproject.pcep.controller.driver.PcepAgent; |
34 | import org.onosproject.pcepio.protocol.PcepError; | 35 | import org.onosproject.pcepio.protocol.PcepError; |
35 | import org.onosproject.pcepio.protocol.PcepErrorInfo; | 36 | import org.onosproject.pcepio.protocol.PcepErrorInfo; |
... | @@ -57,6 +58,7 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -57,6 +58,7 @@ public class PcepClientControllerAdapter implements PcepClientController { |
57 | 58 | ||
58 | protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); | 59 | protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); |
59 | public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet(); | 60 | public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet(); |
61 | + protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet(); | ||
60 | 62 | ||
61 | @Activate | 63 | @Activate |
62 | public void activate() { | 64 | public void activate() { |
... | @@ -116,6 +118,16 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -116,6 +118,16 @@ public class PcepClientControllerAdapter implements PcepClientController { |
116 | } | 118 | } |
117 | 119 | ||
118 | @Override | 120 | @Override |
121 | + public void addPacketListener(PcepPacketListener listener) { | ||
122 | + pcepPacketListener.add(listener); | ||
123 | + } | ||
124 | + | ||
125 | + @Override | ||
126 | + public void removePacketListener(PcepPacketListener listener) { | ||
127 | + pcepPacketListener.remove(listener); | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
119 | public void writeMessage(PccId pccId, PcepMessage msg) { | 131 | public void writeMessage(PccId pccId, PcepMessage msg) { |
120 | this.getClient(pccId).sendMessage(msg); | 132 | this.getClient(pccId).sendMessage(msg); |
121 | } | 133 | } |
... | @@ -273,5 +285,11 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -273,5 +285,11 @@ public class PcepClientControllerAdapter implements PcepClientController { |
273 | l.deleteNode(pccId); | 285 | l.deleteNode(pccId); |
274 | } | 286 | } |
275 | } | 287 | } |
288 | + | ||
289 | + @Override | ||
290 | + public boolean analyzeSyncMsgList(PccId pccId) { | ||
291 | + // TODO Auto-generated method stub | ||
292 | + return false; | ||
293 | + } | ||
276 | } | 294 | } |
277 | } | 295 | } | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment