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

Merge pull request #3 from hwchiu/openflow-1.3#3

Openflow 1.3#3
parents b48ab136 aa76bd53
No related branches found
No related tags found
No related merge requests found
...@@ -25,17 +25,17 @@ import com.fasterxml.jackson.core.JsonGenerator; ...@@ -25,17 +25,17 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException; 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.types.IPv4Address;
/** /**
* Serialize an integer as an IPv4 Address in dotted decimal format * Serialize an IPv4Address in dotted decimal format
*/ */
public class IPv4Serializer extends JsonSerializer<Integer> { public class IPv4Serializer extends JsonSerializer<IPv4Address> {
@Override @Override
public void serialize(Integer i, JsonGenerator jGen, public void serialize(IPv4Address ipv4, JsonGenerator jGen,
SerializerProvider serializer) SerializerProvider serializer)
throws IOException, JsonProcessingException { throws IOException, JsonProcessingException {
jGen.writeString(IPv4.fromIPv4Address(i)); jGen.writeString(ipv4.toString());
} }
} }
...@@ -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.MacAddress;
/** /**
* Serialize a MAC as colon-separated hexadecimal * Serialize a MAC as colon-separated hexadecimal
*/ */
public class MACSerializer extends JsonSerializer<Long> { public class MACSerializer extends JsonSerializer<MacAddress> {
@Override @Override
public void serialize(Long dpid, JsonGenerator jGen, public void serialize(MacAddress mac, JsonGenerator jGen,
SerializerProvider serializer) SerializerProvider serializer)
throws IOException, JsonProcessingException { throws IOException, JsonProcessingException {
jGen.writeString(HexString.toHexString(dpid, 6)); jGen.writeString(mac.toString());
} }
} }
/**
* Copyright 2011,2012 Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* 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 net.floodlightcontroller.core.web.serializers;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.projectfloodlight.openflow.util.HexString;
import org.projectfloodlight.openflow.types.OFPort;
/**
* Serialize a OFPort as short number
*/
public class OFPortSerializer extends JsonSerializer<OFPort> {
@Override
public void serialize(OFPort port, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeNumber(port.getPortNumber());
}
}
/**
* Copyright 2011,2012 Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* 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 net.floodlightcontroller.core.web.serializers;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.projectfloodlight.openflow.util.HexString;
import org.projectfloodlight.openflow.types.VlanVid;
/**
* Serialize a VlanVid as short number
*/
public class VlanVidSerializer extends JsonSerializer<VlanVid> {
@Override
public void serialize(VlanVid vlan, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeString(vlan.toString());
}
}
...@@ -21,6 +21,7 @@ import org.projectfloodlight.openflow.types.DatapathId; ...@@ -21,6 +21,7 @@ import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.OFPort; import org.projectfloodlight.openflow.types.OFPort;
import net.floodlightcontroller.core.web.serializers.DPIDSerializer; import net.floodlightcontroller.core.web.serializers.DPIDSerializer;
import net.floodlightcontroller.core.web.serializers.OFPortSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
...@@ -94,6 +95,7 @@ public class SwitchPort { ...@@ -94,6 +95,7 @@ public class SwitchPort {
return switchDPID; return switchDPID;
} }
@JsonSerialize(using=OFPortSerializer.class)
public OFPort getPort() { public OFPort getPort() {
return port; return port;
} }
...@@ -137,4 +139,4 @@ public class SwitchPort { ...@@ -137,4 +139,4 @@ public class SwitchPort {
", port=" + port + ", errorStatus=" + errorStatus + "]"; ", port=" + port + ", errorStatus=" + errorStatus + "]";
} }
} }
\ No newline at end of file
...@@ -22,6 +22,8 @@ import java.util.Date; ...@@ -22,6 +22,8 @@ import java.util.Date;
import net.floodlightcontroller.core.web.serializers.IPv4Serializer; import net.floodlightcontroller.core.web.serializers.IPv4Serializer;
import net.floodlightcontroller.core.web.serializers.MACSerializer; import net.floodlightcontroller.core.web.serializers.MACSerializer;
import net.floodlightcontroller.core.web.serializers.DPIDSerializer; import net.floodlightcontroller.core.web.serializers.DPIDSerializer;
import net.floodlightcontroller.core.web.serializers.OFPortSerializer;
import net.floodlightcontroller.core.web.serializers.VlanVidSerializer;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
...@@ -138,6 +140,7 @@ public class Entity implements Comparable<Entity> { ...@@ -138,6 +140,7 @@ public class Entity implements Comparable<Entity> {
return ipv4Address; return ipv4Address;
} }
@JsonSerialize(using=VlanVidSerializer.class)
public VlanVid getVlan() { public VlanVid getVlan() {
return vlan; return vlan;
} }
...@@ -147,6 +150,7 @@ public class Entity implements Comparable<Entity> { ...@@ -147,6 +150,7 @@ public class Entity implements Comparable<Entity> {
return switchDPID; return switchDPID;
} }
@JsonSerialize(using=OFPortSerializer.class)
public OFPort getSwitchPort() { public OFPort getSwitchPort() {
return switchPort; return switchPort;
} }
...@@ -226,45 +230,45 @@ public class Entity implements Comparable<Entity> { ...@@ -226,45 +230,45 @@ public class Entity implements Comparable<Entity> {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("Entity [macAddress="); builder.append("Entity [macAddress=");
if (macAddress != null) { if (macAddress != null) {
builder.append(macAddress.toString()); builder.append(macAddress.toString());
} else { } else {
builder.append("null"); builder.append("null");
} }
builder.append(", ipv4Address="); builder.append(", ipv4Address=");
if (ipv4Address != null) { if (ipv4Address != null) {
builder.append(ipv4Address.toString()); builder.append(ipv4Address.toString());
} else { } else {
builder.append("null"); builder.append("null");
} }
builder.append(", vlan="); builder.append(", vlan=");
if (vlan != null) { if (vlan != null) {
builder.append(vlan.getVlan()); builder.append(vlan.getVlan());
} else { } else {
builder.append("null"); builder.append("null");
} }
builder.append(", switchDPID="); builder.append(", switchDPID=");
if (switchDPID != null) { if (switchDPID != null) {
builder.append(switchDPID.toString()); builder.append(switchDPID.toString());
} else { } else {
builder.append("null"); builder.append("null");
} }
builder.append(", switchPort="); builder.append(", switchPort=");
if (switchPort != null) { if (switchPort != null) {
builder.append(switchPort.getPortNumber()); builder.append(switchPort.getPortNumber());
} else { } else {
builder.append("null"); builder.append("null");
} }
builder.append(", lastSeenTimestamp="); builder.append(", lastSeenTimestamp=");
if (lastSeenTimestamp != null) { if (lastSeenTimestamp != null) {
builder.append(lastSeenTimestamp == null? "null" : lastSeenTimestamp.getTime()); builder.append(lastSeenTimestamp == null? "null" : lastSeenTimestamp.getTime());
} else { } else {
builder.append("null"); builder.append("null");
} }
builder.append(", activeSince="); builder.append(", activeSince=");
if (activeSince != null) { if (activeSince != null) {
builder.append(activeSince == null? "null" : activeSince.getTime()); builder.append(activeSince == null? "null" : activeSince.getTime());
} else { } else {
builder.append("null"); builder.append("null");
} }
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
......
/** /**::
* Copyright 2013, Big Switch Networks, Inc. * Copyright 2013, Big Switch Networks, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may * Licensed under the Apache License, Version 2.0 (the "License"); you may
...@@ -315,7 +315,7 @@ public class TopologyInstance { ...@@ -315,7 +315,7 @@ public class TopologyInstance {
Set<Link> lset = switchPortLinks.get(new NodePortTuple(currSw, p)); Set<Link> lset = switchPortLinks.get(new NodePortTuple(currSw, p));
if (lset == null) continue; if (lset == null) continue;
for(Link l:lset) { for(Link l:lset) {
DatapathId dstSw = l.getDst(); DatapathId dstSw = l.getDst();
// ignore incoming links. // ignore incoming links.
if (dstSw.equals(currSw)) continue; if (dstSw.equals(currSw)) continue;
...@@ -507,7 +507,7 @@ public class TopologyInstance { ...@@ -507,7 +507,7 @@ public class TopologyInstance {
seen.put(cnode, true); seen.put(cnode, true);
for (Link link: c.links.get(cnode)) { for (Link link: c.links.get(cnode)) {
DatapathId neighbor; DatapathId neighbor;
if (isDstRooted == true) neighbor = link.getSrc(); if (isDstRooted == true) neighbor = link.getSrc();
else neighbor = link.getDst(); else neighbor = link.getDst();
...@@ -619,7 +619,7 @@ public class TopologyInstance { ...@@ -619,7 +619,7 @@ public class TopologyInstance {
// if srcId equals dstId --- and that too is an 'empty' path [] // if srcId equals dstId --- and that too is an 'empty' path []
} else if ((nexthoplinks!=null) && (nexthoplinks.get(srcId) != null)) { } else if ((nexthoplinks!=null) && (nexthoplinks.get(srcId) != null)) {
while (srcId != dstId) { while (!srcId.equals(dstId)) {
Link l = nexthoplinks.get(srcId); Link l = nexthoplinks.get(srcId);
npt = new NodePortTuple(l.getSrc(), l.getSrcPort()); npt = new NodePortTuple(l.getSrc(), l.getSrcPort());
...@@ -665,7 +665,7 @@ public class TopologyInstance { ...@@ -665,7 +665,7 @@ public class TopologyInstance {
} }
protected Route getRoute(ServiceChain sc, DatapathId srcId, OFPort srcPort, protected Route getRoute(ServiceChain sc, DatapathId srcId, OFPort srcPort,
DatapathId dstId, OFPort dstPort, U64 cookie) { DatapathId dstId, OFPort dstPort, U64 cookie) {
// Return null the route source and desitnation are the // Return null the route source and desitnation are the
...@@ -773,7 +773,7 @@ public class TopologyInstance { ...@@ -773,7 +773,7 @@ public class TopologyInstance {
protected boolean protected boolean
isIncomingBroadcastAllowedOnSwitchPort(DatapathId sw, OFPort portId) { isIncomingBroadcastAllowedOnSwitchPort(DatapathId sw, OFPort portId) {
if (isInternalToOpenflowDomain(sw, portId)) { if (isInternalToOpenflowDomain(sw, portId)) {
DatapathId clusterId = getOpenflowDomainId(sw); DatapathId clusterId = getOpenflowDomainId(sw);
NodePortTuple npt = new NodePortTuple(sw, portId); NodePortTuple npt = new NodePortTuple(sw, portId);
if (clusterBroadcastNodePorts.get(clusterId).contains(npt)) if (clusterBroadcastNodePorts.get(clusterId).contains(npt))
return true; return true;
...@@ -790,7 +790,7 @@ public class TopologyInstance { ...@@ -790,7 +790,7 @@ public class TopologyInstance {
protected Set<NodePortTuple> protected Set<NodePortTuple>
getBroadcastNodePortsInCluster(DatapathId sw) { getBroadcastNodePortsInCluster(DatapathId sw) {
DatapathId clusterId = getOpenflowDomainId(sw); DatapathId clusterId = getOpenflowDomainId(sw);
return clusterBroadcastNodePorts.get(clusterId); return clusterBroadcastNodePorts.get(clusterId);
} }
...@@ -803,13 +803,13 @@ public class TopologyInstance { ...@@ -803,13 +803,13 @@ public class TopologyInstance {
} }
public NodePortTuple getOutgoingSwitchPort(DatapathId src, OFPort srcPort, public NodePortTuple getOutgoingSwitchPort(DatapathId src, OFPort srcPort,
DatapathId dst, OFPort dstPort) { DatapathId dst, OFPort dstPort) {
// Use this function to redirect traffic if needed. // Use this function to redirect traffic if needed.
return new NodePortTuple(dst, dstPort); return new NodePortTuple(dst, dstPort);
} }
public NodePortTuple getIncomingSwitchPort(DatapathId src, OFPort srcPort, public NodePortTuple getIncomingSwitchPort(DatapathId src, OFPort srcPort,
DatapathId dst, OFPort dstPort) { DatapathId dst, OFPort dstPort) {
// Use this function to reinject traffic from a // Use this function to reinject traffic from a
// different port if needed. // different port if needed.
return new NodePortTuple(src, srcPort); return new NodePortTuple(src, srcPort);
......
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