當前位置: 首頁>>代碼示例>>Java>>正文


Java OspfInterfaceState類代碼示例

本文整理匯總了Java中org.onosproject.ospf.protocol.util.OspfInterfaceState的典型用法代碼示例。如果您正苦於以下問題:Java OspfInterfaceState類的具體用法?Java OspfInterfaceState怎麽用?Java OspfInterfaceState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OspfInterfaceState類屬於org.onosproject.ospf.protocol.util包,在下文中一共展示了OspfInterfaceState類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processMaxAgeLsa

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的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: interfaceUp

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Represents an interface is up and connected.
 *
 * @throws Exception might throws exception
 */
public void interfaceUp() throws Exception {
    log.debug("OSPFInterfaceChannelHandler::interfaceUp...!!!");
    if (interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
        setState(OspfInterfaceState.POINT2POINT);
        interfaceTypeOldValue = interfaceType();
        log.debug("OSPFInterfaceChannelHandler::InterfaceType {} state {} ",
                  interfaceType(), state());
    } else if (interfaceType() == OspfInterfaceType.BROADCAST.value()) {
        //if router priority is 0, move the state to DROther
        interfaceTypeOldValue = interfaceType();
        if (routerPriority() == 0) {
            setState(OspfInterfaceState.DROTHER);
        } else {
            log.debug("OSPFInterfaceChannelHandler::InterfaceType {} state {} RouterPriority {}",
                      interfaceType(),
                      state(), routerPriority());
            setState(OspfInterfaceState.WAITING);
            //start wait timer - like inactivity timer with router deadInterval
            startWaitTimer();
        }
    }
    // Start hello timer with interval from config - convert seconds to milliseconds
    startHelloTimer();
    ospfArea.refreshArea(this);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:31,代碼來源:OspfInterfaceImpl.java

示例3: initializeInterfaceMap

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的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: testRun1

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Tests run() method.
 */
@Test
public void testRun1() throws Exception {
    blockingQueue = new ArrayBlockingQueue(5);
    channel = EasyMock.createMock(Channel.class);
    ospfArea = new OspfAreaImpl();
    lsaWrapper = new LsaWrapperImpl();
    routerLsa = new RouterLsa();
    routerLsa.setLsType(1);
    lsaWrapper.addLsa(OspfLsaType.ROUTER, routerLsa);
    ospfInterface = new OspfInterfaceImpl();
    ospfInterface.setState(OspfInterfaceState.DR);
    lsaWrapper.setOspfInterface(ospfInterface);
    lsaWrapper.setIsSelfOriginated(true);
    lsaHeader = new LsaHeader();
    lsaHeader.setLsType(1);
    lsaWrapper.setLsaHeader(lsaHeader);
    lsaWrapper.setLsaProcessing("refreshLsa");
    lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
    blockingQueue.add(lsaWrapper);
    lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
    lsaQueueConsumer.run();
    assertThat(lsaQueueConsumer, is(notNullValue()));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:27,代碼來源:LsaQueueConsumerTest.java

示例5: testRun3

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
@Test
public void testRun3() throws Exception {
    blockingQueue = new ArrayBlockingQueue(5);
    channel = EasyMock.createMock(Channel.class);
    ospfArea = new OspfAreaImpl();
    lsaWrapper = new LsaWrapperImpl();
    routerLsa = new RouterLsa();
    routerLsa.setLsType(2);
    lsaWrapper.addLsa(OspfLsaType.NETWORK, routerLsa);
    ospfInterface = new OspfInterfaceImpl();
    ospfInterface.setState(OspfInterfaceState.BDR);
    lsaWrapper.setOspfInterface(ospfInterface);
    lsaWrapper.setIsSelfOriginated(true);
    lsaHeader = new LsaHeader();
    lsaHeader.setLsType(2);
    lsaWrapper.setLsaHeader(lsaHeader);
    lsaWrapper.setLsaProcessing("refreshLsa");
    lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
    blockingQueue.add(lsaWrapper);
    lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
    lsaQueueConsumer.run();
    assertThat(lsaQueueConsumer, is(notNullValue()));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:LsaQueueConsumerTest.java

示例6: testRun5

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Tests run() method.
 */
@Test
public void testRun5() throws Exception {
    blockingQueue = new ArrayBlockingQueue(5);
    channel = EasyMock.createMock(Channel.class);
    ospfArea = new OspfAreaImpl();
    lsaWrapper = new LsaWrapperImpl();
    routerLsa = new RouterLsa();
    routerLsa.setLsType(2);
    lsaWrapper.addLsa(OspfLsaType.NETWORK, routerLsa);
    ospfInterface = new OspfInterfaceImpl();
    ospfInterface.setState(OspfInterfaceState.DR);
    lsaWrapper.setOspfInterface(ospfInterface);
    lsaWrapper.setIsSelfOriginated(true);
    lsaHeader = new LsaHeader();
    lsaHeader.setLsType(2);
    lsaWrapper.setLsaHeader(lsaHeader);
    lsaWrapper.setLsaProcessing("maxAgeLsa");
    lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
    blockingQueue.add(lsaWrapper);
    lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
    lsaQueueConsumer.run();
    assertThat(lsaQueueConsumer, is(notNullValue()));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:27,代碼來源:LsaQueueConsumerTest.java

示例7: initializeInterfaceMap

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的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

示例8: processRefreshLsa

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的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

示例9: backupSeen

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Gets called when a BDR was detected before the wait timer expired.
 *
 * @param ch channel instance
 * @throws Exception might throws exception
 */
public void backupSeen(Channel ch) throws Exception {
    log.debug("OSPFInterfaceChannelHandler::backupSeen ");
    if (state() == OspfInterfaceState.WAITING) {
        electRouter(ch);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:13,代碼來源:OspfInterfaceImpl.java

示例10: waitTimer

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Gets called when no hello message received for particular period.
 *
 * @param ch channel instance
 * @throws Exception might throws exception
 */
public void waitTimer(Channel ch) throws Exception {
    log.debug("OSPFInterfaceChannelHandler::waitTimer ");
    //section 9.4
    if (state() == OspfInterfaceState.WAITING) {
        electRouter(ch);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:14,代碼來源:OspfInterfaceImpl.java

示例11: neighborChange

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Neighbor change event is triggered when the router priority gets changed.
 *
 * @throws Exception might throws exception
 */
public void neighborChange() throws Exception {
    log.debug("OSPFInterfaceChannelHandler::neighborChange ");
    if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR ||
            state() == OspfInterfaceState.DROTHER) {
        electRouter(channel);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:13,代碼來源:OspfInterfaceImpl.java

示例12: interfaceDown

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Gets called when an interface is down.
 * All interface variables are reset, and interface timers disabled.
 * Also all neighbor connections associated with the interface are destroyed.
 */
public void interfaceDown() {
    log.debug("OSPFInterfaceChannelHandler::interfaceDown ");
    stopHelloTimer();
    listOfNeighbors().clear();
    setState(OspfInterfaceState.DOWN);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:12,代碼來源:OspfInterfaceImpl.java

示例13: getMessage

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Gets message as bytes.
 *
 * @param ospfMessage OSPF message
 * @return OSPF message
 */
private byte[] getMessage(OspfMessage ospfMessage) {
    OspfMessageWriter messageWriter = new OspfMessageWriter();
    if (state().equals(OspfInterfaceState.POINT2POINT)) {
        ospfMessage.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
    }
    return (messageWriter.getMessage(ospfMessage, interfaceIndex, state.value()));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:14,代碼來源:OspfInterfaceImpl.java

示例14: getMessage

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
/**
 * Gets message as bytes.
 *
 * @param ospfMessage OSPF message
 * @return OSPF message
 */
private byte[] getMessage(OspfMessage ospfMessage) {
    OspfMessageWriter messageWriter = new OspfMessageWriter();
    if (((OspfInterfaceImpl) ospfInterface).state().equals(OspfInterfaceState.POINT2POINT)) {
        ospfMessage.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
    }
    return (messageWriter.getMessage(ospfMessage, ospfInterface.interfaceIndex(),
                                     ((OspfInterfaceImpl) ospfInterface).state().value()));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:15,代碼來源:OspfNbrImpl.java

示例15: setUp

import org.onosproject.ospf.protocol.util.OspfInterfaceState; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    lsaHeader = new LsaHeader();
    opaqueLsaHeader = new OpaqueLsaHeader();
    opaqueLsaHeader.setAdvertisingRouter(ip4Address);
    lsaHeader.setAdvertisingRouter(ip4Address);
    routerLsa = new RouterLsa(lsaHeader);
    routerLsa.setAdvertisingRouter(ip4Address);
    opaqueLsa10 = new OpaqueLsa10(opaqueLsaHeader);
    ospfArea = new OspfAreaImpl();
    ospfInterface1 = new OspfInterfaceImpl();
    topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
    ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface1, ip4Address, ip4Address1,
                              2, topologyForDeviceAndLink);
    ospfNbr.setState(OspfNeighborState.EXCHANGE);
    ospfNbr1 = new OspfNbrImpl(ospfArea, ospfInterface1, ip4Address, ip4Address1,
                               2, topologyForDeviceAndLink);
    ospfNbr1.setState(OspfNeighborState.FULL);
    ospfNbr1.setNeighborId(ip4Address);
    ospfNbr.setNeighborId(ip4Address);
    ospfNbr.setIsOpaqueCapable(true);
    ospfInterface1.addNeighbouringRouter(ospfNbr);
    ospfInterface1.addNeighbouringRouter(ospfNbr1);
    ospfInterface2 = new OspfInterfaceImpl();
    ospfInterface2.setIpAddress(ip4Address);
    ospfInterface2.setIpNetworkMask(networkAddress);
    ospfInterface2.setState(OspfInterfaceState.LOOPBACK);
    ospfInterface2.addNeighbouringRouter(ospfNbr);
    ospfInterface2.addNeighbouringRouter(ospfNbr1);
    ospfInterfaces.add(ospfInterface2);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:32,代碼來源:OspfAreaImplTest.java


注:本文中的org.onosproject.ospf.protocol.util.OspfInterfaceState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。