--- libaitrpc/src/cli.c 2011/09/07 09:10:55 1.5.2.2 +++ libaitrpc/src/cli.c 2011/09/07 09:22:15 1.5.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.5.2.2 2011/09/07 09:10:55 misho Exp $ +* $Id: cli.c,v 1.5.2.3 2011/09/07 09:22:15 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -314,6 +314,8 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, struct tagRPCRet *rrpc = NULL; int ret = 0, Limit = 0; struct timeval tv = { DEF_RPC_TIMEOUT, 0 }; + uint16_t tag; + uint32_t hash; if (!cli || !csFunc) { rpc_SetErr(EINVAL, "Error:: Can`t execute call because parameter is null or invalid!\n"); @@ -340,8 +342,8 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, rpc = (struct tagRPCCall*) buf; rpc_addPktSession(&rpc->call_session, cli->cli_parent); rpc->call_argc = htons(in_vars ? io_arraySize(in_vars) : 0); - rpc->call_tag = htons(crcFletcher16((u_short*) str, sizeof str / 2)); - rpc->call_hash = htonl(hash_fnv((char*) str, sizeof str)); + rpc->call_tag = tag = htons(crcFletcher16((u_short*) str, sizeof str / 2)); + rpc->call_hash = hash = htonl(hash_fnv((char*) str, sizeof str)); Limit = sizeof(struct tagRPCCall); if (in_vars && io_arraySize(in_vars)) { @@ -402,6 +404,12 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, return -5; } else Limit = sizeof(struct tagRPCRet); + if (rrpc->ret_tag != tag || rrpc->ret_hash != hash) { + printf("tag=%x/%x hash=%x/%x\n", rrpc->ret_tag, tag, rrpc->ret_hash, hash); + rpc_SetErr(ERPCMISMATCH, "Error:: get wrong RPC reply ...\n"); + free(buf); + return -5; + } if (ntohl(rrpc->ret_retcode) < 0 && ntohl(rrpc->ret_errno)) { rpc_SetErr(ntohl(rrpc->ret_errno), "Error::Server side: retcode=%d #%d %s\n", ntohl(rrpc->ret_retcode), ntohl(rrpc->ret_errno),