本文整理汇总了Java中org.onlab.packet.MplsLabel类的典型用法代码示例。如果您正苦于以下问题:Java MplsLabel类的具体用法?Java MplsLabel怎么用?Java MplsLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MplsLabel类属于org.onlab.packet包,在下文中一共展示了MplsLabel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: printAllocation
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private void printAllocation(DeviceId did, PortNumber num, int level) {
if (level == 0) {
// print DeviceId when Port was directly specified.
print("%s", did);
}
print("%s%s", Strings.repeat(" ", level), asVerboseString(num));
// FIXME: This workaround induces a lot of distributed store access.
// ResourceService should have an API to get all allocations under a parent resource.
Set<Class<?>> subResourceTypes = ImmutableSet.<Class<?>>builder()
.add(OchSignal.class)
.add(VlanId.class)
.add(MplsLabel.class)
.add(Bandwidth.class)
.add(TributarySlot.class)
.build();
DiscreteResourceId resourceId = Resources.discrete(did, num).id();
for (Class<?> t : subResourceTypes) {
resourceService.getResourceAllocations(resourceId, t).stream()
.filter(a -> isSubjectToPrint(a))
.forEach(a -> print("%s%s allocated by %s", Strings.repeat(" ", level + 1),
a.resource().valueAs(Object.class).orElse(""), asVerboseString(a.consumerId())));
}
}
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:AllocationsCommand.java
示例2: installNodeLabelRule
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
/**
* Install a rule for pushing unique global labels to the device.
*
* @param deviceId device to which flow should be pushed
* @param labelId label for the device
* @param type type of operation
*/
private void installNodeLabelRule(DeviceId deviceId, LabelResourceId labelId, Objective.Operation type) {
checkNotNull(flowObjectiveService);
checkNotNull(appId);
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
.withSelector(selectorBuilder.build()).withTreatment(treatment)
.withFlag(ForwardingObjective.Flag.VERSATILE).fromApp(appId).makePermanent();
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, forwardingObjective.add());
} else {
flowObjectiveService.forward(deviceId, forwardingObjective.remove());
}
}
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:PceccSrTeBeHandler.java
示例3: advertiseNodeLabelRule
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
/**
* Install a rule for pushing node labels to the device of other nodes.
*
* @param deviceId device to which flow should be pushed
* @param labelId label for the device
* @param ipPrefix device for which label is pushed
* @param type type of operation
* @param bBos is this the end of sync push
*/
public void advertiseNodeLabelRule(DeviceId deviceId, LabelResourceId labelId, IpPrefix ipPrefix,
Objective.Operation type, boolean bBos) {
checkNotNull(flowObjectiveService);
checkNotNull(appId);
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
selectorBuilder.matchIPSrc(ipPrefix);
if (bBos) {
selectorBuilder.matchMplsBos(bBos);
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
.withSelector(selectorBuilder.build()).withTreatment(treatment)
.withFlag(ForwardingObjective.Flag.VERSATILE).fromApp(appId).makePermanent();
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, forwardingObjective.add());
} else {
flowObjectiveService.forward(deviceId, forwardingObjective.remove());
}
}
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:PceccSrTeBeHandler.java
示例4: installAdjLabelRule
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
/**
* Install a rule for pushing Adjacency labels to the device.
*
* @param deviceId device to which flow should be pushed
* @param labelId label for the adjacency
* @param srcPortNum local port of the adjacency
* @param dstPortNum remote port of the adjacency
* @param type type of operation
*/
public void installAdjLabelRule(DeviceId deviceId, LabelResourceId labelId, PortNumber srcPortNum,
PortNumber dstPortNum, Objective.Operation type) {
checkNotNull(flowObjectiveService);
checkNotNull(appId);
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
selectorBuilder.matchIPSrc(IpPrefix.valueOf((int) srcPortNum.toLong(), 32));
selectorBuilder.matchIPDst(IpPrefix.valueOf((int) dstPortNum.toLong(), 32));
TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
.withSelector(selectorBuilder.build()).withTreatment(treatment)
.withFlag(ForwardingObjective.Flag.VERSATILE).fromApp(appId).makePermanent();
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, forwardingObjective.add());
} else {
flowObjectiveService.forward(deviceId, forwardingObjective.remove());
}
}
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:PceccSrTeBeHandler.java
示例5: MplsIntent
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
/**
* Creates a new point-to-point intent with the supplied ingress/egress
* ports, labels and constraints.
*
* @param appId application identifier
* @param selector traffic selector
* @param treatment treatment
* @param ingressPoint ingress port
* @param ingressLabel ingress MPLS label
* @param egressPoint egress port
* @param egressLabel egress MPLS label
* @param constraints optional list of constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
*/
private MplsIntent(ApplicationId appId,
Key key,
TrafficSelector selector,
TrafficTreatment treatment,
ConnectPoint ingressPoint,
Optional<MplsLabel> ingressLabel,
ConnectPoint egressPoint,
Optional<MplsLabel> egressLabel,
List<Constraint> constraints,
int priority) {
super(appId, key, Collections.emptyList(), selector, treatment, constraints,
priority);
this.ingressPoint = checkNotNull(ingressPoint);
this.ingressLabel = checkNotNull(ingressLabel);
this.egressPoint = checkNotNull(egressPoint);
this.egressLabel = checkNotNull(egressLabel);
checkArgument(!ingressPoint.equals(egressPoint),
"ingress and egress should be different (ingress: %s, egress: %s)",
ingressPoint, egressPoint);
}
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:MplsIntent.java
示例6: mplsPathIntentTestSetUp
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
@Before
public void mplsPathIntentTestSetUp() {
defaultPath = createPath("a", "b", "c");
selector = new IntentTestsMocks.MockSelector();
treatment = new IntentTestsMocks.MockTreatment();
label1 = Optional.of(MplsLabel.mplsLabel(1));
label2 = Optional.of(MplsLabel.mplsLabel(2));
intent1 = MplsPathIntent.builder()
.appId(APP_ID)
.key(KEY1)
.ingressLabel(label1)
.egressLabel(label2)
.path(defaultPath)
.priority(PRIORITY)
.build();
intent2 = MplsPathIntent.builder()
.appId(APP_ID)
.ingressLabel(label1)
.egressLabel(label2)
.path(defaultPath)
.priority(PRIORITY)
.build();
}
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:MplsPathIntentTest.java
示例7: queryMplsLabels
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private Set<MplsLabel> queryMplsLabels(DeviceId device, PortNumber port) {
try {
DriverHandler handler = driverService.createHandler(device);
if (handler == null || !handler.hasBehaviour(MplsQuery.class)) {
return ImmutableSet.of();
}
MplsQuery query = handler.behaviour(MplsQuery.class);
if (query == null) {
return ImmutableSet.of();
}
return query.queryMplsLabels(port);
} catch (ItemNotFoundException e) {
return ImmutableSet.of();
}
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:ResourceDeviceListener.java
示例8: ingressFlow
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private FlowRule ingressFlow(PortNumber inPort, Link link,
MplsPathIntent intent,
MplsLabel label) {
TrafficSelector.Builder ingressSelector = DefaultTrafficSelector
.builder(intent.selector());
TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
ingressSelector.matchInPort(inPort);
if (intent.ingressLabel().isPresent()) {
ingressSelector.matchEthType(Ethernet.MPLS_UNICAST)
.matchMplsLabel(intent.ingressLabel().get());
// Swap the MPLS label
treat.setMpls(label);
} else {
// Push and set the MPLS label
treat.pushMpls().setMpls(label);
}
// Add the output action
treat.setOutput(link.src().port());
return createFlowRule(intent, link.src().deviceId(), ingressSelector.build(), treat.build());
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:MplsPathIntentCompiler.java
示例9: transitFlow
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private FlowRule transitFlow(PortNumber inPort, Link link,
MplsPathIntent intent,
MplsLabel prevLabel,
MplsLabel outLabel) {
// Ignore the ingress Traffic Selector and use only the MPLS label
// assigned in the previous link
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchInPort(inPort).matchEthType(Ethernet.MPLS_UNICAST)
.matchMplsLabel(prevLabel);
TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
// Set the new label only if the label on the packet is
// different
if (!prevLabel.equals(outLabel)) {
treat.setMpls(outLabel);
}
treat.setOutput(link.src().port());
return createFlowRule(intent, link.src().deviceId(), selector.build(), treat.build());
}
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:MplsPathIntentCompiler.java
示例10: createSouthboundGroupEntry
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private Group createSouthboundGroupEntry(GroupId gId,
List<PortNumber> ports,
long referenceCount, DeviceId deviceId) {
List<PortNumber> outPorts = new ArrayList<>();
outPorts.addAll(ports);
List<GroupBucket> buckets = new ArrayList<>();
for (PortNumber portNumber : outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
.setEthDst(MacAddress.valueOf("00:00:00:00:00:02"))
.setEthSrc(MacAddress.valueOf("00:00:00:00:00:01"))
.pushMpls()
.setMpls(MplsLabel.mplsLabel(106));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(
tBuilder.build()));
}
GroupBuckets groupBuckets = new GroupBuckets(buckets);
StoredGroupEntry group = new DefaultGroup(
gId, deviceId, Group.Type.SELECT, groupBuckets);
group.setReferenceCount(referenceCount);
return group;
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:GroupManagerTest.java
示例11: createSouthboundGroupEntry
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private Group createSouthboundGroupEntry(GroupId gId,
List<PortNumber> ports,
long referenceCount) {
List<PortNumber> outPorts = new ArrayList<PortNumber>();
outPorts.addAll(ports);
List<GroupBucket> buckets = new ArrayList<GroupBucket>();
for (PortNumber portNumber: outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
.setEthDst(MacAddress.valueOf("00:00:00:00:00:02"))
.setEthSrc(MacAddress.valueOf("00:00:00:00:00:01"))
.pushMpls()
.setMpls(MplsLabel.mplsLabel(106));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(
tBuilder.build()));
}
GroupBuckets groupBuckets = new GroupBuckets(buckets);
StoredGroupEntry group = new DefaultGroup(
gId, DID, Group.Type.SELECT, groupBuckets);
group.setReferenceCount(referenceCount);
return group;
}
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:24,代码来源:GroupManagerTest.java
示例12: getMplsInBuilder
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private ForwardingObjective.Builder getMplsInBuilder(DeviceId deviceId,
Host host,
Label label) {
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(getTunnlePort(deviceId))
.matchEthType(EthType.EtherType.MPLS_UNICAST.ethType()
.toShort())
.matchMplsBos(true)
.matchMplsLabel(MplsLabel.mplsLabel(label.getLabel())).build();
TrafficTreatment treatment = builder.popMpls(EthType
.EtherType
.IPV4.ethType())
.setOutput(host.location().port()).build();
return DefaultForwardingObjective
.builder().withTreatment(treatment).withSelector(selector)
.fromApp(appId).withFlag(ForwardingObjective.Flag.SPECIFIC)
.withPriority(60000);
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:EvpnManager.java
示例13: configurationValidity
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
/**
* Checks if the configured pseudowires will create problems in the network.
* If yes, then no pseudowires is deployed from this configuration.
*
* @param pseudowires Set of pseudowries to validate
* @return returns true if everything goes well.
*/
public boolean configurationValidity(Set<DefaultL2TunnelDescription> pseudowires) {
// structures to keep pw information
// in order to see if instantiating them will create
// problems
Set<Long> tunIds = new HashSet<>();
Set<MplsLabel> labelsUsed = new HashSet<>();
Map<ConnectPoint, Set<VlanId>> vlanIds = new HashMap<>();
// check that pseudowires can be instantiated in the network
// we try to guarantee that all the pws will work before
// instantiating any of them
for (DefaultL2TunnelDescription pw : pseudowires) {
verifyPseudoWire(pw, labelsUsed, vlanIds, tunIds);
}
return true;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:PwaasConfig.java
示例14: addMplsLabels
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
/**
* Binds MPLS labels to a parent resource, given a parent resource.
*
* @param parent the parent resource
* @return the MPLS labels allocated
*/
private Collection<Resource> addMplsLabels(DiscreteResourceId parent) {
Collection<Resource> resources = new HashSet<>();
if (!this.availableMplsLabels.isEmpty()) {
this.availableMplsLabels.forEach(label -> {
if (label < MplsLabel.MAX_MPLS) {
resources.add(Resources.discrete(parent).resource().child(MplsLabel.mplsLabel(label)));
}
});
} else {
for (int i = 1; i < 1000; i++) {
resources.add(Resources.discrete(parent).resource().child(MplsLabel.mplsLabel(i)));
}
}
return resources;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:22,代码来源:MockResourceService.java
示例15: updateSelectorFromEncapsulation
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
/**
* The method generates a selector starting from
* the encapsulation information (type and label to match).
*
* @param selectorBuilder the builder to update
* @param type the type of encapsulation
* @param identifier the label to match
*/
private void updateSelectorFromEncapsulation(TrafficSelector.Builder selectorBuilder,
EncapsulationType type,
Identifier<?> identifier) {
switch (type) {
case MPLS:
MplsLabel label = (MplsLabel) identifier;
selectorBuilder.matchMplsLabel(label);
selectorBuilder.matchEthType(Ethernet.MPLS_UNICAST);
break;
case VLAN:
VlanId id = (VlanId) identifier;
selectorBuilder.matchVlanId(id);
break;
default:
throw new IntentCompilationException(UNKNOWN_ENCAPSULATION);
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:28,代码来源:LinkCollectionCompiler.java
示例16: createSouthboundGroupEntry
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private static Group createSouthboundGroupEntry(GroupId gId,
List<PortNumber> ports,
long referenceCount, DeviceId deviceId) {
List<PortNumber> outPorts = new ArrayList<>();
outPorts.addAll(ports);
List<GroupBucket> buckets = new ArrayList<>();
for (PortNumber portNumber : outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
.setEthDst(MacAddress.valueOf("00:00:00:00:00:02"))
.setEthSrc(MacAddress.valueOf("00:00:00:00:00:01"))
.pushMpls()
.setMpls(MplsLabel.mplsLabel(106));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(
tBuilder.build()));
}
GroupBuckets groupBuckets = new GroupBuckets(buckets);
StoredGroupEntry group = new DefaultGroup(
gId, deviceId, Group.Type.SELECT, groupBuckets);
group.setReferenceCount(referenceCount);
return group;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:GroupManagerTest.java
示例17: execute
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
@Override
protected void execute() {
IntentService service = get(IntentService.class);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
Optional<MplsLabel> ingressLabel = Optional.empty();
if (!ingressLabelString.isEmpty()) {
ingressLabel = Optional
.ofNullable(MplsLabel.mplsLabel(parseInt(ingressLabelString)));
}
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
Optional<MplsLabel> egressLabel = Optional.empty();
if (!egressLabelString.isEmpty()) {
egressLabel = Optional
.ofNullable(MplsLabel.mplsLabel(parseInt(egressLabelString)));
}
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = buildTrafficTreatment();
List<Constraint> constraints = buildConstraints();
MplsIntent intent = MplsIntent.builder()
.appId(appId())
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.ingressLabel(ingressLabel)
.egressPoint(egress)
.egressLabel(egressLabel)
.constraints(constraints)
.priority(priority())
.build();
service.submit(intent);
}
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:AddMplsIntent.java
示例18: installLocalLabelRule
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
private void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId,
PortNumber portNum, TunnelId tunnelId,
Boolean isBos, Long labelType,
Objective.Operation type) {
checkNotNull(flowObjectiveService);
checkNotNull(appId);
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
selectorBuilder.matchInPort(portNum);
selectorBuilder.matchTunnelId(Long.parseLong(tunnelId.id()));
selectorBuilder.matchMplsBos(isBos);
selectorBuilder.matchMetadata(labelType);
TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
.withSelector(selectorBuilder.build())
.withTreatment(treatment)
.withFlag(ForwardingObjective.Flag.VERSATILE)
.fromApp(appId)
.makePermanent();
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, forwardingObjective.add());
} else {
flowObjectiveService.forward(deviceId, forwardingObjective.remove());
}
}
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:BasicPceccHandler.java
示例19: testModMplsMethod
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
/**
* Test the modMplsLabel method.
*/
@Test
public void testModMplsMethod() {
final MplsLabel mplsLabel = MplsLabel.mplsLabel(33);
final Instruction instruction = Instructions.modMplsLabel(mplsLabel);
final L2ModificationInstruction.ModMplsLabelInstruction modMplsLabelInstruction =
checkAndConvert(instruction,
Instruction.Type.L2MODIFICATION,
L2ModificationInstruction.ModMplsLabelInstruction.class);
assertThat(modMplsLabelInstruction.label(), is(equalTo(mplsLabel)));
assertThat(modMplsLabelInstruction.subtype(),
is(equalTo(L2ModificationInstruction.L2SubType.MPLS_LABEL)));
}
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:InstructionsTest.java
示例20: mplsIntentTestSetUp
import org.onlab.packet.MplsLabel; //导入依赖的package包/类
@Before
public void mplsIntentTestSetUp() throws Exception {
label1 = Optional.of(MplsLabel.mplsLabel(1));
label2 = Optional.of(MplsLabel.mplsLabel(2));
selector = new IntentTestsMocks.MockSelector();
treatment = new IntentTestsMocks.MockTreatment();
intent1 = MplsIntent.builder()
.appId(APP_ID)
.ingressLabel(label1)
.egressLabel(label2)
.ingressPoint(connectPoint("in", 1))
.egressPoint(connectPoint("out", 1))
.selector(selector)
.treatment(treatment)
.priority(PRIORITY)
.build();
intent2 = MplsIntent.builder()
.appId(APP_ID)
.ingressLabel(label1)
.egressLabel(label2)
.ingressPoint(connectPoint("in", 2))
.egressPoint(connectPoint("out", 2))
.selector(selector)
.treatment(treatment)
.priority(PRIORITY)
.build();
}
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:MplsIntentTest.java
注:本文中的org.onlab.packet.MplsLabel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论