Completed the move to the new configuration file format. Default filename is now config.json
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
index baa825b..f0b7abe 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
@@ -51,6 +51,7 @@
import org.openflow.protocol.OFMatch;
import org.openflow.protocol.OFMessage;
import org.openflow.protocol.OFPacketOut;
+import org.openflow.protocol.OFPort;
import org.openflow.protocol.OFType;
import org.openflow.protocol.action.OFAction;
import org.openflow.protocol.action.OFActionDataLayerDestination;
@@ -75,7 +76,7 @@
protected static Ptree ptree;
protected String bgpdRestIp;
protected String routerId;
- protected String gatewaysFilename = "config.json";
+ protected String configFilename = "config.json";
//We need to identify our flows somehow. But like it says in LearningSwitch.java,
//the controller/OS should hand out cookie IDs to prevent conflicts.
@@ -156,7 +157,10 @@
Configuration config = mapper.readValue(gatewaysFile, Configuration.class);
switches = config.getSwitches();
- interfaces = config.getInterfaces();
+ interfaces = new HashMap<String, Interface>();
+ for (Interface intf : config.getInterfaces()){
+ interfaces.put(intf.getName(), intf);
+ }
bgpPeers = new HashMap<InetAddress, BgpPeer>();
for (BgpPeer peer : config.getPeers()){
bgpPeers.put(peer.getIpAddress(), peer);
@@ -246,7 +250,13 @@
log.info("RouterId set to {}", routerId);
}
- readGatewaysConfiguration(gatewaysFilename);
+ String configFilenameParameter = context.getConfigParams(this).get("configfile");
+ if (configFilenameParameter != null){
+ configFilename = configFilenameParameter;
+ }
+ log.debug("Config file set to {}", configFilename);
+
+ readGatewaysConfiguration(configFilename);
// Test.
//test();
}
@@ -572,6 +582,7 @@
.setBufferId(OFPacketOut.BUFFER_ID_NONE)
.setCookie(MAC_RW_COOKIE)
.setCommand(OFFlowMod.OFPFC_DELETE)
+ .setOutPort(OFPort.OFPP_NONE)
.setPriority(SDNIP_PRIORITY)
.setLengthU(OFFlowMod.MINIMUM_LENGTH);
//+ OFActionDataLayerDestination.MINIMUM_LENGTH
@@ -630,9 +641,11 @@
for (BgpPeer peer : bgpPeers.values()) {
Interface peerInterface = interfaces.get(peer.getInterfaceName());
- for (Map.Entry<String, Interface> intfEntry : interfaces.entrySet()) {
- Interface srcInterface = intfEntry.getValue();
- if (peer.getInterfaceName().equals(intfEntry.getKey())){
+ //for (Map.Entry<String, Interface> intfEntry : interfaces.entrySet()) {
+ for (Interface srcInterface : interfaces.values()) {
+ //Interface srcInterface = intfEntry.getValue();
+ //if (peer.getInterfaceName().equals(intfEntry.getKey())){
+ if (peer.getInterfaceName().equals(srcInterface.getName())){
continue;
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Configuration.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Configuration.java
index 08236a7..c3c8cbb 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Configuration.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Configuration.java
@@ -1,7 +1,6 @@
package net.onrc.onos.ofcontroller.bgproute;
import java.util.List;
-import java.util.Map;
import org.codehaus.jackson.annotate.JsonProperty;
import org.openflow.util.HexString;
@@ -10,7 +9,7 @@
private long bgpdAttachmentDpid;
private short bgpdAttachmentPort;
private List<String> switches;
- private Map<String, Interface> interfaces;
+ private List<Interface> interfaces;
private List<BgpPeer> peers;
//private Map<String, GatewayRouter> gateways;
@@ -45,12 +44,12 @@
this.switches = switches;
}
- public Map<String, Interface> getInterfaces() {
+ public List<Interface> getInterfaces() {
return interfaces;
}
@JsonProperty("interfaces")
- public void setInterfaces(Map<String, Interface> interfaces) {
+ public void setInterfaces(List<Interface> interfaces) {
this.interfaces = interfaces;
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java
index 15b2125..088c18e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java
@@ -12,12 +12,22 @@
import com.google.common.net.InetAddresses;
public class Interface {
+ private String name;
private SwitchPort switchPort = null;
private long dpid;
private short port;
private InetAddress ipAddress;
private int prefixLength;
+ public String getName() {
+ return name;
+ }
+
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
public synchronized SwitchPort getSwitchPort() {
if (switchPort == null){
switchPort = new SwitchPort(new Dpid(dpid), new Port(port));