Rev 3444 | Rev 3454 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3444 | Rev 3452 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | #define IPCP_CALLID_SYNC 0 |
44 | #define IPCP_CALLID_SYNC 0 |
45 | 45 | ||
46 | typedef struct { |
46 | typedef struct { |
47 | int phone_hash; |
47 | int phone_hash; |
48 | ipc_call_t question; |
48 | ipc_call_t question; |
- | 49 | oper_t *oper; |
|
49 | 50 | ||
50 | int call_hash; |
51 | int call_hash; |
51 | 52 | ||
52 | link_t link; |
53 | link_t link; |
53 | } pending_call_t; |
54 | } pending_call_t; |
Line 143... | Line 144... | ||
143 | void ipcp_init(void) |
144 | void ipcp_init(void) |
144 | { |
145 | { |
145 | ipc_m_desc_t *desc; |
146 | ipc_m_desc_t *desc; |
146 | oper_t *oper; |
147 | oper_t *oper; |
147 | 148 | ||
- | 149 | val_type_t arg_def[OPER_MAX_ARGS] = { |
|
- | 150 | V_INTEGER, |
|
- | 151 | V_INTEGER, |
|
- | 152 | V_INTEGER, |
|
- | 153 | V_INTEGER, |
|
- | 154 | V_INTEGER |
|
- | 155 | }; |
|
- | 156 | ||
148 | /* |
157 | /* |
149 | * Create a pseudo-protocol 'unknown' that has no known methods. |
158 | * Create a pseudo-protocol 'unknown' that has no known methods. |
150 | */ |
159 | */ |
151 | proto_unknown = proto_new("unknown"); |
160 | proto_unknown = proto_new("unknown"); |
152 | 161 | ||
Line 156... | Line 165... | ||
156 | */ |
165 | */ |
157 | proto_system = proto_new("system"); |
166 | proto_system = proto_new("system"); |
158 | 167 | ||
159 | desc = ipc_methods; |
168 | desc = ipc_methods; |
160 | while (desc->number != 0) { |
169 | while (desc->number != 0) { |
161 | oper = oper_new(desc->name); |
170 | oper = oper_new(desc->name, OPER_MAX_ARGS, arg_def, V_INTEGER, |
- | 171 | OPER_MAX_ARGS, arg_def); |
|
162 | proto_add_oper(proto_system, desc->number, oper); |
172 | proto_add_oper(proto_system, desc->number, oper); |
163 | 173 | ||
164 | ++desc; |
174 | ++desc; |
165 | } |
175 | } |
166 | 176 | ||
Line 177... | Line 187... | ||
177 | { |
187 | { |
178 | pending_call_t *pcall; |
188 | pending_call_t *pcall; |
179 | proto_t *proto; |
189 | proto_t *proto; |
180 | unsigned long key[1]; |
190 | unsigned long key[1]; |
181 | oper_t *oper; |
191 | oper_t *oper; |
- | 192 | ipcarg_t *args; |
|
- | 193 | int i; |
|
182 | 194 | ||
183 | if (have_conn[phone]) proto = connections[phone].proto; |
195 | if (have_conn[phone]) proto = connections[phone].proto; |
184 | else proto = NULL; |
196 | else proto = NULL; |
185 | 197 | ||
- | 198 | args = call->args; |
|
- | 199 | ||
186 | if ((display_mask & DM_IPC) != 0) { |
200 | if ((display_mask & DM_IPC) != 0) { |
187 | printf("Call ID: 0x%x, phone: %d, proto: %s, method: ", hash, |
201 | printf("Call ID: 0x%x, phone: %d, proto: %s, method: ", hash, |
188 | phone, (proto ? proto->name : "n/a")); |
202 | phone, (proto ? proto->name : "n/a")); |
189 | ipc_m_print(proto, IPC_GET_METHOD(*call)); |
203 | ipc_m_print(proto, IPC_GET_METHOD(*call)); |
190 | printf(" args: (%u, %u, %u, %u, %u)\n", |
204 | printf(" args: (%u, %u, %u, %u, %u)\n", args[1], args[2], |
191 | IPC_GET_ARG1(*call), |
- | |
192 | IPC_GET_ARG2(*call), |
- | |
193 | IPC_GET_ARG3(*call), |
- | |
194 | IPC_GET_ARG4(*call), |
205 | args[3], args[4], args[5]); |
195 | IPC_GET_ARG5(*call) |
- | |
196 | ); |
- | |
197 | } |
206 | } |
198 | 207 | ||
199 | 208 | ||
200 | if ((display_mask & DM_USER) != 0) { |
209 | if ((display_mask & DM_USER) != 0) { |
201 | 210 | ||
Line 208... | Line 217... | ||
208 | if (oper != NULL) { |
217 | if (oper != NULL) { |
209 | 218 | ||
210 | printf("%s(%d).%s", (proto ? proto->name : "n/a"), |
219 | printf("%s(%d).%s", (proto ? proto->name : "n/a"), |
211 | phone, (oper ? oper->name : "unknown")); |
220 | phone, (oper ? oper->name : "unknown")); |
212 | 221 | ||
- | 222 | putchar('('); |
|
213 | printf("(%u, %u, %u, %u, %u)\n", |
223 | for (i = 1; i <= oper->argc; ++i) { |
214 | IPC_GET_ARG1(*call), |
224 | if (i > 1) printf(", "); |
- | 225 | val_print(args[i], oper->arg_type[i - 1]); |
|
- | 226 | } |
|
215 | IPC_GET_ARG2(*call), |
227 | putchar(')'); |
- | 228 | ||
- | 229 | if (oper->rv_type == V_VOID && oper->respc == 0) { |
|
- | 230 | /* |
|
- | 231 | * No response data (typically the task will |
|
216 | IPC_GET_ARG3(*call), |
232 | * not be interested in the response). |
217 | IPC_GET_ARG4(*call), |
233 | * We will not display response. |
- | 234 | */ |
|
218 | IPC_GET_ARG5(*call) |
235 | putchar('.'); |
219 | ); |
236 | } |
- | 237 | ||
- | 238 | putchar('\n'); |
|
220 | } |
239 | } |
- | 240 | } else { |
|
- | 241 | oper = NULL; |
|
221 | } |
242 | } |
222 | 243 | ||
223 | /* Store call in hash table for response matching */ |
244 | /* Store call in hash table for response matching */ |
224 | 245 | ||
225 | pcall = malloc(sizeof(pending_call_t)); |
246 | pcall = malloc(sizeof(pending_call_t)); |
226 | pcall->phone_hash = phone; |
247 | pcall->phone_hash = phone; |
227 | pcall->question = *call; |
248 | pcall->question = *call; |
228 | pcall->call_hash = hash; |
249 | pcall->call_hash = hash; |
- | 250 | pcall->oper = oper; |
|
229 | 251 | ||
230 | key[0] = hash; |
252 | key[0] = hash; |
231 | 253 | ||
232 | hash_table_insert(&pending_calls, key, &pcall->link); |
254 | hash_table_insert(&pending_calls, key, &pcall->link); |
233 | } |
255 | } |
Line 240... | Line 262... | ||
240 | ipcarg_t service; |
262 | ipcarg_t service; |
241 | int retval; |
263 | int retval; |
242 | proto_t *proto; |
264 | proto_t *proto; |
243 | int cphone; |
265 | int cphone; |
244 | 266 | ||
- | 267 | ipcarg_t *resp; |
|
- | 268 | oper_t *oper; |
|
- | 269 | int i; |
|
- | 270 | ||
245 | // printf("parse_answer\n"); |
271 | // printf("parse_answer\n"); |
246 | 272 | ||
247 | phone = pcall->phone_hash; |
273 | phone = pcall->phone_hash; |
248 | method = IPC_GET_METHOD(pcall->question); |
274 | method = IPC_GET_METHOD(pcall->question); |
249 | retval = IPC_GET_RETVAL(*answer); |
275 | retval = IPC_GET_RETVAL(*answer); |
250 | 276 | ||
- | 277 | resp = answer->args; |
|
- | 278 | ||
251 | if ((display_mask & DM_IPC) != 0) { |
279 | if ((display_mask & DM_IPC) != 0) { |
252 | printf("Response to 0x%x: retval=%d, args = (%u, %u, %u, %u, %u)\n", |
280 | printf("Response to 0x%x: retval=%d, args = (%u, %u, %u, %u, %u)\n", |
253 | hash, retval, IPC_GET_ARG1(*answer), |
281 | hash, retval, IPC_GET_ARG1(*answer), |
254 | IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), |
282 | IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), |
255 | IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer)); |
283 | IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer)); |
256 | } |
284 | } |
257 | 285 | ||
258 | if ((display_mask & DM_USER) != 0) { |
286 | if ((display_mask & DM_USER) != 0) { |
- | 287 | oper = pcall->oper; |
|
- | 288 | ||
- | 289 | if (oper->rv_type != V_VOID || oper->respc > 0) { |
|
259 | printf("-> %d\n", retval); |
290 | printf("->"); |
- | 291 | ||
- | 292 | if (oper->rv_type != V_VOID) { |
|
- | 293 | putchar(' '); |
|
- | 294 | val_print(retval, oper->rv_type); |
|
- | 295 | } |
|
- | 296 | ||
- | 297 | if (oper->respc > 0) { |
|
- | 298 | putchar(' '); |
|
- | 299 | putchar('('); |
|
- | 300 | for (i = 1; i <= oper->respc; ++i) { |
|
- | 301 | if (i > 1) printf(", "); |
|
- | 302 | val_print(resp[i], oper->resp_type[i - 1]); |
|
- | 303 | } |
|
- | 304 | putchar(')'); |
|
- | 305 | } |
|
- | 306 | ||
- | 307 | putchar('\n'); |
|
- | 308 | } |
|
260 | } |
309 | } |
261 | 310 | ||
262 | if (phone == 0 && method == IPC_M_CONNECT_ME_TO && retval == 0) { |
311 | if (phone == 0 && method == IPC_M_CONNECT_ME_TO && retval == 0) { |
263 | /* Connected to a service (through NS) */ |
312 | /* Connected to a service (through NS) */ |
264 | service = IPC_GET_ARG1(pcall->question); |
313 | service = IPC_GET_ARG1(pcall->question); |