private static void addPortDesc(ONOSLLDP probe, String portDesc) { if (portDesc != null && !portDesc.isEmpty()) { byte[] bPortDesc = portDesc.getBytes(StandardCharsets.UTF_8); if (bPortDesc.length > LLDPTLV.MAX_LENGTH) { bPortDesc = Arrays.copyOf(bPortDesc, LLDPTLV.MAX_LENGTH); } LLDPTLV portDescTlv = new LLDPTLV() .setType(PORT_DESC_TLV_TYPE) .setLength((short) bPortDesc.length) .setValue(bPortDesc); probe.addOptionalTLV(portDescTlv); } }
public void setPortId(final int portNumber) { byte[] port = ArrayUtils.addAll(new byte[] {PORT_TLV_COMPONENT_SUBTYPE}, String.valueOf(portNumber).getBytes(StandardCharsets.UTF_8)); LLDPTLV portTLV = new LLDPTLV(); portTLV.setLength((short) port.length); portTLV.setType(PORT_TLV_TYPE); portTLV.setValue(port); this.setPortId(portTLV); }
public void setPortName(final String portName) { byte[] port = ArrayUtils.addAll(new byte[] {PORT_TLV_INTERFACE_NAME_SUBTYPE}, portName.getBytes(StandardCharsets.UTF_8)); LLDPTLV portTLV = new LLDPTLV(); portTLV.setLength((short) port.length); portTLV.setType(PORT_TLV_TYPE); portTLV.setValue(port); this.setPortId(portTLV); }
public ONOSLLDP(byte... subtype) { super(); for (byte st : subtype) { opttlvs.put(st, new LLDPOrganizationalTLV()); } // guarantee the following (name and device) TLVs exist opttlvs.putIfAbsent(NAME_SUBTYPE, new LLDPOrganizationalTLV()); opttlvs.putIfAbsent(DEVICE_SUBTYPE, new LLDPOrganizationalTLV()); setName(DEFAULT_NAME); setDevice(DEFAULT_DEVICE); setOptionalTLVList(Lists.newArrayList(opttlvs.values())); setTtl(new LLDPTLV().setType(TTL_TLV_TYPE) .setLength((short) ttlValue.length) .setValue(ttlValue)); }
public void setChassisId(final ChassisId chassisId) { MacAddress chassisMac = MacAddress.valueOf(chassisId.value()); byte[] chassis = ArrayUtils.addAll(new byte[] {CHASSIS_TLV_SUBTYPE}, chassisMac.toBytes()); LLDPTLV chassisTLV = new LLDPTLV(); chassisTLV.setLength(CHASSIS_TLV_SIZE); chassisTLV.setType(CHASSIS_TLV_TYPE); chassisTLV.setValue(chassis); this.setChassisId(chassisTLV); }