1 /*
2  * Copyright (c) 2016-2021, OARC, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in
14  *    the documentation and/or other materials provided with the
15  *    distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #include <sys/types.h>
36 
37 #include "dump_cds.h"
38 
39 #ifndef __dnscap_options_h
40 #define __dnscap_options_h
41 
42 typedef enum dump_format dump_format_t;
43 enum dump_format {
44     pcap,
45     cbor,
46     cds
47 };
48 
49 /* clang-format off */
50 
51 #define OPTIONS_T_DEFAULTS { \
52     1024 * 1024, \
53 \
54     1024 * 1024, \
55     64 * 1024, \
56     CDS_DEFAULT_MAX_RLABELS, \
57     CDS_DEFAULT_MIN_RLABEL_SIZE, \
58     0, \
59     CDS_DEFAULT_RDATA_INDEX_MIN_SIZE, \
60     0, \
61     CDS_DEFAULT_RDATA_RINDEX_SIZE, \
62     CDS_DEFAULT_RDATA_RINDEX_MIN_SIZE, \
63 \
64     pcap, \
65 \
66     0, \
67     0, \
68 \
69     0, \
70 \
71     0, 0, 0, 0, 0, 0, 0, \
72 \
73     0, 0, 0, 0, 0, \
74 \
75     0 \
76 }
77 
78 /* clang-format on */
79 
80 typedef struct options options_t;
81 struct options {
82     size_t cbor_chunk_size;
83 
84     size_t cds_cbor_size;
85     size_t cds_message_size;
86     size_t cds_max_rlabels;
87     size_t cds_min_rlabel_size;
88     int    cds_use_rdata_index;
89     size_t cds_rdata_index_min_size;
90     int    cds_use_rdata_rindex;
91     size_t cds_rdata_rindex_size;
92     size_t cds_rdata_rindex_min_size;
93 
94     dump_format_t dump_format;
95 
96     char* user;
97     char* group;
98 
99     size_t pcap_buffer_size;
100 
101     int    use_layers;
102     int    defrag_ipv4;
103     size_t max_ipv4_fragments;
104     size_t max_ipv4_fragments_per_packet;
105     int    defrag_ipv6;
106     size_t max_ipv6_fragments;
107     size_t max_ipv6_fragments_per_packet;
108 
109     int    parse_ongoing_tcp;
110     int    allow_reset_tcpstate;
111     int    reassemble_tcp;
112     size_t reassemble_tcp_faultreset;
113     int    reassemble_tcp_bfbparsedns;
114 
115     int bpf_hosts_apply_all;
116 };
117 
118 int  option_parse(options_t* options, const char* option);
119 void options_free(options_t* options);
120 
121 #endif /* __dnscap_options_h */
122