From f156d51b35485befb6aa9b750ab9fe462e25dd56 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 26 May 2012 15:06:29 +0200 Subject: src: add new parameter type to nfct_timeout_snprintf Thus, we can extend this interface to support the timeout policy in XML output in the future. Signed-off-by: Pablo Neira Ayuso --- src/libnetfilter_cttimeout.c | 45 +++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'src/libnetfilter_cttimeout.c') diff --git a/src/libnetfilter_cttimeout.c b/src/libnetfilter_cttimeout.c index b930089..1e6739d 100644 --- a/src/libnetfilter_cttimeout.c +++ b/src/libnetfilter_cttimeout.c @@ -356,19 +356,10 @@ const char *nfct_timeout_policy_attr_to_name(uint8_t l4proto, uint32_t state) } EXPORT_SYMBOL(nfct_timeout_policy_attr_to_name); - -/** - * nfct_timeout_snprintf - print conntrack timeout object into one buffer - * \param buf: pointer to buffer that is used to print the object - * \param size: size of the buffer (or remaining room in it). - * \param nfct_timeout: pointer to a valid conntrack timeout object. - * \param flags: output flags (CTA_TIMEOUT_SNPRINTF_F_FULL). - * - * This function returns -1 in case that some mandatory attributes are - * missing. On sucess, it returns 0. - */ -int nfct_timeout_snprintf(char *buf, size_t size, const struct nfct_timeout *t, - unsigned int flags) +static int +nfct_timeout_snprintf_default(char *buf, size_t size, + const struct nfct_timeout *t, + unsigned int flags) { int ret = 0; unsigned int offset = 0; @@ -426,6 +417,34 @@ int nfct_timeout_snprintf(char *buf, size_t size, const struct nfct_timeout *t, return ret; } + +/** + * nfct_timeout_snprintf - print conntrack timeout object into one buffer + * \param buf: pointer to buffer that is used to print the object + * \param size: size of the buffer (or remaining room in it). + * \param t: pointer to a valid conntrack timeout object. + * \param type: output type (see NFCT_TIMEOUT_O_*) + * \param flags: output flags (always set this to zero). + * + * This function returns -1 in case that some mandatory attributes are + * missing. On sucess, it returns 0. + */ +int nfct_timeout_snprintf(char *buf, size_t size, const struct nfct_timeout *t, + unsigned int type, unsigned int flags) +{ + int ret = 0; + + switch(type) { + case NFCT_TIMEOUT_O_DEFAULT: + ret = nfct_timeout_snprintf_default(buf, size, t, flags); + break; + /* add your new output here. */ + default: + break; + } + + return ret; +} EXPORT_SYMBOL(nfct_timeout_snprintf); /** -- cgit v1.2.3