2011-02-18 12:02:57 -06:00
|
|
|
/*
|
2011-03-06 07:11:08 -06:00
|
|
|
Copyright (C) 2011 Srivats P.
|
2011-02-18 12:02:57 -06:00
|
|
|
|
|
|
|
This file is part of "Ostinato"
|
|
|
|
|
|
|
|
This 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.
|
|
|
|
|
|
|
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
#ifndef _PCAP_FILE_FORMAT_H
|
|
|
|
#define _PCAP_FILE_FORMAT_H
|
|
|
|
|
2011-03-13 12:06:33 -05:00
|
|
|
#include "abstractfileformat.h"
|
2011-03-19 01:18:58 -05:00
|
|
|
#include "ui_pcapfileimport.h"
|
2011-02-18 12:02:57 -06:00
|
|
|
|
2011-03-06 07:11:08 -06:00
|
|
|
#include <QDataStream>
|
2011-03-19 01:18:58 -05:00
|
|
|
#include <QVariantMap>
|
|
|
|
|
|
|
|
class PcapImportOptionsDialog: public QDialog, public Ui::PcapFileImport
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PcapImportOptionsDialog(QVariantMap *options);
|
|
|
|
~PcapImportOptionsDialog();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void accept();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QVariantMap *options_;
|
|
|
|
};
|
2011-02-18 12:02:57 -06:00
|
|
|
|
2011-03-06 07:11:08 -06:00
|
|
|
class PdmlReader;
|
2011-03-13 12:06:33 -05:00
|
|
|
class PcapFileFormat : public AbstractFileFormat
|
2011-02-18 12:02:57 -06:00
|
|
|
{
|
2011-03-06 07:11:08 -06:00
|
|
|
friend class PdmlReader;
|
|
|
|
|
2011-02-18 12:02:57 -06:00
|
|
|
public:
|
|
|
|
PcapFileFormat();
|
|
|
|
~PcapFileFormat();
|
|
|
|
|
|
|
|
bool openStreams(const QString fileName,
|
|
|
|
OstProto::StreamConfigList &streams, QString &error);
|
|
|
|
bool saveStreams(const OstProto::StreamConfigList streams,
|
|
|
|
const QString fileName, QString &error);
|
2011-03-06 07:11:08 -06:00
|
|
|
|
2011-03-19 01:18:58 -05:00
|
|
|
virtual QDialog* openOptionsDialog();
|
|
|
|
|
2011-03-13 12:06:33 -05:00
|
|
|
bool isMyFileFormat(const QString fileName);
|
|
|
|
bool isMyFileType(const QString fileType);
|
|
|
|
|
2011-03-06 07:11:08 -06:00
|
|
|
private:
|
|
|
|
typedef struct {
|
|
|
|
quint32 magicNumber; /* magic number */
|
|
|
|
quint16 versionMajor; /* major version number */
|
|
|
|
quint16 versionMinor; /* minor version number */
|
|
|
|
qint32 thisZone; /* GMT to local correction */
|
|
|
|
quint32 sigfigs; /* accuracy of timestamps */
|
|
|
|
quint32 snapLen; /* max length of captured packets, in octets */
|
|
|
|
quint32 network; /* data link type */
|
|
|
|
} PcapFileHeader;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
quint32 tsSec; /* timestamp seconds */
|
|
|
|
quint32 tsUsec; /* timestamp microseconds */
|
|
|
|
quint32 inclLen; /* number of octets of packet saved in file */
|
|
|
|
quint32 origLen; /* actual length of packet */
|
|
|
|
} PcapPacketHeader;
|
|
|
|
|
|
|
|
bool readPacket(PcapPacketHeader &pktHdr, QByteArray &pktBuf);
|
|
|
|
|
|
|
|
QDataStream fd_;
|
2011-03-19 01:18:58 -05:00
|
|
|
QVariantMap importOptions_;
|
|
|
|
PcapImportOptionsDialog *importDialog_;
|
2011-02-18 12:02:57 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
extern PcapFileFormat pcapFileFormat;
|
|
|
|
|
|
|
|
#endif
|