Subversion Repositories HelenOS-historic

Rev

Rev 1091 | Rev 1282 | Go to most recent revision | Details | Compare with Previous | 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
 
1089 palkovsky 17
    printf("NS:Name service started.\n");
1259 palkovsky 18
//  ipc_register_irq(1);
1030 palkovsky 19
    while (1) {
20
        callid = ipc_wait_for_call(&call, 0);
1091 palkovsky 21
        printf("NS:Call phone=%lX..", call.phoneid);
22
        switch (IPC_GET_METHOD(call)) {
1259 palkovsky 23
        case IPC_M_INTERRUPT:
24
            printf("GOT INTERRUPT\n");
25
            break;
1089 palkovsky 26
        case IPC_M_PHONE_HUNGUP:
27
            printf("Phone hung up.\n");
28
            retval = 0;
29
            break;
30
        case IPC_M_CONNECT_TO_ME:
1091 palkovsky 31
            printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call));
32
            service = IPC_GET_ARG3(call);
1030 palkovsky 33
            retval = 0;
34
            break;
1089 palkovsky 35
        case IPC_M_CONNECT_ME_TO:
1091 palkovsky 36
            printf("Connectme(%P)to: %zd\n",
37
                   IPC_GET_ARG3(call), IPC_GET_ARG1(call));
1061 palkovsky 38
            retval = 0;
39
            break;
1030 palkovsky 40
        case NS_PING:
1091 palkovsky 41
            printf("Ping...%P %P\n", IPC_GET_ARG1(call),
42
                   IPC_GET_ARG2(call));
1030 palkovsky 43
            retval = 0;
44
            arg1 = 0xdead;
45
            arg2 = 0xbeef;
46
            break;
1089 palkovsky 47
        case NS_HANGUP:
48
            printf("Closing connection.\n");
49
            retval = EHANGUP;
50
            break;
1030 palkovsky 51
        case NS_PING_SVC:
1089 palkovsky 52
            printf("NS:Pinging service %d\n", service);
1030 palkovsky 53
            ipc_call_sync(service, NS_PING, 0xbeef, 0);
1089 palkovsky 54
            printf("NS:Got pong\n");
1030 palkovsky 55
            break;
56
        default:
1091 palkovsky 57
            printf("Unknown method: %zd\n", IPC_GET_METHOD(call));
1030 palkovsky 58
            retval = ENOENT;
59
            break;
60
        }
1259 palkovsky 61
        if (! (callid & IPC_CALLID_NOTIFICATION))
62
            ipc_answer(callid, retval, arg1, arg2);
1030 palkovsky 63
    }
64
}