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


Java VlanVid类代码示例

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


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

示例1: mapSelector

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的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: generateDeviceEvent

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
private void generateDeviceEvent(IDevice device, String reason) {
	List<IPv4Address> ipv4Addresses =
			new ArrayList<IPv4Address>(Arrays.asList(device.getIPv4Addresses()));
	List<IPv6Address> ipv6Addresses =
			new ArrayList<IPv6Address>(Arrays.asList(device.getIPv6Addresses()));
	List<SwitchPort> oldAps =
			new ArrayList<SwitchPort>(Arrays.asList(device.getOldAP()));
	List<SwitchPort> currentAps =
			new ArrayList<SwitchPort>(Arrays.asList(device.getAttachmentPoints()));
	List<VlanVid> vlanIds =
			new ArrayList<VlanVid>(Arrays.asList(device.getVlanId()));

	debugEventCategory.newEventNoFlush(new DeviceEvent(device.getMACAddress(),
			ipv4Addresses,
			ipv6Addresses,
			oldAps,
			currentAps,
			vlanIds, reason));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:DeviceManagerImpl.java

示例3: getSourceEntityFromPacket

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
/**
 * Parse an entity from an {@link Ethernet} packet.
 * @param eth the packet to parse
 * @param sw the switch on which the packet arrived
 * @param pi the original packetin
 * @return the entity from the packet
 */
protected Entity getSourceEntityFromPacket(Ethernet eth, DatapathId swdpid, OFPort port) {
	MacAddress dlAddr = eth.getSourceMACAddress();

	// Ignore broadcast/multicast source
	if (dlAddr.isBroadcast() || dlAddr.isMulticast())
		return null;
	// Ignore 0 source mac
	if (dlAddr.getLong() == 0)
		return null;

	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	IPv4Address ipv4Src = getSrcIPv4AddrFromARP(eth, dlAddr);
	IPv6Address ipv6Src = ipv4Src.equals(IPv4Address.NONE) ? getSrcIPv6Addr(eth) : IPv6Address.NONE;
	return new Entity(dlAddr,
			vlan,
			ipv4Src,
			ipv6Src,
			swdpid,
			port,
			new Date());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:DeviceManagerImpl.java

示例4: DeviceIterator

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
/**
 * Construct a new device iterator over the key fields
 * @param subIterator an iterator over the full data structure to scan
 * @param entityClasses the entity classes to search for
 * @param macAddress The MAC address
 * @param vlan the VLAN
 * @param ipv4Address the ipv4 address
 * @param ipv6Address the ipv6 address
 * @param switchDPID the switch DPID
 * @param switchPort the switch port
 */
public DeviceIterator(Iterator<Device> subIterator, 
                      IEntityClass[] entityClasses,
                      MacAddress macAddress,
                      VlanVid vlan, 
                      IPv4Address ipv4Address, 
                      IPv6Address ipv6Address,
                      DatapathId switchDPID,
                      OFPort switchPort) {
    super(subIterator);
    this.entityClasses = entityClasses;
    this.subIterator = subIterator;
    this.macAddress = macAddress;
    this.vlan = vlan;
    this.ipv4Address = ipv4Address;
    this.ipv6Address = ipv6Address;
    this.switchDPID = switchDPID;
    this.switchPort = switchPort;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:30,代码来源:DeviceIterator.java

示例5: createMatchFromPacket

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
protected Match createMatchFromPacket(IOFSwitch sw, OFPort inPort, FloodlightContext cntx) {
	// The packet in match will only contain the port number.
	// We need to add in specifics for the hosts we're routing between.
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	MacAddress srcMac = eth.getSourceMACAddress();
	MacAddress dstMac = eth.getDestinationMACAddress();

	Match.Builder mb = sw.getOFFactory().buildMatch();
	mb.setExact(MatchField.IN_PORT, inPort)
	.setExact(MatchField.ETH_SRC, srcMac)
	.setExact(MatchField.ETH_DST, dstMac);

	if (!vlan.equals(VlanVid.ZERO)) {
		mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
	}

	return mb.build();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:LearningSwitch.java

示例6: decode_set_vlan_id

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
/**
 * Parse set_vlan_id actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder. Data with a leading 0x is permitted.
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetVlanVid decode_set_vlan_id(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("((?:0x)?\\d+)").matcher(actionToDecode);
	if (n.matches()) {            
		if (n.group(1) != null) {
			try {
				VlanVid vlanid = VlanVid.ofVlan(get_short(n.group(1)));
				OFActionSetVlanVid.Builder ab = OFFactories.getFactory(version).actions().buildSetVlanVid();
				ab.setVlanVid(vlanid);
				log.debug("action {}", ab.build());
				return ab.build();
			}
			catch (NumberFormatException e) {
				log.debug("Invalid VLAN in: {} (error ignored)", actionToDecode);
				return null;
			}
		}          
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:34,代码来源:ActionUtils.java

示例7: testLastSeen

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
@Test
public void testLastSeen() throws Exception {
	Calendar c = Calendar.getInstance();
	Date d1 = c.getTime();
	Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO /* untagged*/, IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, d1);
	c.add(Calendar.SECOND, 1);
	Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO /* untagged*/, IPv4Address.of(1), IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, c.getTime());

	IDevice d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(c.getTime(), d.getLastSeen());
	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(c.getTime(), d.getLastSeen());

	deviceManager.startUp(null);
	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(d1, d.getLastSeen());
	d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(c.getTime(), d.getLastSeen());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:DeviceManagerImplTest.java

示例8: verifyDevice

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
/**
 * Verify that the given device exactly matches the given fields. E.g.,
 * if ip is not null we expect the device to have exactly one IP address.
 * swId and port are the attachment point port.
 * Vlan and ip are optional all other fields must be specified.
 * @return
 */
private static void verifyDevice(IDevice d, MacAddress mac, VlanVid vlan, IPv4Address ipv4,
		IPv6Address ipv6, DatapathId swId, OFPort port) {
	assertNotNull(d);
	if (!mac.equals(MacAddress.NONE)) {
		assertEquals(mac, d.getMACAddress());
	}
	if (vlan != null) {
		assertArrayEquals(new VlanVid[] { vlan }, d.getVlanId());
	}
	if (!ipv4.equals(IPv4Address.NONE)) {
		assertArrayEquals(new IPv4Address[] { ipv4 }, d.getIPv4Addresses());
	}
	if (!ipv6.equals(IPv6Address.NONE)) {
		assertArrayEquals(new IPv6Address[] { ipv6 }, d.getIPv6Addresses());
	}
	if (!swId.equals(DatapathId.NONE) && !port.equals(OFPort.ZERO)) {
		SwitchPort expectedAp = new SwitchPort(swId, port);
		assertArrayEquals(new SwitchPort[] { expectedAp }, d.getAttachmentPoints());
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:28,代码来源:DeviceManagerImplTest.java

示例9: testGetSwitchPortVlanId

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
@Test
public void testGetSwitchPortVlanId() {
	Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(10L), OFPort.of(1), new Date());
	Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(10L), OFPort.of(1), new Date());
	Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(3), IPv4Address.NONE, IPv6Address.NONE,  DatapathId.of(1L), OFPort.of(1), new Date());
	Entity entity4 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(42), IPv4Address.NONE, IPv6Address.NONE,  DatapathId.of(1L), OFPort.of(1), new Date());
	Entity[] entities = new Entity[] { entity1, entity2,
			entity3, entity4
	};
	Device d = new Device(null,1L, null, null, null,
			Arrays.asList(entities), null);
	SwitchPort swp1x1 = new SwitchPort(DatapathId.of(1L), OFPort.of(1));
	SwitchPort swp1x2 = new SwitchPort(DatapathId.of(1L), OFPort.of(2));
	SwitchPort swp2x1 = new SwitchPort(DatapathId.of(2L), OFPort.of(1));
	SwitchPort swp10x1 = new SwitchPort(DatapathId.of(10L), OFPort.of(1));
	assertArrayEquals(new VlanVid[] { VlanVid.ZERO, VlanVid.ofVlan(1)},
			d.getSwitchPortVlanIds(swp10x1));
	assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(3), VlanVid.ofVlan(42)},
			d.getSwitchPortVlanIds(swp1x1));
	assertArrayEquals(new VlanVid[0],
			d.getSwitchPortVlanIds(swp1x2));
	assertArrayEquals(new VlanVid[0],
			d.getSwitchPortVlanIds(swp2x1));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:25,代码来源:DeviceManagerImplTest.java

示例10: setUp

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    e1a = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), IPv4Address.of(1), IPv6Address.of(1, 1), DatapathId.of(1L), OFPort.of(1), new Date());
    e1b = new Entity(MacAddress.of(1L), VlanVid.ofVlan(2), IPv4Address.of(1), IPv6Address.of(1, 1), DatapathId.of(1L), OFPort.of(1), new Date());
    List<Entity> d1Entities = new ArrayList<Entity>(2);
    d1Entities.add(e1a);
    d1Entities.add(e1b);
    d1 = new Device(null, Long.valueOf(1), null, null, null,
                    d1Entities, null);
    
    // e2 and e2 alt match in MAC and VLAN
    e2 = new Entity(MacAddress.of(2L), VlanVid.ofVlan(2), IPv4Address.of(2), IPv6Address.of(2, 2), DatapathId.of(2L), OFPort.of(2), new Date());
    e2alt = new Entity(MacAddress.of(2L), VlanVid.ofVlan(2), IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, Entity.NO_DATE);
    
    // IP is null
    e3 = new Entity(MacAddress.of(3L), VlanVid.ofVlan(3), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(3L), OFPort.of(3), new Date());
    
    // IP and switch and port are null
    e4 = new Entity(MacAddress.of(4L), VlanVid.ofVlan(4), IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, new Date());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:DeviceUniqueIndexTest.java

示例11: learnEntity

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
/**
 * Learn a device using the given characteristics.
 * @param macAddress the MAC
 * @param vlan the VLAN (can be VlanVid.ZERO for untagged)
 * @param ipv4Address the IPv4 (can be IPv4Address.NONE)
 * @param ipv6Address the IPv6 (can be IPv6Address.NONE)
 * @param switchDPID the attachment point switch DPID (can be DatapathId.NONE)
 * @param switchPort the attachment point switch port (can be OFPort.ZERO)
 * @param processUpdates if false, will not send updates.  Note that this
 * method is not thread safe if this is false
 * @return the device, either new or not
 */
public IDevice learnEntity(MacAddress macAddress, VlanVid vlan,
		IPv4Address ipv4Address, IPv6Address ipv6Address, DatapathId switchDPID,
		OFPort switchPort,
		boolean processUpdates) {
	List<IDeviceListener> listeners = deviceListeners.getOrderedListeners();
	if (!processUpdates) {
		deviceListeners.clearListeners();
	}
	
	/* Entity will enforce all but VLAN be non-null */
	IDevice res =  learnDeviceByEntity(new Entity(macAddress, 
			vlan, ipv4Address, ipv6Address, switchDPID, switchPort, new Date()));
	// Restore listeners
	if (listeners != null) {
		for (IDeviceListener listener : listeners) {
			deviceListeners.addListener("device", listener);
		}
	}
	return res;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:33,代码来源:MockDeviceManager.java

示例12: computeVlandIds

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
private VlanVid[] computeVlandIds() {
    if (entities.length == 1) {
        if (entities[0].getVlan() != null) {
            return new VlanVid[]{ entities[0].getVlan() };
        } else {
            return new VlanVid[] { VlanVid.ofVlan(-1) };
        }
    }

    TreeSet<VlanVid> vals = new TreeSet<VlanVid>();
    for (Entity e : entities) {
        if (e.getVlan() == null)
            vals.add(VlanVid.ofVlan(-1));
        else
            vals.add(e.getVlan());
    }
    return vals.toArray(new VlanVid[vals.size()]);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:Device.java

示例13: findDevice

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
@Override
public IDevice findDevice(MacAddress macAddress, VlanVid vlan,
		IPv4Address ipv4Address, DatapathId switchDPID,
		OFPort switchPort)
				throws IllegalArgumentException {
	if (vlan != null && vlan.getVlan() <= 0)
		vlan = null;
	if (ipv4Address != null && ipv4Address.getInt() == 0)
		ipv4Address = null;
	Entity e = new Entity(macAddress, vlan, ipv4Address, switchDPID,
			switchPort, null);
	if (!allKeyFieldsPresent(e, entityClassifier.getKeyFields())) {
		throw new IllegalArgumentException("Not all key fields specified."
				+ " Required fields: " + entityClassifier.getKeyFields());
	}
	return findDeviceByEntity(e);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:DeviceManagerImpl.java

示例14: findClassDevice

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
@Override
public IDevice findClassDevice(IEntityClass entityClass, MacAddress macAddress,
		VlanVid vlan, IPv4Address ipv4Address)
				throws IllegalArgumentException {
	if (vlan != null && vlan.getVlan() <= 0)
		vlan = null;
	if (ipv4Address != null && ipv4Address.getInt() == 0)
		ipv4Address = null;
	Entity e = new Entity(macAddress, vlan, ipv4Address,
			null, null, null);
	if (entityClass == null ||
			!allKeyFieldsPresent(e, entityClass.getKeyFields())) {
		throw new IllegalArgumentException("Not all key fields and/or "
				+ " no source device specified. Required fields: " +
				entityClassifier.getKeyFields());
	}
	return findDestByEntity(entityClass, e);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:DeviceManagerImpl.java

示例15: verifyDevice

import org.projectfloodlight.openflow.types.VlanVid; //导入依赖的package包/类
/**
 * Verify that the given device exactly matches the given fields. E.g.,
 * if ip is not null we expect the device to have exactly one IP address.
 * swId and port are the attachment point port.
 * Vlan and ip are optional all other fields must be specified.
 * @return
 */
private static void verifyDevice(IDevice d, long mac, Short vlan, Integer ip,
		long swId, int port) {
	assertNotNull(d);
	assertEquals(MacAddress.of(mac), d.getMACAddress());
	if (vlan == null)
		assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(-1) }, d.getVlanId());
	else
		assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(vlan) }, d.getVlanId());

	if (ip == null)
		assertArrayEquals(new IPv4Address[] { IPv4Address.of(0) }, d.getIPv4Addresses());
	else
		assertArrayEquals(new IPv4Address[] { IPv4Address.of(ip) }, d.getIPv4Addresses());

	SwitchPort expectedAp = new SwitchPort(DatapathId.of(swId), OFPort.of(port));
	assertArrayEquals(new SwitchPort[] { expectedAp },
			d.getAttachmentPoints());
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:26,代码来源:DeviceManagerImplTest.java


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