@Test public void testGetDdBodyAsByteArray() throws Exception { lsaHeader = createLsaHeader(); ddPacket.addLsaHeader(lsaHeader); result2 = ddPacket.getDdBodyAsByteArray(); assertThat(result2, is(notNullValue())); }
public byte[] getDdBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.imtu()))); bodyLst.add((byte) this.options()); StringBuilder sb = new StringBuilder(); sb.append(this.isInitialize()); sb.append(this.isMore()); sb.append(this.isMaster()); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.sequenceNo()))); for (LsaHeader lsaHeader : lsaHeaderList) { if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) { OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader; bodyLst.addAll(Bytes.asList(header.getOpaqueLsaHeaderAsByteArray())); } else { bodyLst.addAll(Bytes.asList(lsaHeader.getLsaHeaderAsByteArray())); } } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); }
DdPacket extends OspfPacketHeader { public byte[] getDdBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.imtu()))); bodyLst.add((byte) this.options()); StringBuilder sb = new StringBuilder(); sb.append(this.isInitialize()); sb.append(this.isMore()); sb.append(this.isMaster()); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.sequenceNo()))); for (LsaHeader lsaHeader : lsaHeaderList) { if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) { OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader; bodyLst.addAll(Bytes.asList(header.getOpaqueLsaHeaderAsByteArray())); } else { bodyLst.addAll(Bytes.asList(lsaHeader.getLsaHeaderAsByteArray())); } } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } }
DdPacket extends OspfPacketHeader { public byte[] getDdBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.imtu()))); bodyLst.add((byte) this.options()); StringBuilder sb = new StringBuilder(); sb.append(this.isInitialize()); sb.append(this.isMore()); sb.append(this.isMaster()); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.sequenceNo()))); for (LsaHeader lsaHeader : lsaHeaderList) { if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) { OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader; bodyLst.addAll(Bytes.asList(header.getOpaqueLsaHeaderAsByteArray())); } else { bodyLst.addAll(Bytes.asList(lsaHeader.getLsaHeaderAsByteArray())); } } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } DdPacket();  DdPacket(OspfPacketHeader ospfHeader); }
DdPacket extends OspfPacketHeader { public byte[] getDdBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.imtu()))); bodyLst.add((byte) this.options()); StringBuilder sb = new StringBuilder(); sb.append(this.isInitialize()); sb.append(this.isMore()); sb.append(this.isMaster()); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.sequenceNo()))); for (LsaHeader lsaHeader : lsaHeaderList) { if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) { OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader; bodyLst.addAll(Bytes.asList(header.getOpaqueLsaHeaderAsByteArray())); } else { bodyLst.addAll(Bytes.asList(lsaHeader.getLsaHeaderAsByteArray())); } } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } DdPacket();  DdPacket(OspfPacketHeader ospfHeader); boolean isOpaqueCapable(); void setIsOpaqueCapable(boolean isOpaqueCapable); int ims(); void setIms(int ims); int isMaster(); void setIsMaster(int isMaster); int isInitialize(); void setIsInitialize(int isInitialize); int isMore(); void setIsMore(int isMore); int imtu(); void setImtu(int imtu); int options(); void setOptions(int options); long sequenceNo(); void setSequenceNo(long sequenceNo); List<LsaHeader> getLsaHeaderList(); void addLsaHeader(LsaHeader lsaHeader); @Override OspfPacketType ospfMessageType(); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); byte[] getDdHeaderAsByteArray(); byte[] getDdBodyAsByteArray(); @Override String toString(); }
DdPacket extends OspfPacketHeader { public byte[] getDdBodyAsByteArray() { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.imtu()))); bodyLst.add((byte) this.options()); StringBuilder sb = new StringBuilder(); sb.append(this.isInitialize()); sb.append(this.isMore()); sb.append(this.isMaster()); bodyLst.add((byte) Integer.parseInt(sb.toString(), 2)); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.sequenceNo()))); for (LsaHeader lsaHeader : lsaHeaderList) { if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) { OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader; bodyLst.addAll(Bytes.asList(header.getOpaqueLsaHeaderAsByteArray())); } else { bodyLst.addAll(Bytes.asList(lsaHeader.getLsaHeaderAsByteArray())); } } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } DdPacket();  DdPacket(OspfPacketHeader ospfHeader); boolean isOpaqueCapable(); void setIsOpaqueCapable(boolean isOpaqueCapable); int ims(); void setIms(int ims); int isMaster(); void setIsMaster(int isMaster); int isInitialize(); void setIsInitialize(int isInitialize); int isMore(); void setIsMore(int isMore); int imtu(); void setImtu(int imtu); int options(); void setOptions(int options); long sequenceNo(); void setSequenceNo(long sequenceNo); List<LsaHeader> getLsaHeaderList(); void addLsaHeader(LsaHeader lsaHeader); @Override OspfPacketType ospfMessageType(); @Override void readFrom(ChannelBuffer channelBuffer); @Override byte[] asBytes(); byte[] getDdHeaderAsByteArray(); byte[] getDdBodyAsByteArray(); @Override String toString();  }