OpenVPN
|
Go to the source code of this file.
Macros | |
#define | ERR_BUF_SIZE 10240 |
#define | OPENVPN_MSG_FP stdout |
#define | OPENVPN_ERROR_FP stderr |
#define | OPENVPN_EXIT_STATUS_GOOD 0 |
#define | OPENVPN_EXIT_STATUS_ERROR 1 |
#define | OPENVPN_EXIT_STATUS_USAGE 1 |
#define | OPENVPN_EXIT_STATUS_CANNOT_OPEN_DEBUG_FILE 1 |
#define | OPENVPN_DEBUG_FILE PACKAGE ".log" |
#define | openvpn_errno() GetLastError() |
#define | M_DEBUG_LEVEL (0x0F) /* debug level mask */ |
#define | M_FATAL (1<<4) /* exit program */ |
#define | M_NONFATAL (1<<5) /* non-fatal error */ |
#define | M_WARN (1<<6) /* call syslog with LOG_WARNING */ |
#define | M_DEBUG (1<<7) |
#define | M_ERRNO (1<<8) /* show errno description */ |
#define | M_NOMUTE (1<<11) /* don't do mute processing */ |
#define | M_NOPREFIX (1<<12) /* don't show date/time prefix */ |
#define | M_USAGE_SMALL (1<<13) /* fatal options error, call usage_small */ |
#define | M_MSG_VIRT_OUT (1<<14) /* output message through msg_status_output callback */ |
#define | M_OPTERR (1<<15) /* print "Options error:" prefix */ |
#define | M_NOLF (1<<16) /* don't print new line */ |
#define | M_NOIPREFIX (1<<17) /* don't print instance prefix */ |
#define | M_ERR (M_FATAL | M_ERRNO) |
#define | M_USAGE (M_USAGE_SMALL | M_NOPREFIX | M_OPTERR) |
#define | M_CLIENT (M_MSG_VIRT_OUT | M_NOMUTE | M_NOIPREFIX) |
#define | MUTE_LEVEL_SHIFT 24 |
#define | MUTE_LEVEL_MASK 0xFF |
#define | ENCODE_MUTE_LEVEL(mute_level) (((mute_level) & MUTE_LEVEL_MASK) << MUTE_LEVEL_SHIFT) |
#define | DECODE_MUTE_LEVEL(flags) (((flags) >> MUTE_LEVEL_SHIFT) & MUTE_LEVEL_MASK) |
#define | LOGLEV(log_level, mute_level, other) ((log_level) | ENCODE_MUTE_LEVEL(mute_level) | other) |
#define | EXIT_FATAL(flags) do { if ((flags) & M_FATAL) {_exit(1);}} while (false) |
#define | msg(flags, ...) do { if (msg_test(flags)) {x_msg((flags), __VA_ARGS__);} EXIT_FATAL(flags); } while (false) |
#define | dmsg(flags, ...) |
#define | SDL_CONSTRAIN (1<<0) |
#define | ASSERT(x) do { if (!(x)) {assert_failed(__FILE__, __LINE__, #x);}} while (false) |
#define | static_assert(expr, diagnostic) |
Functions | |
const char * | strerror_win32 (DWORD errnum, struct gc_arena *gc) |
bool | dont_mute (unsigned int flags) |
Check muting filter. More... | |
void | x_msg (const unsigned int flags, const char *format,...) |
void | x_msg_va (const unsigned int flags, const char *format, va_list arglist) |
void | error_reset (void) |
void | errors_to_stderr (void) |
void | set_suppress_timestamps (bool suppressed) |
void | set_machine_readable_output (bool parsable) |
bool | set_debug_level (const int level, const unsigned int flags) |
bool | set_mute_cutoff (const int cutoff) |
int | get_debug_level (void) |
int | get_mute_cutoff (void) |
const char * | msg_flags_string (const unsigned int flags, struct gc_arena *gc) |
FILE * | msg_fp (const unsigned int flags) |
void | assert_failed (const char *filename, int line, const char *condition) __attribute__((__noreturn__)) |
static bool | check_debug_level (unsigned int level) |
static bool | msg_test (unsigned int flags) |
Return true if flags represent an enabled, not muted log level. More... | |
void | msg_forked (void) |
void | open_syslog (const char *pgmname, bool stdio_to_null) |
void | close_syslog (void) |
void | redirect_stdout_stderr (const char *file, bool append) |
int | get_orig_stderr (void) |
void | openvpn_exit (const int status) |
void | out_of_memory (void) |
void | reset_check_status (void) |
void | set_check_status (unsigned int info_level, unsigned int verbose_level) |
void | x_check_status (int status, const char *description, struct link_socket *sock, struct tuntap *tt) |
static void | check_status (int status, const char *description, struct link_socket *sock, struct tuntap *tt) |
static void | set_check_status_error_delay (unsigned int milliseconds) |
void | msg_thread_init (void) |
void | msg_thread_uninit (void) |
static void | msg_set_prefix (const char *prefix) |
static const char * | msg_get_prefix (void) |
static void | msg_set_virtual_output (const struct virtual_output *vo) |
static const struct virtual_output * | msg_get_virtual_output (void) |
static bool | ignore_sys_error (const int err, bool crt_error) |
static unsigned int | nonfatal (const unsigned int err) |
Convert fatal errors to nonfatal, don't touch other errors. More... | |
static int | openvpn_errno_maybe_crt (bool *crt_error) |
Variables | |
unsigned int | x_debug_level |
int | x_msg_line_num |
unsigned int | x_cs_info_level |
unsigned int | x_cs_verbose_level |
unsigned int | x_cs_err_delay_ms |
const char * | x_msg_prefix |
const struct virtual_output * | x_msg_virtual_output |
#define ASSERT | ( | x | ) | do { if (!(x)) {assert_failed(__FILE__, __LINE__, #x);}} while (false) |
#define DECODE_MUTE_LEVEL | ( | flags | ) | (((flags) >> MUTE_LEVEL_SHIFT) & MUTE_LEVEL_MASK) |
#define ENCODE_MUTE_LEVEL | ( | mute_level | ) | (((mute_level) & MUTE_LEVEL_MASK) << MUTE_LEVEL_SHIFT) |
#define EXIT_FATAL | ( | flags | ) | do { if ((flags) & M_FATAL) {_exit(1);}} while (false) |
#define LOGLEV | ( | log_level, | |
mute_level, | |||
other | |||
) | ((log_level) | ENCODE_MUTE_LEVEL(mute_level) | other) |
#define M_CLIENT (M_MSG_VIRT_OUT | M_NOMUTE | M_NOIPREFIX) |
#define M_MSG_VIRT_OUT (1<<14) /* output message through msg_status_output callback */ |
#define M_NOIPREFIX (1<<17) /* don't print instance prefix */ |
#define M_OPTERR (1<<15) /* print "Options error:" prefix */ |
#define M_USAGE (M_USAGE_SMALL | M_NOPREFIX | M_OPTERR) |
#define M_USAGE_SMALL (1<<13) /* fatal options error, call usage_small */ |
#define msg | ( | flags, | |
... | |||
) | do { if (msg_test(flags)) {x_msg((flags), __VA_ARGS__);} EXIT_FATAL(flags); } while (false) |
#define static_assert | ( | expr, | |
diagnostic | |||
) |
void assert_failed | ( | const char * | filename, |
int | line, | ||
const char * | condition | ||
) |
|
inlinestatic |
Definition at line 220 of file error.h.
References M_DEBUG_LEVEL, and x_debug_level.
Referenced by check_status(), client_nat_transform(), crypto_print_openssl_errors(), do_route(), env_set_print(), init_verb_mute(), io_wait_dowork(), mroute_helper_regenerate(), msg_test(), multi_get_create_instance_udp(), multi_get_instance_by_virtual_addr(), multi_instance_string(), packet_id_debug(), plugin_show_args_env(), pre_select(), sanitize_control_message(), schedule_add_modify(), schedule_find_least(), session_move_active(), we_wait(), and x_msg_va().
|
inlinestatic |
Definition at line 277 of file error.h.
References check_debug_level(), status, x_check_status(), and x_cs_verbose_level.
Referenced by io_wait_dowork(), process_outgoing_link(), process_outgoing_tun(), read_incoming_link(), and read_incoming_tun().
void close_syslog | ( | void | ) |
bool dont_mute | ( | unsigned int | flags | ) |
void error_reset | ( | void | ) |
Definition at line 161 of file error.c.
References default_err, default_out, machine_readable_output, msgfp, mute_category, mute_count, mute_cutoff, OPENVPN_DEBUG_FILE, openvpn_exit(), OPENVPN_EXIT_STATUS_CANNOT_OPEN_DEBUG_FILE, OPENVPN_MSG_FP, std_redir, suppress_timestamps, use_syslog, and x_debug_level.
Referenced by init_static().
void errors_to_stderr | ( | void | ) |
Definition at line 185 of file error.c.
References default_err, and OPENVPN_ERROR_FP.
Referenced by add_option().
int get_debug_level | ( | void | ) |
Definition at line 137 of file error.c.
References x_debug_level.
Referenced by man_dispatch_command().
int get_mute_cutoff | ( | void | ) |
Definition at line 143 of file error.c.
References mute_cutoff.
Referenced by man_dispatch_command().
int get_orig_stderr | ( | void | ) |
Definition at line 508 of file error.c.
References orig_stderr.
Referenced by get_console_input_win32().
|
inlinestatic |
Definition at line 341 of file error.h.
Referenced by man_io_error(), and x_check_status().
const char* msg_flags_string | ( | const unsigned int | flags, |
struct gc_arena * | gc | ||
) |
Definition at line 783 of file error.c.
References alloc_buf_gc(), BSTR, buf_printf(), M_DEBUG, M_FATAL, M_INFO, M_NONFATAL, and M_WARN.
Referenced by log_entry_print().
FILE* msg_fp | ( | const unsigned int | flags | ) |
Definition at line 194 of file error.c.
References default_err, default_out, M_FATAL, M_USAGE_SMALL, msgfp, openvpn_exit(), and OPENVPN_EXIT_STATUS_CANNOT_OPEN_DEBUG_FILE.
Referenced by usage(), and x_msg_va().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Definition at line 305 of file error.h.
References x_msg_prefix.
Referenced by clear_prefix(), multi_process_outgoing_link(), and set_prefix().
|
inlinestatic |
Definition at line 325 of file error.h.
References x_msg_virtual_output.
Referenced by man_persist_close(), and man_persist_init().
|
inlinestatic |
Return true if flags represent an enabled, not muted log level.
Definition at line 227 of file error.h.
References check_debug_level(), and dont_mute().
Referenced by plugin_vlog(), and x_msg_va().
void msg_thread_init | ( | void | ) |
void msg_thread_uninit | ( | void | ) |
|
inlinestatic |
Convert fatal errors to nonfatal, don't touch other errors.
Definition at line 373 of file error.h.
References M_FATAL, and M_NONFATAL.
void open_syslog | ( | const char * | pgmname, |
bool | stdio_to_null | ||
) |
Definition at line 467 of file error.c.
References M_WARN, msg, msgfp, PACKAGE, set_std_files_to_null(), std_redir, string_alloc(), and use_syslog.
Referenced by add_option().
|
inlinestatic |
Definition at line 379 of file error.h.
Referenced by man_io_error(), x_check_status(), and x_msg_va().
void openvpn_exit | ( | const int | status | ) |
Definition at line 735 of file error.c.
References close_syslog(), forked, OPENVPN_EXIT_STATUS_ERROR, OPENVPN_EXIT_STATUS_GOOD, perf_output_results(), plugin_abort(), remove_pid_file(), status, tun_abort(), and uninit_win32().
Referenced by add_option(), error_reset(), msg_fp(), openvpn_main(), usage(), usage_small(), usage_version(), and x_msg_va().
void out_of_memory | ( | void | ) |
Definition at line 460 of file error.c.
References PACKAGE_NAME.
Referenced by check_malloc_return().
void redirect_stdout_stderr | ( | const char * | file, |
bool | append | ||
) |
Definition at line 515 of file error.c.
References ASSERT, gc_free(), gc_new(), M_ERR, M_ERRNO, M_WARN, msg, msgfp, orig_stderr, std_redir, and wide_string().
Referenced by add_option().
void reset_check_status | ( | void | ) |
Definition at line 630 of file error.c.
References x_cs_info_level, and x_cs_verbose_level.
Referenced by init_static().
void set_check_status | ( | unsigned int | info_level, |
unsigned int | verbose_level | ||
) |
Definition at line 637 of file error.c.
References x_cs_info_level, and x_cs_verbose_level.
Referenced by init_verb_mute().
|
inlinestatic |
Definition at line 286 of file error.h.
References x_cs_err_delay_ms.
Referenced by init_instance().
bool set_debug_level | ( | const int | level, |
const unsigned int | flags | ||
) |
Definition at line 105 of file error.c.
References constrain_int(), SDL_CONSTRAIN, and x_debug_level.
Referenced by add_option(), init_verb_mute(), and man_dispatch_command().
void set_machine_readable_output | ( | bool | parsable | ) |
Definition at line 155 of file error.c.
References machine_readable_output.
Referenced by add_option().
bool set_mute_cutoff | ( | const int | cutoff | ) |
Definition at line 123 of file error.c.
References mute_cutoff.
Referenced by init_verb_mute(), and man_dispatch_command().
void set_suppress_timestamps | ( | bool | suppressed | ) |
const char* strerror_win32 | ( | DWORD | errnum, |
struct gc_arena * | gc | ||
) |
Definition at line 812 of file error.c.
References alloc_buf_gc(), ASSERT, BSTR, buf_printf(), SIZE, status, and utf16to8().
Referenced by add_route_ipapi(), close_tun(), del_route_ipapi(), dhcp_release_by_adapter_index(), dhcp_renew_by_adapter_index(), do_address_service(), do_dns_domain_service(), do_dns_service(), do_route_service(), do_set_mtu_service(), do_wins_service(), get_adapter_info_list(), get_default_gateway_ipv6(), get_device_instance_id_interface(), get_interface_info_list(), get_per_adapter_info(), get_windows_routing_table(), openvpn_strerror(), register_dns_service(), route_ipv6_ipapi(), send_msg_iservice(), service_enable_dhcp(), service_register_ring_buffers(), socket_recv_queue(), socket_send_queue(), tun_read_queue(), tun_write_queue(), tuntap_set_ip_addr(), win_wfp_block_service(), win_wfp_msg_handler(), and windows_set_mtu().
void x_check_status | ( | int | status, |
const char * | description, | ||
struct link_socket * | sock, | ||
struct tuntap * | tt | ||
) |
Definition at line 652 of file error.c.
References link_socket_info::af, gc_free(), gc_new(), ignore_sys_error(), link_socket::info, msg, link_socket::mtu, link_socket_info::mtu_changed, openvpn_errno_maybe_crt(), openvpn_strerror(), platform_sleep_milliseconds(), link_socket_info::proto, proto2ascii(), link_socket::sd, SOCKET_PRINTF, status, tap_win_getinfo(), tuntap_defined(), x_cs_err_delay_ms, x_cs_info_level, and x_cs_verbose_level.
Referenced by check_status().
void x_msg | ( | const unsigned int | flags, |
const char * | format, | ||
... | |||
) |
void x_msg_va | ( | const unsigned int | flags, |
const char * | format, | ||
va_list | arglist | ||
) |
unsigned int x_cs_err_delay_ms |
Definition at line 627 of file error.c.
Referenced by set_check_status_error_delay(), and x_check_status().
unsigned int x_cs_info_level |
Definition at line 625 of file error.c.
Referenced by reset_check_status(), set_check_status(), and x_check_status().
unsigned int x_cs_verbose_level |
Definition at line 626 of file error.c.
Referenced by check_status(), reset_check_status(), set_check_status(), and x_check_status().
unsigned int x_debug_level |
Definition at line 52 of file error.c.
Referenced by check_debug_level().
const char* x_msg_prefix |
Definition at line 722 of file error.c.
Referenced by msg_get_prefix(), and msg_set_prefix().
const struct virtual_output* x_msg_virtual_output |
Definition at line 728 of file error.c.
Referenced by msg_get_virtual_output(), and msg_set_virtual_output().