Module: sip-router
Branch: master
Commit: 58796a4ea5615e4015833d08b979b3cd99b7b5a5
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=58796a4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sun Jun 26 00:43:57 2011 +0200
async: new module for asynchronous config operations
- exports async_sleep(seconds) - sleep asynchronously and continue the
exection after the seconds interval has passed
- it uses t_suspend()/t_continue()
- config execution state is lost, so a return at the same level with
async_sleep() will exit the config execution
---
modules/async/Makefile | 12 +++
modules/async/async_mod.c | 171 +++++++++++++++++++++++++++++++++++++++
modules/async/async_sleep.c | 187 +++++++++++++++++++++++++++++++++++++++++++
modules/async/async_sleep.h | 49 +++++++++++
4 files changed, 419 insertions(+), 0 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=587…
Module: sip-router
Branch: master
Commit: 486ace87c474881dd371fc98d24c960c1832f96d
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=486ace8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sat Jun 25 21:07:31 2011 +0200
core: function to return action struct from param
- moved the function from xlog module to core to be used by other
modules
- get_action_from_param(param, param_no) can return the pointer to
action structure when the pointer to pointer param and param no is
provided (like in the fixup of module functions)
---
route_struct.c | 14 ++++++++++++++
route_struct.h | 2 ++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/route_struct.c b/route_struct.c
index 371acaa..d2dee05 100644
--- a/route_struct.c
+++ b/route_struct.c
@@ -596,3 +596,17 @@ void print_actions(struct action* a)
a = a->next;
}
}
+
+/**
+ * get the pointer to action structure from parameter
+ */
+struct action *get_action_from_param(void **param, int param_no)
+{
+ struct action *ac, ac2;
+ action_u_t *au, au2;
+ /* param points to au->u.string, get pointer to au */
+ au = (void*) ((char *)param - ((char *)&au2.u.string-(char *)&au2));
+ au = au - 1 - param_no;
+ ac = (void*) ((char *)au - ((char *)&ac2.val-(char *)&ac2));
+ return ac;
+}
diff --git a/route_struct.h b/route_struct.h
index ea46a22..985f863 100644
--- a/route_struct.h
+++ b/route_struct.h
@@ -223,5 +223,7 @@ void print_expr(struct expr* exp);
/** joins to cfg file positions into a new one. */
void cfg_pos_join(struct cfg_pos* res,
struct cfg_pos* pos1, struct cfg_pos* pos2);
+
+struct action *get_action_from_param(void **param, int param_no);
#endif
Hi,
We are working on a module in which we plan to utilize the
t_suspend/t_continue functions of the tm module. t_suspend is
straightforward and is working as expected, it seems.
The last parameter of t_continue is of type 'struct action', which I can see
is defined in route_struct.h as:
struct action{
int cline;
char *cfile;
enum action_type type; /* forward, drop, log, send ...*/
int count;
struct action* next;
action_u_t val[MAX_ACTIONS];
};
Does anyone have any practical advice on how to create an action to be used
in t_continue?
Also... when t_continue is called, does it continue processing in the
process that calls t_continue, or is execution handed off to another
process?
Thank you!
Matthew Williams
FlowRoute
Module: sip-router
Branch: master
Commit: 62ed44d1cf6f5f2c824604bcafe54619c298ceaf
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=62ed44d…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Fri Jun 3 13:38:32 2011 +0200
cfg framework: functions to iterate though the group instances
Two functions, cfg_select_first and cfg_select_next, are added
which can be used to iterate though the instances of a cfg group.
---
cfg/cfg_struct.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
cfg/cfg_struct.h | 21 +++++++++++++++++
2 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/cfg/cfg_struct.c b/cfg/cfg_struct.c
index 4e247cd..6e93ca0 100644
--- a/cfg/cfg_struct.c
+++ b/cfg/cfg_struct.c
@@ -1169,3 +1169,68 @@ int cfg_reset(cfg_group_t *group)
group->name_len, group->name);
return 0;
}
+
+/* Move the group handle to the first group instance.
+ * This function together with cfg_select_next() can be used
+ * to iterate though the list of instances.
+ *
+ * Return value:
+ * -1: no group instance found
+ * 0: first group instance is successfully selected.
+ */
+int cfg_select_first(cfg_group_t *group)
+{
+ cfg_group_meta_t *meta;
+ cfg_group_inst_t *ginst;
+
+ meta = CFG_GROUP_META(cfg_local, group);
+ if (!meta || (meta->num == 0))
+ return -1;
+
+ ginst = (cfg_group_inst_t *)meta->array;
+ cfg_move_handle(group,
+ CFG_HANDLE_TO_GINST(*(group->handle)), /* the active group instance */
+ ginst);
+
+ LOG(L_DBG, "DEBUG: cfg_select_first(): group instance '%.*s[%u]' has been selected\n",
+ group->name_len, group->name, ginst->id);
+ return 0;
+}
+
+/* Move the group handle to the next group instance.
+ * This function together with cfg_select_first() can be used
+ * to iterate though the list of instances.
+ *
+ * Return value:
+ * -1: no more group instance found. Note, that the active group
+ * instance is not changed in this case.
+ * 0: the next group instance is successfully selected.
+ */
+int cfg_select_next(cfg_group_t *group)
+{
+ cfg_group_meta_t *meta;
+ cfg_group_inst_t *old_ginst, *new_ginst;
+ int size;
+
+ if (!(meta = CFG_GROUP_META(cfg_local, group)))
+ return -1;
+
+ if (!(old_ginst = CFG_HANDLE_TO_GINST(*(group->handle)) /* the active group instance */)) {
+ LOG(L_ERR, "ERROR: cfg_select_next(): No group instance is set currently. Forgot to call cfg_select_first()?\n");
+ return -1;
+ }
+
+ size = sizeof(cfg_group_inst_t) + group->size - 1;
+ if (((char *)old_ginst - (char *)meta->array)/size + 1 >= meta->num)
+ return -1; /* this is the last group instance */
+
+ new_ginst = (cfg_group_inst_t *)((char *)old_ginst + size);
+ cfg_move_handle(group,
+ old_ginst, /* the active group instance */
+ new_ginst);
+
+ LOG(L_DBG, "DEBUG: cfg_select_next(): group instance '%.*s[%u]' has been selected\n",
+ group->name_len, group->name, new_ginst->id);
+ return 0;
+}
+
diff --git a/cfg/cfg_struct.h b/cfg/cfg_struct.h
index f835a7e..2e91691 100644
--- a/cfg/cfg_struct.h
+++ b/cfg/cfg_struct.h
@@ -513,4 +513,25 @@ int cfg_select(cfg_group_t *group, unsigned int id);
/* Reset the group handle to the default, local configuration */
int cfg_reset(cfg_group_t *group);
+/* Move the group handle to the first group instance.
+ * This function together with cfg_select_next() can be used
+ * to iterate though the list of instances.
+ *
+ * Return value:
+ * -1: no group instance found
+ * 0: first group instance is successfully selected.
+ */
+int cfg_select_first(cfg_group_t *group);
+
+/* Move the group handle to the next group instance.
+ * This function together with cfg_select_first() can be used
+ * to iterate though the list of instances.
+ *
+ * Return value:
+ * -1: no more group instance found. Note, that the active group
+ * instance is not changed in this case.
+ * 0: the next group instance is successfully selected.
+ */
+int cfg_select_next(cfg_group_t *group);
+
#endif /* _CFG_STRUCT_H */
Module: sip-router
Branch: master
Commit: 78ccd1bb98b1329f0ee9d5acaaa5242ef4d797bc
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=78ccd1b…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Fri Jun 24 15:10:51 2011 +0200
cfg framework: set the handle before creating the cfg group
The handle must be set before the config group is created
because the related functions save the value for future use.
The tcp and sctp config handles are not initialized to the default
config struction. This cased a crash because orig_handle was set to
the initial value which is uninitialized.
---
cfg/cfg.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/cfg/cfg.c b/cfg/cfg.c
index 2d0f640..0c4d404 100644
--- a/cfg/cfg.c
+++ b/cfg/cfg.c
@@ -141,6 +141,14 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
goto error;
}
+ /* The cfg variables are ready to use, let us set the handle
+ before passing the new definitions to the drivers.
+ We make the interface usable for the fixup functions
+ at this step
+ cfg_set_group() and cfg_new_group() need the handle to be set because
+ they save its original value. */
+ *handle = values;
+
group_name_len = strlen(group_name);
/* check for duplicates */
if ((group = cfg_lookup_group(group_name, group_name_len))) {
@@ -162,12 +170,6 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
}
group->dynamic = CFG_GROUP_STATIC;
- /* The cfg variables are ready to use, let us set the handle
- before passing the new definitions to the drivers.
- We make the interface usable for the fixup functions
- at this step */
- *handle = values;
-
/* notify the drivers about the new config definition */
cfg_notify_drivers(group_name, group_name_len, def);
Module: sip-router
Branch: master
Commit: 2ebc2cac489596f6b19bc1cebf25b57b1b69331c
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2ebc2ca…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Fri Jun 3 14:37:03 2011 +0200
cfg framework: safety checks added
Verify that the child process has a local configuration
in the functions that work with config group instances.
---
cfg/cfg_struct.c | 60 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/cfg/cfg_struct.c b/cfg/cfg_struct.c
index 6e93ca0..c10dd55 100644
--- a/cfg/cfg_struct.c
+++ b/cfg/cfg_struct.c
@@ -1100,26 +1100,28 @@ void cfg_move_handle(cfg_group_t *group, cfg_group_inst_t *src_ginst, cfg_group_
dst_ginst->vars
: CFG_GROUP_DATA(cfg_local, group);
- /* call the per child process callback of those variables
- that have different value in the two group instances */
- /* TODO: performance optimization: this entire loop can be
- skipped if the group does not have any variable with
- per-child process callback. Use some flag in the group
- structure for this purpose. */
- gname.s = group->name;
- gname.len = group->name_len;
- for (i = 0; i < CFG_MAX_VAR_NUM/(sizeof(int)*8); i++) {
- bitmap = ((src_ginst) ? src_ginst->set[i] : 0U)
- | ((dst_ginst) ? dst_ginst->set[i] : 0U);
- while (bitmap) {
- pos = bit_scan_forward32(bitmap);
- var = &group->mapping[pos + i*sizeof(int)*8];
- if (var->def->on_set_child_cb) {
- vname.s = var->def->name;
- vname.len = var->name_len;
- var->def->on_set_child_cb(&gname, &vname);
+ if (cfg_child_cb != CFG_NO_CHILD_CBS) {
+ /* call the per child process callback of those variables
+ that have different value in the two group instances */
+ /* TODO: performance optimization: this entire loop can be
+ skipped if the group does not have any variable with
+ per-child process callback. Use some flag in the group
+ structure for this purpose. */
+ gname.s = group->name;
+ gname.len = group->name_len;
+ for (i = 0; i < CFG_MAX_VAR_NUM/(sizeof(int)*8); i++) {
+ bitmap = ((src_ginst) ? src_ginst->set[i] : 0U)
+ | ((dst_ginst) ? dst_ginst->set[i] : 0U);
+ while (bitmap) {
+ pos = bit_scan_forward32(bitmap);
+ var = &group->mapping[pos + i*sizeof(int)*8];
+ if (var->def->on_set_child_cb) {
+ vname.s = var->def->name;
+ vname.len = var->name_len;
+ var->def->on_set_child_cb(&gname, &vname);
+ }
+ bitmap -= (1U << pos);
}
- bitmap -= (1U << pos);
}
}
/* keep track of how many group instences are set in the child process */
@@ -1140,6 +1142,11 @@ int cfg_select(cfg_group_t *group, unsigned int id)
{
cfg_group_inst_t *ginst;
+ if (!cfg_local) {
+ LOG(L_ERR, "ERROR: The child process has no local configuration\n");
+ return -1;
+ }
+
if (!(ginst = cfg_find_group(CFG_GROUP_META(cfg_local, group),
group->size,
id))
@@ -1161,6 +1168,11 @@ int cfg_select(cfg_group_t *group, unsigned int id)
/* Reset the group handle to the default, local configuration */
int cfg_reset(cfg_group_t *group)
{
+ if (!cfg_local) {
+ LOG(L_ERR, "ERROR: The child process has no local configuration\n");
+ return -1;
+ }
+
cfg_move_handle(group,
CFG_HANDLE_TO_GINST(*(group->handle)), /* the active group instance */
NULL);
@@ -1183,6 +1195,11 @@ int cfg_select_first(cfg_group_t *group)
cfg_group_meta_t *meta;
cfg_group_inst_t *ginst;
+ if (!cfg_local) {
+ LOG(L_ERR, "ERROR: The child process has no local configuration\n");
+ return -1;
+ }
+
meta = CFG_GROUP_META(cfg_local, group);
if (!meta || (meta->num == 0))
return -1;
@@ -1212,6 +1229,11 @@ int cfg_select_next(cfg_group_t *group)
cfg_group_inst_t *old_ginst, *new_ginst;
int size;
+ if (!cfg_local) {
+ LOG(L_ERR, "ERROR: The child process has no local configuration\n");
+ return -1;
+ }
+
if (!(meta = CFG_GROUP_META(cfg_local, group)))
return -1;