本文整理汇总了Java中org.onosproject.ospf.protocol.lsa.LsaHeader.lsType方法的典型用法代码示例。如果您正苦于以下问题:Java LsaHeader.lsType方法的具体用法?Java LsaHeader.lsType怎么用?Java LsaHeader.lsType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.ospf.protocol.lsa.LsaHeader
的用法示例。
在下文中一共展示了LsaHeader.lsType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLsAckBodyAsByteArray
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Gets LsAck body as byte array.
*
* @return byte array
*/
public byte[] getLsAckBodyAsByteArray() {
List<Byte> bodyLst = new ArrayList<>();
try {
for (LsaHeader lsaHeader : linkStateHeaders) {
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::getLsAckBodyAsByteArray {}", e.getMessage());
return Bytes.toArray(bodyLst);
}
return Bytes.toArray(bodyLst);
}
示例2: getLsaKey
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Gets the LSDB LSA key from Lsa Header.
*
* @param lsaHeader LSA header instance
* @return key
*/
public String getLsaKey(LsaHeader lsaHeader) {
String lsaKey = "";
switch (lsaHeader.lsType()) {
case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
case OspfParameters.AS_OPAQUE_LSA:
OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader;
lsaKey = lsaHeader.lsType() + "-" + header.opaqueType() + header.opaqueId() + "-" +
lsaHeader.advertisingRouter();
break;
case OspfParameters.ROUTER:
case OspfParameters.NETWORK:
case OspfParameters.ASBR_SUMMARY:
case OspfParameters.SUMMARY:
case OspfParameters.EXTERNAL_LSA:
lsaKey = lsaHeader.lsType() + "-" + lsaHeader.linkStateId() + "-" +
lsaHeader.advertisingRouter();
break;
default:
log.debug("Unknown LSA type..!!!");
break;
}
return lsaKey;
}
示例3: getDdBodyAsByteArray
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Gets DD body as byte array.
*
* @return DD body
*/
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()))); // passing long value
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);
}
示例4: processRefreshLsa
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Process refresh LSA.
*
* @param wrapper LSA wrapper instance
*/
private void processRefreshLsa(LsaWrapper wrapper) throws Exception {
if (wrapper.isSelfOriginated()) { //self originated
//set the destination
OspfInterface ospfInterface = wrapper.ospfInterface();
if (ospfInterface != null) {
LsaHeader header = ((LsaWrapperImpl) wrapper).lsaHeader();
header.setAge(wrapper.currentAge());
if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR) {
if (header.lsType() == OspfLsaType.ROUTER.value()) {
RouterLsa routerLsa = ((OspfAreaImpl) ospfArea).buildRouterLsa(ospfInterface);
((OspfAreaImpl) ospfArea).addLsa(routerLsa, true, ospfInterface);
((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(routerLsa);
} else if (header.lsType() == OspfLsaType.NETWORK.value()) {
if (ospfInterface.listOfNeighbors().size() > 0) {
NetworkLsa networkLsa = ((OspfAreaImpl) ospfArea).buildNetworkLsa(
ospfInterface.ipAddress(), ospfInterface.ipNetworkMask());
ospfArea.addLsa(networkLsa, true, ospfInterface);
((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(networkLsa);
}
}
}
if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR ||
((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT ||
((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
ospfArea.refreshArea(ospfInterface);
}
log.debug("LSAQueueConsumer: processRefreshLsa - Flooded SelfOriginated LSA {}",
((LsaWrapperImpl) wrapper).lsaHeader());
}
}
}
示例5: deleteLsa
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Deletes the given LSA.
*
* @param lsaHeader LSA header instance
*/
public void deleteLsa(LsaHeader lsaHeader) {
String lsaKey = getLsaKey(lsaHeader);
switch (lsaHeader.lsType()) {
case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
opaque9Lsas.remove(lsaKey);
break;
case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
opaque10Lsas.remove(lsaKey);
break;
case OspfParameters.AS_OPAQUE_LSA:
opaque11Lsas.remove(lsaKey);
break;
case OspfParameters.ROUTER:
routerLsas.remove(lsaKey);
break;
case OspfParameters.NETWORK:
networkLsas.remove(lsaKey);
break;
case OspfParameters.ASBR_SUMMARY:
asbrSummaryLSAs.remove(lsaKey);
break;
case OspfParameters.SUMMARY:
summaryLsas.remove(lsaKey);
break;
case OspfParameters.EXTERNAL_LSA:
externalLsas.remove(lsaKey);
break;
default:
log.debug("Unknown LSA type to delete..!!!");
break;
}
}
示例6: addLsaHeaderForDelayAck
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Adds LSAHeader to map.
*
* @param lsaHeader LSA header instance
*/
public void addLsaHeaderForDelayAck(LsaHeader lsaHeader) {
String key = lsaHeader.lsType() + "-" + lsaHeader.linkStateId() + "-" +
lsaHeader.advertisingRouter();
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;
key = lsaHeader.lsType() + "-" + header.opaqueType() + header.opaqueId()
+ "-" + lsaHeader.advertisingRouter();
}
log.debug("Adding LSA key {} for delayed Ack", key);
listOfNeighborMap.put(key, lsaHeader);
}
示例7: processRefreshLsa
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Process refresh LSA.
*
* @param wrapper LSA wrapper instance
*/
private void processRefreshLsa(LsaWrapper wrapper) throws OspfParseException {
if (wrapper.isSelfOriginated()) { //self originated
//set the destination
OspfInterface ospfInterface = wrapper.ospfInterface();
if (ospfInterface != null) {
LsaHeader header = ((LsaWrapperImpl) wrapper).lsaHeader();
header.setAge(wrapper.currentAge());
if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR) {
if (header.lsType() == OspfLsaType.ROUTER.value()) {
RouterLsa routerLsa = ((OspfAreaImpl) ospfArea).buildRouterLsa(ospfInterface);
((OspfAreaImpl) ospfArea).addLsa(routerLsa, true, ospfInterface);
((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(routerLsa);
} else if (header.lsType() == OspfLsaType.NETWORK.value()) {
if (ospfInterface.listOfNeighbors().size() > 0) {
NetworkLsa networkLsa = ((OspfAreaImpl) ospfArea).buildNetworkLsa(
ospfInterface.ipAddress(), ospfInterface.ipNetworkMask());
ospfArea.addLsa(networkLsa, true, ospfInterface);
((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(networkLsa);
}
}
}
if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR ||
((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT ||
((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
ospfArea.refreshArea(ospfInterface);
}
log.debug("LSAQueueConsumer: processRefreshLsa - Flooded SelfOriginated LSA {}",
((LsaWrapperImpl) wrapper).lsaHeader());
}
}
}
示例8: addLsaHeaderForDelayAck
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Adds LSA header to map.
*
* @param lsaHeader LSA header instance
*/
public void addLsaHeaderForDelayAck(LsaHeader lsaHeader) {
String key = lsaHeader.lsType() + "-" + lsaHeader.linkStateId() + "-" +
lsaHeader.advertisingRouter();
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;
key = lsaHeader.lsType() + "-" + header.opaqueType() + header.opaqueId()
+ "-" + lsaHeader.advertisingRouter();
}
log.debug("Adding LSA key {} for delayed Ack", key);
listOfNeighborMap.put(key, lsaHeader);
}
示例9: readFrom
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
@Override
public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
try {
//From header 4 bytes is number of lsa's
this.setNumberOfLsa(channelBuffer.readInt());
//get the remaining bytes represents Number of LSA's present. Add all the LSA's
while (channelBuffer.readableBytes() > OspfUtil.LSA_HEADER_LENGTH) {
LsaHeader header = OspfUtil.readLsaHeader(channelBuffer.readBytes(OspfUtil.LSA_HEADER_LENGTH));
int lsaLength = header.lsPacketLen();
int lsType = header.lsType();
switch (lsType) {
case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
OpaqueLsa9 opaqueLsa9 = new OpaqueLsa9((OpaqueLsaHeader) header);
opaqueLsa9.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
addLsa(opaqueLsa9);
break;
case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
OpaqueLsa10 opaqueLsa10 = new OpaqueLsa10((OpaqueLsaHeader) header);
opaqueLsa10.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
addLsa(opaqueLsa10);
break;
case OspfParameters.AS_OPAQUE_LSA:
OpaqueLsa11 opaqueLsa11 = new OpaqueLsa11((OpaqueLsaHeader) header);
opaqueLsa11.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
addLsa(opaqueLsa11);
break;
case OspfParameters.ROUTER:
RouterLsa routerLsa = new RouterLsa(header);
routerLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
addLsa(routerLsa);
break;
case OspfParameters.NETWORK:
NetworkLsa networkLsa = new NetworkLsa(header);
networkLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
addLsa(networkLsa);
break;
case OspfParameters.ASBR_SUMMARY:
AsbrSummaryLsa asbrSummaryLsa = new AsbrSummaryLsa(header);
asbrSummaryLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
addLsa(asbrSummaryLsa);
break;
case OspfParameters.SUMMARY:
SummaryLsa summaryLsa = new SummaryLsa(header);
summaryLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
addLsa(summaryLsa);
break;
case OspfParameters.EXTERNAL_LSA:
ExternalLsa externalLsa = new ExternalLsa(header);
externalLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
addLsa(externalLsa);
break;
default:
log.debug("LSUpdate::readLsUpdateBody::UnKnown LS Type: {}", lsType);
break;
}
}
} catch (Exception e) {
log.debug("Error::LsUpdate:: {}", e.getMessage());
throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH);
}
}
示例10: addToOtherNeighborLsaTxList
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Adds the received LSA in other neighbors tx list.
*
* @param recLsa LSA Header instance
*/
public void addToOtherNeighborLsaTxList(LsaHeader recLsa) {
//Add the received LSA in other neighbors retransmission list.
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList");
List<OspfInterface> ospfInterfaces = ospfInterfaceList();
for (OspfInterface ospfInterfaceFromArea : ospfInterfaces) {
Map neighbors = ospfInterfaceFromArea.listOfNeighbors();
for (Object neighborIP : neighbors.keySet()) {
OspfNbrImpl nbr = (OspfNbrImpl) neighbors.get(neighborIP);
if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) {
continue;
}
String key = database.getLsaKey(recLsa);
if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING) {
if (nbr.getLsReqList().containsKey(key)) {
LsaWrapper lsWrapper = lsaLookup(recLsa);
if (lsWrapper != null) {
LsaHeader ownLsa = (LsaHeader) lsWrapper.ospfLsa();
String status = isNewerOrSameLsa(recLsa, ownLsa);
if (status.equals("old")) {
continue;
} else if (status.equals("same")) {
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: " +
"Removing lsa from reTxtList {}", key);
nbr.getLsReqList().remove(key);
continue;
} else {
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: " +
"Removing lsa from reTxtList {}", key);
nbr.getLsReqList().remove(key);
}
}
}
}
if (recLsa.advertisingRouter().equals((String) neighborIP)) {
continue;
}
if ((recLsa.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA ||
recLsa.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA)) {
if (nbr.isOpaqueCapable()) {
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: Adding lsa to reTxtList {}",
recLsa);
nbr.getReTxList().put(key, recLsa);
}
} else {
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: Adding lsa to reTxtList {}",
recLsa);
nbr.getReTxList().put(key, recLsa);
}
}
}
}
示例11: populateLsaLists
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Populates the LSA lists based on the input.
*
* @param header LSA header instance
* @param area OSPF area instance
*/
private void populateLsaLists(LsaHeader header, OspfArea area) {
String seqNo = Long.toHexString(header.lsSequenceNo());
String checkSum = Long.toHexString(header.lsCheckSum());
if (seqNo.length() == 16) {
seqNo = seqNo.substring(8, seqNo.length());
}
if (checkSum.length() == 16) {
checkSum = checkSum.substring(8, checkSum.length());
}
StringBuffer strBuf = getBuffList(area.areaId().toString(), area.routerId().toString(),
header.linkStateId(),
header.advertisingRouter().toString(),
header.age(), seqNo, checkSum);
if (header.lsType() == OspfLsaType.ROUTER.value()) {
strBuf.append(",");
strBuf.append(((RouterLsa) header).noLink());
routerLsa.add(strBuf.toString());
} else if (header.lsType() == OspfLsaType.NETWORK.value()) {
strBuf.append(",");
strBuf.append("0");
networkLsa.add(strBuf.toString());
} else if (header.lsType() == OspfLsaType.SUMMARY.value()) {
strBuf.append(",");
strBuf.append("0");
summaryLsa.add(strBuf.toString());
} else if (header.lsType() == OspfLsaType.EXTERNAL_LSA.value()) {
strBuf.append(",");
strBuf.append("0");
externalLsa.add(strBuf.toString());
} else if (header.lsType() == OspfLsaType.ASBR_SUMMARY.value()) {
strBuf.append(",");
strBuf.append("0");
asbrSumm.add(strBuf.toString());
} else if (header.lsType() == OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value()) {
strBuf.append(",");
strBuf.append("0");
areaLocalOpaqLsa.add(strBuf.toString());
} else if (header.lsType() == OspfLsaType.LINK_LOCAL_OPAQUE_LSA.value()) {
strBuf.append(",");
strBuf.append("0");
linkLocalOpqLsa.add(strBuf.toString());
} else if (header.lsType() == OspfLsaType.AS_OPAQUE_LSA.value()) {
strBuf.append(",");
strBuf.append("0");
asOpqLsa.add(strBuf.toString());
} else {
strBuf.append(",");
strBuf.append("0");
undefinedLsa.add(strBuf.toString());
}
}
示例12: addToOtherNeighborLsaTxList
import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入方法依赖的package包/类
/**
* Adds the received LSA in other neighbors tx list.
*
* @param recLsa LSA Header instance
*/
public void addToOtherNeighborLsaTxList(LsaHeader recLsa) {
//Add the received LSA in other neighbors retransmission list.
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList");
List<OspfInterface> ospfInterfaces = ospfInterfaceList();
for (OspfInterface ospfInterfaceFromArea : ospfInterfaces) {
Map neighbors = ospfInterfaceFromArea.listOfNeighbors();
for (Object neighborIP : neighbors.keySet()) {
OspfNbrImpl nbr = (OspfNbrImpl) neighbors.get(neighborIP);
if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) {
continue;
}
String key = database.getLsaKey(recLsa);
if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING) {
if (nbr.getLsReqList().containsKey(key)) {
LsaWrapper lsWrapper = lsaLookup(recLsa);
if (lsWrapper != null) {
LsaHeader ownLsa = (LsaHeader) lsWrapper.ospfLsa();
String status = isNewerOrSameLsa(recLsa, ownLsa);
if (status.equals("old")) {
continue;
} else if (status.equals("same")) {
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: " +
"Removing lsa from reTxtList {}", key);
nbr.getLsReqList().remove(key);
continue;
} else {
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: " +
"Removing lsa from reTxtList {}", key);
nbr.getLsReqList().remove(key);
}
}
}
}
if (recLsa.advertisingRouter().toString().equals((String) neighborIP)) {
continue;
}
if ((recLsa.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA ||
recLsa.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA)) {
if (nbr.isOpaqueCapable()) {
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: Adding lsa to reTxtList {}",
recLsa);
nbr.getReTxList().put(key, recLsa);
}
} else {
log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: Adding lsa to reTxtList {}",
recLsa);
nbr.getReTxList().put(key, recLsa);
}
}
}
}