• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PacketContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    if (context == null || context.isHandled()) {
        return;
    }

    Ethernet eth = context.inPacket().parsed();
    if (eth == null || (eth.getEtherType() != TYPE_LLDP && eth.getEtherType() != TYPE_BSN)) {
        return;
    }

    LinkDiscovery ld = discoverers.get(context.inPacket().receivedFrom().deviceId());
    if (ld == null) {
        return;
    }

    if (ld.handleLldp(context)) {
        context.block();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:LldpLinkProvider.java


示例2: extractLinkKey

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
LinkKey extractLinkKey(PacketContext packetContext) {
    Ethernet eth = packetContext.inPacket().parsed();
    if (eth == null) {
        return null;
    }

    ONOSLLDP onoslldp = ONOSLLDP.parseONOSLLDP(eth);
    if (onoslldp != null) {
        PortNumber srcPort = portNumber(onoslldp.getPort());
        PortNumber dstPort = packetContext.inPacket().receivedFrom().port();
        DeviceId srcDeviceId = DeviceId.deviceId(onoslldp.getDeviceString());
        DeviceId dstDeviceId = packetContext.inPacket().receivedFrom().deviceId();

        ConnectPoint src = new ConnectPoint(srcDeviceId, srcPort);
        ConnectPoint dst = new ConnectPoint(dstDeviceId, dstPort);
        return LinkKey.linkKey(src, dst);
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:NetworkConfigLinksProvider.java


示例3: testNotConfiguredLink

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
/**
 * Tests discovery of a link that is not expected in the configuration.
 */
@Test
public void testNotConfiguredLink() {
    PacketContext pktCtx = new TestPacketContext(src, dst);

    testProcessor.process(pktCtx);

    assertThat(providerService.discoveredLinks().entrySet(), hasSize(1));
    DeviceId destination = providerService.discoveredLinks().get(dev1.id());
    assertThat(destination, notNullValue());
    LinkKey key = LinkKey.linkKey(src, dst);
    LinkDescription linkDescription = providerService
            .discoveredLinkDescriptions().get(key);
    assertThat(linkDescription, notNullValue());
    assertThat(linkDescription.isExpected(), is(false));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:NetworkConfigLinksProviderTest.java


示例4: testConfiguredLink

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
/**
 * Tests discovery of an expected link.
 */
@Test
public void testConfiguredLink() {
    LinkKey key = LinkKey.linkKey(src, dst);
    configListener.event(new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED,
                                                key,
                                                BasicLinkConfig.class));

    PacketContext pktCtx = new TestPacketContext(src, dst);

    testProcessor.process(pktCtx);

    assertThat(providerService.discoveredLinks().entrySet(), hasSize(1));
    DeviceId destination = providerService.discoveredLinks().get(dev1.id());
    assertThat(destination, notNullValue());
    LinkDescription linkDescription = providerService
            .discoveredLinkDescriptions().get(key);
    assertThat(linkDescription, notNullValue());
    assertThat(linkDescription.isExpected(), is(true));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:NetworkConfigLinksProviderTest.java


示例5: handlePacketIn

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void handlePacketIn(Bmv2Device device, int inputPort, ImmutableByteSequence packet) {
    Ethernet ethPkt = new Ethernet();
    ethPkt.deserialize(packet.asArray(), 0, packet.size());

    DeviceId deviceId = device.asDeviceId();
    ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(inputPort));

    ByteBuffer rawData = ByteBuffer.wrap(packet.asArray());

    InboundPacket inPkt = new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
    OutboundPacket outPkt = new DefaultOutboundPacket(deviceId, null, rawData);

    PacketContext pktCtx = new Bmv2PacketContext(System.currentTimeMillis(), inPkt, outPkt, false);

    providerService.processPacket(pktCtx);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:Bmv2PacketProvider.java


示例6: forwardPacketToDst

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
/**
 * Forward the packet to it's multicast destinations.
 *
 * @param context The packet context
 * @param egressList The list of egress ports which the multicast packet is intended for.
 */
private void forwardPacketToDst(PacketContext context, ArrayList<ConnectPoint> egressList) {

    // Send the pack out each of the respective egress ports
    for (ConnectPoint egress : egressList) {
        TrafficTreatment treatment = DefaultTrafficTreatment.builder()
                .setOutput(egress.port()).build();

        OutboundPacket packet = new DefaultOutboundPacket(
                egress.deviceId(),
                treatment,
                context.inPacket().unparsed());

        packetService.emit(packet);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:McastForwarding.java


示例7: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    // Stop processing if the packet has been handled, since we
    // can't do any more to it.
    if (context.isHandled()) {
        return;
    }

    Ethernet packet = context.inPacket().parsed();

    if (packet == null) {
        return;
    }

    if (packet.getEtherType() == Ethernet.TYPE_IPV4) {
        IPv4 ipv4Packet = (IPv4) packet.getPayload();
        if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_TCP) {
            TCP tcpPacket = (TCP) ipv4Packet.getPayload();

            if (tcpPacket.getDestinationPort() == BGP_PORT ||
                    tcpPacket.getSourcePort() == BGP_PORT) {
                forward(context);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:TunnellingConnectivityManager.java


示例8: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    // Stop processing if the packet has been handled, since we
    // can't do any more to it.

    if (context.isHandled()) {
        return;
    }

    Ethernet packet = context.inPacket().parsed();

    if (packet == null) {
        return;
    }

    if (packet.getEtherType() == Ethernet.TYPE_IPV4) {
        IPv4 ipv4Packet = (IPv4) packet.getPayload();
        if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) {
            processPacketIn(context.inPacket());
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:IcmpHandler.java


示例9: processArpPacket

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
/**
 * Processes the ARP Payload and initiates a reply to the client.
 *
 * @param context context of the incoming message
 * @param packet the ethernet payload
 */
private void processArpPacket(PacketContext context, Ethernet packet) {

    ARP arpPacket = (ARP) packet.getPayload();

    ARP arpReply = (ARP) arpPacket.clone();
    arpReply.setOpCode(ARP.OP_REPLY);

    arpReply.setTargetProtocolAddress(arpPacket.getSenderProtocolAddress());
    arpReply.setTargetHardwareAddress(arpPacket.getSenderHardwareAddress());
    arpReply.setSenderProtocolAddress(arpPacket.getTargetProtocolAddress());
    arpReply.setSenderHardwareAddress(myMAC.toBytes());

    // Ethernet Frame.
    Ethernet ethReply = new Ethernet();
    ethReply.setSourceMACAddress(myMAC);
    ethReply.setDestinationMACAddress(packet.getSourceMAC());
    ethReply.setEtherType(Ethernet.TYPE_ARP);
    ethReply.setVlanID(packet.getVlanID());

    ethReply.setPayload(arpReply);
    sendReply(context, ethReply);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:DhcpManager.java


示例10: discoverHost

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
/**
 * Integrates hosts learned through DHCP into topology.
 * @param context context of the incoming message
 * @param ipAssigned IP Address assigned to the host by DHCP Manager
 */
private void discoverHost(PacketContext context, Ip4Address ipAssigned) {
    if (!allowHostDiscovery) {
        // host discovery is not allowed, do nothing
        return;
    }

    Ethernet packet = context.inPacket().parsed();
    MacAddress mac = packet.getSourceMAC();
    VlanId vlanId = VlanId.vlanId(packet.getVlanID());
    HostLocation hostLocation = new HostLocation(context.inPacket().receivedFrom(), 0);

    Set<IpAddress> ips = new HashSet<>();
    ips.add(ipAssigned);

    HostId hostId = HostId.hostId(mac, vlanId);
    DefaultHostDescription desc = new DefaultHostDescription(mac, vlanId, hostLocation, ips);

    log.info("Discovered host {}", desc);
    hostProviderService.hostDetected(hostId, desc, false);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DhcpManager.java


示例11: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {

    if (context.isHandled()) {
        return;
    }

    InboundPacket pkt = context.inPacket();
    Ethernet ethernet = pkt.parsed();
    log.trace("Rcvd pktin: {}", ethernet);
    if (ethernet.getEtherType() == Ethernet.TYPE_ARP) {
        arpHandler.processPacketIn(pkt);
    } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
        IPv4 ipPacket = (IPv4) ethernet.getPayload();
        ipHandler.addToPacketBuffer(ipPacket);
        if (ipPacket.getProtocol() == IPv4.PROTOCOL_ICMP) {
            icmpHandler.processPacketIn(pkt);
        } else {
            ipHandler.processPacketIn(pkt);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:SegmentRoutingManager.java


示例12: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    if (context.isHandled()) {
        return;
    }

    Ethernet ethPacket = context.inPacket().parsed();
    if (ethPacket == null || ethPacket.getEtherType() != Ethernet.TYPE_IPV4) {
        return;
    }
    IPv4 ipv4Packet = (IPv4) ethPacket.getPayload();
    if (ipv4Packet.getProtocol() != IPv4.PROTOCOL_UDP) {
        return;
    }
    UDP udpPacket = (UDP) ipv4Packet.getPayload();
    if (udpPacket.getDestinationPort() != UDP.DHCP_SERVER_PORT ||
            udpPacket.getSourcePort() != UDP.DHCP_CLIENT_PORT) {
        return;
    }

    DHCP dhcpPacket = (DHCP) udpPacket.getPayload();
    processDhcp(context, dhcpPacket);
}
 
开发者ID:opencord,项目名称:vtn,代码行数:24,代码来源:CordVtnDhcpProxy.java


示例13: sendReply

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
private void sendReply(PacketContext context, Ethernet ethReply) {
    if (ethReply == null) {
        return;
    }
    ConnectPoint srcPoint = context.inPacket().receivedFrom();
    TrafficTreatment treatment = DefaultTrafficTreatment
            .builder()
            .setOutput(srcPoint.port())
            .build();

    packetService.emit(new DefaultOutboundPacket(
            srcPoint.deviceId(),
            treatment,
            ByteBuffer.wrap(ethReply.serialize())));
    context.block();
}
 
开发者ID:opencord,项目名称:vtn,代码行数:17,代码来源:CordVtnDhcpProxy.java


示例14: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    if (context.isHandled()) {
        return;
    }
    Ethernet ethPacket = context.inPacket().parsed();
    if (ethPacket == null || ethPacket.getEtherType() != Ethernet.TYPE_ARP) {
        return;
    }

    ARP arpPacket = (ARP) ethPacket.getPayload();
    switch (arpPacket.getOpCode()) {
        case ARP.OP_REQUEST:
            processArpRequest(context, ethPacket);
            break;
        case ARP.OP_REPLY:
            processArpReply(context, ethPacket);
            break;
        default:
            break;
    }
}
 
开发者ID:opencord,项目名称:vtn,代码行数:23,代码来源:CordVtnArpProxy.java


示例15: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
	if (context.isHandled()) {
		return;
	}
	InboundPacket pkt = context.inPacket();
	Ethernet ethPkt = pkt.parsed();

	if (ethPkt == null) {
		return;
	}

	if (ethPkt.getEtherType() == EtherType.ARP.ethType().toShort()) {
		context.treatmentBuilder().setOutput(PortNumber.FLOOD);
		context.send();
	}
}
 
开发者ID:ShakhMoves,项目名称:ShakhSDVPN,代码行数:18,代码来源:ARPHandler.java


示例16: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    // Stop processing if the packet has been handled, since we
    // can't do any more to it.
    if (context.isHandled()) {
        return;
    }
    // If IPv6 NDP is disabled, don't handle IPv6 frames.
    InboundPacket pkt = context.inPacket();
    Ethernet ethPkt = pkt.parsed();
    if (ethPkt == null) {
        return;
    }
    if (!ipv6NeighborDiscovery && (ethPkt.getEtherType() == Ethernet.TYPE_IPV6)) {
        return;
    }
    //handle the arp packet.
    proxyArpService.handlePacket(context);
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:20,代码来源:ProxyArp.java


示例17: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {

    if (context.isHandled()) {
        return;
    }

    InboundPacket pkt = context.inPacket();
    Ethernet ethernet = pkt.parsed();

    if (ethernet.getEtherType() == Ethernet.TYPE_ARP) {
        arpHandler.processPacketIn(pkt);
    } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
        IPv4 ipPacket = (IPv4) ethernet.getPayload();
        ipHandler.addToPacketBuffer(ipPacket);
        if (ipPacket.getProtocol() == IPv4.PROTOCOL_ICMP) {
            icmpHandler.processPacketIn(pkt);
        } else {
            ipHandler.processPacketIn(pkt);
        }
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:23,代码来源:SegmentRoutingManager.java


示例18: handleNdp

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
private boolean handleNdp(PacketContext context, Ethernet ethPkt) {
    IPv6 ipv6 = (IPv6) ethPkt.getPayload();

    if (ipv6.getNextHeader() != IPv6.PROTOCOL_ICMP6) {
        return false;
    }
    ICMP6 icmpv6 = (ICMP6) ipv6.getPayload();
    if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_ADVERTISEMENT) {
        forward(ethPkt, context.inPacket().receivedFrom());
    } else if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) {
        reply(ethPkt, context.inPacket().receivedFrom());
    } else {
        return false;
    }
    context.block();
    return true;
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:18,代码来源:ProxyArpManager.java


示例19: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    if (context.isHandled()) {
        return;
    }
    VirtualPacketContext vContexts = virtualize(context);

    if (vContexts == null) {
        return;
    }

    VirtualPacketProviderService service =
            (VirtualPacketProviderService) providerRegistryService
                    .getProviderService(vContexts.networkId(),
                                        VirtualPacketProvider.class);
    if (service != null) {
        service.processPacket(vContexts);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:DefaultVirtualPacketProvider.java


示例20: process

import org.onosproject.net.packet.PacketContext; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    if (context.isHandled()) {
        return;
    }

    if (interfaceService.getInterfacesByPort(context.inPacket().receivedFrom()).isEmpty()) {
        // Don't handle packets that don't come from one of our configured interfaces
        return;
    }

    Ethernet eth = context.inPacket().parsed();
    if (eth == null) {
        return;
    }

    if (!handle(eth)) {
        return;
    }

    context.block();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:DirectHostManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MethodReferencesSearch类代码示例发布时间:2022-05-23
下一篇:
Java SimplePositionedByteRange类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap