当前位置: 首页>>代码示例>>Java>>正文


Java LsaWrapper.ospfLsa方法代码示例

本文整理汇总了Java中org.onosproject.ospf.controller.LsaWrapper.ospfLsa方法的典型用法代码示例。如果您正苦于以下问题:Java LsaWrapper.ospfLsa方法的具体用法?Java LsaWrapper.ospfLsa怎么用?Java LsaWrapper.ospfLsa使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onosproject.ospf.controller.LsaWrapper的用法示例。


在下文中一共展示了LsaWrapper.ospfLsa方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isNullorLatest

import org.onosproject.ospf.controller.LsaWrapper; //导入方法依赖的package包/类
/**
 * RFC 2328 Section 13 (5).
 *
 * @param lsWrapper ls wrapper instance
 * @param recLsa    received LSA instance
 * @return returns a string status
 */
public String isNullorLatest(LsaWrapper lsWrapper, LsaHeader recLsa) {


    if (lsWrapper != null) {
        LsaHeader ownLsa = (LsaHeader) lsWrapper.ospfLsa();
        String status = ospfArea.isNewerOrSameLsa(recLsa, ownLsa);

        if (status.equals("latest")) {
            return "isNullorLatest";
        } else {
            return status;
        }
    } else {
        return "isNullorLatest";
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:OspfNbrImpl.java

示例2: addToList

import org.onosproject.ospf.controller.LsaWrapper; //导入方法依赖的package包/类
/**
 * Adds the LSWrapper to summary list.
 *
 * @param wrapper  LSA wrapper instance
 * @param summList LSA summary list
 */
private void addToList(LsaWrapper wrapper, List summList) {
    LsaHeader header = (LsaHeader) wrapper.ospfLsa();
    //set the current age
    header.setAge(wrapper.currentAge());
    summList.add(header);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:OspfLsdbImpl.java

示例3: addToOtherNeighborLsaTxList

import org.onosproject.ospf.controller.LsaWrapper; //导入方法依赖的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);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:57,代码来源:OspfAreaImpl.java

示例4: processLsRequestMessage

import org.onosproject.ospf.controller.LsaWrapper; //导入方法依赖的package包/类
/**
 * Process the Ls Request message.
 *
 * @param ospfMessage OSPF message instance.
 * @param ctx         channel handler context instance.
 * @throws Exception might throws exception
 */
void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
    log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
    Channel channel = ctx.getChannel();
    LsRequest lsrPacket = (LsRequest) ospfMessage;
    OspfNbr nbr = neighbouringRouter(lsrPacket.routerId().toString());

    if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
            nbr.getState() == OspfNeighborState.FULL) {

        LsRequest reqMsg = (LsRequest) ospfMessage;
        if (reqMsg.getLinkStateRequests().isEmpty()) {
            log.debug("Received Link State Request Vector is Empty ");
            return;
        } else {
            //Send the LsUpdate back
            ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
            while (listItr.hasNext()) {
                LsUpdate lsupdate = new LsUpdate();
                lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
                lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
                lsupdate.setRouterId(ospfArea.routerId());
                lsupdate.setAreaId(ospfArea.areaId());
                lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
                lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
                lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
                lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);

                //limit to mtu
                int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
                int maxSize = mtu() -
                        OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
                int noLsa = 0;
                while (listItr.hasNext()) {
                    LsRequestPacket lsRequest = (LsRequestPacket) listItr.next();
                    // to verify length of the LSA
                    LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
                                                         lsRequest.ownRouterId());
                    OspfLsa ospflsa = wrapper.ospfLsa();
                    if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
                        listItr.previous();
                        break;
                    }
                    if (ospflsa != null) {
                        lsupdate.addLsa(ospflsa);
                        noLsa++;

                        currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
                    } else {
                        nbr.badLSReq(channel);
                    }
                }
                lsupdate.setNumberOfLsa(noLsa);
                //set the destination
                if (state() == OspfInterfaceState.DR ||
                        state() == OspfInterfaceState.BDR ||
                        state() == OspfInterfaceState.POINT2POINT) {
                    lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
                } else if (state() == OspfInterfaceState.DROTHER) {
                    lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
                }
                byte[] messageToWrite = getMessage(lsupdate);
                ctx.getChannel().write(messageToWrite);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:74,代码来源:OspfInterfaceImpl.java

示例5: addToOtherNeighborLsaTxList

import org.onosproject.ospf.controller.LsaWrapper; //导入方法依赖的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);
            }
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:57,代码来源:OspfAreaImpl.java

示例6: processLsRequestMessage

import org.onosproject.ospf.controller.LsaWrapper; //导入方法依赖的package包/类
/**
 * Process the Ls Request message.
 *
 * @param ospfMessage OSPF message instance.
 * @param ctx         channel handler context instance.
 */
void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
    log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
    Channel channel = ctx.getChannel();
    LsRequest lsrPacket = (LsRequest) ospfMessage;
    OspfNbr nbr = neighbouringRouter(lsrPacket.routerId().toString());

    if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
            nbr.getState() == OspfNeighborState.FULL) {

        LsRequest reqMsg = (LsRequest) ospfMessage;
        if (reqMsg.getLinkStateRequests().isEmpty()) {
            log.debug("Received Link State Request Vector is Empty ");
            return;
        } else {
            //Send the LsUpdate back
            ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
            while (listItr.hasNext()) {
                LsUpdate lsupdate = new LsUpdate();
                lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
                lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
                lsupdate.setRouterId(ospfArea.routerId());
                lsupdate.setAreaId(ospfArea.areaId());
                lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
                lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
                lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
                lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);

                //limit to mtu
                int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
                int maxSize = mtu() -
                        OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
                int noLsa = 0;
                while (listItr.hasNext()) {
                    LsRequestPacket lsRequest = listItr.next();
                    // to verify length of the LSA
                    LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
                                                         lsRequest.ownRouterId());
                    if (wrapper != null) {
                        OspfLsa ospflsa = wrapper.ospfLsa();
                        if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
                            listItr.previous();
                            break;
                        }
                        if (ospflsa != null) {
                            lsupdate.addLsa(ospflsa);
                            noLsa++;

                            currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
                        } else {
                            nbr.badLSReq(channel);
                        }
                    }
                }
                lsupdate.setNumberOfLsa(noLsa);
                //set the destination
                if (state() == OspfInterfaceState.DR ||
                        state() == OspfInterfaceState.BDR ||
                        state() == OspfInterfaceState.POINT2POINT) {
                    lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
                } else if (state() == OspfInterfaceState.DROTHER) {
                    lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
                }
                byte[] messageToWrite = getMessage(lsupdate);
                ctx.getChannel().write(messageToWrite);
            }
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:75,代码来源:OspfInterfaceImpl.java


注:本文中的org.onosproject.ospf.controller.LsaWrapper.ospfLsa方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。