/* pcapwriting.h
****************************************************************************************************************
****************************************************************************************************************

    Copyright (C) 2021 Askar Almatov

    This file is part of Trafficmeter.

    Trafficmeter is free software: you can redistribute it and/or modify it under the terms of the GNU General
    Public License as published by the Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    Trafficmeter is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
    implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
    License for more details.

    You should have received a copy of the GNU General Public License along with Trafficmeter. If not, see
    <http://www.gnu.org/licenses/>.
*/

#ifndef __PCAPWRITING_H
#define __PCAPWRITING_H 1

#include <cstdint>

#include "path.h"
#include "timestamp.h"

namespace trafficmeter
{
    /**********************************************************************************************************/
    class PcapWriting
    {
    public:
                                        PcapWriting( const Path& outputFile );
                                        ~PcapWriting();

        void                            writePacket( Timestamp timestamp, const uint8_t* data2, unsigned nBytes2 );
        void                            flush();
        bool                            isConsole() const;

    protected:
        int                             fd_;
        uint8_t*                        buffer_;
        uint8_t*                        cursor_;
    };
}

#endif  // __PCAPWRITING_H
