@Test public void testReadFrom() throws Exception { channelBuffer = ChannelBuffers.copiedBuffer(l1Lsp); lsPdu.readFrom(channelBuffer); assertThat(lsPdu, is(notNullValue())); }
@Override public void readFrom(ChannelBuffer channelBuffer) { this.setPduLength(channelBuffer.readUnsignedShort()); this.setRemainingLifeTime(channelBuffer.readUnsignedShort()); byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE); this.setLspId(IsisUtil.systemIdPlus(tempByteArray)); this.setSequenceNumber(channelBuffer.readInt()); this.setCheckSum(channelBuffer.readUnsignedShort()); int typeTemp = channelBuffer.readUnsignedByte(); byte isTypeByte = (byte) typeTemp; String tempValue = String.format("%8s", Integer.toBinaryString(isTypeByte & 0xFF)).replace(' ', '0'); int pBit = Integer.parseInt(new Character(tempValue.charAt(0)).toString()); if (pBit == 1) { this.setPartitionRepair(true); } else { this.setPartitionRepair(false); } int attValue = Integer.parseInt(tempValue.substring(1, 5), 2); switch (AttachedToOtherAreas.get(attValue)) { case DEFAULTMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC); break; case DELAYMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DELAYMETRIC); break; case EXPENSEMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.EXPENSEMETRIC); break; case ERRORMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.ERRORMETRIC); break; case NONE: this.setAttachedToOtherAreas(AttachedToOtherAreas.NONE); break; default: break; } int lspdbol = Integer.parseInt(new Character(tempValue.charAt(5)).toString()); if (lspdbol == 1) { this.setLspDbol(true); } else { this.setLspDbol(false); } int isType = Integer.parseInt(tempValue.substring(6, 8), 2); byte isTypeByteValue = (byte) isType; this.setIntermediateSystemType(isTypeByteValue); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedByte()); tlvHeader.setTlvLength(channelBuffer.readUnsignedByte()); TlvType tlvValue = TlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (tlv != null) { this.variableLengths.add(tlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } }
LsPdu extends IsisHeader { @Override public void readFrom(ChannelBuffer channelBuffer) { this.setPduLength(channelBuffer.readUnsignedShort()); this.setRemainingLifeTime(channelBuffer.readUnsignedShort()); byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE); this.setLspId(IsisUtil.systemIdPlus(tempByteArray)); this.setSequenceNumber(channelBuffer.readInt()); this.setCheckSum(channelBuffer.readUnsignedShort()); int typeTemp = channelBuffer.readUnsignedByte(); byte isTypeByte = (byte) typeTemp; String tempValue = String.format("%8s", Integer.toBinaryString(isTypeByte & 0xFF)).replace(' ', '0'); int pBit = Integer.parseInt(new Character(tempValue.charAt(0)).toString()); if (pBit == 1) { this.setPartitionRepair(true); } else { this.setPartitionRepair(false); } int attValue = Integer.parseInt(tempValue.substring(1, 5), 2); switch (AttachedToOtherAreas.get(attValue)) { case DEFAULTMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC); break; case DELAYMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DELAYMETRIC); break; case EXPENSEMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.EXPENSEMETRIC); break; case ERRORMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.ERRORMETRIC); break; case NONE: this.setAttachedToOtherAreas(AttachedToOtherAreas.NONE); break; default: break; } int lspdbol = Integer.parseInt(new Character(tempValue.charAt(5)).toString()); if (lspdbol == 1) { this.setLspDbol(true); } else { this.setLspDbol(false); } int isType = Integer.parseInt(tempValue.substring(6, 8), 2); byte isTypeByteValue = (byte) isType; this.setIntermediateSystemType(isTypeByteValue); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedByte()); tlvHeader.setTlvLength(channelBuffer.readUnsignedByte()); TlvType tlvValue = TlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (tlv != null) { this.variableLengths.add(tlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } }
LsPdu extends IsisHeader { @Override public void readFrom(ChannelBuffer channelBuffer) { this.setPduLength(channelBuffer.readUnsignedShort()); this.setRemainingLifeTime(channelBuffer.readUnsignedShort()); byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE); this.setLspId(IsisUtil.systemIdPlus(tempByteArray)); this.setSequenceNumber(channelBuffer.readInt()); this.setCheckSum(channelBuffer.readUnsignedShort()); int typeTemp = channelBuffer.readUnsignedByte(); byte isTypeByte = (byte) typeTemp; String tempValue = String.format("%8s", Integer.toBinaryString(isTypeByte & 0xFF)).replace(' ', '0'); int pBit = Integer.parseInt(new Character(tempValue.charAt(0)).toString()); if (pBit == 1) { this.setPartitionRepair(true); } else { this.setPartitionRepair(false); } int attValue = Integer.parseInt(tempValue.substring(1, 5), 2); switch (AttachedToOtherAreas.get(attValue)) { case DEFAULTMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC); break; case DELAYMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DELAYMETRIC); break; case EXPENSEMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.EXPENSEMETRIC); break; case ERRORMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.ERRORMETRIC); break; case NONE: this.setAttachedToOtherAreas(AttachedToOtherAreas.NONE); break; default: break; } int lspdbol = Integer.parseInt(new Character(tempValue.charAt(5)).toString()); if (lspdbol == 1) { this.setLspDbol(true); } else { this.setLspDbol(false); } int isType = Integer.parseInt(tempValue.substring(6, 8), 2); byte isTypeByteValue = (byte) isType; this.setIntermediateSystemType(isTypeByteValue); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedByte()); tlvHeader.setTlvLength(channelBuffer.readUnsignedByte()); TlvType tlvValue = TlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (tlv != null) { this.variableLengths.add(tlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } LsPdu(IsisHeader isisHeader); }
LsPdu extends IsisHeader { @Override public void readFrom(ChannelBuffer channelBuffer) { this.setPduLength(channelBuffer.readUnsignedShort()); this.setRemainingLifeTime(channelBuffer.readUnsignedShort()); byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE); this.setLspId(IsisUtil.systemIdPlus(tempByteArray)); this.setSequenceNumber(channelBuffer.readInt()); this.setCheckSum(channelBuffer.readUnsignedShort()); int typeTemp = channelBuffer.readUnsignedByte(); byte isTypeByte = (byte) typeTemp; String tempValue = String.format("%8s", Integer.toBinaryString(isTypeByte & 0xFF)).replace(' ', '0'); int pBit = Integer.parseInt(new Character(tempValue.charAt(0)).toString()); if (pBit == 1) { this.setPartitionRepair(true); } else { this.setPartitionRepair(false); } int attValue = Integer.parseInt(tempValue.substring(1, 5), 2); switch (AttachedToOtherAreas.get(attValue)) { case DEFAULTMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC); break; case DELAYMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DELAYMETRIC); break; case EXPENSEMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.EXPENSEMETRIC); break; case ERRORMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.ERRORMETRIC); break; case NONE: this.setAttachedToOtherAreas(AttachedToOtherAreas.NONE); break; default: break; } int lspdbol = Integer.parseInt(new Character(tempValue.charAt(5)).toString()); if (lspdbol == 1) { this.setLspDbol(true); } else { this.setLspDbol(false); } int isType = Integer.parseInt(tempValue.substring(6, 8), 2); byte isTypeByteValue = (byte) isType; this.setIntermediateSystemType(isTypeByteValue); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedByte()); tlvHeader.setTlvLength(channelBuffer.readUnsignedByte()); TlvType tlvValue = TlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (tlv != null) { this.variableLengths.add(tlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } LsPdu(IsisHeader isisHeader); List<IsisTlv> tlvs(); void addTlv(IsisTlv isisTlv); int remainingLifeTime(); void setRemainingLifeTime(int remainingLifeTime); boolean lspDbol(); void setLspDbol(boolean lspDbol); byte typeBlock(); void setTypeBlock(byte typeBlock); int sequenceNumber(); void setSequenceNumber(int sequenceNumber); int checkSum(); void setCheckSum(int checkSum); boolean partitionRepair(); void setPartitionRepair(boolean partitionRepair); AttachedToOtherAreas attachedToOtherAreas(); void setAttachedToOtherAreas(AttachedToOtherAreas attachedToOtherAreas); byte intermediateSystemType(); void setIntermediateSystemType(byte intermediateSystemType); String lspId(); void setLspId(String lspId); int pduLength(); void setPduLength(int pduLength); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); byte[] l1l2IsisPduHeader(); byte[] l1l2LsPduBody(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
LsPdu extends IsisHeader { @Override public void readFrom(ChannelBuffer channelBuffer) { this.setPduLength(channelBuffer.readUnsignedShort()); this.setRemainingLifeTime(channelBuffer.readUnsignedShort()); byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE); this.setLspId(IsisUtil.systemIdPlus(tempByteArray)); this.setSequenceNumber(channelBuffer.readInt()); this.setCheckSum(channelBuffer.readUnsignedShort()); int typeTemp = channelBuffer.readUnsignedByte(); byte isTypeByte = (byte) typeTemp; String tempValue = String.format("%8s", Integer.toBinaryString(isTypeByte & 0xFF)).replace(' ', '0'); int pBit = Integer.parseInt(new Character(tempValue.charAt(0)).toString()); if (pBit == 1) { this.setPartitionRepair(true); } else { this.setPartitionRepair(false); } int attValue = Integer.parseInt(tempValue.substring(1, 5), 2); switch (AttachedToOtherAreas.get(attValue)) { case DEFAULTMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC); break; case DELAYMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.DELAYMETRIC); break; case EXPENSEMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.EXPENSEMETRIC); break; case ERRORMETRIC: this.setAttachedToOtherAreas(AttachedToOtherAreas.ERRORMETRIC); break; case NONE: this.setAttachedToOtherAreas(AttachedToOtherAreas.NONE); break; default: break; } int lspdbol = Integer.parseInt(new Character(tempValue.charAt(5)).toString()); if (lspdbol == 1) { this.setLspDbol(true); } else { this.setLspDbol(false); } int isType = Integer.parseInt(tempValue.substring(6, 8), 2); byte isTypeByteValue = (byte) isType; this.setIntermediateSystemType(isTypeByteValue); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedByte()); tlvHeader.setTlvLength(channelBuffer.readUnsignedByte()); TlvType tlvValue = TlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (tlv != null) { this.variableLengths.add(tlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } LsPdu(IsisHeader isisHeader); List<IsisTlv> tlvs(); void addTlv(IsisTlv isisTlv); int remainingLifeTime(); void setRemainingLifeTime(int remainingLifeTime); boolean lspDbol(); void setLspDbol(boolean lspDbol); byte typeBlock(); void setTypeBlock(byte typeBlock); int sequenceNumber(); void setSequenceNumber(int sequenceNumber); int checkSum(); void setCheckSum(int checkSum); boolean partitionRepair(); void setPartitionRepair(boolean partitionRepair); AttachedToOtherAreas attachedToOtherAreas(); void setAttachedToOtherAreas(AttachedToOtherAreas attachedToOtherAreas); byte intermediateSystemType(); void setIntermediateSystemType(byte intermediateSystemType); String lspId(); void setLspId(String lspId); int pduLength(); void setPduLength(int pduLength); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); byte[] l1l2IsisPduHeader(); byte[] l1l2LsPduBody(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }