1 | /* |
---|
2 | * |
---|
3 | * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand. |
---|
4 | * All rights reserved. |
---|
5 | * |
---|
6 | * This file is part of libtrace. |
---|
7 | * |
---|
8 | * This code has been developed by the University of Waikato WAND |
---|
9 | * research group. For further information please see http://www.wand.net.nz/ |
---|
10 | * |
---|
11 | * libtrace is free software; you can redistribute it and/or modify |
---|
12 | * it under the terms of the GNU Lesser General Public License as published by |
---|
13 | * the Free Software Foundation; either version 3 of the License, or |
---|
14 | * (at your option) any later version. |
---|
15 | * |
---|
16 | * libtrace is distributed in the hope that it will be useful, |
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | * GNU Lesser General Public License for more details. |
---|
20 | * |
---|
21 | * You should have received a copy of the GNU Lesser General Public License |
---|
22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
23 | * |
---|
24 | * |
---|
25 | */ |
---|
26 | /** @file |
---|
27 | * |
---|
28 | * @brief Header file containing definitions required to process DAG / ERF |
---|
29 | * traces |
---|
30 | * |
---|
31 | * @author Daniel Lawson |
---|
32 | * @author Perry Lorier |
---|
33 | * @author Shane Alcock |
---|
34 | * |
---|
35 | * @version $Id$ |
---|
36 | * |
---|
37 | * Most of the structures defined in here are already defined in the Endace DAG |
---|
38 | * libraries, but we need to re-define them ourselves here so that we can |
---|
39 | * process ERF traces without requiring the user to buy a DAG card :) |
---|
40 | */ |
---|
41 | #ifndef _DAGFORMAT_H_ |
---|
42 | #define _DAGFORMAT_H_ |
---|
43 | |
---|
44 | #include "libtrace.h" |
---|
45 | #include "erftypes.h" |
---|
46 | |
---|
47 | #ifdef WIN32 |
---|
48 | #pragma pack(push) |
---|
49 | #pragma pack(1) |
---|
50 | #endif |
---|
51 | |
---|
52 | /** GPP Type 1 */ |
---|
53 | typedef struct pos_rec { |
---|
54 | uint32_t hdlc; /**< The HDLC header */ |
---|
55 | uint8_t pload[1]; /**< First byte of payload */ |
---|
56 | } PACKED pos_rec_t; |
---|
57 | |
---|
58 | /** GPP Type 2 */ |
---|
59 | typedef struct eth_rec { |
---|
60 | uint8_t offset; /**< Ethernet record offset */ |
---|
61 | uint8_t pad; /**< Padding */ |
---|
62 | uint8_t dst[6]; /**< Destination MAC address */ |
---|
63 | uint8_t src[6]; /**< Source MAC address */ |
---|
64 | uint16_t etype; /**< Ethertype */ |
---|
65 | uint8_t pload[1]; /**< First byte of payload */ |
---|
66 | } PACKED eth_rec_t; |
---|
67 | |
---|
68 | /** GPP Type 3 */ |
---|
69 | typedef struct atm_rec { |
---|
70 | uint32_t header; /**< The ATM header */ |
---|
71 | uint8_t pload[1]; /**< First byte of payload */ |
---|
72 | } PACKED atm_rec_t; |
---|
73 | |
---|
74 | /** GPP Type 4 */ |
---|
75 | typedef struct aal5_rec { |
---|
76 | uint32_t header; /**< The AAL5 header */ |
---|
77 | uint8_t pload[1]; /**< First byte of payload */ |
---|
78 | } PACKED aal5_rec_t; |
---|
79 | |
---|
80 | /** Flags */ |
---|
81 | typedef struct flags { |
---|
82 | LT_BITFIELD8 iface:2; /**< Interface (direction) */ |
---|
83 | LT_BITFIELD8 vlen:1; /**< Varying Record Lengths Present */ |
---|
84 | LT_BITFIELD8 trunc:1; /**< Truncated Record */ |
---|
85 | LT_BITFIELD8 rxerror:1; /**< RX Error detected */ |
---|
86 | LT_BITFIELD8 dserror:1; /**< Data stream error */ |
---|
87 | LT_BITFIELD8 pad:2; /**< Unused */ |
---|
88 | } PACKED flags_t; |
---|
89 | |
---|
90 | /** GPP Global type */ |
---|
91 | typedef struct dag_record { |
---|
92 | uint64_t ts; /**< ERF timestamp */ |
---|
93 | uint8_t type; /**< GPP record type */ |
---|
94 | flags_t flags; /**< Flags */ |
---|
95 | uint16_t rlen; /**< Record len (capture+framing) */ |
---|
96 | uint16_t lctr; /**< Loss counter */ |
---|
97 | uint16_t wlen; /**< Wire length */ |
---|
98 | union { |
---|
99 | pos_rec_t pos; |
---|
100 | eth_rec_t eth; |
---|
101 | atm_rec_t atm; |
---|
102 | aal5_rec_t aal5; |
---|
103 | } rec; /**< The captured record itself */ |
---|
104 | } PACKED dag_record_t; |
---|
105 | |
---|
106 | #ifdef WIN32 |
---|
107 | #pragma pack(pop) |
---|
108 | #endif |
---|
109 | |
---|
110 | /** The size of the ERF record header, without the rec field */ |
---|
111 | #define dag_record_size 16U |
---|
112 | |
---|
113 | #endif /* _DAGFORMAT_H_ */ |
---|