Committed by
Gerrit Code Review
OSPF protocol manual merge from 1.6, due to cherry pick merge conflict
Change-Id: I93653e745468722ce95533537a79e897b4292f5d
Showing
83 changed files
with
1262 additions
and
773 deletions
| ... | @@ -98,4 +98,11 @@ public interface LsdbAge { | ... | @@ -98,4 +98,11 @@ public interface LsdbAge { |
| 98 | * @param lsaWrapper wrapper instance | 98 | * @param lsaWrapper wrapper instance |
| 99 | */ | 99 | */ |
| 100 | public void removeLsaFromBin(LsaWrapper lsaWrapper); | 100 | public void removeLsaFromBin(LsaWrapper lsaWrapper); |
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * Gets the age counter roll over. | ||
| 104 | + * | ||
| 105 | + * @return the age counter roll over | ||
| 106 | + */ | ||
| 107 | + public int getAgeCounterRollOver(); | ||
| 101 | } | 108 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -38,17 +38,18 @@ public interface OspfAgent { | ... | @@ -38,17 +38,18 @@ public interface OspfAgent { |
| 38 | void removeConnectedRouter(OspfRouter ospfRouter); | 38 | void removeConnectedRouter(OspfRouter ospfRouter); |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | - * Notifies that got a packet of link from network and need do processing. | 41 | + * Notifies that got a packet of link from network and need to add the link. |
| 42 | * | 42 | * |
| 43 | - * @param ospfRouter router instance | 43 | + * @param ospfRouter router instance |
| 44 | - * @param ospfLinkTed link ted instance | 44 | + * @param ospfLinkTed link TED instance |
| 45 | */ | 45 | */ |
| 46 | void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); | 46 | void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); |
| 47 | 47 | ||
| 48 | /** | 48 | /** |
| 49 | - * Notifies that got a packet of link from network and need do processing. | 49 | + * Notifies that got a packet of link from network and need do delete the link. |
| 50 | * | 50 | * |
| 51 | * @param ospfRouter router instance | 51 | * @param ospfRouter router instance |
| 52 | + * @param ospfLinkTed link TED instance | ||
| 52 | */ | 53 | */ |
| 53 | - void deleteLink(OspfRouter ospfRouter); | 54 | + void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); |
| 54 | } | 55 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -59,7 +59,7 @@ public interface OspfArea { | ... | @@ -59,7 +59,7 @@ public interface OspfArea { |
| 59 | * | 59 | * |
| 60 | * @return LSDB instance for this area | 60 | * @return LSDB instance for this area |
| 61 | */ | 61 | */ |
| 62 | - public OspfLsdb database(); | 62 | + OspfLsdb database(); |
| 63 | 63 | ||
| 64 | /** | 64 | /** |
| 65 | * Checks whether an instance of the given LSA exists in the database. | 65 | * Checks whether an instance of the given LSA exists in the database. |
| ... | @@ -67,19 +67,12 @@ public interface OspfArea { | ... | @@ -67,19 +67,12 @@ public interface OspfArea { |
| 67 | * @param lookupLsa LSA instance to lookup | 67 | * @param lookupLsa LSA instance to lookup |
| 68 | * @return LSA wrapper instance which contains the LSA | 68 | * @return LSA wrapper instance which contains the LSA |
| 69 | */ | 69 | */ |
| 70 | - public LsaWrapper lsaLookup(OspfLsa lookupLsa); | 70 | + LsaWrapper lsaLookup(OspfLsa lookupLsa); |
| 71 | 71 | ||
| 72 | /** | 72 | /** |
| 73 | * Initializes link state database, this acts as a place holder for storing the received LSA. | 73 | * Initializes link state database, this acts as a place holder for storing the received LSA. |
| 74 | */ | 74 | */ |
| 75 | - public void initializeDb(); | 75 | + void initializeDb(); |
| 76 | - | ||
| 77 | - /** | ||
| 78 | - * Sets the stub cost. | ||
| 79 | - * | ||
| 80 | - * @param stubCost stub cost | ||
| 81 | - */ | ||
| 82 | - void setStubCost(int stubCost); | ||
| 83 | 76 | ||
| 84 | /** | 77 | /** |
| 85 | * Sets the options value. | 78 | * Sets the options value. |
| ... | @@ -89,38 +82,6 @@ public interface OspfArea { | ... | @@ -89,38 +82,6 @@ public interface OspfArea { |
| 89 | void setOptions(int options); | 82 | void setOptions(int options); |
| 90 | 83 | ||
| 91 | /** | 84 | /** |
| 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. | 85 | * Gets external routing capability. |
| 125 | * This indicates Whether AS-external-LSAs will be flooded into/throughout the area. | 86 | * This indicates Whether AS-external-LSAs will be flooded into/throughout the area. |
| 126 | * | 87 | * |
| ... | @@ -137,13 +98,6 @@ public interface OspfArea { | ... | @@ -137,13 +98,6 @@ public interface OspfArea { |
| 137 | void setExternalRoutingCapability(boolean externalRoutingCapability); | 98 | void setExternalRoutingCapability(boolean externalRoutingCapability); |
| 138 | 99 | ||
| 139 | /** | 100 | /** |
| 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. | 101 | * Gets if the router is opaque enabled or not. |
| 148 | * This indicates whether the router accepts opaque LSA. | 102 | * This indicates whether the router accepts opaque LSA. |
| 149 | * | 103 | * |
| ... | @@ -156,14 +110,14 @@ public interface OspfArea { | ... | @@ -156,14 +110,14 @@ public interface OspfArea { |
| 156 | * | 110 | * |
| 157 | * @return list of interfaces | 111 | * @return list of interfaces |
| 158 | */ | 112 | */ |
| 159 | - List<OspfInterface> getInterfacesLst(); | 113 | + List<OspfInterface> ospfInterfaceList(); |
| 160 | 114 | ||
| 161 | /** | 115 | /** |
| 162 | * Sets the list of interfaces attached to this area. | 116 | * Sets the list of interfaces attached to this area. |
| 163 | * | 117 | * |
| 164 | * @param interfacesLst list of interface instances | 118 | * @param interfacesLst list of interface instances |
| 165 | */ | 119 | */ |
| 166 | - void setInterfacesLst(List<OspfInterface> interfacesLst); | 120 | + void setOspfInterfaceList(List<OspfInterface> interfacesLst); |
| 167 | 121 | ||
| 168 | /** | 122 | /** |
| 169 | * Gets the options value, which indicates the supported optional capabilities. | 123 | * Gets the options value, which indicates the supported optional capabilities. | ... | ... |
| ... | @@ -15,6 +15,8 @@ | ... | @@ -15,6 +15,8 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.ospf.controller; | 16 | package org.onosproject.ospf.controller; |
| 17 | 17 | ||
| 18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 19 | + | ||
| 18 | import java.util.List; | 20 | import java.util.List; |
| 19 | import java.util.Set; | 21 | import java.util.Set; |
| 20 | 22 | ||
| ... | @@ -55,9 +57,9 @@ public interface OspfController { | ... | @@ -55,9 +57,9 @@ public interface OspfController { |
| 55 | /** | 57 | /** |
| 56 | * Updates configuration of processes. | 58 | * Updates configuration of processes. |
| 57 | * | 59 | * |
| 58 | - * @param processes process info to update | 60 | + * @param processesNode process info to update |
| 59 | */ | 61 | */ |
| 60 | - public void updateConfig(List<OspfProcess> processes); | 62 | + void updateConfig(JsonNode processesNode); |
| 61 | 63 | ||
| 62 | /** | 64 | /** |
| 63 | * Deletes configuration parameters. | 65 | * Deletes configuration parameters. |
| ... | @@ -65,7 +67,7 @@ public interface OspfController { | ... | @@ -65,7 +67,7 @@ public interface OspfController { |
| 65 | * @param processes list of process instance | 67 | * @param processes list of process instance |
| 66 | * @param attribute attribute to delete | 68 | * @param attribute attribute to delete |
| 67 | */ | 69 | */ |
| 68 | - public void deleteConfig(List<OspfProcess> processes, String attribute); | 70 | + void deleteConfig(List<OspfProcess> processes, String attribute); |
| 69 | 71 | ||
| 70 | /** | 72 | /** |
| 71 | * Gets the list of listeners registered for router events. | 73 | * Gets the list of listeners registered for router events. | ... | ... |
| ... | @@ -15,9 +15,10 @@ | ... | @@ -15,9 +15,10 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.ospf.controller; | 16 | package org.onosproject.ospf.controller; |
| 17 | 17 | ||
| 18 | +import org.jboss.netty.channel.ChannelHandlerContext; | ||
| 18 | import org.onlab.packet.Ip4Address; | 19 | import org.onlab.packet.Ip4Address; |
| 19 | 20 | ||
| 20 | -import java.util.HashMap; | 21 | +import java.util.Map; |
| 21 | 22 | ||
| 22 | /** | 23 | /** |
| 23 | * Represents an OSPF Interface. | 24 | * Represents an OSPF Interface. |
| ... | @@ -25,34 +26,39 @@ import java.util.HashMap; | ... | @@ -25,34 +26,39 @@ import java.util.HashMap; |
| 25 | public interface OspfInterface { | 26 | public interface OspfInterface { |
| 26 | 27 | ||
| 27 | /** | 28 | /** |
| 28 | - * Gets network mask of the interface. | 29 | + * Returns interface index. |
| 29 | * | 30 | * |
| 30 | - * @return network mask | 31 | + * @return interface index |
| 31 | */ | 32 | */ |
| 32 | - Ip4Address ipNetworkMask(); | 33 | + public int interfaceIndex(); |
| 33 | 34 | ||
| 34 | /** | 35 | /** |
| 35 | - * Sets area id, to which the interface belongs. | 36 | + * Sets interface index. |
| 36 | * | 37 | * |
| 37 | - * @param areaId area identifier | 38 | + * @param interfaceIndex interface index |
| 38 | */ | 39 | */ |
| 39 | - void setAreaId(int areaId); | 40 | + public void setInterfaceIndex(int interfaceIndex); |
| 40 | 41 | ||
| 41 | /** | 42 | /** |
| 42 | - * Sets the authentication key. | 43 | + * Returns OSPF area instance. |
| 43 | - * Interface uses this to authenticate while establishing communication with other routers. | ||
| 44 | * | 44 | * |
| 45 | - * @param authKey represents authentication key | 45 | + * @return OSPF area instance |
| 46 | */ | 46 | */ |
| 47 | - void setAuthKey(String authKey); | 47 | + public OspfArea ospfArea(); |
| 48 | 48 | ||
| 49 | /** | 49 | /** |
| 50 | - * Sets the authentication type, | 50 | + * Sets OSPF area instance. |
| 51 | - * Interface uses this to authenticate while establishing communication with other routers. | ||
| 52 | * | 51 | * |
| 53 | - * @param authType authType represents authentication type | 52 | + * @param ospfArea OSPF area instance |
| 53 | + */ | ||
| 54 | + public void setOspfArea(OspfArea ospfArea); | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * Gets network mask of the interface. | ||
| 58 | + * | ||
| 59 | + * @return network mask | ||
| 54 | */ | 60 | */ |
| 55 | - void setAuthType(String authType); | 61 | + Ip4Address ipNetworkMask(); |
| 56 | 62 | ||
| 57 | /** | 63 | /** |
| 58 | * Sets the value of BDR. | 64 | * Sets the value of BDR. |
| ... | @@ -87,13 +93,6 @@ public interface OspfInterface { | ... | @@ -87,13 +93,6 @@ public interface OspfInterface { |
| 87 | void setRouterDeadIntervalTime(int routerDeadIntervalTime); | 93 | void setRouterDeadIntervalTime(int routerDeadIntervalTime); |
| 88 | 94 | ||
| 89 | /** | 95 | /** |
| 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. | 96 | * Sets interface type. |
| 98 | * This indicates whether the interface is on point to point mode or broadcast mode. | 97 | * This indicates whether the interface is on point to point mode or broadcast mode. |
| 99 | * | 98 | * |
| ... | @@ -116,22 +115,6 @@ public interface OspfInterface { | ... | @@ -116,22 +115,6 @@ public interface OspfInterface { |
| 116 | void setIpNetworkMask(Ip4Address ipNetworkMask); | 115 | void setIpNetworkMask(Ip4Address ipNetworkMask); |
| 117 | 116 | ||
| 118 | /** | 117 | /** |
| 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. | 118 | * Sets retransmit interval which indicates the number of seconds between LSA retransmissions. |
| 136 | * | 119 | * |
| 137 | * @param reTransmitInterval an integer represents interval | 120 | * @param reTransmitInterval an integer represents interval |
| ... | @@ -153,13 +136,6 @@ public interface OspfInterface { | ... | @@ -153,13 +136,6 @@ public interface OspfInterface { |
| 153 | void setRouterPriority(int routerPriority); | 136 | void setRouterPriority(int routerPriority); |
| 154 | 137 | ||
| 155 | /** | 138 | /** |
| 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. | 139 | * Gets the IP address. |
| 164 | * | 140 | * |
| 165 | * @return an string represents IP address | 141 | * @return an string represents IP address |
| ... | @@ -181,32 +157,11 @@ public interface OspfInterface { | ... | @@ -181,32 +157,11 @@ public interface OspfInterface { |
| 181 | int mtu(); | 157 | int mtu(); |
| 182 | 158 | ||
| 183 | /** | 159 | /** |
| 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. | 160 | * Gets the list of neighbors associated with the interface. |
| 192 | * | 161 | * |
| 193 | * @return listOfNeighbors as key value pair | 162 | * @return listOfNeighbors as key value pair |
| 194 | */ | 163 | */ |
| 195 | - HashMap<String, OspfNbr> listOfNeighbors(); | 164 | + Map<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 | 165 | ||
| 211 | /** | 166 | /** |
| 212 | * Gets the IP address of the BDR. | 167 | * Gets the IP address of the BDR. |
| ... | @@ -223,20 +178,6 @@ public interface OspfInterface { | ... | @@ -223,20 +178,6 @@ public interface OspfInterface { |
| 223 | Ip4Address dr(); | 178 | Ip4Address dr(); |
| 224 | 179 | ||
| 225 | /** | 180 | /** |
| 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. | 181 | * Gets hello interval time in seconds, this defines how often we send the hello packet. |
| 241 | * | 182 | * |
| 242 | * @return hello interval time in seconds | 183 | * @return hello interval time in seconds |
| ... | @@ -294,4 +235,54 @@ public interface OspfInterface { | ... | @@ -294,4 +235,54 @@ public interface OspfInterface { |
| 294 | * @param lsaKey key used to store lsa in map | 235 | * @param lsaKey key used to store lsa in map |
| 295 | */ | 236 | */ |
| 296 | void removeLsaFromNeighborMap(String lsaKey); | 237 | void removeLsaFromNeighborMap(String lsaKey); |
| 238 | + | ||
| 239 | + /** | ||
| 240 | + * When an OSPF message received it is handed over to this method. | ||
| 241 | + * Based on the type of the OSPF message received it will be handed over | ||
| 242 | + * to corresponding message handler methods. | ||
| 243 | + * | ||
| 244 | + * @param ospfMessage received OSPF message | ||
| 245 | + * @param ctx channel handler context instance. | ||
| 246 | + * @throws Exception might throws exception | ||
| 247 | + */ | ||
| 248 | + void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception; | ||
| 249 | + | ||
| 250 | + /** | ||
| 251 | + * Represents an interface is up and connected. | ||
| 252 | + * | ||
| 253 | + * @throws Exception might throws exception | ||
| 254 | + */ | ||
| 255 | + void interfaceUp() throws Exception; | ||
| 256 | + | ||
| 257 | + /** | ||
| 258 | + * Starts the timer which waits for configured seconds and sends Delayed Ack Packet. | ||
| 259 | + */ | ||
| 260 | + void startDelayedAckTimer(); | ||
| 261 | + | ||
| 262 | + /** | ||
| 263 | + * Stops the delayed acknowledge timer. | ||
| 264 | + */ | ||
| 265 | + void stopDelayedAckTimer(); | ||
| 266 | + | ||
| 267 | + /** | ||
| 268 | + * Starts the hello timer which sends hello packet every configured seconds. | ||
| 269 | + */ | ||
| 270 | + void startHelloTimer(); | ||
| 271 | + | ||
| 272 | + /** | ||
| 273 | + * Stops the hello timer. | ||
| 274 | + */ | ||
| 275 | + void stopHelloTimer(); | ||
| 276 | + | ||
| 277 | + /** | ||
| 278 | + * Gets called when an interface is down. | ||
| 279 | + * All interface variables are reset, and interface timers disabled. | ||
| 280 | + * Also all neighbor connections associated with the interface are destroyed. | ||
| 281 | + */ | ||
| 282 | + void interfaceDown(); | ||
| 283 | + | ||
| 284 | + /** | ||
| 285 | + * Removes all the neighbors. | ||
| 286 | + */ | ||
| 287 | + void removeNeighbors(); | ||
| 297 | } | 288 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -23,7 +23,7 @@ public interface OspfLinkListener { | ... | @@ -23,7 +23,7 @@ public interface OspfLinkListener { |
| 23 | /** | 23 | /** |
| 24 | * Notifies that we got a link from network. | 24 | * Notifies that we got a link from network. |
| 25 | * | 25 | * |
| 26 | - * @param ospfRouter router instance | 26 | + * @param ospfRouter router instance |
| 27 | * @param ospfLinkTed link TED information of router | 27 | * @param ospfLinkTed link TED information of router |
| 28 | */ | 28 | */ |
| 29 | void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); | 29 | void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); |
| ... | @@ -31,7 +31,8 @@ public interface OspfLinkListener { | ... | @@ -31,7 +31,8 @@ public interface OspfLinkListener { |
| 31 | /** | 31 | /** |
| 32 | * Notifies that a link got removed from network. | 32 | * Notifies that a link got removed from network. |
| 33 | * | 33 | * |
| 34 | - * @param ospfRouter router instance | 34 | + * @param ospfRouter router instance |
| 35 | + * @param ospfLinkTed link TED information of router | ||
| 35 | */ | 36 | */ |
| 36 | - void deleteLink(OspfRouter ospfRouter); | 37 | + void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); |
| 37 | } | 38 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -13,12 +13,10 @@ | ... | @@ -13,12 +13,10 @@ |
| 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.ospf.protocol.ospfpacket; | 16 | +package org.onosproject.ospf.controller; |
| 17 | 17 | ||
| 18 | import org.jboss.netty.buffer.ChannelBuffer; | 18 | import org.jboss.netty.buffer.ChannelBuffer; |
| 19 | import org.onlab.packet.Ip4Address; | 19 | import org.onlab.packet.Ip4Address; |
| 20 | -import org.onosproject.ospf.exceptions.OspfParseException; | ||
| 21 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | ||
| 22 | 20 | ||
| 23 | /** | 21 | /** |
| 24 | * Representation of an OSPF message. | 22 | * Representation of an OSPF message. |
| ... | @@ -26,6 +24,20 @@ import org.onosproject.ospf.protocol.util.OspfPacketType; | ... | @@ -26,6 +24,20 @@ import org.onosproject.ospf.protocol.util.OspfPacketType; |
| 26 | public interface OspfMessage { | 24 | public interface OspfMessage { |
| 27 | 25 | ||
| 28 | /** | 26 | /** |
| 27 | + * Returns the interface index on which the message received. | ||
| 28 | + * | ||
| 29 | + * @return interface index on which the message received | ||
| 30 | + */ | ||
| 31 | + int interfaceIndex(); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * Sets the interface index on which the message received. | ||
| 35 | + * | ||
| 36 | + * @param interfaceIndex interface index on which the message received | ||
| 37 | + */ | ||
| 38 | + void setInterfaceIndex(int interfaceIndex); | ||
| 39 | + | ||
| 40 | + /** | ||
| 29 | * Returns the type of OSPF message. | 41 | * Returns the type of OSPF message. |
| 30 | * | 42 | * |
| 31 | * @return OSPF message type | 43 | * @return OSPF message type |
| ... | @@ -36,9 +48,9 @@ public interface OspfMessage { | ... | @@ -36,9 +48,9 @@ public interface OspfMessage { |
| 36 | * Reads from ChannelBuffer and initializes the type of LSA. | 48 | * Reads from ChannelBuffer and initializes the type of LSA. |
| 37 | * | 49 | * |
| 38 | * @param channelBuffer channel buffer instance | 50 | * @param channelBuffer channel buffer instance |
| 39 | - * @throws OspfParseException might throws exception while parsing buffer | 51 | + * @throws Exception might throws exception while parsing buffer |
| 40 | */ | 52 | */ |
| 41 | - void readFrom(ChannelBuffer channelBuffer) throws OspfParseException; | 53 | + void readFrom(ChannelBuffer channelBuffer) throws Exception; |
| 42 | 54 | ||
| 43 | /** | 55 | /** |
| 44 | * Returns OSPFMessage as byte array. | 56 | * Returns OSPFMessage as byte array. | ... | ... |
| ... | @@ -189,4 +189,36 @@ public interface OspfNbr { | ... | @@ -189,4 +189,36 @@ public interface OspfNbr { |
| 189 | * @return neighbor's state | 189 | * @return neighbor's state |
| 190 | */ | 190 | */ |
| 191 | OspfNeighborState getState(); | 191 | OspfNeighborState getState(); |
| 192 | + | ||
| 193 | + /** | ||
| 194 | + * Starts the inactivity timer. | ||
| 195 | + */ | ||
| 196 | + void startInactivityTimeCheck(); | ||
| 197 | + | ||
| 198 | + /** | ||
| 199 | + * Stops the inactivity timer. | ||
| 200 | + */ | ||
| 201 | + void stopInactivityTimeCheck(); | ||
| 202 | + | ||
| 203 | + /** | ||
| 204 | + * Sets router dead interval. | ||
| 205 | + * | ||
| 206 | + * @param routerDeadInterval router dead interval | ||
| 207 | + */ | ||
| 208 | + void setRouterDeadInterval(int routerDeadInterval); | ||
| 209 | + | ||
| 210 | + /** | ||
| 211 | + * Stops the flooding timer. | ||
| 212 | + */ | ||
| 213 | + void stopFloodingTimer(); | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + * Stops the Dd Retransmission executor task. | ||
| 217 | + */ | ||
| 218 | + void stopRxMtDdTimer(); | ||
| 219 | + | ||
| 220 | + /** | ||
| 221 | + * Stops Ls request retransmission executor task. | ||
| 222 | + */ | ||
| 223 | + void stopRxMtLsrTimer(); | ||
| 192 | } | 224 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -13,17 +13,32 @@ | ... | @@ -13,17 +13,32 @@ |
| 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.ospf.protocol.util; | 16 | +package org.onosproject.ospf.controller; |
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | * Representation of different OSPF packet types. | 19 | * Representation of different OSPF packet types. |
| 20 | */ | 20 | */ |
| 21 | public enum OspfPacketType { | 21 | public enum OspfPacketType { |
| 22 | 22 | ||
| 23 | + /** | ||
| 24 | + * OSPF hello packet. | ||
| 25 | + */ | ||
| 23 | HELLO(1), | 26 | HELLO(1), |
| 27 | + /** | ||
| 28 | + * OSPF device description packet. | ||
| 29 | + */ | ||
| 24 | DD(2), | 30 | DD(2), |
| 31 | + /** | ||
| 32 | + * OSPF link state request packet. | ||
| 33 | + */ | ||
| 25 | LSREQUEST(3), | 34 | LSREQUEST(3), |
| 35 | + /** | ||
| 36 | + * OSPF link state update packet. | ||
| 37 | + */ | ||
| 26 | LSUPDATE(4), | 38 | LSUPDATE(4), |
| 39 | + /** | ||
| 40 | + * OSPF link state acknowledge packet. | ||
| 41 | + */ | ||
| 27 | LSAACK(5); | 42 | LSAACK(5); |
| 28 | 43 | ||
| 29 | private int value; | 44 | private int value; |
| ... | @@ -31,7 +46,7 @@ public enum OspfPacketType { | ... | @@ -31,7 +46,7 @@ public enum OspfPacketType { |
| 31 | /** | 46 | /** |
| 32 | * Creates instance of OSPF packet types. | 47 | * Creates instance of OSPF packet types. |
| 33 | * | 48 | * |
| 34 | - * @param value | 49 | + * @param value OSPF packet types |
| 35 | */ | 50 | */ |
| 36 | OspfPacketType(int value) { | 51 | OspfPacketType(int value) { |
| 37 | this.value = value; | 52 | this.value = value; | ... | ... |
| ... | @@ -29,7 +29,7 @@ import static com.google.common.base.Preconditions.checkArgument; | ... | @@ -29,7 +29,7 @@ import static com.google.common.base.Preconditions.checkArgument; |
| 29 | */ | 29 | */ |
| 30 | public class OspfRouterId { | 30 | public class OspfRouterId { |
| 31 | 31 | ||
| 32 | - private static final String SCHEME = "ospf"; | 32 | + private static final String SCHEME = "l3"; |
| 33 | private static final long UNKNOWN = 0; | 33 | private static final long UNKNOWN = 0; |
| 34 | private final IpAddress ipAddress; | 34 | private final IpAddress ipAddress; |
| 35 | 35 | ... | ... |
| ... | @@ -50,7 +50,7 @@ public interface TopologyForDeviceAndLink { | ... | @@ -50,7 +50,7 @@ public interface TopologyForDeviceAndLink { |
| 50 | /** | 50 | /** |
| 51 | * Sets link information. | 51 | * Sets link information. |
| 52 | * | 52 | * |
| 53 | - * @param key key used to store in map | 53 | + * @param key key used to store in map |
| 54 | * @param linkInformationMap link information instance | 54 | * @param linkInformationMap link information instance |
| 55 | */ | 55 | */ |
| 56 | void setLinkInformationMap(String key, LinkInformation linkInformationMap); | 56 | void setLinkInformationMap(String key, LinkInformation linkInformationMap); |
| ... | @@ -79,7 +79,7 @@ public interface TopologyForDeviceAndLink { | ... | @@ -79,7 +79,7 @@ public interface TopologyForDeviceAndLink { |
| 79 | void removeDeviceInformationMap(String key); | 79 | void removeDeviceInformationMap(String key); |
| 80 | 80 | ||
| 81 | /** | 81 | /** |
| 82 | - * Removes links from linkInformationMap. | 82 | + * Removes links from link information map. |
| 83 | * | 83 | * |
| 84 | * @param routerId router's IP address | 84 | * @param routerId router's IP address |
| 85 | */ | 85 | */ |
| ... | @@ -109,4 +109,56 @@ public interface TopologyForDeviceAndLink { | ... | @@ -109,4 +109,56 @@ public interface TopologyForDeviceAndLink { |
| 109 | * @param ospfArea area instance | 109 | * @param ospfArea area instance |
| 110 | */ | 110 | */ |
| 111 | void updateLinkInformation(OspfLsa ospfLsa, OspfArea ospfArea); | 111 | void updateLinkInformation(OspfLsa ospfLsa, OspfArea ospfArea); |
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * Gets device information as map. | ||
| 115 | + * | ||
| 116 | + * @return deviceInformationMap to delete from core | ||
| 117 | + */ | ||
| 118 | + Map<String, DeviceInformation> deviceInformationMapToDelete(); | ||
| 119 | + | ||
| 120 | + /** | ||
| 121 | + * Sets device information as map. | ||
| 122 | + * | ||
| 123 | + * @param key key to store in device info map | ||
| 124 | + * @param deviceInformationMapToDelete device information instance | ||
| 125 | + */ | ||
| 126 | + void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete); | ||
| 127 | + | ||
| 128 | + /** | ||
| 129 | + * Removes device information from deviceInformationMapToDelete. | ||
| 130 | + * | ||
| 131 | + * @param key key to remove device information | ||
| 132 | + */ | ||
| 133 | + void removeDeviceInformationMapFromDeleteMap(String key); | ||
| 134 | + | ||
| 135 | + /** | ||
| 136 | + * Gets device information as map for Point-To-Point. | ||
| 137 | + * | ||
| 138 | + * @return deviceInformationMap | ||
| 139 | + */ | ||
| 140 | + Map<String, DeviceInformation> deviceInformationMapForPointToPoint(); | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * Sets device information as map for Point-To-Point. | ||
| 144 | + * | ||
| 145 | + * @param key key to store in device info | ||
| 146 | + * @param deviceInformationMap device information instance | ||
| 147 | + */ | ||
| 148 | + void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap); | ||
| 149 | + | ||
| 150 | + /** | ||
| 151 | + * Gets link information as map for Point-To-Point. | ||
| 152 | + * | ||
| 153 | + * @return linkInformationMap | ||
| 154 | + */ | ||
| 155 | + Map<String, LinkInformation> linkInformationMapForPointToPoint(); | ||
| 156 | + | ||
| 157 | + /** | ||
| 158 | + * Sets link information as map for Point-To-Point. | ||
| 159 | + * | ||
| 160 | + * @param key key to store link info | ||
| 161 | + * @param linkInformationMap link information instance | ||
| 162 | + */ | ||
| 163 | + void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap); | ||
| 112 | } | 164 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -21,7 +21,6 @@ import com.google.common.base.Objects; | ... | @@ -21,7 +21,6 @@ import com.google.common.base.Objects; |
| 21 | import org.onlab.packet.Ip4Address; | 21 | import org.onlab.packet.Ip4Address; |
| 22 | import org.onosproject.ospf.controller.LsaWrapper; | 22 | import org.onosproject.ospf.controller.LsaWrapper; |
| 23 | import org.onosproject.ospf.controller.OspfArea; | 23 | import org.onosproject.ospf.controller.OspfArea; |
| 24 | -import org.onosproject.ospf.controller.OspfAreaAddressRange; | ||
| 25 | import org.onosproject.ospf.controller.OspfInterface; | 24 | import org.onosproject.ospf.controller.OspfInterface; |
| 26 | import org.onosproject.ospf.controller.OspfLsa; | 25 | import org.onosproject.ospf.controller.OspfLsa; |
| 27 | import org.onosproject.ospf.controller.OspfLsaType; | 26 | import org.onosproject.ospf.controller.OspfLsaType; |
| ... | @@ -54,28 +53,14 @@ import java.util.Map; | ... | @@ -54,28 +53,14 @@ import java.util.Map; |
| 54 | public class OspfAreaImpl implements OspfArea { | 53 | public class OspfAreaImpl implements OspfArea { |
| 55 | private static final Logger log = LoggerFactory.getLogger(OspfAreaImpl.class); | 54 | private static final Logger log = LoggerFactory.getLogger(OspfAreaImpl.class); |
| 56 | /** | 55 | /** |
| 57 | - * Address ranges in order to aggregate routing information at area. | ||
| 58 | - * boundaries. Each address range is specified by an [address,mask] pair and | ||
| 59 | - * a status indication of either Advertise or DoNotAdvertise | ||
| 60 | - */ | ||
| 61 | - private List<OspfAreaAddressRange> addressRanges; | ||
| 62 | - /** | ||
| 63 | - * This parameter indicates whether the area can carry data traffic that. | ||
| 64 | - * neither originates nor terminates in the area itself. | ||
| 65 | - */ | ||
| 66 | - private boolean transitCapability; | ||
| 67 | - /** | ||
| 68 | * Whether AS-external-LSAs will be flooded into/throughout the area. | 56 | * Whether AS-external-LSAs will be flooded into/throughout the area. |
| 69 | */ | 57 | */ |
| 70 | private boolean externalRoutingCapability; | 58 | private boolean externalRoutingCapability; |
| 71 | - /** | 59 | + |
| 72 | - * Indicates the cost of the default summary-LSA. | ||
| 73 | - */ | ||
| 74 | - private int stubCost; | ||
| 75 | /** | 60 | /** |
| 76 | * Represents a list of all router's interfaces associated with this area. | 61 | * Represents a list of all router's interfaces associated with this area. |
| 77 | */ | 62 | */ |
| 78 | - private List<OspfInterface> interfacesLst; | 63 | + private List<OspfInterface> ospfInterfaceList; |
| 79 | /** | 64 | /** |
| 80 | * The LS Database for this area. It includes router-LSAs, network-LSAs and. | 65 | * The LS Database for this area. It includes router-LSAs, network-LSAs and. |
| 81 | * summary-LSAs. AS-external-LSAs are hold in the OSPF class itself. | 66 | * summary-LSAs. AS-external-LSAs are hold in the OSPF class itself. |
| ... | @@ -116,18 +101,15 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -116,18 +101,15 @@ public class OspfAreaImpl implements OspfArea { |
| 116 | OspfAreaImpl that = (OspfAreaImpl) o; | 101 | OspfAreaImpl that = (OspfAreaImpl) o; |
| 117 | return Objects.equal(areaId, that.areaId) && | 102 | return Objects.equal(areaId, that.areaId) && |
| 118 | Objects.equal(routerId, that.routerId) && | 103 | Objects.equal(routerId, that.routerId) && |
| 119 | - Objects.equal(addressRanges.size(), that.addressRanges.size()) && | ||
| 120 | - Objects.equal(transitCapability, that.transitCapability) && | ||
| 121 | Objects.equal(externalRoutingCapability, that.externalRoutingCapability) && | 104 | Objects.equal(externalRoutingCapability, that.externalRoutingCapability) && |
| 122 | - Objects.equal(stubCost, that.stubCost) && | 105 | + Objects.equal(ospfInterfaceList.size(), that.ospfInterfaceList.size()) && |
| 123 | - Objects.equal(interfacesLst.size(), that.interfacesLst.size()) && | ||
| 124 | Objects.equal(database, that.database); | 106 | Objects.equal(database, that.database); |
| 125 | } | 107 | } |
| 126 | 108 | ||
| 127 | @Override | 109 | @Override |
| 128 | public int hashCode() { | 110 | public int hashCode() { |
| 129 | - return Objects.hashCode(areaId, routerId, addressRanges, transitCapability, externalRoutingCapability, | 111 | + return Objects.hashCode(areaId, routerId, externalRoutingCapability, |
| 130 | - stubCost, interfacesLst, database); | 112 | + ospfInterfaceList, database); |
| 131 | } | 113 | } |
| 132 | 114 | ||
| 133 | /** | 115 | /** |
| ... | @@ -234,7 +216,7 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -234,7 +216,7 @@ public class OspfAreaImpl implements OspfArea { |
| 234 | networkLsa.setNetworkMask(mask); | 216 | networkLsa.setNetworkMask(mask); |
| 235 | //Adding our own router. | 217 | //Adding our own router. |
| 236 | networkLsa.addAttachedRouter(routerId()); | 218 | networkLsa.addAttachedRouter(routerId()); |
| 237 | - Iterator iter = interfacesLst.iterator(); | 219 | + Iterator iter = ospfInterfaceList.iterator(); |
| 238 | OspfInterfaceImpl ospfInterface = null; | 220 | OspfInterfaceImpl ospfInterface = null; |
| 239 | while (iter.hasNext()) { | 221 | while (iter.hasNext()) { |
| 240 | ospfInterface = (OspfInterfaceImpl) iter.next(); | 222 | ospfInterface = (OspfInterfaceImpl) iter.next(); |
| ... | @@ -310,7 +292,7 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -310,7 +292,7 @@ public class OspfAreaImpl implements OspfArea { |
| 310 | */ | 292 | */ |
| 311 | private void buildLinkForRouterLsa(RouterLsa routerLsa, OspfInterface ospfInterface) { | 293 | private void buildLinkForRouterLsa(RouterLsa routerLsa, OspfInterface ospfInterface) { |
| 312 | OspfInterfaceImpl nextInterface; | 294 | OspfInterfaceImpl nextInterface; |
| 313 | - Iterator interfaces = interfacesLst.iterator(); | 295 | + Iterator interfaces = ospfInterfaceList.iterator(); |
| 314 | while (interfaces.hasNext()) { | 296 | while (interfaces.hasNext()) { |
| 315 | nextInterface = (OspfInterfaceImpl) interfaces.next(); | 297 | nextInterface = (OspfInterfaceImpl) interfaces.next(); |
| 316 | if (nextInterface.state() == OspfInterfaceState.DOWN) { | 298 | if (nextInterface.state() == OspfInterfaceState.DOWN) { |
| ... | @@ -418,44 +400,6 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -418,44 +400,6 @@ public class OspfAreaImpl implements OspfArea { |
| 418 | } | 400 | } |
| 419 | 401 | ||
| 420 | /** | 402 | /** |
| 421 | - * Gets address range. | ||
| 422 | - * | ||
| 423 | - * @return list of area address ranges | ||
| 424 | - */ | ||
| 425 | - public List<OspfAreaAddressRange> addressRanges() { | ||
| 426 | - return addressRanges; | ||
| 427 | - } | ||
| 428 | - | ||
| 429 | - /** | ||
| 430 | - * Sets the area address ranges. | ||
| 431 | - * | ||
| 432 | - * @param addressRanges list of area address range | ||
| 433 | - */ | ||
| 434 | - @JsonProperty("addressRange") | ||
| 435 | - public void setAddressRanges(List<OspfAreaAddressRange> addressRanges) { | ||
| 436 | - this.addressRanges = addressRanges; | ||
| 437 | - } | ||
| 438 | - | ||
| 439 | - /** | ||
| 440 | - * Gets is transit capable or not. | ||
| 441 | - * | ||
| 442 | - * @return true if transit capable, else false | ||
| 443 | - */ | ||
| 444 | - public boolean isTransitCapability() { | ||
| 445 | - return transitCapability; | ||
| 446 | - } | ||
| 447 | - | ||
| 448 | - /** | ||
| 449 | - * Sets transit capability. | ||
| 450 | - * | ||
| 451 | - * @param transitCapability true if transit capable, else false | ||
| 452 | - */ | ||
| 453 | - @JsonProperty("transitCapability") | ||
| 454 | - public void setTransitCapability(boolean transitCapability) { | ||
| 455 | - this.transitCapability = transitCapability; | ||
| 456 | - } | ||
| 457 | - | ||
| 458 | - /** | ||
| 459 | * Gets external routing capability. | 403 | * Gets external routing capability. |
| 460 | * | 404 | * |
| 461 | * @return true if external routing capable, else false | 405 | * @return true if external routing capable, else false |
| ... | @@ -475,41 +419,22 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -475,41 +419,22 @@ public class OspfAreaImpl implements OspfArea { |
| 475 | } | 419 | } |
| 476 | 420 | ||
| 477 | /** | 421 | /** |
| 478 | - * Gets the stub cost. | ||
| 479 | - * | ||
| 480 | - * @return stub cost | ||
| 481 | - */ | ||
| 482 | - public int stubCost() { | ||
| 483 | - return stubCost; | ||
| 484 | - } | ||
| 485 | - | ||
| 486 | - /** | ||
| 487 | - * Sets the stub cost. | ||
| 488 | - * | ||
| 489 | - * @param stubCost stub cost | ||
| 490 | - */ | ||
| 491 | - @JsonProperty("stubCost") | ||
| 492 | - public void setStubCost(int stubCost) { | ||
| 493 | - this.stubCost = stubCost; | ||
| 494 | - } | ||
| 495 | - | ||
| 496 | - /** | ||
| 497 | * Gets the list of interfaces in this area. | 422 | * Gets the list of interfaces in this area. |
| 498 | * | 423 | * |
| 499 | * @return list of interfaces | 424 | * @return list of interfaces |
| 500 | */ | 425 | */ |
| 501 | - public List<OspfInterface> getInterfacesLst() { | 426 | + public List<OspfInterface> ospfInterfaceList() { |
| 502 | - return interfacesLst; | 427 | + return ospfInterfaceList; |
| 503 | } | 428 | } |
| 504 | 429 | ||
| 505 | /** | 430 | /** |
| 506 | * Sets the list of interfaces attached to the area. | 431 | * Sets the list of interfaces attached to the area. |
| 507 | * | 432 | * |
| 508 | - * @param interfacesLst list of OspfInterface instances | 433 | + * @param ospfInterfaceList list of OspfInterface instances |
| 509 | */ | 434 | */ |
| 510 | @JsonProperty("interface") | 435 | @JsonProperty("interface") |
| 511 | - public void setInterfacesLst(List<OspfInterface> interfacesLst) { | 436 | + public void setOspfInterfaceList(List<OspfInterface> ospfInterfaceList) { |
| 512 | - this.interfacesLst = interfacesLst; | 437 | + this.ospfInterfaceList = ospfInterfaceList; |
| 513 | } | 438 | } |
| 514 | 439 | ||
| 515 | /** | 440 | /** |
| ... | @@ -522,7 +447,7 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -522,7 +447,7 @@ public class OspfAreaImpl implements OspfArea { |
| 522 | public boolean noNeighborInLsaExchangeProcess() { | 447 | public boolean noNeighborInLsaExchangeProcess() { |
| 523 | OspfInterfaceImpl nextInterface; | 448 | OspfInterfaceImpl nextInterface; |
| 524 | OspfNeighborState nextNeighborState; | 449 | OspfNeighborState nextNeighborState; |
| 525 | - Iterator interfaces = interfacesLst.iterator(); | 450 | + Iterator interfaces = ospfInterfaceList.iterator(); |
| 526 | while (interfaces.hasNext()) { | 451 | while (interfaces.hasNext()) { |
| 527 | nextInterface = (OspfInterfaceImpl) interfaces.next(); | 452 | nextInterface = (OspfInterfaceImpl) interfaces.next(); |
| 528 | Iterator neighbors = nextInterface.listOfNeighbors().values().iterator(); | 453 | Iterator neighbors = nextInterface.listOfNeighbors().values().iterator(); |
| ... | @@ -659,19 +584,14 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -659,19 +584,14 @@ public class OspfAreaImpl implements OspfArea { |
| 659 | return MoreObjects.toStringHelper(getClass()) | 584 | return MoreObjects.toStringHelper(getClass()) |
| 660 | .omitNullValues() | 585 | .omitNullValues() |
| 661 | .add("areaID", areaId) | 586 | .add("areaID", areaId) |
| 662 | - .add("stubCost", stubCost) | 587 | + .add("ospfInterfaceList", ospfInterfaceList) |
| 663 | - .add("addressRanges", addressRanges) | ||
| 664 | - .add("interfacesLst", interfacesLst) | ||
| 665 | - .add("transitCapability", transitCapability) | ||
| 666 | .add("externalRoutingCapability", externalRoutingCapability) | 588 | .add("externalRoutingCapability", externalRoutingCapability) |
| 667 | .toString(); | 589 | .toString(); |
| 668 | } | 590 | } |
| 669 | 591 | ||
| 670 | /** | 592 | /** |
| 671 | * Checks all Neighbors belonging to this Area whether they are in state lesser than the EXCHANGE. | 593 | * Checks all Neighbors belonging to this Area whether they are in state lesser than the EXCHANGE. |
| 672 | - * <p> | ||
| 673 | * Creates list of such neighbors | 594 | * Creates list of such neighbors |
| 674 | - * <p> | ||
| 675 | * Returns list of neighbors who satisfy the conditions | 595 | * Returns list of neighbors who satisfy the conditions |
| 676 | * | 596 | * |
| 677 | * @param ospfInterface OSPF interface instance | 597 | * @param ospfInterface OSPF interface instance |
| ... | @@ -716,7 +636,7 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -716,7 +636,7 @@ public class OspfAreaImpl implements OspfArea { |
| 716 | public void addToOtherNeighborLsaTxList(LsaHeader recLsa) { | 636 | public void addToOtherNeighborLsaTxList(LsaHeader recLsa) { |
| 717 | //Add the received LSA in other neighbors retransmission list. | 637 | //Add the received LSA in other neighbors retransmission list. |
| 718 | log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList"); | 638 | log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList"); |
| 719 | - List<OspfInterface> ospfInterfaces = getInterfacesLst(); | 639 | + List<OspfInterface> ospfInterfaces = ospfInterfaceList(); |
| 720 | for (OspfInterface ospfInterfaceFromArea : ospfInterfaces) { | 640 | for (OspfInterface ospfInterfaceFromArea : ospfInterfaces) { |
| 721 | Map neighbors = ospfInterfaceFromArea.listOfNeighbors(); | 641 | Map neighbors = ospfInterfaceFromArea.listOfNeighbors(); |
| 722 | for (Object neighborIP : neighbors.keySet()) { | 642 | for (Object neighborIP : neighbors.keySet()) { | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfConfigUtil.java
0 → 100644
This diff is collapsed. Click to expand it.
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.ospf.controller.impl; | 17 | package org.onosproject.ospf.controller.impl; |
| 18 | 18 | ||
| 19 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 19 | import com.google.common.collect.Sets; | 20 | import com.google.common.collect.Sets; |
| 20 | import org.apache.felix.scr.annotations.Activate; | 21 | import org.apache.felix.scr.annotations.Activate; |
| 21 | import org.apache.felix.scr.annotations.Component; | 22 | import org.apache.felix.scr.annotations.Component; |
| ... | @@ -34,7 +35,6 @@ import org.onosproject.ospf.controller.OspfRouterListener; | ... | @@ -34,7 +35,6 @@ import org.onosproject.ospf.controller.OspfRouterListener; |
| 34 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
| 35 | import org.slf4j.LoggerFactory; | 36 | import org.slf4j.LoggerFactory; |
| 36 | 37 | ||
| 37 | -import java.util.ArrayList; | ||
| 38 | import java.util.HashSet; | 38 | import java.util.HashSet; |
| 39 | import java.util.List; | 39 | import java.util.List; |
| 40 | import java.util.Set; | 40 | import java.util.Set; |
| ... | @@ -111,27 +111,23 @@ public class OspfControllerImpl implements OspfController { | ... | @@ -111,27 +111,23 @@ public class OspfControllerImpl implements OspfController { |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | @Override | 113 | @Override |
| 114 | - public void updateConfig(List processes) { | 114 | + public void updateConfig(JsonNode processesNode) { |
| 115 | - List<OspfProcess> ospfProcesses = new ArrayList<>(); | 115 | + try { |
| 116 | - if (processes != null) { | 116 | + List<OspfProcess> ospfProcesses = OspfConfigUtil.processes(processesNode); |
| 117 | - for (Object process : processes) { | 117 | + //if there is interface details then update configuration |
| 118 | - ospfProcesses.add((OspfProcess) process); | 118 | + if (ospfProcesses.size() > 0 && |
| 119 | + ospfProcesses.get(0).areas() != null && ospfProcesses.get(0).areas().size() > 0 && | ||
| 120 | + ospfProcesses.get(0).areas().get(0) != null && | ||
| 121 | + ospfProcesses.get(0).areas().get(0).ospfInterfaceList().size() > 0) { | ||
| 122 | + ctrl.updateConfig(ospfProcesses); | ||
| 119 | } | 123 | } |
| 124 | + } catch (Exception e) { | ||
| 125 | + log.debug("Error::updateConfig::{}", e.getMessage()); | ||
| 120 | } | 126 | } |
| 121 | - log.debug("updateConfig::OspfList::processes::{}", ospfProcesses); | ||
| 122 | - ctrl.updateConfig(ospfProcesses); | ||
| 123 | } | 127 | } |
| 124 | 128 | ||
| 125 | @Override | 129 | @Override |
| 126 | public void deleteConfig(List<OspfProcess> processes, String attribute) { | 130 | public void deleteConfig(List<OspfProcess> processes, String attribute) { |
| 127 | - List<OspfProcess> ospfProcesses = new ArrayList<>(); | ||
| 128 | - if (processes != null) { | ||
| 129 | - for (Object process : processes) { | ||
| 130 | - ospfProcesses.add((OspfProcess) process); | ||
| 131 | - } | ||
| 132 | - } | ||
| 133 | - log.debug("deleteConfig::OspfList::processes::{}", ospfProcesses); | ||
| 134 | - ctrl.deleteConfig(ospfProcesses, attribute); | ||
| 135 | } | 131 | } |
| 136 | 132 | ||
| 137 | /** | 133 | /** |
| ... | @@ -163,9 +159,9 @@ public class OspfControllerImpl implements OspfController { | ... | @@ -163,9 +159,9 @@ public class OspfControllerImpl implements OspfController { |
| 163 | } | 159 | } |
| 164 | 160 | ||
| 165 | @Override | 161 | @Override |
| 166 | - public void deleteLink(OspfRouter ospfRouter) { | 162 | + public void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) { |
| 167 | for (OspfLinkListener l : linkListener()) { | 163 | for (OspfLinkListener l : linkListener()) { |
| 168 | - l.deleteLink(ospfRouter); | 164 | + l.deleteLink(ospfRouter, ospfLinkTed); |
| 169 | } | 165 | } |
| 170 | } | 166 | } |
| 171 | } | 167 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -19,8 +19,10 @@ import org.jboss.netty.buffer.ChannelBuffer; | ... | @@ -19,8 +19,10 @@ import org.jboss.netty.buffer.ChannelBuffer; |
| 19 | import org.jboss.netty.channel.Channel; | 19 | import org.jboss.netty.channel.Channel; |
| 20 | import org.jboss.netty.channel.ChannelHandlerContext; | 20 | import org.jboss.netty.channel.ChannelHandlerContext; |
| 21 | import org.jboss.netty.handler.codec.frame.FrameDecoder; | 21 | import org.jboss.netty.handler.codec.frame.FrameDecoder; |
| 22 | -import org.onosproject.ospf.protocol.ospfpacket.OspfMessage; | 22 | +import org.onlab.packet.Ip4Address; |
| 23 | +import org.onosproject.ospf.controller.OspfMessage; | ||
| 23 | import org.onosproject.ospf.protocol.ospfpacket.OspfMessageReader; | 24 | import org.onosproject.ospf.protocol.ospfpacket.OspfMessageReader; |
| 25 | +import org.onosproject.ospf.protocol.util.OspfUtil; | ||
| 24 | import org.slf4j.Logger; | 26 | import org.slf4j.Logger; |
| 25 | import org.slf4j.LoggerFactory; | 27 | import org.slf4j.LoggerFactory; |
| 26 | 28 | ||
| ... | @@ -35,24 +37,35 @@ public class OspfMessageDecoder extends FrameDecoder { | ... | @@ -35,24 +37,35 @@ public class OspfMessageDecoder extends FrameDecoder { |
| 35 | private static final Logger log = LoggerFactory.getLogger(OspfMessageDecoder.class); | 37 | private static final Logger log = LoggerFactory.getLogger(OspfMessageDecoder.class); |
| 36 | 38 | ||
| 37 | @Override | 39 | @Override |
| 38 | - protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer channelBuffer) throws Exception { | 40 | + protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { |
| 39 | - log.debug("OspfMessageDecoder::Message received <:> length {}", channelBuffer.readableBytes()); | 41 | + log.debug("OspfMessageDecoder::Message received <:> length {}", buffer.readableBytes()); |
| 40 | - log.debug("channelBuffer.readableBytes - decode {}", channelBuffer.readableBytes()); | ||
| 41 | if (!channel.isConnected()) { | 42 | if (!channel.isConnected()) { |
| 42 | log.info("Channel is not connected."); | 43 | log.info("Channel is not connected."); |
| 43 | return null; | 44 | return null; |
| 44 | } | 45 | } |
| 45 | - | ||
| 46 | OspfMessageReader messageReader = new OspfMessageReader(); | 46 | OspfMessageReader messageReader = new OspfMessageReader(); |
| 47 | List<OspfMessage> ospfMessageList = new LinkedList<>(); | 47 | List<OspfMessage> ospfMessageList = new LinkedList<>(); |
| 48 | - | 48 | + while (buffer.readableBytes() >= OspfUtil.MINIMUM_FRAME_LEN) { |
| 49 | - while (channelBuffer.readableBytes() > 0) { | 49 | + ChannelBuffer ospfDataBuffer = buffer.readBytes(OspfUtil.MINIMUM_FRAME_LEN); |
| 50 | - OspfMessage message = messageReader.readFromBuffer(channelBuffer); | 50 | + int readableBytes = ospfDataBuffer.readableBytes(); |
| 51 | + OspfMessage message = messageReader.readFromBuffer(ospfDataBuffer); | ||
| 51 | if (message != null) { | 52 | if (message != null) { |
| 53 | + if (ospfDataBuffer.readableBytes() >= OspfUtil.METADATA_LEN) { | ||
| 54 | + ospfDataBuffer.readerIndex(readableBytes - OspfUtil.METADATA_LEN); | ||
| 55 | + log.debug("IsisMessageDecoder::Reading metadata <:> length {}", ospfDataBuffer.readableBytes()); | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + int interfaceIndex = ospfDataBuffer.readByte(); | ||
| 59 | + byte[] sourceIpBytes = new byte[OspfUtil.FOUR_BYTES]; | ||
| 60 | + ospfDataBuffer.readBytes(sourceIpBytes, 0, OspfUtil.FOUR_BYTES); | ||
| 61 | + Ip4Address sourceIP = Ip4Address.valueOf(sourceIpBytes); | ||
| 62 | + | ||
| 63 | + message.setSourceIp(sourceIP); | ||
| 64 | + message.setInterfaceIndex(interfaceIndex); | ||
| 65 | + } | ||
| 52 | ospfMessageList.add(message); | 66 | ospfMessageList.add(message); |
| 53 | } | 67 | } |
| 54 | } | 68 | } |
| 55 | - | 69 | + return (ospfMessageList.size() > 0) ? ospfMessageList : null; |
| 56 | - return ospfMessageList; | ||
| 57 | } | 70 | } |
| 58 | } | 71 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -17,15 +17,10 @@ | ... | @@ -17,15 +17,10 @@ |
| 17 | package org.onosproject.ospf.controller.impl; | 17 | package org.onosproject.ospf.controller.impl; |
| 18 | 18 | ||
| 19 | import org.jboss.netty.buffer.ChannelBuffer; | 19 | import org.jboss.netty.buffer.ChannelBuffer; |
| 20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
| 20 | import org.jboss.netty.channel.Channel; | 21 | import org.jboss.netty.channel.Channel; |
| 21 | import org.jboss.netty.channel.ChannelHandlerContext; | 22 | import org.jboss.netty.channel.ChannelHandlerContext; |
| 22 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; | 23 | import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; |
| 23 | -import org.onosproject.ospf.controller.OspfInterface; | ||
| 24 | -import org.onosproject.ospf.controller.area.OspfInterfaceImpl; | ||
| 25 | -import org.onosproject.ospf.protocol.ospfpacket.OspfMessage; | ||
| 26 | -import org.onosproject.ospf.protocol.ospfpacket.OspfMessageWriter; | ||
| 27 | -import org.onosproject.ospf.protocol.util.OspfInterfaceState; | ||
| 28 | -import org.onosproject.ospf.protocol.util.OspfUtil; | ||
| 29 | import org.slf4j.Logger; | 24 | import org.slf4j.Logger; |
| 30 | import org.slf4j.LoggerFactory; | 25 | import org.slf4j.LoggerFactory; |
| 31 | 26 | ||
| ... | @@ -35,46 +30,15 @@ import org.slf4j.LoggerFactory; | ... | @@ -35,46 +30,15 @@ import org.slf4j.LoggerFactory; |
| 35 | public class OspfMessageEncoder extends OneToOneEncoder { | 30 | public class OspfMessageEncoder extends OneToOneEncoder { |
| 36 | 31 | ||
| 37 | private static final Logger log = LoggerFactory.getLogger(OspfMessageEncoder.class); | 32 | private static final Logger log = LoggerFactory.getLogger(OspfMessageEncoder.class); |
| 38 | - private OspfInterface ospfInterface; | ||
| 39 | - | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * Creates an instance of OSPF message encoder. | ||
| 43 | - */ | ||
| 44 | - OspfMessageEncoder() { | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - /** | ||
| 48 | - * Creates an instance of OSPF message encoder. | ||
| 49 | - * | ||
| 50 | - * @param ospfInterface OSPF interface instance | ||
| 51 | - */ | ||
| 52 | - OspfMessageEncoder(OspfInterface ospfInterface) { | ||
| 53 | - this.ospfInterface = ospfInterface; | ||
| 54 | - } | ||
| 55 | 33 | ||
| 56 | @Override | 34 | @Override |
| 57 | protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { | 35 | protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { |
| 58 | 36 | ||
| 59 | - log.debug("Encoding ospfMessage...!!!"); | 37 | + byte[] byteMsg = (byte[]) msg; |
| 60 | - if (!(msg instanceof OspfMessage)) { | 38 | + log.debug("Encoding ospfMessage of length {}", byteMsg.length); |
| 61 | - log.debug("Invalid msg."); | 39 | + ChannelBuffer channelBuffer = ChannelBuffers.buffer(byteMsg.length); |
| 62 | - return msg; | 40 | + channelBuffer.writeBytes(byteMsg); |
| 63 | - } | ||
| 64 | - | ||
| 65 | - OspfMessage ospfMessage = (OspfMessage) msg; | ||
| 66 | - OspfMessageWriter messageWriter = new OspfMessageWriter(); | ||
| 67 | - if (((OspfInterfaceImpl) ospfInterface).state().equals(OspfInterfaceState.POINT2POINT)) { | ||
| 68 | - ospfMessage.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS); | ||
| 69 | - } | ||
| 70 | - ChannelBuffer buf = messageWriter.writeToBuffer(ospfMessage, | ||
| 71 | - ((OspfInterfaceImpl) ospfInterface).state().value(), | ||
| 72 | - ospfInterface.interfaceType()); | ||
| 73 | - log.info("OspfMessageEncoder sending packet of lenght {}", buf.readableBytes()); | ||
| 74 | - log.debug("OspfMessageEncoder sending packet of lenght {}", buf.readableBytes()); | ||
| 75 | - log.debug("Sending {} Message to {}, Length :: {}, <=> {}", ospfMessage.ospfMessageType(), | ||
| 76 | - ospfMessage.destinationIp(), buf.readableBytes(), buf.array()); | ||
| 77 | 41 | ||
| 78 | - return buf; | 42 | + return channelBuffer; |
| 79 | } | 43 | } |
| 80 | } | 44 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -18,57 +18,29 @@ package org.onosproject.ospf.controller.impl; | ... | @@ -18,57 +18,29 @@ package org.onosproject.ospf.controller.impl; |
| 18 | import org.jboss.netty.channel.ChannelPipeline; | 18 | import org.jboss.netty.channel.ChannelPipeline; |
| 19 | import org.jboss.netty.channel.ChannelPipelineFactory; | 19 | import org.jboss.netty.channel.ChannelPipelineFactory; |
| 20 | import org.jboss.netty.channel.Channels; | 20 | import org.jboss.netty.channel.Channels; |
| 21 | -import org.jboss.netty.handler.timeout.ReadTimeoutHandler; | ||
| 22 | -import org.jboss.netty.util.ExternalResourceReleasable; | ||
| 23 | -import org.jboss.netty.util.HashedWheelTimer; | ||
| 24 | -import org.jboss.netty.util.Timer; | ||
| 25 | -import org.onosproject.ospf.controller.OspfArea; | ||
| 26 | -import org.onosproject.ospf.controller.OspfInterface; | ||
| 27 | 21 | ||
| 28 | /** | 22 | /** |
| 29 | - * Creates a ChannelPipeline for a server-side OSPF channel. | 23 | + * Creates a ChannelPipeline for a client-side OSPF channel. |
| 30 | */ | 24 | */ |
| 31 | -public class OspfPipelineFactory implements ChannelPipelineFactory, ExternalResourceReleasable { | 25 | +public class OspfPipelineFactory implements ChannelPipelineFactory { |
| 32 | - | 26 | + private OspfInterfaceChannelHandler ospfChannelHandler; |
| 33 | - private static final Timer TIMER = new HashedWheelTimer(); | ||
| 34 | - private Controller controller; | ||
| 35 | - private ReadTimeoutHandler readTimeoutHandler; | ||
| 36 | - private OspfArea ospfArea; | ||
| 37 | - private OspfInterface ospfInterface; | ||
| 38 | - private int holdTime = 120 * 1000; | ||
| 39 | 27 | ||
| 40 | /** | 28 | /** |
| 41 | - * Creates an instance of OSPF pipeline factory. | 29 | + * Creates an instance of OSPF channel pipeline factory. |
| 42 | * | 30 | * |
| 43 | - * @param controller controller instance. | 31 | + * @param ospfChannelHandler OSPF channel handler instance |
| 44 | - * @param ospfArea OSPF area instance. | ||
| 45 | - * @param ospfInterface OSPF interface instance. | ||
| 46 | */ | 32 | */ |
| 47 | - public OspfPipelineFactory(Controller controller, OspfArea ospfArea, OspfInterface ospfInterface) { | 33 | + public OspfPipelineFactory(OspfInterfaceChannelHandler ospfChannelHandler) { |
| 48 | - super(); | 34 | + this.ospfChannelHandler = ospfChannelHandler; |
| 49 | - this.controller = controller; | ||
| 50 | - this.ospfArea = ospfArea; | ||
| 51 | - this.ospfInterface = ospfInterface; | ||
| 52 | - readTimeoutHandler = new ReadTimeoutHandler(TIMER, holdTime); | ||
| 53 | } | 35 | } |
| 54 | 36 | ||
| 55 | @Override | 37 | @Override |
| 56 | public ChannelPipeline getPipeline() throws Exception { | 38 | public ChannelPipeline getPipeline() throws Exception { |
| 57 | - OspfInterfaceChannelHandler interfaceHandler = new OspfInterfaceChannelHandler( | ||
| 58 | - controller, ospfArea, ospfInterface); | ||
| 59 | - | ||
| 60 | ChannelPipeline pipeline = Channels.pipeline(); | 39 | ChannelPipeline pipeline = Channels.pipeline(); |
| 61 | - pipeline.addLast("encoder", new OspfMessageEncoder(ospfInterface)); | 40 | + pipeline.addLast("encoder", new OspfMessageDecoder()); |
| 62 | - pipeline.addLast("decoder", new OspfMessageDecoder()); | 41 | + pipeline.addLast("decoder", new OspfMessageEncoder()); |
| 63 | - pipeline.addLast("holdTime", readTimeoutHandler); | 42 | + pipeline.addLast("handler", ospfChannelHandler); |
| 64 | - pipeline.addLast("interfacehandler", interfaceHandler); | ||
| 65 | 43 | ||
| 66 | return pipeline; | 44 | return pipeline; |
| 67 | } | 45 | } |
| 68 | - | ||
| 69 | - @Override | ||
| 70 | - public void releaseExternalResources() { | ||
| 71 | - TIMER.stop(); | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | } | 46 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -49,6 +49,15 @@ public class LsaWrapperImpl implements LsaWrapper { | ... | @@ -49,6 +49,15 @@ public class LsaWrapperImpl implements LsaWrapper { |
| 49 | private int binNumber = -1; | 49 | private int binNumber = -1; |
| 50 | private OspfInterface ospfInterface; | 50 | private OspfInterface ospfInterface; |
| 51 | private LsdbAge lsdbAge; | 51 | private LsdbAge lsdbAge; |
| 52 | + private int ageCounterRollOverWhenAdded; | ||
| 53 | + | ||
| 54 | + public int getAgeCounterRollOverWhenAdded() { | ||
| 55 | + return ageCounterRollOverWhenAdded; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void setAgeCounterRollOverWhenAdded(int ageCounterRollOverWhenAdded) { | ||
| 59 | + this.ageCounterRollOverWhenAdded = ageCounterRollOverWhenAdded; | ||
| 60 | + } | ||
| 52 | 61 | ||
| 53 | /** | 62 | /** |
| 54 | * Gets the LSA type. | 63 | * Gets the LSA type. |
| ... | @@ -318,6 +327,8 @@ public class LsaWrapperImpl implements LsaWrapper { | ... | @@ -318,6 +327,8 @@ public class LsaWrapperImpl implements LsaWrapper { |
| 318 | 327 | ||
| 319 | if (currentAge >= OspfParameters.MAXAGE) { | 328 | if (currentAge >= OspfParameters.MAXAGE) { |
| 320 | return OspfParameters.MAXAGE; | 329 | return OspfParameters.MAXAGE; |
| 330 | + } else if ((currentAge == lsaAgeReceived) && ageCounterRollOverWhenAdded != lsdbAge.getAgeCounterRollOver()) { | ||
| 331 | + return OspfParameters.MAXAGE; | ||
| 321 | } | 332 | } |
| 322 | 333 | ||
| 323 | return currentAge; | 334 | return currentAge; | ... | ... |
| ... | @@ -41,7 +41,7 @@ public class LsdbAgeImpl implements LsdbAge { | ... | @@ -41,7 +41,7 @@ public class LsdbAgeImpl implements LsdbAge { |
| 41 | 41 | ||
| 42 | private static final Logger log = | 42 | private static final Logger log = |
| 43 | LoggerFactory.getLogger(LsdbAgeImpl.class); | 43 | LoggerFactory.getLogger(LsdbAgeImpl.class); |
| 44 | - protected int ageCounter = 0; | 44 | + protected static int ageCounter = 0; |
| 45 | private InternalAgeTimer dbAgeTimer; | 45 | private InternalAgeTimer dbAgeTimer; |
| 46 | private ScheduledExecutorService exServiceage; | 46 | private ScheduledExecutorService exServiceage; |
| 47 | // creating age bins of MAXAGE | 47 | // creating age bins of MAXAGE | ... | ... |
| ... | @@ -267,6 +267,7 @@ public class OspfLsdbImpl implements OspfLsdb { | ... | @@ -267,6 +267,7 @@ public class OspfLsdbImpl implements OspfLsdb { |
| 267 | lsaWrapper.setLsaHeader(newLsa); | 267 | lsaWrapper.setLsaHeader(newLsa); |
| 268 | lsaWrapper.setLsaAgeReceived(newLsa.age()); | 268 | lsaWrapper.setLsaAgeReceived(newLsa.age()); |
| 269 | lsaWrapper.setAgeCounterWhenReceived(lsdbAge.getAgeCounter()); | 269 | lsaWrapper.setAgeCounterWhenReceived(lsdbAge.getAgeCounter()); |
| 270 | + lsaWrapper.setAgeCounterRollOverWhenAdded(lsdbAge.getAgeCounterRollOver()); | ||
| 270 | lsaWrapper.setIsSelfOriginated(isSelfOriginated); | 271 | lsaWrapper.setIsSelfOriginated(isSelfOriginated); |
| 271 | lsaWrapper.setIsSelfOriginated(isSelfOriginated); | 272 | lsaWrapper.setIsSelfOriginated(isSelfOriginated); |
| 272 | lsaWrapper.setOspfInterface(ospfInterface); | 273 | lsaWrapper.setOspfInterface(ospfInterface); | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
| ... | @@ -71,7 +71,7 @@ public class ControllerTest { | ... | @@ -71,7 +71,7 @@ public class ControllerTest { |
| 71 | ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1")); | 71 | ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1")); |
| 72 | ospfInterfaces.add(ospfInterface); | 72 | ospfInterfaces.add(ospfInterface); |
| 73 | ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2")); | 73 | ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2")); |
| 74 | - ospfArea.setInterfacesLst(ospfInterfaces); | 74 | + ospfArea.setOspfInterfaceList(ospfInterfaces); |
| 75 | ospfProcess.setProcessId("10.10.10.10"); | 75 | ospfProcess.setProcessId("10.10.10.10"); |
| 76 | ospfAreas = new ArrayList(); | 76 | ospfAreas = new ArrayList(); |
| 77 | ospfAreas.add(ospfArea); | 77 | ospfAreas.add(ospfArea); |
| ... | @@ -82,7 +82,7 @@ public class ControllerTest { | ... | @@ -82,7 +82,7 @@ public class ControllerTest { |
| 82 | ospfProcess1.setProcessId("11.11.11.11"); | 82 | ospfProcess1.setProcessId("11.11.11.11"); |
| 83 | ospfArea1 = new OspfAreaImpl(); | 83 | ospfArea1 = new OspfAreaImpl(); |
| 84 | ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2")); | 84 | ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2")); |
| 85 | - ospfArea1.setInterfacesLst(ospfInterfaces); | 85 | + ospfArea1.setOspfInterfaceList(ospfInterfaces); |
| 86 | ospfAreas.add(ospfArea1); | 86 | ospfAreas.add(ospfArea1); |
| 87 | ospfProcess1.setAreas(ospfAreas); | 87 | ospfProcess1.setAreas(ospfAreas); |
| 88 | ospfProcesses.add(ospfProcess1); | 88 | ospfProcesses.add(ospfProcess1); |
| ... | @@ -167,83 +167,6 @@ public class ControllerTest { | ... | @@ -167,83 +167,6 @@ public class ControllerTest { |
| 167 | assertThat(controller, is(notNullValue())); | 167 | assertThat(controller, is(notNullValue())); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | - /** | ||
| 171 | - * Tests deleteInterfaceFromArea() method. | ||
| 172 | - */ | ||
| 173 | - @Test | ||
| 174 | - public void testDeleteInterfaceFromArea() throws Exception { | ||
| 175 | - controller.updateConfig(ospfProcesses); | ||
| 176 | - assertThat(controller.deleteInterfaceFromArea("10.10.10.10", "2.2.2.2", "1.1.1.1"), is(true)); | ||
| 177 | - assertThat(controller.deleteInterfaceFromArea("10.10.10.10", "2.2.2.2", "5.5.5.5"), is(false)); | ||
| 178 | - } | ||
| 179 | - | ||
| 180 | - /** | ||
| 181 | - * Tests checkArea() method. | ||
| 182 | - */ | ||
| 183 | - @Test | ||
| 184 | - public void testCheckArea() throws Exception { | ||
| 185 | - controller.updateConfig(ospfProcesses); | ||
| 186 | - assertThat(controller.checkArea("10.10.10.10", "2.2.2.2"), is(true)); | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - /** | ||
| 190 | - * Tests checkArea() method. | ||
| 191 | - */ | ||
| 192 | - @Test | ||
| 193 | - public void testCheckArea1() throws Exception { | ||
| 194 | - controller.updateConfig(ospfProcesses); | ||
| 195 | - assertThat(controller.checkArea("10.10.10.10", "111.111.111.111"), is(false)); | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - /** | ||
| 199 | - * Tests checkProcess() method. | ||
| 200 | - */ | ||
| 201 | - @Test | ||
| 202 | - public void testCheckProcess() throws Exception { | ||
| 203 | - controller.updateConfig(ospfProcesses); | ||
| 204 | - assertThat(controller.checkProcess("3.3.3.3"), is(false)); | ||
| 205 | - assertThat(controller.checkProcess("1.1.1.1"), is(false)); | ||
| 206 | - } | ||
| 207 | - | ||
| 208 | - /** | ||
| 209 | - * Tests checkInterface() method. | ||
| 210 | - */ | ||
| 211 | - @Test | ||
| 212 | - public void testCheckInterface() throws Exception { | ||
| 213 | - controller.updateConfig(ospfProcesses); | ||
| 214 | - assertThat(controller.checkInterface("10.10.10.10", "2.2.2.2", "1.1.1.1"), is(true)); | ||
| 215 | - } | ||
| 216 | - | ||
| 217 | - /** | ||
| 218 | - * Tests updateAreaInProcess() method. | ||
| 219 | - */ | ||
| 220 | - @Test | ||
| 221 | - public void testUpdateAreaInProcess() throws Exception { | ||
| 222 | - controller.updateConfig(ospfProcesses); | ||
| 223 | - controller.updateAreaInProcess("10.10.10.10", "2.2.2.2", ospfArea); | ||
| 224 | - assertThat(controller, is(notNullValue())); | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | - /** | ||
| 228 | - * Tests updateConfig() method. | ||
| 229 | - */ | ||
| 230 | - @Test | ||
| 231 | - public void testUpdateConfig() throws Exception { | ||
| 232 | - controller.updateConfig(ospfProcesses); | ||
| 233 | - controller.updateConfig(ospfProcesses); | ||
| 234 | - controller.updateConfig(ospfProcesses); | ||
| 235 | - assertThat(controller, is(notNullValue())); | ||
| 236 | - } | ||
| 237 | - | ||
| 238 | - /** | ||
| 239 | - * Tests updateConfig() method. | ||
| 240 | - */ | ||
| 241 | - @Test | ||
| 242 | - public void testUpdateConfig2() throws Exception { | ||
| 243 | - controller.updateConfig(ospfProcesses); | ||
| 244 | - controller.updateConfig(ospfProcesses); | ||
| 245 | - assertThat(controller, is(notNullValue())); | ||
| 246 | - } | ||
| 247 | 170 | ||
| 248 | /** | 171 | /** |
| 249 | * Tests updateConfig() method. | 172 | * Tests updateConfig() method. |
| ... | @@ -257,7 +180,7 @@ public class ControllerTest { | ... | @@ -257,7 +180,7 @@ public class ControllerTest { |
| 257 | ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5")); | 180 | ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5")); |
| 258 | ospfInterfaces.add(ospfInterface); | 181 | ospfInterfaces.add(ospfInterface); |
| 259 | ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2")); | 182 | ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2")); |
| 260 | - ospfArea.setInterfacesLst(ospfInterfaces); | 183 | + ospfArea.setOspfInterfaceList(ospfInterfaces); |
| 261 | ospfProcess.setProcessId("10.10.10.10"); | 184 | ospfProcess.setProcessId("10.10.10.10"); |
| 262 | ospfAreas = new ArrayList(); | 185 | ospfAreas = new ArrayList(); |
| 263 | ospfAreas.add(ospfArea); | 186 | ospfAreas.add(ospfArea); |
| ... | @@ -269,67 +192,6 @@ public class ControllerTest { | ... | @@ -269,67 +192,6 @@ public class ControllerTest { |
| 269 | } | 192 | } |
| 270 | 193 | ||
| 271 | /** | 194 | /** |
| 272 | - * Tests deleteConfig() method. | ||
| 273 | - */ | ||
| 274 | - @Test(expected = Exception.class) | ||
| 275 | - public void testDeleteConfig() throws Exception { | ||
| 276 | - controller.updateConfig(ospfProcesses); | ||
| 277 | - controller.deleteConfig(ospfProcesses, "INTERFACE"); | ||
| 278 | - assertThat(controller, is(notNullValue())); | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - /** | ||
| 282 | - * Tests deleteConfig() method. | ||
| 283 | - */ | ||
| 284 | - @Test(expected = Exception.class) | ||
| 285 | - public void testDeleteConfig1() throws Exception { | ||
| 286 | - controller.updateConfig(ospfProcesses); | ||
| 287 | - controller.deleteConfig(ospfProcesses, "AREA"); | ||
| 288 | - assertThat(controller, is(notNullValue())); | ||
| 289 | - } | ||
| 290 | - | ||
| 291 | - /** | ||
| 292 | - * Tests deleteConfig() method. | ||
| 293 | - */ | ||
| 294 | - | ||
| 295 | - @Test | ||
| 296 | - public void testDeleteConfig2() throws Exception { | ||
| 297 | - controller.updateConfig(ospfProcesses); | ||
| 298 | - controller.deleteConfig(ospfProcesses, "PROCESS"); | ||
| 299 | - assertThat(controller, is(notNullValue())); | ||
| 300 | - } | ||
| 301 | - | ||
| 302 | - /** | ||
| 303 | - * Tests deleteConfig() method. | ||
| 304 | - */ | ||
| 305 | - @Test | ||
| 306 | - public void testDeleteConfig3() throws Exception { | ||
| 307 | - ospfProcesses = new ArrayList(); | ||
| 308 | - controller.deleteConfig(ospfProcesses, "PROCESS"); | ||
| 309 | - assertThat(controller, is(notNullValue())); | ||
| 310 | - } | ||
| 311 | - | ||
| 312 | - /** | ||
| 313 | - * Tests deleteConfig() method. | ||
| 314 | - */ | ||
| 315 | - @Test | ||
| 316 | - public void testDeleteConfig4() throws Exception { | ||
| 317 | - controller.updateConfig(ospfProcesses); | ||
| 318 | - controller.deleteConfig(ospfProcesses, "PROCESS"); | ||
| 319 | - controller.updateConfig(ospfProcesses); | ||
| 320 | - assertThat(controller, is(notNullValue())); | ||
| 321 | - } | ||
| 322 | - | ||
| 323 | - /** | ||
| 324 | - * Tests deleteProcessWhenExists() method. | ||
| 325 | - */ | ||
| 326 | - @Test | ||
| 327 | - public void testDeleteProcessWhenExists() throws Exception { | ||
| 328 | - controller.updateConfig(ospfProcesses); | ||
| 329 | - controller.deleteProcessWhenExists(ospfProcesses, "PROCESS"); | ||
| 330 | - } | ||
| 331 | - | ||
| 332 | - /** | ||
| 333 | * Tests addLinkDetails() method. | 195 | * Tests addLinkDetails() method. |
| 334 | */ | 196 | */ |
| 335 | @Test | 197 | @Test |
| ... | @@ -350,7 +212,7 @@ public class ControllerTest { | ... | @@ -350,7 +212,7 @@ public class ControllerTest { |
| 350 | controller.start(ospfAgent, driverService); | 212 | controller.start(ospfAgent, driverService); |
| 351 | ospfRouter = new OspfRouterImpl(); | 213 | ospfRouter = new OspfRouterImpl(); |
| 352 | controller.addLinkDetails(ospfRouter, new OspfLinkTedImpl()); | 214 | controller.addLinkDetails(ospfRouter, new OspfLinkTedImpl()); |
| 353 | - controller.removeLinkDetails(ospfRouter); | 215 | + controller.removeLinkDetails(ospfRouter, new OspfLinkTedImpl()); |
| 354 | assertThat(controller, is(notNullValue())); | 216 | assertThat(controller, is(notNullValue())); |
| 355 | } | 217 | } |
| 356 | } | 218 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfConfigUtilTest.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 | +package org.onosproject.ospf.controller.impl; | ||
| 17 | + | ||
| 18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 19 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 20 | +import org.junit.After; | ||
| 21 | +import org.junit.Before; | ||
| 22 | +import org.junit.Test; | ||
| 23 | +import org.onosproject.ospf.controller.OspfProcess; | ||
| 24 | + | ||
| 25 | +import java.util.ArrayList; | ||
| 26 | +import java.util.List; | ||
| 27 | + | ||
| 28 | +import static org.hamcrest.CoreMatchers.is; | ||
| 29 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
| 30 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * Unit test class for OspfJsonParsingUtilTest. | ||
| 34 | + */ | ||
| 35 | +public class OspfConfigUtilTest { | ||
| 36 | + private ObjectMapper mapper; | ||
| 37 | + private JsonNode jsonNode; | ||
| 38 | + private List<OspfProcess> ospfProcessList = new ArrayList<>(); | ||
| 39 | + private String jsonString = "{\n" + | ||
| 40 | + "\t\"processes\": {\n" + | ||
| 41 | + "\t\t\"areas\": [{\n" + | ||
| 42 | + "\t\t\t\"interface\": [{\n" + | ||
| 43 | + "\t\t\t\t\"interfaceIndex\": \"2\",\n" + | ||
| 44 | + "\n" + | ||
| 45 | + "\t\t\t\t\"helloIntervalTime\": \"10\",\n" + | ||
| 46 | + "\n" + | ||
| 47 | + "\t\t\t\t\"routerDeadIntervalTime\": \"40\",\n" + | ||
| 48 | + "\n" + | ||
| 49 | + "\t\t\t\t\"interfaceType\": \"2\",\n" + | ||
| 50 | + "\n" + | ||
| 51 | + "\t\t\t\t\"reTransmitInterval\": \"5\"\n" + | ||
| 52 | + "\t\t\t}],\n" + | ||
| 53 | + "\t\t\t\"areaId\": \"5.5.5.5\",\n" + | ||
| 54 | + "\n" + | ||
| 55 | + "\t\t\t\"routerId\": \"7.7.7.7\",\n" + | ||
| 56 | + "\n" + | ||
| 57 | + "\t\t\t\"isOpaqueEnable\": \"false\",\n" + | ||
| 58 | + "\n" + | ||
| 59 | + "\t\t\t\"externalRoutingCapability\": \"true\"\n" + | ||
| 60 | + "\t\t}]\n" + | ||
| 61 | + "\t}\n" + | ||
| 62 | + "}"; | ||
| 63 | + | ||
| 64 | + @Before | ||
| 65 | + public void setUp() throws Exception { | ||
| 66 | + mapper = new ObjectMapper(); | ||
| 67 | + jsonNode = mapper.readTree(jsonString); | ||
| 68 | + mapper = new ObjectMapper(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @After | ||
| 72 | + public void tearDown() throws Exception { | ||
| 73 | + | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Test | ||
| 77 | + public void testProcesses() throws Exception { | ||
| 78 | + jsonNode.path("areas"); | ||
| 79 | + ospfProcessList = OspfConfigUtil.processes(jsonNode); | ||
| 80 | + assertThat(ospfProcessList, is(notNullValue())); | ||
| 81 | + } | ||
| 82 | +} |
| ... | @@ -46,10 +46,8 @@ public class OspfControllerImplTest { | ... | @@ -46,10 +46,8 @@ public class OspfControllerImplTest { |
| 46 | private OspfControllerImpl ospfController; | 46 | private OspfControllerImpl ospfController; |
| 47 | private OspfRouterListener ospfRouterListener; | 47 | private OspfRouterListener ospfRouterListener; |
| 48 | private OspfLinkListener ospfLinkListener; | 48 | private OspfLinkListener ospfLinkListener; |
| 49 | - private Controller controller; | ||
| 50 | private List<OspfProcess> ospfProcesses; | 49 | private List<OspfProcess> ospfProcesses; |
| 51 | private OspfProcess process1; | 50 | private OspfProcess process1; |
| 52 | - private OspfProcess process2; | ||
| 53 | private List<OspfArea> areas; | 51 | private List<OspfArea> areas; |
| 54 | private OspfAreaImpl ospfArea; | 52 | private OspfAreaImpl ospfArea; |
| 55 | private List<OspfInterface> ospfInterfaces; | 53 | private List<OspfInterface> ospfInterfaces; |
| ... | @@ -61,7 +59,6 @@ public class OspfControllerImplTest { | ... | @@ -61,7 +59,6 @@ public class OspfControllerImplTest { |
| 61 | @Before | 59 | @Before |
| 62 | public void setUp() throws Exception { | 60 | public void setUp() throws Exception { |
| 63 | ospfController = new OspfControllerImpl(); | 61 | ospfController = new OspfControllerImpl(); |
| 64 | - controller = new Controller(); | ||
| 65 | } | 62 | } |
| 66 | 63 | ||
| 67 | @After | 64 | @After |
| ... | @@ -69,7 +66,6 @@ public class OspfControllerImplTest { | ... | @@ -69,7 +66,6 @@ public class OspfControllerImplTest { |
| 69 | ospfController = null; | 66 | ospfController = null; |
| 70 | ospfRouterListener = null; | 67 | ospfRouterListener = null; |
| 71 | ospfLinkListener = null; | 68 | ospfLinkListener = null; |
| 72 | - controller = null; | ||
| 73 | ospfProcesses = null; | 69 | ospfProcesses = null; |
| 74 | areas = null; | 70 | areas = null; |
| 75 | ospfArea = null; | 71 | ospfArea = null; |
| ... | @@ -140,38 +136,6 @@ public class OspfControllerImplTest { | ... | @@ -140,38 +136,6 @@ public class OspfControllerImplTest { |
| 140 | } | 136 | } |
| 141 | 137 | ||
| 142 | /** | 138 | /** |
| 143 | - * Tests updateConfig() method. | ||
| 144 | - */ | ||
| 145 | - @Test | ||
| 146 | - public void testUpdateConfig() throws Exception { | ||
| 147 | - ospfProcess = new OspfProcessImpl(); | ||
| 148 | - ospfArea = new OspfAreaImpl(); | ||
| 149 | - ospfInterface = new OspfInterfaceImpl(); | ||
| 150 | - ospfInterfaces = new ArrayList(); | ||
| 151 | - ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11")); | ||
| 152 | - ospfInterfaces.add(ospfInterface); | ||
| 153 | - ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2")); | ||
| 154 | - ospfArea.setInterfacesLst(ospfInterfaces); | ||
| 155 | - ospfProcess.setProcessId("10.10.10.10"); | ||
| 156 | - areas = new ArrayList(); | ||
| 157 | - areas.add(ospfArea); | ||
| 158 | - ospfProcess.setAreas(areas); | ||
| 159 | - ospfProcesses = new ArrayList(); | ||
| 160 | - ospfProcesses.add(ospfProcess); | ||
| 161 | - process1 = new OspfProcessImpl(); | ||
| 162 | - process1.setProcessId("11.11.11.11"); | ||
| 163 | - ospfArea1 = new OspfAreaImpl(); | ||
| 164 | - ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2")); | ||
| 165 | - ospfArea1.setInterfacesLst(ospfInterfaces); | ||
| 166 | - areas.add(ospfArea1); | ||
| 167 | - process1.setAreas(areas); | ||
| 168 | - ospfProcesses.add(process1); | ||
| 169 | - ospfController.updateConfig(ospfProcesses); | ||
| 170 | - assertThat(ospfController, is(notNullValue())); | ||
| 171 | - | ||
| 172 | - } | ||
| 173 | - | ||
| 174 | - /** | ||
| 175 | * Tests deleteConfig() method. | 139 | * Tests deleteConfig() method. |
| 176 | */ | 140 | */ |
| 177 | @Test | 141 | @Test |
| ... | @@ -183,7 +147,7 @@ public class OspfControllerImplTest { | ... | @@ -183,7 +147,7 @@ public class OspfControllerImplTest { |
| 183 | ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5")); | 147 | ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5")); |
| 184 | ospfInterfaces.add(ospfInterface); | 148 | ospfInterfaces.add(ospfInterface); |
| 185 | ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2")); | 149 | ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2")); |
| 186 | - ospfArea.setInterfacesLst(ospfInterfaces); | 150 | + ospfArea.setOspfInterfaceList(ospfInterfaces); |
| 187 | ospfProcess.setProcessId("10.10.10.10"); | 151 | ospfProcess.setProcessId("10.10.10.10"); |
| 188 | areas = new ArrayList(); | 152 | areas = new ArrayList(); |
| 189 | areas.add(ospfArea); | 153 | areas.add(ospfArea); |
| ... | @@ -194,7 +158,7 @@ public class OspfControllerImplTest { | ... | @@ -194,7 +158,7 @@ public class OspfControllerImplTest { |
| 194 | process1.setProcessId("11.11.11.11"); | 158 | process1.setProcessId("11.11.11.11"); |
| 195 | ospfArea1 = new OspfAreaImpl(); | 159 | ospfArea1 = new OspfAreaImpl(); |
| 196 | ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2")); | 160 | ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2")); |
| 197 | - ospfArea1.setInterfacesLst(ospfInterfaces); | 161 | + ospfArea1.setOspfInterfaceList(ospfInterfaces); |
| 198 | areas.add(ospfArea1); | 162 | areas.add(ospfArea1); |
| 199 | process1.setAreas(areas); | 163 | process1.setAreas(areas); |
| 200 | ospfProcesses.add(process1); | 164 | ospfProcesses.add(process1); |
| ... | @@ -221,7 +185,7 @@ public class OspfControllerImplTest { | ... | @@ -221,7 +185,7 @@ public class OspfControllerImplTest { |
| 221 | ospfRouter = new OspfRouterImpl(); | 185 | ospfRouter = new OspfRouterImpl(); |
| 222 | 186 | ||
| 223 | ospfController.agent.addLink(ospfRouter, new OspfLinkTedImpl()); | 187 | ospfController.agent.addLink(ospfRouter, new OspfLinkTedImpl()); |
| 224 | - ospfController.agent.deleteLink(ospfRouter); | 188 | + ospfController.agent.deleteLink(ospfRouter, new OspfLinkTedImpl()); |
| 225 | assertThat(ospfController, is(notNullValue())); | 189 | assertThat(ospfController, is(notNullValue())); |
| 226 | } | 190 | } |
| 227 | 191 | ... | ... |
| ... | @@ -21,6 +21,7 @@ import org.junit.Test; | ... | @@ -21,6 +21,7 @@ import org.junit.Test; |
| 21 | import org.onlab.packet.Ip4Address; | 21 | import org.onlab.packet.Ip4Address; |
| 22 | import org.onlab.packet.Ip6Address; | 22 | import org.onlab.packet.Ip6Address; |
| 23 | 23 | ||
| 24 | +import java.net.InetAddress; | ||
| 24 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
| 25 | import java.util.List; | 26 | import java.util.List; |
| 26 | 27 | ||
| ... | @@ -31,8 +32,6 @@ import static org.junit.Assert.assertThat; | ... | @@ -31,8 +32,6 @@ import static org.junit.Assert.assertThat; |
| 31 | * Unit test class for OspfDeviceTedImpl. | 32 | * Unit test class for OspfDeviceTedImpl. |
| 32 | */ | 33 | */ |
| 33 | public class OspfDeviceTedImplTest { | 34 | public class OspfDeviceTedImplTest { |
| 34 | - private static final Ip6Address LOCAL_ADDRESS = Ip6Address.valueOf("::1"); | ||
| 35 | - | ||
| 36 | private OspfDeviceTedImpl ospfDeviceTed; | 35 | private OspfDeviceTedImpl ospfDeviceTed; |
| 37 | 36 | ||
| 38 | @Before | 37 | @Before |
| ... | @@ -128,10 +127,10 @@ public class OspfDeviceTedImplTest { | ... | @@ -128,10 +127,10 @@ public class OspfDeviceTedImplTest { |
| 128 | /** | 127 | /** |
| 129 | * Tests ipv6RouterIds() getter method. | 128 | * Tests ipv6RouterIds() getter method. |
| 130 | */ | 129 | */ |
| 131 | - @Test | 130 | + @Test(expected = Exception.class) |
| 132 | public void testIpv6RouterIds() throws Exception { | 131 | public void testIpv6RouterIds() throws Exception { |
| 133 | List list = new ArrayList(); | 132 | List list = new ArrayList(); |
| 134 | - list.add(LOCAL_ADDRESS); | 133 | + list.add(Ip6Address.valueOf(InetAddress.getLocalHost())); |
| 135 | ospfDeviceTed.setIpv6RouterIds(list); | 134 | ospfDeviceTed.setIpv6RouterIds(list); |
| 136 | assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1)); | 135 | assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1)); |
| 137 | } | 136 | } |
| ... | @@ -139,11 +138,11 @@ public class OspfDeviceTedImplTest { | ... | @@ -139,11 +138,11 @@ public class OspfDeviceTedImplTest { |
| 139 | /** | 138 | /** |
| 140 | * Tests ipv6RouterIds() setter method. | 139 | * Tests ipv6RouterIds() setter method. |
| 141 | */ | 140 | */ |
| 142 | - @Test | 141 | + @Test(expected = Exception.class) |
| 143 | public void testSetIpv6RouterIds() throws Exception { | 142 | public void testSetIpv6RouterIds() throws Exception { |
| 144 | List list = new ArrayList(); | 143 | List list = new ArrayList(); |
| 145 | - list.add(LOCAL_ADDRESS); | 144 | + list.add(Ip6Address.valueOf(InetAddress.getLocalHost())); |
| 146 | ospfDeviceTed.setIpv6RouterIds(list); | 145 | ospfDeviceTed.setIpv6RouterIds(list); |
| 147 | assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1)); | 146 | assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1)); |
| 148 | } | 147 | } |
| 149 | -} | 148 | +} |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -21,6 +21,7 @@ import org.junit.Test; | ... | @@ -21,6 +21,7 @@ import org.junit.Test; |
| 21 | import org.onlab.packet.Ip4Address; | 21 | import org.onlab.packet.Ip4Address; |
| 22 | import org.onlab.util.Bandwidth; | 22 | import org.onlab.util.Bandwidth; |
| 23 | 23 | ||
| 24 | +import java.net.InetAddress; | ||
| 24 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
| 25 | import java.util.List; | 26 | import java.util.List; |
| 26 | 27 | ||
| ... | @@ -32,8 +33,6 @@ import static org.junit.Assert.assertThat; | ... | @@ -32,8 +33,6 @@ import static org.junit.Assert.assertThat; |
| 32 | * Unit test class for OspfDeviceTedImpl. | 33 | * Unit test class for OspfDeviceTedImpl. |
| 33 | */ | 34 | */ |
| 34 | public class OspfLinkTedImplTest { | 35 | public class OspfLinkTedImplTest { |
| 35 | - private static final Ip4Address LOCAL_ADDRESS = Ip4Address.valueOf("127.0.0.1"); | ||
| 36 | - | ||
| 37 | private OspfLinkTedImpl ospfLinkTed; | 36 | private OspfLinkTedImpl ospfLinkTed; |
| 38 | 37 | ||
| 39 | @Before | 38 | @Before |
| ... | @@ -91,7 +90,7 @@ public class OspfLinkTedImplTest { | ... | @@ -91,7 +90,7 @@ public class OspfLinkTedImplTest { |
| 91 | @Test | 90 | @Test |
| 92 | public void testIpv4RemRouterId() throws Exception { | 91 | public void testIpv4RemRouterId() throws Exception { |
| 93 | List list = new ArrayList(); | 92 | List list = new ArrayList(); |
| 94 | - list.add(LOCAL_ADDRESS); | 93 | + list.add(Ip4Address.valueOf(InetAddress.getLocalHost())); |
| 95 | ospfLinkTed.setIpv4RemRouterId(list); | 94 | ospfLinkTed.setIpv4RemRouterId(list); |
| 96 | assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1)); | 95 | assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1)); |
| 97 | } | 96 | } |
| ... | @@ -102,7 +101,7 @@ public class OspfLinkTedImplTest { | ... | @@ -102,7 +101,7 @@ public class OspfLinkTedImplTest { |
| 102 | @Test | 101 | @Test |
| 103 | public void testSetIpv4RemRouterId() throws Exception { | 102 | public void testSetIpv4RemRouterId() throws Exception { |
| 104 | List list = new ArrayList(); | 103 | List list = new ArrayList(); |
| 105 | - list.add(LOCAL_ADDRESS); | 104 | + list.add(Ip4Address.valueOf(InetAddress.getLocalHost())); |
| 106 | ospfLinkTed.setIpv4RemRouterId(list); | 105 | ospfLinkTed.setIpv4RemRouterId(list); |
| 107 | assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1)); | 106 | assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1)); |
| 108 | } | 107 | } |
| ... | @@ -133,7 +132,7 @@ public class OspfLinkTedImplTest { | ... | @@ -133,7 +132,7 @@ public class OspfLinkTedImplTest { |
| 133 | @Test | 132 | @Test |
| 134 | public void testIpv4LocRouterId() throws Exception { | 133 | public void testIpv4LocRouterId() throws Exception { |
| 135 | List list = new ArrayList(); | 134 | List list = new ArrayList(); |
| 136 | - list.add(LOCAL_ADDRESS); | 135 | + list.add(Ip4Address.valueOf(InetAddress.getLocalHost())); |
| 137 | ospfLinkTed.setIpv4LocRouterId(list); | 136 | ospfLinkTed.setIpv4LocRouterId(list); |
| 138 | assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1)); | 137 | assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1)); |
| 139 | } | 138 | } |
| ... | @@ -144,7 +143,7 @@ public class OspfLinkTedImplTest { | ... | @@ -144,7 +143,7 @@ public class OspfLinkTedImplTest { |
| 144 | @Test | 143 | @Test |
| 145 | public void testSetIpv4LocRouterId() throws Exception { | 144 | public void testSetIpv4LocRouterId() throws Exception { |
| 146 | List list = new ArrayList(); | 145 | List list = new ArrayList(); |
| 147 | - list.add(LOCAL_ADDRESS); | 146 | + list.add(Ip4Address.valueOf(InetAddress.getLocalHost())); |
| 148 | ospfLinkTed.setIpv4LocRouterId(list); | 147 | ospfLinkTed.setIpv4LocRouterId(list); |
| 149 | assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1)); | 148 | assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1)); |
| 150 | } | 149 | } |
| ... | @@ -202,4 +201,4 @@ public class OspfLinkTedImplTest { | ... | @@ -202,4 +201,4 @@ public class OspfLinkTedImplTest { |
| 202 | ospfLinkTed.setMaxUnResBandwidth(Bandwidth.bps(1234.0)); | 201 | ospfLinkTed.setMaxUnResBandwidth(Bandwidth.bps(1234.0)); |
| 203 | assertThat(ospfLinkTed.maxUnResBandwidth(), is(notNullValue())); | 202 | assertThat(ospfLinkTed.maxUnResBandwidth(), is(notNullValue())); |
| 204 | } | 203 | } |
| 205 | -} | 204 | +} |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -28,7 +28,7 @@ import java.net.InetSocketAddress; | ... | @@ -28,7 +28,7 @@ import java.net.InetSocketAddress; |
| 28 | import java.net.SocketAddress; | 28 | import java.net.SocketAddress; |
| 29 | 29 | ||
| 30 | import static org.hamcrest.CoreMatchers.is; | 30 | import static org.hamcrest.CoreMatchers.is; |
| 31 | -import static org.hamcrest.CoreMatchers.nullValue; | 31 | +import static org.hamcrest.CoreMatchers.notNullValue; |
| 32 | import static org.hamcrest.MatcherAssert.assertThat; | 32 | import static org.hamcrest.MatcherAssert.assertThat; |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| ... | @@ -36,7 +36,7 @@ import static org.hamcrest.MatcherAssert.assertThat; | ... | @@ -36,7 +36,7 @@ import static org.hamcrest.MatcherAssert.assertThat; |
| 36 | */ | 36 | */ |
| 37 | public class OspfMessageDecoderTest { | 37 | public class OspfMessageDecoderTest { |
| 38 | 38 | ||
| 39 | - private final byte[] hellopacket = {0, 0, 0, 0, 2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59, | 39 | + private final byte[] hellopacket = {0, 0, 0, 0, 0, 2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59, |
| 40 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, 0, | 40 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, 0, |
| 41 | 40, -64, -88, -86, 8, 0, 0, 0, 0}; | 41 | 40, -64, -88, -86, 8, 0, 0, 0, 0}; |
| 42 | private final byte[] ddpacket = {0, 0, 0, 0, 2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82, | 42 | private final byte[] ddpacket = {0, 0, 0, 0, 2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82, |
| ... | @@ -75,10 +75,10 @@ public class OspfMessageDecoderTest { | ... | @@ -75,10 +75,10 @@ public class OspfMessageDecoderTest { |
| 75 | */ | 75 | */ |
| 76 | @Test | 76 | @Test |
| 77 | public void testDecode() throws Exception { | 77 | public void testDecode() throws Exception { |
| 78 | - | ||
| 79 | channel = EasyMock.createMock(Channel.class); | 78 | channel = EasyMock.createMock(Channel.class); |
| 80 | socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000); | 79 | socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000); |
| 81 | channelBuffer = ChannelBuffers.copiedBuffer(hellopacket); | 80 | channelBuffer = ChannelBuffers.copiedBuffer(hellopacket); |
| 82 | - assertThat(ospfMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue())); | 81 | + ospfMessageDecoder.decode(ctx, channel, channelBuffer); |
| 82 | + assertThat(ospfMessageDecoder, is(notNullValue())); | ||
| 83 | } | 83 | } |
| 84 | } | 84 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -17,24 +17,11 @@ package org.onosproject.ospf.controller.impl; | ... | @@ -17,24 +17,11 @@ package org.onosproject.ospf.controller.impl; |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | import org.easymock.EasyMock; | 19 | import org.easymock.EasyMock; |
| 20 | -import org.jboss.netty.buffer.ChannelBuffer; | ||
| 21 | -import org.jboss.netty.buffer.ChannelBuffers; | ||
| 22 | import org.jboss.netty.channel.Channel; | 20 | import org.jboss.netty.channel.Channel; |
| 23 | import org.jboss.netty.channel.ChannelHandlerContext; | 21 | import org.jboss.netty.channel.ChannelHandlerContext; |
| 24 | import org.junit.After; | 22 | import org.junit.After; |
| 25 | import org.junit.Before; | 23 | import org.junit.Before; |
| 26 | import org.junit.Test; | 24 | import org.junit.Test; |
| 27 | -import org.onlab.packet.Ip4Address; | ||
| 28 | -import org.onosproject.ospf.controller.area.OspfInterfaceImpl; | ||
| 29 | -import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket; | ||
| 30 | -import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket; | ||
| 31 | -import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; | ||
| 32 | -import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest; | ||
| 33 | -import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; | ||
| 34 | -import org.onosproject.ospf.protocol.util.OspfInterfaceState; | ||
| 35 | - | ||
| 36 | -import java.net.InetSocketAddress; | ||
| 37 | -import java.net.SocketAddress; | ||
| 38 | 25 | ||
| 39 | import static org.hamcrest.CoreMatchers.is; | 26 | import static org.hamcrest.CoreMatchers.is; |
| 40 | import static org.hamcrest.CoreMatchers.notNullValue; | 27 | import static org.hamcrest.CoreMatchers.notNullValue; |
| ... | @@ -44,55 +31,24 @@ import static org.hamcrest.MatcherAssert.assertThat; | ... | @@ -44,55 +31,24 @@ import static org.hamcrest.MatcherAssert.assertThat; |
| 44 | * Created by sdn on 13/1/16. | 31 | * Created by sdn on 13/1/16. |
| 45 | */ | 32 | */ |
| 46 | public class OspfMessageEncoderTest { | 33 | public class OspfMessageEncoderTest { |
| 47 | - private final byte[] hpacket = {2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59, | 34 | + |
| 48 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, 0, | 35 | + private final byte[] object = {2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, |
| 49 | - 40, -64, -88, -86, 8, 0, 0, 0, 0}; | 36 | + 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, |
| 50 | - private final byte[] dpacket = {2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82, | 37 | + 0, 40, -64, -88, -86, 8, 0, 0, 0, 0}; |
| 51 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119, -87, 126}; | ||
| 52 | - private final byte[] lrpacket = {2, 3, 0, 36, -64, -88, -86, 3, 0, 0, 0, 1, -67, -57, | ||
| 53 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, -86, 8, -64, -88, -86, 8}; | ||
| 54 | - private byte[] lAckpacket = {2, 5, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, -30, -12, | ||
| 55 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 16, 2, 1, -64, -88, -86, 2, -64, | ||
| 56 | - -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48}; | ||
| 57 | - private HelloPacket helloPacket; | ||
| 58 | - private DdPacket ddPacket; | ||
| 59 | - private LsAcknowledge lsAcknowledge; | ||
| 60 | - private LsRequest lsRequest; | ||
| 61 | - private LsUpdate lsUpdate; | ||
| 62 | - private ChannelHandlerContext ctx; | ||
| 63 | private OspfMessageEncoder ospfMessageEncoder; | 38 | private OspfMessageEncoder ospfMessageEncoder; |
| 64 | - private ChannelBuffer buf; | 39 | + private ChannelHandlerContext channelHandlerContext; |
| 65 | - private SocketAddress socketAddress; | ||
| 66 | private Channel channel; | 40 | private Channel channel; |
| 67 | 41 | ||
| 68 | @Before | 42 | @Before |
| 69 | public void setUp() throws Exception { | 43 | public void setUp() throws Exception { |
| 70 | ospfMessageEncoder = new OspfMessageEncoder(); | 44 | ospfMessageEncoder = new OspfMessageEncoder(); |
| 71 | - helloPacket = new HelloPacket(); | 45 | + channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class); |
| 72 | - ddPacket = new DdPacket(); | 46 | + channel = EasyMock.createMock(Channel.class); |
| 73 | - lsAcknowledge = new LsAcknowledge(); | ||
| 74 | - lsRequest = new LsRequest(); | ||
| 75 | - lsUpdate = new LsUpdate(); | ||
| 76 | - helloPacket.setOspftype(1); | ||
| 77 | - ddPacket.setOspftype(2); | ||
| 78 | - lsAcknowledge.setOspftype(5); | ||
| 79 | - lsRequest.setOspftype(3); | ||
| 80 | - lsUpdate.setOspftype(4); | ||
| 81 | - OspfInterfaceImpl ospfInterface = new OspfInterfaceImpl(); | ||
| 82 | - ospfInterface.setState(OspfInterfaceState.DROTHER); | ||
| 83 | - ospfMessageEncoder = new OspfMessageEncoder(ospfInterface); | ||
| 84 | - | ||
| 85 | } | 47 | } |
| 86 | 48 | ||
| 87 | @After | 49 | @After |
| 88 | public void tearDown() throws Exception { | 50 | public void tearDown() throws Exception { |
| 89 | - helloPacket = null; | ||
| 90 | - ddPacket = null; | ||
| 91 | - lsAcknowledge = null; | ||
| 92 | - lsRequest = null; | ||
| 93 | - lsUpdate = null; | ||
| 94 | ospfMessageEncoder = null; | 51 | ospfMessageEncoder = null; |
| 95 | - buf = null; | ||
| 96 | } | 52 | } |
| 97 | 53 | ||
| 98 | /** | 54 | /** |
| ... | @@ -100,33 +56,6 @@ public class OspfMessageEncoderTest { | ... | @@ -100,33 +56,6 @@ public class OspfMessageEncoderTest { |
| 100 | */ | 56 | */ |
| 101 | @Test | 57 | @Test |
| 102 | public void testEncode() throws Exception { | 58 | public void testEncode() throws Exception { |
| 103 | - socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 8600); | 59 | + assertThat(ospfMessageEncoder.encode(channelHandlerContext, channel, object), is(notNullValue())); |
| 104 | - channel = EasyMock.createMock(Channel.class); | ||
| 105 | - helloPacket = new HelloPacket(); | ||
| 106 | - helloPacket.setDestinationIp(Ip4Address.valueOf("15.15.15.15")); | ||
| 107 | - buf = ChannelBuffers.buffer(hpacket.length); | ||
| 108 | - buf.writeBytes(hpacket); | ||
| 109 | - helloPacket.readFrom(buf); | ||
| 110 | - ospfMessageEncoder.encode(ctx, channel, helloPacket); | ||
| 111 | - ddPacket = new DdPacket(); | ||
| 112 | - ddPacket.setDestinationIp(Ip4Address.valueOf("15.15.15.15")); | ||
| 113 | - buf = ChannelBuffers.buffer(dpacket.length); | ||
| 114 | - buf.writeBytes(dpacket); | ||
| 115 | - ddPacket.readFrom(buf); | ||
| 116 | - ospfMessageEncoder.encode(ctx, channel, ddPacket); | ||
| 117 | - lsRequest = new LsRequest(); | ||
| 118 | - lsRequest.setDestinationIp(Ip4Address.valueOf("15.15.15.15")); | ||
| 119 | - buf = ChannelBuffers.buffer(lrpacket.length); | ||
| 120 | - buf.writeBytes(lrpacket); | ||
| 121 | - lsRequest.readFrom(buf); | ||
| 122 | - ospfMessageEncoder.encode(ctx, channel, lsRequest); | ||
| 123 | - | ||
| 124 | - lsAcknowledge = new LsAcknowledge(); | ||
| 125 | - lsAcknowledge.setDestinationIp(Ip4Address.valueOf("15.15.15.15")); | ||
| 126 | - buf = ChannelBuffers.buffer(lAckpacket.length); | ||
| 127 | - buf.writeBytes(lAckpacket); | ||
| 128 | - lsAcknowledge.readFrom(buf); | ||
| 129 | - ospfMessageEncoder.encode(ctx, channel, lsAcknowledge); | ||
| 130 | - assertThat(ospfMessageEncoder, is(notNullValue())); | ||
| 131 | } | 60 | } |
| 132 | } | 61 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -18,12 +18,6 @@ package org.onosproject.ospf.controller.impl; | ... | @@ -18,12 +18,6 @@ package org.onosproject.ospf.controller.impl; |
| 18 | import org.jboss.netty.channel.ChannelPipeline; | 18 | import org.jboss.netty.channel.ChannelPipeline; |
| 19 | import org.junit.After; | 19 | import org.junit.After; |
| 20 | import org.junit.Before; | 20 | import org.junit.Before; |
| 21 | -import org.junit.Test; | ||
| 22 | -import org.onosproject.ospf.controller.area.OspfAreaImpl; | ||
| 23 | -import org.onosproject.ospf.controller.area.OspfInterfaceImpl; | ||
| 24 | - | ||
| 25 | -import static org.hamcrest.CoreMatchers.*; | ||
| 26 | -import static org.hamcrest.MatcherAssert.assertThat; | ||
| 27 | 21 | ||
| 28 | /** | 22 | /** |
| 29 | * Unit test class for OspfPipelineFactory. | 23 | * Unit test class for OspfPipelineFactory. |
| ... | @@ -35,8 +29,6 @@ public class OspfPipelineFactoryTest { | ... | @@ -35,8 +29,6 @@ public class OspfPipelineFactoryTest { |
| 35 | 29 | ||
| 36 | @Before | 30 | @Before |
| 37 | public void setUp() throws Exception { | 31 | public void setUp() throws Exception { |
| 38 | - ospfPipelineFactory = new OspfPipelineFactory(new Controller(), new OspfAreaImpl(), new OspfInterfaceImpl()); | ||
| 39 | - | ||
| 40 | } | 32 | } |
| 41 | 33 | ||
| 42 | @After | 34 | @After |
| ... | @@ -44,22 +36,4 @@ public class OspfPipelineFactoryTest { | ... | @@ -44,22 +36,4 @@ public class OspfPipelineFactoryTest { |
| 44 | ospfPipelineFactory = null; | 36 | ospfPipelineFactory = null; |
| 45 | channelPipeline = null; | 37 | channelPipeline = null; |
| 46 | } | 38 | } |
| 47 | - | ||
| 48 | - /** | ||
| 49 | - * Tests getPipeline() method. | ||
| 50 | - */ | ||
| 51 | - @Test | ||
| 52 | - public void testGetPipeline() throws Exception { | ||
| 53 | - channelPipeline = ospfPipelineFactory.getPipeline(); | ||
| 54 | - assertThat(channelPipeline, is(notNullValue())); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - /** | ||
| 58 | - * Tests releaseExternalResources() method. | ||
| 59 | - */ | ||
| 60 | - @Test | ||
| 61 | - public void testReleaseExternalResources() throws Exception { | ||
| 62 | - ospfPipelineFactory.releaseExternalResources(); | ||
| 63 | - assertThat(channelPipeline, is(nullValue())); | ||
| 64 | - } | ||
| 65 | } | 39 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -74,8 +74,9 @@ public class LsaQueueConsumerTest { | ... | @@ -74,8 +74,9 @@ public class LsaQueueConsumerTest { |
| 74 | @Test | 74 | @Test |
| 75 | public void testRun() throws Exception { | 75 | public void testRun() throws Exception { |
| 76 | blockingQueue = new ArrayBlockingQueue(5); | 76 | blockingQueue = new ArrayBlockingQueue(5); |
| 77 | - channel = EasyMock.createMock(Channel.class); | ||
| 78 | ospfArea = new OspfAreaImpl(); | 77 | ospfArea = new OspfAreaImpl(); |
| 78 | + lsdbAge = new LsdbAgeImpl(ospfArea); | ||
| 79 | + channel = EasyMock.createMock(Channel.class); | ||
| 79 | lsaWrapper = new LsaWrapperImpl(); | 80 | lsaWrapper = new LsaWrapperImpl(); |
| 80 | lsaWrapper.setLsaProcessing("verifyChecksum"); | 81 | lsaWrapper.setLsaProcessing("verifyChecksum"); |
| 81 | blockingQueue.add(lsaWrapper); | 82 | blockingQueue.add(lsaWrapper); |
| ... | @@ -104,7 +105,7 @@ public class LsaQueueConsumerTest { | ... | @@ -104,7 +105,7 @@ public class LsaQueueConsumerTest { |
| 104 | lsaHeader.setLsType(1); | 105 | lsaHeader.setLsType(1); |
| 105 | lsaWrapper.setLsaHeader(lsaHeader); | 106 | lsaWrapper.setLsaHeader(lsaHeader); |
| 106 | lsaWrapper.setLsaProcessing("refreshLsa"); | 107 | lsaWrapper.setLsaProcessing("refreshLsa"); |
| 107 | - lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl())); | 108 | + lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea)); |
| 108 | blockingQueue.add(lsaWrapper); | 109 | blockingQueue.add(lsaWrapper); |
| 109 | lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea); | 110 | lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea); |
| 110 | lsaQueueConsumer.run(); | 111 | lsaQueueConsumer.run(); |
| ... | @@ -128,7 +129,7 @@ public class LsaQueueConsumerTest { | ... | @@ -128,7 +129,7 @@ public class LsaQueueConsumerTest { |
| 128 | lsaHeader.setLsType(2); | 129 | lsaHeader.setLsType(2); |
| 129 | lsaWrapper.setLsaHeader(lsaHeader); | 130 | lsaWrapper.setLsaHeader(lsaHeader); |
| 130 | lsaWrapper.setLsaProcessing("refreshLsa"); | 131 | lsaWrapper.setLsaProcessing("refreshLsa"); |
| 131 | - lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl())); | 132 | + lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea)); |
| 132 | blockingQueue.add(lsaWrapper); | 133 | blockingQueue.add(lsaWrapper); |
| 133 | lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea); | 134 | lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea); |
| 134 | lsaQueueConsumer.run(); | 135 | lsaQueueConsumer.run(); |
| ... | @@ -155,7 +156,7 @@ public class LsaQueueConsumerTest { | ... | @@ -155,7 +156,7 @@ public class LsaQueueConsumerTest { |
| 155 | lsaHeader.setLsType(2); | 156 | lsaHeader.setLsType(2); |
| 156 | lsaWrapper.setLsaHeader(lsaHeader); | 157 | lsaWrapper.setLsaHeader(lsaHeader); |
| 157 | lsaWrapper.setLsaProcessing("maxAgeLsa"); | 158 | lsaWrapper.setLsaProcessing("maxAgeLsa"); |
| 158 | - lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl())); | 159 | + lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea)); |
| 159 | blockingQueue.add(lsaWrapper); | 160 | blockingQueue.add(lsaWrapper); |
| 160 | lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea); | 161 | lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea); |
| 161 | lsaQueueConsumer.run(); | 162 | lsaQueueConsumer.run(); |
| ... | @@ -168,7 +169,7 @@ public class LsaQueueConsumerTest { | ... | @@ -168,7 +169,7 @@ public class LsaQueueConsumerTest { |
| 168 | @Test | 169 | @Test |
| 169 | public void testSetChannel() throws Exception { | 170 | public void testSetChannel() throws Exception { |
| 170 | channel = EasyMock.createMock(Channel.class); | 171 | channel = EasyMock.createMock(Channel.class); |
| 171 | - lsdbAge = new LsdbAgeImpl(new OspfAreaImpl()); | 172 | + lsdbAge = new LsdbAgeImpl(ospfArea); |
| 172 | lsdbAge.startDbAging(); | 173 | lsdbAge.startDbAging(); |
| 173 | lsdbAge.setChannel(channel); | 174 | lsdbAge.setChannel(channel); |
| 174 | assertThat(lsaQueueConsumer, is(notNullValue())); | 175 | assertThat(lsaQueueConsumer, is(notNullValue())); | ... | ... |
| ... | @@ -23,6 +23,7 @@ import org.junit.Before; | ... | @@ -23,6 +23,7 @@ import org.junit.Before; |
| 23 | import org.junit.Test; | 23 | import org.junit.Test; |
| 24 | import org.onosproject.ospf.controller.LsaBin; | 24 | import org.onosproject.ospf.controller.LsaBin; |
| 25 | import org.onosproject.ospf.controller.OspfArea; | 25 | import org.onosproject.ospf.controller.OspfArea; |
| 26 | +import org.onosproject.ospf.controller.OspfLsaType; | ||
| 26 | import org.onosproject.ospf.controller.area.OspfAreaImpl; | 27 | import org.onosproject.ospf.controller.area.OspfAreaImpl; |
| 27 | 28 | ||
| 28 | import static org.hamcrest.CoreMatchers.*; | 29 | import static org.hamcrest.CoreMatchers.*; |
| ... | @@ -181,14 +182,10 @@ public class LsdbAgeImplTest { | ... | @@ -181,14 +182,10 @@ public class LsdbAgeImplTest { |
| 181 | public void testRefereshLsa() throws Exception { | 182 | public void testRefereshLsa() throws Exception { |
| 182 | lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class); | 183 | lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class); |
| 183 | lsaWrapper.setBinNumber(0); | 184 | lsaWrapper.setBinNumber(0); |
| 185 | + lsaWrapper.setLsaType(OspfLsaType.NETWORK); | ||
| 184 | lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper); | 186 | lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper); |
| 185 | lsdbAge.ageLsaAndFlood(); | 187 | lsdbAge.ageLsaAndFlood(); |
| 186 | - lsaWrapper.setBinNumber(0); | ||
| 187 | - lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class); | ||
| 188 | - lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper); | ||
| 189 | - lsdbAge.ageLsaAndFlood(); | ||
| 190 | lsdbAge.startDbAging(); | 188 | lsdbAge.startDbAging(); |
| 191 | - lsaBin = new LsaBinImpl(1809); | ||
| 192 | lsdbAge.refreshLsa(); | 189 | lsdbAge.refreshLsa(); |
| 193 | assertThat(lsdbAge, is(notNullValue())); | 190 | assertThat(lsdbAge, is(notNullValue())); |
| 194 | } | 191 | } | ... | ... |
| 1 | /* | 1 | /* |
| 2 | - * Copyright 2016-present Open Networking Laboratory | 2 | + * Copyright 2016 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. | ... | ... |
| ... | @@ -103,6 +103,16 @@ public class NetworkLsa extends LsaHeader { | ... | @@ -103,6 +103,16 @@ public class NetworkLsa extends LsaHeader { |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | /** | 105 | /** |
| 106 | + * Gets the list of attached routers. | ||
| 107 | + * | ||
| 108 | + * @return list of attached routers | ||
| 109 | + */ | ||
| 110 | + public List<Ip4Address> attachedRouters() { | ||
| 111 | + | ||
| 112 | + return attachedRouters; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /** | ||
| 106 | * Reads from channel buffer and populate instance. | 116 | * Reads from channel buffer and populate instance. |
| 107 | * | 117 | * |
| 108 | * @param channelBuffer channel buffer instance | 118 | * @param channelBuffer channel buffer instance | ... | ... |
| ... | @@ -29,7 +29,6 @@ import org.onosproject.ospf.protocol.lsa.tlvtypes.OpaqueTopLevelTlvTypes; | ... | @@ -29,7 +29,6 @@ import org.onosproject.ospf.protocol.lsa.tlvtypes.OpaqueTopLevelTlvTypes; |
| 29 | import org.onosproject.ospf.protocol.lsa.tlvtypes.RouterTlv; | 29 | import org.onosproject.ospf.protocol.lsa.tlvtypes.RouterTlv; |
| 30 | import org.onosproject.ospf.protocol.util.OspfParameters; | 30 | import org.onosproject.ospf.protocol.util.OspfParameters; |
| 31 | 31 | ||
| 32 | -import java.util.Arrays; | ||
| 33 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
| 34 | import java.util.List; | 33 | import java.util.List; |
| 35 | 34 | ||
| ... | @@ -193,11 +192,11 @@ public class OpaqueLsa10 extends OpaqueLsaHeader { | ... | @@ -193,11 +192,11 @@ public class OpaqueLsa10 extends OpaqueLsaHeader { |
| 193 | } | 192 | } |
| 194 | OpaqueLsa10 that = (OpaqueLsa10) o; | 193 | OpaqueLsa10 that = (OpaqueLsa10) o; |
| 195 | return Objects.equal(topLevelValues, that.topLevelValues) && | 194 | return Objects.equal(topLevelValues, that.topLevelValues) && |
| 196 | - Arrays.equals(opaqueInfo, that.opaqueInfo); | 195 | + Objects.equal(opaqueInfo, that.opaqueInfo); |
| 197 | } | 196 | } |
| 198 | 197 | ||
| 199 | @Override | 198 | @Override |
| 200 | public int hashCode() { | 199 | public int hashCode() { |
| 201 | - return Objects.hashCode(Arrays.hashCode(opaqueInfo), topLevelValues); | 200 | + return Objects.hashCode(opaqueInfo, topLevelValues); |
| 202 | } | 201 | } |
| 203 | } | 202 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -16,13 +16,12 @@ | ... | @@ -16,13 +16,12 @@ |
| 16 | package org.onosproject.ospf.protocol.lsa.types; | 16 | package org.onosproject.ospf.protocol.lsa.types; |
| 17 | 17 | ||
| 18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
| 19 | +import com.google.common.base.Objects; | ||
| 19 | import com.google.common.primitives.Bytes; | 20 | import com.google.common.primitives.Bytes; |
| 20 | import org.jboss.netty.buffer.ChannelBuffer; | 21 | import org.jboss.netty.buffer.ChannelBuffer; |
| 21 | import org.onosproject.ospf.controller.OspfLsaType; | 22 | import org.onosproject.ospf.controller.OspfLsaType; |
| 22 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; | 23 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; |
| 23 | 24 | ||
| 24 | -import java.util.Arrays; | ||
| 25 | - | ||
| 26 | /** | 25 | /** |
| 27 | * Representation of an Opaque LSA of type AS (11). | 26 | * Representation of an Opaque LSA of type AS (11). |
| 28 | */ | 27 | */ |
| ... | @@ -107,12 +106,12 @@ public class OpaqueLsa11 extends OpaqueLsaHeader { | ... | @@ -107,12 +106,12 @@ public class OpaqueLsa11 extends OpaqueLsaHeader { |
| 107 | return false; | 106 | return false; |
| 108 | } | 107 | } |
| 109 | OpaqueLsa11 that = (OpaqueLsa11) o; | 108 | OpaqueLsa11 that = (OpaqueLsa11) o; |
| 110 | - return Arrays.equals(opaqueInfo, that.opaqueInfo); | 109 | + return Objects.equal(opaqueInfo, that.opaqueInfo); |
| 111 | } | 110 | } |
| 112 | 111 | ||
| 113 | @Override | 112 | @Override |
| 114 | public int hashCode() { | 113 | public int hashCode() { |
| 115 | - return Arrays.hashCode(opaqueInfo); | 114 | + return Objects.hashCode(opaqueInfo); |
| 116 | } | 115 | } |
| 117 | 116 | ||
| 118 | @Override | 117 | @Override | ... | ... |
| ... | @@ -16,13 +16,12 @@ | ... | @@ -16,13 +16,12 @@ |
| 16 | package org.onosproject.ospf.protocol.lsa.types; | 16 | package org.onosproject.ospf.protocol.lsa.types; |
| 17 | 17 | ||
| 18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
| 19 | +import com.google.common.base.Objects; | ||
| 19 | import com.google.common.primitives.Bytes; | 20 | import com.google.common.primitives.Bytes; |
| 20 | import org.jboss.netty.buffer.ChannelBuffer; | 21 | import org.jboss.netty.buffer.ChannelBuffer; |
| 21 | import org.onosproject.ospf.controller.OspfLsaType; | 22 | import org.onosproject.ospf.controller.OspfLsaType; |
| 22 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; | 23 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; |
| 23 | 24 | ||
| 24 | -import java.util.Arrays; | ||
| 25 | - | ||
| 26 | /** | 25 | /** |
| 27 | * Representation of an Opaque LSA of type link local (9). | 26 | * Representation of an Opaque LSA of type link local (9). |
| 28 | */ | 27 | */ |
| ... | @@ -109,12 +108,12 @@ public class OpaqueLsa9 extends OpaqueLsaHeader { | ... | @@ -109,12 +108,12 @@ public class OpaqueLsa9 extends OpaqueLsaHeader { |
| 109 | return false; | 108 | return false; |
| 110 | } | 109 | } |
| 111 | OpaqueLsa9 that = (OpaqueLsa9) o; | 110 | OpaqueLsa9 that = (OpaqueLsa9) o; |
| 112 | - return Arrays.equals(opaqueInfo, that.opaqueInfo); | 111 | + return Objects.equal(opaqueInfo, that.opaqueInfo); |
| 113 | } | 112 | } |
| 114 | 113 | ||
| 115 | @Override | 114 | @Override |
| 116 | public int hashCode() { | 115 | public int hashCode() { |
| 117 | - return Arrays.hashCode(opaqueInfo); | 116 | + return Objects.hashCode(opaqueInfo); |
| 118 | } | 117 | } |
| 119 | 118 | ||
| 120 | @Override | 119 | @Override | ... | ... |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.ospf.protocol.ospfpacket; | ... | @@ -18,6 +18,7 @@ package org.onosproject.ospf.protocol.ospfpacket; |
| 18 | 18 | ||
| 19 | import org.jboss.netty.buffer.ChannelBuffer; | 19 | import org.jboss.netty.buffer.ChannelBuffer; |
| 20 | import org.onlab.packet.Ip4Address; | 20 | import org.onlab.packet.Ip4Address; |
| 21 | +import org.onosproject.ospf.controller.OspfMessage; | ||
| 21 | import org.onosproject.ospf.exceptions.OspfErrorType; | 22 | import org.onosproject.ospf.exceptions.OspfErrorType; |
| 22 | import org.onosproject.ospf.exceptions.OspfParseException; | 23 | import org.onosproject.ospf.exceptions.OspfParseException; |
| 23 | import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket; | 24 | import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket; |
| ... | @@ -46,15 +47,8 @@ public class OspfMessageReader { | ... | @@ -46,15 +47,8 @@ public class OspfMessageReader { |
| 46 | public OspfMessage readFromBuffer(ChannelBuffer channelBuffer) | 47 | public OspfMessage readFromBuffer(ChannelBuffer channelBuffer) |
| 47 | throws Exception { | 48 | throws Exception { |
| 48 | 49 | ||
| 49 | - if (channelBuffer.readableBytes() < OspfUtil.PACKET_MINIMUM_LENGTH) { | ||
| 50 | - log.error("Packet should have minimum length..."); | ||
| 51 | - throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | try { | 50 | try { |
| 55 | OspfPacketHeader ospfHeader = getOspfHeader(channelBuffer); | 51 | OspfPacketHeader ospfHeader = getOspfHeader(channelBuffer); |
| 56 | - int len = ospfHeader.ospfPacLength() - OspfUtil.OSPF_HEADER_LENGTH; | ||
| 57 | - | ||
| 58 | OspfMessage ospfMessage = null; | 52 | OspfMessage ospfMessage = null; |
| 59 | switch (ospfHeader.ospfType()) { | 53 | switch (ospfHeader.ospfType()) { |
| 60 | case OspfParameters.HELLO: | 54 | case OspfParameters.HELLO: |
| ... | @@ -81,7 +75,8 @@ public class OspfMessageReader { | ... | @@ -81,7 +75,8 @@ public class OspfMessageReader { |
| 81 | try { | 75 | try { |
| 82 | log.debug("{} Received::Message Length :: {} ", ospfMessage.ospfMessageType(), | 76 | log.debug("{} Received::Message Length :: {} ", ospfMessage.ospfMessageType(), |
| 83 | ospfHeader.ospfPacLength()); | 77 | ospfHeader.ospfPacLength()); |
| 84 | - ospfMessage.readFrom(channelBuffer.readBytes(len)); | 78 | + ospfMessage.readFrom(channelBuffer.readBytes(ospfHeader.ospfPacLength() - |
| 79 | + OspfUtil.OSPF_HEADER_LENGTH)); | ||
| 85 | } catch (Exception e) { | 80 | } catch (Exception e) { |
| 86 | throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, | 81 | throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, |
| 87 | OspfErrorType.BAD_MESSAGE); | 82 | OspfErrorType.BAD_MESSAGE); |
| ... | @@ -105,22 +100,13 @@ public class OspfMessageReader { | ... | @@ -105,22 +100,13 @@ public class OspfMessageReader { |
| 105 | private OspfPacketHeader getOspfHeader(ChannelBuffer channelBuffer) throws Exception { | 100 | private OspfPacketHeader getOspfHeader(ChannelBuffer channelBuffer) throws Exception { |
| 106 | OspfPacketHeader ospfPacketHeader = new OspfPacketHeader(); | 101 | OspfPacketHeader ospfPacketHeader = new OspfPacketHeader(); |
| 107 | 102 | ||
| 108 | - byte[] sourceIpBytes = new byte[OspfUtil.FOUR_BYTES]; | 103 | + // Determine OSPF version & Packet Type |
| 109 | - channelBuffer.readBytes(sourceIpBytes, 0, OspfUtil.FOUR_BYTES); | ||
| 110 | - Ip4Address sourceIP = Ip4Address.valueOf(sourceIpBytes); | ||
| 111 | - | ||
| 112 | - // Determine ospf version & Packet Type | ||
| 113 | int version = channelBuffer.readByte(); //byte 1 is ospf version | 104 | int version = channelBuffer.readByte(); //byte 1 is ospf version |
| 114 | int packetType = channelBuffer.readByte(); //byte 2 is ospf packet type | 105 | int packetType = channelBuffer.readByte(); //byte 2 is ospf packet type |
| 115 | 106 | ||
| 116 | // byte 3 & 4 combine is packet length. | 107 | // byte 3 & 4 combine is packet length. |
| 117 | int packetLength = channelBuffer.readShort(); | 108 | int packetLength = channelBuffer.readShort(); |
| 118 | 109 | ||
| 119 | - if (packetLength > channelBuffer.readableBytes() + OspfUtil.FOUR_BYTES) { | ||
| 120 | - log.error("Packet should have minimum length..."); | ||
| 121 | - throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH); | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; | 110 | byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; |
| 125 | channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); | 111 | channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); |
| 126 | Ip4Address routerId = Ip4Address.valueOf(tempByteArray); | 112 | Ip4Address routerId = Ip4Address.valueOf(tempByteArray); |
| ... | @@ -133,7 +119,6 @@ public class OspfMessageReader { | ... | @@ -133,7 +119,6 @@ public class OspfMessageReader { |
| 133 | int auType = channelBuffer.readUnsignedShort(); | 119 | int auType = channelBuffer.readUnsignedShort(); |
| 134 | int authentication = (int) channelBuffer.readLong(); | 120 | int authentication = (int) channelBuffer.readLong(); |
| 135 | 121 | ||
| 136 | - ospfPacketHeader.setSourceIp(sourceIP); | ||
| 137 | ospfPacketHeader.setOspfVer(version); | 122 | ospfPacketHeader.setOspfVer(version); |
| 138 | ospfPacketHeader.setOspftype(packetType); | 123 | ospfPacketHeader.setOspftype(packetType); |
| 139 | ospfPacketHeader.setOspfPacLength(packetLength); | 124 | ospfPacketHeader.setOspfPacLength(packetLength); | ... | ... |
| 1 | /* | 1 | /* |
| 2 | -* Copyright 2016-present Open Networking Laboratory | 2 | +* Copyright 2016 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. |
| ... | @@ -15,41 +15,36 @@ | ... | @@ -15,41 +15,36 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.ospf.protocol.ospfpacket; | 16 | package org.onosproject.ospf.protocol.ospfpacket; |
| 17 | 17 | ||
| 18 | -import org.jboss.netty.buffer.ChannelBuffer; | 18 | +import org.onosproject.ospf.controller.OspfMessage; |
| 19 | -import org.jboss.netty.buffer.ChannelBuffers; | ||
| 20 | import org.onosproject.ospf.protocol.util.OspfParameters; | 19 | import org.onosproject.ospf.protocol.util.OspfParameters; |
| 21 | import org.onosproject.ospf.protocol.util.OspfUtil; | 20 | import org.onosproject.ospf.protocol.util.OspfUtil; |
| 22 | import org.slf4j.Logger; | 21 | import org.slf4j.Logger; |
| 23 | import org.slf4j.LoggerFactory; | 22 | import org.slf4j.LoggerFactory; |
| 24 | 23 | ||
| 25 | /** | 24 | /** |
| 26 | - * A message writer which writes an OspfMessage to ChannelBuffer. | 25 | + * A message writer which writes an OSPF message to byte array. |
| 27 | */ | 26 | */ |
| 28 | public class OspfMessageWriter { | 27 | public class OspfMessageWriter { |
| 29 | private static final Logger log = LoggerFactory.getLogger(OspfMessageWriter.class); | 28 | private static final Logger log = LoggerFactory.getLogger(OspfMessageWriter.class); |
| 30 | 29 | ||
| 31 | /** | 30 | /** |
| 32 | - * Writes OSPF message to ChannelBuffer. | 31 | + * Writes OSPF message to byte array. |
| 33 | * | 32 | * |
| 34 | * @param ospfMessage OSPF message | 33 | * @param ospfMessage OSPF message |
| 34 | + * @param interfaceIndex interface index | ||
| 35 | * @param interfaceState interface state | 35 | * @param interfaceState interface state |
| 36 | - * @param interfaceType interface type | 36 | + * @return message as byte array |
| 37 | - * @return channelBuffer channel buffer instance | ||
| 38 | - * @throws Exception might throws exception while parsing message | ||
| 39 | */ | 37 | */ |
| 40 | - public ChannelBuffer writeToBuffer(OspfMessage ospfMessage, int interfaceState, | 38 | + public byte[] getMessage(OspfMessage ospfMessage, int interfaceIndex, int interfaceState) { |
| 41 | - int interfaceType) throws Exception { | ||
| 42 | 39 | ||
| 43 | - ChannelBuffer buf = null; | 40 | + byte[] buf = null; |
| 44 | switch (ospfMessage.ospfMessageType().value()) { | 41 | switch (ospfMessage.ospfMessageType().value()) { |
| 45 | case OspfParameters.HELLO: | 42 | case OspfParameters.HELLO: |
| 46 | case OspfParameters.LSACK: | 43 | case OspfParameters.LSACK: |
| 47 | - buf = writeMessageToBuffer(ospfMessage, interfaceState); | ||
| 48 | - break; | ||
| 49 | case OspfParameters.DD: | 44 | case OspfParameters.DD: |
| 50 | case OspfParameters.LSREQUEST: | 45 | case OspfParameters.LSREQUEST: |
| 51 | case OspfParameters.LSUPDATE: | 46 | case OspfParameters.LSUPDATE: |
| 52 | - buf = writeMessageToBuffer(ospfMessage, interfaceState); | 47 | + buf = writeMessageToBytes(ospfMessage, interfaceIndex, interfaceState); |
| 53 | break; | 48 | break; |
| 54 | default: | 49 | default: |
| 55 | log.debug("Message Writer[Encoder] - Unknown Message to encode..!!!"); | 50 | log.debug("Message Writer[Encoder] - Unknown Message to encode..!!!"); |
| ... | @@ -60,14 +55,13 @@ public class OspfMessageWriter { | ... | @@ -60,14 +55,13 @@ public class OspfMessageWriter { |
| 60 | } | 55 | } |
| 61 | 56 | ||
| 62 | /** | 57 | /** |
| 63 | - * Writes an OSPF Message to channel buffer. | 58 | + * Writes an OSPF Message to byte array. |
| 64 | * | 59 | * |
| 65 | * @param ospfMessage OSPF Message instance | 60 | * @param ospfMessage OSPF Message instance |
| 66 | * @param interfaceState interface state | 61 | * @param interfaceState interface state |
| 67 | - * @return channelBuffer instance | 62 | + * @return message as byte array |
| 68 | */ | 63 | */ |
| 69 | - private ChannelBuffer writeMessageToBuffer(OspfMessage ospfMessage, int interfaceState) throws Exception { | 64 | + private byte[] writeMessageToBytes(OspfMessage ospfMessage, int interfaceIndex, int interfaceState) { |
| 70 | - ChannelBuffer channelBuffer = null; | ||
| 71 | byte[] ospfMessageAsByte = ospfMessage.asBytes(); | 65 | byte[] ospfMessageAsByte = ospfMessage.asBytes(); |
| 72 | //Add the length and checksum in byte array at length position 2 & 3 and Checksum position | 66 | //Add the length and checksum in byte array at length position 2 & 3 and Checksum position |
| 73 | ospfMessageAsByte = OspfUtil.addLengthAndCheckSum(ospfMessageAsByte, OspfUtil.OSPFPACKET_LENGTH_POS1, | 67 | ospfMessageAsByte = OspfUtil.addLengthAndCheckSum(ospfMessageAsByte, OspfUtil.OSPFPACKET_LENGTH_POS1, |
| ... | @@ -76,16 +70,13 @@ public class OspfMessageWriter { | ... | @@ -76,16 +70,13 @@ public class OspfMessageWriter { |
| 76 | OspfUtil.OSPFPACKET_CHECKSUM_POS2); | 70 | OspfUtil.OSPFPACKET_CHECKSUM_POS2); |
| 77 | //Add Interface State Info and destination IP as metadata | 71 | //Add Interface State Info and destination IP as metadata |
| 78 | if (interfaceState == OspfParameters.DR || interfaceState == OspfParameters.BDR) { | 72 | if (interfaceState == OspfParameters.DR || interfaceState == OspfParameters.BDR) { |
| 79 | - ospfMessageAsByte = OspfUtil.addMetadata(ospfMessageAsByte, OspfUtil.JOIN_ALL_DROUTERS, | 73 | + ospfMessageAsByte = OspfUtil.addMetadata(interfaceIndex, ospfMessageAsByte, OspfUtil.JOIN_ALL_DROUTERS, |
| 80 | ospfMessage.destinationIp()); | 74 | ospfMessage.destinationIp()); |
| 81 | } else { | 75 | } else { |
| 82 | - ospfMessageAsByte = OspfUtil.addMetadata(ospfMessageAsByte, OspfUtil.ONLY_ALL_SPF_ROUTERS, | 76 | + ospfMessageAsByte = OspfUtil.addMetadata(interfaceIndex, ospfMessageAsByte, OspfUtil.ONLY_ALL_SPF_ROUTERS, |
| 83 | ospfMessage.destinationIp()); | 77 | ospfMessage.destinationIp()); |
| 84 | } | 78 | } |
| 85 | 79 | ||
| 86 | - channelBuffer = ChannelBuffers.buffer(ospfMessageAsByte.length); | 80 | + return ospfMessageAsByte; |
| 87 | - channelBuffer.writeBytes(ospfMessageAsByte); | ||
| 88 | - | ||
| 89 | - return channelBuffer; | ||
| 90 | } | 81 | } |
| 91 | } | 82 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeader.java
| ... | @@ -18,8 +18,9 @@ package org.onosproject.ospf.protocol.ospfpacket; | ... | @@ -18,8 +18,9 @@ package org.onosproject.ospf.protocol.ospfpacket; |
| 18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
| 19 | import org.jboss.netty.buffer.ChannelBuffer; | 19 | import org.jboss.netty.buffer.ChannelBuffer; |
| 20 | import org.onlab.packet.Ip4Address; | 20 | import org.onlab.packet.Ip4Address; |
| 21 | +import org.onosproject.ospf.controller.OspfMessage; | ||
| 22 | +import org.onosproject.ospf.controller.OspfPacketType; | ||
| 21 | import org.onosproject.ospf.exceptions.OspfParseException; | 23 | import org.onosproject.ospf.exceptions.OspfParseException; |
| 22 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | ||
| 23 | 24 | ||
| 24 | /** | 25 | /** |
| 25 | * Defines the OSPF Packet Header, fields and access methods. | 26 | * Defines the OSPF Packet Header, fields and access methods. |
| ... | @@ -57,6 +58,7 @@ public class OspfPacketHeader implements OspfMessage { | ... | @@ -57,6 +58,7 @@ public class OspfPacketHeader implements OspfMessage { |
| 57 | private int authentication; | 58 | private int authentication; |
| 58 | private Ip4Address destinationIp; | 59 | private Ip4Address destinationIp; |
| 59 | private Ip4Address sourceIp; | 60 | private Ip4Address sourceIp; |
| 61 | + private int interfaceIndex; | ||
| 60 | 62 | ||
| 61 | /** | 63 | /** |
| 62 | * Gets the source IP. | 64 | * Gets the source IP. |
| ... | @@ -256,11 +258,30 @@ public class OspfPacketHeader implements OspfMessage { | ... | @@ -256,11 +258,30 @@ public class OspfPacketHeader implements OspfMessage { |
| 256 | } | 258 | } |
| 257 | 259 | ||
| 258 | /** | 260 | /** |
| 261 | + * Returns the interface index on which the message received. | ||
| 262 | + * | ||
| 263 | + * @return interface index on which the message received | ||
| 264 | + */ | ||
| 265 | + public int interfaceIndex() { | ||
| 266 | + return interfaceIndex; | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + /** | ||
| 270 | + * Sets the interface index on which the message received. | ||
| 271 | + * | ||
| 272 | + * @param interfaceIndex interface index on which the message received | ||
| 273 | + */ | ||
| 274 | + public void setInterfaceIndex(int interfaceIndex) { | ||
| 275 | + this.interfaceIndex = interfaceIndex; | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + /** | ||
| 259 | * Populates the header from the packetHeader instance. | 279 | * Populates the header from the packetHeader instance. |
| 260 | * | 280 | * |
| 261 | * @param ospfPacketHeader packet header instance. | 281 | * @param ospfPacketHeader packet header instance. |
| 262 | */ | 282 | */ |
| 263 | public void populateHeader(OspfPacketHeader ospfPacketHeader) { | 283 | public void populateHeader(OspfPacketHeader ospfPacketHeader) { |
| 284 | + this.setInterfaceIndex(ospfPacketHeader.interfaceIndex()); | ||
| 264 | this.setSourceIp(ospfPacketHeader.sourceIp()); | 285 | this.setSourceIp(ospfPacketHeader.sourceIp()); |
| 265 | this.setOspfVer(ospfPacketHeader.ospfVersion()); | 286 | this.setOspfVer(ospfPacketHeader.ospfVersion()); |
| 266 | this.setOspftype(ospfPacketHeader.ospfType()); | 287 | this.setOspftype(ospfPacketHeader.ospfType()); | ... | ... |
| ... | @@ -23,7 +23,7 @@ import org.onosproject.ospf.exceptions.OspfParseException; | ... | @@ -23,7 +23,7 @@ import org.onosproject.ospf.exceptions.OspfParseException; |
| 23 | import org.onosproject.ospf.protocol.lsa.LsaHeader; | 23 | import org.onosproject.ospf.protocol.lsa.LsaHeader; |
| 24 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; | 24 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; |
| 25 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 25 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 26 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | 26 | +import org.onosproject.ospf.controller.OspfPacketType; |
| 27 | import org.onosproject.ospf.protocol.util.OspfParameters; | 27 | import org.onosproject.ospf.protocol.util.OspfParameters; |
| 28 | import org.onosproject.ospf.protocol.util.OspfUtil; | 28 | import org.onosproject.ospf.protocol.util.OspfUtil; |
| 29 | import org.slf4j.Logger; | 29 | import org.slf4j.Logger; | ... | ... |
| ... | @@ -22,7 +22,7 @@ import org.onlab.packet.Ip4Address; | ... | @@ -22,7 +22,7 @@ import org.onlab.packet.Ip4Address; |
| 22 | import org.onosproject.ospf.exceptions.OspfErrorType; | 22 | import org.onosproject.ospf.exceptions.OspfErrorType; |
| 23 | import org.onosproject.ospf.exceptions.OspfParseException; | 23 | import org.onosproject.ospf.exceptions.OspfParseException; |
| 24 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 24 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 25 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | 25 | +import org.onosproject.ospf.controller.OspfPacketType; |
| 26 | import org.onosproject.ospf.protocol.util.OspfUtil; | 26 | import org.onosproject.ospf.protocol.util.OspfUtil; |
| 27 | import org.slf4j.Logger; | 27 | import org.slf4j.Logger; |
| 28 | import org.slf4j.LoggerFactory; | 28 | import org.slf4j.LoggerFactory; | ... | ... |
| ... | @@ -23,7 +23,7 @@ import org.onosproject.ospf.exceptions.OspfParseException; | ... | @@ -23,7 +23,7 @@ import org.onosproject.ospf.exceptions.OspfParseException; |
| 23 | import org.onosproject.ospf.protocol.lsa.LsaHeader; | 23 | import org.onosproject.ospf.protocol.lsa.LsaHeader; |
| 24 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; | 24 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; |
| 25 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 25 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 26 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | 26 | +import org.onosproject.ospf.controller.OspfPacketType; |
| 27 | import org.onosproject.ospf.protocol.util.OspfParameters; | 27 | import org.onosproject.ospf.protocol.util.OspfParameters; |
| 28 | import org.onosproject.ospf.protocol.util.OspfUtil; | 28 | import org.onosproject.ospf.protocol.util.OspfUtil; |
| 29 | import org.slf4j.Logger; | 29 | import org.slf4j.Logger; | ... | ... |
| ... | @@ -22,7 +22,7 @@ import org.onlab.packet.Ip4Address; | ... | @@ -22,7 +22,7 @@ import org.onlab.packet.Ip4Address; |
| 22 | import org.onosproject.ospf.exceptions.OspfParseException; | 22 | import org.onosproject.ospf.exceptions.OspfParseException; |
| 23 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 23 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 24 | import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket; | 24 | import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket; |
| 25 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | 25 | +import org.onosproject.ospf.controller.OspfPacketType; |
| 26 | import org.onosproject.ospf.protocol.util.OspfUtil; | 26 | import org.onosproject.ospf.protocol.util.OspfUtil; |
| 27 | import org.slf4j.Logger; | 27 | import org.slf4j.Logger; |
| 28 | import org.slf4j.LoggerFactory; | 28 | import org.slf4j.LoggerFactory; | ... | ... |
| ... | @@ -32,7 +32,7 @@ import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9; | ... | @@ -32,7 +32,7 @@ import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9; |
| 32 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; | 32 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; |
| 33 | import org.onosproject.ospf.protocol.lsa.types.SummaryLsa; | 33 | import org.onosproject.ospf.protocol.lsa.types.SummaryLsa; |
| 34 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 34 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 35 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | 35 | +import org.onosproject.ospf.controller.OspfPacketType; |
| 36 | import org.onosproject.ospf.protocol.util.OspfParameters; | 36 | import org.onosproject.ospf.protocol.util.OspfParameters; |
| 37 | import org.onosproject.ospf.protocol.util.OspfUtil; | 37 | import org.onosproject.ospf.protocol.util.OspfUtil; |
| 38 | import org.slf4j.Logger; | 38 | import org.slf4j.Logger; | ... | ... |
| ... | @@ -25,7 +25,7 @@ import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa11; | ... | @@ -25,7 +25,7 @@ import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa11; |
| 25 | import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9; | 25 | import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9; |
| 26 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; | 26 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; |
| 27 | import org.onosproject.ospf.protocol.lsa.types.SummaryLsa; | 27 | import org.onosproject.ospf.protocol.lsa.types.SummaryLsa; |
| 28 | -import org.onosproject.ospf.protocol.ospfpacket.OspfMessage; | 28 | +import org.onosproject.ospf.controller.OspfMessage; |
| 29 | import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket; | 29 | import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket; |
| 30 | import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket; | 30 | import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket; |
| 31 | import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; | 31 | import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; | ... | ... |
| ... | @@ -31,20 +31,55 @@ public enum OspfInterfaceState { | ... | @@ -31,20 +31,55 @@ public enum OspfInterfaceState { |
| 31 | private int value; | 31 | private int value; |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | - * Creates an instance of Interface State. | 34 | + * Creates an instance of interface state. |
| 35 | * | 35 | * |
| 36 | - * @param value Interface State value | 36 | + * @param value Interface state value |
| 37 | */ | 37 | */ |
| 38 | OspfInterfaceState(int value) { | 38 | OspfInterfaceState(int value) { |
| 39 | this.value = value; | 39 | this.value = value; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | /** | 42 | /** |
| 43 | - * Gets value for Interface State. | 43 | + * Gets value for Interface state. |
| 44 | * | 44 | * |
| 45 | - * @return value Interface State | 45 | + * @return value Interface state |
| 46 | */ | 46 | */ |
| 47 | public int value() { | 47 | public int value() { |
| 48 | return value; | 48 | return value; |
| 49 | } | 49 | } |
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * Gets interface state. | ||
| 53 | + * | ||
| 54 | + * @return interface state | ||
| 55 | + */ | ||
| 56 | + public String interfaceState() { | ||
| 57 | + String state = null; | ||
| 58 | + switch (value) { | ||
| 59 | + case 1: | ||
| 60 | + state = "DOWN"; | ||
| 61 | + break; | ||
| 62 | + case 2: | ||
| 63 | + state = "LOOPBACK"; | ||
| 64 | + break; | ||
| 65 | + case 3: | ||
| 66 | + state = "WAITING"; | ||
| 67 | + break; | ||
| 68 | + case 4: | ||
| 69 | + state = "POINT2POINT"; | ||
| 70 | + break; | ||
| 71 | + case 5: | ||
| 72 | + state = "DROTHER"; | ||
| 73 | + break; | ||
| 74 | + case 6: | ||
| 75 | + state = "BDR"; | ||
| 76 | + break; | ||
| 77 | + case 7: | ||
| 78 | + state = "DR"; | ||
| 79 | + break; | ||
| 80 | + default: | ||
| 81 | + break; | ||
| 82 | + } | ||
| 83 | + return state; | ||
| 84 | + } | ||
| 50 | } | 85 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -36,10 +36,11 @@ import java.util.StringTokenizer; | ... | @@ -36,10 +36,11 @@ import java.util.StringTokenizer; |
| 36 | * Representation of an OSPF constants and utility methods. | 36 | * Representation of an OSPF constants and utility methods. |
| 37 | */ | 37 | */ |
| 38 | public final class OspfUtil { | 38 | public final class OspfUtil { |
| 39 | - | ||
| 40 | public static final int OSPF_VERSION_2 = 2; | 39 | public static final int OSPF_VERSION_2 = 2; |
| 41 | public static final int OSPF_VERSION = OSPF_VERSION_2; | 40 | public static final int OSPF_VERSION = OSPF_VERSION_2; |
| 42 | public static final int PACKET_MINIMUM_LENGTH = 24; | 41 | public static final int PACKET_MINIMUM_LENGTH = 24; |
| 42 | + public static final int METADATA_LEN = 5; | ||
| 43 | + public static final int MINIMUM_FRAME_LEN = 1487; | ||
| 43 | public static final int OSPF_HEADER_LENGTH = 24; | 44 | public static final int OSPF_HEADER_LENGTH = 24; |
| 44 | public static final int LSA_HEADER_LENGTH = 20; | 45 | public static final int LSA_HEADER_LENGTH = 20; |
| 45 | public static final int DD_HEADER_LENGTH = OSPF_HEADER_LENGTH + 8; | 46 | public static final int DD_HEADER_LENGTH = OSPF_HEADER_LENGTH + 8; |
| ... | @@ -52,6 +53,8 @@ public final class OspfUtil { | ... | @@ -52,6 +53,8 @@ public final class OspfUtil { |
| 52 | public static final int LSAPACKET_CHECKSUM_POS2 = 17; | 53 | public static final int LSAPACKET_CHECKSUM_POS2 = 17; |
| 53 | public static final Ip4Address ALL_SPF_ROUTERS = Ip4Address.valueOf("224.0.0.5"); | 54 | public static final Ip4Address ALL_SPF_ROUTERS = Ip4Address.valueOf("224.0.0.5"); |
| 54 | public static final Ip4Address ALL_DROUTERS = Ip4Address.valueOf("224.0.0.6"); | 55 | public static final Ip4Address ALL_DROUTERS = Ip4Address.valueOf("224.0.0.6"); |
| 56 | + public static final Ip4Address DEFAULTIP = Ip4Address.valueOf("0.0.0.0"); | ||
| 57 | + public static final int RETRANSMITINTERVAL = 5; | ||
| 55 | public static final int ONLY_ALL_SPF_ROUTERS = 1; | 58 | public static final int ONLY_ALL_SPF_ROUTERS = 1; |
| 56 | public static final int JOIN_ALL_DROUTERS = 2; | 59 | public static final int JOIN_ALL_DROUTERS = 2; |
| 57 | public static final int INITIALIZE_SET = 1; | 60 | public static final int INITIALIZE_SET = 1; |
| ... | @@ -62,9 +65,16 @@ public final class OspfUtil { | ... | @@ -62,9 +65,16 @@ public final class OspfUtil { |
| 62 | public static final int NOT_MASTER = 0; | 65 | public static final int NOT_MASTER = 0; |
| 63 | public static final int NOT_ASSIGNED = 0; | 66 | public static final int NOT_ASSIGNED = 0; |
| 64 | public static final int FOUR_BYTES = 4; | 67 | public static final int FOUR_BYTES = 4; |
| 68 | + public static final int FIVE_BYTES = 5; | ||
| 65 | public static final int EIGHT_BYTES = 8; | 69 | public static final int EIGHT_BYTES = 8; |
| 66 | public static final int TWELVE_BYTES = 12; | 70 | public static final int TWELVE_BYTES = 12; |
| 67 | public static final int EXTERNAL_DESTINATION_LENGTH = 12; | 71 | public static final int EXTERNAL_DESTINATION_LENGTH = 12; |
| 72 | + public static final String SHOST = "127.0.0.1"; | ||
| 73 | + public static final int SPORT = 7000; | ||
| 74 | + public static final int MTU = 1500; | ||
| 75 | + public static final char CONFIG_LENGTH = 1498; | ||
| 76 | + public static final char ROUTER_PRIORITY = 0; | ||
| 77 | + public static final int HELLO_PACKET_OPTIONS = 2; | ||
| 68 | private static final Logger log = | 78 | private static final Logger log = |
| 69 | LoggerFactory.getLogger(OspfUtil.class); | 79 | LoggerFactory.getLogger(OspfUtil.class); |
| 70 | 80 | ||
| ... | @@ -398,18 +408,21 @@ public final class OspfUtil { | ... | @@ -398,18 +408,21 @@ public final class OspfUtil { |
| 398 | /** | 408 | /** |
| 399 | * Adds metadata to ospf packet like whether to join multi cast group and destination IP. | 409 | * Adds metadata to ospf packet like whether to join multi cast group and destination IP. |
| 400 | * | 410 | * |
| 411 | + * @param interfaceIndex interface index | ||
| 401 | * @param ospfPacket OSPF packet | 412 | * @param ospfPacket OSPF packet |
| 402 | * @param allDroutersValue whether to join multi cast or not | 413 | * @param allDroutersValue whether to join multi cast or not |
| 403 | * @param destinationIp destination ip address | 414 | * @param destinationIp destination ip address |
| 404 | * @return byte array | 415 | * @return byte array |
| 405 | */ | 416 | */ |
| 406 | - public static byte[] addMetadata(byte[] ospfPacket, int allDroutersValue, Ip4Address destinationIp) { | 417 | + public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue, |
| 418 | + Ip4Address destinationIp) { | ||
| 407 | byte[] packet; | 419 | byte[] packet; |
| 420 | + byte[] interfaceIndexByteVal = {(byte) interfaceIndex}; | ||
| 408 | byte[] allDroutersByteVal = {(byte) allDroutersValue}; | 421 | byte[] allDroutersByteVal = {(byte) allDroutersValue}; |
| 409 | byte[] destIpAsBytes = destinationIp.toOctets(); | 422 | byte[] destIpAsBytes = destinationIp.toOctets(); |
| 410 | - byte[] metadata = Bytes.concat(allDroutersByteVal, destIpAsBytes); | 423 | + byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal); |
| 411 | - | 424 | + metadata = Bytes.concat(metadata, destIpAsBytes); |
| 412 | - packet = Bytes.concat(metadata, ospfPacket); | 425 | + packet = Bytes.concat(ospfPacket, metadata); |
| 413 | 426 | ||
| 414 | return packet; | 427 | return packet; |
| 415 | } | 428 | } | ... | ... |
| ... | @@ -20,6 +20,7 @@ import org.jboss.netty.buffer.ChannelBuffers; | ... | @@ -20,6 +20,7 @@ import org.jboss.netty.buffer.ChannelBuffers; |
| 20 | import org.junit.After; | 20 | import org.junit.After; |
| 21 | import org.junit.Before; | 21 | import org.junit.Before; |
| 22 | import org.junit.Test; | 22 | import org.junit.Test; |
| 23 | +import org.onosproject.ospf.protocol.util.OspfUtil; | ||
| 23 | 24 | ||
| 24 | import static org.hamcrest.CoreMatchers.is; | 25 | import static org.hamcrest.CoreMatchers.is; |
| 25 | import static org.hamcrest.CoreMatchers.notNullValue; | 26 | import static org.hamcrest.CoreMatchers.notNullValue; |
| ... | @@ -31,17 +32,17 @@ import static org.hamcrest.MatcherAssert.assertThat; | ... | @@ -31,17 +32,17 @@ import static org.hamcrest.MatcherAssert.assertThat; |
| 31 | 32 | ||
| 32 | public class OspfMessageReaderTest { | 33 | public class OspfMessageReaderTest { |
| 33 | 34 | ||
| 34 | - private final byte[] packet1 = {1, 1, 1, 1, 2, 1, 0, 44, -64, -88, -86, 8, | 35 | + private final byte[] packet1 = {2, 1, 0, 44, -64, -88, -86, 8, |
| 35 | 0, 0, 0, 1, 39, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, | 36 | 0, 0, 0, 1, 39, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, |
| 36 | 10, 2, 1, 0, 0, 0, 40, -64, -88, -86, 8, 0, 0, 0, 0}; | 37 | 10, 2, 1, 0, 0, 0, 40, -64, -88, -86, 8, 0, 0, 0, 0}; |
| 37 | - private final byte[] packet2 = {1, 1, 1, 1, 2, 2, 0, 52, -64, -88, -86, 8, 0, | 38 | + private final byte[] packet2 = {2, 2, 0, 52, -64, -88, -86, 8, 0, |
| 38 | 0, 0, 1, -96, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119, | 39 | 0, 0, 1, -96, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119, |
| 39 | -87, 126, 0, 23, 2, 1, 10, 10, 10, 10, 10, 10, 10, 10, -128, 0, 0, 6, | 40 | -87, 126, 0, 23, 2, 1, 10, 10, 10, 10, 10, 10, 10, 10, -128, 0, 0, 6, |
| 40 | -69, 26, 0, 36}; | 41 | -69, 26, 0, 36}; |
| 41 | - private final byte[] packet3 = {1, 1, 1, 1, 2, 3, 0, 36, -64, -88, -86, 3, 0, | 42 | + private final byte[] packet3 = {2, 3, 0, 36, -64, -88, -86, 3, 0, |
| 42 | 0, 0, 1, -67, -57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, | 43 | 0, 0, 1, -67, -57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, |
| 43 | -86, 8, -64, -88, -86, 8}; | 44 | -86, 8, -64, -88, -86, 8}; |
| 44 | - private final byte[] packet4 = {1, 1, 1, 1, 2, 4, 1, 36, -64, -88, -86, 3, 0, | 45 | + private final byte[] packet4 = {2, 4, 1, 36, -64, -88, -86, 3, 0, |
| 45 | 0, 0, 1, 54, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, | 46 | 0, 0, 1, 54, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, |
| 46 | 2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, | 47 | 2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, |
| 47 | 0, 1, 58, -100, 0, 48, 2, 0, 0, 2, -64, -88, -86, | 48 | 0, 1, 58, -100, 0, 48, 2, 0, 0, 2, -64, -88, -86, |
| ... | @@ -62,7 +63,7 @@ public class OspfMessageReaderTest { | ... | @@ -62,7 +63,7 @@ public class OspfMessageReaderTest { |
| 62 | 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, -84, 0, -64, | 63 | 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, -84, 0, -64, |
| 63 | -88, -86, 2, -128, 0, 0, 1, 51, 65, 0, 36, -1, -1, -1, 0, | 64 | -88, -86, 2, -128, 0, 0, 1, 51, 65, 0, 36, -1, -1, -1, 0, |
| 64 | -128, 0, 0, 20, -64, -88, -86, 10, 0, 0, 0, 0}; | 65 | -128, 0, 0, 20, -64, -88, -86, 10, 0, 0, 0, 0}; |
| 65 | - private final byte[] packet5 = {1, 1, 1, 1, 2, 5, 0, 44, -64, -88, -86, 8, 0, 0, | 66 | + private final byte[] packet5 = {2, 5, 0, 44, -64, -88, -86, 8, 0, 0, |
| 66 | 0, 1, -30, -12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 16, 2, 1, -64, -88, -86, | 67 | 0, 1, -30, -12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 16, 2, 1, -64, -88, -86, |
| 67 | 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48}; | 68 | 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48}; |
| 68 | private OspfMessageReader ospfMessageReader; | 69 | private OspfMessageReader ospfMessageReader; |
| ... | @@ -84,21 +85,39 @@ public class OspfMessageReaderTest { | ... | @@ -84,21 +85,39 @@ public class OspfMessageReaderTest { |
| 84 | */ | 85 | */ |
| 85 | @Test | 86 | @Test |
| 86 | public void testReadFromBuffer() throws Exception { | 87 | public void testReadFromBuffer() throws Exception { |
| 87 | - channelBuffer = ChannelBuffers.copiedBuffer(packet1); | 88 | + channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet1)); |
| 88 | ospfMessageReader.readFromBuffer(channelBuffer); | 89 | ospfMessageReader.readFromBuffer(channelBuffer); |
| 89 | 90 | ||
| 90 | - channelBuffer = ChannelBuffers.copiedBuffer(packet2); | 91 | + channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet2)); |
| 91 | ospfMessageReader.readFromBuffer(channelBuffer); | 92 | ospfMessageReader.readFromBuffer(channelBuffer); |
| 92 | 93 | ||
| 93 | - channelBuffer = ChannelBuffers.copiedBuffer(packet3); | 94 | + channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet3)); |
| 94 | ospfMessageReader.readFromBuffer(channelBuffer); | 95 | ospfMessageReader.readFromBuffer(channelBuffer); |
| 95 | 96 | ||
| 96 | - channelBuffer = ChannelBuffers.copiedBuffer(packet4); | 97 | + channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet4)); |
| 97 | ospfMessageReader.readFromBuffer(channelBuffer); | 98 | ospfMessageReader.readFromBuffer(channelBuffer); |
| 98 | 99 | ||
| 99 | - channelBuffer = ChannelBuffers.copiedBuffer(packet5); | 100 | + channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet5)); |
| 100 | ospfMessageReader.readFromBuffer(channelBuffer); | 101 | ospfMessageReader.readFromBuffer(channelBuffer); |
| 101 | assertThat(ospfMessageReader, is(notNullValue())); | 102 | assertThat(ospfMessageReader, is(notNullValue())); |
| 103 | + } | ||
| 102 | 104 | ||
| 105 | + /** | ||
| 106 | + * Frames the packet to min frame length. | ||
| 107 | + * | ||
| 108 | + * @param ospfPacket OSPF packet | ||
| 109 | + * @return OSPF packet as byte array | ||
| 110 | + */ | ||
| 111 | + private byte[] framePacket(byte[] ospfPacket) { | ||
| 112 | + //Set the length of the packet | ||
| 113 | + //Get the total length of the packet | ||
| 114 | + int length = ospfPacket.length; | ||
| 115 | + //PDU_LENGTH + 1 byte for interface index | ||
| 116 | + if (length < OspfUtil.MINIMUM_FRAME_LEN) { | ||
| 117 | + byte[] bytes = new byte[OspfUtil.MINIMUM_FRAME_LEN + 5]; | ||
| 118 | + System.arraycopy(ospfPacket, 0, bytes, 0, length); | ||
| 119 | + return bytes; | ||
| 120 | + } | ||
| 121 | + return ospfPacket; | ||
| 103 | } | 122 | } |
| 104 | } | 123 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -57,10 +57,10 @@ public class OspfMessageWriterTest { | ... | @@ -57,10 +57,10 @@ public class OspfMessageWriterTest { |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /** | 59 | /** |
| 60 | - * Tests writeToBuffer() method. | 60 | + * Tests getMessage() method. |
| 61 | */ | 61 | */ |
| 62 | @Test | 62 | @Test |
| 63 | - public void testWriteToBuffer() throws Exception { | 63 | + public void testGetMessage() throws Exception { |
| 64 | helloPacket = new HelloPacket(); | 64 | helloPacket = new HelloPacket(); |
| 65 | helloPacket.setAuthType(1); | 65 | helloPacket.setAuthType(1); |
| 66 | helloPacket.setOspftype(1); | 66 | helloPacket.setOspftype(1); |
| ... | @@ -79,12 +79,12 @@ public class OspfMessageWriterTest { | ... | @@ -79,12 +79,12 @@ public class OspfMessageWriterTest { |
| 79 | helloPacket.setBdr(Ip4Address.valueOf("2.2.2.2")); | 79 | helloPacket.setBdr(Ip4Address.valueOf("2.2.2.2")); |
| 80 | helloPacket.addNeighbor(Ip4Address.valueOf("8.8.8.8")); | 80 | helloPacket.addNeighbor(Ip4Address.valueOf("8.8.8.8")); |
| 81 | helloPacket.setDestinationIp(Ip4Address.valueOf("5.5.5.5")); | 81 | helloPacket.setDestinationIp(Ip4Address.valueOf("5.5.5.5")); |
| 82 | - ospfMessageWriter.writeToBuffer(helloPacket, 7, 1); | 82 | + ospfMessageWriter.getMessage(helloPacket, 7, 1); |
| 83 | assertThat(ospfMessageWriter, is(notNullValue())); | 83 | assertThat(ospfMessageWriter, is(notNullValue())); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | @Test(expected = Exception.class) | 86 | @Test(expected = Exception.class) |
| 87 | - public void testWriteToBuffer1() throws Exception { | 87 | + public void testGetMessage1() throws Exception { |
| 88 | 88 | ||
| 89 | ddPacket = new DdPacket(); | 89 | ddPacket = new DdPacket(); |
| 90 | ddPacket.setAuthType(1); | 90 | ddPacket.setAuthType(1); |
| ... | @@ -95,12 +95,12 @@ public class OspfMessageWriterTest { | ... | @@ -95,12 +95,12 @@ public class OspfMessageWriterTest { |
| 95 | ddPacket.setAuthentication(2); | 95 | ddPacket.setAuthentication(2); |
| 96 | ddPacket.setOspfPacLength(48); | 96 | ddPacket.setOspfPacLength(48); |
| 97 | ddPacket.setOspfVer(2); | 97 | ddPacket.setOspfVer(2); |
| 98 | - ospfMessageWriter.writeToBuffer(ddPacket, 1, 1); | 98 | + ospfMessageWriter.getMessage(ddPacket, 1, 1); |
| 99 | assertThat(ospfMessageWriter, is(notNullValue())); | 99 | assertThat(ospfMessageWriter, is(notNullValue())); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | @Test(expected = Exception.class) | 102 | @Test(expected = Exception.class) |
| 103 | - public void testWriteToBuffer2() throws Exception { | 103 | + public void testGetMessage2() throws Exception { |
| 104 | 104 | ||
| 105 | lsAck = new LsAcknowledge(); | 105 | lsAck = new LsAcknowledge(); |
| 106 | lsAck.setAuthType(1); | 106 | lsAck.setAuthType(1); |
| ... | @@ -111,12 +111,12 @@ public class OspfMessageWriterTest { | ... | @@ -111,12 +111,12 @@ public class OspfMessageWriterTest { |
| 111 | lsAck.setAuthentication(2); | 111 | lsAck.setAuthentication(2); |
| 112 | lsAck.setOspfPacLength(48); | 112 | lsAck.setOspfPacLength(48); |
| 113 | lsAck.setOspfVer(2); | 113 | lsAck.setOspfVer(2); |
| 114 | - ospfMessageWriter.writeToBuffer(lsAck, 1, 1); | 114 | + ospfMessageWriter.getMessage(lsAck, 1, 1); |
| 115 | assertThat(ospfMessageWriter, is(notNullValue())); | 115 | assertThat(ospfMessageWriter, is(notNullValue())); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | @Test(expected = Exception.class) | 118 | @Test(expected = Exception.class) |
| 119 | - public void testWriteToBuffer3() throws Exception { | 119 | + public void testGetMessage3() throws Exception { |
| 120 | lsReq = new LsRequest(); | 120 | lsReq = new LsRequest(); |
| 121 | lsReq.setAuthType(1); | 121 | lsReq.setAuthType(1); |
| 122 | lsReq.setOspftype(3); | 122 | lsReq.setOspftype(3); |
| ... | @@ -126,12 +126,15 @@ public class OspfMessageWriterTest { | ... | @@ -126,12 +126,15 @@ public class OspfMessageWriterTest { |
| 126 | lsReq.setAuthentication(2); | 126 | lsReq.setAuthentication(2); |
| 127 | lsReq.setOspfPacLength(48); | 127 | lsReq.setOspfPacLength(48); |
| 128 | lsReq.setOspfVer(2); | 128 | lsReq.setOspfVer(2); |
| 129 | - ospfMessageWriter.writeToBuffer(lsReq, 1, 1); | 129 | + ospfMessageWriter.getMessage(lsReq, 1, 1); |
| 130 | assertThat(ospfMessageWriter, is(notNullValue())); | 130 | assertThat(ospfMessageWriter, is(notNullValue())); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | + /** | ||
| 134 | + * Tests getMessage() method. | ||
| 135 | + */ | ||
| 133 | @Test(expected = Exception.class) | 136 | @Test(expected = Exception.class) |
| 134 | - public void testWriteToBuffer4() throws Exception { | 137 | + public void testGetMessage4() throws Exception { |
| 135 | lsUpdate = new LsUpdate(); | 138 | lsUpdate = new LsUpdate(); |
| 136 | lsUpdate.setAuthType(1); | 139 | lsUpdate.setAuthType(1); |
| 137 | lsUpdate.setOspftype(3); | 140 | lsUpdate.setOspftype(3); |
| ... | @@ -141,15 +144,15 @@ public class OspfMessageWriterTest { | ... | @@ -141,15 +144,15 @@ public class OspfMessageWriterTest { |
| 141 | lsUpdate.setAuthentication(2); | 144 | lsUpdate.setAuthentication(2); |
| 142 | lsUpdate.setOspfPacLength(48); | 145 | lsUpdate.setOspfPacLength(48); |
| 143 | lsUpdate.setOspfVer(2); | 146 | lsUpdate.setOspfVer(2); |
| 144 | - ospfMessageWriter.writeToBuffer(lsUpdate, 1, 1); | 147 | + ospfMessageWriter.getMessage(lsUpdate, 1, 1); |
| 145 | assertThat(ospfMessageWriter, is(notNullValue())); | 148 | assertThat(ospfMessageWriter, is(notNullValue())); |
| 146 | } | 149 | } |
| 147 | 150 | ||
| 148 | /** | 151 | /** |
| 149 | - * Tests writeToBuffer() method. | 152 | + * Tests getMessage() method. |
| 150 | */ | 153 | */ |
| 151 | @Test(expected = Exception.class) | 154 | @Test(expected = Exception.class) |
| 152 | - public void testWriteToBuffer5() throws Exception { | 155 | + public void testGetMessage5() throws Exception { |
| 153 | lsAck = new LsAcknowledge(); | 156 | lsAck = new LsAcknowledge(); |
| 154 | lsAck.setAuthType(1); | 157 | lsAck.setAuthType(1); |
| 155 | lsAck.setOspftype(5); | 158 | lsAck.setOspftype(5); |
| ... | @@ -159,6 +162,6 @@ public class OspfMessageWriterTest { | ... | @@ -159,6 +162,6 @@ public class OspfMessageWriterTest { |
| 159 | lsAck.setAuthentication(2); | 162 | lsAck.setAuthentication(2); |
| 160 | lsAck.setOspfPacLength(48); | 163 | lsAck.setOspfPacLength(48); |
| 161 | lsAck.setOspfVer(2); | 164 | lsAck.setOspfVer(2); |
| 162 | - ospfMessageWriter.writeToBuffer(lsAck, 1, 1); | 165 | + ospfMessageWriter.getMessage(lsAck, 1, 1); |
| 163 | } | 166 | } |
| 164 | } | 167 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -22,10 +22,10 @@ import org.junit.Assert; | ... | @@ -22,10 +22,10 @@ import org.junit.Assert; |
| 22 | import org.junit.Before; | 22 | import org.junit.Before; |
| 23 | import org.junit.Test; | 23 | import org.junit.Test; |
| 24 | import org.onlab.packet.Ip4Address; | 24 | import org.onlab.packet.Ip4Address; |
| 25 | +import org.onosproject.ospf.controller.OspfPacketType; | ||
| 25 | import org.onosproject.ospf.protocol.lsa.LsaHeader; | 26 | import org.onosproject.ospf.protocol.lsa.LsaHeader; |
| 26 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; | 27 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; |
| 27 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 28 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 28 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | ||
| 29 | 29 | ||
| 30 | import java.util.List; | 30 | import java.util.List; |
| 31 | import java.util.Vector; | 31 | import java.util.Vector; | ... | ... |
| ... | @@ -21,8 +21,8 @@ import org.junit.After; | ... | @@ -21,8 +21,8 @@ import org.junit.After; |
| 21 | import org.junit.Before; | 21 | import org.junit.Before; |
| 22 | import org.junit.Test; | 22 | import org.junit.Test; |
| 23 | import org.onlab.packet.Ip4Address; | 23 | import org.onlab.packet.Ip4Address; |
| 24 | +import org.onosproject.ospf.controller.OspfPacketType; | ||
| 24 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 25 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 25 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | ||
| 26 | 26 | ||
| 27 | import java.util.Vector; | 27 | import java.util.Vector; |
| 28 | 28 | ... | ... |
| ... | @@ -22,10 +22,10 @@ import org.junit.After; | ... | @@ -22,10 +22,10 @@ import org.junit.After; |
| 22 | import org.junit.Before; | 22 | import org.junit.Before; |
| 23 | import org.junit.Test; | 23 | import org.junit.Test; |
| 24 | import org.onlab.packet.Ip4Address; | 24 | import org.onlab.packet.Ip4Address; |
| 25 | +import org.onosproject.ospf.controller.OspfPacketType; | ||
| 25 | import org.onosproject.ospf.protocol.lsa.LsaHeader; | 26 | import org.onosproject.ospf.protocol.lsa.LsaHeader; |
| 26 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; | 27 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; |
| 27 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 28 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 28 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | ||
| 29 | 29 | ||
| 30 | import java.util.List; | 30 | import java.util.List; |
| 31 | 31 | ... | ... |
| ... | @@ -21,9 +21,9 @@ import org.junit.After; | ... | @@ -21,9 +21,9 @@ import org.junit.After; |
| 21 | import org.junit.Before; | 21 | import org.junit.Before; |
| 22 | import org.junit.Test; | 22 | import org.junit.Test; |
| 23 | import org.onlab.packet.Ip4Address; | 23 | import org.onlab.packet.Ip4Address; |
| 24 | +import org.onosproject.ospf.controller.OspfPacketType; | ||
| 24 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 25 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 25 | import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket; | 26 | import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket; |
| 26 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | ||
| 27 | 27 | ||
| 28 | import java.net.UnknownHostException; | 28 | import java.net.UnknownHostException; |
| 29 | import java.util.List; | 29 | import java.util.List; | ... | ... |
| ... | @@ -22,6 +22,7 @@ import org.junit.Before; | ... | @@ -22,6 +22,7 @@ import org.junit.Before; |
| 22 | import org.junit.Test; | 22 | import org.junit.Test; |
| 23 | import org.onlab.packet.Ip4Address; | 23 | import org.onlab.packet.Ip4Address; |
| 24 | import org.onosproject.ospf.controller.OspfLsa; | 24 | import org.onosproject.ospf.controller.OspfLsa; |
| 25 | +import org.onosproject.ospf.controller.OspfPacketType; | ||
| 25 | import org.onosproject.ospf.protocol.lsa.LsaHeader; | 26 | import org.onosproject.ospf.protocol.lsa.LsaHeader; |
| 26 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; | 27 | import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader; |
| 27 | import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa; | 28 | import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa; |
| ... | @@ -33,7 +34,6 @@ import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9; | ... | @@ -33,7 +34,6 @@ import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9; |
| 33 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; | 34 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; |
| 34 | import org.onosproject.ospf.protocol.lsa.types.SummaryLsa; | 35 | import org.onosproject.ospf.protocol.lsa.types.SummaryLsa; |
| 35 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | 36 | import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; |
| 36 | -import org.onosproject.ospf.protocol.util.OspfPacketType; | ||
| 37 | 37 | ||
| 38 | import java.util.List; | 38 | import java.util.List; |
| 39 | import java.util.Vector; | 39 | import java.util.Vector; | ... | ... |
| ... | @@ -229,7 +229,7 @@ public class OspfUtilTest { | ... | @@ -229,7 +229,7 @@ public class OspfUtilTest { |
| 229 | */ | 229 | */ |
| 230 | @Test | 230 | @Test |
| 231 | public void testAddMetadata() throws Exception { | 231 | public void testAddMetadata() throws Exception { |
| 232 | - result1 = OspfUtil.addMetadata(packet, 123, Ip4Address.valueOf("1.1.1.1")); | 232 | + result1 = OspfUtil.addMetadata(2, packet, 1, Ip4Address.valueOf("1.1.1.1")); |
| 233 | assertThat(result1, is(notNullValue())); | 233 | assertThat(result1, is(notNullValue())); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| ... | @@ -251,7 +251,7 @@ public class OspfUtilTest { | ... | @@ -251,7 +251,7 @@ public class OspfUtilTest { |
| 251 | */ | 251 | */ |
| 252 | @Test | 252 | @Test |
| 253 | public void testAddMetaData() throws Exception { | 253 | public void testAddMetaData() throws Exception { |
| 254 | - result1 = OspfUtil.addMetadata(packet, 1, Ip4Address.valueOf("2.2.2.2")); | 254 | + result1 = OspfUtil.addMetadata(2, packet, 1, Ip4Address.valueOf("2.2.2.2")); |
| 255 | assertThat(result1, is(notNullValue())); | 255 | assertThat(result1, is(notNullValue())); |
| 256 | } | 256 | } |
| 257 | 257 | ... | ... |
providers/ospf/BUCK
0 → 100644
| 1 | +BUNDLES = [ | ||
| 2 | + '//protocols/ospf/api:onos-protocols-ospf-api', | ||
| 3 | + '//protocols/ospf/ctl:onos-protocols-ospf-ctl', | ||
| 4 | + '//protocols/ospf/protocol:onos-protocols-ospf-protocol', | ||
| 5 | + '//providers/ospf/cfg:onos-providers-ospf-cfg', | ||
| 6 | + '//providers/ospf/topology:onos-providers-ospf-topology', | ||
| 7 | +] | ||
| 8 | + | ||
| 9 | +onos_app ( | ||
| 10 | + title = 'OSPF Provider', | ||
| 11 | + category = 'Provider', | ||
| 12 | + url = 'http://onosproject.org', | ||
| 13 | + description = 'ONOS OSPF protocol adapters.', | ||
| 14 | + included_bundles = BUNDLES, | ||
| 15 | +) | ||
| 16 | + |
providers/ospf/app/app.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2016-present 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 | +<app name="org.onosproject.ospf" origin="ON.Lab" version="${project.version}" | ||
| 18 | + featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features" | ||
| 19 | + features="${project.artifactId}"> | ||
| 20 | + <description>${project.description}</description> | ||
| 21 | + <artifact>mvn:${project.groupId}/onos-ospf-api/${project.version}</artifact> | ||
| 22 | + <artifact>mvn:${project.groupId}/onos-ospf-ctl/${project.version}</artifact> | ||
| 23 | + <artifact>mvn:${project.groupId}/onos-ospf-protocol/${project.version}</artifact> | ||
| 24 | + <artifact>mvn:${project.groupId}/onos-ospf-provider-topology/${project.version}</artifact> | ||
| 25 | + <artifact>mvn:${project.groupId}/onos-ospf-provider-cfg/${project.version}</artifact> | ||
| 26 | + <artifact>mvn:${project.groupId}/onos-ospf-provider-cli/${project.version}</artifact> | ||
| 27 | +</app> |
providers/ospf/app/features.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2016-present 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 | +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}"> | ||
| 18 | + <feature name="${project.artifactId}" version="${project.version}" | ||
| 19 | + description="${project.description}"> | ||
| 20 | + <feature>onos-api</feature> | ||
| 21 | + <bundle>mvn:${project.groupId}/onos-ospf-api/${project.version}</bundle> | ||
| 22 | + <bundle>mvn:${project.groupId}/onos-ospf-ctl/${project.version}</bundle> | ||
| 23 | + <bundle>mvn:${project.groupId}/onos-ospf-protocol/${project.version}</bundle> | ||
| 24 | + <bundle>mvn:${project.groupId}/onos-ospf-provider-topology/${project.version}</bundle> | ||
| 25 | + <bundle>mvn:${project.groupId}/onos-ospf-provider-cfg/${project.version}</bundle> | ||
| 26 | + <bundle>mvn:${project.groupId}/onos-ospf-provider-cli/${project.version}</bundle> | ||
| 27 | + </feature> | ||
| 28 | +</features> |
providers/ospf/app/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2016-present 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-providers</artifactId> | ||
| 25 | + <version>1.7.0-SNAPSHOT</version> | ||
| 26 | + <relativePath>../pom.xml</relativePath> | ||
| 27 | + </parent> | ||
| 28 | + | ||
| 29 | + <artifactId>onos-ospf-app</artifactId> | ||
| 30 | + <packaging>pom</packaging> | ||
| 31 | + <description>OSPF protocol southbound providers</description> | ||
| 32 | + | ||
| 33 | + <dependencies> | ||
| 34 | + <dependency> | ||
| 35 | + <groupId>org.onosproject</groupId> | ||
| 36 | + <artifactId>onos-ospf-api</artifactId> | ||
| 37 | + <version>${project.version}</version> | ||
| 38 | + </dependency> | ||
| 39 | + <dependency> | ||
| 40 | + <groupId>org.onosproject</groupId> | ||
| 41 | + <artifactId>onos-ospf-ctl</artifactId> | ||
| 42 | + <version>${project.version}</version> | ||
| 43 | + </dependency> | ||
| 44 | + <dependency> | ||
| 45 | + <groupId>org.onosproject</groupId> | ||
| 46 | + <artifactId>onos-ospf-protocol</artifactId> | ||
| 47 | + <version>${project.version}</version> | ||
| 48 | + </dependency> | ||
| 49 | + <dependency> | ||
| 50 | + <groupId>org.onosproject</groupId> | ||
| 51 | + <artifactId>onos-ospf-provider-topology</artifactId> | ||
| 52 | + <version>${project.version}</version> | ||
| 53 | + </dependency> | ||
| 54 | + | ||
| 55 | + <dependency> | ||
| 56 | + <groupId>org.onosproject</groupId> | ||
| 57 | + <artifactId>onos-ospf-provider-cfg</artifactId> | ||
| 58 | + <version>${project.version}</version> | ||
| 59 | + </dependency> | ||
| 60 | + <dependency> | ||
| 61 | + <groupId>org.onosproject</groupId> | ||
| 62 | + <artifactId>onos-ospf-provider-cli</artifactId> | ||
| 63 | + <version>${project.version}</version> | ||
| 64 | + </dependency> | ||
| 65 | + </dependencies> | ||
| 66 | +</project> |
providers/ospf/cfg/BUCK
0 → 100644
providers/ospf/cfg/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2016-present 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="http://maven.apache.org/POM/4.0.0" | ||
| 18 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 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-providers</artifactId> | ||
| 25 | + <version>1.7.0-SNAPSHOT</version> | ||
| 26 | + <relativePath>../pom.xml</relativePath> | ||
| 27 | + </parent> | ||
| 28 | + | ||
| 29 | + <artifactId>onos-ospf-provider-cfg</artifactId> | ||
| 30 | + <packaging>bundle</packaging> | ||
| 31 | + <description>ONOS OSPF Providers</description> | ||
| 32 | + | ||
| 33 | + <dependencies> | ||
| 34 | + <dependency> | ||
| 35 | + <groupId>org.osgi</groupId> | ||
| 36 | + <artifactId>org.osgi.compendium</artifactId> | ||
| 37 | + </dependency> | ||
| 38 | + <dependency> | ||
| 39 | + <groupId>org.onosproject</groupId> | ||
| 40 | + <artifactId>onos-ospf-ctl</artifactId> | ||
| 41 | + <version>${project.version}</version> | ||
| 42 | + </dependency> | ||
| 43 | + <dependency> | ||
| 44 | + <groupId>org.onosproject</groupId> | ||
| 45 | + <artifactId>onos-ospf-api</artifactId> | ||
| 46 | + <version>${project.version}</version> | ||
| 47 | + </dependency> | ||
| 48 | + </dependencies> | ||
| 49 | +</project> |
providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/OspfAppConfig.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 | +package org.onosproject.provider.ospf.cfg.impl; | ||
| 18 | + | ||
| 19 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 20 | +import org.apache.felix.scr.annotations.Reference; | ||
| 21 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 22 | +import org.onlab.osgi.DefaultServiceDirectory; | ||
| 23 | +import org.onosproject.core.ApplicationId; | ||
| 24 | +import org.onosproject.net.config.Config; | ||
| 25 | +import org.onosproject.ospf.controller.OspfController; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Configuration object for OSPF. | ||
| 29 | + */ | ||
| 30 | +public class OspfAppConfig extends Config<ApplicationId> { | ||
| 31 | + public static final String METHOD = "method"; | ||
| 32 | + public static final String ATTRIBUTE = "attribute"; | ||
| 33 | + public static final String PROCESSES = "processes"; | ||
| 34 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 35 | + private OspfController ospfController; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Returns the configuration method, add, delete etc. | ||
| 39 | + * | ||
| 40 | + * @return the configuration method, add, delete etc | ||
| 41 | + */ | ||
| 42 | + public String method() { | ||
| 43 | + return get(METHOD, null); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * Returns the configuration attribute, area, process etc. | ||
| 48 | + * | ||
| 49 | + * @return the configuration attribute, area, process etc | ||
| 50 | + */ | ||
| 51 | + public String attribute() { | ||
| 52 | + return get(ATTRIBUTE, null); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Returns the configured processes. | ||
| 57 | + * | ||
| 58 | + * @return the configured processes | ||
| 59 | + */ | ||
| 60 | + public JsonNode processes() { | ||
| 61 | + JsonNode jsonNodes = object.get(PROCESSES); | ||
| 62 | + | ||
| 63 | + return jsonNodes; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public boolean isValid() { | ||
| 68 | + this.ospfController = DefaultServiceDirectory.getService(OspfController.class); | ||
| 69 | + | ||
| 70 | + return true; | ||
| 71 | + } | ||
| 72 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/OspfCfgProvider.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 | +package org.onosproject.provider.ospf.cfg.impl; | ||
| 17 | + | ||
| 18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 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.Service; | ||
| 23 | +import org.apache.felix.scr.annotations.Reference; | ||
| 24 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 25 | +import org.onosproject.core.ApplicationId; | ||
| 26 | +import org.onosproject.core.CoreService; | ||
| 27 | +import org.onosproject.net.config.ConfigFactory; | ||
| 28 | +import org.onosproject.net.config.NetworkConfigEvent; | ||
| 29 | +import org.onosproject.net.config.NetworkConfigListener; | ||
| 30 | +import org.onosproject.net.config.NetworkConfigRegistry; | ||
| 31 | +import org.onosproject.net.config.NetworkConfigService; | ||
| 32 | +import org.onosproject.net.config.basics.SubjectFactories; | ||
| 33 | +import org.onosproject.net.provider.AbstractProvider; | ||
| 34 | +import org.onosproject.net.provider.ProviderId; | ||
| 35 | +import org.onosproject.ospf.controller.OspfController; | ||
| 36 | +import org.slf4j.Logger; | ||
| 37 | + | ||
| 38 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 39 | + | ||
| 40 | +/** | ||
| 41 | + * Provider which advertises device descriptions to the core. | ||
| 42 | + */ | ||
| 43 | +@Component(immediate = true) | ||
| 44 | +@Service | ||
| 45 | +public class OspfCfgProvider extends AbstractProvider { | ||
| 46 | + | ||
| 47 | + static final String PROVIDER_ID = "org.onosproject.provider.ospf.cfg"; | ||
| 48 | + private static final Logger log = getLogger(OspfCfgProvider.class); | ||
| 49 | + private final ConfigFactory configFactory = | ||
| 50 | + new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, OspfAppConfig.class, "ospfapp") { | ||
| 51 | + @Override | ||
| 52 | + public OspfAppConfig createConfig() { | ||
| 53 | + return new OspfAppConfig(); | ||
| 54 | + } | ||
| 55 | + }; | ||
| 56 | + private final NetworkConfigListener configListener = new InternalConfigListener(); | ||
| 57 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 58 | + protected OspfController ospfController; | ||
| 59 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 60 | + protected CoreService coreService; | ||
| 61 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 62 | + protected NetworkConfigRegistry configRegistry; | ||
| 63 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 64 | + protected NetworkConfigService configService; | ||
| 65 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 66 | + protected OspfController controller; | ||
| 67 | + private ApplicationId appId; | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * Creates an OSPF device provider. | ||
| 71 | + */ | ||
| 72 | + public OspfCfgProvider() { | ||
| 73 | + super(new ProviderId("ospf", PROVIDER_ID)); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setOspfController(OspfController ospfController) { | ||
| 77 | + this.ospfController = ospfController; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Activate | ||
| 81 | + public void activate() { | ||
| 82 | + appId = coreService.registerApplication(PROVIDER_ID); | ||
| 83 | + configService.addListener(configListener); | ||
| 84 | + configRegistry.registerConfigFactory(configFactory); | ||
| 85 | + log.info("activated...!!!"); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @Deactivate | ||
| 89 | + public void deactivate() { | ||
| 90 | + configRegistry.unregisterConfigFactory(configFactory); | ||
| 91 | + configService.removeListener(configListener); | ||
| 92 | + log.info("deactivated...!!!"); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + private void updateConfig() { | ||
| 96 | + OspfAppConfig ospfAppConfig = configRegistry.getConfig(appId, OspfAppConfig.class); | ||
| 97 | + if ("ADD".equalsIgnoreCase(ospfAppConfig.method())) { | ||
| 98 | + JsonNode jsonNode = ospfAppConfig.processes(); | ||
| 99 | + ospfController.updateConfig(jsonNode); | ||
| 100 | + } else { | ||
| 101 | + log.debug("Please signify prop1 and prop2"); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * OSPF config listener to populate the configuration. | ||
| 107 | + */ | ||
| 108 | + private class InternalConfigListener implements NetworkConfigListener { | ||
| 109 | + @Override | ||
| 110 | + public void event(NetworkConfigEvent event) { | ||
| 111 | + log.debug("InternalConfigListener:: event is getting called"); | ||
| 112 | + if (!event.configClass().equals(OspfAppConfig.class)) { | ||
| 113 | + return; | ||
| 114 | + } | ||
| 115 | + switch (event.type()) { | ||
| 116 | + case CONFIG_ADDED: | ||
| 117 | + updateConfig(); | ||
| 118 | + break; | ||
| 119 | + case CONFIG_UPDATED: | ||
| 120 | + updateConfig(); | ||
| 121 | + break; | ||
| 122 | + case CONFIG_REMOVED: | ||
| 123 | + break; | ||
| 124 | + default: | ||
| 125 | + break; | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/package-info.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Provider that uses OSPF capability request as a means of infrastructure device discovery. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.provider.ospf.cfg.impl; |
providers/ospf/cli/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2016-present 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/xsd/maven-4.0.0.xsd"> | ||
| 20 | + <modelVersion>4.0.0</modelVersion> | ||
| 21 | + | ||
| 22 | + <parent> | ||
| 23 | + <groupId>org.onosproject</groupId> | ||
| 24 | + <artifactId>onos-ospf-providers</artifactId> | ||
| 25 | + <version>1.7.0-SNAPSHOT</version> | ||
| 26 | + <relativePath>../pom.xml</relativePath> | ||
| 27 | + </parent> | ||
| 28 | + | ||
| 29 | + <artifactId>onos-ospf-provider-cli</artifactId> | ||
| 30 | + <packaging>bundle</packaging> | ||
| 31 | + | ||
| 32 | + <description>OSPF cli implementation</description> | ||
| 33 | + | ||
| 34 | + <dependencies> | ||
| 35 | + <dependency> | ||
| 36 | + <groupId>org.onosproject</groupId> | ||
| 37 | + <artifactId>onos-cli</artifactId> | ||
| 38 | + <version>${project.version}</version> | ||
| 39 | + </dependency> | ||
| 40 | + <dependency> | ||
| 41 | + <groupId>org.onosproject</groupId> | ||
| 42 | + <artifactId>onos-ospf-api</artifactId> | ||
| 43 | + <version>${project.version}</version> | ||
| 44 | + </dependency> | ||
| 45 | + <dependency> | ||
| 46 | + <groupId>org.onosproject</groupId> | ||
| 47 | + <artifactId>onos-ospf-ctl</artifactId> | ||
| 48 | + <version>${project.version}</version> | ||
| 49 | + </dependency> | ||
| 50 | + <dependency> | ||
| 51 | + <groupId>org.onosproject</groupId> | ||
| 52 | + <artifactId>onos-ospf-protocol</artifactId> | ||
| 53 | + <version>${project.version}</version> | ||
| 54 | + </dependency> | ||
| 55 | + <dependency> | ||
| 56 | + <groupId>org.osgi</groupId> | ||
| 57 | + <artifactId>org.osgi.compendium</artifactId> | ||
| 58 | + </dependency> | ||
| 59 | + <dependency> | ||
| 60 | + <groupId>org.apache.karaf.shell</groupId> | ||
| 61 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
| 62 | + </dependency> | ||
| 63 | + <dependency> | ||
| 64 | + <groupId>org.apache.felix</groupId> | ||
| 65 | + <artifactId>org.apache.felix.scr.annotations</artifactId> | ||
| 66 | + <scope>provided</scope> | ||
| 67 | + </dependency> | ||
| 68 | + </dependencies> | ||
| 69 | +</project> |
This diff is collapsed. Click to expand it.
| 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 | + * OSPF cli implementation. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.ospf.cli; |
| 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 | +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> | ||
| 17 | + | ||
| 18 | + <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> | ||
| 19 | + <command> | ||
| 20 | + <action class="org.onosproject.ospf.cli.ApplicationOspfCommand"/> | ||
| 21 | + </command> | ||
| 22 | + </command-bundle> | ||
| 23 | + | ||
| 24 | +</blueprint> |
providers/ospf/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2016-present 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="http://maven.apache.org/POM/4.0.0" | ||
| 18 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 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-providers</artifactId> | ||
| 25 | + <version>1.7.0-SNAPSHOT</version> | ||
| 26 | + <relativePath>../pom.xml</relativePath> | ||
| 27 | + </parent> | ||
| 28 | + | ||
| 29 | + <artifactId>onos-ospf-providers</artifactId> | ||
| 30 | + <packaging>pom</packaging> | ||
| 31 | + | ||
| 32 | + <description>ONOS OSPF protocol adapters</description> | ||
| 33 | + | ||
| 34 | + <modules> | ||
| 35 | + <module>app</module> | ||
| 36 | + <module>cfg</module> | ||
| 37 | + <module>cli</module> | ||
| 38 | + <module>topology</module> | ||
| 39 | + </modules> | ||
| 40 | + | ||
| 41 | + <dependencies> | ||
| 42 | + <dependency> | ||
| 43 | + <groupId>org.onosproject</groupId> | ||
| 44 | + <artifactId>onos-ospf-api</artifactId> | ||
| 45 | + <version>${project.version}</version> | ||
| 46 | + </dependency> | ||
| 47 | + <dependency> | ||
| 48 | + <groupId>org.onosproject</groupId> | ||
| 49 | + <artifactId>onos-ospf-ctl</artifactId> | ||
| 50 | + <version>${project.version}</version> | ||
| 51 | + </dependency> | ||
| 52 | + <dependency> | ||
| 53 | + <groupId>org.onosproject</groupId> | ||
| 54 | + <artifactId>onos-api</artifactId> | ||
| 55 | + <classifier>tests</classifier> | ||
| 56 | + <scope>test</scope> | ||
| 57 | + </dependency> | ||
| 58 | + </dependencies> | ||
| 59 | + | ||
| 60 | +</project> |
providers/ospf/topology/BUCK
0 → 100644
| 1 | +COMPILE_DEPS = [ | ||
| 2 | + '//lib:CORE_DEPS', | ||
| 3 | + '//protocols/ospf/api:onos-protocols-ospf-api', | ||
| 4 | + '//protocols/ospf/ctl:onos-protocols-ospf-ctl', | ||
| 5 | +] | ||
| 6 | + | ||
| 7 | +TEST_DEPS = [ | ||
| 8 | + '//lib:TEST_ADAPTERS', | ||
| 9 | +] | ||
| 10 | + | ||
| 11 | +osgi_jar_with_tests ( | ||
| 12 | + deps = COMPILE_DEPS, | ||
| 13 | + test_deps = TEST_DEPS, | ||
| 14 | +) | ||
| 15 | + |
providers/ospf/topology/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2016-present 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="http://maven.apache.org/POM/4.0.0" | ||
| 18 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 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-providers</artifactId> | ||
| 25 | + <version>1.7.0-SNAPSHOT</version> | ||
| 26 | + <relativePath>../pom.xml</relativePath> | ||
| 27 | + </parent> | ||
| 28 | + | ||
| 29 | + <artifactId>onos-ospf-provider-topology</artifactId> | ||
| 30 | + <packaging>bundle</packaging> | ||
| 31 | + | ||
| 32 | + <description>ONOS OSPF Topology Providers</description> | ||
| 33 | + <dependencies> | ||
| 34 | + <dependency> | ||
| 35 | + <groupId>org.osgi</groupId> | ||
| 36 | + <artifactId>org.osgi.compendium</artifactId> | ||
| 37 | + </dependency> | ||
| 38 | + </dependencies> | ||
| 39 | +</project> |
This diff is collapsed. Click to expand it.
providers/ospf/topology/src/main/java/org/onosproject/provider/ospf/topology/impl/package-info.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Provider that uses OSPF as a means of topology discovery. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.provider.ospf.topology.impl; |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment