@Test public void testGetLsuBodyAsByteArray() throws Exception { lsUpdate.setNumberOfLsa(8); lsUpdate.addLsa(ospflsa3); opaqueLsa9 = new OpaqueLsa9(new OpaqueLsaHeader()); opaqueLsa9.setLsType(9); lsUpdate.addLsa(opaqueLsa9); opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader()); opaqueLsa10.setLsType(10); lsUpdate.addLsa(opaqueLsa10); opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader()); opaqueLsa10.setLsType(11); lsUpdate.addLsa(opaqueLsa11); result1 = lsUpdate.getLsuBodyAsByteArray(); assertThat(result1, is(notNullValue())); }
public byte[] getLsuBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.noLsa()))); for (OspfLsa ospfLsa : lsaList) { switch (ospfLsa.getOspfLsaType().value()) { case OspfParameters.LINK_LOCAL_OPAQUE_LSA: OpaqueLsa9 opaqueLsa9 = (OpaqueLsa9) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa9.asBytes())); break; case OspfParameters.AREA_LOCAL_OPAQUE_LSA: OpaqueLsa10 opaqueLsa10 = (OpaqueLsa10) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa10.asBytes())); break; case OspfParameters.AS_OPAQUE_LSA: OpaqueLsa11 opaqueLsa11 = (OpaqueLsa11) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa11.asBytes())); break; case OspfParameters.ROUTER: RouterLsa routerLsa = (RouterLsa) ospfLsa; bodyLst.addAll(Bytes.asList(routerLsa.asBytes())); break; case OspfParameters.NETWORK: NetworkLsa networkLsa = (NetworkLsa) ospfLsa; bodyLst.addAll(Bytes.asList(networkLsa.asBytes())); break; case OspfParameters.ASBR_SUMMARY: AsbrSummaryLsa asbrSummaryLsa = (AsbrSummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(asbrSummaryLsa.asBytes())); break; case OspfParameters.SUMMARY: SummaryLsa summaryLsa = (SummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(summaryLsa.asBytes())); break; case OspfParameters.EXTERNAL_LSA: ExternalLsa externalLsa = (ExternalLsa) ospfLsa; bodyLst.addAll(Bytes.asList(externalLsa.asBytes())); break; default: log.debug("LSUpdate::getLsuBodyAsByteArray::UnKnown ospfLsa: {}", ospfLsa); break; } } } catch (Exception e) { log.debug("Error::getLsuBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); }
LsUpdate extends OspfPacketHeader { public byte[] getLsuBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.noLsa()))); for (OspfLsa ospfLsa : lsaList) { switch (ospfLsa.getOspfLsaType().value()) { case OspfParameters.LINK_LOCAL_OPAQUE_LSA: OpaqueLsa9 opaqueLsa9 = (OpaqueLsa9) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa9.asBytes())); break; case OspfParameters.AREA_LOCAL_OPAQUE_LSA: OpaqueLsa10 opaqueLsa10 = (OpaqueLsa10) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa10.asBytes())); break; case OspfParameters.AS_OPAQUE_LSA: OpaqueLsa11 opaqueLsa11 = (OpaqueLsa11) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa11.asBytes())); break; case OspfParameters.ROUTER: RouterLsa routerLsa = (RouterLsa) ospfLsa; bodyLst.addAll(Bytes.asList(routerLsa.asBytes())); break; case OspfParameters.NETWORK: NetworkLsa networkLsa = (NetworkLsa) ospfLsa; bodyLst.addAll(Bytes.asList(networkLsa.asBytes())); break; case OspfParameters.ASBR_SUMMARY: AsbrSummaryLsa asbrSummaryLsa = (AsbrSummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(asbrSummaryLsa.asBytes())); break; case OspfParameters.SUMMARY: SummaryLsa summaryLsa = (SummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(summaryLsa.asBytes())); break; case OspfParameters.EXTERNAL_LSA: ExternalLsa externalLsa = (ExternalLsa) ospfLsa; bodyLst.addAll(Bytes.asList(externalLsa.asBytes())); break; default: log.debug("LSUpdate::getLsuBodyAsByteArray::UnKnown ospfLsa: {}", ospfLsa); break; } } } catch (Exception e) { log.debug("Error::getLsuBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } }
LsUpdate extends OspfPacketHeader { public byte[] getLsuBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.noLsa()))); for (OspfLsa ospfLsa : lsaList) { switch (ospfLsa.getOspfLsaType().value()) { case OspfParameters.LINK_LOCAL_OPAQUE_LSA: OpaqueLsa9 opaqueLsa9 = (OpaqueLsa9) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa9.asBytes())); break; case OspfParameters.AREA_LOCAL_OPAQUE_LSA: OpaqueLsa10 opaqueLsa10 = (OpaqueLsa10) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa10.asBytes())); break; case OspfParameters.AS_OPAQUE_LSA: OpaqueLsa11 opaqueLsa11 = (OpaqueLsa11) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa11.asBytes())); break; case OspfParameters.ROUTER: RouterLsa routerLsa = (RouterLsa) ospfLsa; bodyLst.addAll(Bytes.asList(routerLsa.asBytes())); break; case OspfParameters.NETWORK: NetworkLsa networkLsa = (NetworkLsa) ospfLsa; bodyLst.addAll(Bytes.asList(networkLsa.asBytes())); break; case OspfParameters.ASBR_SUMMARY: AsbrSummaryLsa asbrSummaryLsa = (AsbrSummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(asbrSummaryLsa.asBytes())); break; case OspfParameters.SUMMARY: SummaryLsa summaryLsa = (SummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(summaryLsa.asBytes())); break; case OspfParameters.EXTERNAL_LSA: ExternalLsa externalLsa = (ExternalLsa) ospfLsa; bodyLst.addAll(Bytes.asList(externalLsa.asBytes())); break; default: log.debug("LSUpdate::getLsuBodyAsByteArray::UnKnown ospfLsa: {}", ospfLsa); break; } } } catch (Exception e) { log.debug("Error::getLsuBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } LsUpdate();  LsUpdate(OspfPacketHeader ospfHeader); }
LsUpdate extends OspfPacketHeader { public byte[] getLsuBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.noLsa()))); for (OspfLsa ospfLsa : lsaList) { switch (ospfLsa.getOspfLsaType().value()) { case OspfParameters.LINK_LOCAL_OPAQUE_LSA: OpaqueLsa9 opaqueLsa9 = (OpaqueLsa9) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa9.asBytes())); break; case OspfParameters.AREA_LOCAL_OPAQUE_LSA: OpaqueLsa10 opaqueLsa10 = (OpaqueLsa10) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa10.asBytes())); break; case OspfParameters.AS_OPAQUE_LSA: OpaqueLsa11 opaqueLsa11 = (OpaqueLsa11) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa11.asBytes())); break; case OspfParameters.ROUTER: RouterLsa routerLsa = (RouterLsa) ospfLsa; bodyLst.addAll(Bytes.asList(routerLsa.asBytes())); break; case OspfParameters.NETWORK: NetworkLsa networkLsa = (NetworkLsa) ospfLsa; bodyLst.addAll(Bytes.asList(networkLsa.asBytes())); break; case OspfParameters.ASBR_SUMMARY: AsbrSummaryLsa asbrSummaryLsa = (AsbrSummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(asbrSummaryLsa.asBytes())); break; case OspfParameters.SUMMARY: SummaryLsa summaryLsa = (SummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(summaryLsa.asBytes())); break; case OspfParameters.EXTERNAL_LSA: ExternalLsa externalLsa = (ExternalLsa) ospfLsa; bodyLst.addAll(Bytes.asList(externalLsa.asBytes())); break; default: log.debug("LSUpdate::getLsuBodyAsByteArray::UnKnown ospfLsa: {}", ospfLsa); break; } } } catch (Exception e) { log.debug("Error::getLsuBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } LsUpdate();  LsUpdate(OspfPacketHeader ospfHeader); List getLsaList(); void addLsa(OspfLsa lsa); int noLsa(); void setNumberOfLsa(int numberOfLsa); @Override OspfPacketType ospfMessageType(); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); byte[] getLsuHeaderAsByteArray(); byte[] getLsuBodyAsByteArray(); @Override String toString(); }
LsUpdate extends OspfPacketHeader { public byte[] getLsuBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.noLsa()))); for (OspfLsa ospfLsa : lsaList) { switch (ospfLsa.getOspfLsaType().value()) { case OspfParameters.LINK_LOCAL_OPAQUE_LSA: OpaqueLsa9 opaqueLsa9 = (OpaqueLsa9) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa9.asBytes())); break; case OspfParameters.AREA_LOCAL_OPAQUE_LSA: OpaqueLsa10 opaqueLsa10 = (OpaqueLsa10) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa10.asBytes())); break; case OspfParameters.AS_OPAQUE_LSA: OpaqueLsa11 opaqueLsa11 = (OpaqueLsa11) ospfLsa; bodyLst.addAll(Bytes.asList(opaqueLsa11.asBytes())); break; case OspfParameters.ROUTER: RouterLsa routerLsa = (RouterLsa) ospfLsa; bodyLst.addAll(Bytes.asList(routerLsa.asBytes())); break; case OspfParameters.NETWORK: NetworkLsa networkLsa = (NetworkLsa) ospfLsa; bodyLst.addAll(Bytes.asList(networkLsa.asBytes())); break; case OspfParameters.ASBR_SUMMARY: AsbrSummaryLsa asbrSummaryLsa = (AsbrSummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(asbrSummaryLsa.asBytes())); break; case OspfParameters.SUMMARY: SummaryLsa summaryLsa = (SummaryLsa) ospfLsa; bodyLst.addAll(Bytes.asList(summaryLsa.asBytes())); break; case OspfParameters.EXTERNAL_LSA: ExternalLsa externalLsa = (ExternalLsa) ospfLsa; bodyLst.addAll(Bytes.asList(externalLsa.asBytes())); break; default: log.debug("LSUpdate::getLsuBodyAsByteArray::UnKnown ospfLsa: {}", ospfLsa); break; } } } catch (Exception e) { log.debug("Error::getLsuBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } LsUpdate();  LsUpdate(OspfPacketHeader ospfHeader); List getLsaList(); void addLsa(OspfLsa lsa); int noLsa(); void setNumberOfLsa(int numberOfLsa); @Override OspfPacketType ospfMessageType(); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); byte[] getLsuHeaderAsByteArray(); byte[] getLsuBodyAsByteArray(); @Override String toString();  }