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


Java VlanId.equals方法代码示例

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


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

示例1: mapSelector

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) {
        VlanId vlanId = ((OfdpaMatchVlanVid) extensionSelector).vlanId();
        // Special VLAN 0x0000/0x1FFF required by OFDPA
        if (vlanId.equals(VlanId.NONE)) {
            OFVlanVidMatch vid = OFVlanVidMatch.ofRawVid((short) 0x0000);
            OFVlanVidMatch mask = OFVlanVidMatch.ofRawVid((short) 0x1FFF);
            return factory.oxms().vlanVidMasked(vid, mask);
        // Normal case
        } else if (vlanId.equals(VlanId.ANY)) {
            return factory.oxms().vlanVidMasked(OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT);
        } else {
            return factory.oxms().vlanVid(OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vlanId.toShort())));
        }
    }
    throw new UnsupportedOperationException(
            "Unexpected ExtensionSelector: " + extensionSelector.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:OfdpaExtensionSelectorInterpreter.java

示例2: createPeerGroup

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private int createPeerGroup(MacAddress srcMac, MacAddress dstMac,
        VlanId vlanId, DeviceId deviceId, PortNumber port) {
    int nextId = flowObjectiveService.allocateNextId();
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
            .withId(nextId)
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(appId);

    TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
    ttBuilder.setEthSrc(srcMac);
    ttBuilder.setEthDst(dstMac);
    ttBuilder.setOutput(port);
    nextObjBuilder.addTreatment(ttBuilder.build());

    TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
    VlanId matchVlanId = (vlanId.equals(VlanId.NONE)) ?
            VlanId.vlanId(SingleSwitchFibInstaller.ASSIGNED_VLAN) :
            vlanId;
    metabuilder.matchVlanId(matchVlanId);
    nextObjBuilder.withMeta(metabuilder.build());

    flowObjectiveService.next(deviceId, nextObjBuilder.add());
    return nextId;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:ControlPlaneRedirectManager.java

示例3: createNextObjective

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
 * Creates a next objective with the given parameters.
 *
 * @param srcMac source MAC address
 * @param dstMac destination MAC address
 * @param port port number
 * @param vlan vlan ID
 * @param add whether to create an add objective or remove objective
 * @return new next objective
 */
private NextObjective createNextObjective(MacAddress srcMac,
                                          MacAddress dstMac,
                                          PortNumber port,
                                          VlanId vlan,
                                          boolean add) {
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
            .setEthSrc(srcMac)
            .setEthDst(dstMac);
    TrafficSelector.Builder metabuilder = null;
    if (!vlan.equals(VlanId.NONE)) {
        treatment.pushVlan()
                 .setVlanId(vlan)
                 .setVlanPcp((byte) 0);
    } else {
        metabuilder = DefaultTrafficSelector.builder();
        metabuilder.matchVlanId(VlanId.vlanId(SingleSwitchFibInstaller.ASSIGNED_VLAN));
    }

    treatment.setOutput(port);
    NextObjective.Builder nextBuilder = DefaultNextObjective.builder()
            .withId(NEXT_ID)
            .addTreatment(treatment.build())
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(APPID);
    if (metabuilder != null) {
        nextBuilder.withMeta(metabuilder.build());
    }

    return add ? nextBuilder.add() : nextBuilder.remove();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:SingleSwitchFibInstallerTest.java

示例4: handleArpReply

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private void handleArpReply(DeviceId deviceId, ConnectPoint inPort, Ethernet payload) {
    ARP arpReply = (ARP) payload.getPayload();
    VlanId vlanId = VlanId.vlanId(payload.getVlanID());
    HostId targetHostId = HostId.hostId(MacAddress.valueOf(
                                        arpReply.getTargetHardwareAddress()),
                                        vlanId);

    // ARP reply for router. Process all pending IP packets.
    if (isArpForRouter(deviceId, arpReply)) {
        Ip4Address hostIpAddress = Ip4Address.valueOf(arpReply.getSenderProtocolAddress());
        srManager.ipHandler.forwardPackets(deviceId, hostIpAddress);
    } else {
        Host targetHost = srManager.hostService.getHost(targetHostId);
        // ARP reply for known hosts. Forward to the host.
        if (targetHost != null) {
            removeVlanAndForward(payload, targetHost.location());
        // ARP reply for unknown host, Flood in the subnet.
        } else {
            // Don't flood to non-edge ports
            if (vlanId.equals(
                    VlanId.vlanId(SegmentRoutingManager.ASSIGNED_VLAN_NO_SUBNET))) {
                return;
            }
            removeVlanAndFlood(payload, inPort);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:ArpHandler.java

示例5: buildSelector

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
 * Builds a traffic selector based on the set of input parameters.
 *
 * @param ipProto IP protocol
 * @param srcIp source IP address
 * @param dstIp destination IP address
 * @param srcTcpPort source TCP port, or null if shouldn't be set
 * @param dstTcpPort destination TCP port, or null if shouldn't be set
 * @return the new traffic selector
 */
private TrafficSelector buildSelector(byte ipProto, VlanId ingressVlanId,
                                      IpAddress srcIp,
                                      IpAddress dstIp, Short srcTcpPort,
                                      Short dstTcpPort) {
    TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchIPProtocol(ipProto);

    // Match on any VLAN Id if a VLAN Id configured on the ingress interface
    if (!ingressVlanId.equals(VlanId.NONE)) {
        builder.matchVlanId(VlanId.ANY);
    }

    if (dstIp.isIp4()) {
        builder.matchEthType(Ethernet.TYPE_IPV4)
                .matchIPSrc(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET_MASK_LENGTH))
                .matchIPDst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET_MASK_LENGTH));
    } else {
        builder.matchEthType(Ethernet.TYPE_IPV6)
                .matchIPv6Src(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET6_MASK_LENGTH))
                .matchIPv6Dst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET6_MASK_LENGTH));
    }

    if (srcTcpPort != null) {
        builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
    }

    if (dstTcpPort != null) {
        builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
    }

    return builder.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:42,代码来源:PeerConnectivityManager.java

示例6: icmpPathintentConstructor

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
 * Constructs a BGP intent and put it into the intentList.
 * <p/>
 * The purpose of this method is too simplify the setUpBgpIntents() method,
 * and to make the setUpBgpIntents() easy to read.
 *
 * @param srcVlanId ingress VlanId
 * @param dstVlanId egress VlanId
 * @param srcPrefix source IP prefix to match
 * @param dstPrefix destination IP prefix to match
 * @param srcConnectPoint source connect point for PointToPointIntent
 * @param dstConnectPoint destination connect point for PointToPointIntent
 */
private void icmpPathintentConstructor(VlanId srcVlanId, VlanId dstVlanId,
                                       String srcPrefix, String dstPrefix,
                                       ConnectPoint srcConnectPoint,
                                       ConnectPoint dstConnectPoint) {

    TrafficSelector.Builder builder = DefaultTrafficSelector.builder()
            .matchEthType(Ethernet.TYPE_IPV4)
            .matchIPProtocol(IPv4.PROTOCOL_ICMP)
            .matchIPSrc(IpPrefix.valueOf(srcPrefix))
            .matchIPDst(IpPrefix.valueOf(dstPrefix));

    if (!srcVlanId.equals(VlanId.NONE)) {
        builder.matchVlanId(VlanId.ANY);
    }

    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();

    if (!dstVlanId.equals(VlanId.NONE)) {
        treatment.setVlanId(dstVlanId);
    }

    Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0]
            + "-" + "icmp", APPID);

    PointToPointIntent intent = PointToPointIntent.builder()
            .appId(APPID)
            .key(key)
            .selector(builder.build())
            .treatment(treatment.build())
            .ingressPoint(srcConnectPoint)
            .egressPoint(dstConnectPoint)
            .build();

    intentList.add(intent);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:49,代码来源:PeerConnectivityManagerTest.java

示例7: buildArpRequest

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private Ethernet buildArpRequest(IpAddress targetIp, IpAddress sourceIp,
                                 MacAddress sourceMac, VlanId vlan) {

    ARP arp = new ARP();
    arp.setHardwareType(ARP.HW_TYPE_ETHERNET)
       .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
       .setProtocolType(ARP.PROTO_TYPE_IP)
       .setProtocolAddressLength((byte) IpAddress.INET_BYTE_LENGTH)
       .setOpCode(ARP.OP_REQUEST);

    arp.setSenderHardwareAddress(sourceMac.toBytes())
       .setSenderProtocolAddress(sourceIp.toOctets())
       .setTargetHardwareAddress(ZERO_MAC_ADDRESS)
       .setTargetProtocolAddress(targetIp.toOctets());

    Ethernet ethernet = new Ethernet();
    ethernet.setEtherType(Ethernet.TYPE_ARP)
            .setDestinationMACAddress(MacAddress.BROADCAST)
            .setSourceMACAddress(sourceMac)
            .setPayload(arp);

    if (!vlan.equals(VlanId.NONE)) {
        ethernet.setVlanID(vlan.toShort());
    }

    ethernet.setPad(true);

    return ethernet;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:HostMonitor.java

示例8: buildNdpRequest

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private Ethernet buildNdpRequest(IpAddress targetIp, IpAddress sourceIp,
                                 MacAddress sourceMac, VlanId vlan) {

    // Create the Ethernet packet
    Ethernet ethernet = new Ethernet();
    ethernet.setEtherType(Ethernet.TYPE_IPV6)
            .setDestinationMACAddress(MacAddress.BROADCAST)
            .setSourceMACAddress(sourceMac);
    if (!vlan.equals(VlanId.NONE)) {
        ethernet.setVlanID(vlan.toShort());
    }

    //
    // Create the IPv6 packet
    //
    // TODO: The destination IP address should be the
    // solicited-node multicast address
    IPv6 ipv6 = new IPv6();
    ipv6.setSourceAddress(sourceIp.toOctets());
    ipv6.setDestinationAddress(targetIp.toOctets());
    ipv6.setHopLimit((byte) 255);

    // Create the ICMPv6 packet
    ICMP6 icmp6 = new ICMP6();
    icmp6.setIcmpType(ICMP6.NEIGHBOR_SOLICITATION);
    icmp6.setIcmpCode((byte) 0);

    // Create the Neighbor Solicitation packet
    NeighborSolicitation ns = new NeighborSolicitation();
    ns.setTargetAddress(targetIp.toOctets());
    ns.addOption(NeighborDiscoveryOptions.TYPE_SOURCE_LL_ADDRESS,
                 sourceMac.toBytes());

    icmp6.setPayload(ns);
    ipv6.setPayload(icmp6);
    ethernet.setPayload(ipv6);

    return ethernet;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:40,代码来源:HostMonitor.java

示例9: hostFwdObjBuilder

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
 * Generates the forwarding objective builder for the host rules.
 *
 * @param deviceId Device that host attaches to
 * @param mac MAC address of the host
 * @param vlanId VLAN ID of the host
 * @param outport Port that host attaches to
 * @return Forwarding objective builder
 */
private ForwardingObjective.Builder hostFwdObjBuilder(
        DeviceId deviceId, MacAddress mac, VlanId vlanId,
        PortNumber outport) {
    // Get assigned VLAN for the subnets
    VlanId outvlan = null;
    Ip4Prefix subnet = srManager.deviceConfiguration.getPortSubnet(deviceId, outport);
    if (subnet == null) {
        outvlan = VlanId.vlanId(SegmentRoutingManager.ASSIGNED_VLAN_NO_SUBNET);
    } else {
        outvlan = srManager.getSubnetAssignedVlanId(deviceId, subnet);
    }

    // match rule
    TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
    sbuilder.matchEthDst(mac);
    /*
     * Note: for untagged packets, match on the assigned VLAN.
     *       for tagged packets, match on its incoming VLAN.
     */
    if (vlanId.equals(VlanId.NONE)) {
        sbuilder.matchVlanId(outvlan);
    } else {
        sbuilder.matchVlanId(vlanId);
    }

    TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder();
    tbuilder.immediate().popVlan();
    tbuilder.immediate().setOutput(outport);

    // for switch pipelines that need it, provide outgoing vlan as metadata
    TrafficSelector meta = DefaultTrafficSelector.builder()
            .matchVlanId(outvlan).build();

    // All forwarding is via Groups. Drivers can re-purpose to flow-actions if needed.
    int portNextObjId = srManager.getPortNextObjectiveId(deviceId, outport,
            tbuilder.build(),
            meta);
    if (portNextObjId == -1) {
        // warning log will come from getPortNextObjective method
        return null;
    }

    return DefaultForwardingObjective.builder()
            .withFlag(ForwardingObjective.Flag.SPECIFIC)
            .withSelector(sbuilder.build())
            .nextStep(portNextObjId)
            .withPriority(100)
            .fromApp(srManager.appId)
            .makePermanent();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:60,代码来源:HostHandler.java

示例10: bgpPathintentConstructor

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
 * Constructs a BGP intent and put it into the intentList.
 * <p/>
 * The purpose of this method is too simplify the setUpBgpIntents() method,
 * and to make the setUpBgpIntents() easy to read.
 *
 * @param srcVlanId ingress VlanId
 * @param dstVlanId egress VlanId
 * @param srcPrefix source IP prefix to match
 * @param dstPrefix destination IP prefix to match
 * @param srcTcpPort source TCP port to match
 * @param dstTcpPort destination TCP port to match
 * @param srcConnectPoint source connect point for PointToPointIntent
 * @param dstConnectPoint destination connect point for PointToPointIntent
 */
private void bgpPathintentConstructor(VlanId srcVlanId, VlanId dstVlanId,
                                      String srcPrefix, String dstPrefix,
                                      Short srcTcpPort, Short dstTcpPort,
                                      ConnectPoint srcConnectPoint,
                                      ConnectPoint dstConnectPoint) {

    TrafficSelector.Builder builder = DefaultTrafficSelector.builder()
            .matchEthType(Ethernet.TYPE_IPV4)
            .matchIPProtocol(IPv4.PROTOCOL_TCP)
            .matchIPSrc(IpPrefix.valueOf(srcPrefix))
            .matchIPDst(IpPrefix.valueOf(dstPrefix));

    if (!srcVlanId.equals(VlanId.NONE)) {
        builder.matchVlanId(VlanId.ANY);
    }

    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();

    if (!dstVlanId.equals(VlanId.NONE)) {
        treatment.setVlanId(dstVlanId);
    }

    if (srcTcpPort != null) {
        builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
    }
    if (dstTcpPort != null) {
        builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
    }

    Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0]
            + "-" + ((srcTcpPort == null) ? "dst" : "src"), APPID);

    PointToPointIntent intent = PointToPointIntent.builder()
            .appId(APPID)
            .key(key)
            .selector(builder.build())
            .treatment(treatment.build())
            .ingressPoint(srcConnectPoint)
            .egressPoint(dstConnectPoint)
            .build();

    intentList.add(intent);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:59,代码来源:PeerConnectivityManagerTest.java


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