Răsfoiți Sursa

kex: added km_append_branch

- K compatible append_branch() function
Daniel-Constantin Mierla 16 ani în urmă
părinte
comite
8cf72b2de1
3 a modificat fișierele cu 102 adăugiri și 0 ștergeri
  1. 5 0
      modules_k/kex/kex_mod.c
  2. 67 0
      modules_k/kex/km_core.c
  3. 30 0
      modules_k/kex/km_core.h

+ 5 - 0
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}
 };

+ 67 - 0
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;
+}
+

+ 30 - 0
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