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