diff --git a/miniupnpd/genconfig.sh b/miniupnpd/genconfig.sh index 3ebb42f..cdebf99 100755 --- a/miniupnpd/genconfig.sh +++ b/miniupnpd/genconfig.sh @@ -18,6 +18,7 @@ case "$argv" in --ipv6) IPV6=1 ;; --igd2) IGD2=1 ;; --strict) STRICT=1 ;; + --debug) DEBUG=1 ;; --leasefile) LEASEFILE=1 ;; --vendorcfg) VENDORCFG=1 ;; --pcp-peer) PCP_PEER=1 ;; @@ -39,6 +40,7 @@ case "$argv" in echo " --ipv6 enable IPv6" echo " --igd2 build an IGDv2 instead of an IGDv1" echo " --strict be more strict regarding compliance with UPnP specifications" + echo " --debug #define DEBUG 1" echo " --leasefile enable lease file" echo " --vendorcfg enable configuration of manufacturer info" echo " --pcp-peer enable PCP PEER operation" @@ -122,6 +124,11 @@ echo "#define MINIUPNPD_VERSION \"`cat VERSION`\"" >> ${CONFIGFILE} echo "#define MINIUPNPD_DATE \"$MINIUPNPD_DATE\"" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE} +if [ -n "$DEBUG" ] ; then + echo "#define DEBUG 1" >> ${CONFIGFILE} + echo "" >> ${CONFIGFILE} +fi + cat >> ${CONFIGFILE} <table = strdup( - (char *) nftnl_rule_get_data(t, NFTNL_RULE_TABLE, &len)); + (char *) nftnl_rule_get_data(rule, NFTNL_RULE_TABLE, &len)); r->chain = strdup(chain); - r->family = *(uint32_t *) nftnl_rule_get_data(t, NFTNL_RULE_FAMILY, + r->family = *(uint32_t *) nftnl_rule_get_data(rule, NFTNL_RULE_FAMILY, &len); - descr = (char *) nftnl_rule_get_data(t, NFTNL_RULE_USERDATA, + descr = (char *) nftnl_rule_get_data(rule, NFTNL_RULE_USERDATA, &r->desc_len); if (r->desc_len > 0) r->desc = strndup(descr, r->desc_len); - r->handle = *(uint32_t *) nftnl_rule_get_data(t, + r->handle = *(uint32_t *) nftnl_rule_get_data(rule, NFTNL_RULE_HANDLE, &len); r->type = RULE_NONE; @@ -504,7 +527,7 @@ table_cb(const struct nlmsghdr *nlh, void *data) r->type = RULE_FILTER; } - itr = nftnl_expr_iter_create(t); + itr = nftnl_expr_iter_create(rule); while ((expr = nftnl_expr_iter_next(itr)) != NULL) { rule_expr_cb(expr, r); @@ -538,7 +561,7 @@ table_cb(const struct nlmsghdr *nlh, void *data) } } - nftnl_rule_free(t); + nftnl_rule_free(rule); } } } diff --git a/miniupnpd/netfilter_nft/nftnlrdr_misc.h b/miniupnpd/netfilter_nft/nftnlrdr_misc.h index fe94fc5..e60d40e 100644 --- a/miniupnpd/netfilter_nft/nftnlrdr_misc.h +++ b/miniupnpd/netfilter_nft/nftnlrdr_misc.h @@ -92,6 +92,19 @@ nft_mnl_connect(void); void nft_mnl_disconnect(void); +#ifdef DEBUG +void +print_rule(const char *func, int line, const struct nftnl_rule *rule); + +void +print_redirect_rules(const char * ifname); + +#define debug_rule(rule) do { print_rule(__func__, __LINE__, rule); } while (0) + +#else +#define debug_rule(rule) +#endif + int nft_send_rule(struct nftnl_rule * rule, uint16_t cmd, enum rule_chain_type type); struct nftnl_rule * @@ -126,7 +139,6 @@ void refresh_nft_cache_filter(void); void refresh_nft_cache_redirect(void); void refresh_nft_cache_peer(void); void refresh_nft_cache(struct rule_list *head, const char *table, const char *chain, uint32_t family); -void print_rule(rule_t *r); int table_op(enum nf_tables_msg_types op, uint16_t family, const char * name); diff --git a/miniupnpd/netfilter_nft/testnftnlrdr.c b/miniupnpd/netfilter_nft/testnftnlrdr.c index caa7645..d12279a 100644 --- a/miniupnpd/netfilter_nft/testnftnlrdr.c +++ b/miniupnpd/netfilter_nft/testnftnlrdr.c @@ -11,6 +11,7 @@ #include #include "nftnlrdr.h" +#include "nftnlrdr_misc.h" #include "../commonrdr.h" #ifndef PRIu64 @@ -84,7 +85,7 @@ main(int argc, char ** argv) printf("test\n"); } printf("trying to list nat rules :\n"); - list_redirect_rule(argv[1]); + print_redirect_rules(argv[1]); printf("deleting\n"); delete_redirect_and_filter_rules(eport, IPPROTO_TCP); return 0;