forked from Rup0rt/pcapfix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pcapfix.h
102 lines (88 loc) · 3.15 KB
/
pcapfix.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*******************************************************************************
*
* Copyright (c) 2012-2021 Robert Krause ([email protected])
*
* This file is part of Pcapfix.
*
* Pcapfix 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 any later version.
*
* Pcapfix 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
* Pcapfix. If not, see http://www.gnu.org/licenses/.
*
******************************************************************************/
#ifndef PF_PCAPFIX
#define PF_PCAPFIX
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <inttypes.h>
#ifdef __WIN32__
#include <Winsock.h> /* needed for htons,htonl on windows systems */
/* fseeko, ftello are unknown on mingw, use o64 instead */
#define fseeko fseeko64
#define ftello ftello64
/* compatibility for fixed size integer types on windows */
typedef uint8_t u_int8_t;
typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;
/* truncate does not exist under windows */
int truncate(const char *pathname, _off_t len);
#else
#include <libgen.h> /* needed for basename */
#include <arpa/inet.h> /* htons, htonl */
#endif
#define FMT_OFF_T "jd" /* printf format for 'off_t' type */
/*
* Function: conshort
* -------------------
* Convertes a short variable into correct byte order (if necessary)
* depending on the global -swapped- settings of pcap data.
*
* This function MUST encapsulate all variables that might be swapped!
*
* var: the variable that shall be converted into correct byte order
*
* returns: the variable in correct byte order
*
*/
unsigned short conshort(unsigned short var);
/*
* Function: conint
* -----------------
* Convertes an integer variable into correct byte order (if necessary)
* depending on the global -swapped- settings of pcap data.
*
* This function MUST encapsulate all variables that might be swapped!
*
* var: the variable that shall be converted into correct byte order
*
* returns: the variable in correct byte order
*
*/
unsigned int conint(unsigned int var);
/*
* Function: print_progress
* -------------------------
* prints the progess line when using pcapfix in non-verbose mode
*
* pos: the current filepointer position
* filesize: the size of the input pcap file in bytes
*
*/
void print_progress(off_t pos, off_t filesize);
/* global configuration variables */
extern int deep_scan; /* deep scan option (default: no depp scan) */
extern int verbose; /* verbose output option (default: dont be verbose) */
extern int swapped; /* pcap file is swapped (big endian) */
extern int data_link_type; /* data link type (default: LINKTYPE_ETHERNET) */
extern int soft_mode; /* soft plausibility check (default: OFF) */
#endif