本文整理汇总了Java中org.onlab.packet.VlanId.vlanId方法的典型用法代码示例。如果您正苦于以下问题:Java VlanId.vlanId方法的具体用法?Java VlanId.vlanId怎么用?Java VlanId.vlanId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onlab.packet.VlanId
的用法示例。
在下文中一共展示了VlanId.vlanId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: execute
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
@Override
protected void execute() {
InterfaceAdminService interfaceService = get(InterfaceAdminService.class);
List<InterfaceIpAddress> ipAddresses = Lists.newArrayList();
if (ips != null) {
for (String strIp : ips) {
ipAddresses.add(InterfaceIpAddress.valueOf(strIp));
}
}
MacAddress macAddr = mac == null ? null : MacAddress.valueOf(mac);
VlanId vlanId = vlan == null ? VlanId.NONE : VlanId.vlanId(Short.parseShort(vlan));
Interface intf = new Interface(name,
ConnectPoint.deviceConnectPoint(connectPoint),
ipAddresses, macAddr, vlanId);
interfaceService.add(intf);
print("Interface added");
}
示例3: 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;
}
示例4: createMcastFilteringObjective
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private void createMcastFilteringObjective(boolean install, Interface intf) {
VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ?
VlanId.vlanId(ASSIGNED_VLAN) :
egressVlan();
FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
// first add filter for the interface
fob.withKey(Criteria.matchInPort(intf.connectPoint().port()))
.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST,
MacAddress.IPV4_MULTICAST_MASK))
.addCondition(Criteria.matchVlanId(ingressVlan()));
fob.withPriority(PRIORITY_OFFSET);
TrafficTreatment tt = DefaultTrafficTreatment.builder()
.pushVlan().setVlanId(assignedVlan).build();
fob.withMeta(tt);
fob.permit().fromApp(routerAppId);
sendFilteringObjective(install, fob, intf);
}
示例5: assignedVlan
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
* Gets assigned VLAN according to the value of egress VLAN.
* If connect point is specified, try to reuse the assigned VLAN on the connect point.
*
* @param cp connect point; Can be null if not specified
* @return assigned VLAN ID
*/
private VlanId assignedVlan(ConnectPoint cp) {
// Use the egressVlan if it is tagged
if (!egressVlan().equals(VlanId.NONE)) {
return egressVlan();
}
// Reuse unicast VLAN if the port has subnet configured
if (cp != null) {
Ip4Prefix portSubnet = srManager.deviceConfiguration
.getPortSubnet(cp.deviceId(), cp.port());
VlanId unicastVlan = srManager.getSubnetAssignedVlanId(cp.deviceId(), portSubnet);
if (unicastVlan != null) {
return unicastVlan;
}
}
// By default, use VLAN_NO_SUBNET
return VlanId.vlanId(SegmentRoutingManager.ASSIGNED_VLAN_NO_SUBNET);
}
示例6: decode
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
@Override
public OfdpaSetVlanVid decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
// parse ofdpa set vlan vid
short vlanVid = (short) nullIsIllegal(json.get(VLAN_ID),
VLAN_ID + MISSING_MEMBER_MESSAGE).asInt();
return new OfdpaSetVlanVid(VlanId.vlanId(vlanVid));
}
示例7: setUpInterfaceService
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
* Sets up the interface service.
*/
private void setUpInterfaceService() {
List<InterfaceIpAddress> interfaceIpAddresses1 = Lists.newArrayList();
interfaceIpAddresses1.add(InterfaceIpAddress.valueOf("192.168.10.101/24"));
Interface sw1Eth1 = new Interface("sw1-eth1", SW1_ETH1,
interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
VlanId.vlanId((short) 1));
interfaces.add(sw1Eth1);
List<InterfaceIpAddress> interfaceIpAddresses2 = Lists.newArrayList();
interfaceIpAddresses2.add(InterfaceIpAddress.valueOf("192.168.20.101/24"));
Interface sw2Eth1 = new Interface("sw2-eth1", SW2_ETH1,
interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
VlanId.vlanId((short) 1));
interfaces.add(sw2Eth1);
InterfaceIpAddress interfaceIpAddress3 = InterfaceIpAddress.valueOf("192.168.30.101/24");
Interface sw3Eth1 = new Interface("sw3-eth1", SW3_ETH1,
Lists.newArrayList(interfaceIpAddress3),
MacAddress.valueOf("00:00:00:00:00:03"),
VlanId.NONE);
interfaces.add(sw3Eth1);
expect(interfaceService.getInterfacesByPort(SW1_ETH1)).andReturn(
Collections.singleton(sw1Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.10.1")))
.andReturn(sw1Eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(SW2_ETH1)).andReturn(
Collections.singleton(sw2Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.20.1")))
.andReturn(sw2Eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(SW3_ETH1)).andReturn(
Collections.singleton(sw3Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.30.1")))
.andReturn(sw3Eth1).anyTimes();
expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
}
示例8: getVlan
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private VlanId getVlan(JsonNode node) {
VlanId vlan = VlanId.NONE;
if (!node.path(VLAN).isMissingNode()) {
vlan = VlanId.vlanId(Short.valueOf(node.path(VLAN).asText()));
}
return vlan;
}
示例9: ingressVlan
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
* Gets ingress VLAN of multicast traffic.
*
* @return Ingress VLAN ID
*/
public VlanId ingressVlan() {
if (!object.has(INGRESS_VLAN)) {
return VlanId.NONE;
}
try {
return VlanId.vlanId(object.path(INGRESS_VLAN).asText());
} catch (IllegalArgumentException e) {
return null;
}
}
示例10: setUpInterfaceService
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
* Sets up the interface service.
*/
private void setUpInterfaceService() {
List<InterfaceIpAddress> interfaceIpAddresses1 = Lists.newArrayList();
interfaceIpAddresses1.add(InterfaceIpAddress.valueOf("192.168.10.101/24"));
Interface sw1Eth1 = new Interface("sw1-eth1", SW1_ETH1,
interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
VlanId.vlanId((short) 1));
interfaces.add(sw1Eth1);
List<InterfaceIpAddress> interfaceIpAddresses2 = Lists.newArrayList();
interfaceIpAddresses2.add(InterfaceIpAddress.valueOf("192.168.20.101/24"));
Interface sw2Eth1 = new Interface("sw2-eth1", SW2_ETH1,
interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
VlanId.vlanId((short) 1));
interfaces.add(sw2Eth1);
InterfaceIpAddress interfaceIpAddress3 = InterfaceIpAddress.valueOf("192.168.30.101/24");
Interface sw3Eth1 = new Interface("sw3-eth1", SW3_ETH1,
Lists.newArrayList(interfaceIpAddress3),
MacAddress.valueOf("00:00:00:00:00:03"),
VlanId.vlanId((short) 2));
interfaces.add(sw3Eth1);
expect(interfaceService.getInterfacesByPort(SW1_ETH1)).andReturn(
Collections.singleton(sw1Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.10.1")))
.andReturn(sw1Eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(SW2_ETH1)).andReturn(
Collections.singleton(sw2Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.20.1")))
.andReturn(sw2Eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(SW3_ETH1)).andReturn(
Collections.singleton(sw3Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.30.1")))
.andReturn(sw3Eth1).anyTimes();
expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
}
示例11: testGetInterfacesByVlan
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
@Test
public void testGetInterfacesByVlan() throws Exception {
VlanId vlanId = VlanId.vlanId((short) 1);
Set<Interface> byVlan = Collections.singleton(createInterface(1));
assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId));
}
示例12: testAddInterface
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
@Test
public void testAddInterface() throws Exception {
// Create a new InterfaceConfig which will get added
VlanId vlanId = VlanId.vlanId((short) 1);
ConnectPoint cp = ConnectPoint.deviceConnectPoint("of:0000000000000001/2");
Interface newIntf = new Interface(cp,
Collections.emptyList(),
MacAddress.valueOf(100),
vlanId);
InterfaceConfig ic = new TestInterfaceConfig(cp, Collections.singleton(newIntf));
subjects.add(cp);
configs.put(cp, ic);
interfaces.add(newIntf);
NetworkConfigEvent event = new NetworkConfigEvent(
NetworkConfigEvent.Type.CONFIG_ADDED, cp, CONFIG_CLASS);
assertEquals(NUM_INTERFACES, interfaceManager.getInterfaces().size());
// Send in a config event containing a new interface config
listener.event(event);
// Check the new interface exists in the InterfaceManager's inventory
assertEquals(interfaces, interfaceManager.getInterfaces());
assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
// There are now two interfaces with vlan ID 1
Set<Interface> byVlan = Sets.newHashSet(createInterface(1), newIntf);
assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId));
}
示例13: testUpdateInterface
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
@Test
public void testUpdateInterface() throws Exception {
ConnectPoint cp = createConnectPoint(1);
// Create an interface that is the same as the existing one, but adds a
// new IP address
Interface intf = createInterface(1);
List<InterfaceIpAddress> addresses = Lists.newArrayList(intf.ipAddresses());
addresses.add(InterfaceIpAddress.valueOf("192.168.100.1/24"));
intf = new Interface(intf.connectPoint(), addresses, intf.mac(), intf.vlan());
// Create a new interface on the same connect point as the existing one
InterfaceIpAddress newAddr = InterfaceIpAddress.valueOf("192.168.101.1/24");
Interface newIntf = new Interface(cp,
Collections.singletonList(newAddr),
MacAddress.valueOf(101),
VlanId.vlanId((short) 101));
Set<Interface> interfaces = Sets.newHashSet(intf, newIntf);
// New interface config updates the existing interface and adds a new
// interface to the same connect point
InterfaceConfig ic = new TestInterfaceConfig(cp, interfaces);
configs.put(cp, ic);
NetworkConfigEvent event = new NetworkConfigEvent(
NetworkConfigEvent.Type.CONFIG_UPDATED, cp, CONFIG_CLASS);
// Send in the event signalling the interfaces for this connect point
// have been updated
listener.event(event);
assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
assertEquals(interfaces, interfaceManager.getInterfacesByPort(cp));
}
示例14: addTenant
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
@Override
public VoltTenant addTenant(VoltTenant newTenant) {
long providerServiceId = newTenant.providerService();
if (providerServiceId == -1) {
providerServiceId = xosProviderService;
}
PortNumber onuPort = newTenant.port().port();
VlanId subscriberVlan;
try {
subscriberVlan = VlanId.vlanId(portToVlan.get(onuPort.toLong()));
} catch (NullPointerException npe) {
log.error("No matched port in portToVlan map", npe);
return newTenant;
}
VoltTenant tenantToCreate = VoltTenant.builder()
.withProviderService(providerServiceId)
.withServiceSpecificId(portToSsid.get(newTenant.port()))
.withVlanId(String.valueOf(subscriberVlan.toShort()))
.withPort(newTenant.port())
.build();
String json = tenantToJson(tenantToCreate);
provisionVlanOnPort(OLT_DEVICE_ID, OLT_UPLINK_PORT, onuPort, subscriberVlan.toShort());
String retJson = postRest(json);
fetchCpeLocation(tenantToCreate, retJson);
return newTenant;
}
示例15: setUpInterfaceService
import org.onlab.packet.VlanId; //导入方法依赖的package包/类
/**
* Sets up the interface service.
*/
private void setUpInterfaceService() {
List<InterfaceIpAddress> interfaceIpAddresses1 = Lists.newArrayList();
interfaceIpAddresses1.add(InterfaceIpAddress.valueOf("192.168.10.101/24"));
Interface sw1Eth1 = new Interface("sw1-eth1", SW1_ETH1,
interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
VlanId.vlanId((short) 1));
interfaces.add(sw1Eth1);
List<InterfaceIpAddress> interfaceIpAddresses2 = Lists.newArrayList();
interfaceIpAddresses2.add(InterfaceIpAddress.valueOf("192.168.20.101/24"));
Interface sw2Eth1 = new Interface("sw2-eth1", SW2_ETH1,
interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
VlanId.vlanId((short) 1));
interfaces.add(sw2Eth1);
InterfaceIpAddress interfaceIpAddress3 = InterfaceIpAddress.valueOf("192.168.30.101/24");
Interface sw3Eth1 = new Interface("sw3-eth1", SW3_ETH1,
Lists.newArrayList(interfaceIpAddress3),
MacAddress.valueOf("00:00:00:00:00:03"),
VlanId.vlanId((short) 1));
interfaces.add(sw3Eth1);
expect(interfaceService.getInterfacesByPort(SW1_ETH1)).andReturn(
Collections.singleton(sw1Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.10.1")))
.andReturn(sw1Eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(SW2_ETH1)).andReturn(
Collections.singleton(sw2Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.20.1")))
.andReturn(sw2Eth1).anyTimes();
expect(interfaceService.getInterfacesByPort(SW3_ETH1)).andReturn(
Collections.singleton(sw3Eth1)).anyTimes();
expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.30.1")))
.andReturn(sw3Eth1).anyTimes();
expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
}