sunish vk
Committed by Gerrit Code Review

OSPF-API refactored based on review comments, ONOS-2738,

Change-Id: I05d39f7f0d6b3a2d0cc51a256feec220f1d0e06a
Showing 27 changed files with 2766 additions and 0 deletions
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2014 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18 + xmlns="http://maven.apache.org/POM/4.0.0"
19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-ospf</artifactId>
25 + <version>1.4.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-ospf-api</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <description>ONOS Ospf controller subsystem API</description>
33 +
34 + <dependencies>
35 + <dependency>
36 + <groupId>io.netty</groupId>
37 + <artifactId>netty</artifactId>
38 + </dependency>
39 + <dependency>
40 + <groupId>org.onosproject</groupId>
41 + <artifactId>onos-api</artifactId>
42 + </dependency>
43 +
44 + </dependencies>
45 + <build>
46 + <plugins>
47 + <plugin>
48 + <groupId>org.apache.felix</groupId>
49 + <artifactId>maven-bundle-plugin</artifactId>
50 + <configuration>
51 + <instructions>
52 + <Export-Package>
53 + org.onosproject.ospf.*
54 + </Export-Package>
55 + </instructions>
56 + </configuration>
57 + </plugin>
58 + </plugins>
59 + </build>
60 +
61 +</project>
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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +import java.util.List;
21 +
22 +/**
23 + * Representation of an OSPF device information.
24 + */
25 +public interface DeviceInformation {
26 +
27 + /**
28 + * Gets router id.
29 + *
30 + * @return router id
31 + */
32 + Ip4Address routerId();
33 +
34 + /**
35 + * Sets router id.
36 + *
37 + * @param routId router id
38 + */
39 + void setRouterId(Ip4Address routId);
40 +
41 + /**
42 + * Gets device id.
43 + *
44 + * @return device id
45 + */
46 + Ip4Address deviceId();
47 +
48 + /**
49 + * Sets device id.
50 + *
51 + * @param deviceId device id
52 + */
53 + void setDeviceId(Ip4Address deviceId);
54 +
55 + /**
56 + * Gets list of interface ids.
57 + *
58 + * @return list of interface ids
59 + */
60 + List<Ip4Address> interfaceId();
61 +
62 + /**
63 + * Adds interface id to list.
64 + *
65 + * @param interfaceId interface id
66 + */
67 + void addInterfaceId(Ip4Address interfaceId);
68 +
69 + /**
70 + * Gets area id.
71 + *
72 + * @return area id
73 + */
74 + Ip4Address areaId();
75 +
76 + /**
77 + * Sets area id.
78 + *
79 + * @param areaId area id
80 + */
81 + void setAreaId(Ip4Address areaId);
82 +
83 + /**
84 + * Gets device information is already created or not.
85 + *
86 + * @return true if device information is already created else false
87 + */
88 + boolean isAlreadyCreated();
89 +
90 + /**
91 + * Sets device information is already created or not.
92 + *
93 + * @param alreadyCreated true if device information is already created else false
94 + */
95 + void setAlreadyCreated(boolean alreadyCreated);
96 +
97 + /**
98 + * Gets device is dr or not.
99 + *
100 + * @return true if device is dr else false
101 + */
102 + boolean isDr();
103 +
104 + /**
105 + * Sets device is dr or not.
106 + *
107 + * @param dr true if device is dr else false
108 + */
109 + void setDr(boolean dr);
110 +
111 + /**
112 + * Gets neighbor id.
113 + *
114 + * @return neighbor id
115 + */
116 + Ip4Address neighborId();
117 +
118 + /**
119 + * Sets neighbor id.
120 + *
121 + * @param neighborId neighbor id
122 + */
123 + void setNeighborId(Ip4Address neighborId);
124 +}
...\ 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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +/**
21 + * Representation of an OSPF 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 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 + * Gets is link source id is same as router id or not.
55 + *
56 + * @return true if link source id is not same as router id else false
57 + */
58 + boolean isLinkSrcIdNotRouterId();
59 +
60 + /**
61 + * Sets is link source id is same as router id or not.
62 + *
63 + * @param linkSrcIdNotRouterId true if link source id is not same as router id else false
64 + */
65 + void setLinkSrcIdNotRouterId(boolean linkSrcIdNotRouterId);
66 +
67 + /**
68 + * Gets link destination id.
69 + *
70 + * @return link destination id
71 + */
72 + Ip4Address linkDestinationId();
73 +
74 + /**
75 + * Sets link destination id.
76 + *
77 + * @param linkDestinationId link destination id
78 + */
79 + void setLinkDestinationId(Ip4Address linkDestinationId);
80 +
81 + /**
82 + * Gets link source id.
83 + *
84 + * @return link source id
85 + */
86 + Ip4Address linkSourceId();
87 +
88 + /**
89 + * Sets link source id.
90 + *
91 + * @param linkSourceId link source id
92 + */
93 + void setLinkSourceId(Ip4Address linkSourceId);
94 +
95 + /**
96 + * Gets interface ip address.
97 + *
98 + * @return interface ip address
99 + */
100 + Ip4Address interfaceIp();
101 +
102 + /**
103 + * Sets interface ip address.
104 + *
105 + * @param interfaceIp interface ip address
106 + */
107 + void setInterfaceIp(Ip4Address interfaceIp);
108 +
109 + /**
110 + * Gets link source ip address.
111 + *
112 + * @return link source ip address
113 + */
114 + Ip4Address linkSourceIpAddress();
115 +
116 + /**
117 + * Sets link source ip address.
118 + *
119 + * @param linkSourceIpAddress link source ip address
120 + */
121 + void setLinkSourceIpAddress(Ip4Address linkSourceIpAddress);
122 +
123 + /**
124 + * Gets link destination ip address.
125 + *
126 + * @return link destination ip address
127 + */
128 + Ip4Address linkDestinationIpAddress();
129 +
130 + /**
131 + * Sets link destination ip address.
132 + *
133 + * @param linkDestinationIpAddress link destination ip address
134 + */
135 + void setLinkDestinationIpAddress(Ip4Address linkDestinationIpAddress);
136 +}
...\ 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.ospf.controller;
17 +
18 +import java.util.Map;
19 +
20 +/**
21 + * Representation of a bin where an LSA is stored for aging.
22 + * A bin is identified by a bin number and can have one or more LSAs
23 + * stored in a particular bin location.
24 + */
25 +public interface LsaBin {
26 +
27 + /**
28 + * Adds the given LSA to this bin with the given key.
29 + *
30 + * @param lsaKey key of the stored LSA
31 + * @param lsaWrapper wrapper instance to store
32 + */
33 + public void addOspfLsa(String lsaKey, LsaWrapper lsaWrapper);
34 +
35 + /**
36 + * Retrieves the LSA from the bin for verification of max age and ls refresh.
37 + *
38 + * @param lsaKey key to search the LSA
39 + * @return LSA Wrapper instance
40 + */
41 + public LsaWrapper ospfLsa(String lsaKey);
42 +
43 + /**
44 + * Removes the given LSA from the bin. when ever it reaches max age or ls refresh time.
45 + *
46 + * @param lsaKey key to search LSA
47 + * @param lsaWrapper wrapper instance of the particular LSA
48 + */
49 + public void removeOspfLsa(String lsaKey, LsaWrapper lsaWrapper);
50 +
51 + /**
52 + * Gets the list of LSAs in this bin as key value pair.
53 + * with key being the LSA key formed from the LSA header.
54 + *
55 + * @return list of LSAs in this bin as key value pair
56 + */
57 + public Map<String, LsaWrapper> listOfLsa();
58 +
59 + /**
60 + * Gets the bin number assigned during the initialization process of the bins .
61 + *
62 + * @return the bin number
63 + */
64 + public int binNumber();
65 +}
...\ 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.ospf.controller;
17 +
18 +/**
19 + * Representation of a wrapper object to store LSA and associated metadata.
20 + * Metadata consists about the origination of LSA, age of LSA when received etc.
21 + */
22 +public interface LsaWrapper {
23 + /**
24 + * Gets the type of LSA, it can be a router,network,summary,external.
25 + *
26 + * @return lsa type
27 + */
28 + public OspfLsaType lsaType();
29 +
30 + /**
31 + * Sets the LSA type during the initialization of wrapper.
32 + *
33 + * @param lsaType lsa type
34 + */
35 + public void setLsaType(OspfLsaType lsaType);
36 +
37 + /**
38 + * Determines the origination of LSA , this is called during ls refresh interval.
39 + *
40 + * @return true if self originated else false
41 + */
42 + public boolean isSelfOriginated();
43 +
44 + /**
45 + * Sets is self originated or not.
46 + *
47 + * @param isSelfOriginated true if self originated else false
48 + */
49 + public void setIsSelfOriginated(boolean isSelfOriginated);
50 +
51 +
52 + /**
53 + * Age of LSA when received during the adjacency formation.
54 + *
55 + * @return Age of LSA when received
56 + */
57 + public int lsaAgeReceived();
58 +
59 + /**
60 + * Sets the Age of LSA when received during the adjacency formation.
61 + *
62 + * @param lsaAgeReceived Age of LSA when received
63 + */
64 + public void setLsaAgeReceived(int lsaAgeReceived);
65 +
66 + /**
67 + * Gets the LSA present in the wrapper instance.
68 + *
69 + * @return LSA instance
70 + */
71 + public OspfLsa ospfLsa();
72 +
73 + /**
74 + * Sets the LSA instance to the wrapper.
75 + *
76 + * @param ospfLsa LSA instance
77 + */
78 + public void setOspfLsa(OspfLsa ospfLsa);
79 +
80 + /**
81 + * Gets the current LSA Age, using this we calculate current age.
82 + * It is done against the age counter which is incremented every second.
83 + *
84 + * @return lsa age
85 + */
86 + public int currentAge();
87 +
88 + /**
89 + * Gets the age counter when received.
90 + *
91 + * @return the age counter when received
92 + */
93 + public int ageCounterWhenReceived();
94 +
95 + /**
96 + * Sets the age counter when received.
97 + *
98 + * @param ageCounterWhenReceived the age counter when received
99 + */
100 + public void setAgeCounterWhenReceived(int ageCounterWhenReceived);
101 +
102 + /**
103 + * Gets the LSA process command, like max age, ls refresh, based on the command set.
104 + * The queue consumer will pick the LSA and start performing the actions, like flooding
105 + * out of the domain or generating a new LSA and flooding.
106 + *
107 + * @return lsa process command
108 + */
109 + public String lsaProcessing();
110 +
111 + /**
112 + * Sets the LSA process command, like max age , ls refresh , based on the command set.
113 + * The queue consumer will pick the LSA and start performing the actions, like flooding
114 + * out of the domain or generating a new LSA and flooding.
115 + *
116 + * @param lsaProcessing lsa process command
117 + */
118 + public void setLsaProcessing(String lsaProcessing);
119 +
120 + /**
121 + * Gets bin number into which the LSA wrapper is put for aging process.
122 + *
123 + * @return bin number
124 + */
125 + public int binNumber();
126 +
127 + /**
128 + * Sets bin number into which the LSA wrapper is put for aging process.
129 + *
130 + * @param binNumber bin number
131 + */
132 + public void setBinNumber(int binNumber);
133 +
134 + /**
135 + * Gets the interface on which the LSA was received.
136 + *
137 + * @return the interface instance
138 + */
139 + public OspfInterface ospfInterface();
140 +
141 + /**
142 + * Sets the interface on which the LSA was received, this is used later to flood the information.
143 + *
144 + * @param ospfInterface interface instance
145 + */
146 + public void setOspfInterface(OspfInterface ospfInterface);
147 +
148 + /**
149 + * Sets the LSDB age.
150 + * Using LSDB age we are calculating age of a particular LSA.
151 + *
152 + * @param lsdbAge lsdbAge instance
153 + */
154 + public void setLsdbAge(LsdbAge lsdbAge);
155 +}
...\ 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.ospf.controller;
17 +
18 +/**
19 + * Representation of LSDB aging process.
20 + * The age of each LSA in the database must be incremented by 1 each second.
21 + * We put all the LSAs of a given age into a single bin. The age of an LSA is the
22 + * difference between its age bin and the bin representing LS age 0.
23 + */
24 +public interface LsdbAge {
25 +
26 + /**
27 + * Adds LSA to bin for aging.
28 + *
29 + * @param binKey key to store the LSA in bin
30 + * @param lsaBin LSA bin instance
31 + */
32 + public void addLsaBin(Integer binKey, LsaBin lsaBin);
33 +
34 + /**
35 + * Gets LSA from bin, this method is used while processing ls refresh and max age on LSA.
36 + *
37 + * @param binKey key to retreive the LSA from bin
38 + * @return lsaBin bin instance
39 + */
40 + public LsaBin getLsaBin(Integer binKey);
41 +
42 + /**
43 + * Adds the lsa to maxAge bin if LSAs age is max age.
44 + *
45 + * @param key key to store the LSA in bin.
46 + * @param wrapper wrapper instance which contains LSA
47 + */
48 + public void addLsaToMaxAgeBin(String key, LsaWrapper wrapper);
49 +
50 + /**
51 + * Gets the bin number out of LSAs age, in which the LSA can be placed.
52 + * so that age can be calculated.
53 + *
54 + * @param x Can be either age or ageCounter
55 + * @return bin number.
56 + */
57 + public int age2Bin(int x);
58 +
59 + /**
60 + * Gets the max age bin, a special bin is created which holds only max age LSAs.
61 + *
62 + * @return lsa bin instance
63 + */
64 + public LsaBin getMaxAgeBin();
65 +
66 + /**
67 + * Gets the age counter.
68 + *
69 + * @return age counter
70 + */
71 + public int getAgeCounter();
72 +
73 +
74 + /**
75 + * Refresh the LSAs which are in the refresh bin.
76 + */
77 + public void refreshLsa();
78 +
79 + /**
80 + * If the LSAs have completed the MaxAge stop aging and flood it.
81 + */
82 + public void maxAgeLsa();
83 +
84 + /**
85 + * Invoked every 1 second as part of the aging process, and increments age counter.
86 + * It also verifies if any LSA has reached ls refresh time or max age.
87 + */
88 + public void ageLsaAndFlood();
89 +
90 + /**
91 + * Starts the aging timer thread which gets invokes every second.
92 + */
93 + public void startDbAging();
94 +
95 + /**
96 + * Removes LSA from Bin, when ever it reaches a max age or ls refresh time.
97 + *
98 + * @param lsaWrapper wrapper instance
99 + */
100 + public void removeLsaFromBin(LsaWrapper lsaWrapper);
101 +}
...\ 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.ospf.controller;
17 +
18 +/**
19 + * Representation of an OSPF agent.
20 + * It is responsible for keeping track of the current set of routers
21 + * connected to the system.
22 + */
23 +public interface OspfAgent {
24 +
25 + /**
26 + * Adds a router that has just connected to the system.
27 + *
28 + * @param ospfRouter the router id to add
29 + * @return true if added, false otherwise
30 + */
31 + boolean addConnectedRouter(OspfRouter ospfRouter);
32 +
33 + /**
34 + * Removes the router which got disconnected from the system.
35 + *
36 + * @param ospfRouter the router id to remove
37 + */
38 + void removeConnectedRouter(OspfRouter ospfRouter);
39 +
40 + /**
41 + * Notifies that got a packet of link from network and need do processing.
42 + *
43 + * @param ospfRouter router instance
44 + * @param ospfLinkTed link ted instance
45 + */
46 + void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
47 +
48 + /**
49 + * Notifies that got a packet of link from network and need do processing.
50 + *
51 + * @param ospfRouter router instance
52 + */
53 + void deleteLink(OspfRouter ospfRouter);
54 +}
...\ 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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +import java.util.List;
21 +
22 +/**
23 + * Representation of an OSPF area. OSPF areas are collections of network segments.
24 + * The configuration of OSPF area consists of assigning an area id to each network segment.
25 + * Each area has its own link state database.
26 + */
27 +public interface OspfArea {
28 +
29 + /**
30 + * Gets the router id associated with the area.
31 + *
32 + * @return router id
33 + */
34 + Ip4Address routerId();
35 +
36 + /**
37 + * Sets the router id for this area.
38 + *
39 + * @param routerId router's ip address
40 + */
41 + void setRouterId(Ip4Address routerId);
42 +
43 + /**
44 + * Gets the area id.
45 + *
46 + * @return area id
47 + */
48 + Ip4Address areaId();
49 +
50 + /**
51 + * Sets the area id.
52 + *
53 + * @param areaId area id as an IPv4 address
54 + */
55 + void setAreaId(Ip4Address areaId);
56 +
57 + /**
58 + * Gets the LSDB instance for this area.
59 + *
60 + * @return LSDB instance for this area
61 + */
62 + public OspfLsdb database();
63 +
64 + /**
65 + * Checks whether an instance of the given LSA exists in the database.
66 + *
67 + * @param lookupLsa LSA instance to lookup
68 + * @return LSA wrapper instance which contains the LSA
69 + */
70 + public LsaWrapper lsaLookup(OspfLsa lookupLsa);
71 +
72 + /**
73 + * Initializes link state database, this acts as a place holder for storing the received LSA.
74 + */
75 + public void initializeDb();
76 +
77 + /**
78 + * Sets the stub cost.
79 + *
80 + * @param stubCost stub cost
81 + */
82 + void setStubCost(int stubCost);
83 +
84 + /**
85 + * Sets the options value.
86 + *
87 + * @param options integer value
88 + */
89 + void setOptions(int options);
90 +
91 + /**
92 + * Gets area address ranges to which this area belongs to.
93 + *
94 + * @return list of area address ranges
95 + */
96 + List<OspfAreaAddressRange> addressRanges();
97 +
98 + /**
99 + * Sets the area address ranges to which this area belongs to.
100 + *
101 + * @param addrRangeList list of area address ranges
102 + */
103 + void setAddressRanges(List<OspfAreaAddressRange> addrRangeList);
104 +
105 + /**
106 + * Gets whether the area is transit capable or not.
107 + * This indicates whether the area can carry data traffic that neither originates
108 + * nor terminates in the area itself.
109 + *
110 + * @return true if transit capable, else false
111 + */
112 + boolean isTransitCapability();
113 +
114 + /**
115 + * Sets whether the area is transit capable or not.
116 + * This indicates whether the area can carry data traffic that neither originates
117 + * nor terminates in the area itself.
118 + *
119 + * @param transitCapability true if transit capable, else false
120 + */
121 + void setTransitCapability(boolean transitCapability);
122 +
123 + /**
124 + * Gets external routing capability.
125 + * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
126 + *
127 + * @return true if external routing capable, else false
128 + */
129 + boolean isExternalRoutingCapability();
130 +
131 + /**
132 + * Sets external routing capability.
133 + * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
134 + *
135 + * @param externalRoutingCapability true if external routing capable, else false
136 + */
137 + void setExternalRoutingCapability(boolean externalRoutingCapability);
138 +
139 + /**
140 + * Gets the stub cost, which indicates if the area has been configured as a stub area.
141 + *
142 + * @return stub cost
143 + */
144 + int stubCost();
145 +
146 + /**
147 + * Gets if the router is opaque enabled or not.
148 + * This indicates whether the router accepts opaque LSA.
149 + *
150 + * @return true if opaque enabled else false
151 + */
152 + boolean isOpaqueEnabled();
153 +
154 + /**
155 + * Gets the list of interfaces attached to this area.
156 + *
157 + * @return list of interfaces
158 + */
159 + List<OspfInterface> getInterfacesLst();
160 +
161 + /**
162 + * Sets the list of interfaces attached to this area.
163 + *
164 + * @param interfacesLst list of interface instances
165 + */
166 + void setInterfacesLst(List<OspfInterface> interfacesLst);
167 +
168 + /**
169 + * Gets the options value, which indicates the supported optional capabilities.
170 + *
171 + * @return options value
172 + */
173 + int options();
174 +
175 + /**
176 + * Gets the opaque enabled options value, which indicates support of opaque capabilities.
177 + *
178 + * @return opaque enabled options value
179 + */
180 + int opaqueEnabledOptions();
181 +
182 + /**
183 + * Sets opaque enabled to true or false, which indicates whether the router accepts opaque LSA.
184 + *
185 + * @param isOpaqueEnable true if opaque enabled else false
186 + */
187 + void setIsOpaqueEnabled(boolean isOpaqueEnable);
188 +
189 + /**
190 + * Refreshes areas, by sending a router LSA and network LSA (in case of DR).
191 + * with a new sequence number.
192 + *
193 + * @param ospfInterface interface instance
194 + * @throws Exception might throw exception
195 + */
196 + void refreshArea(OspfInterface ospfInterface) throws Exception;
197 +
198 + /**
199 + * Verifies no neighbor is in exchange process.
200 + *
201 + * @return boolean indicating that there is no Neighbor in Database Exchange
202 + */
203 + boolean noNeighborInLsaExchangeProcess();
204 +
205 + /**
206 + * Checks whether an instance of the given LSA exists in the database belonging to this area.
207 + * If so return true else false.
208 + *
209 + * @param lsa1 LSA instance to compare
210 + * @param lsa2 LSA instance to compare
211 + * @return "same" if both instances are same, "latest" if lsa1 is latest, or "old" if lsa1 is old
212 + */
213 + String isNewerOrSameLsa(OspfLsa lsa1, OspfLsa lsa2);
214 +
215 + /**
216 + * Whenever we receive an LSA with max age - we put it in the max age bin.
217 + * This is later used to flush LSAs out of the routing domain.
218 + *
219 + * @param key key to add it to LSDB
220 + * @param wrapper LSA wrapper instance
221 + */
222 + void addLsaToMaxAgeBin(String key, LsaWrapper wrapper);
223 +
224 + /**
225 + * Whenever an LSA is being flushed out or reaches max age, it must be stopped from aging.
226 + * This achieved by removing it from bin.
227 + *
228 + * @param lsaWrapper the LSA wrapper instance to delete
229 + */
230 + void removeLsaFromBin(LsaWrapper lsaWrapper);
231 +
232 + /**
233 + * Adds the received LSA to LSDB, this method creates an LSA wrapper for the LSA.
234 + * Also adds it to the LSDB of the area. This method is specifically called for
235 + * the self originated LSAs.
236 + *
237 + * @param ospfLsa LSA instance
238 + * @param isSelfOriginated true if the LSA is self originated else false
239 + * @param ospfInterface interface instance
240 + * @throws Exception might throws exception
241 + */
242 + void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface)
243 + throws Exception;
244 +
245 + /**
246 + * Adds the received LSA to LSDB,this method creates an LSA wrapper for the LSA.
247 + * Adds it to the LSDB of the area.
248 + *
249 + * @param ospfLsa LSA instance
250 + * @param ospfInterface interface instance
251 + * @throws Exception might throws exception
252 + */
253 + void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) throws Exception;
254 +
255 + /**
256 + * Sets router sequence number for router LSA.
257 + *
258 + * @param newSequenceNumber sequence number
259 + */
260 + void setDbRouterSequenceNumber(long newSequenceNumber);
261 +
262 + /**
263 + * Gets LSA header of all types of LSAs present in the link state database.
264 + *
265 + * @param excludeMaxAgeLsa need to include(true) or exclude(false) max age LSA
266 + * @param isOpaqueCapable need to include(true) or exclude(false) type 10 Opaque LSA
267 + * @return list of LSA header in the LSDB
268 + */
269 + List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable);
270 +
271 + /**
272 + * Gets the LSA wrapper from link state database based on the parameters passed.
273 + *
274 + * @param lsType type of LSA to form the key
275 + * @param linkStateID link state id to form the key
276 + * @param advertisingRouter advertising router to form the key
277 + * @return LSA wrapper instance which contains the LSA
278 + * @throws Exception might throws exception
279 + */
280 + LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception;
281 +
282 +}
...\ 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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +/**
21 + * Represents the collection of IP addresses contained in the address range.
22 + */
23 +public interface OspfAreaAddressRange {
24 +
25 + /**
26 + * Gets the IP address.
27 + *
28 + * @return IP address
29 + */
30 + public Ip4Address ipAddress();
31 +
32 + /**
33 + * Sets the IP address.
34 + *
35 + * @param ipAddress IPv4 address
36 + */
37 + public void setIpAddress(Ip4Address ipAddress);
38 +
39 + /**
40 + * Gets the network mask.
41 + *
42 + * @return network mask
43 + */
44 + public String mask();
45 +
46 + /**
47 + * Sets the network mask.
48 + *
49 + * @param mask network mask
50 + */
51 + public void setMask(String mask);
52 +
53 + /**
54 + * Gets the advertise value, which indicates routing information is condensed at area boundaries.
55 + *
56 + * @return advertise true if advertise flag is set else false
57 + */
58 + public boolean isAdvertise();
59 +
60 + /**
61 + * Sets the advertise value, which indicates routing information is condensed at area boundaries.
62 + *
63 + * @param advertise true if advertise flag to set else false
64 + */
65 + public void setAdvertise(boolean advertise);
66 +}
...\ 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.ospf.controller;
17 +
18 +import java.util.List;
19 +import java.util.Set;
20 +
21 +/**
22 + * Abstraction of an OSPF controller.
23 + * Serves as a one stop shop for obtaining OSPF devices and (un)register listeners on OSPF events.
24 + */
25 +public interface OspfController {
26 +
27 + /**
28 + * Registers a listener for router meta events.
29 + *
30 + * @param listener the listener to notify
31 + */
32 + void addRouterListener(OspfRouterListener listener);
33 +
34 + /**
35 + * Unregisters a router listener.
36 + *
37 + * @param listener the listener to unregister
38 + */
39 + void removeRouterListener(OspfRouterListener listener);
40 +
41 + /**
42 + * Registers a listener for OSPF message events.
43 + *
44 + * @param listener the listener to notify
45 + */
46 + void addLinkListener(OspfLinkListener listener);
47 +
48 + /**
49 + * Unregisters a link listener.
50 + *
51 + * @param listener the listener to unregister
52 + */
53 + void removeLinkListener(OspfLinkListener listener);
54 +
55 + /**
56 + * Updates configuration of processes.
57 + *
58 + * @param processes process info to update
59 + */
60 + public void updateConfig(List<OspfProcess> processes);
61 +
62 + /**
63 + * Deletes configuration parameters.
64 + *
65 + * @param processes list of process instance
66 + * @param attribute attribute to delete
67 + */
68 + public void deleteConfig(List<OspfProcess> processes, String attribute);
69 +
70 + /**
71 + * Gets string representation of area configuration parameters to be displayed after CLI command.
72 + *
73 + * @param processId process Id
74 + * @param areaId area Id
75 + * @return Area Information
76 + */
77 + public String showAreaParameters(String processId, String areaId);
78 +
79 + /**
80 + * Gets string representation of area configuration information for the given area/process.
81 + * This method will be called for CLI command.
82 + *
83 + * @param processId process id to which area belongs
84 + * @param areaId area id
85 + * @return string representation of area configuration for CLI display
86 + */
87 + List<String> showAreaConfigurations(String processId, String areaId);
88 +
89 + /**
90 + * Gets the list of listeners registered for router events.
91 + *
92 + * @return list of listeners
93 + */
94 + Set<OspfRouterListener> listener();
95 +
96 + /**
97 + * Gets the list of listeners registered for link events.
98 + *
99 + * @return list of listeners
100 + */
101 + public Set<OspfLinkListener> linkListener();
102 +
103 + /**
104 + * Gets the configured process.
105 + *
106 + * @return list of process instances
107 + */
108 + public List<OspfProcess> getAllConfiguredProcesses();
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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +import org.onlab.packet.Ip6Address;
20 +
21 +import java.util.List;
22 +
23 +/**
24 + * Represents Device Traffic Engineering parameters.
25 + */
26 +public interface OspfDeviceTed {
27 +
28 + /**
29 + * Obtain list of IPv4 router ids.
30 + *
31 + * @return IPv4 router ids
32 + */
33 + public List<Ip4Address> ipv4RouterIds();
34 +
35 + /**
36 + * Sets list of IPv4 router ids.
37 + *
38 + * @param routerIds list of IPv4 router ids
39 + */
40 + public void setIpv4RouterIds(List<Ip4Address> routerIds);
41 +
42 + /**
43 + * Obtain list of IPv6 router id.
44 + *
45 + * @return IPv4 router ids
46 + */
47 + public List<Ip6Address> ipv6RouterIds();
48 +
49 + /**
50 + * Sets list of IPv4 router ids.
51 + *
52 + * @param routerIds list of IPv4 router ids
53 + */
54 + public void setIpv6RouterIds(List<Ip6Address> routerIds);
55 +
56 + /**
57 + * Obtain the list of topology ids.
58 + *
59 + * @return list of topology ids
60 + */
61 + public List<Short> topologyIds();
62 +
63 + /**
64 + * Sets the list of topology ids.
65 + *
66 + * @param topologyIds the list of topology ids
67 + */
68 + public void setTopologyIds(List<Short> topologyIds);
69 +
70 + /**
71 + * Obtains position of device in the network.
72 + *
73 + * @return position of device in the network
74 + */
75 + public Boolean asbr();
76 +
77 + /**
78 + * Sets position of device in the network.
79 + *
80 + * @param asbr position of device in the network
81 + */
82 + public void setAsbr(Boolean asbr);
83 +
84 + /**
85 + * Obtains position of device in the network.
86 + *
87 + * @return position of device in the network
88 + */
89 + public Boolean abr();
90 +
91 + /**
92 + * Sets position of device in the network.
93 + *
94 + * @param abr position of device in the network
95 + */
96 + public void setAbr(Boolean abr);
97 +}
...\ 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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +import java.util.HashMap;
21 +
22 +/**
23 + * Represents an OSPF Interface.
24 + */
25 +public interface OspfInterface {
26 +
27 + /**
28 + * Gets network mask of the interface.
29 + *
30 + * @return network mask
31 + */
32 + Ip4Address ipNetworkMask();
33 +
34 + /**
35 + * Sets area id, to which the interface belongs.
36 + *
37 + * @param areaId area identifier
38 + */
39 + void setAreaId(int areaId);
40 +
41 + /**
42 + * Sets the authentication key.
43 + * Interface uses this to authenticate while establishing communication with other routers.
44 + *
45 + * @param authKey represents authentication key
46 + */
47 + void setAuthKey(String authKey);
48 +
49 + /**
50 + * Sets the authentication type,
51 + * Interface uses this to authenticate while establishing communication with other routers.
52 + *
53 + * @param authType authType represents authentication type
54 + */
55 + void setAuthType(String authType);
56 +
57 + /**
58 + * Sets the value of BDR.
59 + * The BDR is calculated during adjacency formation.
60 + *
61 + * @param bdr backup designated router's IP address
62 + */
63 + void setBdr(Ip4Address bdr);
64 +
65 + /**
66 + * Sets the value of DR.
67 + * The DR is calculated during adjacency formation.
68 + *
69 + * @param dr designated router's IP address
70 + */
71 + void setDr(Ip4Address dr);
72 +
73 + /**
74 + * Sets the hello interval time.
75 + * It is the interval at which a hello packet is sent out via this interface.
76 + *
77 + * @param helloIntervalTime an integer interval time
78 + */
79 + void setHelloIntervalTime(int helloIntervalTime);
80 +
81 + /**
82 + * Sets router dead interval time.
83 + * This is the interval after which this interface will trigger a process to kill neighbor.
84 + *
85 + * @param routerDeadIntervalTime an integer interval time
86 + */
87 + void setRouterDeadIntervalTime(int routerDeadIntervalTime);
88 +
89 + /**
90 + * Sets the interface cost which is the cost of sending a data packet onto the network.
91 + *
92 + * @param interfaceCost an integer represents interface cost
93 + */
94 + void setInterfaceCost(int interfaceCost);
95 +
96 + /**
97 + * Sets interface type.
98 + * This indicates whether the interface is on point to point mode or broadcast mode.
99 + *
100 + * @param interfaceType an integer represents interface type
101 + */
102 + void setInterfaceType(int interfaceType);
103 +
104 + /**
105 + * Sets IP Address of this interface.
106 + *
107 + * @param ipAddress IP address
108 + */
109 + void setIpAddress(Ip4Address ipAddress);
110 +
111 + /**
112 + * Sets IP network mask.
113 + *
114 + * @param ipNetworkMask network mask
115 + */
116 + void setIpNetworkMask(Ip4Address ipNetworkMask);
117 +
118 + /**
119 + * Sets the polling interval.
120 + * Polling interval indicates the interval until when the Hello Packets are
121 + * sent to a dead neighbor.
122 + *
123 + * @param pollInterval an integer represents poll interval
124 + */
125 + void setPollInterval(int pollInterval);
126 +
127 + /**
128 + * Sets transmission delay.
129 + *
130 + * @param transmitDelay an integer represents delay
131 + */
132 + void setTransmitDelay(int transmitDelay);
133 +
134 + /**
135 + * Sets retransmit interval which indicates the number of seconds between LSA retransmissions.
136 + *
137 + * @param reTransmitInterval an integer represents interval
138 + */
139 + void setReTransmitInterval(int reTransmitInterval);
140 +
141 + /**
142 + * Sets MTU.
143 + *
144 + * @param mtu an integer represents max transfer unit
145 + */
146 + void setMtu(int mtu);
147 +
148 + /**
149 + * Sets router priority.
150 + *
151 + * @param routerPriority value
152 + */
153 + void setRouterPriority(int routerPriority);
154 +
155 + /**
156 + * Gets the area id to which router belongs.
157 + *
158 + * @return areaId an integer value
159 + */
160 + int areaId();
161 +
162 + /**
163 + * Gets the IP address.
164 + *
165 + * @return an string represents IP address
166 + */
167 + Ip4Address ipAddress();
168 +
169 + /**
170 + * Gets the interface type.
171 + *
172 + * @return an integer represents interface type
173 + */
174 + int interfaceType();
175 +
176 + /**
177 + * Gets the MTU.
178 + *
179 + * @return an integer representing max transfer unit
180 + */
181 + int mtu();
182 +
183 + /**
184 + * Gets interface cost.
185 + *
186 + * @return an integer representing interface cost
187 + */
188 + int interfaceCost();
189 +
190 + /**
191 + * Gets the list of neighbors associated with the interface.
192 + *
193 + * @return listOfNeighbors as key value pair
194 + */
195 + HashMap<String, OspfNbr> listOfNeighbors();
196 +
197 + /**
198 + * Gets poll interval.
199 + *
200 + * @return pollInterval an integer representing poll interval
201 + */
202 + int pollInterval();
203 +
204 + /**
205 + * Gets transmission delay.
206 + *
207 + * @return transmitDelay an integer representing delay
208 + */
209 + int transmitDelay();
210 +
211 + /**
212 + * Gets the IP address of the BDR.
213 + *
214 + * @return bdr BDR's IP address
215 + */
216 + Ip4Address bdr();
217 +
218 + /**
219 + * Gets the ip address of the DR..
220 + *
221 + * @return dr DR's IP address
222 + */
223 + Ip4Address dr();
224 +
225 + /**
226 + * Gets authentication key.
227 + *
228 + * @return authKey represents authentication key
229 + */
230 + String authKey();
231 +
232 + /**
233 + * Gets authentication type.
234 + *
235 + * @return authType represents authentication type
236 + */
237 + String authType();
238 +
239 + /**
240 + * Gets hello interval time in seconds, this defines how often we send the hello packet.
241 + *
242 + * @return hello interval time in seconds
243 + */
244 + int helloIntervalTime();
245 +
246 + /**
247 + * Gets retransmit interval.
248 + *
249 + * @return reTransmitInterval an integer represents interval
250 + */
251 + int reTransmitInterval();
252 +
253 + /**
254 + * Gets router dead interval time.
255 + * This defines how long we should wait for hello packets before we declare the neighbor is dead.
256 + *
257 + * @return routerDeadIntervalTime an integer interval time
258 + */
259 + int routerDeadIntervalTime();
260 +
261 + /**
262 + * Gets router priority.
263 + *
264 + * @return routerPriority value
265 + */
266 + int routerPriority();
267 +
268 + /**
269 + * Adds the given neighboring router to the neighbor map.
270 + *
271 + * @param ospfNbr neighbor instance
272 + */
273 + void addNeighbouringRouter(OspfNbr ospfNbr);
274 +
275 + /**
276 + * Gets the neighbor instance from listOfNeighbors map for the given neighbor ID.
277 + *
278 + * @param neighborId neighbors id
279 + * @return ospfNbr neighbor instance
280 + */
281 + OspfNbr neighbouringRouter(String neighborId);
282 +
283 + /**
284 + * Checks the given neighbor is in the neighbor list.
285 + *
286 + * @param neighborId neighbors id
287 + * @return true if neighbor in list else false
288 + */
289 + boolean isNeighborInList(String neighborId);
290 +
291 + /**
292 + * Removes LSA headers from the map in which LSA headers are stored.
293 + *
294 + * @param lsaKey key used to store lsa in map
295 + */
296 + void removeLsaFromNeighborMap(String lsaKey);
297 +}
...\ 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.ospf.controller;
17 +
18 +import org.onlab.packet.IpAddress;
19 +
20 +import java.util.List;
21 +
22 +/**
23 + * Abstraction of an OSPF Link.
24 + */
25 +public interface OspfLink {
26 +
27 + /**
28 + * Gets IP address of the Router.
29 + *
30 + * @return IP address of router
31 + */
32 + IpAddress remoteRouterId();
33 +
34 + /**
35 + * Gets the area id for this device.
36 + *
37 + * @return the area id
38 + */
39 + int areaIdOfInterface();
40 +
41 + /**
42 + * Gets IP address of the interface.
43 + *
44 + * @return IP address of the interface
45 + */
46 + IpAddress interfaceIp();
47 +
48 + /**
49 + * Gets list of the link TED.
50 + *
51 + * @return list of the link TED
52 + */
53 + List<OspfLinkTed> linkTedLists();
54 +
55 + /**
56 + * Sets IP address of the router.
57 + *
58 + * @param routerIp router's IP address
59 + */
60 + void setRouterIp(IpAddress routerIp);
61 +
62 + /**
63 + * Sets the area id for this device.
64 + *
65 + * @param areaIdOfInterface area id
66 + */
67 + void setAreaIdOfInterface(int areaIdOfInterface);
68 +
69 + /**
70 + * Sets IP address of the interface.
71 + *
72 + * @param interfaceIp IP address of the interface.
73 + */
74 + void setInterfaceIp(IpAddress interfaceIp);
75 +
76 + /**
77 + * Sets list of the link TED.
78 + *
79 + * @param linkTedLists list of the link TED
80 + */
81 + void setLinkTedLists(List<OspfLinkTed> linkTedLists);
82 +}
...\ 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.ospf.controller;
17 +
18 +/**
19 + * Abstraction of an OSPF link listener.
20 + */
21 +public interface OspfLinkListener {
22 +
23 + /**
24 + * Notifies that we got a link from network.
25 + *
26 + * @param ospfRouter router instance
27 + * @param ospfLinkTed link TED information of router
28 + */
29 + void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
30 +
31 + /**
32 + * Notifies that a link got removed from network.
33 + *
34 + * @param ospfRouter router instance
35 + */
36 + void deleteLink(OspfRouter ospfRouter);
37 +}
...\ 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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +import org.onlab.packet.Ip6Address;
20 +import org.onlab.util.Bandwidth;
21 +
22 +import java.util.List;
23 +
24 +/**
25 + * Represents OSPF Link Traffic Engineering parameters.
26 + */
27 +public interface OspfLinkTed {
28 +
29 + /**
30 + * Provides maximum bandwidth can be used on the link.
31 + *
32 + * @return maximum bandwidth
33 + */
34 + public Bandwidth maximumLink();
35 +
36 + /**
37 + * Sets maximum band width.
38 + *
39 + * @param bandwidth maximum bandwidth
40 + */
41 + public void setMaximumLink(Bandwidth bandwidth);
42 +
43 + /**
44 + * Amount of bandwidth reservable on the link.
45 + *
46 + * @return unreserved bandwidth
47 + */
48 + public 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 + public void setMaxUnResBandwidth(Bandwidth bandwidth);
56 +
57 + /**
58 + * Provides max bandwidth that can be reserved on the link.
59 + *
60 + * @return max bandwidth reserved
61 + */
62 + public Bandwidth maxReserved();
63 +
64 + /**
65 + * Sets max bandwidth that can be reserved on the link.
66 + *
67 + * @param bandwidth max bandwidth that can be reserved on the link
68 + */
69 + public void setMaxReserved(Bandwidth bandwidth);
70 +
71 + /**
72 + * Provides Traffic Engineering metric for the link.
73 + *
74 + * @return Traffic Engineering metric
75 + */
76 + public Integer teMetric();
77 +
78 + /**
79 + * Sets Traffic Engineering metric for the link.
80 + *
81 + * @param teMetric Traffic Engineering metric for the link
82 + */
83 + public void setTeMetric(Integer teMetric);
84 +
85 + /**
86 + * Provides IPv4 router-Id of local node.
87 + *
88 + * @return IPv4 router-Id of local node
89 + */
90 + public List<Ip4Address> ipv4LocRouterId();
91 +
92 + /**
93 + * Sets IPv4 router-Id of local node.
94 + *
95 + * @param routerIds IPv4 router-Id of local node
96 + */
97 + public void setIpv4LocRouterId(List<Ip4Address> routerIds);
98 +
99 + /**
100 + * Provides IPv6 router-Id of local node.
101 + *
102 + * @return IPv6 router-Id of local node
103 + */
104 + public List<Ip6Address> ipv6LocRouterId();
105 +
106 + /**
107 + * Sets IPv6 router-Id of local node.
108 + *
109 + * @param routerIds IPv6 router-Id of local node
110 + */
111 + public void setIpv6LocRouterId(List<Ip6Address> routerIds);
112 +
113 + /**
114 + * Provides IPv4 router-Id of remote node.
115 + *
116 + * @return IPv4 router-Id of remote node
117 + */
118 + public List<Ip4Address> ipv4RemRouterId();
119 +
120 + /**
121 + * Sets IPv4 router-Id of remote node.
122 + *
123 + * @param routerIds IPv4 router-Id of remote node
124 + */
125 + public void setIpv4RemRouterId(List<Ip4Address> routerIds);
126 +
127 + /**
128 + * Provides IPv6 router-Id of remote node.
129 + *
130 + * @return IPv6 router-Id of remote node
131 + */
132 + public List<Ip6Address> ipv6RemRouterId();
133 +
134 + /**
135 + * Sets IPv6 router-Id of remote node.
136 + *
137 + * @param routerIds IPv6 router-Id of remote node
138 + */
139 + public void setIpv6RemRouterId(List<Ip6Address> routerIds);
140 +}
...\ 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.ospf.controller;
17 +
18 +/**
19 + * Represents an OSPF LSA.
20 + */
21 +public interface OspfLsa {
22 +
23 + /**
24 + * Gets the type of OSPF LSA.
25 + *
26 + * @return OSPF LSA type instance
27 + */
28 + OspfLsaType getOspfLsaType();
29 +
30 + /**
31 + * Gets the age of LSA.
32 + *
33 + * @return age of LSA
34 + */
35 + int age();
36 +
37 + /**
38 + * Gets the LSA header instance.
39 + *
40 + * @return this instance
41 + */
42 + public OspfLsa lsaHeader();
43 +}
...\ 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.ospf.controller;
17 +
18 +/**
19 + * Represents OSPF LSA types.
20 + */
21 +public enum OspfLsaType {
22 +
23 + ROUTER(1),
24 + NETWORK(2),
25 + SUMMARY(3),
26 + ASBR_SUMMARY(4),
27 + EXTERNAL_LSA(5),
28 + LINK_LOCAL_OPAQUE_LSA(9),
29 + AREA_LOCAL_OPAQUE_LSA(10),
30 + AS_OPAQUE_LSA(11),
31 + UNDEFINED(20);
32 +
33 + private int value;
34 +
35 + /**
36 + * Creates an instance of OSPF LSA type.
37 + *
38 + * @param value represents LSA type
39 + */
40 + OspfLsaType(int value) {
41 + this.value = value;
42 + }
43 +
44 + /**
45 + * Gets the value representing LSA type.
46 + *
47 + * @return value represents LSA type
48 + */
49 + public int value() {
50 + return value;
51 + }
52 +}
...\ 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.ospf.controller;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Represents an OSPF link state database.
22 + */
23 +public interface OspfLsdb {
24 +
25 + /**
26 + * Initializes the link state database.
27 + */
28 + public void initializeDb();
29 +
30 + /**
31 + * Gets all LSA headers.
32 + *
33 + * @param excludeMaxAgeLsa exclude the max age LSAs
34 + * @param isOpaqueCapable is opaque capable or not
35 + * @return List of LSA headers
36 + */
37 + public List getAllLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable);
38 +
39 + /**
40 + * Finds the LSA from appropriate LSA maps.
41 + *
42 + * @param lsType type of LSA
43 + * @param lsaKey key
44 + * @return LSA wrapper object
45 + */
46 + public LsaWrapper findLsa(int lsType, String lsaKey);
47 +
48 + /**
49 + * Adds the LSA to maxAge bin.
50 + *
51 + * @param key key
52 + * @param lsaWrapper LSA wrapper instance
53 + */
54 + public void addLsaToMaxAgeBin(String key, Object lsaWrapper);
55 +
56 + /**
57 + * Removes LSA from bin.
58 + *
59 + * @param lsaWrapper LSA wrapper instance
60 + */
61 + public void removeLsaFromBin(Object lsaWrapper);
62 +}
...\ 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.ospf.controller;
17 +
18 +import org.jboss.netty.channel.Channel;
19 +import org.onlab.packet.Ip4Address;
20 +
21 +import java.util.Map;
22 +
23 +/**
24 + * Represents an OSPF neighbor.
25 + */
26 +public interface OspfNbr {
27 +
28 + /**
29 + * Gets neighbor's id.
30 + *
31 + * @return neighbor's id
32 + */
33 + public Ip4Address neighborId();
34 +
35 + /**
36 + * Gets router priority.
37 + *
38 + * @return router priority
39 + */
40 + public int routerPriority();
41 +
42 + /**
43 + * Gets the IP address of this neighbor.
44 + *
45 + * @return the IP address of this neighbor
46 + */
47 + public Ip4Address neighborIpAddr();
48 +
49 + /**
50 + * Gets the neighbor's DR address.
51 + *
52 + * @return neighbor's DR address
53 + */
54 + public Ip4Address neighborDr();
55 +
56 + /**
57 + * Gets the neighbor's BDR address.
58 + *
59 + * @return neighbor's BDR address
60 + */
61 + Ip4Address neighborBdr();
62 +
63 + /**
64 + * Determines whether an adjacency should be established/maintained with the neighbor.
65 + *
66 + * @param ch netty channel instance
67 + */
68 + void adjOk(Channel ch);
69 +
70 + /**
71 + * Gets the pending re transmit list as a map.
72 + *
73 + * @return pending re transmit list as a map
74 + */
75 + Map<String, OspfLsa> getPendingReTxList();
76 +
77 + /**
78 + * Sets the neighbor's id.
79 + *
80 + * @param neighborId neighbor's id
81 + */
82 + void setNeighborId(Ip4Address neighborId);
83 +
84 + /**
85 + * Sets the neighbor's BDR address.
86 + *
87 + * @param neighborBdr neighbor's BDR address
88 + */
89 + void setNeighborBdr(Ip4Address neighborBdr);
90 +
91 + /**
92 + * Sets the neighbor's DR address.
93 + *
94 + * @param neighborDr neighbor's DR address
95 + */
96 + void setNeighborDr(Ip4Address neighborDr);
97 +
98 + /**
99 + * Sets router priority.
100 + *
101 + * @param routerPriority router priority
102 + */
103 + void setRouterPriority(int routerPriority);
104 +
105 + /**
106 + * Sets the neighbor is opaque enabled or not.
107 + *
108 + * @param isOpaqueCapable true if the neighbor is opaque enabled else false
109 + */
110 + void setIsOpaqueCapable(boolean isOpaqueCapable);
111 +
112 + /**
113 + * Sets neighbor is master or not.
114 + *
115 + * @param isMaster neighbor is master or not
116 + */
117 + void setIsMaster(int isMaster);
118 +
119 + /**
120 + * Gets the DD sequence number.
121 + *
122 + * @return DD sequence number
123 + */
124 + long ddSeqNum();
125 +
126 + /**
127 + * Sets the DD sequence number.
128 + *
129 + * @param ddSeqNum DD sequence number
130 + */
131 + void setDdSeqNum(long ddSeqNum);
132 +
133 + /**
134 + * Gets neighbor is master or not.
135 + *
136 + * @return true if neighbor is master else false
137 + */
138 + int isMaster();
139 +
140 + /**
141 + * Gets the options value.
142 + *
143 + * @return options value
144 + */
145 + int options();
146 +
147 + /**
148 + * Sets the options value.
149 + *
150 + * @param options options value
151 + */
152 + void setOptions(int options);
153 +
154 + /**
155 + * An invalid request for LSA has been received.
156 + * This indicates an error in the Database Exchange process. Actions to be performed
157 + * are the same as in seqNumMismatch. In addition, stop the possibly activated
158 + * retransmission timer.
159 + *
160 + * @param ch netty channel instance
161 + * @throws Exception might throw exception
162 + */
163 + void badLSReq(Channel ch) throws Exception;
164 +
165 + /**
166 + * Gets the LS request list.
167 + *
168 + * @return LS request list
169 + */
170 + Map getLsReqList();
171 +
172 + /**
173 + * Gets the reTxList instance.
174 + *
175 + * @return reTxList instance
176 + */
177 + Map getReTxList();
178 +
179 + /**
180 + * Gets if the neighbor is opaque enabled or not.
181 + *
182 + * @return true if the neighbor is opaque enabled else false.
183 + */
184 + public boolean isOpaqueCapable();
185 +
186 + /**
187 + * Gets the neighbor's state.
188 + *
189 + * @return neighbor's state
190 + */
191 + OspfNeighborState getState();
192 +}
...\ 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.ospf.controller;
17 +
18 +/**
19 + * Enum representing OSPF neighbor state.
20 + */
21 +public enum OspfNeighborState {
22 +
23 + DOWN(1),
24 + ATTEMPT(2),
25 + INIT(3),
26 + TWOWAY(4),
27 + EXSTART(5),
28 + EXCHANGE(6),
29 + LOADING(7),
30 + FULL(8);
31 +
32 + private int value;
33 +
34 + /**
35 + * Creates an OSPF neighbor state.
36 + *
37 + * @param value represents neighbors state
38 + */
39 + OspfNeighborState(int value) {
40 + this.value = value;
41 + }
42 +
43 + /**
44 + * Gets value of neighbor state.
45 + *
46 + * @return value represents neighbors state
47 + */
48 + public int getValue() {
49 + return value;
50 + }
51 +}
...\ 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"); 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 +package org.onosproject.ospf.controller;
14 +
15 +import java.util.List;
16 +
17 +/**
18 + * Represents an OSPF Process.
19 + */
20 +public interface OspfProcess {
21 +
22 + /**
23 + * Gets the list of areas belonging to this process.
24 + *
25 + * @return list of areas belonging to this process
26 + */
27 + public List<OspfArea> areas();
28 +
29 + /**
30 + * Sets the list of areas belonging to this process.
31 + *
32 + * @param areas list of areas belonging to this process
33 + */
34 + public void setAreas(List<OspfArea> areas);
35 +
36 + /**
37 + * Gets the process id.
38 + *
39 + * @return process id
40 + */
41 + public String processId();
42 +
43 + /**
44 + * Sets the process id.
45 + *
46 + * @param processId the process id
47 + */
48 + public void setProcessId(String processId);
49 +}
...\ 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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +/**
21 + * Abstraction of an OSPF Router.
22 + */
23 +public interface OspfRouter {
24 +
25 + /**
26 + * Gets IP address of the router.
27 + *
28 + * @return IP address of the router
29 + */
30 + Ip4Address routerIp();
31 +
32 + /**
33 + * Gets the area id for this device.
34 + *
35 + * @return the area id for this device
36 + */
37 + Ip4Address areaIdOfInterface();
38 +
39 + /**
40 + * Gets IP address of the interface.
41 + *
42 + * @return IP address of the interface
43 + */
44 + Ip4Address interfaceId();
45 +
46 + /**
47 + * Gets list of device TED.
48 + *
49 + * @return list of device TED.
50 + */
51 + OspfDeviceTed deviceTed();
52 +
53 + /**
54 + * Sets IP address of the Router.
55 + *
56 + * @param routerIp IP address of the router
57 + */
58 + void setRouterIp(Ip4Address routerIp);
59 +
60 + /**
61 + * Sets area id in which this device belongs to.
62 + *
63 + * @param areaIdOfInterface area id in which this device belongs to
64 + */
65 + void setAreaIdOfInterface(Ip4Address areaIdOfInterface);
66 +
67 + /**
68 + * Sets IP address of the interface.
69 + *
70 + * @param interfaceId IP address of the interface
71 + */
72 + void setInterfaceId(Ip4Address interfaceId);
73 +
74 + /**
75 + * Sets the device TED information.
76 + *
77 + * @param deviceTed device TED instance
78 + */
79 + void setDeviceTed(OspfDeviceTed deviceTed);
80 +
81 + /**
82 + * Gets if router is opaque enabled.
83 + *
84 + * @return true if router is opaque enabled else false.
85 + */
86 + boolean isOpaque();
87 +
88 + /**
89 + * Sets true if device is opaque enable if not sets false.
90 + *
91 + * @param opaque true if device is opaque enable if not sets false
92 + */
93 + void setOpaque(boolean opaque);
94 +
95 + /**
96 + * Gets IP address of the advertising router.
97 + *
98 + * @return IP address of the advertising router
99 + */
100 + Ip4Address neighborRouterId();
101 +
102 + /**
103 + * Sets IP address of the advertising router.
104 + *
105 + * @param advertisingRouterId IP address of the advertising router
106 + */
107 + void setNeighborRouterId(Ip4Address advertisingRouterId);
108 +
109 +
110 + /**
111 + * Gets if the router id DR or not.
112 + *
113 + * @return true if the router is DR else false
114 + */
115 + boolean isDr();
116 +
117 + /**
118 + * Sets if the router id DR or not.
119 + *
120 + * @param dr true if the router is DR else false
121 + */
122 + void setDr(boolean dr);
123 +}
...\ 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 +
17 +package org.onosproject.ospf.controller;
18 +
19 +import org.onlab.packet.IpAddress;
20 +
21 +import java.net.URI;
22 +import java.net.URISyntaxException;
23 +import java.util.Objects;
24 +
25 +import static com.google.common.base.Preconditions.checkArgument;
26 +
27 +/**
28 + * Represents an OSPF router id.
29 + */
30 +public class OspfRouterId {
31 +
32 + private static final String SCHEME = "ospf";
33 + private static final long UNKNOWN = 0;
34 + private final IpAddress ipAddress;
35 +
36 + /**
37 + * Creates an instance of OSPF router id.
38 + *
39 + * @param ipAddress IP address of the router
40 + */
41 + public OspfRouterId(IpAddress ipAddress) {
42 + this.ipAddress = ipAddress;
43 + }
44 +
45 + /**
46 + * Creates an instance from ip address.
47 + *
48 + * @param ipAddress IP address
49 + * @return OSPF router id instance
50 + */
51 + public static OspfRouterId ospfRouterId(IpAddress ipAddress) {
52 + return new OspfRouterId(ipAddress);
53 + }
54 +
55 + /**
56 + * Creates OSPF router id instance from the URI.
57 + *
58 + * @param uri device URI
59 + * @return OSPF router id instance
60 + */
61 + public static OspfRouterId ospfRouterId(URI uri) {
62 + checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
63 + return new OspfRouterId(IpAddress.valueOf(uri.getSchemeSpecificPart()));
64 + }
65 +
66 + /**
67 + * Returns device URI from the given router id.
68 + *
69 + * @param ospfRouterId router id instance
70 + * @return device URI
71 + */
72 + public static URI uri(OspfRouterId ospfRouterId) {
73 + return uri(ospfRouterId.ipAddress());
74 + }
75 +
76 + /**
77 + * Returns device URI from the given IP address.
78 + *
79 + * @param ipAddress device IP address
80 + * @return device URI
81 + */
82 + public static URI uri(IpAddress ipAddress) {
83 + try {
84 + return new URI(SCHEME, ipAddress.toString(), null);
85 + } catch (URISyntaxException e) {
86 + return null;
87 + }
88 + }
89 +
90 + /**
91 + * Returns the IP address.
92 + *
93 + * @return IP address
94 + */
95 + public IpAddress ipAddress() {
96 + return ipAddress;
97 + }
98 +
99 + @Override
100 + public String toString() {
101 + return ipAddress.toString();
102 + }
103 +
104 + @Override
105 + public boolean equals(Object other) {
106 + if (!(other instanceof OspfRouterId)) {
107 + return false;
108 + }
109 +
110 + OspfRouterId otherOspfRouterId = (OspfRouterId) other;
111 + return Objects.equals(ipAddress, otherOspfRouterId.ipAddress);
112 + }
113 +
114 + @Override
115 + public int hashCode() {
116 + return Objects.hash(ipAddress);
117 + }
118 +}
...\ 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.ospf.controller;
17 +
18 +/**
19 + * Abstraction of an OSPF Router Listener.
20 + * Allows for providers interested in switch events to be notified.
21 + */
22 +public interface OspfRouterListener {
23 +
24 + /**
25 + * Notifies that a router is added.
26 + *
27 + * @param ospfRouter OSPF router instance
28 + */
29 + void routerAdded(OspfRouter ospfRouter);
30 +
31 + /**
32 + * Notifies that a router is removed.
33 + *
34 + * @param ospfRouter OSPF router instance
35 + */
36 + void routerRemoved(OspfRouter ospfRouter);
37 +
38 + /**
39 + * Notifies that the router has changed in some way.
40 + *
41 + * @param ospfRouter OSPF router instance
42 + */
43 + void routerChanged(OspfRouter ospfRouter);
44 +}
...\ 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.ospf.controller;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +import java.util.List;
21 +import java.util.Map;
22 +
23 +/**
24 + * Represents IP topology for OSPF device and link details.
25 + */
26 +public interface TopologyForDeviceAndLink {
27 +
28 + /**
29 + * Gets the device information.
30 + *
31 + * @return device information
32 + */
33 + Map<String, DeviceInformation> deviceInformationMap();
34 +
35 + /**
36 + * Sets the device information.
37 + *
38 + * @param key key used to store in map
39 + * @param deviceInformationMap device information instance
40 + */
41 + void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap);
42 +
43 + /**
44 + * Gets the link information.
45 + *
46 + * @return link information
47 + */
48 + Map<String, LinkInformation> linkInformationMap();
49 +
50 + /**
51 + * Sets link information.
52 + *
53 + * @param key key used to store in map
54 + * @param linkInformationMap link information instance
55 + */
56 + void setLinkInformationMap(String key, LinkInformation linkInformationMap);
57 +
58 + /**
59 + * Removes link information.
60 + *
61 + * @param key key used to remove from map
62 + */
63 + void removeLinkInformationMap(String key);
64 +
65 + /**
66 + * Adds device information.
67 + *
68 + * @param ospfLsa LSA instance
69 + * @param ospfInterface interface instance
70 + * @param ospfArea area instance
71 + */
72 + void addLocalDevice(OspfLsa ospfLsa, OspfInterface ospfInterface, OspfArea ospfArea);
73 +
74 + /**
75 + * Removes device information.
76 + *
77 + * @param key key used to remove from map
78 + */
79 + void removeDeviceInformationMap(String key);
80 +
81 + /**
82 + * Removes links from linkInformationMap.
83 + *
84 + * @param routerId router's IP address
85 + */
86 + void removeLinks(Ip4Address routerId);
87 +
88 + /**
89 + * Gets OSPF link TED details.
90 + *
91 + * @param key key used to retrieve from map
92 + * @return links TED information
93 + */
94 + OspfLinkTed getOspfLinkTedHashMap(String key);
95 +
96 + /**
97 + * Gets all the router information to be deleted.
98 + *
99 + * @param ospfLsa LSA instance
100 + * @param ospfArea area instance
101 + * @return list of router information which needs to delete from device list
102 + */
103 + List<String> getDeleteRouterInformation(OspfLsa ospfLsa, OspfArea ospfArea);
104 +
105 + /**
106 + * Updates the device and link information.
107 + *
108 + * @param ospfLsa LSA instance
109 + * @param ospfArea area instance
110 + */
111 + void updateLinkInformation(OspfLsa ospfLsa, OspfArea ospfArea);
112 +}
...\ 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 +
17 +/**
18 + * Implementation of the ospf api interfaces.
19 + */
20 +package org.onosproject.ospf.controller;
...\ No newline at end of file ...\ No newline at end of file
1 +package org.onosproject.ospf.controller;
2 +
3 +import org.junit.After;
4 +import org.junit.Before;
5 +import org.junit.Test;
6 +import org.onlab.packet.IpAddress;
7 +
8 +import java.net.URI;
9 +
10 +import static org.hamcrest.CoreMatchers.*;
11 +import static org.hamcrest.MatcherAssert.assertThat;
12 +
13 +/**
14 + * Unit test class for OspfRouterId.
15 + */
16 +public class OspfRouterIdTest {
17 +
18 + private OspfRouterId ospfRouterId;
19 +
20 + @Before
21 + public void setUp() throws Exception {
22 + ospfRouterId = new OspfRouterId(IpAddress.valueOf("2.2.2.2"));
23 + }
24 +
25 + @After
26 + public void tearDown() throws Exception {
27 + ospfRouterId = null;
28 + }
29 +
30 + /**
31 + * Tests constructor.
32 + */
33 + @Test
34 + public void testOspfRouterId() throws Exception {
35 + assertThat(OspfRouterId.ospfRouterId(IpAddress.valueOf("2.2.2.2")), instanceOf(OspfRouterId.class));
36 +
37 + }
38 +
39 + /**
40 + * Tests ipAddress() getter method.
41 + */
42 + @Test
43 + public void testIpAddress() throws Exception {
44 + assertThat(ospfRouterId.ipAddress(), instanceOf(IpAddress.class));
45 + }
46 +
47 + /**
48 + * Tests to string method.
49 + */
50 + @Test
51 + public void testToString() throws Exception {
52 + assertThat(ospfRouterId.toString(), is(notNullValue()));
53 + }
54 +
55 + /**
56 + * Tests equals() method.
57 + */
58 + @Test
59 + public void testEquals() throws Exception {
60 + assertThat(ospfRouterId.equals(new OspfRouterId(IpAddress.valueOf("3.3.3.3"))), is(false));
61 + }
62 +
63 + /**
64 + * Tests hashCode() method.
65 + */
66 + @Test
67 + public void testHashCode() throws Exception {
68 + assertThat(ospfRouterId.hashCode(), is(notNullValue()));
69 + }
70 +
71 + /**
72 + * Tests constructor.
73 + */
74 + @Test
75 + public void testOspfRouterId1() throws Exception {
76 + assertThat(OspfRouterId.ospfRouterId(OspfRouterId.uri(ospfRouterId)), instanceOf(OspfRouterId.class));
77 + }
78 +
79 + /**
80 + * Tests uri() method.
81 + */
82 + @Test
83 + public void testUri() throws Exception {
84 + assertThat(OspfRouterId.uri(IpAddress.valueOf("2.2.2.2")), instanceOf(URI.class));
85 + }
86 +
87 + /**
88 + * Tests uri() method..
89 + */
90 + @Test
91 + public void testUri1() throws Exception {
92 + assertThat(OspfRouterId.uri(ospfRouterId), instanceOf(URI.class));
93 + }
94 +}
...\ No newline at end of file ...\ No newline at end of file