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

Function parse_destination_list

modules/drouting/routing.c:84–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84int parse_destination_list(rt_data_t* rd, char *dstlist, pgw_list_t** pgwl_ret,
85 unsigned short *len, int no_resize, osips_malloc_f mf)
86{
87#define PGWL_SIZE 32
88 pgw_list_t *pgwl=NULL, *p = NULL;
89 unsigned int size, pgwl_size;
90 long int t;
91 char *tmp, *ep;
92 str id;
93
94
95 /* temporary list of gw while parsing */
96 pgwl_size = PGWL_SIZE;
97 pgwl = (pgw_list_t*)pkg_malloc(pgwl_size*sizeof(pgw_list_t));
98 if (pgwl==NULL) {
99 LM_ERR("no more shm mem\n");
100 goto error;
101 }
102 memset(pgwl, 0, pgwl_size*sizeof(pgw_list_t));
103
104 /* parset the destination list */
105 tmp = dstlist;
106 size = 0;
107 /* parse the dstlst */
108 while(tmp && (*tmp!=0)) {
109
110 /* need a larger array ? */
111 if(size>=pgwl_size){
112 p=(pgw_list_t*)pkg_malloc((pgwl_size*2)*sizeof(pgw_list_t));
113 if (p==NULL) {
114 LM_ERR("not enough shm mem to resize\n");
115 goto error;
116 }
117 memset( p+pgwl_size, 0, pgwl_size*sizeof(pgw_list_t));
118 memcpy( p, pgwl, pgwl_size*sizeof(pgw_list_t));
119 pkg_free(pgwl);
120 pgwl_size*=2;
121 pgwl=p;
122 }
123
124 /* go over spaces */
125 EAT_SPACE(tmp);
126
127 /* carrier id or GW id ? */
128 if (*tmp==CARRIER_MARKER) {
129 pgwl[size].is_carrier = 1;
130 tmp++;
131 }
132
133 /* eat the destination ID (alphanumerical) */
134 id.s = tmp;
135 while( *tmp && is_valid_gw_char(*tmp))
136 tmp++;
137 if (id.s == tmp) {
138 LM_ERR("bad id '%c' (%d)[%s]\n",
139 *tmp, (int)(tmp-dstlist), dstlist);
140 goto error;
141 }

Callers 3

do_routingFunction · 0.85
add_carrierFunction · 0.85
build_rt_infoFunction · 0.85

Calls 2

get_carrier_by_idFunction · 0.85
get_gw_by_idFunction · 0.85

Tested by

no test coverage detected