MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / init_lb_bls

Function init_lb_bls

modules/load_balancer/lb_bl.c:54–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53
54int init_lb_bls(void)
55{
56 unsigned int i;
57 struct lb_bl *lbbl;
58 str name;
59 str val;
60 char *p;
61
62 LM_DBG("Initialising lb blacklists\n");
63
64 if (blacklists == NULL)
65 return 0;
66
67 for(i = 0; i < bl_size; i++ ) {
68 LM_DBG("Processing bl definition <%s>\n", blacklists[i]);
69 /* get name */
70 p = strchr( blacklists[i], '=');
71 if (p==NULL || p==blacklists[i]) {
72 LM_ERR("blacklist definition <%s> has no name", blacklists[i]);
73 return -1;
74 }
75 name.s = blacklists[i];
76 name.len = p - name.s;
77 trim(&name);
78 if (name.len == 0) {
79 LM_ERR("empty name in blacklist definition <%s>\n", blacklists[i]);
80 return -1;
81 }
82 LM_DBG("found list name <%.*s>\n", name.len, name.s);
83 /* alloc structure */
84 lbbl = shm_malloc(sizeof(*lbbl));
85 if (lbbl == NULL) {
86 LM_ERR("no more shme memory\n");
87 return -1;
88 }
89 memset(lbbl, 0, sizeof(*lbbl));
90 /* fill in the types */
91 p++;
92 do {
93 if (lbbl->no_groups == LB_BL_MAX_SETS) {
94 LM_ERR("too many types per rule <%s>\n", blacklists[i]);
95 shm_free(lbbl);
96 return -1;
97 }
98 val.s = p;
99 p = strchr( p, ',');
100 if (p == NULL) {
101 val.len = strlen(val.s);
102 } else {
103 val.len = (int)(long)(p - val.s);
104 p++;
105 }
106 trim(&val);
107 if (val.len == 0) {
108 LM_ERR("invalid types listing in <%s>\n", blacklists[i]);
109 shm_free(lbbl);
110 return -1;
111 }

Callers 1

mod_initFunction · 0.85

Calls 6

trimFunction · 0.85
shm_mallocFunction · 0.85
shm_freeFunction · 0.85
str2intFunction · 0.85
create_bl_headFunction · 0.85
_strClass · 0.85

Tested by

no test coverage detected