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

Java InboundPacket类代码示例

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

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



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

示例1: inPacket

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
@Override
public InboundPacket inPacket() {
    ONOSLLDP lldp = ONOSLLDP.onosLLDP(deviceService.getDevice(DID1).id().toString(),
                                      device.chassisId(),
                                      (int) pd1.number().toLong());

    Ethernet ethPacket = new Ethernet();
    ethPacket.setEtherType(Ethernet.TYPE_LLDP);
    ethPacket.setDestinationMACAddress(ONOSLLDP.LLDP_NICIRA);
    ethPacket.setPayload(lldp);
    ethPacket.setPad(true);

    ethPacket.setSourceMACAddress("DE:AD:BE:EF:BA:11");

    ConnectPoint cp = new ConnectPoint(device.id(), pd3.number());

    return new DefaultInboundPacket(cp, ethPacket,
                                    ByteBuffer.wrap(ethPacket.serialize()));

}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:LldpLinkProviderTest.java


示例2: sendPacketIn

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
@Override
public void sendPacketIn(PccId pccId) {
    TCP tcp = new TCP();
    // Set the well known PCEP port. To be used to decide to process/discard the packet while processing.
    tcp.setDestinationPort(PCEP_PORT);

    IPv4 ipv4 = new IPv4();
    ipv4.setProtocol(IPv4.PROTOCOL_TCP);
    ipv4.setPayload(tcp);

    Ethernet eth = new Ethernet();
    eth.setEtherType(Ethernet.TYPE_IPV4);
    eth.setDestinationMACAddress(MacAddress.NONE);
    eth.setPayload(ipv4);

    // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
    String lsrId = String.valueOf(pccId.ipAddress());
    DeviceId pccDeviceId = DeviceId.deviceId(lsrId);

    InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId,
                                                                    PortNumber.portNumber(PCEP_PORT)),
                                                   eth, null);

    packetProviderService.processPacket(new PcepPacketContext(inPkt, null));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:PcepPacketProvider.java


示例3: inPacket

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
@Override
public InboundPacket inPacket() {
    ONOSLLDP lldp = ONOSLLDP.onosLLDP(src.deviceId().toString(),
                                      new ChassisId(),
                                      (int) src.port().toLong());

    Ethernet ethPacket = new Ethernet();
    ethPacket.setEtherType(Ethernet.TYPE_LLDP);
    ethPacket.setDestinationMACAddress(ONOSLLDP.LLDP_NICIRA);
    ethPacket.setPayload(lldp);
    ethPacket.setPad(true);

    ethPacket.setSourceMACAddress("DE:AD:BE:EF:BA:11");

    return new DefaultInboundPacket(dst, ethPacket,
                                    ByteBuffer.wrap(ethPacket.serialize()));

}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:NetworkConfigLinksProviderTest.java


示例4: convertPacketContextToInboundPacket

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
public InboundPacket convertPacketContextToInboundPacket(OpenFlowPacketContext pktCtx) {
        //convert OpenFlowPacketContext to PacketContext
        DeviceId id = DeviceId.deviceId(Dpid.uri(pktCtx.dpid().value()));

        DefaultInboundPacket inPkt = new DefaultInboundPacket(
                new ConnectPoint(id, PortNumber.portNumber(pktCtx.inPort())),
                pktCtx.parsed(), ByteBuffer.wrap(pktCtx.unparsed()));
/*
        DefaultOutboundPacket outPkt = null;
        if (!pktCtx.isBuffered()) {
            outPkt = new DefaultOutboundPacket(id, null,
                    ByteBuffer.wrap(pktCtx.unparsed()));
        }


        OpenFlowCorePacketContext context =
                new OpenFlowCorePacketContext(System.currTimeMillis(),
                        inPkt, outPkt, pktCtx.isHandled(), pktCtx);
*/
        return inPkt;
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:FeatureCollectorProvider.java


示例5: inPacket

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
@Override
public InboundPacket inPacket() {
    ARP arp = new ARP();
    arp.setSenderProtocolAddress(IP)
            .setSenderHardwareAddress(MAC.toBytes())
            .setTargetHardwareAddress(BCMAC.toBytes())
            .setTargetProtocolAddress(IP);

    Ethernet eth = new Ethernet();
    eth.setEtherType(Ethernet.TYPE_ARP)
            .setVlanID(VLAN.toShort())
            .setSourceMACAddress(MAC.toBytes())
            .setDestinationMACAddress(BCMAC)
            .setPayload(arp);
    ConnectPoint receivedFrom = new ConnectPoint(deviceId(deviceId),
                                                 portNumber(INPORT));
    return new DefaultInboundPacket(receivedFrom, eth,
                                    ByteBuffer.wrap(eth.serialize()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:HostLocationProviderTest.java


示例6: handlePacketIn

import org.onosproject.net.packet.InboundPacket; //导入依赖的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


示例7: processPacketIn

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
private void processPacketIn(InboundPacket pkt) {

        boolean ipMatches = false;
        Ethernet ethernet = pkt.parsed();
        IPv4 ipv4 = (IPv4) ethernet.getPayload();
        ConnectPoint connectPoint = pkt.receivedFrom();
        IpAddress destIpAddress = IpAddress.valueOf(ipv4.getDestinationAddress());
        Interface targetInterface = interfaceService.getMatchingInterface(destIpAddress);

        if (targetInterface == null) {
            log.trace("No matching interface for {}", destIpAddress);
            return;
        }

        for (InterfaceIpAddress interfaceIpAddress: targetInterface.ipAddresses()) {
            if (interfaceIpAddress.ipAddress().equals(destIpAddress)) {
                ipMatches = true;
                break;
            }
        }

        if (((ICMP) ipv4.getPayload()).getIcmpType() == ICMP.TYPE_ECHO_REQUEST &&
                ipMatches) {
            sendIcmpResponse(ethernet, connectPoint);
        }
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:IcmpHandler.java


示例8: run

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
@Override
public void run() {
    InboundPacket inboundPacket = context.inPacket();
    Ethernet ethernet = checkNotNull(inboundPacket.parsed());

    //TODO: Considers IPV6
    if (ethernet.getEtherType() != Ethernet.TYPE_IPV4) {
        log.warn("Now, we just consider IP version 4");
        return;
    }

    OpenstackRouter router = getOpenstackRouter(openstackPort);

    rulePopulator.populatePnatFlowRules(inboundPacket, openstackPort, portNum,
            getExternalIp(router), MacAddress.valueOf(config.gatewayExternalInterfaceMac()),
            MacAddress.valueOf(config.physicalRouterMac()));

    packetOut((Ethernet) ethernet.clone(), inboundPacket.receivedFrom().deviceId(), portNum, router);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:OpenstackPnatHandler.java


示例9: process

import org.onosproject.net.packet.InboundPacket; //导入依赖的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


示例10: processPacketIn

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
/**
 * Processes incoming IP packets.
 *
 * If it is an IP packet for known host, then forward it to the host.
 * If it is an IP packet for unknown host in subnet, then send an ARP request
 * to the subnet.
 *
 * @param pkt incoming packet
 */
public void processPacketIn(InboundPacket pkt) {
    Ethernet ethernet = pkt.parsed();
    IPv4 ipv4 = (IPv4) ethernet.getPayload();

    ConnectPoint connectPoint = pkt.receivedFrom();
    DeviceId deviceId = connectPoint.deviceId();
    Ip4Address destinationAddress =
            Ip4Address.valueOf(ipv4.getDestinationAddress());

    // IP packet for know hosts
    if (!srManager.hostService.getHostsByIp(destinationAddress).isEmpty()) {
        forwardPackets(deviceId, destinationAddress);

    // IP packet for unknown host in the subnet of the router
    } else if (config.inSameSubnet(deviceId, destinationAddress)) {
        srManager.arpHandler.sendArpRequest(deviceId, destinationAddress, connectPoint);

    // IP packets for unknown host
    } else {
        log.debug("ICMP request for unknown host {} which is not in the subnet",
                destinationAddress);
        // Do nothing
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:IpHandler.java


示例11: process

import org.onosproject.net.packet.InboundPacket; //导入依赖的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


示例12: processPacketIn

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
private void processPacketIn(InboundPacket pkt) {

        boolean ipMatches = false;
        Ethernet ethernet = pkt.parsed();
        IPv4 ipv4 = (IPv4) ethernet.getPayload();
        ConnectPoint connectPoint = pkt.receivedFrom();
        IpAddress destIpAddress = IpAddress.valueOf(ipv4.getDestinationAddress());
        Interface targetInterface = configService.getMatchingInterface(destIpAddress);

        if (targetInterface == null) {
            log.trace("No matching interface for {}", destIpAddress);
            return;
        }

        for (InterfaceIpAddress interfaceIpAddress: targetInterface.ipAddresses()) {
            if (interfaceIpAddress.ipAddress().equals(destIpAddress)) {
                ipMatches = true;
                break;
            }
        }

        if (((ICMP) ipv4.getPayload()).getIcmpType() == ICMP.TYPE_ECHO_REQUEST &&
                ipMatches) {
            sendICMPResponse(ethernet, connectPoint);
        }
    }
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:27,代码来源:IcmpHandler.java


示例13: process

import org.onosproject.net.packet.InboundPacket; //导入依赖的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


示例14: processPacketIn

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
/**
 * Processes incoming ARP packets.
 * If it is an ARP request to router itself or known hosts,
 * then it sends ARP response.
 * If it is an ARP request to unknown hosts in its own subnet,
 * then it flood the ARP request to the ports.
 * If it is an ARP response, then set a flow rule for the host
 * and forward any IP packets to the host in the packet buffer to the host.
 *
 * @param pkt incoming packet
 */
public void processPacketIn(InboundPacket pkt) {

    Ethernet ethernet = pkt.parsed();
    ARP arp = (ARP) ethernet.getPayload();

    ConnectPoint connectPoint = pkt.receivedFrom();
    PortNumber inPort = connectPoint.port();
    DeviceId deviceId = connectPoint.deviceId();
    byte[] senderMacAddressByte = arp.getSenderHardwareAddress();
    Ip4Address hostIpAddress = Ip4Address.valueOf(arp.getSenderProtocolAddress());

    srManager.routingRulePopulator.populateIpRuleForHost(deviceId, hostIpAddress, MacAddress.
            valueOf(senderMacAddressByte), inPort);

    if (arp.getOpCode() == ARP.OP_REQUEST) {
        handleArpRequest(deviceId, connectPoint, ethernet);
    } else {
        srManager.ipHandler.forwardPackets(deviceId, hostIpAddress);
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:32,代码来源:ArpHandler.java


示例15: process

import org.onosproject.net.packet.InboundPacket; //导入依赖的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


示例16: inPacket

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
@Override
public InboundPacket inPacket() {
    ONOSLLDP lldp = ONOSLLDP.onosLLDP(deviceService.getDevice(DID1).id().toString(),
                                      device.chassisId(),
                                      (int) pd1.number().toLong());

    Ethernet ethPacket = new Ethernet();
    ethPacket.setEtherType(Ethernet.TYPE_LLDP);
    ethPacket.setDestinationMACAddress(MacAddress.ONOS_LLDP);
    ethPacket.setPayload(lldp);
    ethPacket.setPad(true);

    ethPacket.setSourceMACAddress("DE:AD:BE:EF:BA:11");

    ConnectPoint cp = new ConnectPoint(device.id(), pd3.number());

    return new DefaultInboundPacket(cp, ethPacket,
                                    ByteBuffer.wrap(ethPacket.serialize()));

}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:21,代码来源:LldpLinkProviderTest.java


示例17: inPacket

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
@Override
public InboundPacket inPacket() {
    ONOSLLDP lldp = ONOSLLDP.onosLLDP(src.deviceId().toString(),
                                      new ChassisId(),
                                      (int) src.port().toLong());

    Ethernet ethPacket = new Ethernet();
    ethPacket.setEtherType(Ethernet.TYPE_LLDP);
    ethPacket.setDestinationMACAddress(MacAddress.ONOS_LLDP);
    ethPacket.setPayload(lldp);
    ethPacket.setPad(true);

    ethPacket.setSourceMACAddress("DE:AD:BE:EF:BA:11");

    return new DefaultInboundPacket(dst, ethPacket,
                                    ByteBuffer.wrap(ethPacket.serialize()));

}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:NetworkConfigLinksProviderTest.java


示例18: processPacketIn

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
private void processPacketIn(InboundPacket pkt) {

        boolean ipMatches = false;
        Ethernet ethernet = pkt.parsed();
        IPv4 ipv4 = (IPv4) ethernet.getPayload();
        ConnectPoint connectPoint = pkt.receivedFrom();
        IpAddress destIpAddress = IpAddress.valueOf(ipv4.getDestinationAddress());
        Interface targetInterface = interfaceService.getMatchingInterface(destIpAddress);

        if (targetInterface == null) {
            log.trace("No matching interface for {}", destIpAddress);
            return;
        }

        for (InterfaceIpAddress interfaceIpAddress: targetInterface.ipAddressesList()) {
            if (interfaceIpAddress.ipAddress().equals(destIpAddress)) {
                ipMatches = true;
                break;
            }
        }

        if (((ICMP) ipv4.getPayload()).getIcmpType() == ICMP.TYPE_ECHO_REQUEST &&
                ipMatches) {
            sendIcmpResponse(ethernet, connectPoint);
        }
    }
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:27,代码来源:IcmpHandler.java


示例19: process

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

    Set<DeviceId> gateways = osNodeService.completeNodes(GATEWAY)
            .stream().map(OpenstackNode::intgBridge)
            .collect(Collectors.toSet());

    if (!gateways.contains(context.inPacket().receivedFrom().deviceId())) {
        // return if the packet is not from gateway nodes
        return;
    }

    InboundPacket pkt = context.inPacket();
    Ethernet ethernet = pkt.parsed();
    if (ethernet != null &&
            ethernet.getEtherType() == Ethernet.TYPE_ARP) {
        eventExecutor.execute(() -> processArpPacket(context, ethernet));
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:OpenstackRoutingArpHandler.java


示例20: process

import org.onosproject.net.packet.InboundPacket; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
    Set<DeviceId> gateways = osNodeService.completeNodes(GATEWAY)
            .stream().map(OpenstackNode::intgBridge)
            .collect(Collectors.toSet());

    if (context.isHandled()) {
        return;
    } else if (!gateways.contains(context.inPacket().receivedFrom().deviceId())) {
        // return if the packet is not from gateway nodes
        return;
    }

    InboundPacket pkt = context.inPacket();
    Ethernet ethernet = pkt.parsed();
    if (ethernet == null || ethernet.getEtherType() == Ethernet.TYPE_ARP) {
        return;
    }

    IPv4 iPacket = (IPv4) ethernet.getPayload();
    if (iPacket.getProtocol() == IPv4.PROTOCOL_ICMP) {
        eventExecutor.execute(() -> processIcmpPacket(context, ethernet));
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:25,代码来源:OpenstackRoutingIcmpHandler.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java GMSSParameters类代码示例发布时间:2022-05-23
下一篇:
Java CloudOrganization类代码示例发布时间: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