@Test public void testGetLsaBodyAsByteArray() throws Exception { ospfExternalDestination = new OspfExternalDestination(); ospfExternalDestination.setExternalRouterTag(2); ospfExternalDestination.setMetric(100); ospfExternalDestination.setType1orType2Metric(true); externalLsa.addExternalDestination(ospfExternalDestination); ospfExternalDestination1 = new OspfExternalDestination(); ospfExternalDestination.setExternalRouterTag(3); ospfExternalDestination.setMetric(100); ospfExternalDestination.setType1orType2Metric(true); externalLsa.addExternalDestination(ospfExternalDestination1); result1 = externalLsa.getLsaBodyAsByteArray(); assertThat(result1, is(notNullValue())); }
public byte[] getLsaBodyAsByteArray() throws OspfParseException { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(this.networkMask().toOctets())); for (OspfExternalDestination externalDest : externalDestinations) { if (externalDest.isType1orType2Metric()) { bodyLst.add((byte) 128); } else { bodyLst.add((byte) 0); } bodyLst.addAll(Bytes.asList(OspfUtil.convertToThreeBytes(externalDest.metric()))); bodyLst.addAll(Bytes.asList(externalDest.forwardingAddress().toOctets())); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(externalDest.externalRouterTag()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); }
ExternalLsa extends LsaHeader { public byte[] getLsaBodyAsByteArray() throws OspfParseException { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(this.networkMask().toOctets())); for (OspfExternalDestination externalDest : externalDestinations) { if (externalDest.isType1orType2Metric()) { bodyLst.add((byte) 128); } else { bodyLst.add((byte) 0); } bodyLst.addAll(Bytes.asList(OspfUtil.convertToThreeBytes(externalDest.metric()))); bodyLst.addAll(Bytes.asList(externalDest.forwardingAddress().toOctets())); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(externalDest.externalRouterTag()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } }
ExternalLsa extends LsaHeader { public byte[] getLsaBodyAsByteArray() throws OspfParseException { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(this.networkMask().toOctets())); for (OspfExternalDestination externalDest : externalDestinations) { if (externalDest.isType1orType2Metric()) { bodyLst.add((byte) 128); } else { bodyLst.add((byte) 0); } bodyLst.addAll(Bytes.asList(OspfUtil.convertToThreeBytes(externalDest.metric()))); bodyLst.addAll(Bytes.asList(externalDest.forwardingAddress().toOctets())); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(externalDest.externalRouterTag()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } ExternalLsa(LsaHeader lsaHeader); }
ExternalLsa extends LsaHeader { public byte[] getLsaBodyAsByteArray() throws OspfParseException { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(this.networkMask().toOctets())); for (OspfExternalDestination externalDest : externalDestinations) { if (externalDest.isType1orType2Metric()) { bodyLst.add((byte) 128); } else { bodyLst.add((byte) 0); } bodyLst.addAll(Bytes.asList(OspfUtil.convertToThreeBytes(externalDest.metric()))); bodyLst.addAll(Bytes.asList(externalDest.forwardingAddress().toOctets())); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(externalDest.externalRouterTag()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } ExternalLsa(LsaHeader lsaHeader); Ip4Address networkMask(); void setNetworkMask(Ip4Address networkMask); void addExternalDestination(OspfExternalDestination externalDestination); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLsaBodyAsByteArray(); @Override OspfLsaType getOspfLsaType(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); }
ExternalLsa extends LsaHeader { public byte[] getLsaBodyAsByteArray() throws OspfParseException { List<Byte> bodyLst = new ArrayList<>(); try { bodyLst.addAll(Bytes.asList(this.networkMask().toOctets())); for (OspfExternalDestination externalDest : externalDestinations) { if (externalDest.isType1orType2Metric()) { bodyLst.add((byte) 128); } else { bodyLst.add((byte) 0); } bodyLst.addAll(Bytes.asList(OspfUtil.convertToThreeBytes(externalDest.metric()))); bodyLst.addAll(Bytes.asList(externalDest.forwardingAddress().toOctets())); bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(externalDest.externalRouterTag()))); } } catch (Exception e) { log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); return Bytes.toArray(bodyLst); } return Bytes.toArray(bodyLst); } ExternalLsa(LsaHeader lsaHeader); Ip4Address networkMask(); void setNetworkMask(Ip4Address networkMask); void addExternalDestination(OspfExternalDestination externalDestination); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLsaBodyAsByteArray(); @Override OspfLsaType getOspfLsaType(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }