@Override public String toString() { return toStringHelper(getClass()) .add("chassisId", Arrays.toString(chassisId.getValue())) .add("portId", Arrays.toString(portId.getValue())) .add("ttl", Arrays.toString(ttl.getValue())) .add("ethType", Short.toString(ethType)) .toString(); // TODO: need to handle optionalTLVList } }
public String getPortNameString() { ByteBuffer portBB = ByteBuffer.wrap(this.getPortId().getValue()); byte type = portBB.get(); if (type == PORT_TLV_INTERFACE_NAME_SUBTYPE) { return new String(portBB.array(), portBB.position(), portBB.remaining(), StandardCharsets.UTF_8); } else { return null; } }
public String getPortDescString() { LLDPTLV tlv = getPortDescTLV(); if (tlv != null) { return new String(tlv.getValue(), StandardCharsets.UTF_8); } return null; }
public Integer getPort() { ByteBuffer portBB = ByteBuffer.wrap(this.getPortId().getValue()); byte type = portBB.get(); if (type == PORT_TLV_COMPONENT_SUBTYPE) { return Integer.parseInt(new String(portBB.array(), portBB.position(), portBB.remaining(), StandardCharsets.UTF_8)); } else { return -1; } }
public short getTtlBySeconds() { ByteBuffer portBB = ByteBuffer.wrap(this.getTtl().getValue()); return portBB.getShort(); }
public MacAddress getChassisIdByMac() { ByteBuffer portBB = ByteBuffer.wrap(this.getChassisId().getValue()); byte type = portBB.get(); if (type == CHASSIS_TLV_SUBTYPE) { byte[] bytes = new byte[portBB.remaining()]; System.arraycopy(portBB.array(), portBB.position(), bytes, 0, MacAddress.MAC_ADDRESS_LENGTH); return new MacAddress(bytes); } else { return MacAddress.NONE; } }