本文整理汇总了Java中org.pcap4j.util.ByteArrays.validateBounds方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrays.validateBounds方法的具体用法?Java ByteArrays.validateBounds怎么用?Java ByteArrays.validateBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pcap4j.util.ByteArrays
的用法示例。
在下文中一共展示了ByteArrays.validateBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newPacket
import org.pcap4j.util.ByteArrays; //导入方法依赖的package包/类
public static Dot11ManagementFrame newPacket(byte[] rawData, int offset, int length) throws IllegalRawDataException {
ByteArrays.validateBounds(rawData, offset, length);
Dot11ManagementFrame.Dot11ManagementFrameHeader h = new Dot11ManagementFrame.Dot11ManagementFrameHeader(rawData, offset, length);
return new Dot11ManagementFrame(rawData, offset, length, h);
}
示例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);
}
示例3: newInstance
import org.pcap4j.util.ByteArrays; //导入方法依赖的package包/类
/**
* A static factory method.
* This method validates the arguments by {@link ByteArrays#validateBounds(byte[], int, int)},
* which may throw exceptions undocumented here.
*
* @param rawData rawData
* @param offset offset
* @param length length
* @return a new TcpSackOption object.
* @throws IllegalRawDataException if parsing the raw data fails.
*/
public static CustomTcpSackOption newInstance(
byte[] rawData, int offset, int length
) throws IllegalRawDataException {
ByteArrays.validateBounds(rawData, offset, length);
return new CustomTcpSackOption(rawData, offset, length);
}
示例4: newInstance
import org.pcap4j.util.ByteArrays; //导入方法依赖的package包/类
/**
* A static factory method.
* This method validates the arguments by {@link ByteArrays#validateBounds(byte[], int, int)},
* which may throw exceptions undocumented here.
*
* @param rawData rawData
* @param offset offset
* @param length length
* @return a new TcpSackOption object.
* @throws IllegalRawDataException if parsing the raw data fails.
*/
public static CustomTcpSackOption newInstance(
byte[] rawData, int offset, int length
) throws IllegalRawDataException {
ByteArrays.validateBounds(rawData, offset, length);
return new CustomTcpSackOption(rawData, offset, length);
}