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


Java VlanId类代码示例

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


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

示例1: parseHost

import org.onlab.packet.VlanId; //导入依赖的package包/类
/**
 * Creates and adds new host based on given data and returns its host ID.
 *
 * @param node JsonNode containing host information
 * @return host ID of new host created
 */
private HostId parseHost(JsonNode node) {
    MacAddress mac = MacAddress.valueOf(node.get("mac").asText());
    VlanId vlanId = VlanId.vlanId((short) node.get("vlan").asInt(VlanId.UNTAGGED));
    JsonNode locationNode = node.get("location");
    String deviceAndPort = locationNode.get("elementId").asText() + "/" +
            locationNode.get("port").asText();
    HostLocation hostLocation = new HostLocation(ConnectPoint.deviceConnectPoint(deviceAndPort), 0);

    Iterator<JsonNode> ipStrings = node.get("ipAddresses").elements();
    Set<IpAddress> ips = new HashSet<>();
    while (ipStrings.hasNext()) {
        ips.add(IpAddress.valueOf(ipStrings.next().asText()));
    }

    // try to remove elements from json node after reading them
    SparseAnnotations annotations = annotations(removeElements(node, REMOVAL_KEYS));
    // Update host inventory

    HostId hostId = HostId.hostId(mac, vlanId);
    DefaultHostDescription desc = new DefaultHostDescription(mac, vlanId, hostLocation, ips, annotations);
    hostProviderService.hostDetected(hostId, desc, false);
    return hostId;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:HostsWebResource.java

示例2: createHost

import org.onlab.packet.VlanId; //导入依赖的package包/类
/**
 * Creates a default host connected at the given edge device and port. Note
 * that an identifying hex character ("a" - "f") should be supplied. This
 * will be included in the MAC address of the host (and equivalent value
 * as last byte in IP address).
 *
 * @param device  edge device
 * @param port    port number
 * @param hexChar identifying hex character
 * @return host connected at that location
 */
protected static Host createHost(Device device, int port, String hexChar) {
    DeviceId deviceId = device.id();
    String devNum = deviceId.toString().substring(1);

    MacAddress mac = MacAddress.valueOf(HOST_MAC_PREFIX + devNum + hexChar);
    HostId hostId = hostId(String.format("%s/-1", mac));

    int ipByte = Integer.valueOf(hexChar, 16);
    if (ipByte < 10 || ipByte > 15) {
        throw new IllegalArgumentException("hexChar must be a-f");
    }
    HostLocation loc = new HostLocation(deviceId, portNumber(port), 0);

    IpAddress ip = ip("10." + devNum + ".0." + ipByte);

    return new DefaultHost(ProviderId.NONE, hostId, mac, VlanId.NONE,
            loc, ImmutableSet.of(ip));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:AbstractTopoModelTest.java

示例3: processEthDstFilter

import org.onlab.packet.VlanId; //导入依赖的package包/类
@Override
//Dell switches need ETH_DST based match condition in all IP table entries.
//So while processing the ETH_DST based filtering objective, store
//the device MAC to be used locally to use it while pushing the IP rules.
protected List<FlowRule> processEthDstFilter(EthCriterion ethCriterion,
                                             VlanIdCriterion vlanIdCriterion,
                                             FilteringObjective filt,
                                             VlanId assignedVlan,
                                             ApplicationId applicationId) {
    // Store device termination Mac to be used in IP flow entries
    deviceTMac = ethCriterion.mac();

    log.debug("For now not adding any TMAC rules "
            + "into Dell switches as it is ignoring");

    return Collections.emptyList();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:SpringOpenTTPDell.java

示例4: fwdObjBuilder

import org.onlab.packet.VlanId; //导入依赖的package包/类
/**
 * Creates a forwarding objective builder for multicast.
 *
 * @param mcastIp multicast group
 * @param assignedVlan assigned VLAN ID
 * @param nextId next ID of the L3 multicast group
 * @return forwarding objective builder
 */
private ForwardingObjective.Builder fwdObjBuilder(IpAddress mcastIp,
        VlanId assignedVlan, int nextId) {
    TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
    IpPrefix mcastPrefix = IpPrefix.valueOf(mcastIp, IpPrefix.MAX_INET_MASK_LENGTH);
    sbuilder.matchEthType(Ethernet.TYPE_IPV4);
    sbuilder.matchIPDst(mcastPrefix);
    TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
    metabuilder.matchVlanId(assignedVlan);

    ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective.builder();
    fwdBuilder.withSelector(sbuilder.build())
            .withMeta(metabuilder.build())
            .nextStep(nextId)
            .withFlag(ForwardingObjective.Flag.SPECIFIC)
            .fromApp(srManager.appId)
            .withPriority(SegmentRoutingService.DEFAULT_PRIORITY);
    return fwdBuilder;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:McastHandler.java

示例5: processBroadcastNextObjective

import org.onlab.packet.VlanId; //导入依赖的package包/类
/**
 * As per the OFDPA 2.0 TTP, packets are sent out of ports by using
 * a chain of groups. The broadcast Next Objective passed in by the application
 * has to be broken up into a group chain comprising of an
 * L2 Flood group whose buckets point to L2 Interface groups.
 *
 * @param nextObj  the nextObjective of type BROADCAST
 */
private void processBroadcastNextObjective(NextObjective nextObj) {
    VlanId assignedVlan = Ofdpa2Pipeline.readVlanFromSelector(nextObj.meta());
    if (assignedVlan == null) {
        log.warn("VLAN ID required by broadcast next obj is missing. Abort.");
        Ofdpa2Pipeline.fail(nextObj, ObjectiveError.BADPARAMS);
        return;
    }

    List<GroupInfo> groupInfos = prepareL2InterfaceGroup(nextObj, assignedVlan);

    IpPrefix ipDst = Ofdpa2Pipeline.readIpDstFromSelector(nextObj.meta());
    if (ipDst != null) {
        if (ipDst.isMulticast()) {
            createL3MulticastGroup(nextObj, assignedVlan, groupInfos);
        } else {
            log.warn("Broadcast NextObj with non-multicast IP address {}", nextObj);
            Ofdpa2Pipeline.fail(nextObj, ObjectiveError.BADPARAMS);
            return;
        }
    } else {
        createL2FloodGroup(nextObj, assignedVlan, groupInfos);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:Ofdpa2GroupHandler.java

示例6: mapAction

import org.onlab.packet.VlanId; //导入依赖的package包/类
@Override
public ExtensionTreatment mapAction(OFAction action) throws UnsupportedOperationException {
    if (action.getType().equals(OFActionType.SET_FIELD)) {
        OFActionSetField setFieldAction = (OFActionSetField) action;
        OFOxm<?> oxm = setFieldAction.getField();
        switch (oxm.getMatchField().id) {
            case VLAN_VID:
                OFOxmVlanVid vlanVid = (OFOxmVlanVid) oxm;
                return new OfdpaSetVlanVid(VlanId.vlanId(vlanVid.getValue().getRawVid()));
            default:
                throw new UnsupportedOperationException(
                        "Driver does not support extension type " + oxm.getMatchField().id);
        }
    }
    throw new UnsupportedOperationException(
            "Unexpected OFAction: " + action.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OfdpaExtensionTreatmentInterpreter.java

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

示例8: processVlanMplsTable

import org.onlab.packet.VlanId; //导入依赖的package包/类
protected void processVlanMplsTable(boolean install) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment
            .builder();
    FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
    FlowRule rule;

    selector.matchVlanId(VlanId.ANY);
    treatment.transition(VLAN_TABLE);

    rule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(CONTROLLER_PRIORITY)
            .fromApp(appId)
            .makePermanent()
            .forTable(VLAN_MPLS_TABLE).build();

    processFlowRule(true, rule, "Provisioned vlan/mpls table");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:OvsCorsaPipeline.java

示例9: processTaggedPackets

import org.onlab.packet.VlanId; //导入依赖的package包/类
protected void processTaggedPackets(boolean install) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchVlanId(VlanId.ANY);

    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.transition(VLAN_MAC_XLATE_TABLE);

    FlowRule rule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(CONTROLLER_PRIORITY)
            .fromApp(appId)
            .makePermanent()
            .forTable(VLAN_CHECK_TABLE).build();
    processFlowRule(install, rule, "Provisioned vlan table tagged packets");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:CorsaPipelineV3.java

示例10: processUntaggedPackets

import org.onlab.packet.VlanId; //导入依赖的package包/类
private void processUntaggedPackets(boolean install) {

        deviceService.getPorts(deviceId).forEach(port -> {
            if (!port.number().isLogical()) {

                TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
                        .pushVlan().setVlanId(VlanId.vlanId(NATIVE_VLAN))
                        .transition(VLAN_MAC_XLATE_TABLE);

                TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
                        .matchVlanId(VlanId.NONE)
                        .matchInPort(port.number());

                Builder rule = DefaultFlowRule.builder()
                        .forDevice(deviceId)
                        .withTreatment(treatment.build())
                        .withSelector(selector.build())
                        .withPriority(CONTROLLER_PRIORITY)
                        .fromApp(appId)
                        .makePermanent()
                        .forTable(VLAN_CHECK_TABLE);

                processFlowRule(install, rule.build(), "Provisioned vlan untagged packet table");
            }
        });
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:CorsaPipelineV39.java

示例11: addTrunkInterface

import org.onlab.packet.VlanId; //导入依赖的package包/类
/**
 *  Adds a trunk interface for VLANs.
 *
 * @param deviceId the device ID
 * @param intf the name of the interface
 * @param vlanIds the VLAN IDs
 * @return the result of operation
 */
@Override
public boolean addTrunkInterface(DeviceId deviceId, String intf, List<VlanId> vlanIds) {
    NetconfController controller = checkNotNull(handler()
                                   .get(NetconfController.class));

    NetconfSession session = controller.getDevicesMap().get(handler()
                             .data().deviceId()).getSession();
    String reply;
    try {
        reply = session.requestSync(addTrunkInterfaceBuilder(intf, vlanIds));
    } catch (NetconfException e) {
        log.error("Failed to configure trunk mode for VLAN ID {} on device {} interface {}.",
                  vlanIds, deviceId, intf, e);
        return false;
    }

    return XmlConfigParser.configSuccess(XmlConfigParser.loadXml(
            new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8))));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:InterfaceConfigCiscoIosImpl.java

示例12: setUpInterfaceService

import org.onlab.packet.VlanId; //导入依赖的package包/类
/**
 * Setup Interface expectation for all Testcases.
 **/
private void setUpInterfaceService() {
    Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet();
    interfaceIpAddresses1
            .add(new InterfaceIpAddress(IpAddress.valueOf("192.168.10.101"), IpPrefix.valueOf("192.168.10.0/24")));
    Interface sw1Eth1 = new Interface(SW1_ETH1.deviceId().toString(), SW1_ETH1, interfaceIpAddresses1,
            MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE);
    interfaces.add(sw1Eth1);

    Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
    interfaceIpAddresses2
            .add(new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"), IpPrefix.valueOf("192.168.20.0/24")));
    Interface sw1Eth2 = new Interface(SW1_ETH1.deviceId().toString(), SW1_ETH2, interfaceIpAddresses2,
            MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE);
    interfaces.add(sw1Eth2);

    Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
    interfaceIpAddresses3
            .add(new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"), IpPrefix.valueOf("192.168.30.0/24")));
    Interface sw1Eth3 = new Interface(SW1_ETH1.deviceId().toString(), SW1_ETH3, interfaceIpAddresses3,
            MacAddress.valueOf("00:00:00:00:00:03"), VlanId.NONE);
    interfaces.add(sw1Eth3);

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

示例13: setupConnectivity

import org.onlab.packet.VlanId; //导入依赖的package包/类
protected void setupConnectivity() {
    /*
     * Parse Configuration and get Connect Point by VlanId.
     */
    SetMultimap<VlanId, ConnectPoint> confCPointsByVlan = getConfigCPoints();

    /*
     * Check that configured Connect Points have hosts attached and
     * associate their Mac Address to the Connect Points configured.
     */
    SetMultimap<VlanId, Pair<ConnectPoint, MacAddress>> confHostPresentCPoint =
            pairAvailableHosts(confCPointsByVlan);

    /*
     * Create and submit intents between the Connect Points.
     * Intents for broadcast between all the configured Connect Points.
     * Intents for unicast between all the configured Connect Points with
     * hosts attached.
     */
    intentInstaller.installIntents(confHostPresentCPoint);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:Vpls.java

示例14: removeGroupFromDevice

import org.onlab.packet.VlanId; //导入依赖的package包/类
/**
 * Removes entire group on given device.
 *
 * @param deviceId device ID
 * @param mcastIp multicast group to be removed
 * @param assignedVlan assigned VLAN ID
 */
private void removeGroupFromDevice(DeviceId deviceId, IpAddress mcastIp,
        VlanId assignedVlan) {
    McastStoreKey mcastStoreKey = new McastStoreKey(mcastIp, deviceId);
    // This device is not serving this multicast group
    if (!mcastNextObjStore.containsKey(mcastStoreKey)) {
        log.warn("{} is not serving {}. Abort.", deviceId, mcastIp);
        return;
    }
    NextObjective nextObj = mcastNextObjStore.get(mcastStoreKey).value();
    // NOTE: Rely on GroupStore garbage collection rather than explicitly
    //       remove L3MG since there might be other flows/groups refer to
    //       the same L2IG
    ObjectiveContext context = new DefaultObjectiveContext(
            (objective) -> log.debug("Successfully remove {} on {}, vlan {}",
                    mcastIp, deviceId, assignedVlan),
            (objective, error) ->
                    log.warn("Failed to remove {} on {}, vlan {}: {}",
                            mcastIp, deviceId, assignedVlan, error));
    ForwardingObjective fwdObj = fwdObjBuilder(mcastIp, assignedVlan, nextObj.id()).remove(context);
    srManager.flowObjectiveService.forward(deviceId, fwdObj);
    mcastNextObjStore.remove(mcastStoreKey);
    mcastRoleStore.remove(mcastStoreKey);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:McastHandler.java

示例15: createHosts

import org.onlab.packet.VlanId; //导入依赖的package包/类
/**
 * Creates simularted hosts for the specified device.
 *
 * @param deviceId   device identifier
 * @param portOffset port offset where to start attaching hosts
 */
protected void createHosts(DeviceId deviceId, int portOffset) {
    String s = deviceId.toString();
    byte dByte = Byte.parseByte(s.substring(s.length() - 1), 16);
    // TODO: this limits the simulation to 256 devices & 256 hosts/device.
    byte[] macBytes = new byte[]{0, 0, 0, 0, dByte, 0};
    byte[] ipBytes = new byte[]{(byte) 192, (byte) 168, dByte, 0};

    for (int i = 0; i < hostCount; i++) {
        int port = portOffset + i + 1;
        macBytes[5] = (byte) (i + 1);
        ipBytes[3] = (byte) (i + 1);
        HostId id = hostId(MacAddress.valueOf(macBytes), VlanId.NONE);
        IpAddress ip = IpAddress.valueOf(IpAddress.Version.INET, ipBytes);
        hostProviderService.hostDetected(id, description(id, ip, deviceId, port), false);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:TopologySimulator.java


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