1 /*-
2  * Copyright (c) 2001, 2005 Lev Walkin <vlm@lionet.info>.
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  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $Id: cfgvar.h,v 1.17 2005/03/22 17:55:14 vlm Exp $
27  */
28 #ifndef	__CFGVAR_H__
29 #define	__CFGVAR_H__
30 
31 #include "ipcad.h"
32 
33 /*
34  * IP networks aggregation list.
35  * This list implies linear scan, but should be fine for
36  * small number of aggregated networks.
37  */
38 struct atable {
39 	struct in_addr ip;
40 	struct in_addr mask;
41 	struct in_addr strip;
42 	struct atable *next;
43 	int strip_bits;
44 };
45 
46 /*
47  * Ports aggregation table.
48  */
49 extern int agr_portmap[65536];
50 
51 typedef struct config_s {
52 	uid_t set_uid;
53 	gid_t set_gid;
54 
55 	char *chroot_to;
56 	char *pidfile;
57 
58 	char *dump_table_file;	/* File to dump the table */
59 
60 	unsigned memsize;	/* Memory usage size */
61 	unsigned bufsize;	/* Capture buffers size */
62 
63 	int rsh_ttl;	/* Default IP TTL for RSH */
64 
65 	packet_source_t *packet_sources_head;
66 
67 	struct atable *atable;
68 
69 	int capture_ports;	/* Whether to display UDP/TCP ports */
70 
71 	int netflow_enabled;	/* Whether to perform NetFlow export */
72 	int netflow_version;
73 	int netflow_timeout_active;	/* Flow timeout, in seconds */
74 	int netflow_timeout_inactive;	/* Flow timeout, in seconds */
75 	int netflow_packet_interval;	/* Sampling mode, in packets */
76 	int netflow_engine_type;	/* v5 engine-type */
77 	int netflow_engine_id;		/* v5 engine-id */
78 } config_t;
79 
80 extern pthread_mutex_t packet_sources_list_lock;
81 
82 
83 /* Globally visible configuration */
84 extern config_t *conf;
85 
86 /*
87  * Run-time global variables
88  */
89 extern size_t used_memory;
90 
91 
92 /*
93  * Constructors used by the configuration reader.
94  */
95 
96 packet_source_t *cfg_add_iface(char *, int iflags, char *filter);
97 int cfg_add_rsh_host(char *ru, char *rh, int privlevel);
98 int cfg_check_rsh(char *ru, struct in_addr *);
99 
100 int cfg_add_atable(char *ip, char *mask, char *strip);
101 int cfg_add_aggregate_ports_table(int from, int to, int into);
102 
103 int cfg_add_ifclass_map(char *ifclass, int range_start, int range_stop);
104 int iface_to_snmp_id(const char *interface_name);
105 
106 
107 /*
108  * Misc methods.
109  */
110 
111 int make_dump(char *, FILE *);
112 int import_table(char *, FILE *, int clear);
113 
114 #endif	/* __CFGVAR_H__ */
115