Hello,
just committed to GIT support for 'include' in config file. Hopefully
this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
The path_to_file can be relative or absolute. If it is not absolute
path, first attempt is to locate it relative to current directory, and
if fails, relative to directory of the file that includes it. There is
no restriction where include can be used or what can contain - any part
of config file is ok. There is a limit of maximum 10 includes in depth,
otherwise you can use as many includes as you want. Reporting of the cfg
file syntax errors prints now the file name for easier troubleshooting.
Example:
route {
...
include /sr/checks.cfg
...
}
--- /sr/checks.cfg ---
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
}
---
Testing and feedback is much appreciated.
Cheers,
Daniel
--
Daniel-Constantin Mierla
* http://www.asipto.com/
Module: sip-router
Branch: andrei/rpc_async
Commit: 81860287cd49b762eafb49a50a0345fc89be2b93
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8186028…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 30 15:35:37 2009 +0200
core+tm: moved sip msg clone functions to the core
- moved all sip msg clone related functions to the core, since the
xmlrpc modules will need them too.
- renamed sip_msg_cloner() to sip_msg_shm_clone().
- msg_lump_cloner() is no longer static and returns 1 for no
change, 0 for successful cloning and -1 on error.
---
modules/tm/fix_lumps.h => fix_lumps.h | 1 -
modules/tm/h_table.c | 2 +-
modules/tm/sip_msg.c | 964 +-------------------------------
modules/tm/t_fwd.c | 2 +-
modules/tm/t_reply.c | 2 +-
sip_msg_clone.c | 976 +++++++++++++++++++++++++++++++++
sip_msg_clone.h | 44 ++
7 files changed, 1050 insertions(+), 941 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=818…
Module: sip-router
Branch: andrei/rpc_async
Commit: 4dc222c20c93899a35046c1559a94618fb01e84d
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4dc222c…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 30 15:45:11 2009 +0200
xmlrpc(s): basic support for delayed replies
Support for delaying replies with a few caveats:
- a special delayed reply context must be created first (via the
new rpc hooks).
- a function using this context does not have any access to the
original rpc message (so if it needs any parameters from the
original rpc request it must pass them somehow to the function
that will use the delayed reply context).
- a delayed reply context can be used _only_ from one process (is
not possible to add part of the reply from one process and
another part from another process).
- when finished the delayed reply context _must_ be closed (using
the new rpc hook). This must be done from the same process in
which the delayed reply context was used.
---
modules_s/xmlrpc/xmlrpc.c | 140 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 139 insertions(+), 1 deletions(-)
diff --git a/modules_s/xmlrpc/xmlrpc.c b/modules_s/xmlrpc/xmlrpc.c
index c140626..f386a88 100644
--- a/modules_s/xmlrpc/xmlrpc.c
+++ b/modules_s/xmlrpc/xmlrpc.c
@@ -60,6 +60,7 @@
#include "../../action.h" /* run_actions */
#include "../../script_cb.h" /* exec_*_script_cb */
#include "../../route.h" /* route_get */
+#include "../../sip_msg_clone.h" /* sip_msg_shm_clone */
#include "http.h"
/** @addtogroup xmlrpc
@@ -316,6 +317,8 @@ typedef struct rpc_ctx {
received */
struct xmlrpc_reply reply; /**< XML-RPC reply to be sent to the client */
struct rpc_struct* structs; /**< Structures to be added to the reply */
+ int msg_shm_block_size; /**< non-zero for delayed reply contexts with
+ shm cloned msgs */
int reply_sent; /**< The flag is set after a reply is sent,
this prevents a single reply being sent
twice */
@@ -330,6 +333,11 @@ typedef struct rpc_ctx {
} rpc_ctx_t;
+/* extra rpc_ctx_t flags */
+/* first 8 bits reserved for rpc flags (e.g. RET_ARRAY) */
+#define XMLRPC_DELAYED_CTX_F 256
+#define XMLRPC_DELAYED_REPLY_F 512
+
/** The structure represents a XML-RPC document structure.
*
* This is the data structure that represents XML-RPC structures that are sent
@@ -424,6 +432,9 @@ struct module_exports exports = {
#define ESC_AMP "&"
+static void clean_context(rpc_ctx_t* ctx);
+
+
/** Adds arbitrary text to the XML-RPC reply being constructed, special
* characters < and & will be escaped.
*
@@ -606,6 +617,21 @@ static int init_xmlrpc_reply(struct xmlrpc_reply* reply)
}
+
+/* if this a delayed reply context, and it's never been use before, fix it */
+static int fix_delayed_reply_ctx(rpc_ctx_t* ctx)
+{
+ if ((ctx->flags & XMLRPC_DELAYED_CTX_F) && (ctx->reply.buf.s==0)){
+ if (init_xmlrpc_reply(&ctx->reply) <0) return -1;
+ add_xmlrpc_reply(&ctx->reply, &success_prefix);
+ if (ctx->flags & RET_ARRAY)
+ return add_xmlrpc_reply(&ctx->reply, &array_prefix);
+ }
+ return 0;
+}
+
+
+
/** Free all memory used by the XML-RPC reply structure. */
static void clean_xmlrpc_reply(struct xmlrpc_reply* reply)
{
@@ -990,6 +1016,7 @@ static int rpc_add(rpc_ctx_t* ctx, char* fmt, ...)
struct xmlrpc_reply* reply;
struct rpc_struct* p;
+ fix_delayed_reply_ctx(ctx);
va_start(ap, fmt);
reply = &ctx->reply;
@@ -1479,6 +1506,7 @@ static int rpc_printf(rpc_ctx_t* ctx, char* fmt, ...)
str s;
struct xmlrpc_reply* reply;
+ fix_delayed_reply_ctx(ctx);
reply = &ctx->reply;
buf = (char*)pkg_malloc(RPC_BUF_SIZE);
if (!buf) {
@@ -1746,6 +1774,111 @@ static int rpc_struct_scan(struct rpc_struct* s, char* fmt, ...)
}
+/** Returns the RPC capabilities supported by the xmlrpc driver.
+ */
+static rpc_capabilities_t rpc_capabilities(rpc_ctx_t* ctx)
+{
+ return RPC_DELAYED_REPLY;
+}
+
+
+/** Returns a new "delayed reply" context.
+ * Creates a new delayed reply context in shm and returns it.
+ * @return 0 - not supported, already replied, or no more memory;
+ * !=0 pointer to the special delayed ctx.
+ * Note1: one should use the returned ctx reply context to build a reply and
+ * when finished call rpc_delayed_ctx_close().
+ * Note2: adding pieces to the reply in different processes is not supported.
+ */
+static struct rpc_delayed_ctx* rpc_delayed_ctx_new(rpc_ctx_t* ctx)
+{
+ struct rpc_delayed_ctx* ret;
+ int size;
+ rpc_ctx_t* r_ctx;
+ struct sip_msg* shm_msg;
+ int len;
+
+ ret=0;
+ shm_msg=0;
+
+ if (ctx->reply_sent)
+ return 0; /* no delayed reply if already replied */
+ /* clone the sip msg */
+ shm_msg=sip_msg_shm_clone(ctx->msg, &len, 1);
+ if (shm_msg==0)
+ goto error;
+
+ /* alloc into one block */
+ size=ROUND_POINTER(sizeof(*ret))+sizeof(rpc_ctx_t);
+ if ((ret=shm_malloc(size))==0)
+ goto error;
+ memset(ret, 0, size);
+ ret->rpc=func_param;
+ ret->reply_ctx=(char*)ret+ROUND_POINTER(sizeof(*ret));
+ r_ctx=ret->reply_ctx;
+ r_ctx->flags=ctx->flags | XMLRPC_DELAYED_CTX_F;
+ ctx->flags |= XMLRPC_DELAYED_REPLY_F;
+ r_ctx->msg=shm_msg;
+ r_ctx->msg_shm_block_size=len;
+
+ return ret;
+error:
+ if (shm_msg)
+ shm_free(shm_msg);
+ if (ret)
+ shm_free(ret);
+ return 0;
+}
+
+
+
+/** Closes a "delayed reply" context and sends the reply.
+ * If no reply has been sent the reply will be built and sent automatically.
+ * See the notes from rpc_new_delayed_ctx()
+ */
+static void rpc_delayed_ctx_close(struct rpc_delayed_ctx* dctx)
+{
+ rpc_ctx_t* r_ctx;
+ struct hdr_field* hdr;
+
+ r_ctx=dctx->reply_ctx;
+ if (unlikely(!(r_ctx->flags & XMLRPC_DELAYED_CTX_F))){
+ BUG("reply ctx not marked as async/delayed\n");
+ goto error;
+ }
+ if (fix_delayed_reply_ctx(r_ctx)<0)
+ goto error;
+ if (!r_ctx->reply_sent){
+ rpc_send(r_ctx);
+ }
+error:
+ clean_context(r_ctx);
+ /* collect possible garbage (e.g. generated by structures) */
+ collect_garbage();
+ /* free added lumps (rpc_send adds a body lump) */
+ del_nonshm_lump( &(r_ctx->msg->add_rm) );
+ del_nonshm_lump( &(r_ctx->msg->body_lumps) );
+ del_nonshm_lump_rpl( &(r_ctx->msg->reply_lump) );
+ /* free header's parsed structures that were added by failure handlers */
+ for( hdr=r_ctx->msg->headers ; hdr ; hdr=hdr->next ) {
+ if ( hdr->parsed && hdr_allocs_parse(hdr) &&
+ (hdr->parsed<(void*)r_ctx->msg ||
+ hdr->parsed>=(void*)(r_ctx->msg+r_ctx->msg_shm_block_size))) {
+ /* header parsed filed doesn't point inside uas.request memory
+ * chunck -> it was added by failure funcs.-> free it as pkg */
+ DBG("DBG:free_faked_req: removing hdr->parsed %d\n",
+ hdr->type);
+ clean_hdr_field(hdr);
+ hdr->parsed = 0;
+ }
+ }
+ shm_free(r_ctx->msg);
+ r_ctx->msg=0;
+ dctx->reply_ctx=0;
+ shm_free(dctx);
+}
+
+
/** Starts parsing XML-RPC document, get the name of the method to be called
* and position the cursor at the first parameter in the document.
*/
@@ -1832,6 +1965,7 @@ static void close_doc(rpc_ctx_t* ctx)
static int init_context(rpc_ctx_t* ctx, sip_msg_t* msg)
{
ctx->msg = msg;
+ ctx->msg_shm_block_size=0;
ctx->method = 0;
ctx->reply_sent = 0;
ctx->act_param = 0;
@@ -2066,7 +2200,7 @@ static int dispatch_rpc(sip_msg_t* msg, char* s1, char* s2)
skip:
/* The function may have sent the reply itself */
- if (!ctx.reply_sent) {
+ if (!ctx.reply_sent && !(ctx.flags&XMLRPC_DELAYED_REPLY_F)) {
ret = rpc_send(&ctx);
}
clean_context(&ctx);
@@ -2212,6 +2346,10 @@ static int mod_init(void)
func_param.struct_add = (rpc_struct_add_f)rpc_struct_add;
func_param.struct_scan = (rpc_struct_scan_f)rpc_struct_scan;
func_param.struct_printf = (rpc_struct_printf_f)rpc_struct_printf;
+ func_param.capabilities = (rpc_capabilities_f)rpc_capabilities;
+ func_param.delayed_ctx_new = (rpc_delayed_ctx_new_f)rpc_delayed_ctx_new;
+ func_param.delayed_ctx_close =
+ (rpc_delayed_ctx_close_f)rpc_delayed_ctx_close;
register_select_table(xmlrpc_sel);
/* register non-sip hooks */
Module: sip-router
Branch: andrei/rpc_async
Commit: e256ce91db53172264a6e42cfd5040b30dada526
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e256ce9…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 30 15:40:42 2009 +0200
core: rpc capabilities and delayed reply api
- added a new rpc function for interrogating the current rpc
transport capabilities (for now the only extra capability is
RPC_DELAYED_REPLY).
- added a new special delayed reply rpc context and rpc functions hooks for
creating and closing it.
---
rpc.h | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/rpc.h b/rpc.h
index 18e767e..1434146 100644
--- a/rpc.h
+++ b/rpc.h
@@ -37,7 +37,13 @@ enum rpc_flags {
RET_ARRAY = (1 << 0),
RET_VALUE = (1 << 1)
};
-
+
+typedef enum rpc_capabilities {
+ RPC_DELAYED_REPLY = (1 <<0) /* delayed reply support */
+} rpc_capabilities_t;
+
+struct rpc_delayed_ctx;
+
/* Send the result to the caller */
typedef int (*rpc_send_f)(void* ctx); /* Send the reply to the client */
@@ -49,6 +55,13 @@ typedef int (*rpc_struct_add_f)(void* ctx, char* fmt, ...); /* Cr
typedef int (*rpc_struct_scan_f)(void* ctx, char* fmt, ...); /* Scan attributes of a structure */
typedef int (*rpc_struct_printf_f)(void* ctx, char* name, char* fmt, ...); /* Struct version of rpc_printf */
+/* returns the supported capabilities */
+typedef rpc_capabilities_t (*rpc_capabilities_f)(void* ctx);
+/* create a special "context" for delayed replies */
+typedef struct rpc_delayed_ctx* (*rpc_delayed_ctx_new_f)(void* ctx);
+/* close the special "context" for delayed replies */
+typedef void (*rpc_delayed_ctx_close_f)(struct rpc_delayed_ctx* dctx);
+
/*
* RPC context, this is what RPC functions get as a parameter and use
* it to obtain the value of the parameters of the call and reference
@@ -63,9 +76,19 @@ typedef struct rpc {
rpc_struct_add_f struct_add;
rpc_struct_scan_f struct_scan;
rpc_struct_printf_f struct_printf;
+ rpc_capabilities_f capabilities;
+ rpc_delayed_ctx_new_f delayed_ctx_new;
+ rpc_delayed_ctx_close_f delayed_ctx_close;
} rpc_t;
+typedef struct rpc_delayed_ctx{
+ rpc_t rpc;
+ void* reply_ctx;
+ /* more private data might follow */
+} rpc_delayed_ctx_t;
+
+
/*
* RPC Function Prototype
*/
Revision: 5920
http://openser.svn.sourceforge.net/openser/?rev=5920&view=rev
Author: henningw
Date: 2009-09-03 09:07:46 +0000 (Thu, 03 Sep 2009)
Log Message:
-----------
- spelling fix in error message
Modified Paths:
--------------
branches/1.4/modules/imc/imc.c
branches/1.5/modules/imc/imc.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5919
http://openser.svn.sourceforge.net/openser/?rev=5919&view=rev
Author: henningw
Date: 2009-09-03 09:06:46 +0000 (Thu, 03 Sep 2009)
Log Message:
-----------
- spelling fix in module docs
Modified Paths:
--------------
branches/1.4/modules/carrierroute/README
branches/1.4/modules/carrierroute/doc/carrierroute_admin.xml
branches/1.4/modules/sst/README
branches/1.4/modules/sst/doc/sst_admin.xml
branches/1.5/modules/carrierroute/README
branches/1.5/modules/carrierroute/doc/carrierroute_admin.xml
branches/1.5/modules/sst/README
branches/1.5/modules/sst/doc/sst_admin.xml
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.