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


Java ByteArrays.getShort方法代码示例

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


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