Skip to content
Snippets Groups Projects
Commit 559f6dc9 authored by Ryan Izard's avatar Ryan Izard
Browse files

Merge pull request #1 from hwchiu/openflow-1.3

Fixed LLDP handling, DPID and OFPort serializers, accounted for default cluster ID = 0, modify circuitpusher.py for new REST API format.
parents 3de2b506 306be67a
No related branches found
No related tags found
No related merge requests found
...@@ -94,12 +94,12 @@ if args.action=='add': ...@@ -94,12 +94,12 @@ if args.action=='add':
result = os.popen(command).read() result = os.popen(command).read()
parsedResult = json.loads(result) parsedResult = json.loads(result)
print command+"\n" print command+"\n"
try: try:
sourceSwitch = parsedResult[0]['attachmentPoint'][0]['switchDPID'] sourceSwitch = parsedResult[0]['attachmentPoint'][0]['switchDPID']
except IndexError: except IndexError:
print "ERROR : the specified end point (%s) must already been known to the controller (i.e., already have sent packets on the network, easy way to assure this is to do a ping (to any target) from the two hosts." % (args.srcAddress) print "ERROR : the specified end point (%s) must already been known to the controller (i.e., already have sent packets on the network, easy way to assure this is to do a ping (to any target) from the two hosts." % (args.srcAddress)
sys.exit() sys.exit()
sourcePort = parsedResult[0]['attachmentPoint'][0]['port'] sourcePort = parsedResult[0]['attachmentPoint'][0]['port']
...@@ -113,7 +113,7 @@ if args.action=='add': ...@@ -113,7 +113,7 @@ if args.action=='add':
except IndexError: except IndexError:
print "ERROR : the specified end point (%s) must already been known to the controller (i.e., already have sent packets on the network, easy way to assure this is to do a ping (to any target) from the two hosts." % (args.dstAddress) print "ERROR : the specified end point (%s) must already been known to the controller (i.e., already have sent packets on the network, easy way to assure this is to do a ping (to any target) from the two hosts." % (args.dstAddress)
sys.exit() sys.exit()
destPort = parsedResult[0]['attachmentPoint'][0]['port'] destPort = parsedResult[0]['attachmentPoint'][0]['port']
print "Creating circuit:" print "Creating circuit:"
...@@ -123,13 +123,11 @@ if args.action=='add': ...@@ -123,13 +123,11 @@ if args.action=='add':
# retrieving route from source to destination # retrieving route from source to destination
# using Routing rest API # using Routing rest API
command = "curl -s http://%s/wm/topology/route/%s/%s/%s/%s/json" % (controllerRestIp, sourceSwitch, sourcePort, destSwitch, destPort) command = "curl -s http://%s/wm/topology/route/%s/%s/%s/%s/json" % (controllerRestIp, sourceSwitch, sourcePort['shortPortNumber'], destSwitch, destPort['shortPortNumber'])
result = os.popen(command).read() result = os.popen(command).read()
parsedResult = json.loads(result)
print command+"\n"
print result+"\n" print result+"\n"
print command+"\n"
parsedResult = json.loads(result)
for i in range(len(parsedResult)): for i in range(len(parsedResult)):
if i % 2 == 0: if i % 2 == 0:
...@@ -151,26 +149,26 @@ if args.action=='add': ...@@ -151,26 +149,26 @@ if args.action=='add':
# encode each flow entry's name with both switch dpid, user # encode each flow entry's name with both switch dpid, user
# specified name, and flow type (f: forward, r: reverse, farp/rarp: arp) # specified name, and flow type (f: forward, r: reverse, farp/rarp: arp)
command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"src-ip\":\"%s\", \"dst-ip\":\"%s\", \"ether-type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress-port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".f", args.srcAddress, args.dstAddress, "0x800", ap1Port, ap2Port, controllerRestIp) command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"nw_src\":\"%s\", \"nw_dst\":\"%s\", \"dl_type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress_port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".f", args.srcAddress, args.dstAddress, "0x800", ap1Port['shortPortNumber'], ap2Port['shortPortNumber'], controllerRestIp)
result = os.popen(command).read() result = os.popen(command).read()
print command print command
command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"ether-type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress-port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".farp", "0x806", ap1Port, ap2Port, controllerRestIp) command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"arp_spa\":\"%s\", \"arp_dpa\":\"%s\", \"dl_type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress_port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".farp", args.srcAddress, args.dstAddress, "0x806", ap1Port['shortPortNumber'], ap2Port['shortPortNumber'], controllerRestIp)
result = os.popen(command).read() result = os.popen(command).read()
print command print command
command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"src-ip\":\"%s\", \"dst-ip\":\"%s\", \"ether-type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress-port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".r", args.dstAddress, args.srcAddress, "0x800", ap2Port, ap1Port, controllerRestIp) command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"nw_src\":\"%s\", \"nw_dst\":\"%s\", \"dl_type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress_port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".r", args.dstAddress, args.srcAddress, "0x800", ap2Port['shortPortNumber'], ap1Port['shortPortNumber'], controllerRestIp)
result = os.popen(command).read() result = os.popen(command).read()
print command print command
command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"ether-type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress-port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".rarp", "0x806", ap2Port, ap1Port, controllerRestIp) command = "curl -s -d '{\"switch\": \"%s\", \"name\":\"%s\", \"arp_spa\":\"%s\", \"arp_dpa\":\"%s\", \"dl_type\":\"%s\", \"cookie\":\"0\", \"priority\":\"32768\", \"ingress_port\":\"%s\",\"active\":\"true\", \"actions\":\"output=%s\"}' http://%s/wm/staticflowentrypusher/json" % (ap1Dpid, ap1Dpid+"."+args.circuitName+".rarp",args.dstAddress, args.srcAddress, "0x806", ap2Port['shortPortNumber'], ap1Port['shortPortNumber'], controllerRestIp)
result = os.popen(command).read() result = os.popen(command).read()
print command print command
# store created circuit attributes in local ./circuits.json # store created circuit attributes in local ./circuits.json
datetime = time.asctime() datetime = time.asctime()
circuitParams = {'name':args.circuitName, 'Dpid':ap1Dpid, 'inPort':ap1Port, 'outPort':ap2Port, 'datetime':datetime} circuitParams = {'name':args.circuitName, 'Dpid':ap1Dpid, 'inPort':ap1Port['shortPortNumber'], 'outPort':ap2Port['shortPortNumber'], 'datetime':datetime}
str = json.dumps(circuitParams) str = json.dumps(circuitParams)
circuitDb.write(str+"\n") circuitDb.write(str+"\n")
......
...@@ -24,17 +24,17 @@ import com.fasterxml.jackson.core.JsonProcessingException; ...@@ -24,17 +24,17 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import org.projectfloodlight.openflow.util.HexString; import org.projectfloodlight.openflow.util.HexString;
import org.projectfloodlight.openflow.types.DatapathId;
/** /**
* Serialize a DPID as colon-separated hexadecimal * Serialize a DPID as colon-separated hexadecimal
*/ */
public class DPIDSerializer extends JsonSerializer<Long> { public class DPIDSerializer extends JsonSerializer<DatapathId> {
@Override @Override
public void serialize(Long dpid, JsonGenerator jGen, public void serialize(DatapathId dpid, JsonGenerator jGen,
SerializerProvider serializer) SerializerProvider serializer)
throws IOException, JsonProcessingException { throws IOException, JsonProcessingException {
jGen.writeString(HexString.toHexString(dpid, 8)); jGen.writeString(HexString.toHexString(dpid.getLong(), 8));
} }
} }
...@@ -55,7 +55,7 @@ public class DeviceSerializer extends JsonSerializer<Device> { ...@@ -55,7 +55,7 @@ public class DeviceSerializer extends JsonSerializer<Device> {
jGen.writeArrayFieldStart("vlan"); jGen.writeArrayFieldStart("vlan");
for (VlanVid vlan : device.getVlanId()) for (VlanVid vlan : device.getVlanId())
if (vlan.getVlan() >= 0) if (vlan.getVlan() >= 0)
jGen.writeNumber(vlan.toString()); jGen.writeString(vlan.toString());
jGen.writeEndArray(); jGen.writeEndArray();
jGen.writeArrayFieldStart("attachmentPoint"); jGen.writeArrayFieldStart("attachmentPoint");
for (SwitchPort ap : device.getAttachmentPoints(true)) { for (SwitchPort ap : device.getAttachmentPoints(true)) {
......
...@@ -565,7 +565,7 @@ IFloodlightModule, IInfoProvider { ...@@ -565,7 +565,7 @@ IFloodlightModule, IInfoProvider {
FloodlightContext cntx) { FloodlightContext cntx) {
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD); IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_13) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
if (eth.getPayload() instanceof BSN) { if (eth.getPayload() instanceof BSN) {
BSN bsn = (BSN) eth.getPayload(); BSN bsn = (BSN) eth.getPayload();
if (bsn == null) return Command.STOP; if (bsn == null) return Command.STOP;
...@@ -574,9 +574,9 @@ IFloodlightModule, IInfoProvider { ...@@ -574,9 +574,9 @@ IFloodlightModule, IInfoProvider {
// continue with the regular processing. // continue with the regular processing.
if (bsn.getPayload() instanceof LLDP == false) if (bsn.getPayload() instanceof LLDP == false)
return Command.CONTINUE; return Command.CONTINUE;
return handleLldp((LLDP) bsn.getPayload(), sw, pi.getInPort(), false, cntx); return handleLldp((LLDP) bsn.getPayload(), sw, inPort, false, cntx);
} else if (eth.getPayload() instanceof LLDP) { } else if (eth.getPayload() instanceof LLDP) {
return handleLldp((LLDP) eth.getPayload(), sw, pi.getInPort(), true, cntx); return handleLldp((LLDP) eth.getPayload(), sw, inPort, true, cntx);
} else if (eth.getEtherType() < 1500) { } else if (eth.getEtherType() < 1500) {
long destMac = eth.getDestinationMACAddress().getLong(); long destMac = eth.getDestinationMACAddress().getLong();
if ((destMac & LINK_LOCAL_MASK) == LINK_LOCAL_VALUE) { if ((destMac & LINK_LOCAL_MASK) == LINK_LOCAL_VALUE) {
...@@ -1134,7 +1134,7 @@ IFloodlightModule, IInfoProvider { ...@@ -1134,7 +1134,7 @@ IFloodlightModule, IInfoProvider {
// send // send
// no more try-catch. switch will silently fail // no more try-catch. switch will silently fail
iofSwitch.write(po); iofSwitch.write(pob.build());
iofSwitch.flush(); iofSwitch.flush();
} }
......
...@@ -53,7 +53,8 @@ public class Cluster { ...@@ -53,7 +53,8 @@ public class Cluster {
void add(DatapathId n) { void add(DatapathId n) {
if (links.containsKey(n) == false) { if (links.containsKey(n) == false) {
links.put(n, new HashSet<Link>()); links.put(n, new HashSet<Link>());
if (n.getLong() < id.getLong()) id = n; if (id == DatapathId.NONE || n.getLong() < id.getLong())
id = n ;
} }
} }
......
...@@ -55,7 +55,6 @@ public class NodePortTuple implements Comparable<NodePortTuple> { ...@@ -55,7 +55,6 @@ public class NodePortTuple implements Comparable<NodePortTuple> {
this.nodeId = nodeId; this.nodeId = nodeId;
} }
@JsonProperty("port") @JsonProperty("port")
@JsonSerialize(using=UShortSerializer.class)
public OFPort getPortId() { public OFPort getPortId() {
return portId; return portId;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment