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


Java OspfInterface类代码示例

本文整理汇总了Java中org.onosproject.ospf.controller.OspfInterface的典型用法代码示例。如果您正苦于以下问题:Java OspfInterface类的具体用法?Java OspfInterface怎么用?Java OspfInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processMaxAgeLsa

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Process max age LSA.
 *
 * @param wrapper LSA wrapper instance
 */
private void processMaxAgeLsa(LsaWrapper wrapper) {
    //set the destination
    OspfInterface ospfInterface = wrapper.ospfInterface();
    if (ospfInterface != null) {
        LsaHeader header = (LsaHeader) wrapper.ospfLsa().lsaHeader();
        header.setAge(OspfParameters.MAXAGE);
        ((LsaWrapperImpl) wrapper).lsaHeader().setAge(OspfParameters.MAXAGE);
        if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR ||
                ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT) {
            //remove from db
            ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(((LsaWrapperImpl) wrapper).lsaHeader());
            ((OspfAreaImpl) ospfArea).deleteLsa(((LsaWrapperImpl) wrapper).lsaHeader());
        } else {
            ((OspfAreaImpl) ospfArea).deleteLsa(((LsaWrapperImpl) wrapper).lsaHeader());
        }
        log.debug("LSAQueueConsumer: processMaxAgeLsa - Flooded SelfOriginated-Max Age LSA {}",
                  ((LsaWrapperImpl) wrapper).lsaHeader());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:LsaQueueConsumer.java

示例2: addLsa

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Installs a new self-originated LSA if possible.
 * Return true if installing was successful else false.
 *
 * @param newLsa           LSA header instance
 * @param isSelfOriginated is self originated or not
 * @param ospfInterface    OSPF interface instance
 * @return true if successfully added
 */
public boolean addLsa(LsaHeader newLsa, boolean isSelfOriginated, OspfInterface ospfInterface) {

    LsaWrapperImpl lsaWrapper = new LsaWrapperImpl();
    lsaWrapper.setLsaType(newLsa.getOspfLsaType());
    lsaWrapper.setOspfLsa(newLsa);
    lsaWrapper.setLsaHeader(newLsa);
    lsaWrapper.setLsaAgeReceived(newLsa.age());
    lsaWrapper.setAgeCounterWhenReceived(lsdbAge.getAgeCounter());
    lsaWrapper.setAgeCounterRollOverWhenAdded(lsdbAge.getAgeCounterRollOver());
    lsaWrapper.setIsSelfOriginated(isSelfOriginated);
    lsaWrapper.setIsSelfOriginated(isSelfOriginated);
    lsaWrapper.setOspfInterface(ospfInterface);
    lsaWrapper.setLsdbAge(lsdbAge);
    addLsa(lsaWrapper);

    log.debug("Added LSA In LSDB: {}", newLsa);

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:OspfLsdbImpl.java

示例3: initializeInterfaceMap

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Initializes the interface map with interface details.
 *
 * @throws Exception might throws exception
 */
public void initializeInterfaceMap() throws Exception {
    for (OspfProcess process : processes) {
        for (OspfArea area : process.areas()) {
            for (OspfInterface ospfInterface : area.ospfInterfaceList()) {
                OspfInterface anInterface = ospfInterfaceMap.get(ospfInterface.interfaceIndex());
                if (anInterface == null) {
                    ospfInterface.setOspfArea(area);
                    ((OspfInterfaceImpl) ospfInterface).setController(controller);
                    ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DOWN);
                    ospfInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
                    ospfInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
                    ospfInterfaceMap.put(ospfInterface.interfaceIndex(), ospfInterface);
                }
                ((OspfInterfaceImpl) ospfInterface).setChannel(channel);
                ospfInterface.interfaceUp();
                ospfInterface.startDelayedAckTimer();
            }
            //Initialize the LSDB and aging process
            area.initializeDb();
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:OspfInterfaceChannelHandler.java

示例4: channelDisconnected

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
@Override
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) {
    log.debug("OspfChannelHandler::channelDisconnected...!!!");

    for (Integer interfaceIndex : ospfInterfaceMap.keySet()) {
        OspfInterface anInterface = ospfInterfaceMap.get(interfaceIndex);
        if (anInterface != null) {
            anInterface.interfaceDown();
            anInterface.stopDelayedAckTimer();
        }
    }

    if (controller != null) {
        controller.connectPeer();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:OspfInterfaceChannelHandler.java

示例5: OspfNbrImpl

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Creates an instance of Neighbor.
 *
 * @param paramOspfArea                  OSPF Area instance
 * @param paramOspfInterface             OSPF interface instance
 * @param ipAddr                         IP address
 * @param routerId                       router id
 * @param options                        options
 * @param topologyForDeviceAndLinkCommon topology for device and link instance
 */
public OspfNbrImpl(OspfArea paramOspfArea, OspfInterface paramOspfInterface,
                   Ip4Address ipAddr, Ip4Address routerId, int options,
                   TopologyForDeviceAndLink topologyForDeviceAndLinkCommon) {
    this.ospfArea = paramOspfArea;
    this.ospfInterface = paramOspfInterface;
    state = OspfNeighborState.DOWN;
    isMaster = OspfUtil.NOT_MASTER;
    ddSeqNum = OspfUtil.createRandomNumber();
    neighborIpAddr = ipAddr;
    neighborId = routerId;
    this.options = options;
    lastDdPacket = new DdPacket();
    routerDeadInterval = paramOspfInterface.routerDeadIntervalTime();
    this.topologyForDeviceAndLink = topologyForDeviceAndLinkCommon;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:OspfNbrImpl.java

示例6: initializeInterfaceMap

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Initializes the interface map with interface details.
 */
public void initializeInterfaceMap()  {
    for (OspfProcess process : processes) {
        for (OspfArea area : process.areas()) {
            for (OspfInterface ospfInterface : area.ospfInterfaceList()) {
                OspfInterface anInterface = ospfInterfaceMap.get(ospfInterface.interfaceIndex());
                if (anInterface == null) {
                    ospfInterface.setOspfArea(area);
                    ((OspfInterfaceImpl) ospfInterface).setController(controller);
                    ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DOWN);
                    ospfInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
                    ospfInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
                    ospfInterfaceMap.put(ospfInterface.interfaceIndex(), ospfInterface);
                }
                ((OspfInterfaceImpl) ospfInterface).setChannel(channel);
                ospfInterface.interfaceUp();
                ospfInterface.startDelayedAckTimer();
            }
            //Initialize the LSDB and aging process
            area.initializeDb();
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:OspfInterfaceChannelHandler.java

示例7: processRefreshLsa

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

示例8: buildRouterLsa

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Builds Router LSA.
 *
 * @param ospfInterface Interface instance
 * @return routerLsa Router LSA instance
 * @throws Exception might throws exception
 */
public RouterLsa buildRouterLsa(OspfInterface ospfInterface) throws Exception {
    // generate the Router-LSA for this Area.
    RouterLsa routerLsa = new RouterLsa();
    routerLsa.setAdvertisingRouter(routerId);
    routerLsa.setLinkStateId(routerId.toString());
    routerLsa.setLsType(OspfLsaType.ROUTER.value());
    routerLsa.setAge(1);
    routerLsa.setOptions(options);
    routerLsa.setAreaBorderRouter(false);
    routerLsa.setAsBoundaryRouter(false);
    routerLsa.setVirtualEndPoint(false);
    buildLinkForRouterLsa(routerLsa, ospfInterface);
    routerLsa.setLsSequenceNo(database.getLsSequenceNumber(OspfLsaType.ROUTER));
    //Find the byte length and add it in lsa object
    ChecksumCalculator checksum = new ChecksumCalculator();
    byte[] lsaBytes = routerLsa.asBytes();
    routerLsa.setLsPacketLen(lsaBytes.length);
    //Convert lsa object to byte again to reflect the packet length whic we added.
    lsaBytes = routerLsa.asBytes();
    //find the checksum
    byte[] twoByteChecksum = checksum.calculateLsaChecksum(lsaBytes,
                                                           OspfUtil.LSAPACKET_CHECKSUM_POS1,
                                                           OspfUtil.LSAPACKET_CHECKSUM_POS2);
    int checkSumVal = OspfUtil.byteToInteger(twoByteChecksum);
    routerLsa.setLsCheckSum(checkSumVal);
    return routerLsa;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:OspfAreaImpl.java

示例9: processes

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Returns list of OSPF process from the json nodes.
 *
 * @param jsonNodes represents one or more OSPF process configuration
 * @return list of OSPF processes.
 */
public static List<OspfProcess> processes(JsonNode jsonNodes) {
    List<OspfProcess> ospfProcesses = new ArrayList<>();
    if (jsonNodes == null) {
        return ospfProcesses;
    }
    //From each Process nodes, get area and related interface details.
    jsonNodes.forEach(jsonNode -> {
        List<OspfArea> areas = new ArrayList<>();
        //Get configured areas for the process.
        for (JsonNode areaNode : jsonNode.path(AREAS)) {
            List<OspfInterface> interfaceList = new ArrayList<>();
            for (JsonNode interfaceNode : areaNode.path(INTERFACE)) {
                OspfInterface ospfInterface = interfaceDetails(interfaceNode);
                if (ospfInterface != null) {
                    interfaceList.add(ospfInterface);
                }
            }
            //Get the area details
            OspfArea area = areaDetails(areaNode);
            if (area != null) {
                area.setOspfInterfaceList(interfaceList);
                areas.add(area);
            }
        }
        OspfProcess process = new OspfProcessImpl();
        process.setProcessId(jsonNode.path(PROCESSID).asText());
        process.setAreas(areas);
        ospfProcesses.add(process);
    });

    return ospfProcesses;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:OspfConfigUtil.java

示例10: updateConfig

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Updates the processes configuration.
 *
 * @param ospfProcesses list of OSPF process instances
 * @throws Exception might throws parse exception
 */
public void updateConfig(List<OspfProcess> ospfProcesses) throws Exception {
    log.debug("Controller::UpdateConfig called");
    configPacket = new byte[OspfUtil.CONFIG_LENGTH];
    byte numberOfInterface = 0; // number of interfaces to configure
    configPacket[0] = (byte) 0xFF; // its a conf packet - identifier
    for (OspfProcess ospfProcess : ospfProcesses) {
        log.debug("OspfProcessDetails : " + ospfProcess);
        for (OspfArea ospfArea : ospfProcess.areas()) {
            for (OspfInterface ospfInterface : ospfArea.ospfInterfaceList()) {
                log.debug("OspfInterfaceDetails : " + ospfInterface);
                numberOfInterface++;
                configPacket[2 * numberOfInterface] = (byte) ospfInterface.interfaceIndex();
                configPacket[(2 * numberOfInterface) + 1] = (byte) 4;
            }
        }
    }
    configPacket[1] = numberOfInterface;
    //First time configuration
    if (processes == null) {
        if (ospfProcesses.size() > 0) {
            processes = ospfProcesses;
            connectPeer();
        }
    } else {
        ospfChannelHandler.updateInterfaceMap(ospfProcesses);
        //Send the config packet
        ospfChannelHandler.sentConfigPacket(configPacket);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:Controller.java

示例11: processOspfMessage

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * When an OSPF message received it is handed over to this method.
 * Based on the type of the OSPF message received it will be handed over
 * to corresponding message handler methods.
 *
 * @param ospfMessage received OSPF message
 * @param ctx         channel handler context instance.
 * @throws Exception might throws exception
 */
public void processOspfMessage(OspfMessage
                                       ospfMessage, ChannelHandlerContext ctx) throws Exception {
    log.debug("OspfChannelHandler::processOspfMessage...!!!");
    int interfaceIndex = ospfMessage.interfaceIndex();
    OspfInterface ospfInterface = ospfInterfaceMap.get(interfaceIndex);
    if (ospfInterface != null) {
        ospfInterface.processOspfMessage(ospfMessage, ctx);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OspfInterfaceChannelHandler.java

示例12: addLocalDevice

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Adds device information to map.
 *
 * @param ospfLsa       OSPF LSA instance
 * @param ospfInterface OSPF interface instance
 * @param ospfArea      OSPF area instance
 */
public void addLocalDevice(OspfLsa ospfLsa, OspfInterface ospfInterface, OspfArea ospfArea) {
    if (ospfLsa.getOspfLsaType().equals(OspfLsaType.ROUTER)) {
        createDeviceAndLinkFromRouterLsa(ospfLsa, ospfArea);
    } else if (ospfLsa.getOspfLsaType().equals(OspfLsaType.NETWORK)) {
        createDeviceAndLinkFromNetworkLsa(ospfLsa, ospfArea);
    } else if (ospfLsa.getOspfLsaType().equals(OspfLsaType.AREA_LOCAL_OPAQUE_LSA)) {
        createDeviceAndLinkFromOpaqueLsa(ospfLsa, ospfArea);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:TopologyForDeviceAndLinkImpl.java

示例13: isLinkStateMatchesOwnRouterId

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Checks Link State ID is equal to one of the router's own IP interface addresses.
 *
 * @param linkStateId link state id
 * @return true if link state matches or false
 */
private boolean isLinkStateMatchesOwnRouterId(String linkStateId) {
    boolean isLinkStateMatches = false;
    List<OspfInterface> interfaceLst = ospfArea.ospfInterfaceList();
    for (OspfInterface ospfInterface : interfaceLst) {
        if (ospfInterface.ipAddress().toString().equals(linkStateId)) {
            isLinkStateMatches = true;
            break;
        }
    }

    return isLinkStateMatches;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OspfNbrImpl.java

示例14: buildNeighborInformation

import org.onosproject.ospf.controller.OspfInterface; //导入依赖的package包/类
/**
 * Builds OSPF neighbor information.
 */
private void buildNeighborInformation() {
    try {
        this.ospfController = get(OspfController.class);
        List<OspfProcess> listOfProcess = ospfController.getAllConfiguredProcesses();
        boolean flag = false;
        printNeighborsFormat();
        Iterator<OspfProcess> itrProcess = listOfProcess.iterator();
        while (itrProcess.hasNext()) {
            OspfProcess process = itrProcess.next();
            List<OspfArea> listAreas = process.areas();
            Iterator<OspfArea> itrArea = listAreas.iterator();
            while (itrArea.hasNext()) {
                OspfArea area = itrArea.next();
                List<OspfInterface> itrefaceList = area.ospfInterfaceList();
                for (OspfInterface interfc : itrefaceList) {
                    List<OspfNbr> nghbrList = new ArrayList<>(interfc.listOfNeighbors().values());
                    for (OspfNbr neigbor : nghbrList) {
                        print("%-20s%-20s%-20s%-20s%-20s\n", neigbor.neighborId(), neigbor.routerPriority(),
                              neigbor.getState() + "/" + checkDrBdrOther(neigbor.neighborIpAddr().toString(),
                                                                         neigbor.neighborDr().toString(),
                                                                         neigbor.neighborBdr().toString()),
                              neigbor.neighborIpAddr().toString(), interfc.ipAddress());
                    }
                }
            }
        }
    } catch (Exception ex) {
        print("Error occured while Ospf controller getting called" + ex.getMessage());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:ApplicationOspfCommand.java

示例15: processRefreshLsa

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


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