All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hbase.thirdparty.io.netty.handler.pcap.PcapHeaders Maven / Gradle / Ivy

Go to download

Pulls down netty.io, relocates nd then makes a fat new jar with them all in it.

The newest version!
/*
 * Copyright 2020 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package org.apache.hbase.thirdparty.io.netty.handler.pcap;

import org.apache.hbase.thirdparty.io.netty.buffer.ByteBuf;

import java.io.IOException;
import java.io.OutputStream;

final class PcapHeaders {

    /**
     * Pcap Global Header built from:
     * 
    *
  1. magic_number
  2. *
  3. version_major
  4. *
  5. version_minor
  6. *
  7. thiszone
  8. *
  9. sigfigs
  10. *
  11. snaplen
  12. *
  13. network
  14. *
*/ private static final byte[] GLOBAL_HEADER = {-95, -78, -61, -44, 0, 2, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 1}; private PcapHeaders() { // Prevent outside initialization } /** * Writes the Pcap Global Header to the provided {@code OutputStream} * * @param outputStream OutputStream where Pcap data will be written. * @throws IOException if there is an error writing to the {@code OutputStream} */ static void writeGlobalHeader(OutputStream outputStream) throws IOException { outputStream.write(GLOBAL_HEADER); } /** * Write Pcap Packet Header * * @param byteBuf ByteBuf where we'll write header data * @param ts_sec timestamp seconds * @param ts_usec timestamp microseconds * @param incl_len number of octets of packet saved in file * @param orig_len actual length of packet */ static void writePacketHeader(ByteBuf byteBuf, int ts_sec, int ts_usec, int incl_len, int orig_len) { byteBuf.writeInt(ts_sec); byteBuf.writeInt(ts_usec); byteBuf.writeInt(incl_len); byteBuf.writeInt(orig_len); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy