Ethereal now requires 64-bit integer support, so get rid of the tests of
[metze/wireshark/wip.git] / wiretap / erf.h
1 /*
2 *
3 * Copyright (c) 2003 Endace Technology Ltd, Hamilton, New Zealand.
4 * All rights reserved.
5 *
6 * This software and documentation has been developed by Endace Technology Ltd.
7 * along with the DAG PCI network capture cards. For further information please
8 * visit http://www.endace.com/.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 *  1. Redistributions of source code must retain the above copyright notice,
14 *  this list of conditions and the following disclaimer.
15 *
16 *  2. Redistributions in binary form must reproduce the above copyright
17 *  notice, this list of conditions and the following disclaimer in the
18 *  documentation and/or other materials provided with the distribution.
19 *
20 *  3. The name of Endace Technology Ltd may not be used to endorse or promote
21 *  products derived from this software without specific prior written
22 *  permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY ENDACE TECHNOLOGY LTD ``AS IS'' AND ANY EXPRESS
25 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
27 * EVENT SHALL ENDACE TECHNOLOGY LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *
35 * $Id$
36 */
37
38 #ifndef __W_ERF_H__
39 #define __W_ERF_H__
40
41 /* Record type defines */
42 #define TYPE_LEGACY     0
43 #define TYPE_HDLC_POS   1
44 #define TYPE_ETH        2
45 #define TYPE_ATM        3
46 #define TYPE_AAL5       4
47
48  /*
49   * The timestamp is 64bit unsigned fixed point little-endian value with
50   * 32 bits for second and 32 bits for fraction.
51   */
52 typedef guint64 erf_timestamp_t;
53
54 typedef struct erf_record {
55         erf_timestamp_t ts;
56         guint8          type;
57         guint8          flags;
58         guint16         rlen;
59         guint16         lctr;
60         guint16         wlen;
61 } erf_header_t;
62
63 #define MAX_RECORD_LEN  0x10000 /* 64k */
64 #define RECORDS_FOR_ERF_CHECK   3
65 #define FCS_BITS        32
66
67 #ifndef min
68 #define min(a, b) ((a) > (b) ? (b) : (a))
69 #endif
70
71 /*
72  * ATM snaplength
73  */
74 #define ATM_SNAPLEN             48
75
76 /*
77  * Size of ATM payload 
78  */
79 #define ATM_SLEN(h, e)          ATM_SNAPLEN
80 #define ATM_WLEN(h, e)          ATM_SNAPLEN
81
82 /*
83  * Size of Ethernet payload
84  */
85 #define ETHERNET_WLEN(h, e)     (g_htons((h)->wlen))
86 #define ETHERNET_SLEN(h, e)     min(ETHERNET_WLEN(h, e), g_htons((h)->rlen) - sizeof(*(h)) - 2)
87
88 /*
89  * Size of HDLC payload
90  */
91 #define HDLC_WLEN(h, e)         (g_htons((h)->wlen))
92 #define HDLC_SLEN(h, e)         min(HDLC_WLEN(h, e), g_htons((h)->rlen) - sizeof(*(h)))
93
94 int erf_open(wtap *wth, int *err, gchar **err_info);
95
96 #endif /* __W_ERF_H__ */