Rev 1089 | Rev 1282 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1089 | Rev 1091 | ||
---|---|---|---|
1 | #include <ipc.h> |
1 | #include <ipc.h> |
2 | #include <stdio.h> |
2 | #include <stdio.h> |
3 | #include <unistd.h> |
3 | #include <unistd.h> |
4 | #include <stdlib.h> |
4 | #include <stdlib.h> |
5 | #include <ns.h> |
5 | #include <ns.h> |
6 | #include <errno.h> |
6 | #include <errno.h> |
7 | 7 | ||
8 | static int service; |
8 | static int service; |
9 | 9 | ||
10 | int main(int argc, char **argv) |
10 | int main(int argc, char **argv) |
11 | { |
11 | { |
12 | ipc_call_t call; |
12 | ipc_call_t call; |
13 | ipc_callid_t callid; |
13 | ipc_callid_t callid; |
14 | 14 | ||
15 | ipcarg_t retval, arg1, arg2; |
15 | ipcarg_t retval, arg1, arg2; |
16 | 16 | ||
17 | printf("NS:Name service started.\n"); |
17 | printf("NS:Name service started.\n"); |
18 | while (1) { |
18 | while (1) { |
19 | call.taskid = -1; |
- | |
20 | callid = ipc_wait_for_call(&call, 0); |
19 | callid = ipc_wait_for_call(&call, 0); |
21 | printf("NS:Call task=%llX,phone=%lX..", |
20 | printf("NS:Call phone=%lX..", call.phoneid); |
22 | call.taskid,call.data.phoneid); |
- | |
23 | switch (IPC_GET_METHOD(call.data)) { |
21 | switch (IPC_GET_METHOD(call)) { |
24 | case IPC_M_PHONE_HUNGUP: |
22 | case IPC_M_PHONE_HUNGUP: |
25 | printf("Phone hung up.\n"); |
23 | printf("Phone hung up.\n"); |
26 | retval = 0; |
24 | retval = 0; |
27 | break; |
25 | break; |
28 | case IPC_M_CONNECT_TO_ME: |
26 | case IPC_M_CONNECT_TO_ME: |
29 | printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call.data)); |
27 | printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call)); |
30 | service = IPC_GET_ARG3(call.data); |
28 | service = IPC_GET_ARG3(call); |
31 | retval = 0; |
29 | retval = 0; |
32 | break; |
30 | break; |
33 | case IPC_M_CONNECT_ME_TO: |
31 | case IPC_M_CONNECT_ME_TO: |
34 | printf("Connectmeto: %zd\n", |
32 | printf("Connectme(%P)to: %zd\n", |
35 | IPC_GET_ARG1(call.data)); |
33 | IPC_GET_ARG3(call), IPC_GET_ARG1(call)); |
36 | retval = 0; |
34 | retval = 0; |
37 | break; |
35 | break; |
38 | case NS_PING: |
36 | case NS_PING: |
39 | printf("Ping...%P %P\n", IPC_GET_ARG1(call.data), |
37 | printf("Ping...%P %P\n", IPC_GET_ARG1(call), |
40 | IPC_GET_ARG2(call.data)); |
38 | IPC_GET_ARG2(call)); |
41 | retval = 0; |
39 | retval = 0; |
42 | arg1 = 0xdead; |
40 | arg1 = 0xdead; |
43 | arg2 = 0xbeef; |
41 | arg2 = 0xbeef; |
44 | break; |
42 | break; |
45 | case NS_HANGUP: |
43 | case NS_HANGUP: |
46 | printf("Closing connection.\n"); |
44 | printf("Closing connection.\n"); |
47 | retval = EHANGUP; |
45 | retval = EHANGUP; |
48 | break; |
46 | break; |
49 | case NS_PING_SVC: |
47 | case NS_PING_SVC: |
50 | printf("NS:Pinging service %d\n", service); |
48 | printf("NS:Pinging service %d\n", service); |
51 | ipc_call_sync(service, NS_PING, 0xbeef, 0); |
49 | ipc_call_sync(service, NS_PING, 0xbeef, 0); |
52 | printf("NS:Got pong\n"); |
50 | printf("NS:Got pong\n"); |
53 | break; |
51 | break; |
54 | default: |
52 | default: |
55 | printf("Unknown method: %zd\n", IPC_GET_METHOD(call.data)); |
53 | printf("Unknown method: %zd\n", IPC_GET_METHOD(call)); |
56 | retval = ENOENT; |
54 | retval = ENOENT; |
57 | break; |
55 | break; |
58 | } |
56 | } |
59 | ipc_answer(callid, retval, arg1, arg2); |
57 | ipc_answer(callid, retval, arg1, arg2); |
60 | } |
58 | } |
61 | } |
59 | } |
62 | 60 |