本文整理汇总了Java中org.onlab.packet.EthType类的典型用法代码示例。如果您正苦于以下问题:Java EthType类的具体用法?Java EthType怎么用?Java EthType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EthType类属于org.onlab.packet包,在下文中一共展示了EthType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateOspfForwarding
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Installs or removes OSPF forwarding rules.
*
* @param intf the interface on which event is received
* @param install true to create an add objective, false to create a remove
* objective
**/
private void updateOspfForwarding(Interface intf, boolean install) {
// OSPF to router
TrafficSelector toSelector = DefaultTrafficSelector.builder()
.matchInPort(intf.connectPoint().port())
.matchEthType(EthType.EtherType.IPV4.ethType().toShort())
.matchVlanId(intf.vlan())
.matchIPProtocol((byte) OSPF_IP_PROTO)
.build();
// create nextObjectives for forwarding to the controlPlaneConnectPoint
DeviceId deviceId = controlPlaneConnectPoint.deviceId();
PortNumber controlPlanePort = controlPlaneConnectPoint.port();
int cpNextId;
if (intf.vlan() == VlanId.NONE) {
cpNextId = modifyNextObjective(deviceId, controlPlanePort,
VlanId.vlanId(SingleSwitchFibInstaller.ASSIGNED_VLAN),
true, install);
} else {
cpNextId = modifyNextObjective(deviceId, controlPlanePort,
intf.vlan(), false, install);
}
log.debug("OSPF flows intf:{} nextid:{}", intf, cpNextId);
flowObjectiveService.forward(controlPlaneConnectPoint.deviceId(),
buildForwardingObjective(toSelector, null, cpNextId, install ? ospfEnabled : install));
}
示例2: codecSimpleFlowTest
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Checks that a simple rule decodes properly.
*
* @throws IOException if the resource cannot be processed
*/
@Test
public void codecSimpleFlowTest() throws IOException {
FlowRule rule = getRule("simple-flow.json");
checkCommonData(rule);
assertThat(rule.selector().criteria().size(), is(1));
Criterion criterion1 = rule.selector().criteria().iterator().next();
assertThat(criterion1.type(), is(Criterion.Type.ETH_TYPE));
assertThat(((EthTypeCriterion) criterion1).ethType(), is(new EthType(2054)));
assertThat(rule.treatment().allInstructions().size(), is(1));
Instruction instruction1 = rule.treatment().allInstructions().get(0);
assertThat(instruction1.type(), is(Instruction.Type.OUTPUT));
assertThat(((Instructions.OutputInstruction) instruction1).port(), is(PortNumber.CONTROLLER));
}
示例3: getMplsInBuilder
import org.onlab.packet.EthType; //导入依赖的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);
}
示例4: flowAndGroup
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Test a single flow rule that points to a group with output port in it.
*/
@Test
public void flowAndGroup() throws Exception {
StaticPacketTrace traceSuccess = testSuccess(PACKET_OK, GROUP_FLOW_IN_CP, GROUP_FLOW_DEVICE,
GROUP_FLOW_OUT_CP, 1, 1);
assertTrue("Wrong Output Group", traceSuccess.getGroupOuputs(GROUP_FLOW_DEVICE)
.get(0).getGroups().contains(GROUP));
assertEquals("Packet should not have MPLS Label", EthType.EtherType.IPV4.ethType(),
((EthTypeCriterion) traceSuccess.getGroupOuputs(GROUP_FLOW_DEVICE)
.get(0).getFinalPacket().getCriterion(Criterion.Type.ETH_TYPE)).ethType());
assertNull("Packet should not have MPLS Label", traceSuccess.getGroupOuputs(GROUP_FLOW_DEVICE)
.get(0).getFinalPacket().getCriterion(Criterion.Type.MPLS_LABEL));
assertNull("Packet should not have MPLS Label", traceSuccess.getGroupOuputs(GROUP_FLOW_DEVICE)
.get(0).getFinalPacket().getCriterion(Criterion.Type.MPLS_BOS));
}
示例5: json
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Returns a JSON representation of the given packet context.
*
* @param context the packet context
* @return the inbound packetjson message
*/
public static JsonObject json(PacketContext context) {
JsonObject jo = new JsonObject();
InboundPacket pkt = context.inPacket();
// parse connection host
jo.addProperty(SWITCH_ID, pkt.receivedFrom().deviceId().toString());
jo.addProperty(IN_PORT, pkt.receivedFrom().port().name());
jo.addProperty(LOGICAL, pkt.receivedFrom().port().isLogical());
jo.addProperty(RECEIVED, new Date(context.time()).toString());
jo.addProperty(MSG_TYPE, PKT_TYPE);
// parse ethernet
jo.addProperty(SUB_MSG_TYPE,
EthType.EtherType.lookup(pkt.parsed().getEtherType()).name());
jo.addProperty(ETH_TYPE, pkt.parsed().getEtherType());
jo.addProperty(SRC_MAC_ADDR, pkt.parsed().getSourceMAC().toString());
jo.addProperty(DEST_MAC_ADDR, pkt.parsed().getDestinationMAC().toString());
jo.addProperty(VLAN_ID, pkt.parsed().getVlanID());
jo.addProperty(B_CAST, pkt.parsed().isBroadcast());
jo.addProperty(M_CAST, pkt.parsed().isMulticast());
jo.addProperty(PAD, pkt.parsed().isPad());
jo.addProperty(PRIORITY_CODE, pkt.parsed().getPriorityCode());
// parse bytebuffer
jo.addProperty(DATA_LEN, pkt.unparsed().array().length);
jo.addProperty(PAYLOAD, pkt.unparsed().asCharBuffer().toString());
return jo;
}
示例6: requestPacket
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Requests ARP packet to GatewayNode.
*
* @param appId application id
*/
public void requestPacket(ApplicationId appId) {
TrafficSelector arpSelector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.ARP.ethType().toShort())
.build();
packetService.requestPackets(arpSelector,
PacketPriority.CONTROL,
appId,
Optional.of(DeviceId.deviceId(config.gatewayBridgeId())));
}
示例7: testMatchEthTypeMethod
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Test the matchEthType method.
*/
@Test
public void testMatchEthTypeMethod() {
EthType ethType = new EthType(12);
Criterion matchEthType = Criteria.matchEthType(new EthType(12));
EthTypeCriterion ethTypeCriterion =
checkAndConvert(matchEthType,
Criterion.Type.ETH_TYPE,
EthTypeCriterion.class);
assertThat(ethTypeCriterion.ethType(), is(equalTo(ethType)));
}
示例8: testPushMplsMethod
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Test the pushMpls method.
*/
@Test
public void testPushMplsMethod() {
final Instruction instruction = Instructions.pushMpls();
final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstruction =
checkAndConvert(instruction,
Instruction.Type.L2MODIFICATION,
L2ModificationInstruction.PushHeaderInstructions.class);
assertThat(pushHeaderInstruction.ethernetType().toString(),
is(EthType.EtherType.MPLS_MULTICAST.toString()));
assertThat(pushHeaderInstruction.subtype(),
is(L2ModificationInstruction.L2SubType.MPLS_PUSH));
}
示例9: testPopMplsMethod
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Test the popMpls method.
*/
@Test
public void testPopMplsMethod() {
final Instruction instruction = Instructions.popMpls();
final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstruction =
checkAndConvert(instruction,
Instruction.Type.L2MODIFICATION,
L2ModificationInstruction.PushHeaderInstructions.class);
assertThat(pushHeaderInstruction.ethernetType().toString(),
is(EthType.EtherType.MPLS_MULTICAST.toString()));
assertThat(pushHeaderInstruction.subtype(),
is(L2ModificationInstruction.L2SubType.MPLS_POP));
}
示例10: testPopMplsEthertypeMethod
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Test the popMpls(EtherType) method.
*/
@Test
public void testPopMplsEthertypeMethod() {
final Instruction instruction = Instructions.popMpls(new EthType(1));
final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstruction =
checkAndConvert(instruction,
Instruction.Type.L2MODIFICATION,
L2ModificationInstruction.PushHeaderInstructions.class);
assertThat(pushHeaderInstruction.ethernetType().toShort(), is((short) 1));
assertThat(pushHeaderInstruction.subtype(),
is(L2ModificationInstruction.L2SubType.MPLS_POP));
}
示例11: testPushVlanMethod
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Test the pushVlan method.
*/
@Test
public void testPushVlanMethod() {
final Instruction instruction = Instructions.pushVlan();
final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstruction =
checkAndConvert(instruction,
Instruction.Type.L2MODIFICATION,
L2ModificationInstruction.PushHeaderInstructions.class);
assertThat(pushHeaderInstruction.ethernetType().toString(),
is(EthType.EtherType.VLAN.toString()));
assertThat(pushHeaderInstruction.subtype(),
is(L2ModificationInstruction.L2SubType.VLAN_PUSH));
}
示例12: outputEthType
import org.onlab.packet.EthType; //导入依赖的package包/类
private EthType outputEthType(TrafficSelector selector) {
Criterion c = selector.getCriterion(Criterion.Type.ETH_TYPE);
if (c != null && c instanceof EthTypeCriterion) {
EthTypeCriterion ethertype = (EthTypeCriterion) c;
return ethertype.ethType();
} else {
return EthType.EtherType.IPV4.ethType();
}
}
示例13: requestPacket
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Requests ARP packet.
*/
private void requestPacket() {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.ARP.ethType().toShort())
.build();
packetService.requestPackets(
selector,
PacketPriority.CONTROL,
appId,
Optional.empty());
}
示例14: cancelPacket
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Cancels ARP packet.
*/
private void cancelPacket() {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.ARP.ethType().toShort())
.build();
packetService.cancelPackets(
selector,
PacketPriority.CONTROL,
appId,
Optional.empty());
}
示例15: matchesControlTraffic
import org.onlab.packet.EthType; //导入依赖的package包/类
private boolean matchesControlTraffic(TrafficSelector selector) {
EthTypeCriterion c = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
if (c != null && c.ethType().equals(EthType.EtherType.ARP.ethType())) {
return true;
} else if (c != null && c.ethType().equals(EthType.EtherType.IPV6.ethType())) {
IPProtocolCriterion i = (IPProtocolCriterion) selector.getCriterion(Criterion.Type.IP_PROTO);
if (i != null && i.protocol() == PROTOCOL_ICMP6) {
Icmpv6TypeCriterion ic = (Icmpv6TypeCriterion) selector.getCriterion(Criterion.Type.ICMPV6_TYPE);
if (ic.icmpv6Type() != ECHO_REQUEST && ic.icmpv6Type() != ECHO_REPLY) {
return true;
}
}
}
return false;
}