From 7d7ed6ad0cff84791c381edc5a9cc201699b9cdd Mon Sep 17 00:00:00 2001 From: "Olle E. Johansson" Date: Sat, 23 Apr 2016 16:35:53 +0200 Subject: [PATCH] uac Minor code cleanup, add a few doxygen headers --- modules/uac/api.h | 18 +++++++++++ modules/uac/auth.c | 12 ++++++-- modules/uac/auth_alg.c | 7 +++++ modules/uac/auth_hdr.c | 7 +++++ modules/uac/replace.c | 6 ++++ modules/uac/uac.c | 69 ++++++++++++++++++++++++------------------ modules/uac/uac_reg.c | 7 +++++ modules/uac/uac_send.c | 15 ++++++--- 8 files changed, 104 insertions(+), 37 deletions(-) diff --git a/modules/uac/api.h b/modules/uac/api.h index 689f1fefc4e..b886469bfea 100644 --- a/modules/uac/api.h +++ b/modules/uac/api.h @@ -1,3 +1,21 @@ +/* + * This file is part of Kamailio, a free SIP server. + * + * Kamailio is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * Kamailio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef UAC_API_H_ #define UAC_API_H_ #include "../../sr_module.h" diff --git a/modules/uac/auth.c b/modules/uac/auth.c index 7b8e6ed5e2e..6a530b7fbf7 100644 --- a/modules/uac/auth.c +++ b/modules/uac/auth.c @@ -19,6 +19,12 @@ * */ +/*! + * \file + * \brief Kamailio uac :: Authentication + * \ingroup uac + * Module: \ref uac + */ #include #include @@ -250,8 +256,7 @@ static inline struct uac_credential *lookup_realm( str *realm) } -static inline struct uac_credential *get_avp_credential(struct sip_msg *msg, - str *realm) +static inline struct uac_credential *get_avp_credential(struct sip_msg *msg, str *realm) { static struct uac_credential crd; pv_value_t pv_val; @@ -266,8 +271,9 @@ static inline struct uac_credential *get_avp_credential(struct sip_msg *msg, crd.realm = pv_val.rs; /* is it the domain we are looking for? */ if (realm->len!=crd.realm.len || - strncmp( realm->s, crd.realm.s, realm->len)!=0 ) + strncmp( realm->s, crd.realm.s, realm->len)!=0 ) { return 0; + } } /* get username and password */ diff --git a/modules/uac/auth_alg.c b/modules/uac/auth_alg.c index 608ac64f4f5..6edcbab4217 100644 --- a/modules/uac/auth_alg.c +++ b/modules/uac/auth_alg.c @@ -19,6 +19,13 @@ * */ +/*! + * \file + * \brief Kamailio uac :: Authentication + * \ingroup uac + * Module: \ref uac + */ + #include "../../md5.h" diff --git a/modules/uac/auth_hdr.c b/modules/uac/auth_hdr.c index 62d204d52c4..e3cb8ebf753 100644 --- a/modules/uac/auth_hdr.c +++ b/modules/uac/auth_hdr.c @@ -18,6 +18,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*! + * \file + * \brief Kamailio uac :: Authentication headers + * \ingroup uac + * Module: \ref uac + */ + #include "string.h" #include "ctype.h" diff --git a/modules/uac/replace.c b/modules/uac/replace.c index 3899355c5e8..540042b9581 100644 --- a/modules/uac/replace.c +++ b/modules/uac/replace.c @@ -19,6 +19,12 @@ * */ +/*! + * \file + * \brief Kamailio uac :: header replacement/retrieval functions + * \ingroup uac + * Module: \ref uac + */ #include diff --git a/modules/uac/uac.c b/modules/uac/uac.c index eada8581069..7860ebfacf6 100644 --- a/modules/uac/uac.c +++ b/modules/uac/uac.c @@ -19,6 +19,17 @@ * */ +/*! + * \file + * \brief Kamailio uac :: The SIP UA client module + * \ingroup uac + * Module: \ref uac + */ + +/*! \defgroup uac The SIP UA Client module + * + */ + #include #include @@ -105,24 +116,20 @@ static cmd_export_t cmds[]={ REQUEST_ROUTE | BRANCH_ROUTE }, {"uac_replace_from", (cmd_function)w_replace_from, 1, fixup_replace_uri, 0, REQUEST_ROUTE | BRANCH_ROUTE }, - {"uac_restore_from", (cmd_function)w_restore_from, 0, 0, 0, + {"uac_restore_from", (cmd_function)w_restore_from, 0, 0, 0, REQUEST_ROUTE }, {"uac_replace_to", (cmd_function)w_replace_to, 2, fixup_replace_uri, 0, REQUEST_ROUTE | BRANCH_ROUTE }, {"uac_replace_to", (cmd_function)w_replace_to, 1, fixup_replace_uri, 0, REQUEST_ROUTE | BRANCH_ROUTE }, - {"uac_restore_to", (cmd_function)w_restore_to, 0, 0, 0, - REQUEST_ROUTE }, - {"uac_auth", (cmd_function)w_uac_auth, 0, 0, 0, - FAILURE_ROUTE }, - {"uac_req_send", (cmd_function)w_uac_req_send, 0, 0, 0, - ANY_ROUTE}, + {"uac_restore_to", (cmd_function)w_restore_to, 0, 0, 0, REQUEST_ROUTE }, + {"uac_auth", (cmd_function)w_uac_auth, 0, 0, 0, FAILURE_ROUTE }, + {"uac_req_send", (cmd_function)w_uac_req_send, 0, 0, 0, ANY_ROUTE}, {"uac_reg_lookup", (cmd_function)w_uac_reg_lookup, 2, fixup_pvar_pvar, fixup_free_pvar_pvar, ANY_ROUTE }, {"uac_reg_request_to", (cmd_function)w_uac_reg_request_to, 2, fixup_pvar_uint, fixup_free_pvar_uint, REQUEST_ROUTE | FAILURE_ROUTE | BRANCH_ROUTE }, - {"bind_uac", (cmd_function)bind_uac, 1, 0, 0, - 0}, + {"bind_uac", (cmd_function)bind_uac, 1, 0, 0, 0}, {0,0,0,0,0,0} }; @@ -130,22 +137,22 @@ static cmd_export_t cmds[]={ /* Exported parameters */ static param_export_t params[] = { - {"rr_from_store_param", PARAM_STR, &rr_from_param }, - {"rr_to_store_param", PARAM_STR, &rr_to_param }, - {"restore_mode", PARAM_STRING, &restore_mode_str }, - {"restore_dlg", INT_PARAM, &uac_restore_dlg }, - {"restore_passwd", PARAM_STR, &uac_passwd }, - {"restore_from_avp", PARAM_STR, &restore_from_avp }, - {"restore_to_avp", PARAM_STR, &restore_to_avp }, - {"credential", PARAM_STRING|USE_FUNC_PARAM, (void*)&add_credential }, - {"auth_username_avp", PARAM_STRING, &auth_username_avp }, - {"auth_realm_avp", PARAM_STRING, &auth_realm_avp }, - {"auth_password_avp", PARAM_STRING, &auth_password_avp }, - {"reg_db_url", PARAM_STR, ®_db_url }, - {"reg_db_table", PARAM_STR, ®_db_table }, - {"reg_contact_addr", PARAM_STR, ®_contact_addr }, - {"reg_timer_interval", INT_PARAM, ®_timer_interval }, - {"reg_retry_interval", INT_PARAM, ®_retry_interval }, + {"rr_from_store_param", PARAM_STR, &rr_from_param }, + {"rr_to_store_param", PARAM_STR, &rr_to_param }, + {"restore_mode", PARAM_STRING, &restore_mode_str }, + {"restore_dlg", INT_PARAM, &uac_restore_dlg }, + {"restore_passwd", PARAM_STR, &uac_passwd }, + {"restore_from_avp", PARAM_STR, &restore_from_avp }, + {"restore_to_avp", PARAM_STR, &restore_to_avp }, + {"credential", PARAM_STRING|USE_FUNC_PARAM, (void*)&add_credential }, + {"auth_username_avp", PARAM_STRING, &auth_username_avp }, + {"auth_realm_avp", PARAM_STRING, &auth_realm_avp }, + {"auth_password_avp", PARAM_STRING, &auth_password_avp }, + {"reg_db_url", PARAM_STR, ®_db_url }, + {"reg_db_table", PARAM_STR, ®_db_table }, + {"reg_contact_addr", PARAM_STR, ®_contact_addr }, + {"reg_timer_interval", INT_PARAM, ®_timer_interval }, + {"reg_retry_interval", INT_PARAM, ®_retry_interval }, {0, 0, 0} }; @@ -156,10 +163,10 @@ struct module_exports exports= { DEFAULT_DLFLAGS, /* dlopen flags */ cmds, /* exported functions */ params, /* param exports */ - 0, /* exported statistics */ - 0, /* exported MI functions */ + 0, /* exported statistics */ + 0, /* exported MI functions */ mod_pvs, /* exported pseudo-variables */ - 0, /* extra processes */ + 0, /* extra processes */ mod_init, /* module initialization function */ 0, mod_destroy, @@ -423,14 +430,16 @@ int w_replace_from(struct sip_msg* msg, char* p1, char* p2) /* p1 display , p2 uri */ if ( p1!=NULL ) { - if(pv_printf_s( msg, (pv_elem_p)p1, &dsp_s)!=0) + if(pv_printf_s( msg, (pv_elem_p)p1, &dsp_s)!=0) { return -1; + } dsp = &dsp_s; } /* compute the URI string; if empty string -> make it NULL */ - if (pv_printf_s( msg, (pv_elem_p)p2, &uri_s)!=0) + if (pv_printf_s( msg, (pv_elem_p)p2, &uri_s)!=0) { return -1; + } uri = uri_s.len?&uri_s:NULL; if (parse_from_header(msg)<0 ) { diff --git a/modules/uac/uac_reg.c b/modules/uac/uac_reg.c index 8ff63bdef28..c1236aec46d 100644 --- a/modules/uac/uac_reg.c +++ b/modules/uac/uac_reg.c @@ -18,6 +18,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/*! + * \file + * \brief Kamailio uac :: The SIP UA registration client module + * \ingroup uac + * Module: \ref uac + */ + #include #include "../../dprint.h" diff --git a/modules/uac/uac_send.c b/modules/uac/uac_send.c index bf4824b924c..34277a0cfe0 100644 --- a/modules/uac/uac_send.c +++ b/modules/uac/uac_send.c @@ -18,6 +18,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/*! + * \file + * \brief Kamailio uac :: UAC send functions + * \ingroup uac + * Module: \ref uac + */ + #include "../../dprint.h" #include "../../trim.h" #include "../../route.h" @@ -794,10 +801,10 @@ int uac_req_send(void) } uac_r.callid = (_uac_req.s_callid.len <= 0) ? NULL : &_uac_req.s_callid; ret = tmb.t_request(&uac_r, /* UAC Req */ - &_uac_req.s_ruri, /* Request-URI */ - (_uac_req.s_turi.len<=0)?&_uac_req.s_ruri:&_uac_req.s_turi, /* To */ - (_uac_req.s_furi.len<=0)?&_uac_req.s_ruri:&_uac_req.s_furi, /* From */ - (_uac_req.s_ouri.len<=0)?NULL:&_uac_req.s_ouri /* outbound uri */ + &_uac_req.s_ruri, /* Request-URI */ + (_uac_req.s_turi.len<=0)?&_uac_req.s_ruri:&_uac_req.s_turi, /* To */ + (_uac_req.s_furi.len<=0)?&_uac_req.s_ruri:&_uac_req.s_furi, /* From */ + (_uac_req.s_ouri.len<=0)?NULL:&_uac_req.s_ouri /* outbound uri */ ); if(ret<0) {