ONOS源码笔记--实现

app生命周期

@Activate
public void activate(ComponentContext context ) {
    cfgService.registerProperties(getClass());
    appId = coreService .registerApplication("org.onosproject.fwd");

    packetService.addProcessor(processor , PacketProcessor.director(2));
    topologyService.addListener(topologyListener );
    readComponentConfiguration( context);
    requestIntercepts();

    log.info("Started" , appId .id());
}

@Deactivate
public void deactivate() {
    cfgService.unregisterProperties(getClass(), false);
    withdrawIntercepts();
    flowRuleService.removeFlowRulesById(appId );
    packetService.removeProcessor(processor );
    topologyService.removeListener(topologyListener );
    processor = null ;
    log.info("Stopped" );
}

@Modified
public void modified(ComponentContext context ) {
    readComponentConfiguration( context);
    requestIntercepts();
}

常见功能函数

// Indicates whether this is a control packet, e.g. LLDP, BDDP
// 判断是否为控制数据包
private boolean isControlPacket(Ethernet eth ) {
    short type = eth.getEtherType();
    return type == Ethernet.TYPE_LLDP || type == Ethernet.TYPE_BSN;
}

// Indicated whether this is an IPv6 multicast packet.
// 判断是否为ipv6多播包
private boolean isIpv6Multicast(Ethernet eth ) {
    return eth .getEtherType() == Ethernet.TYPE_IPV6 && eth.isMulticast();
}

// Selects a path from the given set that does not lead back to the
// specified port if possible.
// 在一个给定的path集合中选择一条不通过指定端口的路径
private Path pickForwardPathIfPossible(Set<Path> paths, PortNumber notToPort) {
    Path lastPath = null ;
    for (Path path : paths) {
        lastPath = path ;
        if (!path .src().port().equals(notToPort)) {
            return path ;
        }
    }
    return lastPath ;
}

// Floods t
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值