ISIS protocol manual merge from 1.6 due to cherry pick merge conflict
Change-Id: I6c3abf6a83ddaeba76293dc7864fcec88e9b4e7e
Showing
55 changed files
with
3461 additions
and
256 deletions
... | @@ -16,9 +16,11 @@ | ... | @@ -16,9 +16,11 @@ |
16 | package org.onosproject.isis.controller; | 16 | package org.onosproject.isis.controller; |
17 | 17 | ||
18 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
19 | +import org.onosproject.isis.controller.topology.IsisLinkListener; | ||
19 | import org.onosproject.isis.controller.topology.IsisRouterListener; | 20 | import org.onosproject.isis.controller.topology.IsisRouterListener; |
20 | 21 | ||
21 | import java.util.List; | 22 | import java.util.List; |
23 | +import java.util.Set; | ||
22 | 24 | ||
23 | /** | 25 | /** |
24 | * Representation of an ISIS controller. | 26 | * Representation of an ISIS controller. |
... | @@ -52,4 +54,32 @@ public interface IsisController { | ... | @@ -52,4 +54,32 @@ public interface IsisController { |
52 | * @return list of process instances | 54 | * @return list of process instances |
53 | */ | 55 | */ |
54 | List<IsisProcess> allConfiguredProcesses(); | 56 | List<IsisProcess> allConfiguredProcesses(); |
57 | + | ||
58 | + /** | ||
59 | + * Registers a listener for ISIS message events. | ||
60 | + * | ||
61 | + * @param listener the listener to notify | ||
62 | + */ | ||
63 | + void addLinkListener(IsisLinkListener listener); | ||
64 | + | ||
65 | + /** | ||
66 | + * Unregisters a link listener. | ||
67 | + * | ||
68 | + * @param listener the listener to unregister | ||
69 | + */ | ||
70 | + void removeLinkListener(IsisLinkListener listener); | ||
71 | + | ||
72 | + /** | ||
73 | + * Gets the list of listeners registered for router events. | ||
74 | + * | ||
75 | + * @return list of listeners | ||
76 | + */ | ||
77 | + Set<IsisRouterListener> listener(); | ||
78 | + | ||
79 | + /** | ||
80 | + * Gets the list of listeners registered for link events. | ||
81 | + * | ||
82 | + * @return list of listeners | ||
83 | + */ | ||
84 | + Set<IsisLinkListener> linkListener(); | ||
55 | } | 85 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -122,4 +122,11 @@ public interface IsisLsdb { | ... | @@ -122,4 +122,11 @@ public interface IsisLsdb { |
122 | * @param l2LspSeqNo link state sequence number | 122 | * @param l2LspSeqNo link state sequence number |
123 | */ | 123 | */ |
124 | void setL2LspSeqNo(int l2LspSeqNo); | 124 | void setL2LspSeqNo(int l2LspSeqNo); |
125 | + /** | ||
126 | + * Removes topology information when neighbor down. | ||
127 | + * | ||
128 | + * @param neighbor ISIS neighbor instance | ||
129 | + * @param isisInterface ISIS interface instance | ||
130 | + */ | ||
131 | + void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface); | ||
125 | } | 132 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/DeviceInformation.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 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.isis.controller.topology; | ||
17 | + | ||
18 | +import org.onlab.packet.Ip4Address; | ||
19 | + | ||
20 | +/** | ||
21 | + * Representation of an ISIS device information. | ||
22 | + */ | ||
23 | +public interface DeviceInformation { | ||
24 | + | ||
25 | + /** | ||
26 | + * Gets system id. | ||
27 | + * | ||
28 | + * @return system id | ||
29 | + */ | ||
30 | + String systemId(); | ||
31 | + | ||
32 | + /** | ||
33 | + * Sets system id. | ||
34 | + * | ||
35 | + * @param systemId system id | ||
36 | + */ | ||
37 | + void setSystemId(String systemId); | ||
38 | + | ||
39 | + /** | ||
40 | + * Gets interface ids. | ||
41 | + * | ||
42 | + * @return interface ids | ||
43 | + */ | ||
44 | + Ip4Address interfaceId(); | ||
45 | + | ||
46 | + /** | ||
47 | + * Sets interface id. | ||
48 | + * | ||
49 | + * @param interfaceId interface id | ||
50 | + */ | ||
51 | + void setInterfaceId(Ip4Address interfaceId); | ||
52 | + | ||
53 | + /** | ||
54 | + * Gets area id. | ||
55 | + * | ||
56 | + * @return area id | ||
57 | + */ | ||
58 | + String areaId(); | ||
59 | + | ||
60 | + /** | ||
61 | + * Sets area id. | ||
62 | + * | ||
63 | + * @param areaId area id | ||
64 | + */ | ||
65 | + void setAreaId(String areaId); | ||
66 | + | ||
67 | + /** | ||
68 | + * Gets device information is already created or not. | ||
69 | + * | ||
70 | + * @return true if device information is already created else false | ||
71 | + */ | ||
72 | + boolean isAlreadyCreated(); | ||
73 | + | ||
74 | + /** | ||
75 | + * Sets device information is already created or not. | ||
76 | + * | ||
77 | + * @param alreadyCreated true if device information is already created else false | ||
78 | + */ | ||
79 | + void setAlreadyCreated(boolean alreadyCreated); | ||
80 | + | ||
81 | + /** | ||
82 | + * Gets device is dis or not. | ||
83 | + * | ||
84 | + * @return true if device is dis else false | ||
85 | + */ | ||
86 | + boolean isDis(); | ||
87 | + | ||
88 | + /** | ||
89 | + * Sets device is dis or not. | ||
90 | + * | ||
91 | + * @param dis true if device is dr else false | ||
92 | + */ | ||
93 | + void setDis(boolean dis); | ||
94 | + | ||
95 | + /** | ||
96 | + * Gets neighbor id. | ||
97 | + * | ||
98 | + * @return neighbor id | ||
99 | + */ | ||
100 | + String neighborId(); | ||
101 | + | ||
102 | + /** | ||
103 | + * Sets neighbor id. | ||
104 | + * | ||
105 | + * @param neighborId neighbor id | ||
106 | + */ | ||
107 | + void setNeighborId(String neighborId); | ||
108 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | +package org.onosproject.isis.controller.topology; | ||
18 | + | ||
19 | +/** | ||
20 | + * Representation of an ISIS agent. | ||
21 | + * It is responsible for keeping track of the current set of routers | ||
22 | + * connected to the system. | ||
23 | + */ | ||
24 | +public interface IsisAgent { | ||
25 | + /** | ||
26 | + * Adds a router that has just connected to the system. | ||
27 | + * | ||
28 | + * @param isisRouter the router id to add | ||
29 | + * @return true if added, false otherwise | ||
30 | + */ | ||
31 | + boolean addConnectedRouter(IsisRouter isisRouter); | ||
32 | + | ||
33 | + /** | ||
34 | + * Removes the router which got disconnected from the system. | ||
35 | + * | ||
36 | + * @param isisRouter the router id to remove | ||
37 | + */ | ||
38 | + void removeConnectedRouter(IsisRouter isisRouter); | ||
39 | + | ||
40 | + /** | ||
41 | + * Notifies that got a packet of link from network and need do processing. | ||
42 | + * | ||
43 | + * @param isisLink link instance | ||
44 | + */ | ||
45 | + void addLink(IsisLink isisLink); | ||
46 | + | ||
47 | + /** | ||
48 | + * Notifies that got a packet of link from network and need do processing. | ||
49 | + * | ||
50 | + * @param isisLink link instance | ||
51 | + */ | ||
52 | + void deleteLink(IsisLink isisLink); | ||
53 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -15,9 +15,7 @@ | ... | @@ -15,9 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.isis.controller.topology; | 16 | package org.onosproject.isis.controller.topology; |
17 | 17 | ||
18 | -import org.onlab.packet.IpAddress; | 18 | +import org.onlab.packet.Ip4Address; |
19 | - | ||
20 | -import java.util.List; | ||
21 | 19 | ||
22 | /** | 20 | /** |
23 | * Abstraction of an ISIS Link. | 21 | * Abstraction of an ISIS Link. |
... | @@ -25,58 +23,72 @@ import java.util.List; | ... | @@ -25,58 +23,72 @@ import java.util.List; |
25 | public interface IsisLink { | 23 | public interface IsisLink { |
26 | 24 | ||
27 | /** | 25 | /** |
28 | - * Returns IP address of the Router. | 26 | + * Returns the remote system ID. |
29 | * | 27 | * |
30 | - * @return IP address of router | 28 | + * @return remote system ID |
31 | */ | 29 | */ |
32 | - IpAddress remoteRouterId(); | 30 | + String remoteSystemId(); |
33 | 31 | ||
34 | /** | 32 | /** |
35 | - * Returns the area ID for this device. | 33 | + * Returns the local system ID. |
36 | * | 34 | * |
37 | - * @return the area ID | 35 | + * @return local system ID |
38 | */ | 36 | */ |
39 | - int areaIdOfInterface(); | 37 | + String localSystemId(); |
40 | 38 | ||
41 | /** | 39 | /** |
42 | * Returns IP address of the interface. | 40 | * Returns IP address of the interface. |
43 | * | 41 | * |
44 | * @return IP address of the interface | 42 | * @return IP address of the interface |
45 | */ | 43 | */ |
46 | - IpAddress interfaceIp(); | 44 | + Ip4Address interfaceIp(); |
45 | + | ||
46 | + /** | ||
47 | + * Returns IP address of the neighbor. | ||
48 | + * | ||
49 | + * @return IP address of the neighbor | ||
50 | + */ | ||
51 | + Ip4Address neighborIp(); | ||
47 | 52 | ||
48 | /** | 53 | /** |
49 | - * Returns the list of link TED details. | 54 | + * Returns the link TED details. |
50 | * | 55 | * |
51 | - * @return linkTed list of link TED | 56 | + * @return linkTed link TED |
52 | */ | 57 | */ |
53 | - List<IsisLinkTed> linkTed(); | 58 | + IsisLinkTed linkTed(); |
54 | 59 | ||
55 | /** | 60 | /** |
56 | - * Sets IP address of the router. | 61 | + * Sets remote system ID. |
57 | * | 62 | * |
58 | - * @param routerIp router's IP address | 63 | + * @param remoteSystemId remote system ID |
59 | */ | 64 | */ |
60 | - void setRouterIp(IpAddress routerIp); | 65 | + void setRemoteSystemId(String remoteSystemId); |
61 | 66 | ||
62 | /** | 67 | /** |
63 | - * Sets the area ID for this device. | 68 | + * Sets local system ID. |
64 | * | 69 | * |
65 | - * @param areaIdOfInterface area ID | 70 | + * @param localSystemId remote system ID |
66 | */ | 71 | */ |
67 | - void setAreaIdOfInterface(int areaIdOfInterface); | 72 | + void setLocalSystemId(String localSystemId); |
68 | 73 | ||
69 | /** | 74 | /** |
70 | * Sets IP address of the interface. | 75 | * Sets IP address of the interface. |
71 | * | 76 | * |
72 | * @param interfaceIp IP address of the interface | 77 | * @param interfaceIp IP address of the interface |
73 | */ | 78 | */ |
74 | - void setInterfaceIp(IpAddress interfaceIp); | 79 | + void setInterfaceIp(Ip4Address interfaceIp); |
80 | + | ||
81 | + /** | ||
82 | + * Sets IP address of the neighbor. | ||
83 | + * | ||
84 | + * @param neighborIp IP address of the neighbor | ||
85 | + */ | ||
86 | + void setNeighborIp(Ip4Address neighborIp); | ||
75 | 87 | ||
76 | /** | 88 | /** |
77 | - * Sets the list of link TED. | 89 | + * Sets the link TED information. |
78 | * | 90 | * |
79 | - * @param linkTed list of link TED | 91 | + * @param linkTed link TED |
80 | */ | 92 | */ |
81 | - void setLinkTed(List<IsisLinkTed> linkTed); | 93 | + void setLinkTed(IsisLinkTed linkTed); |
82 | } | 94 | } | ... | ... |
... | @@ -23,16 +23,14 @@ public interface IsisLinkListener { | ... | @@ -23,16 +23,14 @@ public interface IsisLinkListener { |
23 | /** | 23 | /** |
24 | * Notifies that we got a link from network. | 24 | * Notifies that we got a link from network. |
25 | * | 25 | * |
26 | - * @param isisRouter router instance | 26 | + * @param isisLink link instance |
27 | - * @param isisLinkTed link TED information of router | ||
28 | */ | 27 | */ |
29 | - void addLink(IsisRouter isisRouter, IsisLinkTed isisLinkTed); | 28 | + void addLink(IsisLink isisLink); |
30 | 29 | ||
31 | /** | 30 | /** |
32 | * Notifies that a link got removed from network. | 31 | * Notifies that a link got removed from network. |
33 | * | 32 | * |
34 | - * @param isisRouter router instance | 33 | + * @param isisLink link instance |
35 | - * @param isisLinkTed isis link ted infromation | ||
36 | */ | 34 | */ |
37 | - void deleteLink(IsisRouter isisRouter, IsisLinkTed isisLinkTed); | 35 | + void deleteLink(IsisLink isisLink); |
38 | } | 36 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.isis.controller.topology; | 16 | package org.onosproject.isis.controller.topology; |
17 | 17 | ||
18 | import org.onlab.packet.Ip4Address; | 18 | import org.onlab.packet.Ip4Address; |
19 | -import org.onlab.packet.Ip6Address; | ||
20 | import org.onlab.util.Bandwidth; | 19 | import org.onlab.util.Bandwidth; |
21 | 20 | ||
22 | import java.util.List; | 21 | import java.util.List; |
... | @@ -27,114 +26,100 @@ import java.util.List; | ... | @@ -27,114 +26,100 @@ import java.util.List; |
27 | public interface IsisLinkTed { | 26 | public interface IsisLinkTed { |
28 | 27 | ||
29 | /** | 28 | /** |
30 | - * Provides maximum bandwidth can be used on the link. | 29 | + * Gets the administrative group. |
31 | * | 30 | * |
32 | - * @return maximum bandwidth | 31 | + * @return administrative group |
33 | */ | 32 | */ |
34 | - Bandwidth maximumLink(); | 33 | + int administrativeGroup(); |
35 | 34 | ||
36 | /** | 35 | /** |
37 | - * Sets maximum band width. | 36 | + * Sets the administrative group. |
38 | * | 37 | * |
39 | - * @param bandwidth maximum bandwidth | 38 | + * @param administrativeGroup administrative group |
40 | */ | 39 | */ |
41 | - void setMaximumLink(Bandwidth bandwidth); | 40 | + void setAdministrativeGroup(int administrativeGroup); |
42 | 41 | ||
43 | /** | 42 | /** |
44 | - * Amount of bandwidth reservable on the link. | 43 | + * Provides the IPv4 interface address. |
45 | * | 44 | * |
46 | - * @return unreserved bandwidth | 45 | + * @return IPv4 interface address |
47 | - */ | ||
48 | - List<Bandwidth> maxUnResBandwidth(); | ||
49 | - | ||
50 | - /** | ||
51 | - * Sets max bandwidth that is not reserved on the link. | ||
52 | - * | ||
53 | - * @param bandwidth max bandwidth that is not reserved on the link | ||
54 | - */ | ||
55 | - void setMaxUnResBandwidth(Bandwidth bandwidth); | ||
56 | - | ||
57 | - /** | ||
58 | - * Provides max bandwidth that can be reserved on the link. | ||
59 | - * | ||
60 | - * @return max bandwidth reserved | ||
61 | */ | 46 | */ |
62 | - Bandwidth maxReserved(); | 47 | + Ip4Address ipv4InterfaceAddress(); |
63 | 48 | ||
64 | /** | 49 | /** |
65 | - * Sets max bandwidth that can be reserved on the link. | 50 | + * Sets the IPv4 interface address. |
66 | * | 51 | * |
67 | - * @param bandwidth max bandwidth that can be reserved on the link | 52 | + * @param interfaceAddress IPv4 interface address |
68 | */ | 53 | */ |
69 | - void setMaxReserved(Bandwidth bandwidth); | 54 | + void setIpv4InterfaceAddress(Ip4Address interfaceAddress); |
70 | 55 | ||
71 | /** | 56 | /** |
72 | - * Provides Traffic Engineering metric for the link. | 57 | + * Provides the IPv4 neighbor address. |
73 | * | 58 | * |
74 | - * @return Traffic Engineering metric | 59 | + * @return IPv4 neighbor address |
75 | */ | 60 | */ |
76 | - int teMetric(); | 61 | + Ip4Address ipv4NeighborAddress(); |
77 | 62 | ||
78 | /** | 63 | /** |
79 | - * Sets Traffic Engineering metric for the link. | 64 | + * Sets the IPv4 neighbor address. |
80 | * | 65 | * |
81 | - * @param teMetric Traffic Engineering metric for the link | 66 | + * @param neighborAddress IPv4 neighbor address |
82 | */ | 67 | */ |
83 | - void setTeMetric(int teMetric); | 68 | + void setIpv4NeighborAddress(Ip4Address neighborAddress); |
84 | 69 | ||
85 | /** | 70 | /** |
86 | - * Provides IPv4 router-Id of local node. | 71 | + * Gets the maximum link bandwidth. |
87 | * | 72 | * |
88 | - * @return IPv4 router-Id of local node | 73 | + * @return maximum link bandwidth |
89 | */ | 74 | */ |
90 | - List<Ip4Address> ipv4LocRouterId(); | 75 | + Bandwidth maximumLinkBandwidth(); |
91 | 76 | ||
92 | /** | 77 | /** |
93 | - * Sets IPv4 router-Id of local node. | 78 | + * Sets the maximum link bandwidth. |
94 | * | 79 | * |
95 | - * @param routerIds IPv4 router-Id of local node | 80 | + * @param bandwidth maximum link bandwidth |
96 | */ | 81 | */ |
97 | - void setIpv4LocRouterId(List<Ip4Address> routerIds); | 82 | + void setMaximumLinkBandwidth(Bandwidth bandwidth); |
98 | 83 | ||
99 | /** | 84 | /** |
100 | - * Provides IPv6 router-Id of local node. | 85 | + * Provides max bandwidth that can be reservable on the link. |
101 | * | 86 | * |
102 | - * @return IPv6 router-Id of local node | 87 | + * @return max bandwidth reservable |
103 | */ | 88 | */ |
104 | - List<Ip6Address> ipv6LocRouterId(); | 89 | + Bandwidth maximumReservableLinkBandwidth(); |
105 | 90 | ||
106 | /** | 91 | /** |
107 | - * Sets IPv6 router-Id of local node. | 92 | + * Sets max bandwidth that can be reservable on the link. |
108 | * | 93 | * |
109 | - * @param routerIds IPv6 router-Id of local node | 94 | + * @param bandwidth max bandwidth that can be reservable on the link |
110 | */ | 95 | */ |
111 | - void setIpv6LocRouterId(List<Ip6Address> routerIds); | 96 | + void setMaximumReservableLinkBandwidth(Bandwidth bandwidth); |
112 | 97 | ||
113 | /** | 98 | /** |
114 | - * Provides IPv4 router-Id of remote node. | 99 | + * Amount of bandwidth unreserved on the link. |
115 | * | 100 | * |
116 | - * @return IPv4 router-Id of remote node | 101 | + * @return unreserved bandwidth |
117 | */ | 102 | */ |
118 | - List<Ip4Address> ipv4RemRouterId(); | 103 | + List<Bandwidth> unreservedBandwidth(); |
119 | 104 | ||
120 | /** | 105 | /** |
121 | - * Sets IPv4 router-Id of remote node. | 106 | + * Sets the bandwidth unreserved on the link. |
122 | * | 107 | * |
123 | - * @param routerIds IPv4 router-Id of remote node | 108 | + * @param bandwidth bandwidth unreserved |
124 | */ | 109 | */ |
125 | - void setIpv4RemRouterId(List<Ip4Address> routerIds); | 110 | + void setUnreservedBandwidth(List<Bandwidth> bandwidth); |
126 | 111 | ||
127 | /** | 112 | /** |
128 | - * Provides IPv6 router-Id of remote node. | 113 | + * Provides Traffic Engineering metric for the link. |
129 | * | 114 | * |
130 | - * @return IPv6 router-Id of remote node | 115 | + * @return Traffic Engineering Default metric |
131 | */ | 116 | */ |
132 | - List<Ip6Address> ipv6RemRouterId(); | 117 | + long teDefaultMetric(); |
133 | 118 | ||
134 | /** | 119 | /** |
135 | - * Sets IPv6 router-Id of remote node. | 120 | + * Sets Traffic Engineering metric for the link. |
136 | * | 121 | * |
137 | - * @param routerIds IPv6 router-Id of remote node | 122 | + * @param teMetric Traffic Engineering Default metric for the link |
138 | */ | 123 | */ |
139 | - void setIpv6RemRouterId(List<Ip6Address> routerIds); | 124 | + void setTeDefaultMetric(long teMetric); |
140 | } | 125 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -23,11 +23,11 @@ import org.onlab.packet.Ip4Address; | ... | @@ -23,11 +23,11 @@ import org.onlab.packet.Ip4Address; |
23 | public interface IsisRouter { | 23 | public interface IsisRouter { |
24 | 24 | ||
25 | /** | 25 | /** |
26 | - * Returns IP address of the router. | 26 | + * Returns system ID for the router. |
27 | * | 27 | * |
28 | - * @return IP address of the router | 28 | + * @return system ID of the router |
29 | */ | 29 | */ |
30 | - Ip4Address routerIp(); | 30 | + String systemId(); |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Returns IP address of the interface. | 33 | * Returns IP address of the interface. |
... | @@ -37,9 +37,44 @@ public interface IsisRouter { | ... | @@ -37,9 +37,44 @@ public interface IsisRouter { |
37 | Ip4Address interfaceId(); | 37 | Ip4Address interfaceId(); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | - * Sets IP address of the Router. | 40 | + * Gets IP address of the interface. |
41 | * | 41 | * |
42 | - * @param routerIp IP address of the router | 42 | + * @param interfaceId IP address of the interface |
43 | */ | 43 | */ |
44 | - void setRouterIp(Ip4Address routerIp); | 44 | + void setInterfaceId(Ip4Address interfaceId); |
45 | + | ||
46 | + /** | ||
47 | + * Sets system ID of the Router. | ||
48 | + * | ||
49 | + * @param systemId system ID of the router | ||
50 | + */ | ||
51 | + void setSystemId(String systemId); | ||
52 | + | ||
53 | + /** | ||
54 | + * Gets neighbours ID. | ||
55 | + * | ||
56 | + * @return neighbour ID | ||
57 | + */ | ||
58 | + Ip4Address neighborRouterId(); | ||
59 | + | ||
60 | + /** | ||
61 | + * Sets the neighbour Id. | ||
62 | + * | ||
63 | + * @param neighbourId neighbour Id | ||
64 | + */ | ||
65 | + void setNeighborRouterId(Ip4Address neighbourId); | ||
66 | + | ||
67 | + /** | ||
68 | + * Gets if the router id DIS or not. | ||
69 | + * | ||
70 | + * @return true if the router is DIS else false | ||
71 | + */ | ||
72 | + boolean isDis(); | ||
73 | + | ||
74 | + /** | ||
75 | + * Sets if the router id DIS or not. | ||
76 | + * | ||
77 | + * @param dis true if the router is DIS else false | ||
78 | + */ | ||
79 | + void setDis(boolean dis); | ||
45 | } | 80 | } | ... | ... |
protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterId.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 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 | +package org.onosproject.isis.controller.topology; | ||
18 | + | ||
19 | +import java.net.URI; | ||
20 | +import java.net.URISyntaxException; | ||
21 | +import java.util.Objects; | ||
22 | + | ||
23 | +import static com.google.common.base.Preconditions.checkArgument; | ||
24 | + | ||
25 | +/** | ||
26 | + * Represents an ISIS router id. | ||
27 | + */ | ||
28 | +public class IsisRouterId { | ||
29 | + | ||
30 | + private static final String SCHEME = "l3"; | ||
31 | + private static final long UNKNOWN = 0; | ||
32 | + private final String ipAddress; | ||
33 | + | ||
34 | + /** | ||
35 | + * Creates an instance of ISIS router id. | ||
36 | + * | ||
37 | + * @param ipAddress IP address of the router | ||
38 | + */ | ||
39 | + public IsisRouterId(String ipAddress) { | ||
40 | + this.ipAddress = ipAddress; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Creates an instance from ip address. | ||
45 | + * | ||
46 | + * @param ipAddress IP address | ||
47 | + * @return ISIS router id instance | ||
48 | + */ | ||
49 | + public static IsisRouterId isisRouterId(String ipAddress) { | ||
50 | + return new IsisRouterId(ipAddress); | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Creates ISIS router id instance from the URI. | ||
55 | + * | ||
56 | + * @param uri device URI | ||
57 | + * @return ISIS router id instance | ||
58 | + */ | ||
59 | + public static IsisRouterId isisRouterId(URI uri) { | ||
60 | + checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme"); | ||
61 | + return new IsisRouterId(uri.getSchemeSpecificPart()); | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Returns device URI from the given router id. | ||
66 | + * | ||
67 | + * @param isisRouterId router id instance | ||
68 | + * @return device URI | ||
69 | + */ | ||
70 | + public static URI uri(IsisRouterId isisRouterId) { | ||
71 | + return uri(isisRouterId.ipAddress()); | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Returns device URI from the given IP address. | ||
76 | + * | ||
77 | + * @param ipAddress device IP address | ||
78 | + * @return device URI | ||
79 | + */ | ||
80 | + public static URI uri(String ipAddress) { | ||
81 | + try { | ||
82 | + return new URI(SCHEME, ipAddress, null); | ||
83 | + } catch (URISyntaxException e) { | ||
84 | + return null; | ||
85 | + } | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Returns the IP address. | ||
90 | + * | ||
91 | + * @return IP address | ||
92 | + */ | ||
93 | + public String ipAddress() { | ||
94 | + return ipAddress; | ||
95 | + } | ||
96 | + | ||
97 | + @Override | ||
98 | + public String toString() { | ||
99 | + return ipAddress; | ||
100 | + } | ||
101 | + | ||
102 | + @Override | ||
103 | + public boolean equals(Object other) { | ||
104 | + if (!(other instanceof IsisRouterId)) { | ||
105 | + return false; | ||
106 | + } | ||
107 | + | ||
108 | + IsisRouterId otherIsisRouterId = (IsisRouterId) other; | ||
109 | + return Objects.equals(ipAddress, otherIsisRouterId.ipAddress); | ||
110 | + } | ||
111 | + | ||
112 | + @Override | ||
113 | + public int hashCode() { | ||
114 | + return Objects.hash(ipAddress); | ||
115 | + } | ||
116 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -34,11 +34,4 @@ public interface IsisRouterListener { | ... | @@ -34,11 +34,4 @@ public interface IsisRouterListener { |
34 | * @param isisRouter ISIS router instance | 34 | * @param isisRouter ISIS router instance |
35 | */ | 35 | */ |
36 | void routerRemoved(IsisRouter isisRouter); | 36 | void routerRemoved(IsisRouter isisRouter); |
37 | - | ||
38 | - /** | ||
39 | - * Notifies that the router has changed in some way. | ||
40 | - * | ||
41 | - * @param isisRouter ISIS router instance | ||
42 | - */ | ||
43 | - void routerChanged(IsisRouter isisRouter); | ||
44 | } | 37 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/LinkInformation.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 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.isis.controller.topology; | ||
17 | + | ||
18 | +import org.onlab.packet.Ip4Address; | ||
19 | + | ||
20 | +/** | ||
21 | + * Representation of an ISIS link information. | ||
22 | + */ | ||
23 | +public interface LinkInformation { | ||
24 | + | ||
25 | + /** | ||
26 | + * Gets link id. | ||
27 | + * | ||
28 | + * @return link id | ||
29 | + */ | ||
30 | + String linkId(); | ||
31 | + | ||
32 | + /** | ||
33 | + * Sets link id. | ||
34 | + * | ||
35 | + * @param linkId link id | ||
36 | + */ | ||
37 | + void setLinkId(String linkId); | ||
38 | + | ||
39 | + /** | ||
40 | + * Gets whether link information is already created or not. | ||
41 | + * | ||
42 | + * @return true if link information is already created else false | ||
43 | + */ | ||
44 | + boolean isAlreadyCreated(); | ||
45 | + | ||
46 | + /** | ||
47 | + * Sets link information is already created or not. | ||
48 | + * | ||
49 | + * @param alreadyCreated true if link information is already created else false | ||
50 | + */ | ||
51 | + void setAlreadyCreated(boolean alreadyCreated); | ||
52 | + | ||
53 | + | ||
54 | + /** | ||
55 | + * Returns link destination ID. | ||
56 | + * | ||
57 | + * @return link destination ID | ||
58 | + */ | ||
59 | + String linkDestinationId(); | ||
60 | + | ||
61 | + /** | ||
62 | + * Sets link destination id. | ||
63 | + * | ||
64 | + * @param linkDestinationId link destination id | ||
65 | + */ | ||
66 | + void setLinkDestinationId(String linkDestinationId); | ||
67 | + | ||
68 | + /** | ||
69 | + * Gets link source id. | ||
70 | + * | ||
71 | + * @return link source id | ||
72 | + */ | ||
73 | + String linkSourceId(); | ||
74 | + | ||
75 | + /** | ||
76 | + * Sets link source id. | ||
77 | + * | ||
78 | + * @param linkSourceId link source id | ||
79 | + */ | ||
80 | + void setLinkSourceId(String linkSourceId); | ||
81 | + | ||
82 | + /** | ||
83 | + * Gets interface ip address. | ||
84 | + * | ||
85 | + * @return interface ip address | ||
86 | + */ | ||
87 | + Ip4Address interfaceIp(); | ||
88 | + | ||
89 | + /** | ||
90 | + * Sets interface ip address. | ||
91 | + * | ||
92 | + * @param interfaceIp interface ip address | ||
93 | + */ | ||
94 | + void setInterfaceIp(Ip4Address interfaceIp); | ||
95 | + | ||
96 | + /** | ||
97 | + * Gets neighbor ip address. | ||
98 | + * | ||
99 | + * @return neighbor ip address | ||
100 | + */ | ||
101 | + Ip4Address neighborIp(); | ||
102 | + | ||
103 | + /** | ||
104 | + * Sets neighbor ip address. | ||
105 | + * | ||
106 | + * @param neighborIp neighbor ip address | ||
107 | + */ | ||
108 | + void setNeighborIp(Ip4Address neighborIp); | ||
109 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 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.isis.controller.topology; | ||
17 | + | ||
18 | +import java.util.Map; | ||
19 | + | ||
20 | +/** | ||
21 | + * Represents IP topology for ISIS device and link details. | ||
22 | + */ | ||
23 | +public interface TopologyForDeviceAndLink { | ||
24 | + | ||
25 | + /** | ||
26 | + * Gets the device information. | ||
27 | + * | ||
28 | + * @return device information | ||
29 | + */ | ||
30 | + Map<String, DeviceInformation> deviceInformationMap(); | ||
31 | + | ||
32 | + /** | ||
33 | + * Sets the device information. | ||
34 | + * | ||
35 | + * @param key system ID of the device as key | ||
36 | + * @param deviceInformationMap device information instance | ||
37 | + */ | ||
38 | + void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap); | ||
39 | + | ||
40 | + /** | ||
41 | + * Gets the link information. | ||
42 | + * | ||
43 | + * @return link information | ||
44 | + */ | ||
45 | + Map<String, LinkInformation> linkInformationMap(); | ||
46 | + | ||
47 | + /** | ||
48 | + * Sets link information. | ||
49 | + * | ||
50 | + * @param key system ID of the device as key | ||
51 | + * @param linkInformationMap link information instance | ||
52 | + */ | ||
53 | + void setLinkInformationMap(String key, LinkInformation linkInformationMap); | ||
54 | + | ||
55 | + /** | ||
56 | + * Removes link information. | ||
57 | + * | ||
58 | + * @param key key used to remove from map | ||
59 | + */ | ||
60 | + void removeLinkInformationMap(String key); | ||
61 | + | ||
62 | + /** | ||
63 | + * Removes device information. | ||
64 | + * | ||
65 | + * @param key key used to remove from map | ||
66 | + */ | ||
67 | + void removeDeviceInformationMap(String key); | ||
68 | + | ||
69 | + /** | ||
70 | + * Removes links from linkInformationMap. | ||
71 | + * | ||
72 | + * @param linkId ID | ||
73 | + */ | ||
74 | + void removeLinks(String linkId); | ||
75 | + | ||
76 | + /** | ||
77 | + * Gets deviceInformation as map. | ||
78 | + * | ||
79 | + * @return deviceInformationMap to delete from core | ||
80 | + */ | ||
81 | + Map<String, DeviceInformation> deviceInformationMapToDelete(); | ||
82 | + | ||
83 | + /** | ||
84 | + * Sets deviceInformation as map. | ||
85 | + * | ||
86 | + * @param key key used to add in map | ||
87 | + * @param deviceInformationMapToDelete device information to delete from map | ||
88 | + */ | ||
89 | + void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete); | ||
90 | + | ||
91 | + /** | ||
92 | + * Removes Device Information from deviceInformationMapToDelete. | ||
93 | + * | ||
94 | + * @param key key to remove from map | ||
95 | + */ | ||
96 | + void removeDeviceInformationMapFromDeleteMap(String key); | ||
97 | + | ||
98 | + /** | ||
99 | + * Gets deviceInformation as map for Point-To-Point. | ||
100 | + * | ||
101 | + * @return deviceInformationMap | ||
102 | + */ | ||
103 | + Map<String, DeviceInformation> deviceInformationMapForPointToPoint(); | ||
104 | + | ||
105 | + /** | ||
106 | + * Sets deviceInformation as map for Point-To-Point.. | ||
107 | + * | ||
108 | + * @param key key to add to map | ||
109 | + * @param deviceInformationMap device information map | ||
110 | + */ | ||
111 | + void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap); | ||
112 | + | ||
113 | + /** | ||
114 | + * Gets linkInformation as map for PointToPoint. | ||
115 | + * | ||
116 | + * @return linkInformationMap | ||
117 | + */ | ||
118 | + Map<String, LinkInformation> linkInformationMapForPointToPoint(); | ||
119 | + | ||
120 | + /** | ||
121 | + * Sets linkInformation as map for PointToPoint. | ||
122 | + * | ||
123 | + * @param key key to add link information to map | ||
124 | + * @param linkInformationMap link information to add | ||
125 | + */ | ||
126 | + void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap); | ||
127 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -30,6 +30,9 @@ import org.onosproject.isis.controller.IsisInterface; | ... | @@ -30,6 +30,9 @@ import org.onosproject.isis.controller.IsisInterface; |
30 | import org.onosproject.isis.controller.IsisNetworkType; | 30 | import org.onosproject.isis.controller.IsisNetworkType; |
31 | import org.onosproject.isis.controller.IsisProcess; | 31 | import org.onosproject.isis.controller.IsisProcess; |
32 | import org.onosproject.isis.controller.IsisRouterType; | 32 | import org.onosproject.isis.controller.IsisRouterType; |
33 | +import org.onosproject.isis.controller.topology.IsisAgent; | ||
34 | +import org.onosproject.isis.controller.topology.IsisLink; | ||
35 | +import org.onosproject.isis.controller.topology.IsisRouter; | ||
33 | import org.onosproject.isis.io.util.IsisConstants; | 36 | import org.onosproject.isis.io.util.IsisConstants; |
34 | import org.slf4j.Logger; | 37 | import org.slf4j.Logger; |
35 | import org.slf4j.LoggerFactory; | 38 | import org.slf4j.LoggerFactory; |
... | @@ -43,6 +46,7 @@ import java.util.Enumeration; | ... | @@ -43,6 +46,7 @@ import java.util.Enumeration; |
43 | import java.util.List; | 46 | import java.util.List; |
44 | import java.util.concurrent.Executors; | 47 | import java.util.concurrent.Executors; |
45 | import java.util.concurrent.ScheduledExecutorService; | 48 | import java.util.concurrent.ScheduledExecutorService; |
49 | +import java.util.concurrent.ScheduledFuture; | ||
46 | import java.util.concurrent.TimeUnit; | 50 | import java.util.concurrent.TimeUnit; |
47 | 51 | ||
48 | import static org.onlab.util.Tools.groupedThreads; | 52 | import static org.onlab.util.Tools.groupedThreads; |
... | @@ -64,15 +68,29 @@ public class Controller { | ... | @@ -64,15 +68,29 @@ public class Controller { |
64 | private ScheduledExecutorService connectExecutor = null; | 68 | private ScheduledExecutorService connectExecutor = null; |
65 | private int connectRetryCounter = 0; | 69 | private int connectRetryCounter = 0; |
66 | private int connectRetryTime; | 70 | private int connectRetryTime; |
71 | + private ScheduledFuture future = null; | ||
72 | + private IsisAgent agent; | ||
67 | 73 | ||
68 | /** | 74 | /** |
69 | * Deactivates ISIS controller. | 75 | * Deactivates ISIS controller. |
70 | */ | 76 | */ |
71 | public void isisDeactivate() { | 77 | public void isisDeactivate() { |
78 | + disconnectExecutor(); | ||
79 | + processes = null; | ||
72 | peerExecFactory.shutdown(); | 80 | peerExecFactory.shutdown(); |
73 | } | 81 | } |
74 | 82 | ||
75 | /** | 83 | /** |
84 | + * Sets ISIS agent. | ||
85 | + * | ||
86 | + * @param agent ISIS agent instance | ||
87 | + */ | ||
88 | + public void setAgent(IsisAgent agent) { | ||
89 | + this.agent = agent; | ||
90 | + } | ||
91 | + | ||
92 | + | ||
93 | + /** | ||
76 | * Updates the processes configuration. | 94 | * Updates the processes configuration. |
77 | * | 95 | * |
78 | * @param jsonNode json node instance | 96 | * @param jsonNode json node instance |
... | @@ -462,7 +480,8 @@ public class Controller { | ... | @@ -462,7 +480,8 @@ public class Controller { |
462 | */ | 480 | */ |
463 | public void disconnectExecutor() { | 481 | public void disconnectExecutor() { |
464 | if (connectExecutor != null) { | 482 | if (connectExecutor != null) { |
465 | - connectExecutor.shutdown(); | 483 | + future.cancel(true); |
484 | + connectExecutor.shutdownNow(); | ||
466 | connectExecutor = null; | 485 | connectExecutor = null; |
467 | } | 486 | } |
468 | } | 487 | } |
... | @@ -480,10 +499,55 @@ public class Controller { | ... | @@ -480,10 +499,55 @@ public class Controller { |
480 | * @param retryDelay retry delay | 499 | * @param retryDelay retry delay |
481 | */ | 500 | */ |
482 | private void scheduleConnectionRetry(long retryDelay) { | 501 | private void scheduleConnectionRetry(long retryDelay) { |
483 | - if (this.connectExecutor == null) { | 502 | + if (connectExecutor == null) { |
484 | - this.connectExecutor = Executors.newSingleThreadScheduledExecutor(); | 503 | + connectExecutor = Executors.newSingleThreadScheduledExecutor(); |
504 | + } | ||
505 | + future = connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES); | ||
506 | + } | ||
507 | + | ||
508 | + /** | ||
509 | + * Adds device details. | ||
510 | + * | ||
511 | + * @param isisRouter ISIS router instance | ||
512 | + */ | ||
513 | + public void addDeviceDetails(IsisRouter isisRouter) { | ||
514 | + agent.addConnectedRouter(isisRouter); | ||
515 | + } | ||
516 | + | ||
517 | + /** | ||
518 | + * Removes device details. | ||
519 | + * | ||
520 | + * @param isisRouter Isis router instance | ||
521 | + */ | ||
522 | + public void removeDeviceDetails(IsisRouter isisRouter) { | ||
523 | + agent.removeConnectedRouter(isisRouter); | ||
524 | + } | ||
525 | + | ||
526 | + /** | ||
527 | + * Adds link details. | ||
528 | + * | ||
529 | + * @param isisLink ISIS link instance | ||
530 | + */ | ||
531 | + public void addLinkDetails(IsisLink isisLink) { | ||
532 | + agent.addLink(isisLink); | ||
533 | + } | ||
534 | + | ||
535 | + /** | ||
536 | + * Removes link details. | ||
537 | + * | ||
538 | + * @param isisLink ISIS link instance | ||
539 | + */ | ||
540 | + public void removeLinkDetails(IsisLink isisLink) { | ||
541 | + agent.deleteLink(isisLink); | ||
485 | } | 542 | } |
486 | - this.connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES); | 543 | + |
544 | + /** | ||
545 | + * Returns the isisAgent instance. | ||
546 | + * | ||
547 | + * @return agent | ||
548 | + */ | ||
549 | + public IsisAgent agent() { | ||
550 | + return this.agent; | ||
487 | } | 551 | } |
488 | 552 | ||
489 | /** | 553 | /** | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.isis.controller.impl; | 16 | package org.onosproject.isis.controller.impl; |
17 | 17 | ||
18 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
19 | +import com.google.common.collect.Sets; | ||
19 | import org.apache.felix.scr.annotations.Activate; | 20 | import org.apache.felix.scr.annotations.Activate; |
20 | import org.apache.felix.scr.annotations.Component; | 21 | import org.apache.felix.scr.annotations.Component; |
21 | import org.apache.felix.scr.annotations.Deactivate; | 22 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -24,12 +25,18 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -24,12 +25,18 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
24 | import org.apache.felix.scr.annotations.Service; | 25 | import org.apache.felix.scr.annotations.Service; |
25 | import org.onosproject.isis.controller.IsisController; | 26 | import org.onosproject.isis.controller.IsisController; |
26 | import org.onosproject.isis.controller.IsisProcess; | 27 | import org.onosproject.isis.controller.IsisProcess; |
28 | +import org.onosproject.isis.controller.topology.IsisAgent; | ||
29 | +import org.onosproject.isis.controller.topology.IsisLink; | ||
30 | +import org.onosproject.isis.controller.topology.IsisLinkListener; | ||
31 | +import org.onosproject.isis.controller.topology.IsisRouter; | ||
27 | import org.onosproject.isis.controller.topology.IsisRouterListener; | 32 | import org.onosproject.isis.controller.topology.IsisRouterListener; |
28 | import org.onosproject.net.driver.DriverService; | 33 | import org.onosproject.net.driver.DriverService; |
29 | import org.slf4j.Logger; | 34 | import org.slf4j.Logger; |
30 | import org.slf4j.LoggerFactory; | 35 | import org.slf4j.LoggerFactory; |
31 | 36 | ||
37 | +import java.util.HashSet; | ||
32 | import java.util.List; | 38 | import java.util.List; |
39 | +import java.util.Set; | ||
33 | 40 | ||
34 | /** | 41 | /** |
35 | * Represents ISIS controller implementation. | 42 | * Represents ISIS controller implementation. |
... | @@ -42,10 +49,14 @@ public class DefaultIsisController implements IsisController { | ... | @@ -42,10 +49,14 @@ public class DefaultIsisController implements IsisController { |
42 | private final Controller controller = new Controller(); | 49 | private final Controller controller = new Controller(); |
43 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 50 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
44 | protected DriverService driverService; | 51 | protected DriverService driverService; |
52 | + protected Set<IsisRouterListener> isisRouterListener = new HashSet<>(); | ||
53 | + protected Set<IsisLinkListener> isisLinkListener = Sets.newHashSet(); | ||
54 | + protected IsisAgent agent = new InternalDeviceConfig(); | ||
45 | 55 | ||
46 | @Activate | 56 | @Activate |
47 | public void activate() { | 57 | public void activate() { |
48 | log.debug("ISISControllerImpl activate"); | 58 | log.debug("ISISControllerImpl activate"); |
59 | + controller.setAgent(agent); | ||
49 | } | 60 | } |
50 | 61 | ||
51 | @Deactivate | 62 | @Deactivate |
... | @@ -55,6 +66,38 @@ public class DefaultIsisController implements IsisController { | ... | @@ -55,6 +66,38 @@ public class DefaultIsisController implements IsisController { |
55 | } | 66 | } |
56 | 67 | ||
57 | @Override | 68 | @Override |
69 | + public void addRouterListener(IsisRouterListener listener) { | ||
70 | + if (!isisRouterListener.contains(listener)) { | ||
71 | + this.isisRouterListener.add(listener); | ||
72 | + } | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public void removeRouterListener(IsisRouterListener listener) { | ||
77 | + this.isisRouterListener.remove(listener); | ||
78 | + } | ||
79 | + | ||
80 | + @Override | ||
81 | + public void addLinkListener(IsisLinkListener listener) { | ||
82 | + isisLinkListener.add(listener); | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public void removeLinkListener(IsisLinkListener listener) { | ||
87 | + isisLinkListener.remove(listener); | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public Set<IsisRouterListener> listener() { | ||
92 | + return isisRouterListener; | ||
93 | + } | ||
94 | + | ||
95 | + @Override | ||
96 | + public Set<IsisLinkListener> linkListener() { | ||
97 | + return isisLinkListener; | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
58 | public List<IsisProcess> allConfiguredProcesses() { | 101 | public List<IsisProcess> allConfiguredProcesses() { |
59 | List<IsisProcess> processes = controller.getAllConfiguredProcesses(); | 102 | List<IsisProcess> processes = controller.getAllConfiguredProcesses(); |
60 | return processes; | 103 | return processes; |
... | @@ -70,13 +113,37 @@ public class DefaultIsisController implements IsisController { | ... | @@ -70,13 +113,37 @@ public class DefaultIsisController implements IsisController { |
70 | } | 113 | } |
71 | } | 114 | } |
72 | 115 | ||
116 | + /** | ||
117 | + * Notifier for internal ISIS device and link changes. | ||
118 | + */ | ||
119 | + private class InternalDeviceConfig implements IsisAgent { | ||
73 | @Override | 120 | @Override |
74 | - public void addRouterListener(IsisRouterListener isisRouterListener) { | 121 | + public boolean addConnectedRouter(IsisRouter isisRouter) { |
75 | - log.debug("IsisControllerImpl::addRouterListener..."); | 122 | + for (IsisRouterListener l : listener()) { |
123 | + l.routerAdded(isisRouter); | ||
124 | + } | ||
125 | + return true; | ||
76 | } | 126 | } |
77 | 127 | ||
78 | @Override | 128 | @Override |
79 | - public void removeRouterListener(IsisRouterListener isisRouterListener) { | 129 | + public void removeConnectedRouter(IsisRouter isisRouter) { |
80 | - log.debug("IsisControllerImpl::removeRouterListener..."); | 130 | + for (IsisRouterListener l : listener()) { |
131 | + l.routerRemoved(isisRouter); | ||
132 | + } | ||
133 | + } | ||
134 | + | ||
135 | + @Override | ||
136 | + public void addLink(IsisLink isisLink) { | ||
137 | + for (IsisLinkListener l : linkListener()) { | ||
138 | + l.addLink(isisLink); | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
142 | + @Override | ||
143 | + public void deleteLink(IsisLink isisLink) { | ||
144 | + for (IsisLinkListener l : linkListener()) { | ||
145 | + l.deleteLink(isisLink); | ||
146 | + } | ||
147 | + } | ||
81 | } | 148 | } |
82 | } | 149 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
100644 → 100755
... | @@ -356,6 +356,8 @@ public class DefaultIsisNeighbor implements IsisNeighbor { | ... | @@ -356,6 +356,8 @@ public class DefaultIsisNeighbor implements IsisNeighbor { |
356 | stopInactivityTimeCheck(); | 356 | stopInactivityTimeCheck(); |
357 | stopHoldingTimeCheck(); | 357 | stopHoldingTimeCheck(); |
358 | isisInterface.removeNeighbor(this); | 358 | isisInterface.removeNeighbor(this); |
359 | + | ||
360 | + isisInterface.isisLsdb().removeTopology(this, isisInterface); | ||
359 | } | 361 | } |
360 | 362 | ||
361 | /** | 363 | /** | ... | ... |
... | @@ -68,6 +68,16 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -68,6 +68,16 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { |
68 | public IsisChannelHandler(Controller controller, List<IsisProcess> processes) { | 68 | public IsisChannelHandler(Controller controller, List<IsisProcess> processes) { |
69 | this.controller = controller; | 69 | this.controller = controller; |
70 | this.processes = processes; | 70 | this.processes = processes; |
71 | + ((DefaultIsisLsdb) isisLsdb).setController(this.controller); | ||
72 | + ((DefaultIsisLsdb) isisLsdb).setIsisInterface(isisInterfaceList()); | ||
73 | + } | ||
74 | + | ||
75 | + private List<IsisInterface> isisInterfaceList() { | ||
76 | + List<IsisInterface> isisInterfaceList = new ArrayList<>(); | ||
77 | + for (Integer key : isisInterfaceMap.keySet()) { | ||
78 | + isisInterfaceList.add(isisInterfaceMap.get(key)); | ||
79 | + } | ||
80 | + return isisInterfaceList; | ||
71 | } | 81 | } |
72 | 82 | ||
73 | /** | 83 | /** |
... | @@ -178,30 +188,25 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -178,30 +188,25 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { |
178 | 188 | ||
179 | @Override | 189 | @Override |
180 | public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { | 190 | public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { |
181 | - log.info("[exceptionCaught]: " + e.toString()); | ||
182 | if (e.getCause() instanceof ReadTimeoutException) { | 191 | if (e.getCause() instanceof ReadTimeoutException) { |
183 | - log.error("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress()); | 192 | + log.debug("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress()); |
184 | return; | 193 | return; |
185 | } else if (e.getCause() instanceof ClosedChannelException) { | 194 | } else if (e.getCause() instanceof ClosedChannelException) { |
186 | log.debug("Channel for ISIS {} already closed", e.getChannel().getRemoteAddress()); | 195 | log.debug("Channel for ISIS {} already closed", e.getChannel().getRemoteAddress()); |
187 | } else if (e.getCause() instanceof IOException) { | 196 | } else if (e.getCause() instanceof IOException) { |
188 | - log.error("Disconnecting ISIS {} due to IO Error: {}", e.getChannel().getRemoteAddress(), | 197 | + log.debug("Disconnecting ISIS {} due to IO Error: {}", e.getChannel().getRemoteAddress(), |
189 | e.getCause().getMessage()); | 198 | e.getCause().getMessage()); |
190 | - if (log.isDebugEnabled()) { | ||
191 | - log.debug("StackTrace for previous Exception: {}", e.getCause()); | ||
192 | - } | ||
193 | } else if (e.getCause() instanceof IsisParseException) { | 199 | } else if (e.getCause() instanceof IsisParseException) { |
194 | IsisParseException errMsg = (IsisParseException) e.getCause(); | 200 | IsisParseException errMsg = (IsisParseException) e.getCause(); |
195 | byte errorCode = errMsg.errorCode(); | 201 | byte errorCode = errMsg.errorCode(); |
196 | byte errorSubCode = errMsg.errorSubCode(); | 202 | byte errorSubCode = errMsg.errorSubCode(); |
197 | - log.error("Error while parsing message from ISIS {}, ErrorCode {}", | 203 | + log.debug("Error while parsing message from ISIS {}, ErrorCode {}", |
198 | e.getChannel().getRemoteAddress(), errorCode); | 204 | e.getChannel().getRemoteAddress(), errorCode); |
199 | } else if (e.getCause() instanceof RejectedExecutionException) { | 205 | } else if (e.getCause() instanceof RejectedExecutionException) { |
200 | - log.warn("Could not process message: queue full"); | 206 | + log.debug("Could not process message: queue full"); |
201 | } else { | 207 | } else { |
202 | - log.error("Error while processing message from ISIS {}, {}", | 208 | + log.debug("Error while processing message from ISIS {}, {}", |
203 | e.getChannel().getRemoteAddress(), e.getCause().getMessage()); | 209 | e.getChannel().getRemoteAddress(), e.getCause().getMessage()); |
204 | - e.getCause().printStackTrace(); | ||
205 | } | 210 | } |
206 | } | 211 | } |
207 | 212 | ||
... | @@ -274,7 +279,7 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -274,7 +279,7 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { |
274 | * @param configPacket interface configuration | 279 | * @param configPacket interface configuration |
275 | */ | 280 | */ |
276 | public void sentConfigPacket(byte[] configPacket) { | 281 | public void sentConfigPacket(byte[] configPacket) { |
277 | - if (channel != null) { | 282 | + if (channel != null && channel.isConnected() && channel.isOpen()) { |
278 | channel.write(configPacket); | 283 | channel.write(configPacket); |
279 | log.debug("IsisChannelHandler sentConfigPacket packet sent..!!!"); | 284 | log.debug("IsisChannelHandler sentConfigPacket packet sent..!!!"); |
280 | } else { | 285 | } else { | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java
0 → 100755
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.isis.controller.impl; | ||
17 | + | ||
18 | +import org.onlab.packet.Ip4Address; | ||
19 | +import org.onlab.util.Bandwidth; | ||
20 | +import org.onosproject.isis.controller.IsisNetworkType; | ||
21 | +import org.onosproject.isis.controller.LspWrapper; | ||
22 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisLink; | ||
23 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkInformation; | ||
24 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkTed; | ||
25 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisRouter; | ||
26 | +import org.onosproject.isis.controller.impl.topology.TopologyForDeviceAndLinkImpl; | ||
27 | +import org.onosproject.isis.controller.topology.IsisLink; | ||
28 | +import org.onosproject.isis.controller.topology.IsisLinkTed; | ||
29 | +import org.onosproject.isis.controller.topology.IsisRouter; | ||
30 | +import org.onosproject.isis.controller.topology.LinkInformation; | ||
31 | +import org.onosproject.isis.io.isispacket.pdu.LsPdu; | ||
32 | +import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability; | ||
33 | +import org.onosproject.isis.io.isispacket.tlv.IsisTlv; | ||
34 | +import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs; | ||
35 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup; | ||
36 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.InterfaceIpAddress; | ||
37 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumBandwidth; | ||
38 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth; | ||
39 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.NeighborIpAddress; | ||
40 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric; | ||
41 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv; | ||
42 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.UnreservedBandwidth; | ||
43 | +import org.onosproject.isis.io.util.IsisConstants; | ||
44 | +import org.onosproject.isis.io.util.IsisUtil; | ||
45 | +import org.slf4j.Logger; | ||
46 | +import org.slf4j.LoggerFactory; | ||
47 | + | ||
48 | +import java.util.ArrayList; | ||
49 | +import java.util.LinkedHashMap; | ||
50 | +import java.util.List; | ||
51 | +import java.util.Map; | ||
52 | +import java.util.concurrent.BlockingQueue; | ||
53 | + | ||
54 | +/** | ||
55 | + * Representation of LSP event consumer. | ||
56 | + */ | ||
57 | +public class LspEventConsumer implements Runnable { | ||
58 | + private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class); | ||
59 | + private BlockingQueue queue = null; | ||
60 | + private Controller controller = null; | ||
61 | + private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl(); | ||
62 | + private Map<String, IsisRouter> isisRouterDetails = new LinkedHashMap<>(); | ||
63 | + | ||
64 | + /** | ||
65 | + * Creates an instance of this. | ||
66 | + * | ||
67 | + * @param queue blocking queue instance | ||
68 | + * @param controller controller instance | ||
69 | + */ | ||
70 | + public LspEventConsumer(BlockingQueue queue, Controller controller) { | ||
71 | + this.queue = queue; | ||
72 | + this.controller = controller; | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public void run() { | ||
77 | + try { | ||
78 | + while (true) { | ||
79 | + if (!queue.isEmpty()) { | ||
80 | + LspWrapper wrapper = (LspWrapper) queue.take(); | ||
81 | + LsPdu lsPdu = (LsPdu) wrapper.lsPdu(); | ||
82 | + if (wrapper.lspProcessing().equals(IsisConstants.LSPREMOVED)) { | ||
83 | + callTopologyToRemoveInfo(lsPdu); | ||
84 | + } else if (wrapper.lspProcessing().equals(IsisConstants.LSPADDED)) { | ||
85 | + callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(), | ||
86 | + wrapper.isisInterface().systemId() + ".00"); | ||
87 | + } | ||
88 | + } | ||
89 | + } | ||
90 | + } catch (Exception e) { | ||
91 | + log.debug("Error::LspsForProvider::{}", e.getMessage()); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Sends topology information to core. | ||
97 | + * | ||
98 | + * @param lsPdu ls pdu instance | ||
99 | + * @param isisNetworkType ISIS network type | ||
100 | + * @param ownSystemId own system ID | ||
101 | + */ | ||
102 | + private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType, | ||
103 | + String ownSystemId) { | ||
104 | + if ((lsPdu.lspId().equals(ownSystemId + "-00"))) { | ||
105 | + return; | ||
106 | + } | ||
107 | + sendDeviceInfo(createDeviceInfo(lsPdu)); | ||
108 | + | ||
109 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { | ||
110 | + if (isisTlv instanceof IsExtendedReachability) { | ||
111 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | ||
112 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); | ||
113 | + for (NeighborForExtendedIs teTlv : neighbours) { | ||
114 | + String neighbor = teTlv.neighborId(); | ||
115 | + IsisRouter isisRouter = isisRouterDetails.get(neighbor); | ||
116 | + if (isisRouter != null) { | ||
117 | + IsisRouter sourceRouter = isisRouterDetails.get(IsisUtil.removeTailingZeros(lsPdu.lspId())); | ||
118 | + IsisRouter destinationRouter = isisRouter; | ||
119 | + if (sourceRouter.isDis()) { | ||
120 | + LinkInformation linkInformation = createLinkInfo(sourceRouter.systemId(), | ||
121 | + destinationRouter.systemId(), | ||
122 | + sourceRouter.interfaceId(), | ||
123 | + destinationRouter.interfaceId(), lsPdu); | ||
124 | + controller.addLinkDetails(createIsisLink(linkInformation, lsPdu)); | ||
125 | + } else if (destinationRouter.isDis()) { | ||
126 | + LinkInformation linkInformation1 = createLinkInfo(destinationRouter.systemId(), | ||
127 | + sourceRouter.systemId(), | ||
128 | + destinationRouter.interfaceId(), | ||
129 | + sourceRouter.interfaceId(), lsPdu); | ||
130 | + controller.addLinkDetails(createIsisLink(linkInformation1, lsPdu)); | ||
131 | + } else { | ||
132 | + LinkInformation linkInformation = createLinkInfo(sourceRouter.systemId(), | ||
133 | + destinationRouter.systemId(), | ||
134 | + sourceRouter.interfaceId(), | ||
135 | + destinationRouter.interfaceId(), lsPdu); | ||
136 | + controller.addLinkDetails(createIsisLink(linkInformation, lsPdu)); | ||
137 | + LinkInformation linkInformation1 = createLinkInfo(destinationRouter.systemId(), | ||
138 | + sourceRouter.systemId(), | ||
139 | + destinationRouter.interfaceId(), | ||
140 | + sourceRouter.interfaceId(), lsPdu); | ||
141 | + controller.addLinkDetails(createIsisLink(linkInformation1, lsPdu)); | ||
142 | + } | ||
143 | + } | ||
144 | + } | ||
145 | + } | ||
146 | + } | ||
147 | + } | ||
148 | + | ||
149 | + /** | ||
150 | + * Removes topology information from core. | ||
151 | + * | ||
152 | + * @param lsPdu ls pdu instance | ||
153 | + */ | ||
154 | + private void callTopologyToRemoveInfo(LsPdu lsPdu) { | ||
155 | + String routerId = IsisUtil.removeTailingZeros(lsPdu.lspId()); | ||
156 | + IsisRouter isisRouter = isisRouterDetails.get(routerId); | ||
157 | + removeDeviceInfo(isisRouter); | ||
158 | + removeLinkInfo(lsPdu); | ||
159 | + } | ||
160 | + | ||
161 | + /** | ||
162 | + * Sends the device information to topology provider. | ||
163 | + * | ||
164 | + * @param isisRouter ISIS router instance | ||
165 | + */ | ||
166 | + private void sendDeviceInfo(IsisRouter isisRouter) { | ||
167 | + if (isisRouter.systemId() != null) { | ||
168 | + controller.addDeviceDetails(isisRouter); | ||
169 | + } | ||
170 | + } | ||
171 | + | ||
172 | + /** | ||
173 | + * Creates Device instance. | ||
174 | + * | ||
175 | + * @param lsPdu ISIS LSPDU instance | ||
176 | + * @return isisRouter isisRouter instance | ||
177 | + */ | ||
178 | + public IsisRouter createDeviceInfo(LsPdu lsPdu) { | ||
179 | + IsisRouter isisRouter = createIsisRouter(lsPdu); | ||
180 | + if (isisRouter.systemId() != null) { | ||
181 | + isisRouterDetails.put(isisRouter.systemId(), isisRouter); | ||
182 | + } | ||
183 | + return isisRouter; | ||
184 | + } | ||
185 | + | ||
186 | + /** | ||
187 | + * Creates ISIS router instance. | ||
188 | + * | ||
189 | + * @param lsPdu lsp instance | ||
190 | + * @return isisRouter instance | ||
191 | + */ | ||
192 | + private IsisRouter createIsisRouter(LsPdu lsPdu) { | ||
193 | + IsisRouter isisRouter = new DefaultIsisRouter(); | ||
194 | + if (IsisUtil.checkIsDis(lsPdu.lspId())) { | ||
195 | + isisRouter.setDis(true); | ||
196 | + } else { | ||
197 | + isisRouter.setDis(false); | ||
198 | + } | ||
199 | + isisRouter.setSystemId(IsisUtil.removeTailingZeros(lsPdu.lspId())); | ||
200 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { | ||
201 | + if (isisTlv instanceof IsExtendedReachability) { | ||
202 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | ||
203 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); | ||
204 | + for (NeighborForExtendedIs teTlv : neighbours) { | ||
205 | + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv(); | ||
206 | + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) { | ||
207 | + if (teSubTlv instanceof InterfaceIpAddress) { | ||
208 | + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv; | ||
209 | + isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress()); | ||
210 | + } else if (teSubTlv instanceof NeighborIpAddress) { | ||
211 | + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv; | ||
212 | + isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress()); | ||
213 | + } | ||
214 | + | ||
215 | + } | ||
216 | + } | ||
217 | + } | ||
218 | + } | ||
219 | + if (isisRouter.interfaceId() == null) { | ||
220 | + isisRouter.setInterfaceId(IsisConstants.DEFAULTIP); | ||
221 | + } | ||
222 | + if (isisRouter.neighborRouterId() == null) { | ||
223 | + isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP); | ||
224 | + } | ||
225 | + return isisRouter; | ||
226 | + } | ||
227 | + | ||
228 | + /** | ||
229 | + * Creates link information. | ||
230 | + * | ||
231 | + * @param localSystemId local system ID | ||
232 | + * @param remoteSystemId remote system ID | ||
233 | + * @return link information | ||
234 | + * @param interfaceIp interface address | ||
235 | + * @param neighborIp neighbor address | ||
236 | + * @param lsPdu link state PDU instance | ||
237 | + * @return link information instance | ||
238 | + */ | ||
239 | + public LinkInformation createLinkInfo(String localSystemId, String remoteSystemId, | ||
240 | + Ip4Address interfaceIp, Ip4Address neighborIp, | ||
241 | + LsPdu lsPdu) { | ||
242 | + | ||
243 | + String linkId = "link:" + localSystemId + "-" + remoteSystemId; | ||
244 | + LinkInformation linkInformation = new DefaultIsisLinkInformation(); | ||
245 | + linkInformation.setInterfaceIp(interfaceIp); | ||
246 | + linkInformation.setNeighborIp(neighborIp); | ||
247 | + linkInformation.setLinkId(linkId); | ||
248 | + linkInformation.setAlreadyCreated(false); | ||
249 | + linkInformation.setLinkDestinationId(remoteSystemId); | ||
250 | + linkInformation.setLinkSourceId(localSystemId); | ||
251 | + | ||
252 | + return linkInformation; | ||
253 | + } | ||
254 | + | ||
255 | + /** | ||
256 | + * Removes the device information from topology provider. | ||
257 | + * | ||
258 | + * @param isisRouter ISIS router instance | ||
259 | + */ | ||
260 | + private void removeDeviceInfo(IsisRouter isisRouter) { | ||
261 | + if (isisRouter.systemId() != null) { | ||
262 | + controller.removeDeviceDetails(isisRouter); | ||
263 | + } | ||
264 | + isisRouterDetails.remove(isisRouter.systemId()); | ||
265 | + } | ||
266 | + | ||
267 | + | ||
268 | + /** | ||
269 | + * Removes the link information from topology provider. | ||
270 | + * | ||
271 | + * @param lsPdu ls pdu instance | ||
272 | + */ | ||
273 | + private void removeLinkInfo(LsPdu lsPdu) { | ||
274 | + Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu.lspId()); | ||
275 | + for (String key : linkInformationList.keySet()) { | ||
276 | + LinkInformation linkInformation = linkInformationList.get(key); | ||
277 | + controller.removeLinkDetails(createIsisLink(linkInformation, lsPdu)); | ||
278 | + } | ||
279 | + } | ||
280 | + | ||
281 | + /** | ||
282 | + * Creates ISIS link instance. | ||
283 | + * | ||
284 | + * @param linkInformation link information instance | ||
285 | + * @return isisLink instance | ||
286 | + */ | ||
287 | + private IsisLink createIsisLink(LinkInformation linkInformation, LsPdu lsPdu) { | ||
288 | + IsisLink isisLink = new DefaultIsisLink(); | ||
289 | + isisLink.setLocalSystemId(linkInformation.linkSourceId()); | ||
290 | + isisLink.setRemoteSystemId(linkInformation.linkDestinationId()); | ||
291 | + isisLink.setInterfaceIp(linkInformation.interfaceIp()); | ||
292 | + isisLink.setNeighborIp(linkInformation.neighborIp()); | ||
293 | + isisLink.setLinkTed(createIsisLinkTedInfo(lsPdu)); | ||
294 | + return isisLink; | ||
295 | + } | ||
296 | + | ||
297 | + /** | ||
298 | + * Creates the ISIS link TED information. | ||
299 | + * | ||
300 | + * @param lsPdu link state PDU | ||
301 | + * @return isisLinkTed | ||
302 | + */ | ||
303 | + public IsisLinkTed createIsisLinkTedInfo(LsPdu lsPdu) { | ||
304 | + IsisLinkTed isisLinkTed = new DefaultIsisLinkTed(); | ||
305 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { | ||
306 | + if (isisTlv instanceof IsExtendedReachability) { | ||
307 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | ||
308 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); | ||
309 | + for (NeighborForExtendedIs teTlv : neighbours) { | ||
310 | + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv(); | ||
311 | + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) { | ||
312 | + if (teSubTlv instanceof AdministrativeGroup) { | ||
313 | + AdministrativeGroup ag = (AdministrativeGroup) teSubTlv; | ||
314 | + isisLinkTed.setAdministrativeGroup(ag.administrativeGroup()); | ||
315 | + } | ||
316 | + if (teSubTlv instanceof InterfaceIpAddress) { | ||
317 | + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv; | ||
318 | + isisLinkTed.setIpv4InterfaceAddress(localIpAddress.localInterfaceIPAddress()); | ||
319 | + } | ||
320 | + if (teSubTlv instanceof NeighborIpAddress) { | ||
321 | + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv; | ||
322 | + isisLinkTed.setIpv4NeighborAddress(neighborIpAddress.neighborIPAddress()); | ||
323 | + } | ||
324 | + if (teSubTlv instanceof TrafficEngineeringMetric) { | ||
325 | + TrafficEngineeringMetric teM = (TrafficEngineeringMetric) teSubTlv; | ||
326 | + isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue()); | ||
327 | + } | ||
328 | + if (teSubTlv instanceof MaximumBandwidth) { | ||
329 | + MaximumBandwidth maxLinkBandwidth = (MaximumBandwidth) teSubTlv; | ||
330 | + isisLinkTed.setMaximumLinkBandwidth( | ||
331 | + Bandwidth.bps(maxLinkBandwidth.getMaximumBandwidthValue())); | ||
332 | + } | ||
333 | + if (teSubTlv instanceof MaximumReservableBandwidth) { | ||
334 | + MaximumReservableBandwidth maxReservableBw = (MaximumReservableBandwidth) teSubTlv; | ||
335 | + isisLinkTed.setMaximumReservableLinkBandwidth( | ||
336 | + Bandwidth.bps(maxReservableBw.getMaximumBandwidthValue())); | ||
337 | + } | ||
338 | + if (teSubTlv instanceof UnreservedBandwidth) { | ||
339 | + UnreservedBandwidth unReservedBandwidth = (UnreservedBandwidth) teSubTlv; | ||
340 | + List<Bandwidth> bandwidthList = new ArrayList<>(); | ||
341 | + List<Float> unReservedBandwidthList = unReservedBandwidth.unReservedBandwidthValue(); | ||
342 | + for (Float unReservedBandwidthFloatValue : unReservedBandwidthList) { | ||
343 | + Bandwidth bandwidth = Bandwidth.bps(unReservedBandwidthFloatValue); | ||
344 | + bandwidthList.add(bandwidth); | ||
345 | + } | ||
346 | + isisLinkTed.setUnreservedBandwidth(bandwidthList); | ||
347 | + } | ||
348 | + } | ||
349 | + } | ||
350 | + } | ||
351 | + } | ||
352 | + return isisLinkTed; | ||
353 | + } | ||
354 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
100644 → 100755
... | @@ -21,17 +21,24 @@ import org.onosproject.isis.controller.IsisLsdb; | ... | @@ -21,17 +21,24 @@ import org.onosproject.isis.controller.IsisLsdb; |
21 | import org.onosproject.isis.controller.IsisLsdbAge; | 21 | import org.onosproject.isis.controller.IsisLsdbAge; |
22 | import org.onosproject.isis.controller.IsisLspBin; | 22 | import org.onosproject.isis.controller.IsisLspBin; |
23 | import org.onosproject.isis.controller.IsisMessage; | 23 | import org.onosproject.isis.controller.IsisMessage; |
24 | +import org.onosproject.isis.controller.IsisNeighbor; | ||
24 | import org.onosproject.isis.controller.IsisPduType; | 25 | import org.onosproject.isis.controller.IsisPduType; |
26 | +import org.onosproject.isis.controller.IsisRouterType; | ||
25 | import org.onosproject.isis.controller.LspWrapper; | 27 | import org.onosproject.isis.controller.LspWrapper; |
28 | +import org.onosproject.isis.controller.impl.Controller; | ||
29 | +import org.onosproject.isis.controller.impl.LspEventConsumer; | ||
26 | import org.onosproject.isis.io.isispacket.pdu.LsPdu; | 30 | import org.onosproject.isis.io.isispacket.pdu.LsPdu; |
27 | import org.onosproject.isis.io.util.IsisConstants; | 31 | import org.onosproject.isis.io.util.IsisConstants; |
28 | import org.onosproject.isis.io.util.IsisUtil; | 32 | import org.onosproject.isis.io.util.IsisUtil; |
29 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
30 | import org.slf4j.LoggerFactory; | 34 | import org.slf4j.LoggerFactory; |
31 | 35 | ||
36 | +import java.util.ArrayList; | ||
32 | import java.util.Iterator; | 37 | import java.util.Iterator; |
33 | import java.util.List; | 38 | import java.util.List; |
34 | import java.util.Map; | 39 | import java.util.Map; |
40 | +import java.util.concurrent.ArrayBlockingQueue; | ||
41 | +import java.util.concurrent.BlockingQueue; | ||
35 | import java.util.concurrent.ConcurrentHashMap; | 42 | import java.util.concurrent.ConcurrentHashMap; |
36 | import java.util.concurrent.CopyOnWriteArrayList; | 43 | import java.util.concurrent.CopyOnWriteArrayList; |
37 | 44 | ||
... | @@ -43,10 +50,14 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -43,10 +50,14 @@ public class DefaultIsisLsdb implements IsisLsdb { |
43 | private Map<String, LspWrapper> isisL1Db = new ConcurrentHashMap<>(); | 50 | private Map<String, LspWrapper> isisL1Db = new ConcurrentHashMap<>(); |
44 | private Map<String, LspWrapper> isisL2Db = new ConcurrentHashMap<>(); | 51 | private Map<String, LspWrapper> isisL2Db = new ConcurrentHashMap<>(); |
45 | private IsisLsdbAge lsdbAge = null; | 52 | private IsisLsdbAge lsdbAge = null; |
53 | + private Controller controller = null; | ||
54 | + private List<IsisInterface> isisInterfaceList = new ArrayList<>(); | ||
46 | 55 | ||
47 | 56 | ||
48 | private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; | 57 | private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; |
49 | private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; | 58 | private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; |
59 | + private LspEventConsumer queueConsumer = null; | ||
60 | + private BlockingQueue<LspWrapper> lspForProviderQueue = new ArrayBlockingQueue<>(1024); | ||
50 | 61 | ||
51 | /** | 62 | /** |
52 | * Creates an instance of ISIS LSDB. | 63 | * Creates an instance of ISIS LSDB. |
... | @@ -56,10 +67,30 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -56,10 +67,30 @@ public class DefaultIsisLsdb implements IsisLsdb { |
56 | } | 67 | } |
57 | 68 | ||
58 | /** | 69 | /** |
70 | + * Sets the controller instance. | ||
71 | + * | ||
72 | + * @param controller controller instance | ||
73 | + */ | ||
74 | + public void setController(Controller controller) { | ||
75 | + this.controller = controller; | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Sets the list of IsisInterface instance. | ||
80 | + * | ||
81 | + * @param isisInterfaceList isisInterface instance | ||
82 | + */ | ||
83 | + public void setIsisInterface(List<IsisInterface> isisInterfaceList) { | ||
84 | + this.isisInterfaceList = isisInterfaceList; | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
59 | * Initializes the link state database. | 88 | * Initializes the link state database. |
60 | */ | 89 | */ |
61 | public void initializeDb() { | 90 | public void initializeDb() { |
62 | lsdbAge.startDbAging(); | 91 | lsdbAge.startDbAging(); |
92 | + queueConsumer = new LspEventConsumer(lspForProviderQueue, controller); | ||
93 | + new Thread(queueConsumer).start(); | ||
63 | } | 94 | } |
64 | 95 | ||
65 | /** | 96 | /** |
... | @@ -96,7 +127,6 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -96,7 +127,6 @@ public class DefaultIsisLsdb implements IsisLsdb { |
96 | return lspKey.toString(); | 127 | return lspKey.toString(); |
97 | } | 128 | } |
98 | 129 | ||
99 | - | ||
100 | /** | 130 | /** |
101 | * Returns the neighbor L1 database information. | 131 | * Returns the neighbor L1 database information. |
102 | * | 132 | * |
... | @@ -236,6 +266,14 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -236,6 +266,14 @@ public class DefaultIsisLsdb implements IsisLsdb { |
236 | addLsp(lspWrapper, lspdu.lspId()); | 266 | addLsp(lspWrapper, lspdu.lspId()); |
237 | 267 | ||
238 | log.debug("Added LSp In LSDB: {}", lspWrapper); | 268 | log.debug("Added LSp In LSDB: {}", lspWrapper); |
269 | + try { | ||
270 | + if (!lspWrapper.isSelfOriginated()) { | ||
271 | + lspWrapper.setLspProcessing(IsisConstants.LSPADDED); | ||
272 | + lspForProviderQueue.put(lspWrapper); | ||
273 | + } | ||
274 | + } catch (Exception e) { | ||
275 | + log.debug("Added LSp In Blocking queue: {}", lspWrapper); | ||
276 | + } | ||
239 | return true; | 277 | return true; |
240 | } | 278 | } |
241 | 279 | ||
... | @@ -276,6 +314,7 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -276,6 +314,7 @@ public class DefaultIsisLsdb implements IsisLsdb { |
276 | lspWrapper.lsPdu().isisPduType(), | 314 | lspWrapper.lsPdu().isisPduType(), |
277 | binNumber, lspWrapper.remainingLifetime()); | 315 | binNumber, lspWrapper.remainingLifetime()); |
278 | } | 316 | } |
317 | + | ||
279 | return false; | 318 | return false; |
280 | } | 319 | } |
281 | 320 | ||
... | @@ -337,6 +376,7 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -337,6 +376,7 @@ public class DefaultIsisLsdb implements IsisLsdb { |
337 | public void deleteLsp(IsisMessage lspMessage) { | 376 | public void deleteLsp(IsisMessage lspMessage) { |
338 | LsPdu lsp = (LsPdu) lspMessage; | 377 | LsPdu lsp = (LsPdu) lspMessage; |
339 | String lspKey = lsp.lspId(); | 378 | String lspKey = lsp.lspId(); |
379 | + LspWrapper lspWrapper = findLsp(lspMessage.isisPduType(), lspKey); | ||
340 | switch (lsp.isisPduType()) { | 380 | switch (lsp.isisPduType()) { |
341 | case L1LSPDU: | 381 | case L1LSPDU: |
342 | isisL1Db.remove(lspKey); | 382 | isisL1Db.remove(lspKey); |
... | @@ -348,5 +388,47 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -348,5 +388,47 @@ public class DefaultIsisLsdb implements IsisLsdb { |
348 | log.debug("Unknown LSP type to remove..!!!"); | 388 | log.debug("Unknown LSP type to remove..!!!"); |
349 | break; | 389 | break; |
350 | } | 390 | } |
391 | + | ||
392 | + try { | ||
393 | + lspWrapper.setLspProcessing(IsisConstants.LSPREMOVED); | ||
394 | + lspForProviderQueue.put(lspWrapper); | ||
395 | + } catch (Exception e) { | ||
396 | + log.debug("Added LSp In Blocking queue: {}", lspWrapper); | ||
397 | + } | ||
398 | + } | ||
399 | + | ||
400 | + /** | ||
401 | + * Removes topology information when neighbor down. | ||
402 | + * | ||
403 | + * @param neighbor ISIS neighbor instance | ||
404 | + * @param isisInterface ISIS interface instance | ||
405 | + */ | ||
406 | + public void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface) { | ||
407 | + String lspKey = neighbor.neighborSystemId() + ".00-00"; | ||
408 | + LspWrapper lspWrapper = null; | ||
409 | + switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) { | ||
410 | + case L1: | ||
411 | + lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey); | ||
412 | + break; | ||
413 | + case L2: | ||
414 | + lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey); | ||
415 | + break; | ||
416 | + case L1L2: | ||
417 | + lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey); | ||
418 | + if (lspWrapper == null) { | ||
419 | + lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey); | ||
420 | + } | ||
421 | + break; | ||
422 | + default: | ||
423 | + log.debug("Unknown type"); | ||
424 | + } | ||
425 | + try { | ||
426 | + if (lspWrapper != null) { | ||
427 | + lspWrapper.setLspProcessing(IsisConstants.LSPREMOVED); | ||
428 | + lspForProviderQueue.put(lspWrapper); | ||
429 | + } | ||
430 | + } catch (Exception e) { | ||
431 | + log.debug("Added LSp In Blocking queue: {}", lspWrapper); | ||
432 | + } | ||
351 | } | 433 | } |
352 | } | 434 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -231,7 +231,6 @@ public class DefaultIsisLsdbAge implements IsisLsdbAge { | ... | @@ -231,7 +231,6 @@ public class DefaultIsisLsdbAge implements IsisLsdbAge { |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | - | ||
235 | /** | 234 | /** |
236 | * Runnable task which runs every second and calls aging process. | 235 | * Runnable task which runs every second and calls aging process. |
237 | */ | 236 | */ | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
... | @@ -72,7 +72,6 @@ public class IsisLspQueueConsumer implements Runnable { | ... | @@ -72,7 +72,6 @@ public class IsisLspQueueConsumer implements Runnable { |
72 | } | 72 | } |
73 | } | 73 | } |
74 | } | 74 | } |
75 | - | ||
76 | } catch (Exception e) { | 75 | } catch (Exception e) { |
77 | log.debug("Error::LSPQueueConsumer::{}", e.getMessage()); | 76 | log.debug("Error::LSPQueueConsumer::{}", e.getMessage()); |
78 | } | 77 | } |
... | @@ -106,7 +105,6 @@ public class IsisLspQueueConsumer implements Runnable { | ... | @@ -106,7 +105,6 @@ public class IsisLspQueueConsumer implements Runnable { |
106 | log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}", | 105 | log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}", |
107 | wrapper.lsPdu()); | 106 | wrapper.lsPdu()); |
108 | } | 107 | } |
109 | - | ||
110 | } | 108 | } |
111 | } | 109 | } |
112 | 110 | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLink.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2015 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 | +package org.onosproject.isis.controller.impl.topology; | ||
18 | + | ||
19 | +import com.google.common.base.MoreObjects; | ||
20 | +import com.google.common.base.Objects; | ||
21 | +import org.onlab.packet.Ip4Address; | ||
22 | +import org.onosproject.isis.controller.topology.IsisLink; | ||
23 | +import org.onosproject.isis.controller.topology.IsisLinkTed; | ||
24 | + | ||
25 | +/** | ||
26 | + * Representation of an ISIS Link. | ||
27 | + */ | ||
28 | +public class DefaultIsisLink implements IsisLink { | ||
29 | + | ||
30 | + private String remoteSystemId; | ||
31 | + private String localSystemId; | ||
32 | + private Ip4Address interfaceIp; | ||
33 | + private Ip4Address neighborIp; | ||
34 | + private IsisLinkTed linkTed; | ||
35 | + | ||
36 | + @Override | ||
37 | + public String remoteSystemId() { | ||
38 | + return this.remoteSystemId; | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public String localSystemId() { | ||
43 | + return this.localSystemId; | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public Ip4Address interfaceIp() { | ||
48 | + return this.interfaceIp; | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public Ip4Address neighborIp() { | ||
53 | + return this.neighborIp; | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public IsisLinkTed linkTed() { | ||
58 | + return this.linkTed; | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public void setRemoteSystemId(String remoteSystemId) { | ||
63 | + this.remoteSystemId = remoteSystemId; | ||
64 | + } | ||
65 | + | ||
66 | + @Override | ||
67 | + public void setLocalSystemId(String localSystemId) { | ||
68 | + this.localSystemId = localSystemId; | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public void setInterfaceIp(Ip4Address interfaceIp) { | ||
73 | + this.interfaceIp = interfaceIp; | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
77 | + public void setNeighborIp(Ip4Address neighborIp) { | ||
78 | + this.neighborIp = neighborIp; | ||
79 | + } | ||
80 | + | ||
81 | + @Override | ||
82 | + public void setLinkTed(IsisLinkTed linkTed) { | ||
83 | + this.linkTed = linkTed; | ||
84 | + } | ||
85 | + | ||
86 | + @Override | ||
87 | + public String toString() { | ||
88 | + return MoreObjects.toStringHelper(getClass()) | ||
89 | + .omitNullValues() | ||
90 | + .add("remoteSystemId", remoteSystemId) | ||
91 | + .add("localSystemId", localSystemId) | ||
92 | + .add("interfaceIp", interfaceIp) | ||
93 | + .add("neighborIp", neighborIp) | ||
94 | + .add("linkTed", linkTed) | ||
95 | + .toString(); | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public boolean equals(Object o) { | ||
100 | + if (this == o) { | ||
101 | + return true; | ||
102 | + } | ||
103 | + if (o == null || getClass() != o.getClass()) { | ||
104 | + return false; | ||
105 | + } | ||
106 | + DefaultIsisLink that = (DefaultIsisLink) o; | ||
107 | + return Objects.equal(remoteSystemId, that.remoteSystemId) && | ||
108 | + Objects.equal(localSystemId, that.localSystemId) && | ||
109 | + Objects.equal(interfaceIp, that.interfaceIp) && | ||
110 | + Objects.equal(neighborIp, that.neighborIp) && | ||
111 | + Objects.equal(linkTed, that.linkTed); | ||
112 | + } | ||
113 | + | ||
114 | + @Override | ||
115 | + public int hashCode() { | ||
116 | + return Objects.hashCode(remoteSystemId, localSystemId, interfaceIp, neighborIp, linkTed); | ||
117 | + } | ||
118 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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.isis.controller.impl.topology; | ||
17 | + | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | +import com.google.common.base.Objects; | ||
20 | +import org.onlab.packet.Ip4Address; | ||
21 | +import org.onosproject.isis.controller.topology.LinkInformation; | ||
22 | + | ||
23 | +/** | ||
24 | + * Representation of an ISIS link information.. | ||
25 | + */ | ||
26 | +public class DefaultIsisLinkInformation implements LinkInformation { | ||
27 | + | ||
28 | + String linkId; | ||
29 | + String linkSourceId; | ||
30 | + String linkDestinationId; | ||
31 | + Ip4Address interfaceIp; | ||
32 | + Ip4Address neighborIp; | ||
33 | + boolean alreadyCreated; | ||
34 | + | ||
35 | + /** | ||
36 | + * Gets link id. | ||
37 | + * | ||
38 | + * @return link id | ||
39 | + */ | ||
40 | + public String linkId() { | ||
41 | + return linkId; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Sets link id.DefaultIsisDeviceInformation. | ||
46 | + * | ||
47 | + * @param linkId link id | ||
48 | + */ | ||
49 | + public void setLinkId(String linkId) { | ||
50 | + this.linkId = linkId; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Gets is already created or not. | ||
55 | + * | ||
56 | + * @return true if already created else false | ||
57 | + */ | ||
58 | + public boolean isAlreadyCreated() { | ||
59 | + return alreadyCreated; | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * Sets is already created or not. | ||
64 | + * | ||
65 | + * @param alreadyCreated true or false | ||
66 | + */ | ||
67 | + public void setAlreadyCreated(boolean alreadyCreated) { | ||
68 | + this.alreadyCreated = alreadyCreated; | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * Gets link destination id. | ||
73 | + * | ||
74 | + * @return link destination id | ||
75 | + */ | ||
76 | + public String linkDestinationId() { | ||
77 | + return linkDestinationId; | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * Sets link destination id. | ||
82 | + * | ||
83 | + * @param linkDestinationId link destination id | ||
84 | + */ | ||
85 | + public void setLinkDestinationId(String linkDestinationId) { | ||
86 | + this.linkDestinationId = linkDestinationId; | ||
87 | + } | ||
88 | + | ||
89 | + /** | ||
90 | + * Gets link source id. | ||
91 | + * | ||
92 | + * @return link source id | ||
93 | + */ | ||
94 | + public String linkSourceId() { | ||
95 | + return linkSourceId; | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Sets link source id. | ||
100 | + * | ||
101 | + * @param linkSourceId link source id | ||
102 | + */ | ||
103 | + public void setLinkSourceId(String linkSourceId) { | ||
104 | + this.linkSourceId = linkSourceId; | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * Gets interface IP address. | ||
109 | + * | ||
110 | + * @return interface IP address | ||
111 | + */ | ||
112 | + public Ip4Address interfaceIp() { | ||
113 | + return interfaceIp; | ||
114 | + } | ||
115 | + | ||
116 | + /** | ||
117 | + * Sets interface IP address. | ||
118 | + * | ||
119 | + * @param interfaceIp interface IP address | ||
120 | + */ | ||
121 | + public void setInterfaceIp(Ip4Address interfaceIp) { | ||
122 | + this.interfaceIp = interfaceIp; | ||
123 | + } | ||
124 | + | ||
125 | + @Override | ||
126 | + public Ip4Address neighborIp() { | ||
127 | + return this.neighborIp; | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
131 | + public void setNeighborIp(Ip4Address neighborIp) { | ||
132 | + this.neighborIp = neighborIp; | ||
133 | + } | ||
134 | + | ||
135 | + @Override | ||
136 | + public String toString() { | ||
137 | + return MoreObjects.toStringHelper(getClass()) | ||
138 | + .omitNullValues() | ||
139 | + .add("linkId", linkId) | ||
140 | + .add("linkSourceId", linkSourceId) | ||
141 | + .add("linkDestinationId", linkDestinationId) | ||
142 | + .add("interfaceIp", interfaceIp) | ||
143 | + .toString(); | ||
144 | + } | ||
145 | + | ||
146 | + @Override | ||
147 | + public boolean equals(Object o) { | ||
148 | + if (this == o) { | ||
149 | + return true; | ||
150 | + } | ||
151 | + if (o == null || getClass() != o.getClass()) { | ||
152 | + return false; | ||
153 | + } | ||
154 | + DefaultIsisLinkInformation that = (DefaultIsisLinkInformation) o; | ||
155 | + return Objects.equal(linkId, that.linkId) && | ||
156 | + Objects.equal(linkSourceId, that.linkSourceId) && | ||
157 | + Objects.equal(linkDestinationId, that.linkDestinationId) && | ||
158 | + Objects.equal(interfaceIp, that.interfaceIp); | ||
159 | + } | ||
160 | + | ||
161 | + @Override | ||
162 | + public int hashCode() { | ||
163 | + return Objects.hashCode(linkId, linkSourceId, linkDestinationId, | ||
164 | + interfaceIp); | ||
165 | + } | ||
166 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 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.isis.controller.impl.topology; | ||
17 | + | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | +import com.google.common.base.Objects; | ||
20 | +import org.onlab.packet.Ip4Address; | ||
21 | +import org.onlab.util.Bandwidth; | ||
22 | +import org.onosproject.isis.controller.topology.IsisLinkTed; | ||
23 | + | ||
24 | +import java.util.ArrayList; | ||
25 | +import java.util.List; | ||
26 | + | ||
27 | +/** | ||
28 | + * Representation of an ISIS device information. | ||
29 | + */ | ||
30 | +public class DefaultIsisLinkTed implements IsisLinkTed { | ||
31 | + private int administrativeGroup; | ||
32 | + private Ip4Address ipv4InterfaceAddress; | ||
33 | + private Ip4Address ipv4NeighborAddress; | ||
34 | + private Bandwidth maximumLinkBandwidth; | ||
35 | + private Bandwidth maximumReservableLinkBandwidth; | ||
36 | + private List<Bandwidth> unreservedBandwidth = new ArrayList<>(); | ||
37 | + private long teDefaultMetric; | ||
38 | + | ||
39 | + @Override | ||
40 | + public int administrativeGroup() { | ||
41 | + return administrativeGroup; | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public void setAdministrativeGroup(int administrativeGroup) { | ||
46 | + this.administrativeGroup = administrativeGroup; | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public Ip4Address ipv4InterfaceAddress() { | ||
51 | + return ipv4InterfaceAddress; | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public void setIpv4InterfaceAddress(Ip4Address interfaceAddress) { | ||
56 | + this.ipv4InterfaceAddress = interfaceAddress; | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public Ip4Address ipv4NeighborAddress() { | ||
61 | + return ipv4NeighborAddress; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public void setIpv4NeighborAddress(Ip4Address neighborAddress) { | ||
66 | + this.ipv4NeighborAddress = neighborAddress; | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public Bandwidth maximumLinkBandwidth() { | ||
71 | + return maximumLinkBandwidth; | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public void setMaximumLinkBandwidth(Bandwidth bandwidth) { | ||
76 | + this.maximumLinkBandwidth = bandwidth; | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public Bandwidth maximumReservableLinkBandwidth() { | ||
81 | + return maximumReservableLinkBandwidth; | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public void setMaximumReservableLinkBandwidth(Bandwidth bandwidth) { | ||
86 | + this.maximumReservableLinkBandwidth = bandwidth; | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public List<Bandwidth> unreservedBandwidth() { | ||
91 | + return this.unreservedBandwidth; | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + public void setUnreservedBandwidth(List<Bandwidth> bandwidth) { | ||
96 | + this.unreservedBandwidth.addAll(bandwidth); | ||
97 | + } | ||
98 | + | ||
99 | + @Override | ||
100 | + public long teDefaultMetric() { | ||
101 | + return teDefaultMetric; | ||
102 | + } | ||
103 | + | ||
104 | + @Override | ||
105 | + public void setTeDefaultMetric(long teMetric) { | ||
106 | + this.teDefaultMetric = teMetric; | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public String toString() { | ||
111 | + return MoreObjects.toStringHelper(getClass()) | ||
112 | + .omitNullValues() | ||
113 | + .add("administrativeGroup", administrativeGroup) | ||
114 | + .add("ipv4InterfaceAddress", ipv4InterfaceAddress) | ||
115 | + .add("ipv4NeighborAddress", ipv4NeighborAddress) | ||
116 | + .add("maximumLinkBandwidth", maximumLinkBandwidth) | ||
117 | + .add("maximumReservableLinkBandwidth", maximumReservableLinkBandwidth) | ||
118 | + .add("teDefaultMetric", teDefaultMetric) | ||
119 | + .toString(); | ||
120 | + } | ||
121 | + | ||
122 | + @Override | ||
123 | + public boolean equals(Object o) { | ||
124 | + if (this == o) { | ||
125 | + return true; | ||
126 | + } | ||
127 | + if (o == null || getClass() != o.getClass()) { | ||
128 | + return false; | ||
129 | + } | ||
130 | + DefaultIsisLinkTed that = (DefaultIsisLinkTed) o; | ||
131 | + return Objects.equal(administrativeGroup, that.administrativeGroup) && | ||
132 | + Objects.equal(ipv4InterfaceAddress, that.ipv4InterfaceAddress) && | ||
133 | + Objects.equal(ipv4NeighborAddress, that.ipv4NeighborAddress) && | ||
134 | + Objects.equal(maximumLinkBandwidth, that.maximumLinkBandwidth) && | ||
135 | + Objects.equal(maximumReservableLinkBandwidth, | ||
136 | + that.maximumReservableLinkBandwidth) && | ||
137 | + Objects.equal(teDefaultMetric, that.teDefaultMetric); | ||
138 | + } | ||
139 | + | ||
140 | + @Override | ||
141 | + public int hashCode() { | ||
142 | + return Objects.hashCode(administrativeGroup, ipv4InterfaceAddress, | ||
143 | + ipv4NeighborAddress, maximumLinkBandwidth, teDefaultMetric); | ||
144 | + } | ||
145 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2015 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 | +package org.onosproject.isis.controller.impl.topology; | ||
18 | + | ||
19 | +import com.google.common.base.MoreObjects; | ||
20 | +import com.google.common.base.Objects; | ||
21 | +import org.onlab.packet.Ip4Address; | ||
22 | +import org.onosproject.isis.controller.topology.IsisRouter; | ||
23 | + | ||
24 | +/** | ||
25 | + * Representation of an ISIS Router. | ||
26 | + */ | ||
27 | +public class DefaultIsisRouter implements IsisRouter { | ||
28 | + | ||
29 | + private String systemId; | ||
30 | + private Ip4Address neighborRouterId; | ||
31 | + private Ip4Address interfaceId; | ||
32 | + private boolean isDis; | ||
33 | + | ||
34 | + /** | ||
35 | + * Gets the system ID. | ||
36 | + * | ||
37 | + * @return systemId system ID | ||
38 | + */ | ||
39 | + public String systemId() { | ||
40 | + return systemId; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Sets IP address of the Router. | ||
45 | + */ | ||
46 | + public void setSystemId(String systemId) { | ||
47 | + this.systemId = systemId; | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * Gets IP address of the interface. | ||
52 | + * | ||
53 | + * @return IP address of the interface | ||
54 | + */ | ||
55 | + public Ip4Address interfaceId() { | ||
56 | + return interfaceId; | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Gets IP address of the interface. | ||
61 | + * | ||
62 | + * @param interfaceId IP address of the interface | ||
63 | + */ | ||
64 | + public void setInterfaceId(Ip4Address interfaceId) { | ||
65 | + this.interfaceId = interfaceId; | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Gets neighbor's Router id. | ||
70 | + * | ||
71 | + * @return neighbor's Router id | ||
72 | + */ | ||
73 | + public Ip4Address neighborRouterId() { | ||
74 | + return neighborRouterId; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Sets neighbor's Router id. | ||
79 | + * | ||
80 | + * @param advertisingRouterId neighbor's Router id | ||
81 | + */ | ||
82 | + public void setNeighborRouterId(Ip4Address advertisingRouterId) { | ||
83 | + this.neighborRouterId = advertisingRouterId; | ||
84 | + } | ||
85 | + | ||
86 | + /** | ||
87 | + * Gets if DR or not. | ||
88 | + * | ||
89 | + * @return true if DR else false | ||
90 | + */ | ||
91 | + public boolean isDis() { | ||
92 | + return isDis; | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Sets dis or not. | ||
97 | + * | ||
98 | + * @param dis true if DIS else false | ||
99 | + */ | ||
100 | + public void setDis(boolean dis) { | ||
101 | + isDis = dis; | ||
102 | + } | ||
103 | + | ||
104 | + @Override | ||
105 | + public String toString() { | ||
106 | + return MoreObjects.toStringHelper(getClass()) | ||
107 | + .omitNullValues() | ||
108 | + .add("systemId", systemId) | ||
109 | + .add("neighborRouterId", neighborRouterId) | ||
110 | + .add("interfaceId", interfaceId) | ||
111 | + .toString(); | ||
112 | + } | ||
113 | + | ||
114 | + @Override | ||
115 | + public boolean equals(Object o) { | ||
116 | + if (this == o) { | ||
117 | + return true; | ||
118 | + } | ||
119 | + if (o == null || getClass() != o.getClass()) { | ||
120 | + return false; | ||
121 | + } | ||
122 | + DefaultIsisRouter that = (DefaultIsisRouter) o; | ||
123 | + return Objects.equal(systemId, that.systemId) && | ||
124 | + Objects.equal(neighborRouterId, that.neighborRouterId) && | ||
125 | + Objects.equal(interfaceId, that.interfaceId); | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
129 | + public int hashCode() { | ||
130 | + return Objects.hashCode(systemId, neighborRouterId, interfaceId); | ||
131 | + } | ||
132 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | +* Copyright 2016 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.isis.controller.impl.topology; | ||
17 | + | ||
18 | +import org.onlab.util.Bandwidth; | ||
19 | +import org.onosproject.isis.controller.topology.DeviceInformation; | ||
20 | +import org.onosproject.isis.controller.topology.IsisRouter; | ||
21 | +import org.onosproject.isis.controller.topology.LinkInformation; | ||
22 | +import org.onosproject.isis.controller.topology.TopologyForDeviceAndLink; | ||
23 | +import org.onosproject.isis.controller.topology.IsisLinkTed; | ||
24 | +import org.onosproject.isis.io.isispacket.pdu.LsPdu; | ||
25 | +import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability; | ||
26 | +import org.onosproject.isis.io.isispacket.tlv.IsisTlv; | ||
27 | +import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs; | ||
28 | + | ||
29 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv; | ||
30 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.InterfaceIpAddress; | ||
31 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.NeighborIpAddress; | ||
32 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup; | ||
33 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric; | ||
34 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.UnreservedBandwidth; | ||
35 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth; | ||
36 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumBandwidth; | ||
37 | +import org.onosproject.isis.io.util.IsisConstants; | ||
38 | +import org.onosproject.isis.io.util.IsisUtil; | ||
39 | +import org.slf4j.Logger; | ||
40 | +import org.slf4j.LoggerFactory; | ||
41 | + | ||
42 | +import java.util.ArrayList; | ||
43 | +import java.util.LinkedHashMap; | ||
44 | +import java.util.List; | ||
45 | +import java.util.Map; | ||
46 | + | ||
47 | +/** | ||
48 | + * Represents device and link topology information. | ||
49 | + */ | ||
50 | +public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { | ||
51 | + | ||
52 | + private static final Logger log = LoggerFactory.getLogger(TopologyForDeviceAndLinkImpl.class); | ||
53 | + private Map<String, DeviceInformation> deviceInformationMap = new LinkedHashMap<>(); | ||
54 | + private Map<String, IsisRouter> isisRouterDetails = new LinkedHashMap<>(); | ||
55 | + private Map<String, DeviceInformation> deviceInformationMapForPointToPoint = new LinkedHashMap<>(); | ||
56 | + private Map<String, DeviceInformation> deviceInformationMapToDelete = new LinkedHashMap<>(); | ||
57 | + private Map<String, LinkInformation> addedLinkInformationMap = new LinkedHashMap<>(); | ||
58 | + | ||
59 | + /** | ||
60 | + * Gets device information. | ||
61 | + * | ||
62 | + * @return device information | ||
63 | + */ | ||
64 | + public Map<String, DeviceInformation> deviceInformationMap() { | ||
65 | + return deviceInformationMap; | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Gets ISIS router list information. | ||
70 | + * | ||
71 | + * @return router information | ||
72 | + */ | ||
73 | + public Map<String, IsisRouter> isisDeviceList() { | ||
74 | + return isisRouterDetails; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Sets device information. | ||
79 | + * | ||
80 | + * @param key key used to add in map | ||
81 | + * @param deviceInformationMap device information instance | ||
82 | + */ | ||
83 | + public void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap) { | ||
84 | + if (deviceInformationMap != null) { | ||
85 | + this.deviceInformationMap.put(key, deviceInformationMap); | ||
86 | + } | ||
87 | + | ||
88 | + } | ||
89 | + | ||
90 | + /** | ||
91 | + * Gets deviceInformation as map for Point-To-Point. | ||
92 | + * | ||
93 | + * @return deviceInformationMap | ||
94 | + */ | ||
95 | + public Map<String, DeviceInformation> deviceInformationMapForPointToPoint() { | ||
96 | + return deviceInformationMapForPointToPoint; | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * Sets deviceInformation as map for Point-To-Point.. | ||
101 | + * | ||
102 | + * @param key key used to add in map | ||
103 | + * @param deviceInformationMap device information instance | ||
104 | + */ | ||
105 | + public void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap) { | ||
106 | + if (deviceInformationMap != null) { | ||
107 | + this.deviceInformationMapForPointToPoint.put(key, deviceInformationMap); | ||
108 | + } | ||
109 | + | ||
110 | + } | ||
111 | + | ||
112 | + /** | ||
113 | + * Gets deviceInformation as map. | ||
114 | + * | ||
115 | + * @return deviceInformationMap to delete from core | ||
116 | + */ | ||
117 | + public Map<String, DeviceInformation> deviceInformationMapToDelete() { | ||
118 | + return deviceInformationMapToDelete; | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * Sets device information for removal. | ||
123 | + * | ||
124 | + * @param key ket used to add in map | ||
125 | + * @param deviceInformationMapToDelete map from device information to remove | ||
126 | + */ | ||
127 | + public void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete) { | ||
128 | + if (deviceInformationMapToDelete != null) { | ||
129 | + this.deviceInformationMapToDelete.put(key, deviceInformationMapToDelete); | ||
130 | + } | ||
131 | + } | ||
132 | + | ||
133 | + /** | ||
134 | + * Removes Device Information. | ||
135 | + * | ||
136 | + * @param key ket used to remove from map | ||
137 | + */ | ||
138 | + public void removeDeviceInformationMapFromDeleteMap(String key) { | ||
139 | + removeDeviceInformationMap(key); | ||
140 | + if (this.deviceInformationMapToDelete.containsKey(key)) { | ||
141 | + this.deviceInformationMapToDelete.remove(key); | ||
142 | + } | ||
143 | + } | ||
144 | + | ||
145 | + /** | ||
146 | + * Gets Device Information. | ||
147 | + * | ||
148 | + * @param key system id as key to store in map | ||
149 | + * @return Device Information | ||
150 | + */ | ||
151 | + public DeviceInformation deviceInformation(String key) { | ||
152 | + DeviceInformation deviceInformation = this.deviceInformationMap.get(key); | ||
153 | + return deviceInformation; | ||
154 | + } | ||
155 | + | ||
156 | + /** | ||
157 | + * Removes Device Information from map. | ||
158 | + * | ||
159 | + * @param key key used to remove from map | ||
160 | + */ | ||
161 | + public void removeDeviceInformationMap(String key) { | ||
162 | + if (this.deviceInformationMap.containsKey(key)) { | ||
163 | + this.deviceInformationMap.remove(key); | ||
164 | + } | ||
165 | + } | ||
166 | + | ||
167 | + @Override | ||
168 | + public void removeLinks(String linkId) { | ||
169 | + this.addedLinkInformationMap.remove(linkId); | ||
170 | + } | ||
171 | + | ||
172 | + /** | ||
173 | + * Gets link information as map. | ||
174 | + * | ||
175 | + * @return link information as map | ||
176 | + */ | ||
177 | + public Map<String, LinkInformation> linkInformationMap() { | ||
178 | + return addedLinkInformationMap; | ||
179 | + } | ||
180 | + | ||
181 | + private LinkInformation getLinkInformation(String key) { | ||
182 | + LinkInformation linkInformation = this.addedLinkInformationMap.get(key); | ||
183 | + return linkInformation; | ||
184 | + } | ||
185 | + | ||
186 | + /** | ||
187 | + * Sets link information in map. | ||
188 | + * | ||
189 | + * @param key key used to add in map | ||
190 | + * @param linkInformationMap link information instance | ||
191 | + */ | ||
192 | + public void setLinkInformationMap(String key, LinkInformation linkInformationMap) { | ||
193 | + if (!this.addedLinkInformationMap.containsKey(key)) { | ||
194 | + this.addedLinkInformationMap.put(key, linkInformationMap); | ||
195 | + } | ||
196 | + } | ||
197 | + | ||
198 | + /** | ||
199 | + * Gets linkInformation as map for PointToPoint. | ||
200 | + * | ||
201 | + * @return linkInformationMap | ||
202 | + */ | ||
203 | + public Map<String, LinkInformation> linkInformationMapForPointToPoint() { | ||
204 | + return addedLinkInformationMap; | ||
205 | + } | ||
206 | + | ||
207 | + /** | ||
208 | + * Sets linkInformation as map for PointToPoint. | ||
209 | + * | ||
210 | + * @param key key used to add in map | ||
211 | + * @param linkInformationMap link information instance | ||
212 | + */ | ||
213 | + public void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap) { | ||
214 | + if (!this.addedLinkInformationMap.containsKey(key)) { | ||
215 | + this.addedLinkInformationMap.put(key, linkInformationMap); | ||
216 | + } | ||
217 | + } | ||
218 | + | ||
219 | + /** | ||
220 | + * Removes Link Information from linkInformationMap. | ||
221 | + * | ||
222 | + * @param key key used to remove in map | ||
223 | + */ | ||
224 | + public void removeLinkInformationMap(String key) { | ||
225 | + if (this.addedLinkInformationMap.containsKey(key)) { | ||
226 | + this.addedLinkInformationMap.remove(key); | ||
227 | + } | ||
228 | + } | ||
229 | + | ||
230 | + /** | ||
231 | + * Returns the ISIS router instance. | ||
232 | + * | ||
233 | + * @param systemId system ID to get router details | ||
234 | + * @return ISIS router instance | ||
235 | + */ | ||
236 | + public IsisRouter isisRouter(String systemId) { | ||
237 | + String routerId = IsisUtil.removeTailingZeros(systemId); | ||
238 | + IsisRouter isisRouter = isisRouterDetails.get(routerId); | ||
239 | + if (isisRouter != null) { | ||
240 | + return isisRouter; | ||
241 | + } else { | ||
242 | + log.debug("IsisRouter is not available"); | ||
243 | + IsisRouter isisRouterCheck = new DefaultIsisRouter(); | ||
244 | + isisRouterCheck.setSystemId(routerId); | ||
245 | + return isisRouterCheck; | ||
246 | + } | ||
247 | + } | ||
248 | + | ||
249 | + /** | ||
250 | + * Removes the ISIS router instance from map. | ||
251 | + * | ||
252 | + * @param systemId system ID to remove router details | ||
253 | + */ | ||
254 | + public void removeRouter(String systemId) { | ||
255 | + String routerId = IsisUtil.removeTailingZeros(systemId); | ||
256 | + isisRouterDetails.remove(systemId); | ||
257 | + } | ||
258 | + | ||
259 | + /** | ||
260 | + * Creates Device instance. | ||
261 | + * | ||
262 | + * @param lsPdu ISIS LSPDU instance | ||
263 | + * @return isisRouter isisRouter instance | ||
264 | + */ | ||
265 | + public IsisRouter createDeviceInfo(LsPdu lsPdu) { | ||
266 | + IsisRouter isisRouter = createIsisRouter(lsPdu); | ||
267 | + | ||
268 | + if (isisRouter.systemId() != null) { | ||
269 | + if (isisRouter.interfaceId() == null && isisRouter.neighborRouterId() == null) { | ||
270 | + isisRouter.setInterfaceId(IsisConstants.DEFAULTIP); | ||
271 | + isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP); | ||
272 | + isisRouterDetails.put(isisRouter.systemId(), isisRouter); | ||
273 | + } | ||
274 | + } | ||
275 | + return isisRouter; | ||
276 | + }/* | ||
277 | + | ||
278 | + *//** | ||
279 | + * Removes Device and Link instance. | ||
280 | + * | ||
281 | + * @param lsPdu ISIS LSPDU instance | ||
282 | + * @return isisRouter isisRouter instance | ||
283 | + *//* | ||
284 | + public IsisRouter removeDeviceAndLinkInfo(LsPdu lsPdu) { | ||
285 | + IsisRouter isisRouter = createIsisRouter(lsPdu); | ||
286 | + return isisRouter; | ||
287 | + }*/ | ||
288 | + | ||
289 | + /** | ||
290 | + * Creates link information. | ||
291 | + * | ||
292 | + * @param lsPdu ls pdu instance | ||
293 | + * @param ownSystemId system ID | ||
294 | + * @return link information | ||
295 | + */ | ||
296 | + public Map<String, LinkInformation> createLinkInfo(LsPdu lsPdu, String ownSystemId) { | ||
297 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { | ||
298 | + if (isisTlv instanceof IsExtendedReachability) { | ||
299 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | ||
300 | + List<NeighborForExtendedIs> neighborForExtendedIsList = isExtendedReachability.neighbours(); | ||
301 | + for (NeighborForExtendedIs neighbor : neighborForExtendedIsList) { | ||
302 | + String neighbourId = neighbor.neighborId(); | ||
303 | + String routerId = IsisUtil.removeTailingZeros(lsPdu.lspId()); | ||
304 | + if (!(neighbourId.equals(ownSystemId))) { | ||
305 | + IsisRouter isisRouter = isisRouterDetails.get(neighbourId); | ||
306 | + if (isisRouter != null) { | ||
307 | + String linkId = "link:" + routerId + "-" + neighbourId; | ||
308 | + addedLinkInformationMap.put(linkId, createLinkInformation(lsPdu, linkId, | ||
309 | + routerId, neighbourId)); | ||
310 | + } else { | ||
311 | + createIsisRouterDummy(neighbourId); | ||
312 | + String linkId = "link:" + routerId + "-" + neighbourId; | ||
313 | + LinkInformation linkInformation = createLinkInformation(lsPdu, linkId, | ||
314 | + routerId, neighbourId); | ||
315 | + linkInformation.setAlreadyCreated(true); | ||
316 | + addedLinkInformationMap.put(linkId, linkInformation); | ||
317 | + } | ||
318 | + } | ||
319 | + | ||
320 | + } | ||
321 | + } | ||
322 | + } | ||
323 | + return addedLinkInformationMap; | ||
324 | + } | ||
325 | + | ||
326 | + /** | ||
327 | + * Removes link information. | ||
328 | + * | ||
329 | + * @param systemId system ID to remove link information | ||
330 | + * @return updated link information | ||
331 | + */ | ||
332 | + public Map<String, LinkInformation> removeLinkInfo(String systemId) { | ||
333 | + String routerId = IsisUtil.removeTailingZeros(systemId); | ||
334 | + Map<String, LinkInformation> removeLinkInformationMap = new LinkedHashMap<>(); | ||
335 | + for (String key : addedLinkInformationMap.keySet()) { | ||
336 | + if (key.contains(routerId)) { | ||
337 | + removeLinkInformationMap.put(key, addedLinkInformationMap.get(key)); | ||
338 | + } | ||
339 | + } | ||
340 | + return removeLinkInformationMap; | ||
341 | + } | ||
342 | + | ||
343 | + /** | ||
344 | + * Creates link information. | ||
345 | + * | ||
346 | + * @param lsPdu link state pdu | ||
347 | + * @param linkId link id | ||
348 | + * @param localRouter local router system id | ||
349 | + * @param neighborId destination router system id | ||
350 | + * @return linkInformation instance | ||
351 | + */ | ||
352 | + private LinkInformation createLinkInformation(LsPdu lsPdu, String linkId, String localRouter, String neighborId) { | ||
353 | + LinkInformation linkInformation = new DefaultIsisLinkInformation(); | ||
354 | + IsisRouter isisRouter = isisRouterDetails.get(neighborId); | ||
355 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { | ||
356 | + if (isisTlv instanceof IsExtendedReachability) { | ||
357 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | ||
358 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); | ||
359 | + for (NeighborForExtendedIs teTlv : neighbours) { | ||
360 | + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv(); | ||
361 | + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) { | ||
362 | + if (teSubTlv instanceof InterfaceIpAddress) { | ||
363 | + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv; | ||
364 | + linkInformation.setInterfaceIp(localIpAddress.localInterfaceIPAddress()); | ||
365 | + } else if (teSubTlv instanceof NeighborIpAddress) { | ||
366 | + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv; | ||
367 | + linkInformation.setNeighborIp(neighborIpAddress.neighborIPAddress()); | ||
368 | + } | ||
369 | + | ||
370 | + } | ||
371 | + } | ||
372 | + } | ||
373 | + } | ||
374 | + linkInformation.setLinkId(linkId); | ||
375 | + linkInformation.setAlreadyCreated(false); | ||
376 | + linkInformation.setLinkDestinationId(neighborId); | ||
377 | + linkInformation.setLinkSourceId(localRouter); | ||
378 | + return linkInformation; | ||
379 | + } | ||
380 | + | ||
381 | + /** | ||
382 | + * Creates ISIS router instance. | ||
383 | + * | ||
384 | + * @param lsPdu lsp instance | ||
385 | + * @return isisRouter instance | ||
386 | + */ | ||
387 | + private IsisRouter createIsisRouter(LsPdu lsPdu) { | ||
388 | + IsisRouter isisRouter = new DefaultIsisRouter(); | ||
389 | + if (IsisUtil.checkIsDis(lsPdu.lspId())) { | ||
390 | + isisRouter.setDis(true); | ||
391 | + } else { | ||
392 | + isisRouter.setDis(false); | ||
393 | + } | ||
394 | + isisRouter.setSystemId(IsisUtil.removeTailingZeros(lsPdu.lspId())); | ||
395 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { | ||
396 | + if (isisTlv instanceof IsExtendedReachability) { | ||
397 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | ||
398 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); | ||
399 | + for (NeighborForExtendedIs teTlv : neighbours) { | ||
400 | + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv(); | ||
401 | + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) { | ||
402 | + if (teSubTlv instanceof InterfaceIpAddress) { | ||
403 | + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv; | ||
404 | + isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress()); | ||
405 | + } else if (teSubTlv instanceof NeighborIpAddress) { | ||
406 | + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv; | ||
407 | + isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress()); | ||
408 | + } | ||
409 | + | ||
410 | + } | ||
411 | + } | ||
412 | + } | ||
413 | + } | ||
414 | + return isisRouter; | ||
415 | + } | ||
416 | + | ||
417 | + /** | ||
418 | + * Creates ISIS router instance. | ||
419 | + * | ||
420 | + * @param systemId system ID | ||
421 | + * @return isisRouter instance | ||
422 | + */ | ||
423 | + private IsisRouter createIsisRouterDummy(String systemId) { | ||
424 | + IsisRouter isisRouter = new DefaultIsisRouter(); | ||
425 | + isisRouter.setSystemId(systemId); | ||
426 | + isisRouter.setDis(false); | ||
427 | + isisRouter.setInterfaceId(IsisConstants.DEFAULTIP); | ||
428 | + isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP); | ||
429 | + | ||
430 | + return isisRouter; | ||
431 | + } | ||
432 | + | ||
433 | + /** | ||
434 | + * Creates the ISIS link TED information. | ||
435 | + * | ||
436 | + * @param lsPdu link state PDU | ||
437 | + * @return isisLinkTed | ||
438 | + */ | ||
439 | + public IsisLinkTed createIsisLinkTedInfo(LsPdu lsPdu) { | ||
440 | + IsisLinkTed isisLinkTed = new DefaultIsisLinkTed(); | ||
441 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { | ||
442 | + if (isisTlv instanceof IsExtendedReachability) { | ||
443 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | ||
444 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); | ||
445 | + for (NeighborForExtendedIs teTlv : neighbours) { | ||
446 | + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv(); | ||
447 | + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) { | ||
448 | + if (teSubTlv instanceof AdministrativeGroup) { | ||
449 | + AdministrativeGroup ag = (AdministrativeGroup) teSubTlv; | ||
450 | + isisLinkTed.setAdministrativeGroup(ag.administrativeGroup()); | ||
451 | + } | ||
452 | + if (teSubTlv instanceof InterfaceIpAddress) { | ||
453 | + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv; | ||
454 | + isisLinkTed.setIpv4InterfaceAddress(localIpAddress.localInterfaceIPAddress()); | ||
455 | + } | ||
456 | + if (teSubTlv instanceof NeighborIpAddress) { | ||
457 | + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv; | ||
458 | + isisLinkTed.setIpv4NeighborAddress(neighborIpAddress.neighborIPAddress()); | ||
459 | + } | ||
460 | + if (teSubTlv instanceof TrafficEngineeringMetric) { | ||
461 | + TrafficEngineeringMetric teM = (TrafficEngineeringMetric) teSubTlv; | ||
462 | + isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue()); | ||
463 | + } | ||
464 | + if (teSubTlv instanceof MaximumBandwidth) { | ||
465 | + MaximumBandwidth maxLinkBandwidth = (MaximumBandwidth) teSubTlv; | ||
466 | + isisLinkTed.setMaximumLinkBandwidth( | ||
467 | + Bandwidth.bps(maxLinkBandwidth.getMaximumBandwidthValue())); | ||
468 | + } | ||
469 | + if (teSubTlv instanceof MaximumReservableBandwidth) { | ||
470 | + MaximumReservableBandwidth maxReservableBw = (MaximumReservableBandwidth) teSubTlv; | ||
471 | + isisLinkTed.setMaximumReservableLinkBandwidth( | ||
472 | + Bandwidth.bps(maxReservableBw.getMaximumBandwidthValue())); | ||
473 | + } | ||
474 | + if (teSubTlv instanceof UnreservedBandwidth) { | ||
475 | + UnreservedBandwidth unReservedBandwidth = (UnreservedBandwidth) teSubTlv; | ||
476 | + List<Bandwidth> bandwidthList = new ArrayList<>(); | ||
477 | + List<Float> unReservedBandwidthList = unReservedBandwidth.unReservedBandwidthValue(); | ||
478 | + for (Float unReservedBandwidthFloatValue : unReservedBandwidthList) { | ||
479 | + Bandwidth bandwidth = Bandwidth.bps(unReservedBandwidthFloatValue); | ||
480 | + bandwidthList.add(bandwidth); | ||
481 | + } | ||
482 | + isisLinkTed.setUnreservedBandwidth(bandwidthList); | ||
483 | + } | ||
484 | + } | ||
485 | + } | ||
486 | + } | ||
487 | + } | ||
488 | + return isisLinkTed; | ||
489 | + } | ||
490 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/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 | +/** | ||
18 | + * Implementation of the ISIS controller topology. | ||
19 | + */ | ||
20 | +package org.onosproject.isis.controller.impl.topology; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -90,7 +90,6 @@ public class LsPdu extends IsisHeader { | ... | @@ -90,7 +90,6 @@ public class LsPdu extends IsisHeader { |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Creates an instance of Link State packet. | 92 | * Creates an instance of Link State packet. |
93 | - * Parameterized constructor which populate | ||
94 | * | 93 | * |
95 | * @param isisHeader isis header details | 94 | * @param isisHeader isis header details |
96 | */ | 95 | */ |
... | @@ -99,6 +98,15 @@ public class LsPdu extends IsisHeader { | ... | @@ -99,6 +98,15 @@ public class LsPdu extends IsisHeader { |
99 | } | 98 | } |
100 | 99 | ||
101 | /** | 100 | /** |
101 | + * Returns the ISIS tlvs. | ||
102 | + * | ||
103 | + * @return tlvs | ||
104 | + */ | ||
105 | + public List<IsisTlv> tlvs() { | ||
106 | + return this.variableLengths; | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
102 | * Adds the isis tlv to the list for the link state PDU. | 110 | * Adds the isis tlv to the list for the link state PDU. |
103 | * | 111 | * |
104 | * @param isisTlv isis tlv | 112 | * @param isisTlv isis tlv | ... | ... |
... | @@ -52,6 +52,15 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { | ... | @@ -52,6 +52,15 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { |
52 | } | 52 | } |
53 | 53 | ||
54 | /** | 54 | /** |
55 | + * Returns list of traffic engineering sub tlvs. | ||
56 | + * | ||
57 | + * @return trafEnginSubTlv | ||
58 | + */ | ||
59 | + public List<TrafficEngineeringSubTlv> teTlvs() { | ||
60 | + return this.trafEnginSubTlv; | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
55 | * Returns the prefix of IP external reachability TLV. | 64 | * Returns the prefix of IP external reachability TLV. |
56 | * | 65 | * |
57 | * @return prefix | 66 | * @return prefix | ... | ... |
... | @@ -41,6 +41,15 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv { | ... | @@ -41,6 +41,15 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv { |
41 | } | 41 | } |
42 | 42 | ||
43 | /** | 43 | /** |
44 | + * Returns neighbor list. | ||
45 | + * | ||
46 | + * @return neighbor list | ||
47 | + */ | ||
48 | + public List<NeighborForExtendedIs> neighbours() { | ||
49 | + return neighbors; | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
44 | * Adds the neighbor for extended IS instance to IS extended reachability TLV. | 53 | * Adds the neighbor for extended IS instance to IS extended reachability TLV. |
45 | * | 54 | * |
46 | * @param neighbor neighbor for extended IS instance | 55 | * @param neighbor neighbor for extended IS instance | ... | ... |
... | @@ -46,6 +46,15 @@ public class NeighborForExtendedIs { | ... | @@ -46,6 +46,15 @@ public class NeighborForExtendedIs { |
46 | } | 46 | } |
47 | 47 | ||
48 | /** | 48 | /** |
49 | + * Returns list of sub tlvs. | ||
50 | + * | ||
51 | + * @return teSubTlv list of sub tlvs | ||
52 | + */ | ||
53 | + public List<TrafficEngineeringSubTlv> teSubTlv() { | ||
54 | + return teSubTlv; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
49 | * Sets neighbor ID. | 58 | * Sets neighbor ID. |
50 | * | 59 | * |
51 | * @param neighborId neighbor ID | 60 | * @param neighborId neighbor ID | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2016-present Open Networking Laboratory | 2 | +* Copyright 2016-present Open Networking Laboratory |
3 | - * | 3 | +* |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | +* You may obtain a copy of the License at |
7 | - * | 7 | +* |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | +* http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | +* |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | +* Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | +* distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
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.isis.io.isispacket.tlv.subtlv; | 16 | package org.onosproject.isis.io.isispacket.tlv.subtlv; |
17 | 17 | ||
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
... | @@ -32,8 +32,8 @@ import java.util.List; | ... | @@ -32,8 +32,8 @@ import java.util.List; |
32 | */ | 32 | */ |
33 | public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringSubTlv { | 33 | public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringSubTlv { |
34 | private static final Logger log = | 34 | private static final Logger log = |
35 | - LoggerFactory.getLogger(InterfaceIpAddress.class); | 35 | + LoggerFactory.getLogger(NeighborIpAddress.class); |
36 | - private List<Ip4Address> localInterfaceIPAddress = new ArrayList<>(); | 36 | + private Ip4Address localInterfaceIPAddress; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * Creates an instance of local interface ip address. | 39 | * Creates an instance of local interface ip address. |
... | @@ -50,16 +50,16 @@ public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringS | ... | @@ -50,16 +50,16 @@ public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringS |
50 | * | 50 | * |
51 | * @param localAddress ip address | 51 | * @param localAddress ip address |
52 | */ | 52 | */ |
53 | - public void addLocalInterfaceIPAddress(Ip4Address localAddress) { | 53 | + public void setIpAddress(Ip4Address localAddress) { |
54 | - localInterfaceIPAddress.add(localAddress); | 54 | + this.localInterfaceIPAddress = localAddress; |
55 | } | 55 | } |
56 | 56 | ||
57 | /** | 57 | /** |
58 | - * Returns local interface ip address. | 58 | + * Gets local interface ip address. |
59 | * | 59 | * |
60 | * @return localAddress ip address | 60 | * @return localAddress ip address |
61 | */ | 61 | */ |
62 | - public List<Ip4Address> getLocalInterfaceIPAddress() { | 62 | + public Ip4Address localInterfaceIPAddress() { |
63 | return localInterfaceIPAddress; | 63 | return localInterfaceIPAddress; |
64 | } | 64 | } |
65 | 65 | ||
... | @@ -72,17 +72,19 @@ public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringS | ... | @@ -72,17 +72,19 @@ public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringS |
72 | while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) { | 72 | while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) { |
73 | byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES]; | 73 | byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES]; |
74 | channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); | 74 | channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); |
75 | - this.addLocalInterfaceIPAddress(Ip4Address.valueOf(tempByteArray)); | 75 | + this.setIpAddress(Ip4Address.valueOf(tempByteArray)); |
76 | + | ||
76 | } | 77 | } |
77 | } | 78 | } |
78 | 79 | ||
79 | /** | 80 | /** |
80 | - * Returns local interface ip address as byte array. | 81 | + * Gets local interface ip address as byte array. |
81 | * | 82 | * |
82 | * @return local interface ip address as byte array | 83 | * @return local interface ip address as byte array |
83 | */ | 84 | */ |
84 | public byte[] asBytes() { | 85 | public byte[] asBytes() { |
85 | byte[] linkSubType = null; | 86 | byte[] linkSubType = null; |
87 | + | ||
86 | byte[] linkSubTlvHeader = tlvHeaderAsByteArray(); | 88 | byte[] linkSubTlvHeader = tlvHeaderAsByteArray(); |
87 | byte[] linkSubTlvBody = tlvBodyAsBytes(); | 89 | byte[] linkSubTlvBody = tlvBodyAsBytes(); |
88 | linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody); | 90 | linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody); |
... | @@ -91,15 +93,16 @@ public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringS | ... | @@ -91,15 +93,16 @@ public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringS |
91 | } | 93 | } |
92 | 94 | ||
93 | /** | 95 | /** |
94 | - * Returns byte array of local interface ip address. | 96 | + * Gets byte array of local interface ip address. |
95 | * | 97 | * |
96 | * @return byte array of local interface ip address | 98 | * @return byte array of local interface ip address |
97 | */ | 99 | */ |
98 | public byte[] tlvBodyAsBytes() { | 100 | public byte[] tlvBodyAsBytes() { |
101 | + | ||
99 | List<Byte> linkSubTypeBody = new ArrayList<>(); | 102 | List<Byte> linkSubTypeBody = new ArrayList<>(); |
100 | - for (Ip4Address remoteAddress : this.localInterfaceIPAddress) { | 103 | + |
101 | - linkSubTypeBody.addAll(Bytes.asList(remoteAddress.toOctets())); | 104 | + linkSubTypeBody.addAll(Bytes.asList(this.localInterfaceIPAddress.toOctets())); |
102 | - } | 105 | + |
103 | 106 | ||
104 | return Bytes.toArray(linkSubTypeBody); | 107 | return Bytes.toArray(linkSubTypeBody); |
105 | } | 108 | } | ... | ... |
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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | +import com.google.common.base.Objects; | ||
20 | +import com.google.common.primitives.Bytes; | ||
21 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
22 | +import org.onlab.packet.Ip4Address; | ||
23 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
24 | +import org.onosproject.isis.io.util.IsisUtil; | ||
25 | +import org.slf4j.Logger; | ||
26 | +import org.slf4j.LoggerFactory; | ||
27 | + | ||
28 | +import java.util.ArrayList; | ||
29 | +import java.util.List; | ||
30 | + | ||
31 | +/** | ||
32 | + * Representation of neighbor ip address TE value. | ||
33 | + */ | ||
34 | +public class NeighborIpAddress extends TlvHeader implements TrafficEngineeringSubTlv { | ||
35 | + private static final Logger log = | ||
36 | + LoggerFactory.getLogger(NeighborIpAddress.class); | ||
37 | + private Ip4Address neighborIPAddress; | ||
38 | + | ||
39 | + /** | ||
40 | + * Creates an instance of neighbor ip address. | ||
41 | + * | ||
42 | + * @param header tlv header instance | ||
43 | + */ | ||
44 | + public NeighborIpAddress(TlvHeader header) { | ||
45 | + this.setTlvType(header.tlvType()); | ||
46 | + this.setTlvLength(header.tlvLength()); | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Sets the neighbor ip address. | ||
51 | + * | ||
52 | + * @param neighborIPAddress ip address | ||
53 | + */ | ||
54 | + public void setIpAddress(Ip4Address neighborIPAddress) { | ||
55 | + this.neighborIPAddress = neighborIPAddress; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Gets the neighbor ip address. | ||
60 | + * | ||
61 | + * @return neighbor ip address | ||
62 | + */ | ||
63 | + public Ip4Address neighborIPAddress() { | ||
64 | + return neighborIPAddress; | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Reads bytes from channel buffer. | ||
69 | + * | ||
70 | + * @param channelBuffer channel buffer instance | ||
71 | + */ | ||
72 | + public void readFrom(ChannelBuffer channelBuffer) { | ||
73 | + while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) { | ||
74 | + byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES]; | ||
75 | + channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); | ||
76 | + this.setIpAddress(Ip4Address.valueOf(tempByteArray)); | ||
77 | + | ||
78 | + } | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * Gets the neighbor ip address as byte array. | ||
83 | + * | ||
84 | + * @return neighbor ip address as byte array | ||
85 | + */ | ||
86 | + public byte[] asBytes() { | ||
87 | + byte[] linkSubType = null; | ||
88 | + | ||
89 | + byte[] linkSubTlvHeader = tlvHeaderAsByteArray(); | ||
90 | + byte[] linkSubTlvBody = tlvBodyAsBytes(); | ||
91 | + linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody); | ||
92 | + | ||
93 | + return linkSubType; | ||
94 | + } | ||
95 | + | ||
96 | + /** | ||
97 | + * Gets byte array of neighborIPAddress. | ||
98 | + * | ||
99 | + * @return byte array of neighborIPAddress | ||
100 | + */ | ||
101 | + public byte[] tlvBodyAsBytes() { | ||
102 | + | ||
103 | + List<Byte> linkSubTypeBody = new ArrayList<>(); | ||
104 | + | ||
105 | + linkSubTypeBody.addAll(Bytes.asList(this.neighborIPAddress.toOctets())); | ||
106 | + | ||
107 | + | ||
108 | + return Bytes.toArray(linkSubTypeBody); | ||
109 | + } | ||
110 | + | ||
111 | + @Override | ||
112 | + public boolean equals(Object o) { | ||
113 | + if (this == o) { | ||
114 | + return true; | ||
115 | + } | ||
116 | + if (o == null || getClass() != o.getClass()) { | ||
117 | + return false; | ||
118 | + } | ||
119 | + NeighborIpAddress that = (NeighborIpAddress) o; | ||
120 | + return Objects.equal(neighborIPAddress, that.neighborIPAddress); | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public int hashCode() { | ||
125 | + return Objects.hashCode(neighborIPAddress); | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
129 | + public String toString() { | ||
130 | + return MoreObjects.toStringHelper(getClass()) | ||
131 | + .omitNullValues() | ||
132 | + .add("localInterfaceIPAddress", neighborIPAddress) | ||
133 | + .toString(); | ||
134 | + } | ||
135 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -71,6 +71,11 @@ public final class SubTlvFinder { | ... | @@ -71,6 +71,11 @@ public final class SubTlvFinder { |
71 | ipInterfaceAddressTlv.readFrom(channelBuffer); | 71 | ipInterfaceAddressTlv.readFrom(channelBuffer); |
72 | subTlv = ipInterfaceAddressTlv; | 72 | subTlv = ipInterfaceAddressTlv; |
73 | break; | 73 | break; |
74 | + case NEIGHBORADDRESS: | ||
75 | + NeighborIpAddress ipNeighborAddressTlv = new NeighborIpAddress(tlvHeader); | ||
76 | + ipNeighborAddressTlv.readFrom(channelBuffer); | ||
77 | + subTlv = ipNeighborAddressTlv; | ||
78 | + break; | ||
74 | default: | 79 | default: |
75 | //TODO | 80 | //TODO |
76 | break; | 81 | break; | ... | ... |
protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java
... | @@ -60,8 +60,8 @@ public final class SubTlvToBytes { | ... | @@ -60,8 +60,8 @@ public final class SubTlvToBytes { |
60 | } else if (subTlv instanceof UnreservedBandwidth) { | 60 | } else if (subTlv instanceof UnreservedBandwidth) { |
61 | UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) subTlv; | 61 | UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) subTlv; |
62 | subTlvBytes.addAll(Bytes.asList(unreservedBandwidth.asBytes())); | 62 | subTlvBytes.addAll(Bytes.asList(unreservedBandwidth.asBytes())); |
63 | - } else if (subTlv instanceof InterfaceIpAddress) { | 63 | + } else if (subTlv instanceof NeighborIpAddress) { |
64 | - InterfaceIpAddress interfaceIpAddress = (InterfaceIpAddress) subTlv; | 64 | + NeighborIpAddress interfaceIpAddress = (NeighborIpAddress) subTlv; |
65 | subTlvBytes.addAll(Bytes.asList(interfaceIpAddress.asBytes())); | 65 | subTlvBytes.addAll(Bytes.asList(interfaceIpAddress.asBytes())); |
66 | } else { | 66 | } else { |
67 | log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes "); | 67 | log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes "); | ... | ... |
... | @@ -44,6 +44,10 @@ public enum SubTlvType { | ... | @@ -44,6 +44,10 @@ public enum SubTlvType { |
44 | */ | 44 | */ |
45 | INTERFACEADDRESS(6), | 45 | INTERFACEADDRESS(6), |
46 | /** | 46 | /** |
47 | + * Represents traffic engineering neighbor address TLV. | ||
48 | + */ | ||
49 | + NEIGHBORADDRESS(8), | ||
50 | + /** | ||
47 | * Represents traffic engineering unreserved bandwidth TLV. | 51 | * Represents traffic engineering unreserved bandwidth TLV. |
48 | */ | 52 | */ |
49 | UNRESERVEDBANDWIDTH(11); | 53 | UNRESERVEDBANDWIDTH(11); | ... | ... |
... | @@ -54,7 +54,7 @@ public class UnreservedBandwidth extends TlvHeader implements TrafficEngineering | ... | @@ -54,7 +54,7 @@ public class UnreservedBandwidth extends TlvHeader implements TrafficEngineering |
54 | * | 54 | * |
55 | * @return List of un reserved bandwidth | 55 | * @return List of un reserved bandwidth |
56 | */ | 56 | */ |
57 | - public List<Float> getUnReservedBandwidthValue() { | 57 | + public List<Float> unReservedBandwidthValue() { |
58 | return this.unReservedBandwidth; | 58 | return this.unReservedBandwidth; |
59 | } | 59 | } |
60 | 60 | ... | ... |
... | @@ -65,6 +65,9 @@ public final class IsisConstants { | ... | @@ -65,6 +65,9 @@ public final class IsisConstants { |
65 | public static final String AREAADDRESS = "areaAddress"; | 65 | public static final String AREAADDRESS = "areaAddress"; |
66 | public static final String HOLDINGTIME = "holdingTime"; | 66 | public static final String HOLDINGTIME = "holdingTime"; |
67 | public static final String HELLOINTERVAL = "helloInterval"; | 67 | public static final String HELLOINTERVAL = "helloInterval"; |
68 | + public static final int PORT = 7000; | ||
69 | + public static final String LSPADDED = "LSP_ADDED"; | ||
70 | + public static final String LSPREMOVED = "LSP_REMOVED"; | ||
68 | 71 | ||
69 | /** | 72 | /** |
70 | * Non parameterized constructor. | 73 | * Non parameterized constructor. | ... | ... |
... | @@ -726,4 +726,37 @@ public final class IsisUtil { | ... | @@ -726,4 +726,37 @@ public final class IsisUtil { |
726 | } | 726 | } |
727 | return Bytes.toArray(byteList); | 727 | return Bytes.toArray(byteList); |
728 | } | 728 | } |
729 | + | ||
730 | + /** | ||
731 | + * Return the DIS value from the systemId. | ||
732 | + * | ||
733 | + * @param systemId system Id. | ||
734 | + * @return return true if DIS else false | ||
735 | + */ | ||
736 | + public static boolean checkIsDis(String systemId) { | ||
737 | + StringTokenizer stringTokenizer = new StringTokenizer(systemId, "." + "-"); | ||
738 | + int count = 0; | ||
739 | + while (stringTokenizer.hasMoreTokens()) { | ||
740 | + String str = stringTokenizer.nextToken(); | ||
741 | + if (count == 3) { | ||
742 | + int x = Integer.parseInt(str); | ||
743 | + if (x > 0) { | ||
744 | + return true; | ||
745 | + } | ||
746 | + } | ||
747 | + count++; | ||
748 | + } | ||
749 | + return false; | ||
750 | + } | ||
751 | + | ||
752 | + /** | ||
753 | + * Return the systemId. | ||
754 | + * | ||
755 | + * @param systemId system Id. | ||
756 | + * @return return system ID | ||
757 | + */ | ||
758 | + public static String removeTailingZeros(String systemId) { | ||
759 | + StringTokenizer stringTokenizer = new StringTokenizer(systemId, "-"); | ||
760 | + return stringTokenizer.nextToken(); | ||
761 | + } | ||
729 | } | 762 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.notNullValue; | ... | @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.notNullValue; |
33 | public class InterfaceIpAddressTest { | 33 | public class InterfaceIpAddressTest { |
34 | private final byte[] packet = {1, 1, 1, 1}; | 34 | private final byte[] packet = {1, 1, 1, 1}; |
35 | private final byte[] packet1 = {}; | 35 | private final byte[] packet1 = {}; |
36 | - private InterfaceIpAddress interfaceIpAddress; | 36 | + private NeighborIpAddress interfaceIpAddress; |
37 | private TlvHeader tlvHeader; | 37 | private TlvHeader tlvHeader; |
38 | private Ip4Address ip4Address = Ip4Address.valueOf("1.1.1.1"); | 38 | private Ip4Address ip4Address = Ip4Address.valueOf("1.1.1.1"); |
39 | private byte[] result; | 39 | private byte[] result; |
... | @@ -41,7 +41,7 @@ public class InterfaceIpAddressTest { | ... | @@ -41,7 +41,7 @@ public class InterfaceIpAddressTest { |
41 | 41 | ||
42 | @Before | 42 | @Before |
43 | public void setUp() throws Exception { | 43 | public void setUp() throws Exception { |
44 | - interfaceIpAddress = new InterfaceIpAddress(new TlvHeader()); | 44 | + interfaceIpAddress = new NeighborIpAddress(new TlvHeader()); |
45 | } | 45 | } |
46 | 46 | ||
47 | @After | 47 | @After |
... | @@ -61,15 +61,6 @@ public class InterfaceIpAddressTest { | ... | @@ -61,15 +61,6 @@ public class InterfaceIpAddressTest { |
61 | } | 61 | } |
62 | 62 | ||
63 | /** | 63 | /** |
64 | - * Tests addLocalInterfaceIPAddress() method. | ||
65 | - */ | ||
66 | - @Test | ||
67 | - public void testAddLocalInterfaceIPAddress() throws Exception { | ||
68 | - interfaceIpAddress.addLocalInterfaceIPAddress(ip4Address); | ||
69 | - assertThat(interfaceIpAddress, is(notNullValue())); | ||
70 | - } | ||
71 | - | ||
72 | - /** | ||
73 | * Tests readFrom() method. | 64 | * Tests readFrom() method. |
74 | */ | 65 | */ |
75 | @Test | 66 | @Test |
... | @@ -77,7 +68,7 @@ public class InterfaceIpAddressTest { | ... | @@ -77,7 +68,7 @@ public class InterfaceIpAddressTest { |
77 | tlvHeader = new TlvHeader(); | 68 | tlvHeader = new TlvHeader(); |
78 | tlvHeader.setTlvType(3); | 69 | tlvHeader.setTlvType(3); |
79 | tlvHeader.setTlvLength(4); | 70 | tlvHeader.setTlvLength(4); |
80 | - interfaceIpAddress = new InterfaceIpAddress(tlvHeader); | 71 | + interfaceIpAddress = new NeighborIpAddress(tlvHeader); |
81 | channelBuffer = ChannelBuffers.copiedBuffer(packet); | 72 | channelBuffer = ChannelBuffers.copiedBuffer(packet); |
82 | interfaceIpAddress.readFrom(channelBuffer); | 73 | interfaceIpAddress.readFrom(channelBuffer); |
83 | assertThat(interfaceIpAddress, is(notNullValue())); | 74 | assertThat(interfaceIpAddress, is(notNullValue())); |
... | @@ -91,27 +82,11 @@ public class InterfaceIpAddressTest { | ... | @@ -91,27 +82,11 @@ public class InterfaceIpAddressTest { |
91 | tlvHeader = new TlvHeader(); | 82 | tlvHeader = new TlvHeader(); |
92 | tlvHeader.setTlvType(3); | 83 | tlvHeader.setTlvType(3); |
93 | tlvHeader.setTlvLength(4); | 84 | tlvHeader.setTlvLength(4); |
94 | - interfaceIpAddress = new InterfaceIpAddress(tlvHeader); | 85 | + interfaceIpAddress = new NeighborIpAddress(tlvHeader); |
95 | channelBuffer = ChannelBuffers.copiedBuffer(packet1); | 86 | channelBuffer = ChannelBuffers.copiedBuffer(packet1); |
96 | interfaceIpAddress.readFrom(channelBuffer); | 87 | interfaceIpAddress.readFrom(channelBuffer); |
97 | assertThat(interfaceIpAddress, is(notNullValue())); | 88 | assertThat(interfaceIpAddress, is(notNullValue())); |
98 | } | 89 | } |
99 | 90 | ||
100 | - /** | ||
101 | - * Tests asBytes() method. | ||
102 | - */ | ||
103 | - @Test | ||
104 | - public void testAsBytes() throws Exception { | ||
105 | - result = interfaceIpAddress.asBytes(); | ||
106 | - assertThat(result, is(notNullValue())); | ||
107 | - } | ||
108 | 91 | ||
109 | - /** | ||
110 | - * Tests getLinkSubTypeTlvBodyAsByteArray() method. | ||
111 | - */ | ||
112 | - @Test | ||
113 | - public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception { | ||
114 | - result = interfaceIpAddress.tlvBodyAsBytes(); | ||
115 | - assertThat(result, is(notNullValue())); | ||
116 | - } | ||
117 | } | 92 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -3,7 +3,7 @@ BUNDLES = [ | ... | @@ -3,7 +3,7 @@ BUNDLES = [ |
3 | '//protocols/isis/ctl:onos-protocols-isis-ctl', | 3 | '//protocols/isis/ctl:onos-protocols-isis-ctl', |
4 | '//protocols/isis/isisio:onos-protocols-isis-isisio', | 4 | '//protocols/isis/isisio:onos-protocols-isis-isisio', |
5 | '//providers/isis/cfg:onos-providers-isis-cfg', | 5 | '//providers/isis/cfg:onos-providers-isis-cfg', |
6 | - '//providers/isis/device:onos-providers-isis-device', | 6 | + '//providers/isis/topology:onos-providers-isis-topology', |
7 | ] | 7 | ] |
8 | 8 | ||
9 | onos_app ( | 9 | onos_app ( | ... | ... |
... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
21 | <artifact>mvn:${project.groupId}/onos-isis-api/${project.version}</artifact> | 21 | <artifact>mvn:${project.groupId}/onos-isis-api/${project.version}</artifact> |
22 | <artifact>mvn:${project.groupId}/onos-isis-isisio/${project.version}</artifact> | 22 | <artifact>mvn:${project.groupId}/onos-isis-isisio/${project.version}</artifact> |
23 | <artifact>mvn:${project.groupId}/onos-isis-ctl/${project.version}</artifact> | 23 | <artifact>mvn:${project.groupId}/onos-isis-ctl/${project.version}</artifact> |
24 | - <artifact>mvn:${project.groupId}/onos-isis-provider-device/${project.version}</artifact> | 24 | + <artifact>mvn:${project.groupId}/onos-isis-provider-topology/${project.version}</artifact> |
25 | <artifact>mvn:${project.groupId}/onos-isis-provider-cfg/${project.version}</artifact> | 25 | <artifact>mvn:${project.groupId}/onos-isis-provider-cfg/${project.version}</artifact> |
26 | + <artifact>mvn:${project.groupId}/onos-isis-provider-cli/${project.version}</artifact> | ||
26 | </app> | 27 | </app> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -21,7 +21,8 @@ | ... | @@ -21,7 +21,8 @@ |
21 | <bundle>mvn:${project.groupId}/onos-isis-api/${project.version}</bundle> | 21 | <bundle>mvn:${project.groupId}/onos-isis-api/${project.version}</bundle> |
22 | <bundle>mvn:${project.groupId}/onos-isis-isisio/${project.version}</bundle> | 22 | <bundle>mvn:${project.groupId}/onos-isis-isisio/${project.version}</bundle> |
23 | <bundle>mvn:${project.groupId}/onos-isis-ctl/${project.version}</bundle> | 23 | <bundle>mvn:${project.groupId}/onos-isis-ctl/${project.version}</bundle> |
24 | - <bundle>mvn:${project.groupId}/onos-isis-provider-device/${project.version}</bundle> | 24 | + <bundle>mvn:${project.groupId}/onos-isis-provider-topology/${project.version}</bundle> |
25 | <bundle>mvn:${project.groupId}/onos-isis-provider-cfg/${project.version}</bundle> | 25 | <bundle>mvn:${project.groupId}/onos-isis-provider-cfg/${project.version}</bundle> |
26 | + <bundle>mvn:${project.groupId}/onos-isis-provider-cli/${project.version}</bundle> | ||
26 | </feature> | 27 | </feature> |
27 | </features> | 28 | </features> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -48,7 +48,7 @@ | ... | @@ -48,7 +48,7 @@ |
48 | </dependency> | 48 | </dependency> |
49 | <dependency> | 49 | <dependency> |
50 | <groupId>org.onosproject</groupId> | 50 | <groupId>org.onosproject</groupId> |
51 | - <artifactId>onos-isis-provider-device</artifactId> | 51 | + <artifactId>onos-isis-provider-topology</artifactId> |
52 | <version>${project.version}</version> | 52 | <version>${project.version}</version> |
53 | </dependency> | 53 | </dependency> |
54 | <dependency> | 54 | <dependency> |
... | @@ -56,5 +56,10 @@ | ... | @@ -56,5 +56,10 @@ |
56 | <artifactId>onos-isis-provider-cfg</artifactId> | 56 | <artifactId>onos-isis-provider-cfg</artifactId> |
57 | <version>${project.version}</version> | 57 | <version>${project.version}</version> |
58 | </dependency> | 58 | </dependency> |
59 | + <dependency> | ||
60 | + <groupId>org.onosproject</groupId> | ||
61 | + <artifactId>onos-isis-provider-cli</artifactId> | ||
62 | + <version>${project.version}</version> | ||
63 | + </dependency> | ||
59 | </dependencies> | 64 | </dependencies> |
60 | </project> | 65 | </project> | ... | ... |
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 | -package org.onosproject.provider.isis.device.impl; | ||
18 | - | ||
19 | -import org.apache.felix.scr.annotations.Activate; | ||
20 | -import org.apache.felix.scr.annotations.Component; | ||
21 | -import org.apache.felix.scr.annotations.Deactivate; | ||
22 | -import org.apache.felix.scr.annotations.Reference; | ||
23 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
24 | -import org.onosproject.isis.controller.IsisController; | ||
25 | -import org.onosproject.net.provider.AbstractProvider; | ||
26 | -import org.onosproject.net.provider.ProviderId; | ||
27 | -import org.slf4j.Logger; | ||
28 | - | ||
29 | -import static org.slf4j.LoggerFactory.getLogger; | ||
30 | - | ||
31 | -/** | ||
32 | - * Provider which advertises device descriptions to the core. | ||
33 | - */ | ||
34 | -@Component(immediate = true) | ||
35 | -public class IsisTopologyProvider extends AbstractProvider { | ||
36 | - | ||
37 | - private static final Logger log = getLogger(IsisTopologyProvider.class); | ||
38 | - final InternalDeviceProvider listener = new InternalDeviceProvider(); | ||
39 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
40 | - private IsisController isisController; | ||
41 | - | ||
42 | - | ||
43 | - /** | ||
44 | - * Creates an ISIS device provider. | ||
45 | - */ | ||
46 | - public IsisTopologyProvider() { | ||
47 | - super(new ProviderId("isis", "org.onosproject.provider.isis")); | ||
48 | - } | ||
49 | - | ||
50 | - @Activate | ||
51 | - public void activate() { | ||
52 | - log.debug("Activate...!!!"); | ||
53 | - } | ||
54 | - | ||
55 | - @Deactivate | ||
56 | - public void deactivate() { | ||
57 | - log.debug("Deactivate...!!!"); | ||
58 | - } | ||
59 | - | ||
60 | - /** | ||
61 | - * Internal device provider implementation. | ||
62 | - */ | ||
63 | - private class InternalDeviceProvider { | ||
64 | - | ||
65 | - } | ||
66 | -} |
... | @@ -31,10 +31,10 @@ | ... | @@ -31,10 +31,10 @@ |
31 | <description>ONOS ISIS protocol adapters</description> | 31 | <description>ONOS ISIS protocol adapters</description> |
32 | 32 | ||
33 | <modules> | 33 | <modules> |
34 | - <module>device</module> | ||
35 | <module>app</module> | 34 | <module>app</module> |
36 | <module>cfg</module> | 35 | <module>cfg</module> |
37 | <module>cli</module> | 36 | <module>cli</module> |
37 | + <module>topology</module> | ||
38 | </modules> | 38 | </modules> |
39 | 39 | ||
40 | <dependencies> | 40 | <dependencies> | ... | ... |
1 | COMPILE_DEPS = [ | 1 | COMPILE_DEPS = [ |
2 | '//lib:CORE_DEPS', | 2 | '//lib:CORE_DEPS', |
3 | '//protocols/isis/api:onos-protocols-isis-api', | 3 | '//protocols/isis/api:onos-protocols-isis-api', |
4 | + '//protocols/isis/ctl:onos-protocols-isis-ctl', | ||
5 | +] | ||
6 | + | ||
7 | +TEST_DEPS = [ | ||
8 | + '//lib:TEST_ADAPTERS', | ||
4 | ] | 9 | ] |
5 | 10 | ||
6 | osgi_jar_with_tests ( | 11 | osgi_jar_with_tests ( |
7 | deps = COMPILE_DEPS, | 12 | deps = COMPILE_DEPS, |
13 | + test_deps = TEST_DEPS, | ||
8 | ) | 14 | ) |
9 | - | ... | ... |
... | @@ -25,7 +25,7 @@ | ... | @@ -25,7 +25,7 @@ |
25 | <version>1.7.0-SNAPSHOT</version> | 25 | <version>1.7.0-SNAPSHOT</version> |
26 | </parent> | 26 | </parent> |
27 | 27 | ||
28 | - <artifactId>onos-isis-provider-device</artifactId> | 28 | + <artifactId>onos-isis-provider-topology</artifactId> |
29 | <packaging>bundle</packaging> | 29 | <packaging>bundle</packaging> |
30 | 30 | ||
31 | <description>ONOS ISIS Providers</description> | 31 | <description>ONOS ISIS Providers</description> | ... | ... |
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 | +package org.onosproject.provider.isis.topology.impl; | ||
18 | + | ||
19 | +import org.apache.felix.scr.annotations.Activate; | ||
20 | +import org.apache.felix.scr.annotations.Component; | ||
21 | +import org.apache.felix.scr.annotations.Deactivate; | ||
22 | +import org.apache.felix.scr.annotations.Reference; | ||
23 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
24 | +import org.onlab.packet.ChassisId; | ||
25 | +import org.onlab.util.Bandwidth; | ||
26 | +import org.onosproject.isis.controller.IsisController; | ||
27 | +import org.onosproject.isis.controller.topology.IsisLink; | ||
28 | +import org.onosproject.isis.controller.topology.IsisLinkListener; | ||
29 | +import org.onosproject.isis.controller.topology.IsisLinkTed; | ||
30 | +import org.onosproject.isis.controller.topology.IsisRouter; | ||
31 | +import org.onosproject.isis.controller.topology.IsisRouterId; | ||
32 | +import org.onosproject.isis.controller.topology.IsisRouterListener; | ||
33 | +import org.onosproject.net.AnnotationKeys; | ||
34 | +import org.onosproject.net.ConnectPoint; | ||
35 | +import org.onosproject.net.DefaultAnnotations; | ||
36 | +import org.onosproject.net.Device; | ||
37 | +import org.onosproject.net.DeviceId; | ||
38 | +import org.onosproject.net.Link; | ||
39 | +import org.onosproject.net.MastershipRole; | ||
40 | +import org.onosproject.net.PortNumber; | ||
41 | +import org.onosproject.net.config.NetworkConfigService; | ||
42 | +import org.onosproject.net.config.basics.BandwidthCapacity; | ||
43 | +import org.onosproject.net.device.DefaultDeviceDescription; | ||
44 | +import org.onosproject.net.device.DefaultPortDescription; | ||
45 | +import org.onosproject.net.device.DeviceDescription; | ||
46 | +import org.onosproject.net.device.DeviceProvider; | ||
47 | +import org.onosproject.net.device.DeviceProviderRegistry; | ||
48 | +import org.onosproject.net.device.DeviceProviderService; | ||
49 | +import org.onosproject.net.device.PortDescription; | ||
50 | +import org.onosproject.net.link.DefaultLinkDescription; | ||
51 | +import org.onosproject.net.link.LinkDescription; | ||
52 | +import org.onosproject.net.link.LinkProvider; | ||
53 | +import org.onosproject.net.link.LinkProviderRegistry; | ||
54 | +import org.onosproject.net.link.LinkProviderService; | ||
55 | +import org.onosproject.net.link.LinkService; | ||
56 | +import org.onosproject.net.provider.AbstractProvider; | ||
57 | +import org.onosproject.net.provider.ProviderId; | ||
58 | +import org.slf4j.Logger; | ||
59 | + | ||
60 | +import java.util.ArrayList; | ||
61 | +import java.util.HashMap; | ||
62 | +import java.util.List; | ||
63 | +import java.util.StringTokenizer; | ||
64 | + | ||
65 | +import static org.slf4j.LoggerFactory.getLogger; | ||
66 | + | ||
67 | +/** | ||
68 | + * Provider which advertises device descriptions to the core. | ||
69 | + */ | ||
70 | +@Component(immediate = true) | ||
71 | +public class IsisTopologyProvider extends AbstractProvider implements DeviceProvider, LinkProvider { | ||
72 | + | ||
73 | + public static final long PSEUDO_PORT = 0xffffffff; | ||
74 | + public static final String ADMINISTRATIVEGROUP = "administrativeGroup"; | ||
75 | + public static final String TE_METRIC = "teMetric"; | ||
76 | + public static final String MAXRESERVABLEBANDWIDTH = "maxReservableBandwidth"; | ||
77 | + public static final String ROUTERID = "routerId"; | ||
78 | + public static final String NEIGHBORID = "neighborId"; | ||
79 | + private static final Logger log = getLogger(IsisTopologyProvider.class); | ||
80 | + // Default values for tunable parameters | ||
81 | + private static final String UNKNOWN = "unknown"; | ||
82 | + final InternalTopologyProvider listener = new InternalTopologyProvider(); | ||
83 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
84 | + protected DeviceProviderRegistry deviceProviderRegistry; | ||
85 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
86 | + protected LinkProviderRegistry linkProviderRegistry; | ||
87 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
88 | + protected NetworkConfigService networkConfigService; | ||
89 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
90 | + protected LinkService linkService; | ||
91 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
92 | + protected IsisController controller; | ||
93 | + //This Interface that defines how this provider can interact with the core. | ||
94 | + private LinkProviderService linkProviderService; | ||
95 | + // The interface that defines how this Provider can interact with the core | ||
96 | + private DeviceProviderService deviceProviderService; | ||
97 | + private HashMap<DeviceId, List<PortDescription>> portMap = new HashMap<>(); | ||
98 | + | ||
99 | + /** | ||
100 | + * Creates an ISIS device provider. | ||
101 | + */ | ||
102 | + public IsisTopologyProvider() { | ||
103 | + super(new ProviderId("l3", "org.onosproject.provider.isis")); | ||
104 | + } | ||
105 | + | ||
106 | + @Activate | ||
107 | + public void activate() { | ||
108 | + deviceProviderService = deviceProviderRegistry.register(this); | ||
109 | + linkProviderService = linkProviderRegistry.register(this); | ||
110 | + controller.addRouterListener(listener); | ||
111 | + controller.addLinkListener(listener); | ||
112 | + log.debug("IsisDeviceProvider::activate...!!!!"); | ||
113 | + } | ||
114 | + | ||
115 | + @Deactivate | ||
116 | + public void deactivate() { | ||
117 | + log.debug("IsisDeviceProvider::deactivate...!!!!"); | ||
118 | + deviceProviderRegistry.unregister(this); | ||
119 | + deviceProviderService = null; | ||
120 | + linkProviderRegistry.unregister(this); | ||
121 | + linkProviderService = null; | ||
122 | + controller.removeRouterListener(listener); | ||
123 | + controller.removeLinkListener(listener); | ||
124 | + } | ||
125 | + | ||
126 | + @Override | ||
127 | + public void triggerProbe(DeviceId deviceId) { | ||
128 | + log.debug("IsisDeviceProvider::triggerProbe...!!!!"); | ||
129 | + } | ||
130 | + | ||
131 | + @Override | ||
132 | + public void roleChanged(DeviceId deviceId, MastershipRole newRole) { | ||
133 | + log.debug("IsisDeviceProvider::roleChanged...!!!!"); | ||
134 | + } | ||
135 | + | ||
136 | + @Override | ||
137 | + public boolean isReachable(DeviceId deviceId) { | ||
138 | + log.debug("IsisDeviceProvider::isReachable...!!!!"); | ||
139 | + return true; | ||
140 | + } | ||
141 | + | ||
142 | + @Override | ||
143 | + public void changePortState(DeviceId deviceId, PortNumber portNumber, boolean enable) { | ||
144 | + log.debug("IsisDeviceProvider::changePortState...!!!!"); | ||
145 | + } | ||
146 | + | ||
147 | + /** | ||
148 | + * Builds link description. | ||
149 | + * | ||
150 | + * @param isisLink ISIS link instance | ||
151 | + * @return link description | ||
152 | + */ | ||
153 | + private LinkDescription buildLinkDes(IsisLink isisLink) { | ||
154 | + long srcAddress = 0; | ||
155 | + long dstAddress = 0; | ||
156 | + boolean localPseduo = false; | ||
157 | + boolean remotePseduo = false; | ||
158 | + String localSystemId = isisLink.localSystemId(); | ||
159 | + String remoteSystemId = isisLink.remoteSystemId(); | ||
160 | + //Changing of port numbers | ||
161 | + if (isisLink.interfaceIp() != null) { | ||
162 | + //srcAddress = isisLink.interfaceIp().toInt(); | ||
163 | + srcAddress = (long) Long.parseUnsignedLong(Integer.toBinaryString(isisLink.interfaceIp().toInt()), 2); | ||
164 | + } | ||
165 | + if (isisLink.neighborIp() != null) { | ||
166 | + //dstAddress = isisLink.neighborIp().toInt(); | ||
167 | + dstAddress = (long) Long.parseUnsignedLong(Integer.toBinaryString(isisLink.neighborIp().toInt()), 2); | ||
168 | + } | ||
169 | + DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId)); | ||
170 | + DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId)); | ||
171 | + if (checkIsDis(isisLink.localSystemId())) { | ||
172 | + localPseduo = true; | ||
173 | + } else if (checkIsDis(isisLink.remoteSystemId())) { | ||
174 | + remotePseduo = true; | ||
175 | + } else { | ||
176 | + log.debug("IsisDeviceProvider::buildLinkDes : unknown type.!"); | ||
177 | + } | ||
178 | + | ||
179 | + if (localPseduo && srcAddress == 0) { | ||
180 | + srcAddress = PSEUDO_PORT; | ||
181 | + } else if (remotePseduo && dstAddress == 0) { | ||
182 | + dstAddress = PSEUDO_PORT; | ||
183 | + } | ||
184 | + | ||
185 | + ConnectPoint src = new ConnectPoint(srcId, PortNumber.portNumber(srcAddress)); | ||
186 | + ConnectPoint dst = new ConnectPoint(dstId, PortNumber.portNumber(dstAddress)); | ||
187 | + DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder(); | ||
188 | + if (isisLink != null) { | ||
189 | + annotationBuilder = buildAnnotations(annotationBuilder, isisLink); | ||
190 | + } | ||
191 | + | ||
192 | + return new DefaultLinkDescription(src, dst, Link.Type.DIRECT, false, annotationBuilder.build()); | ||
193 | + } | ||
194 | + | ||
195 | + /** | ||
196 | + * Return the DIS value from the systemId. | ||
197 | + * | ||
198 | + * @param systemId system Id. | ||
199 | + * @return return true if DIS else false | ||
200 | + */ | ||
201 | + public static boolean checkIsDis(String systemId) { | ||
202 | + StringTokenizer stringTokenizer = new StringTokenizer(systemId, "." + "-"); | ||
203 | + int count = 0; | ||
204 | + while (stringTokenizer.hasMoreTokens()) { | ||
205 | + String str = stringTokenizer.nextToken(); | ||
206 | + if (count == 3) { | ||
207 | + int x = Integer.parseInt(str); | ||
208 | + if (x > 0) { | ||
209 | + return true; | ||
210 | + } | ||
211 | + } | ||
212 | + count++; | ||
213 | + } | ||
214 | + return false; | ||
215 | + } | ||
216 | + | ||
217 | + /** | ||
218 | + * Builds port description. | ||
219 | + * | ||
220 | + * @param deviceId device ID for the port | ||
221 | + * @param portNumber port number of the link | ||
222 | + * @return list of port description | ||
223 | + */ | ||
224 | + private List<PortDescription> buildPortDescriptions(DeviceId deviceId, | ||
225 | + PortNumber portNumber) { | ||
226 | + List<PortDescription> portList; | ||
227 | + if (portMap.containsKey(deviceId)) { | ||
228 | + portList = portMap.get(deviceId); | ||
229 | + } else { | ||
230 | + portList = new ArrayList<>(); | ||
231 | + } | ||
232 | + if (portNumber != null) { | ||
233 | + PortDescription portDescriptions = new DefaultPortDescription(portNumber, true); | ||
234 | + portList.add(portDescriptions); | ||
235 | + } | ||
236 | + portMap.put(deviceId, portList); | ||
237 | + | ||
238 | + return portList; | ||
239 | + } | ||
240 | + | ||
241 | + /** | ||
242 | + * Builds the annotation details. | ||
243 | + * | ||
244 | + * @param annotationBuilder default annotation builder instance | ||
245 | + * @param isisLink ISIS link instance | ||
246 | + * @return annotation builder instance | ||
247 | + */ | ||
248 | + private DefaultAnnotations.Builder buildAnnotations(DefaultAnnotations.Builder annotationBuilder, | ||
249 | + IsisLink isisLink) { | ||
250 | + int administrativeGroup = 0; | ||
251 | + long teMetric = 0; | ||
252 | + Bandwidth maxReservableBandwidth = Bandwidth.bps(0); | ||
253 | + String routerId = null; | ||
254 | + String neighborId = null; | ||
255 | + | ||
256 | + //TE Info | ||
257 | + IsisLinkTed isisLinkTed = isisLink.linkTed(); | ||
258 | + log.info("Ted Information: {}", isisLinkTed.toString()); | ||
259 | + administrativeGroup = isisLinkTed.administrativeGroup(); | ||
260 | + teMetric = isisLinkTed.teDefaultMetric(); | ||
261 | + maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth(); | ||
262 | + routerId = isisLink.localSystemId(); | ||
263 | + neighborId = isisLink.remoteSystemId(); | ||
264 | + annotationBuilder.set(ADMINISTRATIVEGROUP, String.valueOf(administrativeGroup)); | ||
265 | + annotationBuilder.set(TE_METRIC, String.valueOf(teMetric)); | ||
266 | + annotationBuilder.set(MAXRESERVABLEBANDWIDTH, String.valueOf(maxReservableBandwidth)); | ||
267 | + annotationBuilder.set(ROUTERID, String.valueOf(routerId)); | ||
268 | + annotationBuilder.set(NEIGHBORID, String.valueOf(neighborId)); | ||
269 | + return annotationBuilder; | ||
270 | + } | ||
271 | + | ||
272 | + /** | ||
273 | + * Internal device provider implementation. | ||
274 | + */ | ||
275 | + private class InternalTopologyProvider implements IsisRouterListener, IsisLinkListener { | ||
276 | + | ||
277 | + @Override | ||
278 | + public void routerAdded(IsisRouter isisRouter) { | ||
279 | + String systemId = isisRouter.systemId(); | ||
280 | + log.info("Added device {}", systemId); | ||
281 | + DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId)); | ||
282 | + Device.Type deviceType = Device.Type.ROUTER; | ||
283 | + //If our routerType is Dr or Bdr type is PSEUDO | ||
284 | + if (isisRouter.isDis()) { | ||
285 | + deviceType = Device.Type.ROUTER; | ||
286 | + } else { | ||
287 | + deviceType = Device.Type.VIRTUAL; | ||
288 | + } | ||
289 | + ChassisId cId = new ChassisId(); | ||
290 | + DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); | ||
291 | + newBuilder.set(AnnotationKeys.TYPE, "L3"); | ||
292 | + newBuilder.set("RouterId", systemId); | ||
293 | + DeviceDescription description = | ||
294 | + new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN, | ||
295 | + UNKNOWN, cId, newBuilder.build()); | ||
296 | + deviceProviderService.deviceConnected(deviceId, description); | ||
297 | + System.out.println("Device added: " + systemId); | ||
298 | + } | ||
299 | + | ||
300 | + @Override | ||
301 | + public void routerRemoved(IsisRouter isisRouter) { | ||
302 | + String systemId = isisRouter.systemId(); | ||
303 | + log.info("Delete device {}", systemId); | ||
304 | + DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId)); | ||
305 | + if (deviceProviderService == null) { | ||
306 | + return; | ||
307 | + } | ||
308 | + deviceProviderService.deviceDisconnected(deviceId); | ||
309 | + log.info("delete device {}", systemId); | ||
310 | + } | ||
311 | + | ||
312 | + @Override | ||
313 | + public void addLink(IsisLink isisLink) { | ||
314 | + log.debug("Addlink {}", isisLink.localSystemId()); | ||
315 | + | ||
316 | + LinkDescription linkDes = buildLinkDes(isisLink); | ||
317 | + //Updating ports of the link | ||
318 | + //If already link exists, return | ||
319 | + if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) { | ||
320 | + return; | ||
321 | + } | ||
322 | + ConnectPoint destconnectPoint = linkDes.dst(); | ||
323 | + PortNumber destport = destconnectPoint.port(); | ||
324 | + if (destport.toLong() != 0) { | ||
325 | + deviceProviderService.updatePorts(linkDes.src().deviceId(), | ||
326 | + buildPortDescriptions(linkDes.src().deviceId(), | ||
327 | + linkDes.src().port())); | ||
328 | + deviceProviderService.updatePorts(linkDes.dst().deviceId(), | ||
329 | + buildPortDescriptions(linkDes.dst().deviceId(), | ||
330 | + linkDes.dst().port())); | ||
331 | + registerBandwidth(linkDes, isisLink); | ||
332 | + linkProviderService.linkDetected(linkDes); | ||
333 | + System.out.println("link desc " + linkDes.toString()); | ||
334 | + } | ||
335 | + } | ||
336 | + | ||
337 | + @Override | ||
338 | + public void deleteLink(IsisLink isisLink) { | ||
339 | + log.debug("Delete link {}", isisLink.localSystemId()); | ||
340 | + if (linkProviderService == null) { | ||
341 | + return; | ||
342 | + } | ||
343 | + LinkDescription linkDes = buildLinkDes(isisLink); | ||
344 | + linkProviderService.linkVanished(linkDes); | ||
345 | + } | ||
346 | + | ||
347 | + /** | ||
348 | + * Registers the bandwidth for source and destination points. | ||
349 | + * | ||
350 | + * @param linkDes link description instance | ||
351 | + * @param isisLink ISIS link instance | ||
352 | + */ | ||
353 | + private void registerBandwidth(LinkDescription linkDes, IsisLink isisLink) { | ||
354 | + if (isisLink == null) { | ||
355 | + log.error("Could not able to register bandwidth "); | ||
356 | + return; | ||
357 | + } | ||
358 | + IsisLinkTed isisLinkTed = isisLink.linkTed(); | ||
359 | + Bandwidth maxReservableBw = isisLinkTed.maximumReservableLinkBandwidth(); | ||
360 | + if (maxReservableBw != null) { | ||
361 | + if (maxReservableBw.compareTo(Bandwidth.bps(0)) == 0) { | ||
362 | + return; | ||
363 | + } | ||
364 | + //Configure bandwidth for src and dst port | ||
365 | + BandwidthCapacity config = networkConfigService.addConfig(linkDes.src(), BandwidthCapacity.class); | ||
366 | + config.capacity(maxReservableBw).apply(); | ||
367 | + | ||
368 | + config = networkConfigService.addConfig(linkDes.dst(), BandwidthCapacity.class); | ||
369 | + config.capacity(maxReservableBw).apply(); | ||
370 | + } | ||
371 | + } | ||
372 | + } | ||
373 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -17,4 +17,4 @@ | ... | @@ -17,4 +17,4 @@ |
17 | /** | 17 | /** |
18 | * Provider that uses ISIS request as a means of infrastructure device discovery. | 18 | * Provider that uses ISIS request as a means of infrastructure device discovery. |
19 | */ | 19 | */ |
20 | -package org.onosproject.provider.isis.device.impl; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
20 | +package org.onosproject.provider.isis.topology.impl; | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
5 | + * the License. You may obtain a copy of the License at | ||
6 | + * | ||
7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | + * | ||
9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
10 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
11 | + * specific language governing permissions and limitations under the License. | ||
12 | + */ | ||
13 | + | ||
14 | +package org.onosproject.provider.isis.topology.impl; | ||
15 | + | ||
16 | +import com.fasterxml.jackson.databind.JsonNode; | ||
17 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
18 | +import com.fasterxml.jackson.databind.node.JsonNodeFactory; | ||
19 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | +import org.onlab.packet.Ip4Address; | ||
24 | +import org.onlab.util.Bandwidth; | ||
25 | +import org.onosproject.isis.controller.IsisController; | ||
26 | +import org.onosproject.isis.controller.IsisProcess; | ||
27 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisLink; | ||
28 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkTed; | ||
29 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisRouter; | ||
30 | +import org.onosproject.isis.controller.topology.IsisLink; | ||
31 | +import org.onosproject.isis.controller.topology.IsisLinkListener; | ||
32 | +import org.onosproject.isis.controller.topology.IsisLinkTed; | ||
33 | +import org.onosproject.isis.controller.topology.IsisRouter; | ||
34 | +import org.onosproject.isis.controller.topology.IsisRouterListener; | ||
35 | +import org.onosproject.net.ConnectPoint; | ||
36 | +import org.onosproject.net.Device; | ||
37 | +import org.onosproject.net.DeviceId; | ||
38 | +import org.onosproject.net.Link; | ||
39 | +import org.onosproject.net.MastershipRole; | ||
40 | +import org.onosproject.net.PortNumber; | ||
41 | +import org.onosproject.net.config.Config; | ||
42 | +import org.onosproject.net.config.ConfigApplyDelegate; | ||
43 | +import org.onosproject.net.config.ConfigFactory; | ||
44 | +import org.onosproject.net.config.NetworkConfigRegistryAdapter; | ||
45 | +import org.onosproject.net.config.basics.BandwidthCapacity; | ||
46 | +import org.onosproject.net.device.DeviceDescription; | ||
47 | +import org.onosproject.net.device.DeviceListener; | ||
48 | +import org.onosproject.net.device.DeviceProvider; | ||
49 | +import org.onosproject.net.device.DeviceProviderRegistry; | ||
50 | +import org.onosproject.net.device.DeviceProviderService; | ||
51 | +import org.onosproject.net.device.DeviceServiceAdapter; | ||
52 | +import org.onosproject.net.device.PortDescription; | ||
53 | +import org.onosproject.net.device.PortStatistics; | ||
54 | +import org.onosproject.net.link.LinkDescription; | ||
55 | +import org.onosproject.net.link.LinkListener; | ||
56 | +import org.onosproject.net.link.LinkProvider; | ||
57 | +import org.onosproject.net.link.LinkProviderRegistry; | ||
58 | +import org.onosproject.net.link.LinkProviderService; | ||
59 | +import org.onosproject.net.link.LinkServiceAdapter; | ||
60 | +import org.onosproject.net.provider.ProviderId; | ||
61 | + | ||
62 | +import java.util.ArrayList; | ||
63 | +import java.util.Collection; | ||
64 | +import java.util.Collections; | ||
65 | +import java.util.HashMap; | ||
66 | +import java.util.HashSet; | ||
67 | +import java.util.List; | ||
68 | +import java.util.Map; | ||
69 | +import java.util.Set; | ||
70 | +import java.util.concurrent.CopyOnWriteArraySet; | ||
71 | + | ||
72 | +import static org.junit.Assert.assertNotNull; | ||
73 | +import static org.junit.Assert.assertTrue; | ||
74 | + | ||
75 | +/** | ||
76 | + * Test cases for ISIS topology provider. | ||
77 | + */ | ||
78 | +public class IsisTopologyProviderTest { | ||
79 | + | ||
80 | + private final IsisTopologyProvider provider = new IsisTopologyProvider(); | ||
81 | + private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry(); | ||
82 | + private final TestLinkRegistry linkRegistry = new TestLinkRegistry(); | ||
83 | + private final TestController controller = new TestController(); | ||
84 | + private final TestLinkService linkService = new TestLinkService(); | ||
85 | + private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter(); | ||
86 | + | ||
87 | + @Before | ||
88 | + public void setUp() throws Exception { | ||
89 | + provider.deviceProviderRegistry = nodeRegistry; | ||
90 | + provider.linkProviderRegistry = linkRegistry; | ||
91 | + provider.networkConfigService = networkConfigService; | ||
92 | + provider.controller = controller; | ||
93 | + provider.linkService = linkService; | ||
94 | + provider.activate(); | ||
95 | + assertNotNull("provider should be registered", nodeRegistry.provider); | ||
96 | + assertNotNull("listener should be registered", controller.nodeListener); | ||
97 | + } | ||
98 | + | ||
99 | + @After | ||
100 | + public void tearDown() throws Exception { | ||
101 | + provider.deactivate(); | ||
102 | + provider.controller = null; | ||
103 | + provider.deviceProviderRegistry = null; | ||
104 | + provider.networkConfigService = null; | ||
105 | + } | ||
106 | + | ||
107 | + @Test | ||
108 | + public void triggerProbe() { | ||
109 | + DeviceId deviceId = DeviceId.deviceId("2929.2929.2929.00-00"); | ||
110 | + provider.triggerProbe(deviceId); | ||
111 | + } | ||
112 | + | ||
113 | + @Test | ||
114 | + public void roleChanged() { | ||
115 | + DeviceId deviceId = DeviceId.deviceId("1111.1111.1111.00-00"); | ||
116 | + provider.roleChanged(deviceId, MastershipRole.MASTER); | ||
117 | + } | ||
118 | + | ||
119 | + @Test | ||
120 | + public void changePortState() { | ||
121 | + DeviceId deviceId = DeviceId.deviceId("2222.2222.2222.00-82"); | ||
122 | + provider.changePortState(deviceId, PortNumber.portNumber(168430087), false); | ||
123 | + } | ||
124 | + | ||
125 | + @Test | ||
126 | + public void isReachable() { | ||
127 | + DeviceId deviceId = DeviceId.deviceId("1010.1010.1111.00-22"); | ||
128 | + provider.isReachable(deviceId); | ||
129 | + } | ||
130 | + | ||
131 | + | ||
132 | + /* Validate node is added to the device validating URI and should get updated properly */ | ||
133 | + @Test | ||
134 | + public void isisTopologyProviderTestAddDevice1() { | ||
135 | + int deviceAddCount = 0; | ||
136 | + IsisRouter isisRouter = new DefaultIsisRouter(); | ||
137 | + isisRouter.setSystemId("2929.2929.2929.00"); | ||
138 | + isisRouter.setNeighborRouterId(Ip4Address.valueOf("10.10.10.1")); | ||
139 | + isisRouter.setInterfaceId(Ip4Address.valueOf("10.10.10.2")); | ||
140 | + isisRouter.setDis(false); | ||
141 | + | ||
142 | + for (IsisRouterListener l : controller.nodeListener) { | ||
143 | + l.routerAdded(isisRouter); | ||
144 | + deviceAddCount = nodeRegistry.connected.size(); | ||
145 | + assertTrue(deviceAddCount == 1); | ||
146 | + l.routerRemoved(isisRouter); | ||
147 | + deviceAddCount = nodeRegistry.connected.size(); | ||
148 | + assertTrue(deviceAddCount == 0); | ||
149 | + } | ||
150 | + } | ||
151 | + | ||
152 | + @Test | ||
153 | + public void isisTopologyProviderTestAddDevice2() { | ||
154 | + int deviceAddCount = 0; | ||
155 | + IsisRouter isisRouter = new DefaultIsisRouter(); | ||
156 | + isisRouter.setSystemId("7777.7777.7777.00"); | ||
157 | + isisRouter.setNeighborRouterId(Ip4Address.valueOf("10.10.10.1")); | ||
158 | + isisRouter.setInterfaceId(Ip4Address.valueOf("10.10.10.7")); | ||
159 | + isisRouter.setDis(false); | ||
160 | + IsisRouter isisRouter1 = new DefaultIsisRouter(); | ||
161 | + isisRouter1.setSystemId("1111.1111.1111.00"); | ||
162 | + isisRouter1.setNeighborRouterId(Ip4Address.valueOf("10.10.10.7")); | ||
163 | + isisRouter1.setInterfaceId(Ip4Address.valueOf("10.10.10.1")); | ||
164 | + isisRouter1.setDis(true); | ||
165 | + for (IsisRouterListener l : controller.nodeListener) { | ||
166 | + l.routerAdded(isisRouter); | ||
167 | + deviceAddCount = nodeRegistry.connected.size(); | ||
168 | + assertTrue(deviceAddCount == 1); | ||
169 | + l.routerAdded(isisRouter1); | ||
170 | + deviceAddCount = nodeRegistry.connected.size(); | ||
171 | + assertTrue(deviceAddCount == 2); | ||
172 | + l.routerRemoved(isisRouter); | ||
173 | + deviceAddCount = nodeRegistry.connected.size(); | ||
174 | + assertTrue(deviceAddCount == 1); | ||
175 | + } | ||
176 | + } | ||
177 | + | ||
178 | + @Test | ||
179 | + public void isisTopologyProviderTestAddLink() { | ||
180 | + int deviceAddCount = 0; | ||
181 | + IsisRouter isisRouter = new DefaultIsisRouter(); | ||
182 | + isisRouter.setSystemId("7777.7777.7777.00"); | ||
183 | + isisRouter.setNeighborRouterId(Ip4Address.valueOf("10.10.10.1")); | ||
184 | + isisRouter.setInterfaceId(Ip4Address.valueOf("10.10.10.7")); | ||
185 | + isisRouter.setDis(false); | ||
186 | + IsisRouter isisRouter1 = new DefaultIsisRouter(); | ||
187 | + isisRouter1.setSystemId("1111.1111.1111.00"); | ||
188 | + isisRouter1.setNeighborRouterId(Ip4Address.valueOf("10.10.10.7")); | ||
189 | + isisRouter1.setInterfaceId(Ip4Address.valueOf("10.10.10.1")); | ||
190 | + isisRouter1.setDis(true); | ||
191 | + IsisLink isisLink = new DefaultIsisLink(); | ||
192 | + isisLink.setRemoteSystemId("7777.7777.7777.00"); | ||
193 | + isisLink.setLocalSystemId("1111.1111.1111.00"); | ||
194 | + isisLink.setInterfaceIp(Ip4Address.valueOf("10.10.10.1")); | ||
195 | + isisLink.setNeighborIp(Ip4Address.valueOf("10.10.10.7")); | ||
196 | + IsisLinkTed isisLinkTed = new DefaultIsisLinkTed(); | ||
197 | + isisLinkTed.setTeDefaultMetric(10); | ||
198 | + isisLinkTed.setAdministrativeGroup(5); | ||
199 | + isisLinkTed.setIpv4InterfaceAddress(Ip4Address.valueOf("10.10.10.1")); | ||
200 | + isisLinkTed.setIpv4NeighborAddress(Ip4Address.valueOf("10.10.10.7")); | ||
201 | + isisLinkTed.setMaximumLinkBandwidth(Bandwidth.bps(0)); | ||
202 | + isisLinkTed.setMaximumReservableLinkBandwidth(Bandwidth.bps(1.0)); | ||
203 | + List<Bandwidth> unresList = new ArrayList<>(); | ||
204 | + unresList.add(Bandwidth.bps(0.0)); | ||
205 | + unresList.add(Bandwidth.bps(1.0)); | ||
206 | + unresList.add(Bandwidth.bps(2.0)); | ||
207 | + unresList.add(Bandwidth.bps(3.0)); | ||
208 | + isisLinkTed.setUnreservedBandwidth(unresList); | ||
209 | + isisLink.setLinkTed(isisLinkTed); | ||
210 | + for (IsisRouterListener l : controller.nodeListener) { | ||
211 | + l.routerAdded(isisRouter); | ||
212 | + deviceAddCount = nodeRegistry.connected.size(); | ||
213 | + assertTrue(deviceAddCount == 1); | ||
214 | + l.routerAdded(isisRouter1); | ||
215 | + deviceAddCount = nodeRegistry.connected.size(); | ||
216 | + assertTrue(deviceAddCount == 2); | ||
217 | + } | ||
218 | + for (IsisLinkListener l : controller.linkListener) { | ||
219 | + l.addLink(isisLink); | ||
220 | + l.deleteLink(isisLink); | ||
221 | + | ||
222 | + } | ||
223 | + } | ||
224 | + | ||
225 | + | ||
226 | + /* Class implement device test registry */ | ||
227 | + private class TestDeviceRegistry implements DeviceProviderRegistry { | ||
228 | + DeviceProvider provider; | ||
229 | + | ||
230 | + Set<DeviceId> connected = new HashSet<>(); | ||
231 | + | ||
232 | + @Override | ||
233 | + public DeviceProviderService register(DeviceProvider provider) { | ||
234 | + this.provider = provider; | ||
235 | + return new TestProviderService(); | ||
236 | + } | ||
237 | + | ||
238 | + @Override | ||
239 | + public void unregister(DeviceProvider provider) { | ||
240 | + } | ||
241 | + | ||
242 | + @Override | ||
243 | + public Set<ProviderId> getProviders() { | ||
244 | + return null; | ||
245 | + } | ||
246 | + | ||
247 | + private class TestProviderService implements DeviceProviderService { | ||
248 | + | ||
249 | + @Override | ||
250 | + public DeviceProvider provider() { | ||
251 | + return null; | ||
252 | + } | ||
253 | + | ||
254 | + @Override | ||
255 | + public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) { | ||
256 | + | ||
257 | + connected.add(deviceId); | ||
258 | + | ||
259 | + } | ||
260 | + | ||
261 | + | ||
262 | + @Override | ||
263 | + public void deviceDisconnected(DeviceId deviceId) { | ||
264 | + | ||
265 | + connected.remove(deviceId); | ||
266 | + } | ||
267 | + | ||
268 | + | ||
269 | + @Override | ||
270 | + public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) { | ||
271 | + // TODO Auto-generated method stub | ||
272 | + | ||
273 | + } | ||
274 | + | ||
275 | + @Override | ||
276 | + public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) { | ||
277 | + // TODO Auto-generated method stub | ||
278 | + | ||
279 | + } | ||
280 | + | ||
281 | + @Override | ||
282 | + public void receivedRoleReply(DeviceId deviceId, MastershipRole requested, MastershipRole response) { | ||
283 | + // TODO Auto-generated method stub | ||
284 | + | ||
285 | + } | ||
286 | + | ||
287 | + | ||
288 | + @Override | ||
289 | + public void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics) { | ||
290 | + // TODO Auto-generated method stub | ||
291 | + | ||
292 | + } | ||
293 | + } | ||
294 | + } | ||
295 | + | ||
296 | + | ||
297 | + | ||
298 | + private class TestDeviceService extends DeviceServiceAdapter { | ||
299 | + private DeviceListener listener; | ||
300 | + | ||
301 | + @Override | ||
302 | + public void addListener(DeviceListener listener) { | ||
303 | + this.listener = listener; | ||
304 | + } | ||
305 | + | ||
306 | + @Override | ||
307 | + public Iterable<Device> getDevices() { | ||
308 | + return Collections.emptyList(); | ||
309 | + } | ||
310 | + } | ||
311 | + | ||
312 | + private class TestLinkService extends LinkServiceAdapter { | ||
313 | + private LinkListener listener; | ||
314 | + | ||
315 | + @Override | ||
316 | + public void addListener(LinkListener listener) { | ||
317 | + this.listener = listener; | ||
318 | + } | ||
319 | + | ||
320 | + @Override | ||
321 | + public Iterable<Link> getLinks() { | ||
322 | + return Collections.emptyList(); | ||
323 | + } | ||
324 | + } | ||
325 | + | ||
326 | + /* Class implement device test registry */ | ||
327 | + private class TestLinkRegistry implements LinkProviderRegistry { | ||
328 | + LinkProvider provider; | ||
329 | + | ||
330 | + Set<DeviceId> connected = new HashSet<>(); | ||
331 | + | ||
332 | + @Override | ||
333 | + public LinkProviderService register(LinkProvider provider) { | ||
334 | + this.provider = provider; | ||
335 | + return new TestLinkProviderService(); | ||
336 | + } | ||
337 | + | ||
338 | + @Override | ||
339 | + public void unregister(LinkProvider provider) { | ||
340 | + | ||
341 | + } | ||
342 | + | ||
343 | + @Override | ||
344 | + public Set<ProviderId> getProviders() { | ||
345 | + return null; | ||
346 | + } | ||
347 | + | ||
348 | + private class TestLinkProviderService implements LinkProviderService { | ||
349 | + | ||
350 | + @Override | ||
351 | + public void linkDetected(LinkDescription linkDescription) { | ||
352 | + | ||
353 | + } | ||
354 | + | ||
355 | + @Override | ||
356 | + public void linkVanished(LinkDescription linkDescription) { | ||
357 | + | ||
358 | + } | ||
359 | + | ||
360 | + @Override | ||
361 | + public void linksVanished(ConnectPoint connectPoint) { | ||
362 | + | ||
363 | + } | ||
364 | + | ||
365 | + @Override | ||
366 | + public void linksVanished(DeviceId deviceId) { | ||
367 | + | ||
368 | + } | ||
369 | + | ||
370 | + @Override | ||
371 | + public LinkProvider provider() { | ||
372 | + return null; | ||
373 | + } | ||
374 | + } | ||
375 | + } | ||
376 | + | ||
377 | + /* class implement test controller */ | ||
378 | + private class TestController implements IsisController { | ||
379 | + protected Set<IsisRouterListener> nodeListener = new CopyOnWriteArraySet<>(); | ||
380 | + protected Set<IsisLinkListener> linkListener = new CopyOnWriteArraySet<>(); | ||
381 | + | ||
382 | + @Override | ||
383 | + public void addRouterListener(IsisRouterListener nodeListener) { | ||
384 | + this.nodeListener.add(nodeListener); | ||
385 | + } | ||
386 | + | ||
387 | + @Override | ||
388 | + public void removeRouterListener(IsisRouterListener nodeListener) { | ||
389 | + this.nodeListener.remove(nodeListener); | ||
390 | + } | ||
391 | + | ||
392 | + @Override | ||
393 | + public void addLinkListener(IsisLinkListener listener) { | ||
394 | + this.linkListener.add(listener); | ||
395 | + } | ||
396 | + | ||
397 | + @Override | ||
398 | + public void removeLinkListener(IsisLinkListener listener) { | ||
399 | + this.linkListener.remove(listener); | ||
400 | + } | ||
401 | + | ||
402 | + @Override | ||
403 | + public void updateConfig(JsonNode processesNode) { | ||
404 | + | ||
405 | + } | ||
406 | + | ||
407 | + @Override | ||
408 | + public List<IsisProcess> allConfiguredProcesses() { | ||
409 | + return null; | ||
410 | + } | ||
411 | + | ||
412 | + @Override | ||
413 | + public Set<IsisRouterListener> listener() { | ||
414 | + return null; | ||
415 | + } | ||
416 | + | ||
417 | + @Override | ||
418 | + public Set<IsisLinkListener> linkListener() { | ||
419 | + return null; | ||
420 | + } | ||
421 | + | ||
422 | + } | ||
423 | + | ||
424 | + /* Mock test for device service */ | ||
425 | + private class MockNetConfigRegistryAdapter extends NetworkConfigRegistryAdapter { | ||
426 | + private ConfigFactory cfgFactory; | ||
427 | + private Map<ConnectPoint, BandwidthCapacity> classConfig = new HashMap<>(); | ||
428 | + | ||
429 | + @Override | ||
430 | + public void registerConfigFactory(ConfigFactory configFactory) { | ||
431 | + cfgFactory = configFactory; | ||
432 | + } | ||
433 | + | ||
434 | + @Override | ||
435 | + public void unregisterConfigFactory(ConfigFactory configFactory) { | ||
436 | + cfgFactory = null; | ||
437 | + } | ||
438 | + | ||
439 | + @Override | ||
440 | + public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { | ||
441 | + if (configClass == BandwidthCapacity.class) { | ||
442 | + BandwidthCapacity devCap = new BandwidthCapacity(); | ||
443 | + classConfig.put((ConnectPoint) subject, devCap); | ||
444 | + | ||
445 | + JsonNode node = new ObjectNode(new MockJsonNode()); | ||
446 | + ObjectMapper mapper = new ObjectMapper(); | ||
447 | + ConfigApplyDelegate delegate = new InternalApplyDelegate(); | ||
448 | + devCap.init((ConnectPoint) subject, null, node, mapper, delegate); | ||
449 | + return (C) devCap; | ||
450 | + } | ||
451 | + | ||
452 | + return null; | ||
453 | + } | ||
454 | + | ||
455 | + @Override | ||
456 | + public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) { | ||
457 | + classConfig.remove(subject); | ||
458 | + } | ||
459 | + | ||
460 | + @Override | ||
461 | + public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) { | ||
462 | + if (configClass == BandwidthCapacity.class) { | ||
463 | + return (C) classConfig.get(subject); | ||
464 | + } | ||
465 | + return null; | ||
466 | + } | ||
467 | + | ||
468 | + private class MockJsonNode extends JsonNodeFactory { | ||
469 | + } | ||
470 | + | ||
471 | + // Auxiliary delegate to receive notifications about changes applied to | ||
472 | + // the network configuration - by the apps. | ||
473 | + private class InternalApplyDelegate implements ConfigApplyDelegate { | ||
474 | + @Override | ||
475 | + public void onApply(Config config) { | ||
476 | + } | ||
477 | + } | ||
478 | + } | ||
479 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment