#include "nufw.h"
#include <linux/netfilter.h>
#include <unistd.h>
#include <pthread.h>
#include <netdb.h>
#include <signal.h>
#include <syslog.h>
#include <errno.h>
#include <sys/types.h>
#include <nubase.h>
Include dependency graph for main.c:

Go to the source code of this file.
Defines | |
| #define | NUFW_PID_FILE LOCAL_STATE_DIR "/run/nufw.pid" |
Functions | |
| void | nufw_stop_thread () |
| void | nufw_prepare_quit () |
| void | nufw_hard_cleanup (int signal) |
| void | nufw_cleanup (int signal) |
| void | create_thread () |
| void | install_signals () |
| void | nufw_daemonize () |
| int | init_checks () |
| int | main (int argc, char *argv[]) |
Variables | |
| GCRY_THREAD_OPTION_PTHREAD_IMPL | |
| char * | key_file = NULL |
| char * | cert_file = NULL |
| nufw_threadtype | thread |
| nufw_signals | signals |
See function main().
Definition in file main.c.
| #define NUFW_PID_FILE LOCAL_STATE_DIR "/run/nufw.pid" |
Name of pid file prefixed by LOCAL_STATE_DIR (variable defined during compilation/installation)
Definition at line 57 of file main.c.
Referenced by nufw_daemonize(), and nufw_prepare_quit().
| void create_thread | ( | ) |
Create packet server thread: init mutex and create thread with packetsrv() function. Send pointer to thread to the function.
Definition at line 166 of file main.c.
References DEBUG_AREA_MAIN, DEBUG_LEVEL_FATAL, log_area_printf(), nufw_threadtype::mutex, packetsrv(), nufw_threadargument::parent_pid, nufw_threadtype::thread, thread, nufw_threadargument::thread, and tls.
Referenced by main().
Here is the call graph for this function:

| int init_checks | ( | ) |
| void install_signals | ( | ) |
Install signals:
Definition at line 209 of file main.c.
References DEBUG_AREA_MAIN, DEBUG_LEVEL_FATAL, DEBUG_LEVEL_WARNING, log_area_printf(), nufw_cleanup(), nufw_signals::old_sigint_hdl, nufw_signals::old_sigterm_hdl, process_hup(), process_poll(), process_usr1(), process_usr2(), and signals.
Here is the call graph for this function:

| int main | ( | int | argc, | |
| char * | argv[] | |||
| ) |
Main function of NuFW:
When NuFW is running, main loop and two threads (packetsrv() and authsrv()) and are running.
The most interresting things are done in the packet server (thread packetsrv()). The main loop just clean up old packets and display statistics.
Definition at line 385 of file main.c.
References nuauth_conn::auth_server_running, AUTHREQ_ADDR, authreq_addr, AUTHREQ_PORT, authreq_port, ca_file, cert_file, clean_old_packets(), create_thread(), crl_file, daemonize(), DEBUG_AREA_GW, DEBUG_AREA_MAIN, debug_areas, debug_level, DEBUG_LEVEL_CRITICAL, DEBUG_LEVEL_FATAL, DEBUG_LEVEL_VERBOSE_DEBUG, DEBUG_LEVEL_WARNING, DEFAULT_DEBUG_AREAS, DEFAULT_DEBUG_LEVEL, packets_list_t::end, init_checks(), init_log_engine(), install_signals(), key_file, packets_list_t::length, log_area_printf(), log_engine, LOG_TO_STD, nuauth_conn::mutex, packets_list_t::mutex, nuauth_cert_dn, nufw_daemonize(), nufw_no_ipv6, nufw_prepare_quit(), nufw_set_mark, nufw_stop_thread(), nufw_strict_tls, nussl_init(), NUSSL_OK, PACKET_TIMEOUT, packet_timeout, packets_list, pckt_rx, pckt_tx, process_poll(), raw_sock4, raw_sock6, SECURE_STRNCPY, nuauth_conn::session, packets_list_t::start, tls, tls_connect(), TRACK_SIZE, and track_size.
Here is the call graph for this function:

| void nufw_cleanup | ( | int | signal | ) |
Cleanup before leaving:
Definition at line 134 of file main.c.
References DEBUG_AREA_MAIN, DEBUG_LEVEL_FATAL, log_area_printf(), nufw_hard_cleanup(), nufw_prepare_quit(), and nufw_stop_thread().
Referenced by install_signals().
Here is the call graph for this function:

| void nufw_daemonize | ( | ) |
Daemonize current process.
Definition at line 280 of file main.c.
References DEBUG_LEVEL_FATAL, log_engine, log_printf(), LOG_TO_SYSLOG, and NUFW_PID_FILE.
Referenced by main().
Here is the call graph for this function:

| void nufw_hard_cleanup | ( | int | signal | ) |
"Hard" cleanup before leaving: called when SIGINT/SIGTERM is called twice. Don't wait for thread end.
Definition at line 113 of file main.c.
References DEBUG_AREA_MAIN, DEBUG_LEVEL_FATAL, log_area_printf(), nufw_prepare_quit(), nufw_signals::old_sigint_hdl, nufw_signals::old_sigterm_hdl, and signals.
Referenced by nufw_cleanup().
Here is the call graph for this function:

| void nufw_prepare_quit | ( | ) |
Clean mutex, memory, etc. before exiting NuFW
Definition at line 82 of file main.c.
References adr_srv, ca_file, cert_file, clear_packet_list(), close_tls_session(), crl_file, key_file, nuauth_conn::mutex, packets_list_t::mutex, NUFW_PID_FILE, packets_list, and tls.
Referenced by main(), nufw_cleanup(), and nufw_hard_cleanup().
Here is the call graph for this function:

| void nufw_stop_thread | ( | ) |
Stop threads and then wait until threads exit.
Definition at line 62 of file main.c.
References nuauth_conn::auth_server, nuauth_conn::auth_server_mutex, nuauth_conn::auth_server_running, DEBUG_AREA_MAIN, DEBUG_LEVEL_MESSAGE, log_area_printf(), nufw_threadtype::mutex, nufw_threadtype::thread, thread, and tls.
Referenced by main(), and nufw_cleanup().
Here is the call graph for this function:

| char* cert_file = NULL |
Certificatename used in TLS connection, default value: NULL
Definition at line 47 of file main.c.
Referenced by init_checks(), init_x509_filenames(), main(), nufw_prepare_quit(), and tls_connect().
| char* key_file = NULL |
Key filename used in TLS connection, default value: NULL
Definition at line 46 of file main.c.
Referenced by init_checks(), init_x509_filenames(), main(), nufw_prepare_quit(), and tls_connect().
| struct nufw_signals signals |
| struct nufw_threadtype thread |
Definition at line 50 of file main.c.
Referenced by create_thread(), nufw_stop_thread(), thread_destroy(), thread_new(), thread_new_wdata(), thread_stop(), thread_wait_end(), tls_nufw_authsrv(), and tls_user_authsrv().
1.4.7