@Test public void testGetLsa() throws Exception { assertThat(ospfArea.getLsa(1, "1.1.1.1", "1.1.1.1"), is(nullValue())); assertThat(ospfArea.getLsa(10, "1.1.1.1", "1.1.1.1"), is(nullValue())); }
public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception { String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter; if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AS_OPAQUE_LSA) { byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress(); int opaqueType = linkStateAsBytes[0]; int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1, linkStateAsBytes.length)); lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter; } return database.findLsa(lsType, lsaKey); }
OspfAreaImpl implements OspfArea { public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception { String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter; if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AS_OPAQUE_LSA) { byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress(); int opaqueType = linkStateAsBytes[0]; int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1, linkStateAsBytes.length)); lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter; } return database.findLsa(lsType, lsaKey); } }
OspfAreaImpl implements OspfArea { public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception { String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter; if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AS_OPAQUE_LSA) { byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress(); int opaqueType = linkStateAsBytes[0]; int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1, linkStateAsBytes.length)); lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter; } return database.findLsa(lsType, lsaKey); } OspfAreaImpl(); }
OspfAreaImpl implements OspfArea { public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception { String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter; if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AS_OPAQUE_LSA) { byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress(); int opaqueType = linkStateAsBytes[0]; int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1, linkStateAsBytes.length)); lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter; } return database.findLsa(lsType, lsaKey); } OspfAreaImpl(); @Override boolean equals(Object o); @Override int hashCode(); Ip4Address routerId(); @JsonProperty("routerId") void setRouterId(Ip4Address routerId); @JsonProperty("isOpaqueEnable") void setIsOpaqueEnabled(boolean isOpaqueEnable); boolean isOpaqueEnabled(); void initializeDb(); @Override void refreshArea(OspfInterface ospfInterface); NetworkLsa buildNetworkLsa(Ip4Address interfaceIp, Ip4Address mask); RouterLsa buildRouterLsa(OspfInterface ospfInterface); Ip4Address areaId(); @JsonProperty("areaId") void setAreaId(Ip4Address areaId); boolean isExternalRoutingCapability(); @JsonProperty("externalRoutingCapability") void setExternalRoutingCapability(boolean externalRoutingCapability); List<OspfInterface> ospfInterfaceList(); @JsonProperty("interface") void setOspfInterfaceList(List<OspfInterface> ospfInterfaceList); boolean noNeighborInLsaExchangeProcess(); List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaquecapable); LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter); LsaWrapper lsaLookup(OspfLsa lookupLsa); String isNewerOrSameLsa(OspfLsa lsa1, OspfLsa lsa2); void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface); void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface); void addLsaToMaxAgeBin(String key, LsaWrapper wrapper); void setDbRouterSequenceNumber(long newSequenceNumber); void deleteLsa(LsaHeader ospfLsa); void removeLsaFromBin(LsaWrapper lsaWrapper); @Override String toString(); List<OspfNbr> getNeighborsInFullState(OspfInterface ospfInterface); String getLsaKey(LsaHeader lsaHeader); void addToOtherNeighborLsaTxList(LsaHeader recLsa); int options(); void setOptions(int options); int opaqueEnabledOptions(); OspfLsdb database(); }
OspfAreaImpl implements OspfArea { public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception { String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter; if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AS_OPAQUE_LSA) { byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress(); int opaqueType = linkStateAsBytes[0]; int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1, linkStateAsBytes.length)); lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter; } return database.findLsa(lsType, lsaKey); } OspfAreaImpl(); @Override boolean equals(Object o); @Override int hashCode(); Ip4Address routerId(); @JsonProperty("routerId") void setRouterId(Ip4Address routerId); @JsonProperty("isOpaqueEnable") void setIsOpaqueEnabled(boolean isOpaqueEnable); boolean isOpaqueEnabled(); void initializeDb(); @Override void refreshArea(OspfInterface ospfInterface); NetworkLsa buildNetworkLsa(Ip4Address interfaceIp, Ip4Address mask); RouterLsa buildRouterLsa(OspfInterface ospfInterface); Ip4Address areaId(); @JsonProperty("areaId") void setAreaId(Ip4Address areaId); boolean isExternalRoutingCapability(); @JsonProperty("externalRoutingCapability") void setExternalRoutingCapability(boolean externalRoutingCapability); List<OspfInterface> ospfInterfaceList(); @JsonProperty("interface") void setOspfInterfaceList(List<OspfInterface> ospfInterfaceList); boolean noNeighborInLsaExchangeProcess(); List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaquecapable); LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter); LsaWrapper lsaLookup(OspfLsa lookupLsa); String isNewerOrSameLsa(OspfLsa lsa1, OspfLsa lsa2); void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface); void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface); void addLsaToMaxAgeBin(String key, LsaWrapper wrapper); void setDbRouterSequenceNumber(long newSequenceNumber); void deleteLsa(LsaHeader ospfLsa); void removeLsaFromBin(LsaWrapper lsaWrapper); @Override String toString(); List<OspfNbr> getNeighborsInFullState(OspfInterface ospfInterface); String getLsaKey(LsaHeader lsaHeader); void addToOtherNeighborLsaTxList(LsaHeader recLsa); int options(); void setOptions(int options); int opaqueEnabledOptions(); OspfLsdb database();  }