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


Java LsaHeader类代码示例

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


LsaHeader类属于org.onosproject.ospf.protocol.lsa包,在下文中一共展示了LsaHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:LsAcknowledge.java

示例2: testIsValidLsaCheckSum6

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的package包/类
/**
 * Tests isValidLsaCheckSum() method.
 */
@Test
public void testIsValidLsaCheckSum6() throws Exception {

    external2 = new SummaryLsa(new LsaHeader());
    external2.setAge(2);
    external2.setOptions(2);
    external2.setLsType(3);
    external2.setLinkStateId("80.212.16.0");
    external2.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
    external2.setLsSequenceNo(2147483649L);
    external2.setLsCheckSum(25125);
    external2.setLsPacketLen(36);
    validate = checksumCalculator.isValidLsaCheckSum(external2, external2.lsType(),
                                                     lsaChecksumPos1, lsaChecksumPos2);
    assertThat(validate, is(false));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:ChecksumCalculatorTest.java

示例3: testIsValidLsaCheckSum7

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的package包/类
/**
 * Tests isValidLsaCheckSum() method.
 */
@Test(expected = Exception.class)
public void testIsValidLsaCheckSum7() throws Exception {
    external3 = new AsbrSummaryLsa(new LsaHeader());
    external3.setAge(2);
    external3.setOptions(2);
    external3.setLsType(4);
    external3.setLinkStateId("80.212.16.0");
    external3.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
    external3.setLsSequenceNo(2147483649L);
    external3.setLsCheckSum(25125);
    external3.setLsPacketLen(36);
    validate = checksumCalculator.isValidLsaCheckSum(external3, external3.lsType(),
                                                     lsaChecksumPos1, lsaChecksumPos2);
    assertThat(validate, is(false));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:ChecksumCalculatorTest.java

示例4: processMaxAgeLsa

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的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

示例5: 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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:OspfLsdbImpl.java

示例6: addLsa

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的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

示例7: processLsUpdateMessage

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的package包/类
/**
 * Process the ls update message.
 *
 * @param ospfMessage OSPF message instance.
 * @param ctx         channel handler context instance.
 * @throws Exception might throws exception
 */
void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
    log.debug("OspfChannelHandler::processLsUpdateMessage");
    LsUpdate lsUpdate = (LsUpdate) ospfMessage;
    String neighbourId = lsUpdate.routerId().toString();
    //LSUpdate packet has been associated with a particular neighbor.
    //Neighbor should not be in lesser state than Exchange.
    if (isNeighborInList(neighbourId)) {
        OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId);
        if (nbr.getState() == OspfNeighborState.EXCHANGE ||
                nbr.getState() == OspfNeighborState.LOADING) {
            nbr.processLsUpdate(lsUpdate, ctx.getChannel());
        } else if (nbr.getState() == OspfNeighborState.FULL) {
            if (lsUpdate.noLsa() != 0) {
                List<OspfLsa> list = lsUpdate.getLsaList();
                Iterator itr = list.iterator();
                while (itr.hasNext()) {
                    LsaHeader lsa = (LsaHeader) itr.next();
                    nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp());
                }
            } else {
                return;
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:OspfInterfaceImpl.java

示例8: isNullorLatest

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的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

示例9: sendLsa

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的package包/类
/**
 * Sends the LSA to destination address.
 *
 * @param lsa         LSA instance to sent
 * @param destination destination IP address
 * @param ch          netty channel instance
 */
public void sendLsa(LsaHeader lsa, Ip4Address destination, Channel ch) {
    if (lsa == null) {
        return;
    }

    LsUpdate responseLsUpdate = new LsUpdate();
    // seting OSPF Header
    responseLsUpdate.setOspfVer(OspfUtil.OSPF_VERSION);
    responseLsUpdate.setOspftype(OspfPacketType.LSUPDATE.value());
    responseLsUpdate.setRouterId(ospfArea.routerId());
    responseLsUpdate.setAreaId(ospfArea.areaId());
    responseLsUpdate.setAuthType(OspfUtil.NOT_ASSIGNED);
    responseLsUpdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
    responseLsUpdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
    responseLsUpdate.setChecksum(OspfUtil.NOT_ASSIGNED);
    responseLsUpdate.setNumberOfLsa(1);
    responseLsUpdate.addLsa(lsa);

    //setting the destination.
    responseLsUpdate.setDestinationIp(destination);
    byte[] messageToWrite = getMessage(responseLsUpdate);
    ch.write(messageToWrite);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:OspfNbrImpl.java

示例10: directAcknowledge

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的package包/类
/**
 * Sends a direct Acknowledgment for a particular LSA to the Neighbor.
 *
 * @param ackLsa   LSA instance
 * @param ch       netty channel instance
 * @param sourceIp source IP address
 */
public void directAcknowledge(LsaHeader ackLsa, Channel ch, Ip4Address sourceIp) {
    log.debug("OSPFNbr::directAcknowledge...!!!");

    LsAcknowledge ackContent = new LsAcknowledge();
    // seting OSPF Header
    ackContent.setOspfVer(OspfUtil.OSPF_VERSION);
    ackContent.setOspftype(OspfPacketType.LSAACK.value());
    ackContent.setRouterId(ospfArea.routerId());
    ackContent.setAreaId(ospfArea.areaId());
    ackContent.setAuthType(OspfUtil.NOT_ASSIGNED);
    ackContent.setAuthentication(OspfUtil.NOT_ASSIGNED);
    ackContent.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
    ackContent.setChecksum(OspfUtil.NOT_ASSIGNED);
    ackContent.addLinkStateHeader(ackLsa);
    //setting the destination IP
    ackContent.setDestinationIp(sourceIp);
    byte[] messageToWrite = getMessage(ackContent);
    ch.write(messageToWrite);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:OspfNbrImpl.java

示例11: testRun1

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的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

示例12: testRun3

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的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

示例13: testRun5

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的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

示例14: processLsUpdateMessage

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的package包/类
/**
 * Process the ls update message.
 *
 * @param ospfMessage OSPF message instance.
 * @param ctx         channel handler context instance.
 * @throws OspfParseException on parsing error
 */
void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws OspfParseException {
    log.debug("OspfChannelHandler::processLsUpdateMessage");
    LsUpdate lsUpdate = (LsUpdate) ospfMessage;
    String neighbourId = lsUpdate.routerId().toString();
    //LSUpdate packet has been associated with a particular neighbor.
    //Neighbor should not be in lesser state than Exchange.
    if (isNeighborInList(neighbourId)) {
        OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId);
        if (nbr.getState() == OspfNeighborState.EXCHANGE ||
                nbr.getState() == OspfNeighborState.LOADING) {
            nbr.processLsUpdate(lsUpdate, ctx.getChannel());
        } else if (nbr.getState() == OspfNeighborState.FULL) {
            if (lsUpdate.noLsa() != 0) {
                List<OspfLsa> list = lsUpdate.getLsaList();
                Iterator itr = list.iterator();
                while (itr.hasNext()) {
                    LsaHeader lsa = (LsaHeader) itr.next();
                    nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp());
                }
            } else {
                return;
            }
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:33,代码来源:OspfInterfaceImpl.java

示例15: addLsaHeader

import org.onosproject.ospf.protocol.lsa.LsaHeader; //导入依赖的package包/类
/**
 * Adds LSA header to header list.
 *
 * @param lsaHeader lsa header instance
 */
public void addLsaHeader(LsaHeader lsaHeader) {

    if (!lsaHeaderList.contains(lsaHeader)) {
        lsaHeaderList.add(lsaHeader);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:DdPacket.java


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