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

Function get_group_id

modules/drouting/drouting.c:2445–2510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2443
2444
2445static inline int get_group_id(struct sip_uri *uri, struct head_db *
2446 current_partition)
2447{
2448 db_key_t keys_ret[1];
2449 db_key_t keys_cmp[2];
2450 db_val_t vals_cmp[2];
2451 db_res_t* res = 0;
2452 int n;
2453
2454 /* user */
2455 keys_cmp[0] = &drg_user_col;
2456 vals_cmp[0].type = DB_STR;
2457 vals_cmp[0].nul = 0;
2458 vals_cmp[0].val.str_val = uri->user;
2459 n = 1;
2460
2461 if (use_domain) {
2462 keys_cmp[1] = &drg_domain_col;
2463 vals_cmp[1].type = DB_STR;
2464 vals_cmp[1].nul = 0;
2465 vals_cmp[1].val.str_val = uri->host;
2466 n++;
2467 }
2468
2469 keys_ret[0] = &drg_grpid_col;
2470 res = 0;
2471
2472
2473 if( (current_partition->db_funcs).use_table(*(current_partition->db_con),
2474 &(current_partition->drg_table))<0 ) {
2475 LM_ERR("cannot select table \"%.*s\"\n",
2476 (current_partition->drg_table).len,
2477 (current_partition->drg_table).s);
2478 goto error;
2479 }
2480 if ( (current_partition->db_funcs).query(*(current_partition->db_con),
2481 keys_cmp,0,vals_cmp,keys_ret,n,1,0,&res)<0 ) {
2482 LM_ERR("DB query failed\n");
2483 goto error;
2484 }
2485
2486 if (RES_ROW_N(res) == 0) {
2487 if (dr_default_grp!=-1) {
2488 (current_partition->db_funcs).free_result
2489 (*(current_partition->db_con), res);
2490 return dr_default_grp;
2491 }
2492 LM_ERR("no group for user "
2493 "\"%.*s\"@\"%.*s\"\n", uri->user.len, uri->user.s,
2494 uri->host.len, uri->host.s);
2495 goto error;
2496 }
2497 if (res->rows[0].values[0].nul || res->rows[0].values[0].type!=DB_INT) {
2498 LM_ERR("null or non-integer group_id\n");
2499 goto error;
2500 }
2501 n = res->rows[0].values[0].val.int_val;
2502

Callers 1

do_routingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected