@Test(expected = Exception.class) public void testReadFrom() throws Exception { opqueHeader = new OpaqueLsaHeader(); opqueHeader.setLsType(10); opqueHeader.setLsPacketLen(48); opqueHeader.setLsCheckSum(10); opqueHeader.setAge(4); opqueHeader.setOpaqueId(1); opqueHeader.setOpaqueType(10); opqueHeader.setLsSequenceNo(250); opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165")); opqueHeader.setOptions(66); opaqueLsa10 = new OpaqueLsa10(opqueHeader); channelBuffer = ChannelBuffers.copiedBuffer(packet); opaqueLsa10.readFrom(channelBuffer); result = opaqueLsa10.asBytes(); assertThat(result, is(notNullValue())); }
public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { if (this.opaqueId() == OspfParameters.TRAFFIC_ENGINEERING) { while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedShort()); tlvHeader.setTlvLength(channelBuffer.readUnsignedShort()); if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.ROUTER.value()) { RouterTlv routerTlv = new RouterTlv(tlvHeader); routerTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(routerTlv); } else if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.LINK.value()) { LinkTlv linkTlv = new LinkTlv(tlvHeader); linkTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(linkTlv); } } } else { int length = channelBuffer.readableBytes(); opaqueInfo = new byte[length]; channelBuffer.readBytes(opaqueInfo, 0, length); } } catch (Exception e) { log.debug("Error::OpaqueLsa10:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } }
OpaqueLsa10 extends OpaqueLsaHeader { public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { if (this.opaqueId() == OspfParameters.TRAFFIC_ENGINEERING) { while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedShort()); tlvHeader.setTlvLength(channelBuffer.readUnsignedShort()); if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.ROUTER.value()) { RouterTlv routerTlv = new RouterTlv(tlvHeader); routerTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(routerTlv); } else if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.LINK.value()) { LinkTlv linkTlv = new LinkTlv(tlvHeader); linkTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(linkTlv); } } } else { int length = channelBuffer.readableBytes(); opaqueInfo = new byte[length]; channelBuffer.readBytes(opaqueInfo, 0, length); } } catch (Exception e) { log.debug("Error::OpaqueLsa10:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } }
OpaqueLsa10 extends OpaqueLsaHeader { public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { if (this.opaqueId() == OspfParameters.TRAFFIC_ENGINEERING) { while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedShort()); tlvHeader.setTlvLength(channelBuffer.readUnsignedShort()); if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.ROUTER.value()) { RouterTlv routerTlv = new RouterTlv(tlvHeader); routerTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(routerTlv); } else if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.LINK.value()) { LinkTlv linkTlv = new LinkTlv(tlvHeader); linkTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(linkTlv); } } } else { int length = channelBuffer.readableBytes(); opaqueInfo = new byte[length]; channelBuffer.readBytes(opaqueInfo, 0, length); } } catch (Exception e) { log.debug("Error::OpaqueLsa10:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } OpaqueLsa10(OpaqueLsaHeader lsaHeader); }
OpaqueLsa10 extends OpaqueLsaHeader { public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { if (this.opaqueId() == OspfParameters.TRAFFIC_ENGINEERING) { while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedShort()); tlvHeader.setTlvLength(channelBuffer.readUnsignedShort()); if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.ROUTER.value()) { RouterTlv routerTlv = new RouterTlv(tlvHeader); routerTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(routerTlv); } else if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.LINK.value()) { LinkTlv linkTlv = new LinkTlv(tlvHeader); linkTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(linkTlv); } } } else { int length = channelBuffer.readableBytes(); opaqueInfo = new byte[length]; channelBuffer.readBytes(opaqueInfo, 0, length); } } catch (Exception e) { log.debug("Error::OpaqueLsa10:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } OpaqueLsa10(OpaqueLsaHeader lsaHeader); List<TopLevelTlv> topLevelValues(); void addValue(TopLevelTlv value); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLsaBodyAsByteArray(); @Override OspfLsaType getOspfLsaType(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
OpaqueLsa10 extends OpaqueLsaHeader { public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { if (this.opaqueId() == OspfParameters.TRAFFIC_ENGINEERING) { while (channelBuffer.readableBytes() > 0) { TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(channelBuffer.readUnsignedShort()); tlvHeader.setTlvLength(channelBuffer.readUnsignedShort()); if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.ROUTER.value()) { RouterTlv routerTlv = new RouterTlv(tlvHeader); routerTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(routerTlv); } else if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.LINK.value()) { LinkTlv linkTlv = new LinkTlv(tlvHeader); linkTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength())); this.addValue(linkTlv); } } } else { int length = channelBuffer.readableBytes(); opaqueInfo = new byte[length]; channelBuffer.readBytes(opaqueInfo, 0, length); } } catch (Exception e) { log.debug("Error::OpaqueLsa10:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } OpaqueLsa10(OpaqueLsaHeader lsaHeader); List<TopLevelTlv> topLevelValues(); void addValue(TopLevelTlv value); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLsaBodyAsByteArray(); @Override OspfLsaType getOspfLsaType(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }