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


Java PcapPacket.getByteArray方法代码示例

本文整理汇总了Java中org.jnetpcap.packet.PcapPacket.getByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java PcapPacket.getByteArray方法的具体用法?Java PcapPacket.getByteArray怎么用?Java PcapPacket.getByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jnetpcap.packet.PcapPacket的用法示例。


在下文中一共展示了PcapPacket.getByteArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * pseudonymize the packet as configured.
 *
 * @param packet the captured PcapPacket
 */
@Override
public void handle(PcapPacket packet) {
    //Copy the data.
    byte[] packetData = packet.getByteArray(0, packet.size());
    try {
        // If parsing fails the packet is not pseudonymized. This should logged at a lower level TODO PEF-77.
        // Packet should be discarded because pseudonymization is not guaranteed otherwise.
        final byte[] pseudopacketData  = _pseudonymizer.pseudonymize(packetData);
        PcapPacket copyPacket = new PcapPacket(packet.getCaptureHeader(), ByteBuffer.wrap(pseudopacketData));
        _pseudoDumper.dump(copyPacket);
    }
    catch (final IOException e) {
        logger.severe(e.getMessage());
    }
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:21,代码来源:PEFPseudonymizeDumper.java

示例2: handle

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * Handles the packets and writes the packet after modification with the metal library,
 * JNetPcap library and stores a reference file.
 *
 * @param packet the captured PcapPacket
 */
@Override
public void handle(PcapPacket packet) {
    _referenceDumper.dump(packet);

    byte[] packetData = packet.getByteArray(0, packet.size());
    try {
        final byte[] pseudopacketData  = _pseudonymizer.pseudonymize(packetData);
        PcapPacket copyPacket = new PcapPacket(packet.getCaptureHeader(), ByteBuffer.wrap(pseudopacketData));
        _metalDumper.dump(copyPacket);
    } catch (final IOException ioexc) {
        logger.severe("problem when pseudonymizing packets with the metal library");
    }
    _packetModifier.modifyPacket(packet);
    _jnetpcapDumper.dump(packet);
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:22,代码来源:TestPseudonymizerLibs.java

示例3: dissectSIB1

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
/**
 * parses a SIB1 packet for its MCC / MNC / TAC / CID
 * <p>
 * Some values have varying length and quantity, so the offset where
 * each value starts has to be calculated successively here. The plmnOffset-variable
 * keeps track of the current position in the bit-stream where we are currently operating.
 *
 * @param sib1
 * @return
 */
private Cell dissectSIB1(PcapPacket sib1) {

    byte[] sib1Bytes = sib1.getByteArray(DATA_OFFSET, sib1.size() - DATA_OFFSET);
    this.sib1BitSet = fromByteArrayReverse(sib1Bytes);
    boolean hasMncThreeDigits;
    int numberOfPLMMNs, mcc = 0, mnc = 0, tac, cid, digit1, digit2, digit3;

    plmnOffset = 6;
    numberOfPLMMNs = getValueFromOffset(3) + 1; // there are x + 1 items in the PLMN-identity list
    plmnOffset = 8;

    for (int i = 0; i < numberOfPLMMNs; i++) {
        //get MCC -> 3 digits of 4 bits
        plmnOffset += 2;
        digit1 = getValueFromOffset(4) * 100;
        digit2 = getValueFromOffset(4) * 10;
        digit3 = getValueFromOffset(4);
        mcc = digit1 + digit2 + digit3;

        hasMncThreeDigits = getValueFromOffset(1) == 1;
        //get MNC -> 2-3 digits of 4 bits
        digit1 = getValueFromOffset(4);
        digit2 = getValueFromOffset(4);

        if (hasMncThreeDigits) {
            digit1 *= 100;
            digit2 *= 10;
            digit3 = getValueFromOffset(4);
            mnc = digit1 + digit2 + digit3;
        } else {
            mnc = digit1 * 10 + digit2;
        }
    }

    // we reached the end of the plmn list, tac and cid start here
    plmnOffset = plmnOffset + 1; // (not sure what this offset does)
    tac = getValueFromOffset(16); // get tac -> integer of 16 bits
    cid = getValueFromOffset(28); // get cid -> integer of 28 bits

    return new Cell(mcc, mnc, tac, cid);
}
 
开发者ID:shreaker,项目名称:LTE-CellTracker,代码行数:52,代码来源:PcapParser.java

示例4: setUp

import org.jnetpcap.packet.PcapPacket; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
PcapPacket packet = getPcapPacket(L2TP, 0);

data = packet.getByteArray(0, packet.size());
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:7,代码来源:Bug2828030_wirelen_not_set_in_JMemoryPacket.java


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