本文整理汇总了Java中org.projectfloodlight.openflow.types.ArpOpcode类的典型用法代码示例。如果您正苦于以下问题:Java ArpOpcode类的具体用法?Java ArpOpcode怎么用?Java ArpOpcode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArpOpcode类属于org.projectfloodlight.openflow.types包,在下文中一共展示了ArpOpcode类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOpCode
import org.projectfloodlight.openflow.types.ArpOpcode; //导入依赖的package包/类
/**
* @return the opCode
*/
public ArpOpcode getOpCode() {
return opCode;
}
示例2: setOpCode
import org.projectfloodlight.openflow.types.ArpOpcode; //导入依赖的package包/类
/**
* @param opCode the opCode to set
*/
public ARP setOpCode(ArpOpcode opCode) {
this.opCode = opCode;
return this;
}
示例3: iterateArpFields
import org.projectfloodlight.openflow.types.ArpOpcode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void iterateArpFields() {
MacAddress macSrc = MacAddress.of("00:01:02:03:04:05");
MacAddress macDst = MacAddress.of("01:01:02:02:03:03");
IPv4Address ipSrc = IPv4Address.of("10.192.20.1");
IPv4Address ipDst = IPv4Address.of("10.192.20.2");
OFVersion version = factory.getVersion();
boolean supportsArpHardwareAddress = (version != OFVersion.OF_10) &&
(version != OFVersion.OF_11) && (version != OFVersion.OF_12);
int matchFieldCount = 4;
Match.Builder builder = factory.buildMatch();
builder.setExact(MatchField.ETH_TYPE, EthType.ARP)
.setExact(MatchField.ARP_OP, ArpOpcode.REPLY)
.setExact(MatchField.ARP_SPA, ipSrc)
.setExact(MatchField.ARP_TPA, ipDst);
if (supportsArpHardwareAddress) {
builder.setExact(MatchField.ARP_SHA, macSrc);
builder.setExact(MatchField.ARP_THA, macDst);
matchFieldCount += 2;
}
Match match = builder.build();
assertThat(Iterables.size(match.getMatchFields()), is(matchFieldCount));
for (MatchField<?> matchField: match.getMatchFields()) {
switch (matchField.id) {
case ETH_TYPE:
EthType ethType = match.get((MatchField<EthType>) matchField);
assertThat(ethType, is(EthType.ARP));
break;
case ARP_OP:
ArpOpcode opcode = match.get((MatchField<ArpOpcode>) matchField);
assertThat(opcode, is(ArpOpcode.REPLY));
break;
case ARP_SHA:
MacAddress mac = match.get((MatchField<MacAddress>) matchField);
assertThat(mac, is(macSrc));
break;
case ARP_THA:
mac = match.get((MatchField<MacAddress>) matchField);
assertThat(mac, is(macDst));
break;
case ARP_SPA:
IPv4Address ip = match.get((MatchField<IPv4Address>) matchField);
assertThat(ip, is(ipSrc));
break;
case ARP_TPA:
ip = match.get((MatchField<IPv4Address>) matchField);
assertThat(ip, is(ipDst));
break;
default:
fail("Unexpected match field returned from iterator");
}
}
}