git:master:793a4a64: cfgutils: rand functions exported to kemi framework

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

git:master:793a4a64: cfgutils: rand functions exported to kemi framework

Daniel-Constantin Mierla-6
Module: kamailio
Branch: master
Commit: 793a4a642d702fbaf403d9e523ed715dd6303619
URL: https://github.com/kamailio/kamailio/commit/793a4a642d702fbaf403d9e523ed715dd6303619

Author: Daniel-Constantin Mierla <[hidden email]>
Committer: Daniel-Constantin Mierla <[hidden email]>
Date: 2017-06-12T09:10:08+02:00

cfgutils: rand functions exported to kemi framework

---

Modified: src/modules/cfgutils/cfgutils.c

---

Diff:  https://github.com/kamailio/kamailio/commit/793a4a642d702fbaf403d9e523ed715dd6303619.diff
Patch: https://github.com/kamailio/kamailio/commit/793a4a642d702fbaf403d9e523ed715dd6303619.patch

---

diff --git a/src/modules/cfgutils/cfgutils.c b/src/modules/cfgutils/cfgutils.c
index c9325ddc3a..e4560f7226 100644
--- a/src/modules/cfgutils/cfgutils.c
+++ b/src/modules/cfgutils/cfgutils.c
@@ -541,18 +541,35 @@ static int set_prob(struct sip_msg *bar, char *percent_par, char *foo)
  return 1;
 }
 
+static int ki_rand_set_prob(sip_msg_t *msg, int percent_par)
+{
+ *probability=percent_par;
+ return 1;
+}
+
 static int reset_prob(struct sip_msg *bar, char *percent_par, char *foo)
 {
  *probability=initial_prob;
  return 1;
 }
 
+static int ki_rand_reset_prob(sip_msg_t *msg)
+{
+ *probability=initial_prob;
+ return 1;
+}
+
 static int get_prob(struct sip_msg *bar, char *foo1, char *foo2)
 {
  return *probability;
 }
 
-static int rand_event(struct sip_msg *bar, char *foo1, char *foo2)
+static int ki_rand_get_prob(sip_msg_t *bar)
+{
+ return *probability;
+}
+
+static int ki_rand_event(sip_msg_t *msg)
 {
  double tmp;
  /* most of the time this will be disabled completly. Tis will also fix the
@@ -572,6 +589,11 @@ static int rand_event(struct sip_msg *bar, char *foo1, char *foo2)
  }
 }
 
+static int rand_event(struct sip_msg *bar, char *foo1, char *foo2)
+{
+ return ki_rand_event(bar);
+}
+
 static int pv_get_random_val(struct sip_msg *msg, pv_param_t *param,
  pv_value_t *res)
 {
@@ -925,6 +947,26 @@ static sr_kemi_t sr_kemi_cfgutils_exports[] = {
  { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
  SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
  },
+ { str_init("cfgutils"), str_init("rand_set_prob"),
+ SR_KEMIP_INT, ki_rand_set_prob,
+ { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("cfgutils"), str_init("rand_reset_prob"),
+ SR_KEMIP_INT, ki_rand_reset_prob,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("cfgutils"), str_init("rand_get_prob"),
+ SR_KEMIP_INT, ki_rand_get_prob,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("cfgutils"), str_init("rand_event"),
+ SR_KEMIP_INT, ki_rand_event,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
 
  { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };


_______________________________________________
Kamailio (SER) - Development Mailing List
[hidden email]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Loading...