From e4895abf5a533b96bf5e7112488a0facaabfc1a7 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 29 Jul 2020 13:15:25 +0200 Subject: [PATCH] pua_bla: convert to PKG/SHM memory logging helper functions * remove trailing spaces * remove history notes and $Id --- src/modules/pua_bla/notify.c | 38 ++++++++++-------------- src/modules/pua_bla/pua_bla.c | 47 +++++++++++++----------------- src/modules/pua_bla/pua_bla.h | 10 ++----- src/modules/pua_bla/registrar_cb.c | 35 ++++++++++------------ src/modules/pua_bla/registrar_cb.h | 15 ++++------ 5 files changed, 60 insertions(+), 85 deletions(-) diff --git a/src/modules/pua_bla/notify.c b/src/modules/pua_bla/notify.c index 646da21d410..bd8345e492c 100644 --- a/src/modules/pua_bla/notify.c +++ b/src/modules/pua_bla/notify.c @@ -1,6 +1,4 @@ /* - * $Id: notify.c 1666 2007-03-02 13:40:09Z anca_vamanu $ - * * pua_bla module - pua Bridged Line Appearance * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -20,21 +18,17 @@ * 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 - * - * History: - * -------- - * 2007-03-30 initial version (anca) */ -#include -#include -#include +#include +#include +#include #include "../../core/parser/parse_content.h" #include "../../core/parser/contact/parse_contact.h" #include "../../core/parser/parse_from.h" #include "../../core/strutils.h" #include "../pua/hash.h" -#include"pua_bla.h" +#include "pua_bla.h" int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2) { @@ -85,21 +79,21 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2) } publ.pres_uri= &pto->uri; dialog.watcher_uri= publ.pres_uri; - + if (pto->tag_value.s==NULL || pto->tag_value.len==0 ) { LM_ERR("NULL to_tag value\n"); goto error; } dialog.from_tag= pto->tag_value; - + if( msg->callid==NULL || msg->callid->body.s==NULL) { LM_ERR("cannot parse callid header\n"); goto error; } dialog.call_id = msg->callid->body; - + if (!msg->from || !msg->from->body.s) { LM_ERR("cannot find 'from' header!\n"); @@ -117,13 +111,13 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2) } pfrom = (struct to_body*)msg->from->parsed; dialog.pres_uri= &pfrom->uri; - + if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0) { LM_ERR("no from tag value present\n"); goto error; } - + dialog.to_tag= pfrom->tag_value; dialog.event= BLA_EVENT; dialog.flag= BLA_SUBSCRIBE; @@ -133,7 +127,7 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2) goto error; } LM_DBG("found a matching dialog\n"); - + /* parse Subscription-State and extract expires if existing */ hdr = msg->headers; while (hdr!= NULL) @@ -183,7 +177,7 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2) goto error; } } - + if ( get_content_length(msg) == 0 ) { LM_ERR("content length= 0\n"); @@ -199,7 +193,7 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2) } body.len = get_content_length( msg ); } - + if(msg->contact== NULL || msg->contact->body.s== NULL) { LM_ERR("no contact header found"); @@ -228,25 +222,25 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2) extra_headers.len+= contact.len; memcpy(extra_headers.s+ extra_headers.len, CRLF, CRLF_LEN); extra_headers.len+= CRLF_LEN; - + publ.body= &body; publ.source_flag= BLA_PUBLISH; publ.expires= expires; publ.event= BLA_EVENT; publ.extra_headers= &extra_headers; - + if(pua_send_publish(&publ)< 0) { LM_ERR("while sending Publish\n"); goto error; } - + xmlCleanupParser(); xmlMemoryDump(); free_to_params(&TO); return 1; - + error: free_to_params(&TO); return 0; diff --git a/src/modules/pua_bla/pua_bla.c b/src/modules/pua_bla/pua_bla.c index f08e575c83e..b8616d7f3e2 100644 --- a/src/modules/pua_bla/pua_bla.c +++ b/src/modules/pua_bla/pua_bla.c @@ -1,6 +1,4 @@ /* - * $Id: pua_bla.c 1666 2007-03-02 13:40:09Z anca_vamanu $ - * * pua_bla module - pua Bridged Line Appearance * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -17,17 +15,14 @@ * 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 + * 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 - * - * History: - * -------- - * 2007-03-30 initial version (anca) */ -#include -#include +#include +#include + #include "../../core/sr_module.h" #include "../../core/dprint.h" #include "../usrloc/usrloc.h" @@ -56,7 +51,7 @@ str server_address= {0, 0}; static cmd_export_t cmds[]= { {"bla_set_flag", (cmd_function)bla_set_flag, 0, 0, 0, REQUEST_ROUTE}, - {"bla_handle_notify", (cmd_function)bla_handle_notify, 0, 0, 0, REQUEST_ROUTE}, + {"bla_handle_notify", (cmd_function)bla_handle_notify, 0, 0, 0, REQUEST_ROUTE}, {0, 0, 0, 0, 0, 0} }; static param_export_t params[]= @@ -81,7 +76,7 @@ struct module_exports exports= { 0, /* per-child init function */ 0 /* module destroy function */ }; - + /** * init module function */ @@ -97,19 +92,19 @@ static int mod_init(void) } if(!default_domain.s || default_domain.len<=0) - { + { LM_ERR("default domain not found\n"); return -1; } if(!header_name.s || header_name.len<=0) - { + { LM_ERR("header_name parameter not set\n"); return -1; } if(!bla_outbound_proxy.s || bla_outbound_proxy.len<=0) - { + { LM_DBG("No outbound proxy set\n"); } @@ -119,7 +114,7 @@ static int mod_init(void) LM_ERR("Can't bind pua\n"); return -1; } - + if (bind_pua(&pua) < 0) { LM_ERR("Can't bind pua\n"); @@ -145,12 +140,12 @@ static int mod_init(void) return -1; } pua_is_dialog= pua.is_dialog; - + if(pua.register_puacb== NULL) { LM_ERR("Could not import register callback\n"); return -1; - } + } bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) @@ -176,19 +171,19 @@ static int mod_init(void) return -1; } if(ul.register_ulcb(UL_CONTACT_EXPIRE, bla_cb, 0)< 0) - { + { LM_ERR("can not register callback for" " insert\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_UPDATE, bla_cb, 0)< 0) - { + { LM_ERR("can not register callback for" " update\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_DELETE, bla_cb, 0)< 0) - { + { LM_ERR("can not register callback for" " delete\n"); return -1; @@ -201,19 +196,19 @@ static int mod_init(void) int bla_set_flag(struct sip_msg* msg , char* s1, char* s2) { LM_DBG("mark as bla aor\n"); - + is_bla_aor= 1; - + if( parse_headers(msg,HDR_EOH_F, 0)==-1 ) { LM_ERR("parsing headers\n"); return -1; } - + if (msg->from->parsed == NULL) { - if ( parse_from_header( msg )<0 ) + if ( parse_from_header( msg )<0 ) { LM_DBG("cannot parse From header\n"); return -1; @@ -223,5 +218,5 @@ int bla_set_flag(struct sip_msg* msg , char* s1, char* s2) reg_from_uri= ((struct to_body*)(msg->from->parsed))->uri; return 1; -} +} diff --git a/src/modules/pua_bla/pua_bla.h b/src/modules/pua_bla/pua_bla.h index d99c562cf36..415edcdf508 100644 --- a/src/modules/pua_bla/pua_bla.h +++ b/src/modules/pua_bla/pua_bla.h @@ -1,6 +1,4 @@ /* - * $Id: pua_bla.h 1666 2007-03-02 13:40:09Z anca_vamanu $ - * * pua_bla module - pua Bridged Line Appearance * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -17,13 +15,9 @@ * 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 + * 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 - * - * History: - * -------- - * 2007-03-30 initial version (anca) */ #ifndef PUA_BLA_H diff --git a/src/modules/pua_bla/registrar_cb.c b/src/modules/pua_bla/registrar_cb.c index ee642423654..e7a40769071 100644 --- a/src/modules/pua_bla/registrar_cb.c +++ b/src/modules/pua_bla/registrar_cb.c @@ -1,6 +1,4 @@ /* - * $Id: registrar_cb.c 1666 2007-03-02 13:40:09Z anca_vamanu $ - * * pua_bla module - pua Bridged Line Appearance * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -17,17 +15,14 @@ * 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 + * 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 - * - * History: - * -------- - * 2007-03-30 initial version (anca) */ -#include -#include +#include +#include + #include "../../core/dprint.h" #include "../pua/pua.h" #include "registrar_cb.h" @@ -44,7 +39,7 @@ void bla_cb(ucontact_t* c, int type, void* param) { LM_DBG("Not a recognized BLA AOR\n"); return ; - } + } if(type & UL_CONTACT_INSERT) LM_DBG("type= UL_CONTACT_INSERT\n"); @@ -60,12 +55,14 @@ void bla_cb(ucontact_t* c, int type, void* param) memset(&subs, 0, sizeof(subs_info_t)); subs.remote_target= &c->c; - + subs.pres_uri= ®_from_uri; uri.s = (char*)pkg_malloc(sizeof(char)*(c->aor->len+default_domain.len+6)); - if(uri.s == NULL) + if(uri.s == NULL) { + PKG_MEM_ERROR; goto error; + } memcpy(uri.s, "sip:", 4); uri.len = 4; @@ -77,20 +74,20 @@ void bla_cb(ucontact_t* c, int type, void* param) { uri.s[uri.len++]= '@'; memcpy(uri.s+ uri.len, default_domain.s, default_domain.len); - uri.len+= default_domain.len; + uri.len+= default_domain.len; } - + subs.watcher_uri= &uri; if(type & UL_CONTACT_DELETE || type & UL_CONTACT_EXPIRE ) subs.expires= 0; else subs.expires= c->expires - (int)time(NULL); - + subs.source_flag= BLA_SUBSCRIBE; subs.event= BLA_EVENT; subs.contact= &server_address; - + if(bla_outbound_proxy.s && bla_outbound_proxy.len) subs.outbound_proxy= &bla_outbound_proxy; else @@ -105,9 +102,9 @@ void bla_cb(ucontact_t* c, int type, void* param) if(pua_send_subscribe(&subs)< 0) { LM_ERR("while sending subscribe\n"); - } + } pkg_free(uri.s); error: is_bla_aor= 0; return ; -} +} diff --git a/src/modules/pua_bla/registrar_cb.h b/src/modules/pua_bla/registrar_cb.h index 179aa9b3c36..7fc2da3f879 100644 --- a/src/modules/pua_bla/registrar_cb.h +++ b/src/modules/pua_bla/registrar_cb.h @@ -1,6 +1,4 @@ /* - * $Id: pua_bla.c 1666 2007-03-02 13:40:09Z anca_vamanu $ - * * pua_bla module - pua Bridged Line Appearance * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -17,17 +15,14 @@ * 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 + * 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 - * - * History: - * -------- - * 2007-03-30 initial version (anca) */ -#include -#include +#include +#include + #include "../../core/dprint.h" #include "../usrloc/usrloc.h"