#include "../../config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <time.h>
#include <ctype.h>
#include <stdint.h>
#include "main.h"
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | _UTIL_H 1 |
#define | SPF_MAX_DATETIME 26 |
#define | SPF_MAX_GHBNR_DBUF 2048 |
#define | SIZEOF(object) ((size_t) sizeof(object)) |
#define | xmalloc(n) UTIL_malloc(n, __FILE__, __LINE__, __FUNCTION__) |
#define | xrealloc(m, n) UTIL_realloc(m, n, __FILE__, __LINE__, __FUNCTION__) |
#define | xfree(m) UTIL_free(m, __FILE__, __LINE__, __FUNCTION__) |
#define | xstrdup(m) UTIL_strdup(m) |
#define | xstrndup(m, n) UTIL_strndup(m, n) |
#define | xprintf(format,) dbg_printf(FL_A, __FUNCTION__, __FILE__, __LINE__, format, __VA_ARGS__) |
#define | xvprintf(format,) dbg_printf(FL_B, __FUNCTION__, __FILE__, __LINE__, format, __VA_ARGS__) |
#define | xpprintf(s) dbg_pprintf(FL_D, __FUNCTION__, __FILE__, __LINE__, s) |
#define | xeprintf(format,) dbg_printf(FL_E, __FUNCTION__, __FILE__, __LINE__, format, __VA_ARGS__) |
#define | xepprintf(s) dbg_pprintf(FL_F, __FUNCTION__, __FILE__, __LINE__, s) |
#define | xpthread_mutex_lock(m) _UTIL_pthread_mutex(m, SPF_TRUE) |
#define | xpthread_mutex_unlock(m) _UTIL_pthread_mutex(m, SPF_FALSE) |
#define | f_bit_set(fl_bit_vector, bit) ((int)((fl_bit_vector)&(bit))) |
#define | urlchr_test(c) (urlchr_table[(unsigned char)(c)] & 1) |
#define | DEBUG_LOG_FILE "/var/log/spf.log" |
#define | OUTPUT_LOG_FILE "/var/log/spflog.txt" |
#define | dbg_printf _dummy_debug |
#define | dbg_pprintf _dummy_pdebug |
Functions | |
void | _printf_dbg (const u_int8_t, const char *, const char *, const size_t, const char *,...) |
void | _pprintf_dbg (const u_int8_t, const char *, const char *, const size_t, const char *) |
void | _dummy_debug (const u_int8_t, const char *, const char *, const size_t, const char *,...) |
void | _dummy_pdebug (const u_int8_t, const char *, const char *, const size_t, const char *) |
void * | UTIL_malloc (const int32_t, const char *, const int32_t, const char *) |
void * | UTIL_realloc (void *, const int32_t, const char *, const int32_t, const char *) |
void | UTIL_free (void *, const char *, const int32_t, const char *) |
void | UTIL_log_result (peer_info_t *) |
char * | UTIL_get_date (void) |
char * | UTIL_strndup (const char *, const size_t) |
char * | UTIL_strdup (const char *) |
int16_t | UTIL_index (const char *, const char) |
char * | UTIL_split_str (const char *, const char, const u_int8_t) |
char * | UTIL_split_strr (const char *, const char, const u_int8_t) |
u_int8_t | UTIL_count_delim (const char *, const char) |
SPF_BOOL | UTIL_is_spf_delim (const char) |
SPF_BOOL | UTIL_is_spf_result (const char) |
SPF_BOOL | UTIL_is_macro (const char *) |
SPF_BOOL | UTIL_mx_cmp (peer_info_t *, const char *, const int8_t) |
SPF_BOOL | UTIL_a_cmp (peer_info_t *, const char *, const int8_t) |
SPF_BOOL | UTIL_ptr_cmp (peer_info_t *, const char *) |
SPF_MECHANISM | UTIL_get_policy_mech (const char *) |
SPF_RESULT | UTIL_get_mech_prefix (peer_info_t *, const char *) |
SPF_BOOL | UTIL_assoc_prefix (peer_info_t *, SPF_RESULT, const char *) |
policy_addr_t * | UTIL_expand_ip (const char *) |
SPF_BOOL | UTIL_is_ip (const char *) |
char * | UTIL_rev_addr (const char *) |
char * | UTIL_get_dname (const char *) |
SPF_BOOL | UTIL_cidr_cmp (const policy_addr_t *, const struct in_addr *) |
SPF_BOOL | UTIL_validate_ptr (peer_info_t *) |
SPF_BOOL | UTIL_validate_hostname (peer_info_t *, const char *, const int8_t) |
char * | UTIL_url_encode (const char *) |
char * | UTIL_reverse (const char *, const char) |
SPF_BOOL | UTIL_addnode (split_str_t *, const char *, SPF_BOOL) |
void | _UTIL_pthread_mutex (void *, SPF_BOOL) |
Variables | |
const u_char | urlchr_table [256] |
void * | util_mutex |
|
|
|
|
Definition at line 210 of file util.h. Referenced by _printf_dbg(). |
|
Definition at line 168 of file util.h. Referenced by _pprintf_dbg(), and _printf_dbg(). |
|
Definition at line 213 of file util.h. Referenced by UTIL_log_result(). |
|
Definition at line 108 of file util.h. Referenced by MACRO_addbuf(), MACRO_expand(), SPF_init(), UTIL_a_cmp(), UTIL_addnode(), UTIL_expand_ip(), UTIL_reverse(), and UTIL_validate_hostname(). |
|
Definition at line 95 of file util.h. Referenced by SPF_init(), and UTIL_get_date(). |
|
Definition at line 98 of file util.h. Referenced by UTIL_a_cmp(), and UTIL_validate_hostname(). |
|
Definition at line 171 of file util.h. Referenced by UTIL_url_encode(). |
|
|
Definition at line 150 of file util.h. Referenced by DNS_check_client_reverse(), and UTIL_a_cmp(). |
|
|
Definition at line 125 of file util.h. Referenced by _pprintf_dbg(), _printf_dbg(), DNS_cname_answer(), DNS_mx_answer(), DNS_txt_answer(), MACRO_addbuf(), MACRO_eatmore(), MACRO_expand(), MACRO_process(), SPF_build_header(), SPF_init(), SPF_result(), UTIL_a_cmp(), UTIL_addnode(), UTIL_expand_ip(), UTIL_get_date(), UTIL_log_result(), UTIL_rev_addr(), UTIL_reverse(), UTIL_strndup(), UTIL_url_encode(), and UTIL_validate_hostname(). |
|
Definition at line 146 of file util.h. Referenced by DNS_check_client_reverse(), DNS_cname_answer(), DNS_txt_answer(), SPF_parse_policy(), SPF_policy_main(), SPF_policy_main_rec(), UTIL_addnode(), UTIL_get_policy_mech(), UTIL_index(), UTIL_is_ip(), UTIL_is_macro(), UTIL_is_spf_delim(), UTIL_is_spf_result(), UTIL_mx_cmp(), and UTIL_validate_hostname(). |
|
Definition at line 138 of file util.h. Referenced by DNS_mx_answer(), DNS_query(), MACRO_eatmore(), MACRO_expand(), MACRO_process(), SPF_get_explain(), SPF_init(), SPF_parse_policy(), SPF_policy_main_rec(), SPF_result(), SPF_smtp_from(), SPF_smtp_helo(), UTIL_get_dname(), UTIL_get_mech_prefix(), and UTIL_rev_addr(). |
|
Definition at line 163 of file util.h. Referenced by _printf_dbg(), UTIL_get_date(), and UTIL_log_result(). |
|
Definition at line 164 of file util.h. Referenced by _printf_dbg(), UTIL_get_date(), and UTIL_log_result(). |
|
Definition at line 126 of file util.h. Referenced by DNS_cname_answer(), DNS_mx_answer(), and DNS_txt_answer(). |
|
Definition at line 128 of file util.h. Referenced by SPF_smtp_helo(), and UTIL_split_strr(). |
|
Definition at line 129 of file util.h. Referenced by DNS_check_client_reverse(), DNS_txt_answer(), MACRO_eatmore(), MACRO_expand(), MACRO_process(), SPF_init(), SPF_parse_policy(), SPF_smtp_from(), UTIL_a_cmp(), UTIL_cidr_cmp(), UTIL_expand_ip(), UTIL_get_dname(), UTIL_mx_cmp(), UTIL_ptr_cmp(), UTIL_rev_addr(), UTIL_reverse(), UTIL_split_str(), UTIL_validate_hostname(), and UTIL_validate_ptr(). |
|
|
|
|
Definition at line 97 of file util.c. References confg, f_bit_set, FL_D, FL_F, spf_config_s::level, SPF_MAX_DEBUG, xfree, and xmalloc. |
|
Definition at line 154 of file util.c. References confg, DEBUG_LOG_FILE, f_bit_set, FL_E, spf_config_s::level, SPF_MAX_DEBUG, util_mutex, xmalloc, xpthread_mutex_lock, and xpthread_mutex_unlock. |
|
|
Definition at line 980 of file util.c. References peer_info_s::addr, peer_info_s::current_domain, peer_info_t, policy_addr_t, SIZEOF, SPF_BOOL, SPF_FALSE, SPF_MAX_GHBNR_DBUF, SPF_MAX_HNAME, SPF_PASS, SPF_TRUE, UTIL_assoc_prefix(), UTIL_cidr_cmp(), UTIL_index(), xepprintf, xeprintf, xfree, xgethostbyname, xgethostbyname_free, xmalloc, xstrndup, and xvprintf. Referenced by SPF_parse_policy(). Here is the call graph for this function: ![]() |
|
Definition at line 2421 of file util.c. References split_str_s::elements, split_str_s::head, split_str_node_s::len, split_str_node_s::next, split_str_node_s::s, SIZEOF, SPF_BOOL, SPF_FALSE, SPF_TRUE, split_str_node_t, split_str_t, split_str_s::tail, xepprintf, xmalloc, xpprintf, and xvprintf. Referenced by UTIL_reverse(). |
|
Definition at line 1309 of file util.c. References peer_info_s::error, peer_info_s::last_m, peer_info_t, peer_info_s::RES, peer_info_s::rs, spf_result_t::s, SPF_BOOL, SPF_ERROR, SPF_FALSE, SPF_H_FAIL, SPF_MAX_ERROR, SPF_NEUTRAL, SPF_NONE, SPF_PASS, peer_info_s::spf_result, SPF_RESULT, SPF_S_FAIL, SPF_TRUE, SPF_UNKNOWN, SPF_UNMECH, UTIL_index(), xepprintf, and xvprintf. Referenced by DNS_query(), SPF_init(), SPF_parse_policy(), SPF_policy_main(), SPF_policy_main_rec(), UTIL_a_cmp(), UTIL_mx_cmp(), and UTIL_validate_hostname(). Here is the call graph for this function: ![]() |
|
Definition at line 1961 of file util.c. References policy_addr_s::addr, policy_addr_s::cidr, policy_addr_t, SPF_BOOL, SPF_FALSE, SPF_MAX_IP_ADDR, SPF_TRUE, xepprintf, xfree, xstrndup, and xvprintf. Referenced by SPF_parse_policy(), UTIL_a_cmp(), and UTIL_validate_hostname(). |
|
Definition at line 751 of file util.c. References SPF_MAX_DELIM, xepprintf, and xvprintf. Referenced by MACRO_eatmore(), and UTIL_get_dname(). |
|
Definition at line 1694 of file util.c. References policy_addr_s::addr, policy_addr_s::cidr, policy_addr_t, SIZEOF, UTIL_index(), xepprintf, xfree, xmalloc, xstrndup, and xvprintf. Referenced by SPF_parse_policy(). Here is the call graph for this function: ![]() |
|
Definition at line 522 of file util.c. References xvprintf. |
|
Definition at line 282 of file util.c. References SPF_MAX_DATETIME, util_mutex, xmalloc, xpthread_mutex_lock, and xpthread_mutex_unlock. Referenced by UTIL_log_result(). |
|
Definition at line 1906 of file util.c. References UTIL_count_delim(), UTIL_split_str(), xepprintf, xprintf, xstrndup, and xvprintf. Here is the call graph for this function: ![]() |
|
Definition at line 1555 of file util.c. References peer_info_s::ALL, peer_info_s::last_m, peer_info_t, peer_info_s::RES_P, SPF_ERROR, SPF_H_FAIL, SPF_MAX_HNAME, SPF_NEUTRAL, SPF_PASS, SPF_RESULT, SPF_S_FAIL, SPF_TRUE, UTIL_index(), xepprintf, xprintf, and xvprintf. Referenced by SPF_parse_policy(). Here is the call graph for this function: ![]() |
|
Definition at line 1198 of file util.c. References A, ALL, DEFAULT, EXISTS, EXPLAIN, INCLUDE, IP4, IP6, MX, NO_POLICY, PTR, REDIRECT, SPF_MECHANISM, UNMECH, VERSION, xepprintf, xpprintf, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 564 of file util.c. References xepprintf, xpprintf, and xvprintf. Referenced by MACRO_expand(), SPF_parse_policy(), UTIL_a_cmp(), UTIL_assoc_prefix(), UTIL_expand_ip(), and UTIL_get_mech_prefix(). |
|
Definition at line 1793 of file util.c. References SPF_BOOL, SPF_FALSE, SPF_TRUE, xepprintf, xpprintf, and xvprintf. |
|
Definition at line 869 of file util.c. References SPF_BOOL, SPF_FALSE, SPF_TRUE, xepprintf, xpprintf, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 790 of file util.c. References SPF_BOOL, SPF_FALSE, SPF_TRUE, xepprintf, xpprintf, and xvprintf. Referenced by MACRO_eatmore(). |
|
Definition at line 832 of file util.c. References SPF_BOOL, SPF_FALSE, SPF_TRUE, xpprintf, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 326 of file util.c. References peer_info_s::error, peer_info_s::from, OUTPUT_LOG_FILE, peer_info_t, peer_info_s::r_ip, peer_info_s::RES, SPF_MAX_DEBUG, peer_info_s::spf_result, peer_info_s::spf_rlevel, peer_info_s::spf_ver, SPF_VERSION, UTIL_get_date(), util_mutex, xfree, xmalloc, xpthread_mutex_lock, and xpthread_mutex_unlock. Referenced by SPF_policy_main_rec(). Here is the call graph for this function: ![]() |
|
Definition at line 447 of file util.c. References xvprintf. Referenced by UTIL_realloc(). |
|
Definition at line 914 of file util.c. References peer_info_s::addr, DNS_query(), peer_info_s::from, peer_info_t, SPF_BOOL, SPF_FALSE, SPF_PASS, SPF_TRUE, UTIL_assoc_prefix(), UTIL_validate_hostname(), xfree, xpprintf, xstrndup, and xvprintf. Referenced by SPF_parse_policy(). Here is the call graph for this function: ![]() |
|
Definition at line 1135 of file util.c. References peer_info_s::current_domain, DNS_query(), peer_info_s::error, peer_info_t, peer_info_s::r_ip, peer_info_s::rs, SPF_BOOL, SPF_FALSE, SPF_MAX_HNAME, SPF_TRUE, UTIL_rev_addr(), xepprintf, xfree, xstrndup, and xvprintf. Referenced by SPF_parse_policy(). Here is the call graph for this function: ![]() |
|
Definition at line 486 of file util.c. References UTIL_malloc(), and xvprintf. Here is the call graph for this function: ![]() |
|
Definition at line 1843 of file util.c. References xepprintf, xfree, xmalloc, xprintf, xstrndup, and xvprintf. Referenced by DNS_check_client_reverse(), UTIL_ptr_cmp(), and UTIL_validate_ptr(). |
|
Definition at line 2331 of file util.c. References split_str_s::elements, split_str_s::head, split_str_node_s::len, split_str_node_s::next, split_str_node_s::s, SIZEOF, SPF_FALSE, SPF_TRUE, split_str_node_t, split_str_t, split_str_s::tail, UTIL_addnode(), xepprintf, xfree, xmalloc, xstrndup, and xvprintf. Referenced by MACRO_eatmore(). Here is the call graph for this function: ![]() |
|
Definition at line 615 of file util.c. References SPF_MAX_STR, xepprintf, xfree, xstrndup, and xvprintf. Referenced by UTIL_get_dname(). |
|
Definition at line 684 of file util.c. References xepprintf, xstrdup, and xvprintf. Referenced by MACRO_eatmore(). |
|
|
|
Definition at line 2272 of file util.c. References urlchr_test, xepprintf, xmalloc, and xvprintf. |
|
Definition at line 2100 of file util.c. References peer_info_s::addr, peer_info_t, policy_addr_t, peer_info_s::r_ip, SIZEOF, SPF_BOOL, SPF_FALSE, SPF_MAX_GHBNR_DBUF, SPF_MAX_IP_ADDR, SPF_PASS, SPF_TRUE, UTIL_assoc_prefix(), UTIL_cidr_cmp(), xepprintf, xfree, xgethostbyname, xgethostbyname_free, xmalloc, xpprintf, xstrndup, and xvprintf. Referenced by DNS_check_client_reverse(), DNS_ptr_answer(), and UTIL_mx_cmp(). Here is the call graph for this function: ![]() |
|
Definition at line 2038 of file util.c. References peer_info_s::current_domain, DNS_query(), peer_info_s::error, peer_info_t, peer_info_s::r_ip, peer_info_s::r_vhname, peer_info_s::rs, SPF_BOOL, SPF_FALSE, SPF_MAX_HNAME, SPF_TRUE, UTIL_rev_addr(), xepprintf, xfree, xstrndup, and xvprintf. Here is the call graph for this function: ![]() |
|
Initial value: Definition at line 172 of file util.h. |
|
Definition at line 66 of file util.c. Referenced by _printf_dbg(), UTIL_get_date(), and UTIL_log_result(). |