Subversion Repositories HelenOS

Rev

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

Rev 2927 Rev 3150
Line 48... Line 48...
48
#include <libadt/hash_table.h>
48
#include <libadt/hash_table.h>
49
#include <sysinfo.h>
49
#include <sysinfo.h>
50
#include <ddi.h>
50
#include <ddi.h>
51
#include <as.h>
51
#include <as.h>
52
 
52
 
53
#define NAME    "NS"
53
#define NAME    "ns"
54
 
54
 
55
#define NS_HASH_TABLE_CHAINS    20
55
#define NS_HASH_TABLE_CHAINS    20
56
 
56
 
57
static int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call);
57
static int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call);
58
static int connect_to_service(ipcarg_t service, ipc_call_t *call,
58
static int connect_to_service(ipcarg_t service, ipc_call_t *call,
Line 102... Line 102...
102
    ipc_answer_2(callid, EOK, (ipcarg_t) *addr, AS_AREA_READ);
102
    ipc_answer_2(callid, EOK, (ipcarg_t) *addr, AS_AREA_READ);
103
}
103
}
104
 
104
 
105
int main(int argc, char **argv)
105
int main(int argc, char **argv)
106
{
106
{
-
 
107
    printf(NAME ": HelenOS IPC Naming Service\n");
-
 
108
   
107
    ipc_call_t call;
109
    ipc_call_t call;
108
    ipc_callid_t callid;
110
    ipc_callid_t callid;
109
   
111
   
110
    ipcarg_t retval;
112
    ipcarg_t retval;
111
 
113
 
112
    if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3,
114
    if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3,
113
        &ns_hash_table_ops)) {
115
        &ns_hash_table_ops)) {
-
 
116
        printf(NAME ": No memory available\n");
114
        return ENOMEM;
117
        return ENOMEM;
115
    }
118
    }
116
       
119
   
-
 
120
    printf(NAME ": Accepting connections\n");
117
    while (1) {
121
    while (1) {
118
        callid = ipc_wait_for_call(&call);
122
        callid = ipc_wait_for_call(&call);
119
        switch (IPC_GET_METHOD(call)) {
123
        switch (IPC_GET_METHOD(call)) {
120
        case IPC_M_SHARE_IN:
124
        case IPC_M_SHARE_IN:
121
            switch (IPC_GET_ARG3(call)) {
125
            switch (IPC_GET_ARG3(call)) {
Line 154... Line 158...
154
        }
158
        }
155
        if (!(callid & IPC_CALLID_NOTIFICATION)) {
159
        if (!(callid & IPC_CALLID_NOTIFICATION)) {
156
            ipc_answer_0(callid, retval);
160
            ipc_answer_0(callid, retval);
157
        }
161
        }
158
    }
162
    }
-
 
163
   
-
 
164
    /* Not reached */
-
 
165
    return 0;
159
}
166
}
160
 
167
 
161
/** Register service.
168
/** Register service.
162
 *
169
 *
163
 * @param service Service to be registered.
170
 * @param service Service to be registered.