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


Java DefaultOutboundPacket类代码示例

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


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

示例1: handlePacketIn

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

示例2: forwardPacketToDst

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

示例3: sendRequestPacketToExt

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
private void sendRequestPacketToExt(IPv4 icmpRequestIpv4, ICMP icmpRequest, DeviceId deviceId,
                                    Ip4Address pNatIpAddress) {
    icmpRequest.resetChecksum();
    icmpRequestIpv4.setSourceAddress(pNatIpAddress.toInt())
            .resetChecksum();
    icmpRequestIpv4.setPayload(icmpRequest);

    Ethernet icmpRequestEth = new Ethernet();

    icmpRequestEth.setEtherType(Ethernet.TYPE_IPV4)
            .setSourceMACAddress(MacAddress.valueOf(config.gatewayExternalInterfaceMac()))
            .setDestinationMACAddress(MacAddress.valueOf(config.physicalRouterMac()))
            .setPayload(icmpRequestIpv4);

    TrafficTreatment treatment = DefaultTrafficTreatment.builder()
            .setOutput(getPortForAnnotationPortName(DeviceId.deviceId(config.gatewayBridgeId()),
                    config.gatewayExternalInterfaceName()))
            .build();

    OutboundPacket packet = new DefaultOutboundPacket(deviceId,
            treatment, ByteBuffer.wrap(icmpRequestEth.serialize()));

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

示例4: sendResponsePacketToHost

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
private void sendResponsePacketToHost(Ethernet icmpResponseEth, OpenstackPortInfo openstackPortInfo) {
    Map.Entry<String, OpenstackPortInfo> entry = openstackSwitchingService.openstackPortInfo().entrySet().stream()
            .filter(e -> e.getValue().mac().equals(openstackPortInfo.mac()))
            .findAny().orElse(null);

    if (entry == null) {
        return;
    }

    TrafficTreatment treatment = DefaultTrafficTreatment.builder()
            .setOutput(getPortForAnnotationPortName(openstackPortInfo.deviceId(), entry.getKey()))
            .build();

    OutboundPacket packet = new DefaultOutboundPacket(openstackPortInfo.deviceId(),
            treatment, ByteBuffer.wrap(icmpResponseEth.serialize()));

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

示例5: vlanFlood

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
/**
 * Flood the arp request at all edges on a specifc VLAN.
 *
 * @param request the arp request
 * @param dsts the destination interfaces
 * @param inPort the connect point the arp request was received on
 */
private void vlanFlood(Ethernet request, Set<Interface> dsts, ConnectPoint inPort) {
    TrafficTreatment.Builder builder = null;
    ByteBuffer buf = ByteBuffer.wrap(request.serialize());

    for (Interface intf : dsts) {
        ConnectPoint cPoint = intf.connectPoint();
        if (cPoint.equals(inPort)) {
            continue;
        }

        builder = DefaultTrafficTreatment.builder();
        builder.setOutput(cPoint.port());
        packetService.emit(new DefaultOutboundPacket(cPoint.deviceId(),
                builder.build(), buf));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:ProxyArpManager.java

示例6: flood

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
/**
 * Flood the arp request at all edges in the network.
 *
 * @param request the arp request
 * @param inPort  the connect point the arp request was received on
 */
private void flood(Ethernet request, ConnectPoint inPort) {
    TrafficTreatment.Builder builder = null;
    ByteBuffer buf = ByteBuffer.wrap(request.serialize());

    for (ConnectPoint connectPoint : edgeService.getEdgePoints()) {
        if (hasIpAddress(connectPoint)
         || hasVlan(connectPoint)
         || connectPoint.equals(inPort)) {
            continue;
        }

        builder = DefaultTrafficTreatment.builder();
        builder.setOutput(connectPoint.port());
        packetService.emit(new DefaultOutboundPacket(connectPoint.deviceId(),
                                                     builder.build(), buf));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:ProxyArpManager.java

示例7: sendProbe

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
private void sendProbe(ConnectPoint connectPoint,
                       IpAddress targetIp,
                       IpAddress sourceIp, MacAddress sourceMac,
                       VlanId vlan) {
    Ethernet probePacket = null;

    if (targetIp.isIp4()) {
        // IPv4: Use ARP
        probePacket = buildArpRequest(targetIp, sourceIp, sourceMac, vlan);
    } else {
        // IPv6: Use Neighbor Discovery
        probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac, vlan);
    }

    TrafficTreatment treatment = DefaultTrafficTreatment.builder()
        .setOutput(connectPoint.port())
        .build();

    OutboundPacket outboundPacket =
        new DefaultOutboundPacket(connectPoint.deviceId(), treatment,
                                  ByteBuffer.wrap(probePacket.serialize()));

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

示例8: sendReply

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

示例9: sendGratuitousArp

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
/**
 * Emits gratuitous ARP when a gateway mac address has been changed.
 *
 * @param gatewayIp gateway ip address to update MAC
 * @param instances set of instances to send gratuitous ARP packet
 */
private void sendGratuitousArp(IpAddress gatewayIp, Set<Instance> instances) {
    MacAddress gatewayMac = gateways.get(gatewayIp);
    if (gatewayMac == null) {
        log.debug("Gateway {} is not registered to ARP proxy", gatewayIp);
        return;
    }

    Ethernet ethArp = buildGratuitousArp(gatewayIp.getIp4Address(), gatewayMac);
    instances.forEach(instance -> {
        TrafficTreatment treatment = DefaultTrafficTreatment.builder()
                .setOutput(instance.portNumber())
                .build();

        packetService.emit(new DefaultOutboundPacket(
                instance.deviceId(),
                treatment,
                ByteBuffer.wrap(ethArp.serialize())));
    });
}
 
开发者ID:opencord,项目名称:vtn,代码行数:26,代码来源:CordVtnArpProxy.java

示例10: forwardPackets

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
/**
 * Forwards IP packets in the buffer to the destination IP address.
 * It is called when the controller finds the destination MAC address
 * via ARP responsees.
 *
 * @param deviceId switch device ID
 * @param destIpAddress destination IP address
 */
public void forwardPackets(DeviceId deviceId, Ip4Address destIpAddress) {
    for (IPv4 ipPacket : ipPacketQueue.get(destIpAddress)) {
        Ip4Address destAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress());
        if (ipPacket != null && config.inSameSubnet(deviceId, destAddress)) {
            ipPacket.setTtl((byte) (ipPacket.getTtl() - 1));
            ipPacket.setChecksum((short) 0);
            for (Host dest: srManager.hostService.getHostsByIp(destIpAddress)) {
                Ethernet eth = new Ethernet();
                eth.setDestinationMACAddress(dest.mac());
                eth.setSourceMACAddress(config.getRouterMacAddress(
                        deviceId));
                eth.setEtherType(Ethernet.TYPE_IPV4);
                eth.setPayload(ipPacket);

                TrafficTreatment treatment = DefaultTrafficTreatment.builder().
                        setOutput(dest.location().port()).build();
                OutboundPacket packet = new DefaultOutboundPacket(deviceId,
                        treatment, ByteBuffer.wrap(eth.serialize()));
                srManager.packetService.emit(packet);
            }
        }
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:32,代码来源:IpHandler.java

示例11: forward

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
@Override
public void forward(Ethernet eth, ConnectPoint inPort) {
    checkNotNull(eth, REQUEST_NULL);

    Host h = hostService.getHost(HostId.hostId(eth.getDestinationMAC(),
            VlanId.vlanId(eth.getVlanID())));

    if (h == null) {
        flood(eth, inPort);
    } else {
        TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
        builder.setOutput(h.location().port());
        packetService.emit(new DefaultOutboundPacket(h.location().deviceId(),
                builder.build(), ByteBuffer.wrap(eth.serialize())));
    }

}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:18,代码来源:ProxyArpManager.java

示例12: flood

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
/**
 * Flood the arp request at all edges in the network.
 *
 * @param request the arp request
 * @param inPort the connect point the arp request was received on
 */
private void flood(Ethernet request, ConnectPoint inPort) {
    TrafficTreatment.Builder builder = null;
    ByteBuffer buf = ByteBuffer.wrap(request.serialize());

    synchronized (externalPorts) {
        for (Entry<Device, PortNumber> entry : externalPorts.entries()) {
            ConnectPoint cp = new ConnectPoint(entry.getKey().id(), entry.getValue());
            if (isOutsidePort(cp) || cp.equals(inPort)) {
                continue;
            }

            builder = DefaultTrafficTreatment.builder();
            builder.setOutput(entry.getValue());
            packetService.emit(new DefaultOutboundPacket(entry.getKey().id(),
                    builder.build(), buf));
        }
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:25,代码来源:ProxyArpManager.java

示例13: send

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

    if (this.block()) {
        log.info("Unable to send, packet context is blocked");
        return;
    }

    DeviceId deviceId = outPacket().sendThrough();
    ByteBuffer rawData = outPacket().data();

    TrafficTreatment treatment;
    if (outPacket().treatment() == null) {
        treatment = (treatmentBuilder() == null) ? emptyTreatment() : treatmentBuilder().build();
    } else {
        treatment = outPacket().treatment();
    }

    OutboundPacket outboundPacket = new DefaultOutboundPacket(deviceId, treatment, rawData);
    log.debug("Processing outbound packet: {}", outboundPacket);

    emit(outboundPacket);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:P4RuntimePacketProvider.java

示例14: sendProbe

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
private void sendProbe(Host host, IpAddress targetIp) {
    Ethernet probePacket = null;
    if (targetIp.isIp4()) {
        // IPv4: Use ARP
        probePacket = buildArpRequest(targetIp, host);
    } else {
        // IPv6: Use Neighbor Discovery
        //TODO need to implement ndp probe
        log.info("Triggering probe on device {} ", host);
        return;
    }

    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(host.location().port()).build();

    OutboundPacket outboundPacket = new DefaultOutboundPacket(host.location().deviceId(), treatment,
            ByteBuffer.wrap(probePacket.serialize()));

    packetService.emit(outboundPacket);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:HostLocationProvider.java

示例15: handleDhcpDiscoverAndRequest

import org.onosproject.net.packet.DefaultOutboundPacket; //导入依赖的package包/类
/**
 * forward the packet to ConnectPoint where the DHCP server is attached.
 *
 * @param packet the packet
 */
private void handleDhcpDiscoverAndRequest(Ethernet packet, DHCP dhcpPayload) {
    boolean direct = directlyConnected(dhcpPayload);
    DhcpServerInfo serverInfo = defaultServerInfoList.get(0);
    if (!direct && !indirectServerInfoList.isEmpty()) {
        serverInfo = indirectServerInfoList.get(0);
    }
    ConnectPoint portToFotward = serverInfo.getDhcpServerConnectPoint().orElse(null);
    // send packet to dhcp server connect point.
    if (portToFotward != null) {
        TrafficTreatment t = DefaultTrafficTreatment.builder()
                .setOutput(portToFotward.port()).build();
        OutboundPacket o = new DefaultOutboundPacket(
                portToFotward.deviceId(), t, ByteBuffer.wrap(packet.serialize()));
        if (log.isTraceEnabled()) {
            log.trace("Relaying packet to dhcp server {}", packet);
        }
        packetService.emit(o);
    } else {
        log.warn("Can't find DHCP server connect point, abort.");
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:27,代码来源:Dhcp4HandlerImpl.java


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