@Test public void testReadFrom() throws Exception { ospflsaLink = createOspfLsaLink(); routerLsa.addRouterLink(ospflsaLink); inputArray = createByteForRouterLsa(); lsaHeader = createLsaHeader(); routerLsa = new RouterLsa(lsaHeader); channelBuffer = ChannelBuffers.copiedBuffer(inputArray); routerLsa.readFrom(channelBuffer); assertThat(routerLsa, is(notNullValue())); }
public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { int veb = channelBuffer.readByte(); int unUsed = channelBuffer.readByte(); String strVeb = Integer.toBinaryString(veb); if (strVeb.length() == 3) { this.setVirtualEndPoint((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(2))) == 1) ? true : false); } else if (strVeb.length() == 2) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); } else if (strVeb.length() == 1) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter(false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); } this.setNoLink(channelBuffer.readUnsignedShort()); while (channelBuffer.readableBytes() >= OspfUtil.TWELVE_BYTES) { OspfLsaLink ospfLsaLink = new OspfLsaLink(); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkData(InetAddress.getByAddress(tempByteArray).getHostName()); ospfLsaLink.setLinkType(channelBuffer.readByte()); ospfLsaLink.setTos(channelBuffer.readByte()); ospfLsaLink.setMetric(channelBuffer.readUnsignedShort()); this.addRouterLink(ospfLsaLink); } } catch (Exception e) { log.debug("Error::RouterLsa:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } }
RouterLsa extends LsaHeader { public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { int veb = channelBuffer.readByte(); int unUsed = channelBuffer.readByte(); String strVeb = Integer.toBinaryString(veb); if (strVeb.length() == 3) { this.setVirtualEndPoint((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(2))) == 1) ? true : false); } else if (strVeb.length() == 2) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); } else if (strVeb.length() == 1) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter(false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); } this.setNoLink(channelBuffer.readUnsignedShort()); while (channelBuffer.readableBytes() >= OspfUtil.TWELVE_BYTES) { OspfLsaLink ospfLsaLink = new OspfLsaLink(); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkData(InetAddress.getByAddress(tempByteArray).getHostName()); ospfLsaLink.setLinkType(channelBuffer.readByte()); ospfLsaLink.setTos(channelBuffer.readByte()); ospfLsaLink.setMetric(channelBuffer.readUnsignedShort()); this.addRouterLink(ospfLsaLink); } } catch (Exception e) { log.debug("Error::RouterLsa:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } }
RouterLsa extends LsaHeader { public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { int veb = channelBuffer.readByte(); int unUsed = channelBuffer.readByte(); String strVeb = Integer.toBinaryString(veb); if (strVeb.length() == 3) { this.setVirtualEndPoint((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(2))) == 1) ? true : false); } else if (strVeb.length() == 2) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); } else if (strVeb.length() == 1) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter(false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); } this.setNoLink(channelBuffer.readUnsignedShort()); while (channelBuffer.readableBytes() >= OspfUtil.TWELVE_BYTES) { OspfLsaLink ospfLsaLink = new OspfLsaLink(); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkData(InetAddress.getByAddress(tempByteArray).getHostName()); ospfLsaLink.setLinkType(channelBuffer.readByte()); ospfLsaLink.setTos(channelBuffer.readByte()); ospfLsaLink.setMetric(channelBuffer.readUnsignedShort()); this.addRouterLink(ospfLsaLink); } } catch (Exception e) { log.debug("Error::RouterLsa:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } RouterLsa();  RouterLsa(LsaHeader lsaHeader); }
RouterLsa extends LsaHeader { public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { int veb = channelBuffer.readByte(); int unUsed = channelBuffer.readByte(); String strVeb = Integer.toBinaryString(veb); if (strVeb.length() == 3) { this.setVirtualEndPoint((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(2))) == 1) ? true : false); } else if (strVeb.length() == 2) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); } else if (strVeb.length() == 1) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter(false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); } this.setNoLink(channelBuffer.readUnsignedShort()); while (channelBuffer.readableBytes() >= OspfUtil.TWELVE_BYTES) { OspfLsaLink ospfLsaLink = new OspfLsaLink(); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkData(InetAddress.getByAddress(tempByteArray).getHostName()); ospfLsaLink.setLinkType(channelBuffer.readByte()); ospfLsaLink.setTos(channelBuffer.readByte()); ospfLsaLink.setMetric(channelBuffer.readUnsignedShort()); this.addRouterLink(ospfLsaLink); } } catch (Exception e) { log.debug("Error::RouterLsa:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } RouterLsa();  RouterLsa(LsaHeader lsaHeader); void setVirtualEndPoint(boolean isVirtualEndPoint); void setAsBoundaryRouter(boolean isAsBoundaryRouter); void setAreaBorderRouter(boolean isAreaBorderRouter); int noLink(); void setNoLink(int noLink); void addRouterLink(OspfLsaLink lsaLink); List<OspfLsaLink> routerLink(); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLsaBodyAsByteArray(); void incrementLinkNo(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
RouterLsa extends LsaHeader { public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { try { int veb = channelBuffer.readByte(); int unUsed = channelBuffer.readByte(); String strVeb = Integer.toBinaryString(veb); if (strVeb.length() == 3) { this.setVirtualEndPoint((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(2))) == 1) ? true : false); } else if (strVeb.length() == 2) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false); } else if (strVeb.length() == 1) { this.setVirtualEndPoint(false); this.setAsBoundaryRouter(false); this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false); } this.setNoLink(channelBuffer.readUnsignedShort()); while (channelBuffer.readableBytes() >= OspfUtil.TWELVE_BYTES) { OspfLsaLink ospfLsaLink = new OspfLsaLink(); byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); ospfLsaLink.setLinkData(InetAddress.getByAddress(tempByteArray).getHostName()); ospfLsaLink.setLinkType(channelBuffer.readByte()); ospfLsaLink.setTos(channelBuffer.readByte()); ospfLsaLink.setMetric(channelBuffer.readUnsignedShort()); this.addRouterLink(ospfLsaLink); } } catch (Exception e) { log.debug("Error::RouterLsa:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } RouterLsa();  RouterLsa(LsaHeader lsaHeader); void setVirtualEndPoint(boolean isVirtualEndPoint); void setAsBoundaryRouter(boolean isAsBoundaryRouter); void setAreaBorderRouter(boolean isAreaBorderRouter); int noLink(); void setNoLink(int noLink); void addRouterLink(OspfLsaLink lsaLink); List<OspfLsaLink> routerLink(); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLsaBodyAsByteArray(); void incrementLinkNo(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }