本文整理汇总了Java中org.pcap4j.packet.namednumber.EtherType.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java EtherType.getInstance方法的具体用法?Java EtherType.getInstance怎么用?Java EtherType.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pcap4j.packet.namednumber.EtherType
的用法示例。
在下文中一共展示了EtherType.getInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildPacket
import org.pcap4j.packet.namednumber.EtherType; //导入方法依赖的package包/类
/**
*
* @param builder
*/
public void buildPacket(AbstractPacket.AbstractBuilder builder) {
if (!this.type.equals(EtherType.getInstance((short) 0x0000))) {
// do nothing if type not 0x0000
} else if (builder == null) {
this.type = EtherType.getInstance((short) 0xFFFF);
} else {
this.type = EtherType.IPV4;
}
db = new Dot1qVlanTagPacket.Builder();
db.priority(priority)
.cfi(cfi)
.vid(vid)
.type(type)
.payloadBuilder(builder);
this.packet = db.build();
}
示例2: buildPacket
import org.pcap4j.packet.namednumber.EtherType; //导入方法依赖的package包/类
/**
*
* @param builder
*/
public void buildPacket(AbstractPacket.AbstractBuilder builder) {
if (builder == null) {
this.type = EtherType.getInstance((short) 0xFFFF);
}
ethernetBuilder = new EthernetPacket.Builder();
ethernetBuilder.dstAddr(dstAddr)
.srcAddr(srcAddr)
.type(type)
.payloadBuilder(builder);
byte[] pad;
if (builder == null || addPad) {
if (payload != null) {
String payloadString = payload.getPayloadType().getPadPayloadString(payload.getPayloadPattern(), 100000);
pad = new BigInteger(payloadString, 16).toByteArray();
} else {
pad = new byte[0];
}
ethernetBuilder.paddingAtBuild(false).pad(pad);
this.packet = ethernetBuilder.build();
fixPacketLength();
} else {
ethernetBuilder.paddingAtBuild(true);
this.packet = ethernetBuilder.build();
}
}
示例3: TrexVlanPacket
import org.pcap4j.packet.namednumber.EtherType; //导入方法依赖的package包/类
/**
*
*/
public TrexVlanPacket() {
this.priority = (byte) 0;
this.cfi = false;
this.vid = (short) 0;
this.type = EtherType.getInstance((short) 0x0000);
}
示例4: setType
import org.pcap4j.packet.namednumber.EtherType; //导入方法依赖的package包/类
/**
*
* @param type
*/
public void setType(short type) {
this.type = EtherType.getInstance(type);
}