From f5ef3919b42541ac6daa1c3ea2ed7c1707f4dd01 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 3 Jul 2018 15:59:48 +0200 Subject: [PATCH] blst: more functions exported to kemi framework --- src/modules/blst/blst.c | 165 ++++++++++++++++++++++++++++++++++------ 1 file changed, 141 insertions(+), 24 deletions(-) diff --git a/src/modules/blst/blst.c b/src/modules/blst/blst.c index 29b3fc95fbb..e3c5226b91e 100644 --- a/src/modules/blst/blst.c +++ b/src/modules/blst/blst.c @@ -299,15 +299,12 @@ static int blst_is_blacklisted_f(struct sip_msg* msg, char* foo, char* bar) /** * */ -static int blst_set_ignore_f(struct sip_msg* msg, char* flags, char* foo) +static int ki_blst_set_ignore(sip_msg_t* msg, int mask) { #ifdef USE_DST_BLACKLIST unsigned char blst_imask; - int mask; - - if (unlikely(flags && (get_int_fparam(&mask, msg, (fparam_t*)flags)<0))) - return -1; - blst_imask=flags?mask:0xff; + + blst_imask=mask; msg->fwd_send_flags.blst_imask|=blst_imask; return 1; #else /* USE_DST_BLACKLIST */ @@ -317,19 +314,37 @@ static int blst_set_ignore_f(struct sip_msg* msg, char* flags, char* foo) return 1; } +/** + * + */ +static int ki_blst_set_ignore_all(sip_msg_t* msg) +{ + return ki_blst_set_ignore(msg, 0xff); +} + /** * */ -static int blst_clear_ignore_f(struct sip_msg* msg, char* flags, char* foo) +static int blst_set_ignore_f(struct sip_msg* msg, char* flags, char* foo) { -#ifdef USE_DST_BLACKLIST - unsigned char blst_imask; - int mask; - + int mask = 0xff; + if (unlikely(flags && (get_int_fparam(&mask, msg, (fparam_t*)flags)<0))) return -1; - blst_imask=flags?mask:0xff; + + return ki_blst_set_ignore(msg, mask); +} + +/** + * + */ +static int ki_blst_clear_ignore(sip_msg_t* msg, int mask) +{ +#ifdef USE_DST_BLACKLIST + unsigned char blst_imask; + + blst_imask=mask; msg->fwd_send_flags.blst_imask&=~blst_imask; return 1; #else /* USE_DST_BLACKLIST */ @@ -343,15 +358,34 @@ static int blst_clear_ignore_f(struct sip_msg* msg, char* flags, char* foo) /** * */ -static int blst_rpl_set_ignore_f(struct sip_msg* msg, char* flags, char* foo) +static int ki_blst_clear_ignore_all(sip_msg_t* msg) { -#ifdef USE_DST_BLACKLIST - unsigned char blst_imask; - int mask; - + return ki_blst_clear_ignore(msg, 0xff); +} + +/** + * + */ +static int blst_clear_ignore_f(struct sip_msg* msg, char* flags, char* foo) +{ + int mask = 0xff; + if (unlikely(flags && (get_int_fparam(&mask, msg, (fparam_t*)flags)<0))) return -1; - blst_imask=flags?mask:0xff; + + return ki_blst_clear_ignore(msg, mask); +} + + +/** + * + */ +static int ki_blst_rpl_set_ignore(sip_msg_t* msg, int mask) +{ +#ifdef USE_DST_BLACKLIST + unsigned char blst_imask; + + blst_imask=mask; msg->rpl_send_flags.blst_imask|=blst_imask; return 1; #else /* USE_DST_BLACKLIST */ @@ -365,15 +399,35 @@ static int blst_rpl_set_ignore_f(struct sip_msg* msg, char* flags, char* foo) /** * */ -static int blst_rpl_clear_ignore_f(struct sip_msg* msg, char* flags, char* foo) +static int ki_blst_rpl_set_ignore_all(sip_msg_t* msg, int mask) { -#ifdef USE_DST_BLACKLIST - unsigned char blst_imask; - int mask; - + return ki_blst_rpl_set_ignore(msg, 0xff); +} + + +/** + * + */ +static int blst_rpl_set_ignore_f(struct sip_msg* msg, char* flags, char* foo) +{ + int mask = 0xff; + if (unlikely(flags && (get_int_fparam(&mask, msg, (fparam_t*)flags)<0))) return -1; - blst_imask=flags?mask:0xff; + + return ki_blst_rpl_set_ignore(msg, mask); +} + + +/** + * + */ +static int ki_blst_rpl_clear_ignore(sip_msg_t* msg, int mask) +{ +#ifdef USE_DST_BLACKLIST + unsigned char blst_imask; + + blst_imask=mask; msg->rpl_send_flags.blst_imask&=~blst_imask; return 1; #else /* USE_DST_BLACKLIST */ @@ -383,6 +437,29 @@ static int blst_rpl_clear_ignore_f(struct sip_msg* msg, char* flags, char* foo) return 1; } + +/** + * + */ +static int ki_blst_rpl_clear_ignore_all(sip_msg_t* msg) +{ + return ki_blst_rpl_clear_ignore(msg, 0xff); +} + + +/** + * + */ +static int blst_rpl_clear_ignore_f(struct sip_msg* msg, char* flags, char* foo) +{ + int mask = 0xff; + + if (unlikely(flags && (get_int_fparam(&mask, msg, (fparam_t*)flags)<0))) + return -1; + + return ki_blst_rpl_clear_ignore(msg, mask); +} + /** * */ @@ -413,6 +490,46 @@ static sr_kemi_t sr_kemi_blst_exports[] = { { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } }, + { str_init("blst"), str_init("blst_set_ignore"), + SR_KEMIP_INT, ki_blst_set_ignore, + { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("blst"), str_init("blst_set_ignore_all"), + SR_KEMIP_INT, ki_blst_set_ignore_all, + { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("blst"), str_init("blst_clear_ignore"), + SR_KEMIP_INT, ki_blst_clear_ignore, + { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("blst"), str_init("blst_clear_ignore_all"), + SR_KEMIP_INT, ki_blst_clear_ignore_all, + { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("blst"), str_init("blst_rpl_set_ignore"), + SR_KEMIP_INT, ki_blst_rpl_set_ignore, + { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("blst"), str_init("blst_rpl_set_ignore_all"), + SR_KEMIP_INT, ki_blst_rpl_set_ignore_all, + { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("blst"), str_init("blst_rpl_clear_ignore"), + SR_KEMIP_INT, ki_blst_rpl_clear_ignore, + { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("blst"), str_init("blst_rpl_clear_ignore_all"), + SR_KEMIP_INT, ki_blst_rpl_clear_ignore_all, + { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } };