Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.bgproute; |
| 2 | |
| 3 | import java.net.InetAddress; |
| 4 | |
| 5 | import net.onrc.onos.ofcontroller.util.Dpid; |
| 6 | import net.onrc.onos.ofcontroller.util.Port; |
| 7 | import net.onrc.onos.ofcontroller.util.SwitchPort; |
| 8 | |
| 9 | import org.codehaus.jackson.annotate.JsonProperty; |
| 10 | import org.openflow.util.HexString; |
| 11 | |
| 12 | import com.google.common.net.InetAddresses; |
| 13 | |
| 14 | public class Interface { |
| 15 | private SwitchPort switchPort = null; |
| 16 | private long dpid; |
| 17 | private short port; |
| 18 | private InetAddress ipAddress; |
| 19 | private int prefixLength; |
| 20 | |
| 21 | public synchronized SwitchPort getSwitchPort() { |
| 22 | if (switchPort == null){ |
| 23 | switchPort = new SwitchPort(new Dpid(dpid), new Port(port)); |
| 24 | } |
| 25 | return switchPort; |
| 26 | } |
| 27 | |
| 28 | public long getDpid() { |
| 29 | return dpid; |
| 30 | } |
| 31 | |
| 32 | @JsonProperty("dpid") |
| 33 | public void setDpid(String dpid) { |
| 34 | this.dpid = HexString.toLong(dpid); |
| 35 | } |
| 36 | |
| 37 | public short getPort() { |
| 38 | return port; |
| 39 | } |
| 40 | |
| 41 | @JsonProperty("port") |
| 42 | public void setPort(short port) { |
| 43 | this.port = port; |
| 44 | } |
| 45 | |
| 46 | public InetAddress getIpAddress() { |
| 47 | return ipAddress; |
| 48 | } |
| 49 | |
| 50 | @JsonProperty("ipAddress") |
| 51 | public void setIpAddress(String ipAddress) { |
| 52 | this.ipAddress = InetAddresses.forString(ipAddress); |
| 53 | } |
| 54 | |
| 55 | public int getPrefixLength() { |
| 56 | return prefixLength; |
| 57 | } |
| 58 | |
| 59 | @JsonProperty("prefixLength") |
| 60 | public void setPrefixLength(int prefixLength) { |
| 61 | this.prefixLength = prefixLength; |
| 62 | } |
| 63 | } |