void * sca_hash_table_kv_find( sca_hash_table *ht, str *key ) { int slot_idx; slot_idx = sca_hash_table_index_for_key( ht, key ); return( sca_hash_table_index_kv_find( ht, slot_idx, key )); }
int sca_hash_table_kv_delete( sca_hash_table *ht, str *key ) { int slot_idx; slot_idx = sca_hash_table_index_for_key( ht, key ); return( sca_hash_table_index_kv_delete( ht, slot_idx, key )); }
int sca_hash_table_kv_insert( sca_hash_table *ht, str *key, void *value, int (*e_compare)(str *, void *), void (*e_description)(void *), void (*e_free)(void *)) { int hash_idx; int rc; assert( ht != NULL && !SCA_STR_EMPTY( key ) && value != NULL ); hash_idx = sca_hash_table_index_for_key( ht, key ); rc = sca_hash_table_index_kv_insert( ht, hash_idx, value, e_compare, e_description, e_free ); return( rc ); }
/* * send a call-info NOTIFY to all subscribers to a given SCA AoR. */ int sca_notify_call_info_subscribers(sca_mod *scam, str *subscription_aor) { sca_hash_slot *slot; sca_hash_entry *e; sca_subscription *sub; str headers = STR_NULL; str hash_key = STR_NULL; char hdrbuf[SCA_HEADERS_MAX_LEN]; char keybuf[512]; char *event_name; int slot_idx; int rc = -1; assert(scam->subscriptions != NULL); assert(!SCA_STR_EMPTY(subscription_aor)); LM_DBG("Notifying ALL subscribers of AOR %.*s due to a SUBSCRIBTION request\n", STR_FMT(subscription_aor)); event_name = sca_event_name_from_type(SCA_EVENT_TYPE_CALL_INFO); if (subscription_aor->len + strlen(event_name) >= sizeof(keybuf)) { LM_ERR("Hash key %.*s + %s is too long\n", STR_FMT(subscription_aor), event_name); return (-1); } hash_key.s = keybuf; SCA_STR_COPY(&hash_key, subscription_aor); SCA_STR_APPEND_CSTR(&hash_key, event_name); slot_idx = sca_hash_table_index_for_key(scam->subscriptions, &hash_key); slot = sca_hash_table_slot_for_index(scam->subscriptions, slot_idx); sca_hash_table_lock_index(scam->subscriptions, slot_idx); for (e = slot->entries; e != NULL; e = e->next) { sub = (sca_subscription *) e->value; if (!SCA_STR_EQ(subscription_aor, &sub->target_aor)) { continue; } if (headers.len == 0) { headers.s = hdrbuf; if (sca_notify_build_headers_from_info(&headers, sizeof(hdrbuf), scam, sub, SCA_CALL_INFO_APPEARANCE_INDEX_ANY) < 0) { LM_ERR("Failed to build NOTIFY headers\n"); goto done; } } // XXX would like this to be wrapped in one location sub->dialog.notify_cseq += 1; if (sca_notify_subscriber_internal(scam, sub, &headers) < 0) { goto done; } } rc = 1; done: sca_hash_table_unlock_index(scam->subscriptions, slot_idx); return (rc); }