Kalyankumar Asangi
Committed by Gerrit Code Review

ONOS-2740,ONOS-2741,from ONOS-3032 - to ONOS 3071 , OSPF Protocol Implementation

Change-Id: Ie8cccca4aaf2641ab1e332ed367ddfc9b725a35c
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.area;
import com.google.common.base.MoreObjects;
import org.onosproject.ospf.controller.OspfProcess;
import java.util.List;
/**
* Representation of an OSPF configuration data.
*/
public class Configuration {
private List<OspfProcess> processes;
private String method;
/**
* Gets the configured processes.
*
* @return list of configured processes.
*/
public List<OspfProcess> getProcesses() {
return processes;
}
/**
* Sets the configured processes.
*
* @param processes configured processes
*/
public void setProcesses(List<OspfProcess> processes) {
this.processes = processes;
}
/**
* Gets whether to update, add or delete configuration.
*
* @return update, add or delete configuration
*/
public String getMethod() {
return method;
}
/**
* Sets whether to update, add or delete configuration.
*
* @param method configuration method.
*/
public void setMethod(String method) {
this.method = method;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.omitNullValues()
.add("method", method)
.add("processes", processes)
.toString();
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.area;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import org.onlab.packet.Ip4Address;
import org.onosproject.ospf.controller.OspfAreaAddressRange;
/**
* Representation of an area address ranges.
* Address ranges are used in order to aggregate routing information at area boundaries.
* Each address range is specified by an [address,mask] pair and a status indication of
* either advertise or do not advertise
*/
public class OspfAreaAddressRangeImpl implements OspfAreaAddressRange {
public Ip4Address ipAddress;
public String mask;
public boolean advertise;
/**
* Gets the IP address.
*
* @return IP address
*/
public Ip4Address ipAddress() {
return ipAddress;
}
/**
* Sets the IP address.
*
* @param ipAddress IP address
*/
public void setIpAddress(Ip4Address ipAddress) {
this.ipAddress = ipAddress;
}
/**
* Gets the network mask.
*
* @return network mask
*/
public String mask() {
return mask;
}
/**
* Sets the network mask.
*
* @param mask network mask value
*/
public void setMask(String mask) {
this.mask = mask;
}
/**
* Gets the advertise value.
*
* @return advertise value
*/
public boolean isAdvertise() {
return advertise;
}
/**
* Sets the advertise value.
*
* @param advertise advertise value
*/
public void setAdvertise(boolean advertise) {
this.advertise = advertise;
}
@Override
public boolean equals(Object other) {
if (!(other instanceof OspfAreaAddressRangeImpl)) {
return false;
}
OspfAreaAddressRangeImpl otherAreaAddressRange = (OspfAreaAddressRangeImpl) other;
return Objects.equal(ipAddress, otherAreaAddressRange.ipAddress) &&
Objects.equal(mask, otherAreaAddressRange.mask) &&
Objects.equal(advertise, otherAreaAddressRange.advertise);
}
@Override
public int hashCode() {
return Objects.hashCode(ipAddress, mask, advertise);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.omitNullValues()
.add("ipAddress", ipAddress)
.add("mask", mask)
.add("advertise", advertise)
.toString();
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.area;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import org.onosproject.ospf.controller.OspfArea;
import org.onosproject.ospf.controller.OspfProcess;
import java.util.List;
/**
* Representation of the configuration data for OSPF Process, which will be configured using rest URI.
*/
public class OspfProcessImpl implements OspfProcess {
private String processId;
private List<OspfArea> areas;
/**
* Gets the list of areas belonging to this process.
*
* @return list of areas belonging to this process
*/
public List<OspfArea> areas() {
return areas;
}
/**
* Sets the list of areas belonging to this process.
*
* @param areas list of areas belonging to this process
*/
@JsonProperty("areas")
public void setAreas(List<OspfArea> areas) {
this.areas = areas;
}
/**
* Gets the process id.
*
* @return process id
*/
public String processId() {
return processId;
}
/**
* Sets the process id.
*
* @param processId the process id
*/
@JsonProperty("processId")
public void setProcessId(String processId) {
this.processId = processId;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.omitNullValues()
.add("areas", areas)
.toString();
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Implementation of the OSPF controller.
*/
package org.onosproject.ospf.controller.area;
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Implementation of the OSPF controller.
*/
package org.onosproject.ospf.controller.impl;
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.lsdb;
import com.google.common.base.MoreObjects;
import org.onosproject.ospf.controller.LsaBin;
import org.onosproject.ospf.controller.LsaWrapper;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Represents a bin, where an LSA is stored for Aging.
* A bin is identified by a bin number and can have one or more LSAs
* store in a particular bin location.
*/
public class LsaBinImpl implements LsaBin {
private int binNumber;
private Map<String, LsaWrapper> listOfLsa = new ConcurrentHashMap<>();
/**
* Creates an instance of LSA bin.
*
* @param binNumber unique number of this bin
*/
public LsaBinImpl(int binNumber) {
this.binNumber = binNumber;
}
/**
* Adds the LSA to this bin with the given key.
*
* @param lsaKey key of the LSA
* @param lsaWrapper wrapper instance to store
*/
public void addOspfLsa(String lsaKey, LsaWrapper lsaWrapper) {
if (!listOfLsa.containsKey(lsaKey)) {
listOfLsa.put(lsaKey, lsaWrapper);
lsaWrapper.setBinNumber(this.binNumber);
}
}
/**
* Gets the LSA from the bin.
*
* @param lsaKey key to search the LSA
* @return LSA Wrapper instance
*/
public LsaWrapper ospfLsa(String lsaKey) {
return listOfLsa.get(lsaKey);
}
/**
* Removes LSA from the bin.
*
* @param lsaKey key to search LSA
* @param lsaWrapper wrapper object to remove
*/
public void removeOspfLsa(String lsaKey, LsaWrapper lsaWrapper) {
if (listOfLsa.containsKey(lsaKey)) {
listOfLsa.remove(lsaKey);
}
}
/**
* Gets the list of LSAs in this bin as key value pair.
*
* @return list of LSAs in this bin as key value pair
*/
public Map<String, LsaWrapper> listOfLsa() {
return listOfLsa;
}
/**
* Gets the bin number.
*
* @return the bin number
*/
public int binNumber() {
return binNumber;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.omitNullValues()
.add("binNumber", binNumber)
.add("listOfLsa", listOfLsa)
.toString();
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Implementation of the OSPF Link state database and Ageing.
*/
package org.onosproject.ospf.controller.lsdb;
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.util;
import org.onlab.packet.Ip4Address;
/**
* Represents a router who is eligible for DR election.
*/
public class OspfEligibleRouter {
private Ip4Address ipAddress;
private Ip4Address routerId;
private int routerPriority;
private boolean isDr;
private boolean isBdr;
/**
* Creates an instance.
* Initialize IP address of eligible router.
*/
public OspfEligibleRouter() {
ipAddress = Ip4Address.valueOf("0.0.0.0");
}
/**
* Gets the value of IP address.
*
* @return IP address
*/
public Ip4Address getIpAddress() {
return ipAddress;
}
/**
* Sets the value of IP address.
*
* @param ipAddress IP address
*/
public void setIpAddress(Ip4Address ipAddress) {
this.ipAddress = ipAddress;
}
/**
* Gets the value of router id.
*
* @return router id.
*/
public Ip4Address getRouterId() {
return routerId;
}
/**
* Sets the value of router id.
*
* @param routerId router id
*/
public void setRouterId(Ip4Address routerId) {
this.routerId = routerId;
}
/**
* Gets the value of router priority.
*
* @return router priority.
*/
public int getRouterPriority() {
return routerPriority;
}
/**
* Sets the value of router priority.
*
* @param routerPriority router priority
*/
public void setRouterPriority(int routerPriority) {
this.routerPriority = routerPriority;
}
/**
* Gets whether the router is DR.
*
* @return boolean true if router is DR else return false.
*/
public boolean isDr() {
return isDr;
}
/**
* Sets the router is DR or not.
*
* @param isDr router is DR or not
*/
public void setIsDr(boolean isDr) {
this.isDr = isDr;
}
/**
* Gets whether the router is BDR or not.
*
* @return boolean true if router is Bdr else return false.
*/
public boolean isBdr() {
return isBdr;
}
/**
* Sets the router is BDR or not.
*
* @param isBdr the router is BDR or not
*/
public void setIsBdr(boolean isBdr) {
this.isBdr = isBdr;
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.util;
/**
* Enum represents OSPF interface types.
*/
public enum OspfInterfaceType {
POINT_TO_POINT(1),
BROADCAST(2),
VIRTUAL(3);
private int value;
/**
* Creates an instance.
*
* @param value value represents interface type
*/
OspfInterfaceType(int value) {
this.value = value;
}
/**
* Gets value represents interface type.
*
* @return value represents interface type
*/
public int value() {
return value;
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ospf.controller.util;
/**
* Enum represents OSPF link type.
*/
public enum OspfLinkType {
/**
* Indicates a point-to-point connection to another router.
*/
POINT_TO_POINT,
/**
* Indicates a connection to a transit network.
*/
TO_TRANSIT_NET,
/**
* Indicates a connection to a stub network.
*/
TO_STUB_NET,
/**
* Indicates a Virtual link to another area border router.
*/
VIRTUAL_LINK;
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Implementation of the OSPF utilities.
*/
package org.onosproject.ospf.controller.util;
\ No newline at end of file