@Override @XmlElement(name = "value") protected String getValueString() { return String.valueOf(NetUtils.getUnsignedShort(port)); }
@Override @XmlElement(name = "value") protected String getValueString() { return String.valueOf(NetUtils.getUnsignedShort(port)); }
@Override @XmlElement(name = "value") protected String getValueString() { return String.format("0X%s", Integer.toHexString(NetUtils.getUnsignedShort(ethertype))); }
public String stringify(Object value) { if (value == null) { return null; } switch (this) { case DL_DST: case DL_SRC: return HexEncode.bytesToHexStringFormat((byte[]) value); case DL_TYPE: case DL_VLAN: return ((Integer) NetUtils.getUnsignedShort((Short) value)).toString(); case NW_SRC: case NW_DST: return ((InetAddress) value).getHostAddress(); case NW_TOS: return ((Integer) NetUtils.getUnsignedByte((Byte) value)).toString(); case TP_SRC: case TP_DST: return ((Integer) NetUtils.getUnsignedShort((Short) value)).toString(); default: break; } return value.toString(); }
private static Integer transportPort(final Match sourceMatch, final MatchType matchType) { MatchField transportPort = sourceMatch.getField(matchType); if (transportPort != null && transportPort.getValue() != null && transportPort.getValue().getClass().equals(Short.class)) { return NetUtils.getUnsignedShort((short) transportPort.getValue()); } return null; }
/** * Converts the Openflow port number to the equivalent NodeConnector. */ public static NodeConnector toNodeConnector(short ofPort, Node node) { // Restore original OF unsigned 16 bits value for the comparison int unsignedOFPort = NetUtils.getUnsignedShort(ofPort); log.trace("Openflow port number signed: {} unsigned: {}", ofPort, unsignedOFPort); if (unsignedOFPort > maxOFPhysicalPort) { if (ofPort == OFPort.OFPP_LOCAL.getValue()) { return NodeConnectorCreator.createNodeConnector( NodeConnectorIDType.SWSTACK, NodeConnector.SPECIALNODECONNECTORID, node); } else if (ofPort == OFPort.OFPP_NORMAL.getValue()) { return NodeConnectorCreator.createNodeConnector( NodeConnectorIDType.HWPATH, NodeConnector.SPECIALNODECONNECTORID, node); } else if (ofPort == OFPort.OFPP_CONTROLLER.getValue()) { return NodeConnectorCreator.createNodeConnector( NodeConnectorIDType.CONTROLLER, NodeConnector.SPECIALNODECONNECTORID, node); } } return NodeConnectorCreator.createNodeConnector(ofPort, node); }
.getValue()); row.put(MatchType.TP_SRC.id(), String.valueOf(NetUtils.getUnsignedShort(tpSrc))); } else { row.put(MatchType.TP_SRC.id(), "*"); .getValue()); row.put(MatchType.TP_DST.id(), String.valueOf(NetUtils.getUnsignedShort(tpDst))); } else { row.put(MatchType.TP_DST.id(), "*"); ((Integer) flowOnNode.getDurationSeconds()).toString()); row.put("idleTimeout", ((Short) flow.getIdleTimeout()).toString()); row.put("priority", String.valueOf(NetUtils.getUnsignedShort(flow.getPriority()))); return row;
private static VlanMatch vlanMatch(final Match sourceMatch) { VlanMatchBuilder vlanMatchBuild = new VlanMatchBuilder(); MatchField vlan = sourceMatch.getField(MatchType.DL_VLAN); if (vlan != null && vlan.getValue() != null) { VlanIdBuilder vlanIDBuilder = new VlanIdBuilder(); short vid = (short)vlan.getValue(); boolean present = (vid != MatchType.DL_VLAN_NONE); vlanIDBuilder.setVlanId(new VlanId((NetUtils .getUnsignedShort(vid)))); vlanIDBuilder.setVlanIdPresent(present); vlanMatchBuild.setVlanId(vlanIDBuilder.build()); } MatchField vlanPriority = sourceMatch.getField(MatchType.DL_VLAN_PR); if (vlanPriority != null && vlanPriority.getValue() != null) { vlanMatchBuild.setVlanPcp(new VlanPcp((short) ((byte) vlanPriority .getValue()))); } if((vlan != null && vlan.getValue() != null) || (vlanPriority != null && vlanPriority.getValue() != null)) { return vlanMatchBuild.build(); } return null; }
private static EthernetMatch ethernetMatch(final Match sourceMatch) { final EthernetMatchBuilder targetEthMatchBuild = new EthernetMatchBuilder(); if(sourceMatch.getField(DL_SRC) != null && sourceMatch.getField(DL_SRC).getValue() != null) { EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder() .setAddress(ethernetSourceAddress(sourceMatch)); targetEthMatchBuild.setEthernetSource(ethSourBuild.build()); } if(sourceMatch.getField(DL_DST) != null && sourceMatch.getField(DL_DST).getValue() != null) { EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder() .setAddress(ethernetDestAddress(sourceMatch)); targetEthMatchBuild.setEthernetDestination(ethDestBuild.build()); } final MatchField dataLinkType = sourceMatch.getField(MatchType.DL_TYPE); if (dataLinkType != null && dataLinkType.getValue() != null) { EtherType etherType = new EtherType((long) NetUtils.getUnsignedShort((Short) dataLinkType.getValue())); EthernetTypeBuilder ethType = new EthernetTypeBuilder() .setType(etherType); targetEthMatchBuild.setEthernetType(ethType.build()); } if((sourceMatch.getField(DL_SRC) != null && sourceMatch.getField(DL_SRC).getValue() != null) || (sourceMatch.getField(DL_DST) != null && sourceMatch.getField(DL_DST).getValue() != null)|| dataLinkType != null ) { return targetEthMatchBuild.build(); } return null; }
Short port = ((OFActionTransportLayerSource) ofAction) .getTransportPort(); int intPort = NetUtils.getUnsignedShort(port); salAction = new SetTpSrc(intPort); } else if (ofAction instanceof OFActionTransportLayerDestination) { Short port = ((OFActionTransportLayerDestination) ofAction) .getTransportPort(); int intPort = NetUtils.getUnsignedShort(port); salAction = new SetTpDst(intPort);