Annotation of libaitrpc/src/srv.c, revision 1.1.1.1.2.1
1.1 misho 1: /*************************************************************************
2: * (C) 2010 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
3: * by Michael Pounov <misho@openbsd-bg.org>
4: *
5: * $Author: misho $
1.1.1.1.2.1! misho 6: * $Id: srv.c,v 1.1.1.1 2010/06/18 01:48:06 misho Exp $
1.1 misho 7: *
8: *************************************************************************/
9: #include "global.h"
10:
11:
12: static void *
13: rpc_srv_dispatchCall(void *arg)
14: {
15: rpc_cli_t *c = arg;
16: rpc_srv_t *s;
17: rpc_val_t *vals, *v = NULL;
18: rpc_func_t *f;
19: struct tagRPCCall *rpc;
20: struct tagRPCRet rrpc;
21: fd_set fds;
22: u_char buf[BUFSIZ], *data;
23: int ret, argc, Limit = 0;
24: register int i;
25:
26: if (!arg) {
27: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t procced RPC client ...\n");
28: return NULL;
29: } else
30: s = c->cli_parent;
31:
32: do {
33: FD_ZERO(&fds);
34: FD_SET(c->cli_sock, &fds);
35: ret = select(c->cli_sock + 1, &fds, NULL, NULL, NULL);
36: if (ret == -1) {
37: ret = -2;
38: }
39: memset(&rrpc, 0, sizeof rrpc);
40: memset(buf, 0, BUFSIZ);
41: if ((ret = recv(c->cli_sock, buf, BUFSIZ, 0)) == -1) {
42: LOGERR;
43: ret = -3;
44: break;
45: }
46: if (!ret) { // receive EOF
47: ret = 0;
48: break;
49: }
50: if (ret < sizeof(struct tagRPCCall)) {
51: rpc_SetErr(EMSGSIZE, "Error:: too short RPC packet ...\n");
52: ret = -4;
53: break;
54: } else
55: rpc = (struct tagRPCCall*) buf;
56: // check RPC packet session info
57: if (memcmp(&rpc->call_session, &s->srv_session, sizeof rpc->call_session)) {
58: rpc_SetErr(EINVAL, "Error:: get invalid RPC session ...\n");
59: ret = -5;
60: break;
61: }
62: // RPC is OK! Go decapsulate variables ...
63: if (rpc->call_argc) {
64: v = (rpc_val_t*) (buf + sizeof(struct tagRPCCall));
65: // RPC received variables types OK!
66: data = (u_char*) v + rpc->call_argc * sizeof(rpc_val_t);
67: for (i = 0; i < rpc->call_argc; i++) {
68: switch (v[i].val_type) {
69: case buffer:
70: v[i].val.buffer = data;
71: data += v[i].val_len;
72: break;
73: case string:
74: v[i].val.string = (int8_t*) data;
75: data += v[i].val_len + 1;
76: break;
77: case array:
78: v[i].val.array = (int8_t**) data;
79: data += v[i].val_len;
80: break;
81: default:
82: break;
83: }
84: }
85: }
86:
87: argc = 0;
88: vals = NULL;
89: if (!(f = rpc_srv_getCall(s, rpc->call_tag, rpc->call_hash))) {
90: rpc_SetErr(EINVAL, "Error:: call not found into RPC server ...\n");
91: ret = -6;
92: } else
93: if ((ret = rpc_srv_execCall(s, f, rpc, v)) == -1)
94: ret = -6;
95: else
96: argc = rpc_srv_getValsCall(f, &vals);
97:
98: memcpy(&rrpc.ret_session, &rpc->call_session, sizeof rrpc.ret_session);
99: rrpc.ret_tag = rpc->call_tag;
100: rrpc.ret_hash = rpc->call_hash;
101: rrpc.ret_errno = rpc_Errno;
102: rrpc.ret_retcode = ret;
103: rrpc.ret_argc = argc;
104:
105: memset(buf, 0, BUFSIZ);
106: memcpy(buf, &rrpc, (Limit = sizeof rrpc));
107: if (argc && vals) {
108: v = (rpc_val_t*) (buf + sizeof rrpc);
109: memcpy(v, vals, argc * sizeof(rpc_val_t));
110: Limit += argc * sizeof(rpc_val_t);
111: data = (u_char*) v + argc * sizeof(rpc_val_t);
112: for (ret = i = 0; i < argc; i++) {
113: switch (vals[i].val_type) {
114: case buffer:
115: if (ret || Limit + vals[i].val_len > BUFSIZ) {
116: rpc_SetErr(EMSGSIZE, "Error:: in prepare RPC packet (-7) ...\n");
117: rrpc.ret_retcode = ret = -7;
118: rrpc.ret_argc = 0;
119: break;
120: }
121:
122: memcpy(data, vals[i].val.buffer, vals[i].val_len);
123: data += vals[i].val_len;
124: Limit += vals[i].val_len;
125: break;
126: case string:
127: if (ret || Limit + vals[i].val_len + 1 > BUFSIZ) {
128: rpc_SetErr(EMSGSIZE, "Error:: in prepare RPC packet (-7) ...\n");
129: rrpc.ret_retcode = ret = -7;
130: rrpc.ret_argc = 0;
131: break;
132: }
133:
134: memcpy(data, vals[i].val.string, vals[i].val_len + 1);
135: data += vals[i].val_len + 1;
136: Limit += vals[i].val_len + 1;
137: break;
138: case array:
139: if (ret || Limit + vals[i].val_len > BUFSIZ) {
140: rpc_SetErr(EMSGSIZE, "Error:: in prepare RPC packet (-7) ...\n");
141: rrpc.ret_retcode = ret = -7;
142: rrpc.ret_argc = 0;
143: break;
144: }
145:
146: memcpy(data, vals[i].val.array, vals[i].val_len);
147: data += vals[i].val_len;
148: Limit += vals[i].val_len;
149: break;
150: default:
151: break;
152: }
153:
154: RPC_FREE_VAL(&vals[i]);
155: }
156: }
157:
158: if ((ret = send(c->cli_sock, buf, Limit, 0)) == -1) {
159: LOGERR;
160: ret = -8;
161: break;
162: }
163: if (ret != Limit) {
164: rpc_SetErr(EBADMSG, "Error:: in send RPC request, should be send %d bytes, "
165: "really is %d\n", Limit, ret);
166: ret = -9;
167: break;
168: }
169: } while (ret > -1);
170:
171: shutdown(c->cli_sock, SHUT_RDWR);
172: close(c->cli_sock);
173: memset(c, 0, sizeof(rpc_cli_t));
174: return (void*) ret;
175: }
176:
177: // -------------------------------------------------
178:
179: /*
180: * rpc_srv_initServer() Init & create RPC Server
181: * @regProgID = ProgramID for authentication & recognition
182: * @regProcID = ProcessID for authentication & recognition
183: * @concurentClients = Concurent clients at same time to this server
184: * @family = Family socket type, AF_INET or AF_INET6
185: * @csHost = Host name or IP address for bind server, if NULL any address
186: * @Port = Port for bind server, if Port == 0 default port is selected
187: * return: NULL == error or !=NULL bind and created RPC server instance
188: */
189: rpc_srv_t *
190: rpc_srv_initServer(u_int regProgID, u_int regProcID, int concurentClients,
191: u_short family, const char *csHost, u_short Port)
192: {
193: rpc_srv_t *srv = NULL;
194: int n = 1;
195: struct hostent *host = NULL;
196: struct sockaddr_in sin;
197: struct sockaddr_in6 sin6;
198:
199: if (!concurentClients || !regProgID || (family != AF_INET && family != AF_INET6)) {
200: rpc_SetErr(EINVAL, "Error:: Invalid parameters can`t init RPC server ...\n");
201: return NULL;
202: }
203: if (!Port)
204: Port = RPC_DEFPORT;
205: if (csHost) {
206: host = gethostbyname2(csHost, family);
207: if (!host) {
208: rpc_SetErr(h_errno, "Error:: %s\n", hstrerror(h_errno));
209: return NULL;
210: }
211: }
212: switch (family) {
213: case AF_INET:
214: memset(&sin, 0, sizeof sin);
215: sin.sin_len = sizeof sin;
216: sin.sin_family = family;
217: sin.sin_port = htons(Port);
218: if (csHost)
219: memcpy(&sin.sin_addr, host->h_addr, host->h_length);
220: break;
221: case AF_INET6:
222: memset(&sin6, 0, sizeof sin6);
223: sin6.sin6_len = sizeof sin6;
224: sin6.sin6_family = family;
225: sin6.sin6_port = htons(Port);
226: if (csHost)
227: memcpy(&sin6.sin6_addr, host->h_addr, host->h_length);
228: break;
229: default:
230: rpc_SetErr(EINVAL, "Error:: Invalid parameters can`t start RPC server ...\n");
231: return NULL;
232: }
233:
234: srv = malloc(sizeof(rpc_srv_t));
235: if (!srv) {
236: LOGERR;
237: return NULL;
238: } else
239: memset(srv, 0, sizeof(rpc_srv_t));
240:
241: srv->srv_numcli = concurentClients;
242: srv->srv_session.sess_version = RPC_VERSION;
243: srv->srv_session.sess_program = regProgID;
244: srv->srv_session.sess_process = regProcID;
245:
246: srv->srv_server.cli_parent = srv;
247: if (family == AF_INET)
248: memcpy(&srv->srv_server.cli_sa, &sin, sizeof srv->srv_server.cli_sa);
249: else
250: memcpy(&srv->srv_server.cli_sa, &sin6, sizeof srv->srv_server.cli_sa);
251: srv->srv_server.cli_sock = socket(family, SOCK_STREAM, 0);
252: if (srv->srv_server.cli_sock == -1) {
253: LOGERR;
254: free(srv);
255: return NULL;
256: }
257: if (setsockopt(srv->srv_server.cli_sock, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n) == -1) {
258: LOGERR;
259: close(srv->srv_server.cli_sock);
260: free(srv);
261: return NULL;
262: }
263: if (bind(srv->srv_server.cli_sock, &srv->srv_server.cli_sa, sizeof srv->srv_server.cli_sa) == -1) {
264: LOGERR;
265: close(srv->srv_server.cli_sock);
266: free(srv);
267: return NULL;
268: }
269:
270: srv->srv_clients = calloc(srv->srv_numcli, sizeof(rpc_cli_t));
271: if (!srv->srv_clients) {
272: LOGERR;
273: close(srv->srv_server.cli_sock);
274: free(srv);
275: return NULL;
276: } else
277: memset(srv->srv_clients, 0, srv->srv_numcli * sizeof(rpc_cli_t));
278:
1.1.1.1.2.1! misho 279: rpc_srv_registerCall(srv, NULL, CALL_SRVSHUTDOWN, 0);
1.1 misho 280: rpc_srv_registerCall(srv, NULL, CALL_SRVCLIENTS, 0);
281: rpc_srv_registerCall(srv, NULL, CALL_SRVCALLS, 0);
282: rpc_srv_registerCall(srv, NULL, CALL_SRVSESSIONS, 0);
1.1.1.1.2.1! misho 283:
! 284: pthread_mutex_init(&rpc_mtx, NULL);
1.1 misho 285: return srv;
286: }
287:
288: /*
289: * rpc_srv_endServer() Destroy RPC server, close all opened sockets and free resources
290: * @srv = RPC Server instance
291: * return: none
292: */
293: void
294: rpc_srv_endServer(rpc_srv_t * __restrict srv)
295: {
296: rpc_cli_t *c;
297: register int i;
298: rpc_func_t *f;
299:
300: if (!srv) {
301: rpc_SetErr(EINVAL, "Error:: Can`t destroy server because parameter is null!\n");
302: return;
303: }
304:
1.1.1.1.2.1! misho 305: pthread_mutex_destroy(&rpc_mtx);
! 306:
1.1 misho 307: while ((f = srv->srv_funcs)) {
308: srv->srv_funcs = f->func_next;
309: free(f);
310: }
311:
312: for (i = 0, c = srv->srv_clients; i < srv->srv_numcli && c; i++, c++)
313: if (c->cli_sa.sa_family)
314: shutdown(c->cli_sock, SHUT_RDWR);
315: close(srv->srv_server.cli_sock);
316:
317: if (srv->srv_clients) {
318: free(srv->srv_clients);
319: srv->srv_numcli = 0;
320: }
321:
322: free(srv);
323: srv = NULL;
324: }
325:
326: /*
327: * rpc_srv_execServer() Execute Main server loop and wait for clients requests
328: * @srv = RPC Server instance
329: * return: -1 error or 0 ok, infinite loop ...
330: */
331: int
332: rpc_srv_execServer(rpc_srv_t * __restrict srv)
333: {
334: socklen_t salen = sizeof(struct sockaddr);
335: register int i;
336: rpc_cli_t *c;
337:
338: if (!srv) {
339: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t start RPC server ...\n");
340: return -1;
341: }
342:
343: if (listen(srv->srv_server.cli_sock, SOMAXCONN) == -1) {
344: LOGERR;
345: return -1;
346: }
347:
1.1.1.1.2.1! misho 348: while (!rpc_Kill) {
1.1 misho 349: for (c = srv->srv_clients, i = 0; i < srv->srv_numcli && c; i++, c++)
350: if (!c->cli_sa.sa_family)
351: break;
352: if (c && c->cli_sa.sa_family && c->cli_parent) {
353: usleep(1000000);
354: continue;
355: }
356: c->cli_sock = accept(srv->srv_server.cli_sock, &c->cli_sa, &salen);
357: if (c->cli_sock == -1) {
358: printf("%s(%d): #%d - %s\n", __func__, __LINE__, errno, strerror(errno));
359: LOGERR;
360: continue;
361: } else
362: c->cli_parent = srv;
363:
364: if (pthread_create(&c->cli_tid, NULL, rpc_srv_dispatchCall, c)) {
365: LOGERR;
366: continue;
367: }
368: }
369:
370: /* not reached !!! */
371: return 0;
372: }
373:
374: // ---------------------------------------------------------
375:
376: /*
377: * rpc_srv_freeValsCall() Free return variables for RPC call
378: * @call = RPC function call
379: * return: none
380: */
381: inline void
382: rpc_srv_freeValsCall(rpc_func_t * __restrict call)
383: {
384: rpc_srv_declValsCall(call, 0);
385: }
386:
387: /*
388: * rpc_srv_declValsCall() Declare return variables for RPC call
389: * @call = RPC function call
390: * @return_vals = Number of return variables
391: * return: -1 error, !=-1 ok
392: */
393: inline int
394: rpc_srv_declValsCall(rpc_func_t * __restrict call, int return_vals)
395: {
396: void *ptr;
397:
398: if (!call || return_vals < 0) {
399: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t declare return variables for RPC call...\n");
400: return -1;
401: } else
402: call->func_args = return_vals;
403:
404: if (!return_vals) {
405: if (call->func_vals) {
406: free(call->func_vals);
407: call->func_vals = NULL;
408: }
409: } else {
410: ptr = realloc(call->func_vals, return_vals * sizeof(rpc_val_t));
411: if (!ptr) {
412: LOGERR;
413: return -1;
414: } else
415: call->func_vals = ptr;
416: }
417:
418: return call->func_args;
419: }
420:
421: /*
422: * rpc_srv_delValsCall() Clean values from return variables of RPC call
423: * @call = RPC function call
424: * return: -1 error, !=-1 Returned number of cleaned RPC variables
425: */
426: inline int
427: rpc_srv_delValsCall(rpc_func_t * __restrict call)
428: {
429: if (!call) {
430: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t delete return variables ...\n");
431: return -1;
432: }
433:
434: memset(call->func_vals, 0, call->func_args * sizeof(rpc_val_t));
435: return call->func_args;
436: }
437:
438: /*
439: * rpc_srv_copyValsCall() Copy return variables for RPC call to new variable
440: * @call = RPC function call
441: * @newvals = New allocated variables array, must be free after use
442: * return: -1 error, !=-1 Returned number of copied RPC variables
443: */
444: inline int
445: rpc_srv_copyValsCall(rpc_func_t * __restrict call, rpc_val_t ** __restrict newvals)
446: {
447: if (!call || !newvals) {
448: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t copy return variables to new array\n");
449: return -1;
450: }
451:
452: *newvals = calloc(call->func_args, sizeof(rpc_val_t));
453: if (!*newvals) {
454: LOGERR;
455: return -1;
456: } else
457: memcpy(*newvals, call->func_vals, call->func_args * sizeof(rpc_val_t));
458:
459: return call->func_args;
460: }
461:
462: /*
463: * rpc_srv_getValsCall() Get return variables for RPC call
464: * @call = RPC function call
465: * @vals = Returned variables, may be NULL
466: * return: -1 error, !=-1 Number of returned variables
467: */
468: inline int
469: rpc_srv_getValsCall(rpc_func_t * __restrict call, rpc_val_t ** __restrict vals)
470: {
471: if (!call) {
472: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t get return variables ...\n");
473: return -1;
474: }
475:
476: if (vals)
477: *vals = call->func_vals;
478: return call->func_args;
479: }
480:
481: // ---------------------------------------------------------
482:
483: /*
484: * rpc_srv_registerCall() Register call to RPC server
485: * @srv = RPC Server instance
486: * @csModule = Module name, if NULL self binary
487: * @csFunc = Function name
488: * @args = Number of function arguments
489: * return: -1 error or 0 register ok
490: */
491: int
492: rpc_srv_registerCall(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc, u_char args)
493: {
494: rpc_func_t *func;
495: u_char str[MAXPATHLEN + UCHAR_MAX + 1];
496:
497: memset(str, 0, MAXPATHLEN + UCHAR_MAX + 1);
498: if (!srv || !csFunc) {
499: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t register function to RPC server ...\n");
500: return -1;
501: }
502: if (!(func = malloc(sizeof(rpc_func_t)))) {
503: LOGERR;
504: return -1;
505: } else {
506: memset(func, 0, sizeof(rpc_func_t));
507: strlcpy((char*) func->func_name, csFunc, UCHAR_MAX + 1);
508: }
509: if (csModule) {
510: strlcpy((char*) func->func_file, csModule, MAXPATHLEN);
511: strlcpy((char*) str, csModule, MAXPATHLEN + UCHAR_MAX + 1);
512: }
513: strlcat((char*) str, "__", MAXPATHLEN + UCHAR_MAX + 1);
514: strlcat((char*) str, csFunc, MAXPATHLEN + UCHAR_MAX + 1);
515:
516: func->func_tag = crcFletcher16((u_short*) str, (MAXPATHLEN + UCHAR_MAX + 1) / 2);
517: func->func_hash = hash_fnv((char*) str, MAXPATHLEN + UCHAR_MAX + 1);
518:
519: if (rpc_srv_declValsCall(func, args) == -1) {
520: free(func);
521: return -1;
522: }
523:
524: func->func_next = srv->srv_funcs;
525: srv->srv_funcs = func;
526: return 0;
527: }
528:
529: /*
530: * rpc_srv_unregisterCall() Unregister call from RPC server
531: * @srv = RPC Server instance
532: * @csModule = Module name, if NULL self binary
533: * @csFunc = Function name
534: * return: -1 error, 0 not found call, 1 unregister ok
535: */
536: int
537: rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc)
538: {
539: rpc_func_t func, *f, *curr;
540: u_char str[MAXPATHLEN + UCHAR_MAX + 1];
541:
542: memset(&func, 0, sizeof(rpc_func_t));
543: memset(str, 0, MAXPATHLEN + UCHAR_MAX + 1);
544: if (!srv || !csFunc) {
545: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t unregister function from RPC server ...\n");
546: return -1;
547: } else
548: strlcpy((char*) func.func_name, csFunc, UCHAR_MAX + 1);
549: if (csModule) {
550: strlcpy((char*) func.func_file, csModule, MAXPATHLEN);
551: strlcpy((char*) str, csModule, MAXPATHLEN + UCHAR_MAX + 1);
552: }
553: strlcat((char*) str, "__", MAXPATHLEN + UCHAR_MAX + 1);
554: strlcat((char*) str, csFunc, MAXPATHLEN + UCHAR_MAX + 1);
555:
556: func.func_tag = crcFletcher16((u_short*) str, (MAXPATHLEN + UCHAR_MAX + 1) / 2);
557: func.func_hash = hash_fnv((char*) str, MAXPATHLEN + UCHAR_MAX + 1);
558:
559: f = rpc_srv_getCall(srv, func.func_tag, func.func_hash);
560: if (!f) // not found element for unregister
561: return 0;
562:
563: if (srv->srv_funcs == f) { // if is 1st element
564: srv->srv_funcs = srv->srv_funcs->func_next;
565:
566: if (f->func_args && f->func_vals)
567: free(f->func_vals);
568: free(f);
569: } else {
570: for (curr = srv->srv_funcs; curr->func_next != f; curr = curr->func_next);
571: curr->func_next = curr->func_next->func_next;
572:
573: if (f->func_args && f->func_vals)
574: free(f->func_vals);
575: free(f);
576: }
577:
578: return 1;
579: }
580:
581: /*
582: * rpc_srv_getCall() Get registered call from RPC server
583: * @srv = RPC Server instance
584: * @tag = tag for function
585: * @hash = hash for function
586: * return: NULL not found call, !=NULL return call
587: */
588: inline rpc_func_t *
589: rpc_srv_getCall(rpc_srv_t * __restrict srv, uint16_t tag, uint32_t hash)
590: {
591: rpc_func_t *f;
592:
593: if (!srv) {
594: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t get function from RPC server ...\n");
595: return NULL;
596: }
597:
598: for (f = srv->srv_funcs; f; f = f->func_next)
599: if (f->func_tag == tag && f->func_hash == hash)
600: break;
601:
602: return f;
603: }
604:
605: /*
606: * rpc_srv_getFunc() Get registered call from RPC server by Name
607: * @srv = RPC Server instance
608: * @csModule = Module name, if NULL self binary
609: * @csFunc = Function name
610: * return: NULL not found call, !=NULL return call
611: */
612: rpc_func_t *
613: rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char *csModule, const char *csFunc)
614: {
615: rpc_func_t func;
616: u_char str[MAXPATHLEN + UCHAR_MAX + 1];
617:
618: memset(&func, 0, sizeof(rpc_func_t));
619: memset(str, 0, MAXPATHLEN + UCHAR_MAX + 1);
620: if (!srv || !csFunc) {
621: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t get function from RPC server ...\n");
622: return NULL;
623: } else
624: strlcpy((char*) func.func_name, csFunc, UCHAR_MAX + 1);
625: if (csModule) {
626: strlcpy((char*) func.func_file, csModule, MAXPATHLEN);
627: strlcpy((char*) str, csModule, MAXPATHLEN + UCHAR_MAX + 1);
628: }
629: strlcat((char*) str, "__", MAXPATHLEN + UCHAR_MAX + 1);
630: strlcat((char*) str, csFunc, MAXPATHLEN + UCHAR_MAX + 1);
631:
632: func.func_tag = crcFletcher16((u_short*) str, (MAXPATHLEN + UCHAR_MAX + 1) / 2);
633: func.func_hash = hash_fnv((char*) str, MAXPATHLEN + UCHAR_MAX + 1);
634:
635: return rpc_srv_getCall(srv, func.func_tag, func.func_hash);
636: }
637:
638: // ---------------------------------------------------------
639:
640: /*
641: * rpc_srv_execCall() Execute registered call from RPC server
642: * @data = RPC const data
643: * @call = Register RPC call
644: * @rpc = IN RPC call structure
645: * @args = IN RPC call array of rpc values
646: * return: -1 error, !=-1 ok
647: */
648: int
649: rpc_srv_execCall(void * const data, rpc_func_t * __restrict call,
650: struct tagRPCCall * __restrict rpc, rpc_val_t * __restrict args)
651: {
652: void *dl;
653: rpc_callback_t func;
654: int ret;
655:
656: if (!data || !call || !rpc) {
657: rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t exec call from RPC server ...\n");
658: return -1;
659: }
660:
661: dl = dlopen((char*) (*call->func_file ? call->func_file : NULL), RTLD_NOW);
662: if (!dl) {
663: rpc_SetErr(ENOENT, "Error:: Can`t attach module %s!\n", dlerror());
664: return -1;
665: }
666:
667: func = dlsym(dl, (char*) call->func_name);
668: if (func)
669: ret = func(data, call, rpc->call_argc, args);
670: else {
671: rpc_SetErr(ENOEXEC, "Error:: Can`t find function %s!\n", dlerror());
672: ret = -1;
673: }
674:
675: dlclose(dl);
676: return ret;
677: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>