Skip to content

Commit

Permalink
<Issue> dlinknctu#74 - Upgrade LinkInfoForOmniUI to floodlight v1.0
Browse files Browse the repository at this point in the history
Signed-off-by: hwchiu <[email protected]>
  • Loading branch information
hungweic authored and hwchiu committed Feb 3, 2015
1 parent dd62632 commit 7396562
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions adapter/floodlight/omniui/LinkInfoForOmniUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,40 @@
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.openflow.util.HexString;

import net.floodlightcontroller.routing.Link;
import org.projectfloodlight.openflow.util.HexString;
import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.OFPort;

import net.floodlightcontroller.routing.Link;

@JsonSerialize(using=LinkInfoForOmniUI.class)
public class LinkInfoForOmniUI extends JsonSerializer<LinkInfoForOmniUI> {
private long srcDpid;
private long dstDpid;
private short srcPort;
private short dstPort;

private DatapathId srcDpid;
private DatapathId dstDpid;
private OFPort srcPort;
private OFPort dstPort;
// Do NOT delete this, it's required for the serializer
public LinkInfoForOmniUI() {}

public LinkInfoForOmniUI(Link link){
public LinkInfoForOmniUI(Link link) {
this.srcDpid = link.getSrc();
this.dstDpid = link.getDst();
this.srcPort = link.getSrcPort();
this.dstPort = link.getDstPort();
}

@Override
public void serialize(LinkInfoForOmniUI linkinfo, JsonGenerator jgen, SerializerProvider arg2)
throws IOException, JsonProcessingException {
// You ****MUST*** use lwt for the fields as it's actually a different object.

jgen.writeStartObject();
jgen.writeStringField("src-switch", linkinfo.getSrcDpidHexString());
jgen.writeNumberField("src-port", linkinfo.getSrcPort());
jgen.writeNumberField("src-port", linkinfo.getSrcPort().getPortNumber());
jgen.writeStringField("dst-switch", linkinfo.getDstDpidHexString());
jgen.writeNumberField("dst-port", linkinfo.getDstPort());
jgen.writeNumberField("dst-port", linkinfo.getDstPort().getPortNumber());
jgen.writeEndObject();
}

Expand All @@ -48,22 +51,22 @@ public Class<LinkInfoForOmniUI> handledType() {
}

//getter
public long getSrcDpid(){
public DatapathId getSrcDpid() {
return this.srcDpid;
}
public String getSrcDpidHexString(){
return HexString.toHexString(this.srcDpid);
public String getSrcDpidHexString() {
return HexString.toHexString(this.srcDpid.getLong());
}
public long getDstDpid(){
public DatapathId getDstDpid() {
return this.dstDpid;
}
public String getDstDpidHexString(){
return HexString.toHexString(this.dstDpid);
public String getDstDpidHexString() {
return HexString.toHexString(this.dstDpid.getLong());
}
public long getSrcPort(){
public OFPort getSrcPort() {
return this.srcPort;
}
public long getDstPort(){
public OFPort getDstPort() {
return this.dstPort;
}
}

0 comments on commit 7396562

Please sign in to comment.