本文整理汇总了Java中org.onlab.packet.EthType类的典型用法代码示例。如果您正苦于以下问题:Java EthType类的具体用法?Java EthType怎么用?Java EthType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EthType类属于org.onlab.packet包,在下文中一共展示了EthType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:ControlPlaneRedirectManager.java
示例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));
}
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:FlowRuleCodecTest.java
示例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);
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:EvpnManager.java
示例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));
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:21,代码来源:TroubleshootManagerTest.java
示例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;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:32,代码来源:MQUtil.java
示例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())));
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:OpenstackRoutingArpHandler.java
示例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)));
}
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:CriteriaTest.java
示例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));
}
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:InstructionsTest.java
示例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));
}
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:InstructionsTest.java
示例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));
}
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:InstructionsTest.java
示例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));
}
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:InstructionsTest.java
示例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();
}
}
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:MplsPathIntentCompiler.java
示例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());
}
开发者ID:opencord,项目名称:vtn,代码行数:15,代码来源:CordVtnArpProxy.java
示例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());
}
开发者ID:opencord,项目名称:vtn,代码行数:15,代码来源:CordVtnArpProxy.java
示例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;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:16,代码来源:SoftRouterPipeline.java
示例16: fromEtherType
import org.onlab.packet.EthType; //导入依赖的package包/类
public static TagType fromEtherType(EthType.EtherType type) {
for (TagType tt:values()) {
if (tt.type.equals(type)) {
return tt;
}
}
throw new IllegalArgumentException("Unsupported EtherType: " + type);
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:9,代码来源:Component.java
示例17: updateOspfForwarding
import org.onlab.packet.EthType; //导入依赖的package包/类
/**
* Installs or removes OSPF forwarding rules.
*
* @param request provisioning request containing router and interface
* @param install true to create an add objective, false to create a remove
* objective
*/
private void updateOspfForwarding(InterfaceProvisionRequest request, boolean install) {
// TODO IPv6 support has not been implemented yet
Interface intf = request.intf();
log.debug("{} OSPF flows for {}", operation(install), intf);
// 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 = intf.connectPoint().deviceId();
PortNumber controlPlanePort = request.controlPlaneConnectPoint().port();
int cpNextId;
if (intf.vlan() == VlanId.NONE) {
cpNextId = modifyNextObjective(deviceId, controlPlanePort,
VlanId.vlanId(ASSIGNED_VLAN),
true, install);
} else {
cpNextId = modifyNextObjective(deviceId, controlPlanePort,
intf.vlan(), false, install);
}
flowObjectiveService.forward(intf.connectPoint().deviceId(),
buildForwardingObjective(toSelector, null, cpNextId,
install ? request.info().ospfEnabled() : install, ACL_PRIORITY));
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:37,代码来源:ControlPlaneRedirectManager.java
示例18: enable
import org.onlab.packet.EthType; //导入依赖的package包/类
private void enable() {
hostService.addListener(hostListener);
packetService.addProcessor(packetProcessor, PacketProcessor.director(3));
// Requests packets for IPv4 traffic.
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.IPV4.ethType().toShort()).build();
packetService.requestPackets(selector, PacketPriority.REACTIVE, appId, Optional.empty());
// Requests packets for IPv6 traffic.
selector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.IPV6.ethType().toShort()).build();
packetService.requestPackets(selector, PacketPriority.REACTIVE, appId, Optional.empty());
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:13,代码来源:DirectHostManager.java
示例19: disable
import org.onlab.packet.EthType; //导入依赖的package包/类
private void disable() {
packetService.removeProcessor(packetProcessor);
hostService.removeListener(hostListener);
// Withdraws IPv4 request.
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.IPV4.ethType().toShort()).build();
packetService.cancelPackets(selector, PacketPriority.REACTIVE, appId, Optional.empty());
// Withdraws IPv6 request.
selector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.IPV6.ethType().toShort()).build();
packetService.cancelPackets(selector, PacketPriority.REACTIVE, appId, Optional.empty());
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:13,代码来源:DirectHostManager.java
示例20: requestPacket
import org.onlab.packet.EthType; //导入依赖的package包/类
private void requestPacket() {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.ARP.ethType().toShort())
.build();
packetService.requestPackets(
selector,
PacketPriority.CONTROL,
appId);
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:11,代码来源:OpenstackSwitchingArpHandler.java
注:本文中的org.onlab.packet.EthType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论