Module: sip-router Branch: master Commit: 8cf72b2de1ca86cafe7203433ff411e837d26dfa URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8cf72b2d...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Tue Apr 28 19:23:23 2009 +0200
kex: added km_append_branch
- K compatible append_branch() function
---
modules_k/kex/kex_mod.c | 5 +++ modules_k/kex/km_core.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ modules_k/kex/km_core.h | 30 +++++++++++++++++++++ 3 files changed, 102 insertions(+), 0 deletions(-)
diff --git a/modules_k/kex/kex_mod.c b/modules_k/kex/kex_mod.c index e4960c0..9baa48d 100644 --- a/modules_k/kex/kex_mod.c +++ b/modules_k/kex/kex_mod.c @@ -31,6 +31,7 @@ #include "../../mod_fix.h"
#include "flags.h" +#include "km_core.h" #include "mi_core.h" #include "core_stats.h"
@@ -63,6 +64,10 @@ static cmd_export_t cmds[]={ 0, ANY_ROUTE }, {"isbflagset", (cmd_function)w_isbflagset, 2,fixup_igp_igp, 0, ANY_ROUTE }, + {"km_append_branch", (cmd_function)w_km_append_branch, 0, 0, + 0, REQUEST_ROUTE | FAILURE_ROUTE }, + {"km_append_branch", (cmd_function)w_km_append_branch, 1, fixup_spve_null, + 0, REQUEST_ROUTE | FAILURE_ROUTE },
{0,0,0,0,0,0} }; diff --git a/modules_k/kex/km_core.c b/modules_k/kex/km_core.c new file mode 100644 index 0000000..beebb35 --- /dev/null +++ b/modules_k/kex/km_core.c @@ -0,0 +1,67 @@ +/** + * $Id$ + * + * Copyright (C) 2009 + * + * This file is part of SIP-Router.org, a free SIP server. + * + * SIP-Router 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "../../dprint.h" +#include "../../dset.h" +#include "../../flags.h" +#include "../../mod_fix.h" +#include "km_core.h" + +int w_km_append_branch(struct sip_msg *msg, char *uri, str *sq) +{ + str suri; + int ret; + int q = Q_UNSPECIFIED; + flag_t branch_flags = 0; + + getbflagsval(0, &branch_flags); + if (uri==NULL) { + ret = km_append_branch(msg, 0, &msg->dst_uri, &msg->path_vec, + q, branch_flags, msg->force_send_socket); + /* reset all branch info */ + msg->force_send_socket = 0; + setbflagsval(0, 0); + if(msg->dst_uri.s!=0) + pkg_free(msg->dst_uri.s); + msg->dst_uri.s = 0; + msg->dst_uri.len = 0; + if(msg->path_vec.s!=0) + pkg_free(msg->path_vec.s); + msg->path_vec.s = 0; + msg->path_vec.len = 0; + } else { + if(fixup_get_svalue(msg, (gparam_p)uri, &suri)!=0) + { + LM_ERR("cannot get the URI parameter\n"); + return -1; + } + ret = km_append_branch(msg, &suri, &msg->dst_uri, + &msg->path_vec, q, branch_flags, + msg->force_send_socket); + } + return ret; +} + diff --git a/modules_k/kex/km_core.h b/modules_k/kex/km_core.h new file mode 100644 index 0000000..a668c71 --- /dev/null +++ b/modules_k/kex/km_core.h @@ -0,0 +1,30 @@ +/** + * $Id$ + * + * Copyright (C) 2009 + * + * This file is part of SIP-Router.org, a free SIP server. + * + * SIP-Router 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _KEX_CORE_H_ +#define _KEX_CORE_H_ + +#include "../../sr_module.h" + +int w_km_append_branch(struct sip_msg *msg, char *uri, str *s2); + +#endif