int ds_hash_fromuri(struct sip_msg *msg, unsigned int *hash) { str from; if(msg==NULL || hash == NULL) { LOG(L_ERR, "DISPATCHER:ds_hash_fromuri: bad parameters\n"); return -1; } if(parse_from_header(msg)==-1) { LOG(L_ERR, "DISPATCHER:ds_hash_fromuri:ERROR cannot parse From hdr\n"); return -1; } if(msg->from==NULL || get_from(msg)==NULL) { LOG(L_ERR, "DISPATCHER:ds_hash_fromuri:ERROR cannot get From uri\n"); return -1; } from.s = get_from(msg)->uri.s; from.len = get_from(msg)->uri.len; trim(&from); *hash = ds_get_hash(&from, NULL); return 0; }
int ds_hash_touri(struct sip_msg *msg, unsigned int *hash) { str to; str key1; str key2; if(msg==NULL || hash == NULL) { LOG(L_ERR, "DISPATCHER:ds_hash_touri: bad parameters\n"); return -1; } if ((msg->to==0) && ((parse_headers(msg, HDR_TO_F, 0)==-1) || (msg->to==0))) { LOG(L_ERR, "DISPATCHER:ds_hash_touri:ERROR cannot parse To hdr\n"); return -1; } to = get_to(msg)->uri; trim(&to); if (get_uri_hash_keys(&key1, &key2, &to, 0, ds_flags)<0) return -1; *hash = ds_get_hash(&key1, &key2); return 0; }
int ds_hash_fromuri(struct sip_msg *msg, unsigned int *hash) { str from; str key1; str key2; if(msg==NULL || hash == NULL) { LOG(L_ERR, "DISPATCHER:ds_hash_fromuri: bad parameters\n"); return -1; } if(parse_from_header(msg)==-1) { LOG(L_ERR, "DISPATCHER:ds_hash_fromuri:ERROR cannot parse From hdr\n"); return -1; } if(msg->from==NULL || get_from(msg)==NULL) { LOG(L_ERR, "DISPATCHER:ds_hash_fromuri:ERROR cannot get From uri\n"); return -1; } from = get_from(msg)->uri; trim(&from); if (get_uri_hash_keys(&key1, &key2, &from, 0, ds_flags)<0) return -1; *hash = ds_get_hash(&key1, &key2); return 0; }
int ds_hash_pvar(struct sip_msg *msg, unsigned int *hash) { /* The String to create the hash */ str hash_str = {0, 0}; if(msg==NULL || hash == NULL || hash_param_model == NULL) { LM_ERR("bad parameters\n"); return -1; } if (pv_printf_s(msg, hash_param_model, &hash_str)<0) { LM_ERR("error - cannot print the format\n"); return -1; } /* Remove empty spaces */ trim(&hash_str); if (hash_str.len <= 0) { LM_ERR("String is empty!\n"); return -1; } LM_DBG("Hashing %.*s!\n", hash_str.len, hash_str.s); *hash = ds_get_hash(&hash_str, NULL); return 0; }
int ds_hash_authusername(struct sip_msg *msg, unsigned int *hash) { /* Header, which contains the authorization */ struct hdr_field* h = 0; /* The Username */ str username = {0, 0}; /* The Credentials from this request */ auth_body_t* cred; if(msg==NULL || hash == NULL) { LM_ERR("bad parameters\n"); return -1; } if (parse_headers(msg, HDR_PROXYAUTH_F, 0) == -1) { LM_ERR("error parsing headers!\n"); return -1; } if (msg->proxy_auth && !msg->proxy_auth->parsed) parse_credentials(msg->proxy_auth); if (msg->proxy_auth && msg->proxy_auth->parsed) { h = msg->proxy_auth; } if (!h) { if (parse_headers(msg, HDR_AUTHORIZATION_F, 0) == -1) { LM_ERR("error parsing headers!\n"); return -1; } if (msg->authorization && !msg->authorization->parsed) parse_credentials(msg->authorization); if (msg->authorization && msg->authorization->parsed) { h = msg->authorization; } } if (!h) { LM_DBG("No Authorization-Header!\n"); return 1; } cred=(auth_body_t*)(h->parsed); if (!cred || !cred->digest.username.user.len) { LM_ERR("No Authorization-Username or Credentials!\n"); return 1; } username.s = cred->digest.username.user.s; username.len = cred->digest.username.user.len; trim(&username); *hash = ds_get_hash(&username, NULL); return 0; }
int ds_hash_callid(struct sip_msg *msg, unsigned int *hash) { str cid; if(msg==NULL || hash == NULL) { LOG(L_ERR, "DISPATCHER:ds_hash_callid: bad parameters\n"); return -1; } if(msg->callid==NULL && ((parse_headers(msg, HDR_CALLID, 0)==-1) || (msg->callid==NULL)) ) { LOG(L_ERR, "DISPATCHER:ds_hash_callid:ERROR cannot parse Call-Id\n"); return -1; } cid.s = msg->callid->body.s; cid.len = msg->callid->body.len; trim(&cid); *hash = ds_get_hash(&cid, NULL); return 0; }
int ds_hash_ruri(struct sip_msg *msg, unsigned int *hash) { str* uri; str key1; str key2; if(msg==NULL || hash == NULL) { LOG(L_ERR, "DISPATCHER:ds_hash_ruri: bad parameters\n"); return -1; } if (parse_sip_msg_uri(msg)<0){ LOG(L_ERR, "DISPATCHER: ds_hash_ruri: ERROR: bad request uri\n"); return -1; } uri=GET_RURI(msg); if (get_uri_hash_keys(&key1, &key2, uri, &msg->parsed_uri, ds_flags)<0) return -1; *hash = ds_get_hash(&key1, &key2); return 0; }