xref: /dflybsd-src/contrib/tcpdump/cpack.h (revision 59c07fbdf8168fa08c76c515186d561b5a92690c)
141c99275SPeter Avalos /*-
241c99275SPeter Avalos  * Copyright (c) 2003, 2004 David Young.  All rights reserved.
341c99275SPeter Avalos  *
441c99275SPeter Avalos  * Redistribution and use in source and binary forms, with or without
541c99275SPeter Avalos  * modification, are permitted provided that the following conditions
641c99275SPeter Avalos  * are met:
741c99275SPeter Avalos  * 1. Redistributions of source code must retain the above copyright
841c99275SPeter Avalos  *    notice, this list of conditions and the following disclaimer.
941c99275SPeter Avalos  * 2. Redistributions in binary form must reproduce the above copyright
1041c99275SPeter Avalos  *    notice, this list of conditions and the following disclaimer in the
1141c99275SPeter Avalos  *    documentation and/or other materials provided with the distribution.
1241c99275SPeter Avalos  * 3. The name of David Young may not be used to endorse or promote
1341c99275SPeter Avalos  *    products derived from this software without specific prior
1441c99275SPeter Avalos  *    written permission.
1541c99275SPeter Avalos  *
1641c99275SPeter Avalos  * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
1741c99275SPeter Avalos  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1841c99275SPeter Avalos  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
1941c99275SPeter Avalos  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DAVID
2041c99275SPeter Avalos  * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2141c99275SPeter Avalos  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
2241c99275SPeter Avalos  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2341c99275SPeter Avalos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2441c99275SPeter Avalos  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2541c99275SPeter Avalos  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2641c99275SPeter Avalos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
2741c99275SPeter Avalos  * OF SUCH DAMAGE.
2841c99275SPeter Avalos  */
2941c99275SPeter Avalos 
30*ed775ee7SAntonio Huete Jimenez #ifndef ND_CPACK_H
31*ed775ee7SAntonio Huete Jimenez #define ND_CPACK_H
32*ed775ee7SAntonio Huete Jimenez 
33*ed775ee7SAntonio Huete Jimenez #include "netdissect.h"
3441c99275SPeter Avalos 
3541c99275SPeter Avalos struct cpack_state {
36411677aeSAaron LI 	const uint8_t					*c_buf;
37411677aeSAaron LI 	const uint8_t					*c_next;
3841c99275SPeter Avalos 	size_t						 c_len;
3941c99275SPeter Avalos };
4041c99275SPeter Avalos 
41*ed775ee7SAntonio Huete Jimenez int nd_cpack_init(struct cpack_state *, const uint8_t *, size_t);
4241c99275SPeter Avalos 
43*ed775ee7SAntonio Huete Jimenez int nd_cpack_uint8(netdissect_options *, struct cpack_state *, uint8_t *);
44*ed775ee7SAntonio Huete Jimenez int nd_cpack_int8(netdissect_options *, struct cpack_state *, int8_t *);
45*ed775ee7SAntonio Huete Jimenez int nd_cpack_uint16(netdissect_options *, struct cpack_state *, uint16_t *);
46*ed775ee7SAntonio Huete Jimenez int nd_cpack_int16(netdissect_options *, struct cpack_state *, int16_t *);
47*ed775ee7SAntonio Huete Jimenez int nd_cpack_uint32(netdissect_options *, struct cpack_state *, uint32_t *);
48*ed775ee7SAntonio Huete Jimenez int nd_cpack_int32(netdissect_options *, struct cpack_state *, int32_t *);
49*ed775ee7SAntonio Huete Jimenez int nd_cpack_uint64(netdissect_options *, struct cpack_state *, uint64_t *);
50*ed775ee7SAntonio Huete Jimenez int nd_cpack_int64(netdissect_options *, struct cpack_state *, int64_t *);
5141c99275SPeter Avalos 
52*ed775ee7SAntonio Huete Jimenez const uint8_t *nd_cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment);
53*ed775ee7SAntonio Huete Jimenez const uint8_t *nd_cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
5427bfbee1SPeter Avalos 
55*ed775ee7SAntonio Huete Jimenez extern int nd_cpack_advance(struct cpack_state *, const size_t);
56411677aeSAaron LI 
57*ed775ee7SAntonio Huete Jimenez #endif /* ND_CPACK_H */
58