Subversion Repositories HelenOS

Rev

Rev 2894 | Rev 3435 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2894 Rev 2946
Line 61... Line 61...
61
int have_conn[MAX_PHONE];
61
int have_conn[MAX_PHONE];
62
 
62
 
63
#define PCALL_TABLE_CHAINS 32
63
#define PCALL_TABLE_CHAINS 32
64
hash_table_t pending_calls;
64
hash_table_t pending_calls;
65
 
65
 
-
 
66
static hash_index_t pending_call_hash(unsigned long key[]);
-
 
67
static int pending_call_compare(unsigned long key[], hash_count_t keys,
-
 
68
    link_t *item);
-
 
69
static void pending_call_remove_callback(link_t *item);
-
 
70
 
-
 
71
hash_table_operations_t pending_call_ops = {
-
 
72
    .hash = pending_call_hash,
-
 
73
    .compare = pending_call_compare,
-
 
74
    .remove_callback = pending_call_remove_callback
-
 
75
};
-
 
76
 
-
 
77
 
66
hash_index_t pending_call_hash(unsigned long key[])
78
static hash_index_t pending_call_hash(unsigned long key[])
67
{
79
{
68
//  printf("pending_call_hash\n");
80
//  printf("pending_call_hash\n");
69
    return key[0] % PCALL_TABLE_CHAINS;
81
    return key[0] % PCALL_TABLE_CHAINS;
70
}
82
}
71
 
83
 
72
int pending_call_compare(unsigned long key[], hash_count_t keys,
84
static int pending_call_compare(unsigned long key[], hash_count_t keys,
73
    link_t *item)
85
    link_t *item)
74
{
86
{
75
    pending_call_t *hs;
87
    pending_call_t *hs;
76
 
88
 
77
//  printf("pending_call_compare\n");
89
//  printf("pending_call_compare\n");
78
    hs = hash_table_get_instance(item, pending_call_t, link);
90
    hs = hash_table_get_instance(item, pending_call_t, link);
79
 
91
 
80
    return key[0] == hs->call_hash;
92
    return key[0] == hs->call_hash;
81
}
93
}
82
 
94
 
83
void pending_call_remove_callback(link_t *item)
95
static void pending_call_remove_callback(link_t *item)
84
{
96
{
85
//  printf("pending_call_remove_callback\n");
97
//  printf("pending_call_remove_callback\n");
86
}
98
}
87
 
99
 
88
hash_table_operations_t pending_call_ops = {
-
 
89
    .hash = pending_call_hash,
-
 
90
    .compare = pending_call_compare,
-
 
91
    .remove_callback = pending_call_remove_callback
-
 
92
};
-
 
93
 
100
 
94
void ipcp_connection_set(int phone, int server, proto_t *proto)
101
void ipcp_connection_set(int phone, int server, proto_t *proto)
95
{
102
{
96
    if (phone <0 || phone >= MAX_PHONE) return;
103
    if (phone <0 || phone >= MAX_PHONE) return;
97
    connections[phone].server = server;
104
    connections[phone].server = server;
Line 145... Line 152...
145
 
152
 
146
void ipcp_call_out(int phone, ipc_call_t *call, ipc_callid_t hash)
153
void ipcp_call_out(int phone, ipc_call_t *call, ipc_callid_t hash)
147
{
154
{
148
    pending_call_t *pcall;
155
    pending_call_t *pcall;
149
    proto_t *proto;
156
    proto_t *proto;
-
 
157
    unsigned long key[1];
150
 
158
 
151
    if (have_conn[phone]) proto = connections[phone].proto;
159
    if (have_conn[phone]) proto = connections[phone].proto;
152
    else proto = NULL;
160
    else proto = NULL;
153
 
161
 
154
//  printf("ipcp_call_out()\n");
162
//  printf("ipcp_call_out()\n");
Line 168... Line 176...
168
    pcall = malloc(sizeof(pending_call_t));
176
    pcall = malloc(sizeof(pending_call_t));
169
    pcall->phone_hash = phone;
177
    pcall->phone_hash = phone;
170
    pcall->question = *call;
178
    pcall->question = *call;
171
    pcall->call_hash = hash;
179
    pcall->call_hash = hash;
172
 
180
 
-
 
181
    key[0] = hash;
-
 
182
 
173
    hash_table_insert(&pending_calls, &pcall->call_hash, &pcall->link);
183
    hash_table_insert(&pending_calls, key, &pcall->link);
174
}
184
}
175
 
185
 
176
static void parse_answer(pending_call_t *pcall, ipc_call_t *answer)
186
static void parse_answer(pending_call_t *pcall, ipc_call_t *answer)
177
{
187
{
178
    int phone;
188
    int phone;
Line 206... Line 216...
206
 
216
 
207
void ipcp_call_in(ipc_call_t *call, ipc_callid_t hash)
217
void ipcp_call_in(ipc_call_t *call, ipc_callid_t hash)
208
{
218
{
209
    link_t *item;
219
    link_t *item;
210
    pending_call_t *pcall;
220
    pending_call_t *pcall;
-
 
221
    unsigned long key[1];
211
 
222
 
212
//  printf("ipcp_call_in()\n");
223
//  printf("ipcp_call_in()\n");
213
/*  printf("phone: %d, method: ", call->in_phone_hash);
224
/*  printf("phone: %d, method: ", call->in_phone_hash);
214
    ipc_m_print(IPC_GET_METHOD(*call));
225
    ipc_m_print(IPC_GET_METHOD(*call));
215
    printf(" args: (%u, %u, %u, %u, %u)\n",
226
    printf(" args: (%u, %u, %u, %u, %u)\n",
Line 225... Line 236...
225
        printf("Not a response (hash %d)\n", hash);
236
        printf("Not a response (hash %d)\n", hash);
226
        return;
237
        return;
227
    }
238
    }
228
 
239
 
229
    hash = hash & ~IPC_CALLID_ANSWERED;
240
    hash = hash & ~IPC_CALLID_ANSWERED;
-
 
241
    key[0] = hash;
230
 
242
 
231
    item = hash_table_find(&pending_calls, &hash);
243
    item = hash_table_find(&pending_calls, key);
232
    if (item == NULL) return; // No matching question found
244
    if (item == NULL) return; // No matching question found
233
   
245
   
234
    pcall = hash_table_get_instance(item, pending_call_t, link);
246
    pcall = hash_table_get_instance(item, pending_call_t, link);
235
 
247
 
236
    printf("response matched to question\n");
248
    printf("response matched to question\n");
237
    hash_table_remove(&pending_calls, &hash, 1);
249
    hash_table_remove(&pending_calls, key, 1);
238
 
250
 
239
    parse_answer(pcall, call);
251
    parse_answer(pcall, call);
240
    free(pcall);
252
    free(pcall);
241
}
253
}
242
 
254