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

Merge Hung-Wei's #3 pull request

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