@Test public void testReadFrom() throws Exception { ospfPacketHeader = new OspfPacketHeader(); ospfPacketHeader.setAreaId(Ip4Address.valueOf("1.1.1.1")); ospfPacketHeader.setAuthentication(0); ospfPacketHeader.setAuthType(0); ospfPacketHeader.setChecksum(12345); ospfPacketHeader.setDestinationIp(Ip4Address.valueOf("10.10.10.10")); ospfPacketHeader.setOspfPacLength(56); ospfPacketHeader.setOspftype(3); ospfPacketHeader.setOspfVer(2); ospfPacketHeader.setRouterId(Ip4Address.valueOf("2.2.2.2")); ospfPacketHeader.setSourceIp(Ip4Address.valueOf("3.3.3.3")); lsRequest = new LsRequest(ospfPacketHeader); result1 = createByteLsReqestPacket(); channelBuffer = ChannelBuffers.copiedBuffer(result1); lsRequest.readFrom(channelBuffer); assertThat(lsRequest, is(notNullValue())); assertThat(lsRequest.ospfMessageType(), is(OspfPacketType.LSREQUEST)); }
@Override public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { while (channelBuffer.readableBytes() >= OspfUtil.LSREQUEST_LENGTH) { LsRequestPacket lsRequestPacket = new LsRequestPacket(); lsRequestPacket.setLsType(channelBuffer.readInt()); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setLinkStateId(Ip4Address.valueOf(tempByteArray).toString()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setOwnRouterId(Ip4Address.valueOf(tempByteArray).toString()); this.addLinkStateRequests(lsRequestPacket); } }
LsRequest extends OspfPacketHeader { @Override public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { while (channelBuffer.readableBytes() >= OspfUtil.LSREQUEST_LENGTH) { LsRequestPacket lsRequestPacket = new LsRequestPacket(); lsRequestPacket.setLsType(channelBuffer.readInt()); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setLinkStateId(Ip4Address.valueOf(tempByteArray).toString()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setOwnRouterId(Ip4Address.valueOf(tempByteArray).toString()); this.addLinkStateRequests(lsRequestPacket); } } }
LsRequest extends OspfPacketHeader { @Override public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { while (channelBuffer.readableBytes() >= OspfUtil.LSREQUEST_LENGTH) { LsRequestPacket lsRequestPacket = new LsRequestPacket(); lsRequestPacket.setLsType(channelBuffer.readInt()); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setLinkStateId(Ip4Address.valueOf(tempByteArray).toString()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setOwnRouterId(Ip4Address.valueOf(tempByteArray).toString()); this.addLinkStateRequests(lsRequestPacket); } } LsRequest();  LsRequest(OspfPacketHeader ospfHeader); }
LsRequest extends OspfPacketHeader { @Override public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { while (channelBuffer.readableBytes() >= OspfUtil.LSREQUEST_LENGTH) { LsRequestPacket lsRequestPacket = new LsRequestPacket(); lsRequestPacket.setLsType(channelBuffer.readInt()); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setLinkStateId(Ip4Address.valueOf(tempByteArray).toString()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setOwnRouterId(Ip4Address.valueOf(tempByteArray).toString()); this.addLinkStateRequests(lsRequestPacket); } } LsRequest();  LsRequest(OspfPacketHeader ospfHeader); void addLinkStateRequests(LsRequestPacket lsRequestPacket); List<LsRequestPacket> getLinkStateRequests(); @Override OspfPacketType ospfMessageType(); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); byte[] getLsrHeaderAsByteArray(); byte[] getLsrBodyAsByteArray(); @Override String toString(); }
LsRequest extends OspfPacketHeader { @Override public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { while (channelBuffer.readableBytes() >= OspfUtil.LSREQUEST_LENGTH) { LsRequestPacket lsRequestPacket = new LsRequestPacket(); lsRequestPacket.setLsType(channelBuffer.readInt()); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setLinkStateId(Ip4Address.valueOf(tempByteArray).toString()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); lsRequestPacket.setOwnRouterId(Ip4Address.valueOf(tempByteArray).toString()); this.addLinkStateRequests(lsRequestPacket); } } LsRequest();  LsRequest(OspfPacketHeader ospfHeader); void addLinkStateRequests(LsRequestPacket lsRequestPacket); List<LsRequestPacket> getLinkStateRequests(); @Override OspfPacketType ospfMessageType(); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); byte[] getLsrHeaderAsByteArray(); byte[] getLsrBodyAsByteArray(); @Override String toString();  }