xref: /aosp_15_r20/external/tcpdump/cpack.h (revision 05b00f6010a2396e3db2409989fc67270046269f)
1*05b00f60SXin Li /*-
2*05b00f60SXin Li  * Copyright (c) 2003, 2004 David Young.  All rights reserved.
3*05b00f60SXin Li  *
4*05b00f60SXin Li  * Redistribution and use in source and binary forms, with or without
5*05b00f60SXin Li  * modification, are permitted provided that the following conditions
6*05b00f60SXin Li  * are met:
7*05b00f60SXin Li  * 1. Redistributions of source code must retain the above copyright
8*05b00f60SXin Li  *    notice, this list of conditions and the following disclaimer.
9*05b00f60SXin Li  * 2. Redistributions in binary form must reproduce the above copyright
10*05b00f60SXin Li  *    notice, this list of conditions and the following disclaimer in the
11*05b00f60SXin Li  *    documentation and/or other materials provided with the distribution.
12*05b00f60SXin Li  * 3. The name of David Young may not be used to endorse or promote
13*05b00f60SXin Li  *    products derived from this software without specific prior
14*05b00f60SXin Li  *    written permission.
15*05b00f60SXin Li  *
16*05b00f60SXin Li  * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
17*05b00f60SXin Li  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18*05b00f60SXin Li  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19*05b00f60SXin Li  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DAVID
20*05b00f60SXin Li  * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21*05b00f60SXin Li  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22*05b00f60SXin Li  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23*05b00f60SXin Li  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24*05b00f60SXin Li  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25*05b00f60SXin Li  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*05b00f60SXin Li  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
27*05b00f60SXin Li  * OF SUCH DAMAGE.
28*05b00f60SXin Li  */
29*05b00f60SXin Li 
30*05b00f60SXin Li #ifndef ND_CPACK_H
31*05b00f60SXin Li #define ND_CPACK_H
32*05b00f60SXin Li 
33*05b00f60SXin Li #include "netdissect.h"
34*05b00f60SXin Li 
35*05b00f60SXin Li struct cpack_state {
36*05b00f60SXin Li 	const uint8_t					*c_buf;
37*05b00f60SXin Li 	const uint8_t					*c_next;
38*05b00f60SXin Li 	size_t						 c_len;
39*05b00f60SXin Li };
40*05b00f60SXin Li 
41*05b00f60SXin Li int nd_cpack_init(struct cpack_state *, const uint8_t *, size_t);
42*05b00f60SXin Li 
43*05b00f60SXin Li int nd_cpack_uint8(netdissect_options *, struct cpack_state *, uint8_t *);
44*05b00f60SXin Li int nd_cpack_int8(netdissect_options *, struct cpack_state *, int8_t *);
45*05b00f60SXin Li int nd_cpack_uint16(netdissect_options *, struct cpack_state *, uint16_t *);
46*05b00f60SXin Li int nd_cpack_int16(netdissect_options *, struct cpack_state *, int16_t *);
47*05b00f60SXin Li int nd_cpack_uint32(netdissect_options *, struct cpack_state *, uint32_t *);
48*05b00f60SXin Li int nd_cpack_int32(netdissect_options *, struct cpack_state *, int32_t *);
49*05b00f60SXin Li int nd_cpack_uint64(netdissect_options *, struct cpack_state *, uint64_t *);
50*05b00f60SXin Li int nd_cpack_int64(netdissect_options *, struct cpack_state *, int64_t *);
51*05b00f60SXin Li 
52*05b00f60SXin Li const uint8_t *nd_cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment);
53*05b00f60SXin Li const uint8_t *nd_cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
54*05b00f60SXin Li 
55*05b00f60SXin Li extern int nd_cpack_advance(struct cpack_state *, const size_t);
56*05b00f60SXin Li 
57*05b00f60SXin Li #endif /* ND_CPACK_H */
58