-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcapture.h
More file actions
72 lines (61 loc) · 2.42 KB
/
Copy pathcapture.h
File metadata and controls
72 lines (61 loc) · 2.42 KB
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
/**
* libcap_utils - DPMI capture utilities
* Copyright (C) 2003-2013 (see AUTHORS)
*
* This program 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CAPUTILS_CAPTURE_H
#define CAPUTILS_CAPTURE_H
#include <caputils/picotime.h>
#include <caputils/file.h>
#include <stdint.h>
#include <netinet/if_ether.h>
#ifdef CAPUTILS_EXPORT
#pragma GCC visibility push(default)
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct ether_vlan_header{
uint8_t ether_dhost[ETH_ALEN]; /* destination eth addr */
uint8_t ether_shost[ETH_ALEN]; /* source ether addr */
uint16_t vlan_proto; /* vlan is present if field begins with 0x8100 */
uint16_t vlan_tci; /* vlan is present if field begins with 0x8100 */
uint16_t h_proto; /* Ethernet payload protocol */
} __attribute((packed));
// Capture Header. This header is attached to each packet that we keep, i.e. it matched a filter.
#define CAPHEAD_NICLEN 8
struct cap_header {
char nic[CAPHEAD_NICLEN]; // Identifies the CI where the frame was caught
char mampid[8]; // Identifies the MP where the frame was caught
timepico ts; // Identifies when the frame was caught
uint32_t len; // Identifies the lenght of the frame
uint32_t caplen; // Identifies how much of the frame that we find here
/* convenience accessor (since array size is 0 it won't affect sizeof) */
union {
char payload[0];
struct ethhdr ethhdr[0];
struct ether_vlan_header ethvlanhdr[0];
};
} __attribute((packed));
typedef struct cap_header cap_head;
typedef struct cap_header* caphead_t;
#ifdef CAPUTILS_EXPORT
#pragma GCC visibility pop
#endif
#ifdef __cplusplus
}
#endif
#endif /* CAPUTILS_CAPTURE_H */