Subversion Repositories HelenOS

Rev

Rev 1061 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1030 palkovsky 1
#include <ipc.h>
2
#include <stdio.h>
3
#include <unistd.h>
4
#include <stdlib.h>
5
#include <ns.h>
6
#include <errno.h>
7
 
8
static int service;
9
 
10
int main(int argc, char **argv)
11
{
12
    ipc_call_t call;
13
    ipc_callid_t callid;
14
 
15
    ipcarg_t retval, arg1, arg2;
16
 
17
    printf("Name service started.\n");
18
    while (1) {
19
        callid = ipc_wait_for_call(&call, 0);
20
        printf("Received call from: %P..%Q\n", &call.taskid,call.taskid);
21
        switch (IPC_GET_METHOD(call.data)) {
22
        case IPC_M_CONNECTTOME:
23
            printf("Somebody wants to connect with phoneid %d...accepting\n", IPC_GET_ARG3(call.data));
24
            service = IPC_GET_ARG3(call.data);
25
            retval = 0;
26
            break;
27
        case NS_PING:
28
            printf("Ping...%P %P\n", IPC_GET_ARG1(call.data),
29
                   IPC_GET_ARG2(call.data));
30
            retval = 0;
31
            arg1 = 0xdead;
32
            arg2 = 0xbeef;
33
            break;
34
        case NS_PING_SVC:
35
            printf("Pinging service %d\n", service);
36
            ipc_call_sync(service, NS_PING, 0xbeef, 0);
37
            printf("Got pong\n");
38
            break;
39
        default:
40
            printf("Unknown method: %d\n", IPC_GET_METHOD(call.data));
41
            retval = ENOENT;
42
            break;
43
        }
44
        ipc_answer(callid, retval, arg1, arg2);
45
    }
46
}