1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2014 Jason King. All rights reserved.
14 */
15
16 #ifndef _PKT_IMPL_H
17 #define _PKT_IMPL_H
18
19 #include "pkt.h"
20 #include "ike.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 typedef enum pkt_walk_ret {
27 PKT_WALK_ERROR = -1,
28 PKT_WALK_OK = 0,
29 PKT_WALK_STOP = 1
30 } pkt_walk_ret_t;
31
32 typedef pkt_walk_ret_t (*pkt_walk_fn_t)(uint8_t, uint8_t, uchar_t *restrict,
33 size_t, void *restrict);
34 pkt_walk_ret_t pkt_payload_walk(uchar_t *restrict, size_t, pkt_walk_fn_t,
35 uint8_t, void *restrict);
36
37 boolean_t pkt_count_payloads(uchar_t *restrict, size_t, uint8_t, size_t *,
38 size_t *);
39 boolean_t pkt_index_payloads(pkt_t *, uchar_t *, size_t, uint8_t, size_t);
40 boolean_t pkt_size_index(pkt_t *, size_t, size_t);
41
42 pkt_t *pkt_in_alloc(uchar_t *, size_t);
43 pkt_t *pkt_out_alloc(uint64_t, uint64_t, uint8_t, uint8_t, uint32_t);
44 void pkt_free(pkt_t *);
45
46 void pkt_stack_push(pkt_t *restrict, pkt_stack_item_t, pkt_finish_fn,
47 uintptr_t);
48
49 boolean_t pkt_add_payload(pkt_t *, uint8_t, uint8_t);
50 boolean_t pkt_add_prop(pkt_t *, uint8_t, uint8_t, size_t, uint64_t);
51 boolean_t pkt_add_xform(pkt_t *, uint8_t, uint8_t);
52 boolean_t pkt_add_xform_attr_tv(pkt_t *, uint16_t, uint16_t);
53 boolean_t pkt_add_xform_attr_tlv(pkt_t *restrict, uint16_t,
54 const uchar_t *restrict, size_t);
55 boolean_t pkt_add_cert(pkt_t *restrict, uint8_t, const uchar_t *restrict,
56 size_t);
57
58 #ifdef __cplusplus
59 }
60 #endif
61
62 #endif /* _PKT_IMPL_H */