11,6 → 11,8 |
#include "ipc_desc.h" |
#include "ipcp.h" |
|
#define IPCP_CALLID_SYNC 0 |
|
typedef struct { |
int phone_hash; |
ipc_call_t question; |
34,15 → 36,16 |
|
hash_index_t pending_call_hash(unsigned long key[]) |
{ |
printf("pending_call_hash\n"); |
// printf("pending_call_hash\n"); |
return key[0] % PCALL_TABLE_CHAINS; |
} |
|
int pending_call_compare(unsigned long key[], hash_count_t keys, link_t *item) |
int pending_call_compare(unsigned long key[], hash_count_t keys, |
link_t *item) |
{ |
pending_call_t *hs; |
|
printf("pending_call_remove_compare\n"); |
// printf("pending_call_compare\n"); |
hs = hash_table_get_instance(item, pending_call_t, link); |
|
return key[0] == hs->call_hash; |
50,7 → 53,7 |
|
void pending_call_remove_callback(link_t *item) |
{ |
printf("pending_call_remove_callback\n"); |
// printf("pending_call_remove_callback\n"); |
} |
|
hash_table_operations_t pending_call_ops = { |
105,9 → 108,14 |
void ipcp_call_out(int phone, ipc_call_t *call, ipc_callid_t hash) |
{ |
pending_call_t *pcall; |
char *proto_name; |
|
if (have_conn[phone]) proto_name = connections[phone].proto->name; |
else proto_name = "n/a"; |
|
// printf("ipcp_call_out()\n"); |
printf("call id: 0x%x, phone: %d, method: ", hash, phone); |
printf("call id: 0x%x, phone: %d, proto: %s, method: ", hash, phone, |
proto_name); |
ipc_m_print(IPC_GET_METHOD(*call)); |
printf(" args: (%u, %u, %u, %u, %u)\n", |
IPC_GET_ARG1(*call), |
127,6 → 135,32 |
hash_table_insert(&pending_calls, &pcall->call_hash, &pcall->link); |
} |
|
static void parse_answer(pending_call_t *pcall, ipc_call_t *answer) |
{ |
int phone; |
ipcarg_t method; |
int retval; |
static proto_t proto = { .name = "unknown" }; |
int cphone; |
|
// printf("parse_answer\n"); |
|
phone = pcall->phone_hash; |
method = IPC_GET_METHOD(pcall->question); |
retval = IPC_GET_RETVAL(*answer); |
printf("phone=%d, method=%d, retval=%d\n", |
phone, method, retval); |
|
if (phone == 0 && method == IPC_M_CONNECT_ME_TO && retval == 0) { |
/* Connected to a service (through NS) */ |
cphone = IPC_GET_ARG5(*answer); |
printf("registering connection (phone %d)\n", cphone); |
connection_set(cphone, 0, &proto); |
} else { |
printf("unrecognized connection\n"); |
} |
} |
|
void ipcp_call_in(ipc_call_t *call, ipc_callid_t hash) |
{ |
link_t *item; |
143,9 → 177,9 |
IPC_GET_ARG5(*call) |
);*/ |
|
if ((hash & IPC_CALLID_ANSWERED) == 0) { |
if ((hash & IPC_CALLID_ANSWERED) == 0 && hash != IPCP_CALLID_SYNC) { |
/* Not a response */ |
printf("Not a response\n"); |
printf("Not a response (hash %d)\n", hash); |
return; |
} |
|
158,17 → 192,21 |
|
printf("response matched to question\n"); |
hash_table_remove(&pending_calls, &hash, 1); |
|
parse_answer(pcall, call); |
free(pcall); |
} |
|
void ipcp_call_sync(int phone, ipc_call_t *call, ipc_call_t *answer) |
{ |
ipcp_call_out(phone, call, 0); |
ipcp_call_in(answer, 0); |
ipcp_call_out(phone, call, IPCP_CALLID_SYNC); |
ipcp_call_in(answer, IPCP_CALLID_SYNC); |
} |
|
void ipcp_hangup(int phone, int rc) |
{ |
printf("hangup phone %d -> %d\n", phone, rc); |
connection_clear(phone); |
} |
|
/** @} |