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


Java InboundPacket.receivedFrom方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: process

import org.onosproject.net.packet.InboundPacket; //导入方法依赖的package包/类
@Override
public void process(PacketContext context) {
    InboundPacket pkt = context.inPacket();
    ConnectPoint connectPoint = pkt.receivedFrom();
    DeviceId deviceId = connectPoint.deviceId();
    Ethernet ethPkt = pkt.parsed();
    if (ethPkt == null) {
        return;
    }
    if (ethPkt.getEtherType() == Ethernet.TYPE_ARP) {
        ARP arpPacket = (ARP) ethPkt.getPayload();
        if ((arpPacket.getOpCode() == ARP.OP_REQUEST)) {
            arprequestProcess(arpPacket, deviceId);
        } else if (arpPacket.getOpCode() == ARP.OP_REPLY) {
            arpresponceProcess(arpPacket, deviceId);
        }
    } else if (ethPkt.getEtherType() == Ethernet.TYPE_IPV4) {
        if (ethPkt.getDestinationMAC().isMulticast()) {
            return;
        }
        IPv4 ip = (IPv4) ethPkt.getPayload();
        upStreamPacketProcessor(ip, deviceId);

    } else {
        return;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:VtnManager.java

示例7: process

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

    InboundPacket pkt = context.inPacket();
    Ethernet ethPkt = pkt.parsed();
    if (ethPkt == null) {
        return;
    }

    // In theory, we do not need to check whether it is Ethernet
    // TYPE_IPV4. However, due to the current implementation of the
    // packetService, we will receive all packets from all subscribers.
    // Hence, we have to check the Ethernet type again here.
    if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) {
        return;
    }

    // Parse packet
    IPv4 ipv4Packet = (IPv4) ethPkt.getPayload();
    IpAddress dstIp =
            IpAddress.valueOf(ipv4Packet.getDestinationAddress());
    IpAddress srcIp =
            IpAddress.valueOf(ipv4Packet.getSourceAddress());
    ConnectPoint srcConnectPoint = pkt.receivedFrom();
    MacAddress srcMac = ethPkt.getSourceMAC();
    routingService.packetReactiveProcessor(dstIp, srcIp,
                                           srcConnectPoint, srcMac);

    // TODO emit packet first or packetReactiveProcessor first
    ConnectPoint egressConnectPoint = null;
    egressConnectPoint = routingService.getEgressConnectPoint(dstIp);
    if (egressConnectPoint != null) {
        forwardPacketToDst(context, egressConnectPoint);
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:36,代码来源:SdnIpReactiveRouting.java

示例8: processPacketIn

import org.onosproject.net.packet.InboundPacket; //导入方法依赖的package包/类
/**
 * Process incoming ICMP packet.
 * If it is an ICMP request to router or known host, then sends an ICMP response.
 * If it is an ICMP packet to known host and forward the packet to the host.
 * If it is an ICMP packet to unknown host in a subnet, then sends an ARP request
 * to the subnet.
 *
 * @param pkt
 */
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());
    Ip4Address gatewayIpAddress = config.getGatewayIpAddress(deviceId);
    IpPrefix routerIpPrefix = config.getRouterIpAddress(deviceId);
    Ip4Address routerIpAddress = routerIpPrefix.getIp4Prefix().address();

    // ICMP to the router IP or gateway IP
    if (((ICMP) ipv4.getPayload()).getIcmpType() == ICMP.TYPE_ECHO_REQUEST &&
            (destinationAddress.equals(routerIpAddress) ||
                    gatewayIpAddress.equals(destinationAddress))) {
        sendICMPResponse(ethernet, connectPoint);
        // TODO: do we need to set the flow rule again ??

    // ICMP for any known host
    } else if (!srManager.hostService.getHostsByIp(destinationAddress).isEmpty()) {
        srManager.ipHandler.forwardPackets(deviceId, destinationAddress);

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

    // ICMP for an unknown host
    } else {
        log.debug("ICMP request for unknown host {} ", destinationAddress);
        // Do nothing
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:44,代码来源:IcmpHandler.java

示例9: process

import org.onosproject.net.packet.InboundPacket; //导入方法依赖的package包/类
@Override
public void process(PacketContext context) {
    InboundPacket pkt = context.inPacket();
    Ethernet ethPkt = pkt.parsed();
    if (ethPkt == null) {
        return;
    }
    ConnectPoint srcCp = pkt.receivedFrom();
    IpAddress srcIp;
    IpAddress dstIp;
    byte ipProto = 0;  /* 0 or tcp, udp */

    switch (EthType.EtherType.lookup(ethPkt.getEtherType())) {
    case IPV4:
        IPv4 ipv4Packet = (IPv4) ethPkt.getPayload();
        srcIp = IpAddress.valueOf(ipv4Packet.getSourceAddress());
        dstIp = IpAddress.valueOf(ipv4Packet.getDestinationAddress());
        ipProto = ipv4Packet.getProtocol();
        break;
    case IPV6:
        IPv6 ipv6Packet = (IPv6) ethPkt.getPayload();
        srcIp = IpAddress.valueOf(IpAddress.Version.INET6, ipv6Packet.getSourceAddress());
        dstIp = IpAddress.valueOf(IpAddress.Version.INET6, ipv6Packet.getDestinationAddress());
        ipProto = ipv6Packet.getNextHeader();
        break;
    default:
        return;  // ignore unknow ether type packets
    }
    if (ipProto != 6 && ipProto != 17) {
        ipProto = 0;  /* handle special for TCP and UDP only */
    }

    if (!checkVirtualGatewayIpPacket(pkt, srcIp, dstIp)) {
        ipPacketReactiveProcessor(context, ethPkt, srcCp, srcIp, dstIp, ipProto);
        // TODO: add ReactiveRouting for dstIp to srcIp with discovered egressCp as srcCp
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:38,代码来源:SimpleFabricReactiveRouting.java

示例10: process

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

    InboundPacket pkt = context.inPacket();
    Ethernet ethPkt = pkt.parsed();
    if (ethPkt == null) {
        return;
    }
    ConnectPoint srcConnectPoint = pkt.receivedFrom();

    switch (EthType.EtherType.lookup(ethPkt.getEtherType())) {
    case ARP:
        ARP arpPacket = (ARP) ethPkt.getPayload();
        Ip4Address targetIpAddress = Ip4Address
                .valueOf(arpPacket.getTargetProtocolAddress());
        // Only when it is an ARP request packet and the target IP
        // address is a virtual gateway IP address, then it will be
        // processed.
        if (arpPacket.getOpCode() == ARP.OP_REQUEST
                && config.isVirtualGatewayIpAddress(targetIpAddress)) {
            MacAddress gatewayMacAddress =
                    config.getVirtualGatewayMacAddress();
            if (gatewayMacAddress == null) {
                break;
            }
            Ethernet eth = ARP.buildArpReply(targetIpAddress,
                                             gatewayMacAddress,
                                             ethPkt);

            TrafficTreatment.Builder builder =
                    DefaultTrafficTreatment.builder();
            builder.setOutput(srcConnectPoint.port());
            packetService.emit(new DefaultOutboundPacket(
                    srcConnectPoint.deviceId(),
                    builder.build(),
                    ByteBuffer.wrap(eth.serialize())));
        }
        break;
    case IPV4:
        // Parse packet
        IPv4 ipv4Packet = (IPv4) ethPkt.getPayload();
        IpAddress dstIp =
                IpAddress.valueOf(ipv4Packet.getDestinationAddress());
        IpAddress srcIp =
                IpAddress.valueOf(ipv4Packet.getSourceAddress());
        MacAddress srcMac = ethPkt.getSourceMAC();
        packetReactiveProcessor(dstIp, srcIp, srcConnectPoint, srcMac);

        // TODO emit packet first or packetReactiveProcessor first
        ConnectPoint egressConnectPoint = null;
        egressConnectPoint = getEgressConnectPoint(dstIp);
        if (egressConnectPoint != null) {
            forwardPacketToDst(context, egressConnectPoint);
        }
        break;
    default:
        break;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:60,代码来源:SdnIpReactiveRouting.java

示例11: processPacketIn

import org.onosproject.net.packet.InboundPacket; //导入方法依赖的package包/类
/**
 * Process incoming ICMP packet.
 * If it is an ICMP request to router or known host, then sends an ICMP response.
 * If it is an ICMP packet to known host and forward the packet to the host.
 * If it is an ICMP packet to unknown host in a subnet, then sends an ARP request
 * to the subnet.
 *
 * @param pkt inbound 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());
    Set<Ip4Address> gatewayIpAddresses = config.getPortIPs(deviceId);
    Ip4Address routerIp;
    try {
        routerIp = config.getRouterIp(deviceId);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting processPacketIn.");
        return;
    }
    IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH);
    Ip4Address routerIpAddress = routerIpPrefix.getIp4Prefix().address();

    // ICMP to the router IP or gateway IP
    if (((ICMP) ipv4.getPayload()).getIcmpType() == ICMP.TYPE_ECHO_REQUEST &&
            (destinationAddress.equals(routerIpAddress) ||
                    gatewayIpAddresses.contains(destinationAddress))) {
        sendICMPResponse(ethernet, connectPoint);

    // ICMP for any known host
    } else if (!srManager.hostService.getHostsByIp(destinationAddress).isEmpty()) {
        // TODO: known host packet should not be coming to controller - resend flows?
        srManager.ipHandler.forwardPackets(deviceId, destinationAddress);

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

    // ICMP for an unknown host
    } else {
        log.debug("ICMP request for unknown host {} ", destinationAddress);
        // Do nothing
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:51,代码来源:IcmpHandler.java

示例12: process

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

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

    // Only handle the ARP packets
    if (ethPkt == null || ethPkt.getEtherType() != Ethernet.TYPE_ARP) {
        return;
    }
    ARP arpPacket = (ARP) ethPkt.getPayload();
    // Only handle ARP request packets
    if (arpPacket.getOpCode() != ARP.OP_REQUEST) {
        return;
    }

    Ip4Address targetIpAddress = Ip4Address
            .valueOf(arpPacket.getTargetProtocolAddress());

    // Only handle an ARP request when the target IP address inside is
    // an assigned public IP address
    if (!vbngConfigService.isAssignedPublicIpAddress(targetIpAddress)) {
        return;
    }

    MacAddress virtualHostMac =
            vbngConfigService.getPublicFacingMac();
    if (virtualHostMac == null) {
        return;
    }

    ConnectPoint srcConnectPoint = pkt.receivedFrom();
    Ethernet eth = ARP.buildArpReply(targetIpAddress,
                                     virtualHostMac,
                                     ethPkt);

    TrafficTreatment.Builder builder =
            DefaultTrafficTreatment.builder();
    builder.setOutput(srcConnectPoint.port());
    packetService.emit(new DefaultOutboundPacket(
            srcConnectPoint.deviceId(),
            builder.build(),
            ByteBuffer.wrap(eth.serialize())));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:45,代码来源:VirtualPublicHosts.java

示例13: 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.
 * <p>
 * Note: We handles all ARP packet in, even for those ARP packets between
 * hosts in the same subnet.
 * For an ARP packet with broadcast destination MAC,
 * some switches pipelines will send it to the controller due to table miss,
 * other switches will flood the packets directly in the data plane without
 * packet in.
 * We can deal with both cases.
 *
 * @param pkt incoming packet
 */
public void processPacketIn(InboundPacket pkt) {

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

    ConnectPoint connectPoint = pkt.receivedFrom();
    DeviceId deviceId = connectPoint.deviceId();
    if (arp.getOpCode() == ARP.OP_REQUEST) {
        handleArpRequest(deviceId, connectPoint, ethernet);
    } else {
        handleArpReply(deviceId, connectPoint, ethernet);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:ArpHandler.java


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