1 /*
2  * Tunnel SIE data from an SRA or RAD server.
3  *
4  *  Copyright (c) 2014-2018 by Farsight Security, Inc.
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  */
18 
19 #ifndef SRATUNNEL_H
20 #define SRATUNNEL_H
21 
22 #include <config.h>
23 #include <axa/client.h>
24 #include <axa/client_config.h>
25 #include <axa/axa_endian.h>
26 #include <axa/fields.h>
27 #include <axa/open_nmsg_out.h>
28 #include <axa/mdb.h>
29 
30 #include <nmsg.h>
31 #include <nmsg/base/defs.h>
32 #include <nmsg/base/packet.pb-c.h>
33 
34 #include <net/ethernet.h>
35 #ifdef __linux
36 #include <netinet/ether.h>
37 #include <bsd/string.h>
38 #endif
39 #include <errno.h>
40 #include <fcntl.h>
41 #include <signal.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <sysexits.h>
45 #include <sys/stat.h>
46 #include <unistd.h>
47 
48 #include <lmdb.h>
49 
50 #define OUT_FLUSH_MS    10		/* flush output this often */
51 
52 typedef struct arg arg_t;
53 struct arg {
54 	arg_t           *next;
55 	const char      *c;
56 };
57 
58 typedef enum {
59 	SRA,
60 	RAD
61 } axa_mode_t;
62 
63 /* forward.c */
64 void forward(void);
65 
66 /* main.c */
67 void stop(int s) AXA_NORETURN;
68 
69 /* output.c */
70 bool out_open(bool);
71 void out_close(void);
72 void out_flush(void);
73 void out_whit_nmsg(axa_p_whit_t *whit, size_t whit_len);
74 void out_whit_pcap(axa_p_whit_t *whit, size_t whit_len);
75 
76 /* pidfile.c */
77 FILE *pidfile_open(void);
78 void pidfile_write(void);
79 
80 /* print.c */
81 void print_op(bool always, bool sent, const axa_p_hdr_t *hdr, const void *body);
82 void print_bad_op(const char *adj);
83 void print_trace(void);
84 void print_missed(void);
85 
86 /* server.c */
87 void disconnect(bool complain, const char *p, ...) AXA_PF(2,3);
88 void srvr_connect(void);
89 bool srvr_send(axa_tag_t tag, axa_p_op_t op, const void *b, size_t b_len);
90 
91 /* signal.c */
92 void sigterm(int sig);
93 
94 #ifdef SIGINFO
95 void siginfo(int);
96 #endif
97 
98 #endif /* SRATUNNEL_H */
99