--- libaitrpc/src/srv.c 2011/09/07 07:24:21 1.5 +++ libaitrpc/src/srv.c 2011/09/07 09:10:55 1.5.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.5 2011/09/07 07:24:21 misho Exp $ +* $Id: srv.c,v 1.5.2.2 2011/09/07 09:10:55 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -103,7 +103,7 @@ rpc_srv_dispatchCall(void *arg) } else rpc = (struct tagRPCCall*) buf; /* check RPC packet session info */ - if (memcmp(&rpc->call_session, &s->srv_session, sizeof rpc->call_session)) { + if (rpc_chkPktSession(&rpc->call_session, &s->srv_session)) { rpc_SetErr(ERPCMISMATCH, "Error:: get invalid RPC session ...\n"); ret = -5; goto makeReply; @@ -111,8 +111,9 @@ rpc_srv_dispatchCall(void *arg) Limit = sizeof(struct tagRPCCall); /* RPC is OK! Go decapsulate variables ... */ - if (rpc->call_argc) { - arr = io_buffer2vals(buf + Limit, s->srv_netbuf - Limit, rpc->call_argc, 1); + if (ntohs(rpc->call_argc)) { + arr = io_buffer2vals(buf + Limit, s->srv_netbuf - Limit, + ntohs(rpc->call_argc), 1); if (!arr) { ret = -5; goto makeReply; @@ -123,7 +124,7 @@ rpc_srv_dispatchCall(void *arg) /* execute call */ argc = 0; memcpy(&ses, &rpc->call_session, sizeof ses); - if (!(f = rpc_srv_getCall(s, rpc->call_tag, rpc->call_hash))) { + if (!(f = rpc_srv_getCall(s, ntohs(rpc->call_tag), ntohl(rpc->call_hash)))) { rpc_SetErr(EPROGUNAVAIL, "Error:: call not found into RPC server ...\n"); ret = -6; } else @@ -148,9 +149,9 @@ makeReply: memcpy(&rrpc->ret_session, &ses, sizeof(rpc_sess_t)); rrpc->ret_tag = rpc->call_tag; rrpc->ret_hash = rpc->call_hash; - rrpc->ret_errno = rpc_Errno; - rrpc->ret_retcode = ret; - rrpc->ret_argc = argc; + rrpc->ret_errno = htonl(rpc_Errno); + rrpc->ret_retcode = htonl(ret); + rrpc->ret_argc = htons(argc); if (argc && arr) { /* Go Encapsulate variables ... */ @@ -827,7 +828,7 @@ rpc_srv_execCall(rpc_func_t * __restrict call, struct func = dlsym(dl, (char*) call->func_name); if (func) - ret = func(call, rpc->call_argc, args); + ret = func(call, ntohs(rpc->call_argc), args); else { rpc_SetErr(ENOEXEC, "Error:: Can`t find function %s!\n", dlerror()); ret = -1;