63,13 → 63,25 |
#define PCALL_TABLE_CHAINS 32 |
hash_table_t pending_calls; |
|
hash_index_t pending_call_hash(unsigned long key[]) |
static hash_index_t pending_call_hash(unsigned long key[]); |
static int pending_call_compare(unsigned long key[], hash_count_t keys, |
link_t *item); |
static void pending_call_remove_callback(link_t *item); |
|
hash_table_operations_t pending_call_ops = { |
.hash = pending_call_hash, |
.compare = pending_call_compare, |
.remove_callback = pending_call_remove_callback |
}; |
|
|
static hash_index_t pending_call_hash(unsigned long key[]) |
{ |
// printf("pending_call_hash\n"); |
return key[0] % PCALL_TABLE_CHAINS; |
} |
|
int pending_call_compare(unsigned long key[], hash_count_t keys, |
static int pending_call_compare(unsigned long key[], hash_count_t keys, |
link_t *item) |
{ |
pending_call_t *hs; |
80,16 → 92,11 |
return key[0] == hs->call_hash; |
} |
|
void pending_call_remove_callback(link_t *item) |
static void pending_call_remove_callback(link_t *item) |
{ |
// printf("pending_call_remove_callback\n"); |
} |
|
hash_table_operations_t pending_call_ops = { |
.hash = pending_call_hash, |
.compare = pending_call_compare, |
.remove_callback = pending_call_remove_callback |
}; |
|
void ipcp_connection_set(int phone, int server, proto_t *proto) |
{ |
147,6 → 154,7 |
{ |
pending_call_t *pcall; |
proto_t *proto; |
unsigned long key[1]; |
|
if (have_conn[phone]) proto = connections[phone].proto; |
else proto = NULL; |
170,7 → 178,9 |
pcall->question = *call; |
pcall->call_hash = hash; |
|
hash_table_insert(&pending_calls, &pcall->call_hash, &pcall->link); |
key[0] = hash; |
|
hash_table_insert(&pending_calls, key, &pcall->link); |
} |
|
static void parse_answer(pending_call_t *pcall, ipc_call_t *answer) |
208,6 → 218,7 |
{ |
link_t *item; |
pending_call_t *pcall; |
unsigned long key[1]; |
|
// printf("ipcp_call_in()\n"); |
/* printf("phone: %d, method: ", call->in_phone_hash); |
227,14 → 238,15 |
} |
|
hash = hash & ~IPC_CALLID_ANSWERED; |
key[0] = hash; |
|
item = hash_table_find(&pending_calls, &hash); |
item = hash_table_find(&pending_calls, key); |
if (item == NULL) return; // No matching question found |
|
pcall = hash_table_get_instance(item, pending_call_t, link); |
|
printf("response matched to question\n"); |
hash_table_remove(&pending_calls, &hash, 1); |
hash_table_remove(&pending_calls, key, 1); |
|
parse_answer(pcall, call); |
free(pcall); |