Module: kamailio
Branch: master
Commit: b6cd84b999030acb2db03ce9ff9d3de4d942fff9
URL: 
https://github.com/kamailio/kamailio/commit/b6cd84b999030acb2db03ce9ff9d3de4d942fff9

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2024-06-06T20:32:36+02:00

dispatcher: new set of attributes oc-based routing

- ocmin, ocmax and ocrate

---

Modified: src/modules/dispatcher/dispatch.c
Modified: src/modules/dispatcher/dispatch.h

---

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

---

diff --git a/src/modules/dispatcher/dispatch.c 
b/src/modules/dispatcher/dispatch.c
index 9e27f998c25..d22188ada1f 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -79,6 +79,7 @@
 #define DS_ALG_RELWEIGHT 11
 #define DS_ALG_PARALLEL 12
 #define DS_ALG_LATENCY 13
+#define DS_ALG_OVERLOAD 14
 
 #define DS_HN_SIZE 256
 
@@ -376,8 +377,33 @@ int ds_set_attrs(ds_dest_t *dest, str *vattrs)
                } else if(pit->name.len == 7
                                  && strncasecmp(pit->name.s, "obproxy", 7) == 
0) {
                        dest->attrs.obproxy = pit->body;
+               } else if(pit->name.len == 5
+                                 && strncasecmp(pit->name.s, "ocmin", 5) == 0) 
{
+                       str2int(&pit->body, &dest->attrs.ocmin);
+               } else if(pit->name.len == 5
+                                 && strncasecmp(pit->name.s, "ocmax", 5) == 0) 
{
+                       str2int(&pit->body, &dest->attrs.ocmax);
+               } else if(pit->name.len == 6
+                                 && strncasecmp(pit->name.s, "ocrate", 6) == 
0) {
+                       str2int(&pit->body, &dest->attrs.ocmin);
                }
        }
+       if(dest->attrs.ocmax <= 0 || dest->attrs.ocmax > 100) {
+               dest->attrs.ocmax = 100;
+       }
+       if(dest->attrs.ocmin <= 0 || dest->attrs.ocmin > 100) {
+               dest->attrs.ocmin = 10;
+       }
+       if(dest->attrs.ocrate <= 0 || dest->attrs.ocrate > 100) {
+               dest->attrs.ocrate = 10;
+       }
+       if(dest->attrs.ocrate < dest->attrs.ocmin) {
+               dest->attrs.ocrate = dest->attrs.ocmin;
+       }
+       if(dest->attrs.ocrate > dest->attrs.ocmax) {
+               dest->attrs.ocrate = dest->attrs.ocmax;
+       }
+
        if(params_list)
                free_params(params_list);
        return 0;
diff --git a/src/modules/dispatcher/dispatch.h 
b/src/modules/dispatcher/dispatch.h
index a887c555932..296097b7e97 100644
--- a/src/modules/dispatcher/dispatch.h
+++ b/src/modules/dispatcher/dispatch.h
@@ -204,6 +204,9 @@ typedef struct _ds_attrs {
        str ping_from;
        str obproxy;
        int rpriority;
+       uint32_t ocmin;
+       uint32_t ocmax;
+       uint32_t ocrate;
 } ds_attrs_t;
 
 typedef struct _ds_latency_stats {
@@ -236,6 +239,8 @@ typedef struct _ds_dest {
        unsigned short int proto;       /*!< protocol of the URI */
        int message_count;
        struct timeval dnstime;
+       uint32_t ocidx;
+       uint32_t ocdist[100];
        struct _ds_dest *next;
 } ds_dest_t;
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to [email protected]

Reply via email to