@Test public void testReadFrom() throws Exception { channelBuffer = ChannelBuffers.copiedBuffer(tlv); ipExtendedReachabilityTlv.readFrom(channelBuffer); assertThat(ipExtendedReachabilityTlv.metric(), is(0)); channelBuffer = ChannelBuffers.copiedBuffer(tlv1); ipExtendedReachabilityTlv.readFrom(channelBuffer); assertThat(ipExtendedReachabilityTlv.metric(), is(0)); channelBuffer = ChannelBuffers.copiedBuffer(tlv2); ipExtendedReachabilityTlv.readFrom(channelBuffer); assertThat(ipExtendedReachabilityTlv.metric(), is(0)); channelBuffer = ChannelBuffers.copiedBuffer(tlv3); ipExtendedReachabilityTlv.readFrom(channelBuffer); assertThat(ipExtendedReachabilityTlv.metric(), is(0)); }
@Override public void readFrom(ChannelBuffer channelBuffer) { this.setMetric(channelBuffer.readInt()); int controlInfo = channelBuffer.readByte(); byte[] tempByteArray = null; String string = IsisUtil.toEightBitBinary(Integer.toBinaryString(controlInfo)); if (string.charAt(0) == '0') { this.setDown(false); } if (string.charAt(1) == '1') { this.setSubTlvPresence(true); } this.setPrefixLength(Integer.parseInt(string.substring(2, string.length()), 2)); if (this.prefixLength >= 0 && this.prefixLength <= 8) { channelBuffer.readByte(); } else if (this.prefixLength >= 8 && this.prefixLength <= 16) { tempByteArray = new byte[IsisUtil.TWO_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.TWO_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 17 && this.prefixLength <= 24) { tempByteArray = new byte[IsisUtil.THREE_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.THREE_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 24 && this.prefixLength <= 32) { tempByteArray = new byte[IsisUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } if (this.isSubTlvPresence()) { this.setSubTlvLength(channelBuffer.readByte()); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readByte()); tlvHeader.setTlvLength(channelBuffer.readByte()); SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { TrafficEngineeringSubTlv subTlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (subTlv != null) { this.addSubTlv(subTlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } }
IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { @Override public void readFrom(ChannelBuffer channelBuffer) { this.setMetric(channelBuffer.readInt()); int controlInfo = channelBuffer.readByte(); byte[] tempByteArray = null; String string = IsisUtil.toEightBitBinary(Integer.toBinaryString(controlInfo)); if (string.charAt(0) == '0') { this.setDown(false); } if (string.charAt(1) == '1') { this.setSubTlvPresence(true); } this.setPrefixLength(Integer.parseInt(string.substring(2, string.length()), 2)); if (this.prefixLength >= 0 && this.prefixLength <= 8) { channelBuffer.readByte(); } else if (this.prefixLength >= 8 && this.prefixLength <= 16) { tempByteArray = new byte[IsisUtil.TWO_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.TWO_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 17 && this.prefixLength <= 24) { tempByteArray = new byte[IsisUtil.THREE_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.THREE_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 24 && this.prefixLength <= 32) { tempByteArray = new byte[IsisUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } if (this.isSubTlvPresence()) { this.setSubTlvLength(channelBuffer.readByte()); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readByte()); tlvHeader.setTlvLength(channelBuffer.readByte()); SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { TrafficEngineeringSubTlv subTlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (subTlv != null) { this.addSubTlv(subTlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } } }
IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { @Override public void readFrom(ChannelBuffer channelBuffer) { this.setMetric(channelBuffer.readInt()); int controlInfo = channelBuffer.readByte(); byte[] tempByteArray = null; String string = IsisUtil.toEightBitBinary(Integer.toBinaryString(controlInfo)); if (string.charAt(0) == '0') { this.setDown(false); } if (string.charAt(1) == '1') { this.setSubTlvPresence(true); } this.setPrefixLength(Integer.parseInt(string.substring(2, string.length()), 2)); if (this.prefixLength >= 0 && this.prefixLength <= 8) { channelBuffer.readByte(); } else if (this.prefixLength >= 8 && this.prefixLength <= 16) { tempByteArray = new byte[IsisUtil.TWO_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.TWO_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 17 && this.prefixLength <= 24) { tempByteArray = new byte[IsisUtil.THREE_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.THREE_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 24 && this.prefixLength <= 32) { tempByteArray = new byte[IsisUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } if (this.isSubTlvPresence()) { this.setSubTlvLength(channelBuffer.readByte()); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readByte()); tlvHeader.setTlvLength(channelBuffer.readByte()); SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { TrafficEngineeringSubTlv subTlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (subTlv != null) { this.addSubTlv(subTlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } } IpExtendedReachabilityTlv(TlvHeader tlvHeader); }
IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { @Override public void readFrom(ChannelBuffer channelBuffer) { this.setMetric(channelBuffer.readInt()); int controlInfo = channelBuffer.readByte(); byte[] tempByteArray = null; String string = IsisUtil.toEightBitBinary(Integer.toBinaryString(controlInfo)); if (string.charAt(0) == '0') { this.setDown(false); } if (string.charAt(1) == '1') { this.setSubTlvPresence(true); } this.setPrefixLength(Integer.parseInt(string.substring(2, string.length()), 2)); if (this.prefixLength >= 0 && this.prefixLength <= 8) { channelBuffer.readByte(); } else if (this.prefixLength >= 8 && this.prefixLength <= 16) { tempByteArray = new byte[IsisUtil.TWO_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.TWO_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 17 && this.prefixLength <= 24) { tempByteArray = new byte[IsisUtil.THREE_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.THREE_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 24 && this.prefixLength <= 32) { tempByteArray = new byte[IsisUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } if (this.isSubTlvPresence()) { this.setSubTlvLength(channelBuffer.readByte()); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readByte()); tlvHeader.setTlvLength(channelBuffer.readByte()); SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { TrafficEngineeringSubTlv subTlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (subTlv != null) { this.addSubTlv(subTlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } } IpExtendedReachabilityTlv(TlvHeader tlvHeader); List<TrafficEngineeringSubTlv> teTlvs(); String prefix(); void setPrefix(String prefix); boolean isDown(); void setDown(boolean upOrDown); boolean isSubTlvPresence(); void setSubTlvPresence(boolean subTlvPresence); int prefixLength(); void setPrefixLength(int prefixLength); void addSubTlv(TrafficEngineeringSubTlv trafEnginSubTlv); byte subTlvLength(); void setSubTlvLength(byte subTlvLength); int metric(); void setMetric(int metric); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); @Override String toString(); }
IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { @Override public void readFrom(ChannelBuffer channelBuffer) { this.setMetric(channelBuffer.readInt()); int controlInfo = channelBuffer.readByte(); byte[] tempByteArray = null; String string = IsisUtil.toEightBitBinary(Integer.toBinaryString(controlInfo)); if (string.charAt(0) == '0') { this.setDown(false); } if (string.charAt(1) == '1') { this.setSubTlvPresence(true); } this.setPrefixLength(Integer.parseInt(string.substring(2, string.length()), 2)); if (this.prefixLength >= 0 && this.prefixLength <= 8) { channelBuffer.readByte(); } else if (this.prefixLength >= 8 && this.prefixLength <= 16) { tempByteArray = new byte[IsisUtil.TWO_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.TWO_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 17 && this.prefixLength <= 24) { tempByteArray = new byte[IsisUtil.THREE_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.THREE_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } else if (this.prefixLength >= 24 && this.prefixLength <= 32) { tempByteArray = new byte[IsisUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); this.setPrefix(IsisUtil.prefixConversion(tempByteArray)); } if (this.isSubTlvPresence()) { this.setSubTlvLength(channelBuffer.readByte()); while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readByte()); tlvHeader.setTlvLength(channelBuffer.readByte()); SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType()); if (tlvValue != null) { TrafficEngineeringSubTlv subTlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength())); if (subTlv != null) { this.addSubTlv(subTlv); } } else { channelBuffer.readBytes(tlvHeader.tlvLength()); } } } } IpExtendedReachabilityTlv(TlvHeader tlvHeader); List<TrafficEngineeringSubTlv> teTlvs(); String prefix(); void setPrefix(String prefix); boolean isDown(); void setDown(boolean upOrDown); boolean isSubTlvPresence(); void setSubTlvPresence(boolean subTlvPresence); int prefixLength(); void setPrefixLength(int prefixLength); void addSubTlv(TrafficEngineeringSubTlv trafEnginSubTlv); byte subTlvLength(); void setSubTlvLength(byte subTlvLength); int metric(); void setMetric(int metric); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); @Override String toString();  }