当前位置: 首页>>代码示例>>Java>>正文


Java ByteArrays.validateBounds方法代码示例

本文整理汇总了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);
}
 
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:6,代码来源:Dot11ManagementFrame.java

示例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);
}
 
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:54,代码来源:AssociationResponseFrameHandler.java

示例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);
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:18,代码来源:CustomTcpSackOption.java

示例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);
}
 
开发者ID:Bpazy,项目名称:finalspeed,代码行数:18,代码来源:CustomTcpSackOption.java


注:本文中的org.pcap4j.util.ByteArrays.validateBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。