本文整理汇总了Java中org.pcap4j.util.ByteArrays.getShort方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrays.getShort方法的具体用法?Java ByteArrays.getShort怎么用?Java ByteArrays.getShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pcap4j.util.ByteArrays
的用法示例。
在下文中一共展示了ByteArrays.getShort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import org.pcap4j.util.ByteArrays; //导入方法依赖的package包/类
public static short extract(byte[] payload, byte[] header) {
if(payload.length < DEAUTH_CONTENT_LENGTH+1) {
return -1;
}
byte[] reasonBytes = {
payload[DEAUTH_CONTENT_LENGTH],
payload[DEAUTH_CONTENT_LENGTH +1]
};
return ByteArrays.getShort(reasonBytes, 0, ByteOrder.LITTLE_ENDIAN);
}
示例2: handle
import org.pcap4j.util.ByteArrays; //导入方法依赖的package包/类
@Override
public void handle(byte[] payload, byte[] header, Dot11MetaInformation meta) throws IllegalRawDataException {
tick();
Dot11ManagementFrame associationResponse = Dot11ManagementFrame.newPacket(payload, 0, payload.length);
// Check bounds for response code field.
try {
ByteArrays.validateBounds(payload, 0, STATUS_CODE_POSITION+STATUS_CODE_LENGTH-1);
} catch(Exception e) {
malformed(meta);
LOG.trace("Payload out of bounds. (1) Ignoring.");
return;
}
// Parse the response code. 0 means success any other value means failure.
short responseCode = ByteArrays.getShort(new byte[]{payload[26], payload[27]}, 0, ByteOrder.LITTLE_ENDIAN);
if(responseCode < 0) {
LOG.trace("Invalid response code <{}>.", responseCode);
return;
}
String response = "refused";
if (responseCode == 0) {
response = "success";
}
String destination = "";
if(associationResponse.getHeader().getAddress1() != null) {
destination = associationResponse.getHeader().getAddress1().toString();
}
String transmitter = "";
if(associationResponse.getHeader().getAddress2() != null) {
transmitter = associationResponse.getHeader().getAddress2().toString();
}
String message = transmitter + " answered association request from " + destination
+ ". Response: " + response.toUpperCase() + " (" + responseCode + ")";
nzyme.notify(
new Notification(message, meta.getChannel())
.addField(FieldNames.TRANSMITTER, transmitter)
.addField(FieldNames.DESTINATION, destination)
.addField(FieldNames.RESPONSE_CODE, responseCode)
.addField(FieldNames.RESPONSE_STRING, response)
.addField(FieldNames.SUBTYPE, "assoc-resp"),
meta
);
LOG.debug(message);
}