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

Function register_dr_cb

modules/drouting/dr_cb.c:111–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111int register_dr_cb(enum drcb_types type, dr_cb f, void *param,
112 dr_param_free_cb ff)
113{
114 sort_cb_type alg = (sort_cb_type)(intptr_t)param;
115 struct dr_callback *cb;
116
117 cb = pkg_malloc(sizeof *cb);
118 if (!cb) {
119 LM_ERR("oom\n");
120 return -1;
121 }
122 memset(cb, 0, sizeof *cb);
123
124 cb->callback = f;
125 cb->callback_param_free = ff;
126
127 if (type != DRCB_SORT_DST) {
128 cb->param = param; /* because now param holds the type of the
129 * sorting function */
130 /* insert callback to the right list (based on type) */
131 if (dr_cbs[type] == POINTER_CLOSED_MARKER) {
132 LM_CRIT("DRCB_SORT_DST registered after shut down!\n");
133 goto error;
134 }
135 cb->next = dr_cbs[type];
136 dr_cbs[type] = cb;
137 } else {
138 if (alg >= N_MAX_SORT_CBS) {
139 LM_ERR("invalid sorting algorithm: %u\n", alg);
140 goto error;
141 }
142
143 if (dr_sort_cbs[alg])
144 LM_WARN("sort callback for alg %u will be overwritten\n", alg);
145
146 dr_sort_cbs[alg] = cb;
147 }
148
149 return 0;
150error:
151 pkg_free(cb);
152 return -1;
153}
154
155
156/* runs a callback from an array - sort_cb_type will represent

Callers 1

dr_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected