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

Function is_from_user_enum

modules/enum/enum.c:230–384  ·  view source on GitHub ↗

* Check if from user is a valid enum based user, and check to make sure * that the src_ip == an srv record that maps to the enum from user. */

Source from the content-addressed store, hash-verified

228 * that the src_ip == an srv record that maps to the enum from user.
229 */
230int is_from_user_enum(struct sip_msg* _msg, str* suffix, str* service)
231{
232 struct ip_addr addr;
233 struct hostent* he;
234 unsigned short zp;
235 unsigned short proto;
236 char *user_s;
237 int user_len, i, j;
238 char name[MAX_DOMAIN_SIZE];
239 char uri[MAX_URI_SIZE];
240 struct sip_uri *furi;
241 struct sip_uri luri;
242 struct rdata* head;
243
244 struct rdata* l;
245 struct naptr_rdata* naptr;
246
247 str pattern, replacement, result;
248 char string[17];
249
250 if (parse_from_header(_msg) < 0) {
251 LM_ERR("Failed to parse From header\n");
252 return -1;
253 }
254
255 if(_msg->from==NULL || get_from(_msg)==NULL) {
256 LM_DBG("No From header\n");
257 return -1;
258 }
259
260 if ((furi = parse_from_uri(_msg)) == NULL) {
261 LM_ERR("Failed to parse From URI\n");
262 return -1;
263 }
264
265 if (is_e164(&(furi->user)) == -1) {
266 LM_ERR("From URI user is not an E164 number\n");
267 return -1;
268 }
269
270 /* assert: the from user is a valid formatted e164 string */
271
272 user_s = furi->user.s;
273 user_len = furi->user.len;
274
275 j = 0;
276 for (i = user_len - 1; i > 0; i--) {
277 name[j] = user_s[i];
278 name[j + 1] = '.';
279 j = j + 2;
280 }
281
282 memcpy(name + j, suffix->s, suffix->len + 1);
283
284 head = get_record(name, T_NAPTR);
285
286 if (head == 0) {
287 LM_DBG("No NAPTR record found for %s.\n", name);

Callers

nothing calls this directly

Calls 9

parse_from_headerFunction · 0.85
parse_from_uriFunction · 0.85
get_recordFunction · 0.85
free_rdata_listFunction · 0.85
sip_matchFunction · 0.85
reg_replaceFunction · 0.85
parse_uriFunction · 0.85
sip_resolvehostFunction · 0.85
parse_naptr_regexpFunction · 0.70

Tested by

no test coverage detected