@Test public void testReadFrom() throws Exception { tlvHeader = new TlvHeader(); tlvHeader.setTlvType(4); tlvHeader.setTlvLength(4); remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(tlvHeader); channelBuffer = ChannelBuffers.copiedBuffer(packet); remoteInterfaceIpAddress.readFrom(channelBuffer); assertThat(remoteInterfaceIpAddress, is(notNullValue())); }
public void readFrom(ChannelBuffer channelBuffer) throws Exception { while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.addRemoteInterfaceAddress(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::RemoteInterfaceIPAddress:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } }
RemoteInterfaceIpAddress extends TlvHeader implements LinkSubType { public void readFrom(ChannelBuffer channelBuffer) throws Exception { while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.addRemoteInterfaceAddress(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::RemoteInterfaceIPAddress:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } } }
RemoteInterfaceIpAddress extends TlvHeader implements LinkSubType { public void readFrom(ChannelBuffer channelBuffer) throws Exception { while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.addRemoteInterfaceAddress(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::RemoteInterfaceIPAddress:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } } RemoteInterfaceIpAddress(TlvHeader header); }
RemoteInterfaceIpAddress extends TlvHeader implements LinkSubType { public void readFrom(ChannelBuffer channelBuffer) throws Exception { while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.addRemoteInterfaceAddress(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::RemoteInterfaceIPAddress:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } } RemoteInterfaceIpAddress(TlvHeader header); void addRemoteInterfaceAddress(String remoteAddress); List<String> getRemoteInterfaceAddress(); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLinkSubTypeTlvBodyAsByteArray(); String toString(); }
RemoteInterfaceIpAddress extends TlvHeader implements LinkSubType { public void readFrom(ChannelBuffer channelBuffer) throws Exception { while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.addRemoteInterfaceAddress(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::RemoteInterfaceIPAddress:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } } RemoteInterfaceIpAddress(TlvHeader header); void addRemoteInterfaceAddress(String remoteAddress); List<String> getRemoteInterfaceAddress(); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLinkSubTypeTlvBodyAsByteArray(); String toString();  }