#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 "main.h"
Go to the source code of this file.
Defines | |
#define | _UTIL_H 1 |
#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__, format, __VA_ARGS__) |
#define | xvprintf(format,) dbg_printf(FL_B, __FUNCTION__, format, __VA_ARGS__) |
#define | xpprintf(format,) dbg_printf(FL_D, __FUNCTION__, format, __VA_ARGS__) |
#define | xeprintf(s) (fprintf(stderr, s)) |
#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 |
Functions | |
void | _printf_dbg (const u_int8_t level, const char *function, const char *format,...) |
void | dummy_debug (const u_int8_t level, const char *function, const char *format,...) |
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 *) |
char * | UTIL_printf (char *format,...) |
void | UTIL_log_result (peer_info_t *peer_info) |
char * | UTIL_get_date (void) |
char * | UTIL_strndup (const char *s, const size_t n) |
char * | UTIL_strdup (const char *s) |
int16_t | UTIL_index (const char *s, const char c) |
char * | UTIL_split_str (const char *s, const char c, const u_int8_t num) |
char * | UTIL_split_strr (const char *s, const char c, const u_int8_t num) |
u_int8_t | UTIL_count_delim (const char *s, const char c) |
size_t | UTIL_guess_whats_in_the_box (char *s, const char c, const u_int16_t num) |
SPF_BOOL | UTIL_is_spf_delim (const char c) |
SPF_BOOL | UTIL_is_spf_result (const char c) |
SPF_BOOL | UTIL_is_macro (const char *s) |
SPF_BOOL | UTIL_mx_cmp (peer_info_t *peer_info, const char *s, const int8_t cidr) |
SPF_BOOL | UTIL_a_cmp (peer_info_t *peer_info, const char *s, const int8_t cidr) |
SPF_BOOL | UTIL_ptr_cmp (peer_info_t *peer_info, const char *s) |
SPF_MECHANISM | UTIL_get_policy_mech (const char *s) |
SPF_RESULT | UTIL_get_mech_prefix (peer_info_t *peer_info, const char *s) |
SPF_BOOL | UTIL_assoc_prefix (peer_info_t *peer_info, SPF_RESULT p, const char *s) |
policy_addr_t * | UTIL_expand_ip (const char *s) |
char * | UTIL_rev_addr (const char *s) |
char * | UTIL_get_dname (const char *s) |
SPF_BOOL | UTIL_cidr_cmp (peer_info_t *peer_info, const policy_addr_t *policy_addr, const struct in_addr *peer_addr) |
SPF_BOOL | UTIL_validate_ptr (peer_info_t *peer_info) |
SPF_BOOL | UTIL_validate_hostname (peer_info_t *peer_info, const char *s, const int8_t cidr) |
char * | UTIL_url_encode (const char *s) |
char * | UTIL_reverse (const char *s, const char delim) |
SPF_BOOL | UTIL_addnode (split_str_t *master, const char *s, SPF_BOOL last) |
Variables | |
const u_char | urlchr_table [256] |
|
|
|
|
|
Definition at line 120 of file util.h. Referenced by _printf_dbg(). |
|
Definition at line 85 of file util.h. Referenced by _printf_dbg(). |
|
Definition at line 123 of file util.h. Referenced by UTIL_log_result(). |
|
Definition at line 69 of file util.h. Referenced by _printf_dbg(). |
|
Definition at line 88 of file util.h. Referenced by UTIL_url_encode(). |
|
|
Definition at line 74 of file util.h. Referenced by DNS_ptr_answer(), DNS_txt_answer(), MACRO_eatmore(), MACRO_expand(), MACRO_process(), SPF_close(), SPF_init(), SPF_parse_policy(), SPF_policy_main_rec(), SPF_smtp_from(), SPF_smtp_helo(), UTIL_a_cmp(), UTIL_cidr_cmp(), UTIL_expand_ip(), UTIL_mx_cmp(), UTIL_ptr_cmp(), UTIL_rev_addr(), UTIL_reverse(), UTIL_split_str(), UTIL_split_strr(), UTIL_validate_hostname(), and UTIL_validate_ptr(). |
|
Definition at line 72 of file util.h. Referenced by 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_rev_addr(), UTIL_reverse(), UTIL_strndup(), UTIL_url_encode(), and UTIL_validate_hostname(). |
|
|
|
Definition at line 79 of file util.h. Referenced by DNS_mx_answer(), DNS_ptr_answer(), MACRO_eatmore(), MACRO_expand(), MACRO_process(), SPF_get_explain(), SPF_init(), SPF_parse_policy(), SPF_policy_main_rec(), SPF_result(), SPF_smtp_from(), and SPF_smtp_helo(). |
|
Definition at line 73 of file util.h. Referenced by DNS_cname_answer(), DNS_mx_answer(), and DNS_txt_answer(). |
|
Definition at line 75 of file util.h. Referenced by SPF_smtp_from(), and SPF_smtp_helo(). |
|
Definition at line 76 of file util.h. Referenced by DNS_ptr_answer(), DNS_txt_answer(), MACRO_eatmore(), MACRO_expand(), MACRO_process(), SPF_init(), SPF_parse_policy(), 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_split_strr(), UTIL_validate_hostname(), and UTIL_validate_ptr(). |
|
|
Definition at line 61 of file util.c. References confg, DEBUG_LOG_FILE, f_bit_set, spf_config_s::level, MAX_DEBUG_LEN, and SIZEOF. |
|
|
|
Definition at line 791 of file util.c. References peer_info_s::addr, policy_addr_s::addr, policy_addr_s::cidr, peer_info_s::cur_dom, FALSE, SPF_BOOL, SPF_PASS, TRUE, UTIL_assoc_prefix(), UTIL_cidr_cmp(), UTIL_index(), xeprintf, xfree, xmalloc, xstrndup, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 2020 of file util.c. References split_str_s::elements, FALSE, split_str_s::head, split_str_node_s::len, split_str_node_s::next, split_str_node_s::s, SPF_BOOL, split_str_s::tail, TRUE, xeprintf, and xmalloc. Referenced by UTIL_reverse(). |
|
Definition at line 1076 of file util.c. References peer_info_s::error, FALSE, peer_info_s::last_m, MAX_ERROR, peer_info_s::RES, peer_info_s::rs, spf_result_t::s, SPF_BOOL, SPF_ERROR, SPF_H_FAIL, SPF_NEUTRAL, SPF_NONE, SPF_PASS, peer_info_s::spf_result, spf_rlevel, SPF_S_FAIL, SPF_UNKNOWN, SPF_UNMECH, TRUE, UTIL_index(), and xvprintf. Referenced by DNS_query(), SPF_init(), SPF_parse_policy(), SPF_policy_main_rec(), UTIL_a_cmp(), UTIL_mx_cmp(), and UTIL_validate_hostname(). |
|
Definition at line 1604 of file util.c. References policy_addr_s::addr, policy_addr_s::cidr, FALSE, IP_ADDR, SPF_BOOL, TRUE, xeprintf, xfree, xstrndup, and xvprintf. Referenced by SPF_parse_policy(), UTIL_a_cmp(), and UTIL_validate_hostname(). |
|
Definition at line 541 of file util.c. References xeprintf, and xvprintf. Referenced by MACRO_eatmore(), and UTIL_get_dname(). |
|
Definition at line 1365 of file util.c. References policy_addr_s::addr, policy_addr_s::cidr, UTIL_index(), xeprintf, xfree, xmalloc, xstrndup, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 358 of file util.c. References xvprintf. |
|
Definition at line 153 of file util.c. Referenced by UTIL_log_result(). |
|
Definition at line 1557 of file util.c. References UTIL_count_delim(), UTIL_split_str(), xeprintf, xstrndup, and xvprintf. Referenced by DNS_ptr_answer(). |
|
Definition at line 1262 of file util.c. References peer_info_s::ALL, peer_info_s::last_m, peer_info_s::RES_P, SPF_ERROR, SPF_H_FAIL, SPF_NEUTRAL, SPF_PASS, SPF_RESULT, spf_rlevel, SPF_S_FAIL, TRUE, UTIL_index(), xeprintf, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 980 of file util.c. References A, ALL, DEFAULT, EXISTS, EXPLAIN, INCLUDE, IP4, IP6, MX, NO_POLICY, PTR, REDIRECT, SPF_MECHANISM, UNMECH, VERSION, xeprintf, and xvprintf. Referenced by SPF_parse_policy(). |
|
|
|
Definition at line 387 of file util.c. References xeprintf, 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 687 of file util.c. References FALSE, SPF_BOOL, TRUE, xeprintf, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 635 of file util.c. References FALSE, SPF_BOOL, TRUE, and xvprintf. Referenced by MACRO_eatmore(). |
|
Definition at line 661 of file util.c. References FALSE, SPF_BOOL, TRUE, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 180 of file util.c. References peer_info_s::error, peer_info_s::from, MAX_DEBUG_LEN, OUTPUT_LOG_FILE, peer_info_s::r_ip, peer_info_s::RES, peer_info_s::spf_result, spf_rlevel, peer_info_s::spf_ver, SPF_VERSION, and UTIL_get_date(). Referenced by SPF_policy_main_rec(). |
|
Definition at line 290 of file util.c. References xvprintf. Referenced by UTIL_realloc(). |
|
Definition at line 728 of file util.c. References peer_info_s::addr, DNS_query(), FALSE, peer_info_s::from, SPF_BOOL, SPF_PASS, TRUE, UTIL_assoc_prefix(), UTIL_validate_hostname(), xeprintf, xfree, xstrndup, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 127 of file util.c. References xvprintf. |
|
Definition at line 923 of file util.c. References peer_info_s::cur_dom, DNS_query(), peer_info_s::error, FALSE, peer_info_s::r_ip, peer_info_s::rs, SPF_BOOL, TRUE, UTIL_rev_addr(), xeprintf, xfree, xstrndup, and xvprintf. Referenced by SPF_parse_policy(). |
|
Definition at line 321 of file util.c. References UTIL_malloc(), and xvprintf. |
|
Definition at line 1498 of file util.c. References xeprintf, xfree, xmalloc, xstrndup, and xvprintf. Referenced by UTIL_ptr_cmp(), and UTIL_validate_ptr(). |
|
Definition at line 1933 of file util.c. References split_str_s::elements, FALSE, split_str_s::head, split_str_node_s::len, split_str_node_s::next, split_str_node_s::s, split_str_s::tail, TRUE, UTIL_addnode(), xeprintf, xfree, xmalloc, xstrndup, and xvprintf. Referenced by MACRO_eatmore(). |
|
Definition at line 425 of file util.c. References xeprintf, xfree, xstrndup, and xvprintf. Referenced by UTIL_get_dname(). |
|
Definition at line 475 of file util.c. References xeprintf, xfree, xstrndup, and xvprintf. Referenced by MACRO_eatmore(). |
|
|
|
|
|
Definition at line 1881 of file util.c. References urlchr_test, xeprintf, xmalloc, and xvprintf. |
|
Definition at line 1719 of file util.c. References policy_addr_s::addr, peer_info_s::addr, policy_addr_s::cidr, FALSE, IP_ADDR, peer_info_s::r_ip, SPF_BOOL, SPF_PASS, TRUE, UTIL_assoc_prefix(), UTIL_cidr_cmp(), xeprintf, xfree, xmalloc, xstrndup, and xvprintf. Referenced by DNS_ptr_answer(), and UTIL_mx_cmp(). |
|
Definition at line 1673 of file util.c. References peer_info_s::cur_dom, DNS_query(), peer_info_s::error, FALSE, peer_info_s::r_ip, peer_info_s::r_vhname, peer_info_s::rs, SPF_BOOL, TRUE, UTIL_rev_addr(), xfree, xstrndup, and xvprintf. Referenced by MACRO_process(). |
|
Initial value:
|