本文整理汇总了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());
}
}
示例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);
}
示例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();
}
}
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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();
}
}
}
示例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());
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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()));
}
示例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()));
}
示例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);
}