@Test public void testGetLsaBodyAsByteArray() throws Exception { routerLsa.setAreaBorderRouter(true); routerLsa.setVirtualEndPoint(true); routerLsa.setAreaBorderRouter(true); ospflsaLink = createOspfLsaLink(); routerLsa.addRouterLink(ospflsaLink); result2 = routerLsa.getLsaBodyAsByteArray(); assertThat(result2, is(notNullValue())); }
public byte[] getLsaBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { int isVirtualEndPointVal = this.isVirtualEndPoint ? 1 : 0; int isASBoundaryRouterVal = this.isAsBoundaryRouter ? 1 : 0; int isAreaBorderRouterVal = this.isAreaBorderRouter ? 1 : 0; StringBuilder sb = new StringBuilder(); sb.append(Integer.toBinaryString(isVirtualEndPointVal)); sb.append(Integer.toBinaryString(isASBoundaryRouterVal)); sb.append(Integer.toBinaryString(isAreaBorderRouterVal)); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.add((byte) 0); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.noLink()))); for (OspfLsaLink lsaLink : routerLinks) { bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkId()).getAddress())); bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkData()).getAddress())); bodyLst.add((byte) lsaLink.linkType()); bodyLst.add((byte) lsaLink.tos()); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(lsaLink.metric()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); }
RouterLsa extends LsaHeader { public byte[] getLsaBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { int isVirtualEndPointVal = this.isVirtualEndPoint ? 1 : 0; int isASBoundaryRouterVal = this.isAsBoundaryRouter ? 1 : 0; int isAreaBorderRouterVal = this.isAreaBorderRouter ? 1 : 0; StringBuilder sb = new StringBuilder(); sb.append(Integer.toBinaryString(isVirtualEndPointVal)); sb.append(Integer.toBinaryString(isASBoundaryRouterVal)); sb.append(Integer.toBinaryString(isAreaBorderRouterVal)); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.add((byte) 0); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.noLink()))); for (OspfLsaLink lsaLink : routerLinks) { bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkId()).getAddress())); bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkData()).getAddress())); bodyLst.add((byte) lsaLink.linkType()); bodyLst.add((byte) lsaLink.tos()); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(lsaLink.metric()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } }
RouterLsa extends LsaHeader { public byte[] getLsaBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { int isVirtualEndPointVal = this.isVirtualEndPoint ? 1 : 0; int isASBoundaryRouterVal = this.isAsBoundaryRouter ? 1 : 0; int isAreaBorderRouterVal = this.isAreaBorderRouter ? 1 : 0; StringBuilder sb = new StringBuilder(); sb.append(Integer.toBinaryString(isVirtualEndPointVal)); sb.append(Integer.toBinaryString(isASBoundaryRouterVal)); sb.append(Integer.toBinaryString(isAreaBorderRouterVal)); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.add((byte) 0); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.noLink()))); for (OspfLsaLink lsaLink : routerLinks) { bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkId()).getAddress())); bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkData()).getAddress())); bodyLst.add((byte) lsaLink.linkType()); bodyLst.add((byte) lsaLink.tos()); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(lsaLink.metric()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } RouterLsa();  RouterLsa(LsaHeader lsaHeader); }
RouterLsa extends LsaHeader { public byte[] getLsaBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { int isVirtualEndPointVal = this.isVirtualEndPoint ? 1 : 0; int isASBoundaryRouterVal = this.isAsBoundaryRouter ? 1 : 0; int isAreaBorderRouterVal = this.isAreaBorderRouter ? 1 : 0; StringBuilder sb = new StringBuilder(); sb.append(Integer.toBinaryString(isVirtualEndPointVal)); sb.append(Integer.toBinaryString(isASBoundaryRouterVal)); sb.append(Integer.toBinaryString(isAreaBorderRouterVal)); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.add((byte) 0); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.noLink()))); for (OspfLsaLink lsaLink : routerLinks) { bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkId()).getAddress())); bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkData()).getAddress())); bodyLst.add((byte) lsaLink.linkType()); bodyLst.add((byte) lsaLink.tos()); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(lsaLink.metric()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } 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 byte[] getLsaBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { int isVirtualEndPointVal = this.isVirtualEndPoint ? 1 : 0; int isASBoundaryRouterVal = this.isAsBoundaryRouter ? 1 : 0; int isAreaBorderRouterVal = this.isAreaBorderRouter ? 1 : 0; StringBuilder sb = new StringBuilder(); sb.append(Integer.toBinaryString(isVirtualEndPointVal)); sb.append(Integer.toBinaryString(isASBoundaryRouterVal)); sb.append(Integer.toBinaryString(isAreaBorderRouterVal)); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.add((byte) 0); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.noLink()))); for (OspfLsaLink lsaLink : routerLinks) { bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkId()).getAddress())); bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkData()).getAddress())); bodyLst.add((byte) lsaLink.linkType()); bodyLst.add((byte) lsaLink.tos()); bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(lsaLink.metric()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } 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();  }