--- libaitrpc/src/srv.c 2013/03/07 23:10:50 1.14 +++ libaitrpc/src/srv.c 2013/04/02 15:50:14 1.15 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.14 2013/03/07 23:10:50 misho Exp $ +* $Id: srv.c,v 1.15 2013/04/02 15:50:14 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -193,9 +193,11 @@ txPacket(sched_task_t *task) rpc->call_len = htons(wlen); +#if 0 /* calculate CRC */ rpc->call_crc ^= rpc->call_crc; rpc->call_crc = htons(crcFletcher16((u_short*) buf, wlen / 2)); +#endif /* send reply */ ret = send(TASK_FD(task), buf, wlen, MSG_NOSIGNAL); @@ -269,7 +271,10 @@ rxPacket(sched_task_t *task) rpc_cli_t *c = TASK_ARG(task); rpc_srv_t *s = c->cli_parent; int len, rlen, noreply; - u_short crc, off = TASK_DATLEN(task); + u_short off = TASK_DATLEN(task); +#if 0 + u_short crc; +#endif u_char *buf = AIT_GET_BUF(&c->cli_buf); struct tagRPCCall *rpc; @@ -308,6 +313,7 @@ rxPacket(sched_task_t *task) break; } +#if 0 /* check integrity of packet */ crc = ntohs(rpc->call_crc); rpc->call_crc ^= rpc->call_crc; @@ -318,6 +324,7 @@ rxPacket(sched_task_t *task) /* try next packet remaining into buffer */ continue; } +#endif noreply = RPC_CHK_NOREPLY(rpc); @@ -556,13 +563,8 @@ txBLOB(sched_task_t *task) { rpc_cli_t *c = TASK_ARG(task); u_char *buf = AIT_GET_BUF(&c->cli_buf); - struct tagBLOBHdr *blob = (struct tagBLOBHdr *) buf; int wlen = sizeof(struct tagBLOBHdr); - /* calculate CRC */ - blob->hdr_crc ^= blob->hdr_crc; - blob->hdr_crc = htons(crcFletcher16((u_short*) buf, wlen / 2)); - /* send reply */ wlen = send(TASK_FD(task), buf, wlen, MSG_NOSIGNAL); if (wlen == -1 || wlen != sizeof(struct tagBLOBHdr)) { @@ -581,7 +583,6 @@ rxBLOB(sched_task_t *task) rpc_blob_t *b; struct tagBLOBHdr blob; int rlen; - u_short crc; memset(&blob, 0, sizeof blob); rlen = recv(TASK_FD(task), &blob, sizeof blob, 0); @@ -599,18 +600,8 @@ rxBLOB(sched_task_t *task) return NULL; } - /* check integrity of packet */ - crc = ntohs(blob.hdr_crc); - blob.hdr_crc ^= blob.hdr_crc; - if (crc != crcFletcher16((u_short*) &blob, rlen / 2)) { - rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet"); - - schedReadSelf(task); - return NULL; - } - /* check RPC packet session info */ - if ((crc = rpc_chkPktSession(&blob.hdr_session, &s->srv_session))) { + if (rpc_chkPktSession(&blob.hdr_session, &s->srv_session)) { rpc_SetErr(ERPCMISMATCH, "Get invalid RPC session"); blob.hdr_cmd = error; goto end; @@ -911,8 +902,7 @@ rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv) /* * rpc_srv_initServer() - Init & create RPC Server * - * @regProgID = ProgramID for authentication & recognition - * @regProcID = ProcessID for authentication & recognition + * @InstID = Instance for authentication & recognition * @concurentClients = Concurent clients at same time to this server * @netBuf = Network buffer length (min:512 bytes), if =0 == BUFSIZ (also meaning max RPC packet) * @csHost = Host name or address for bind server, if NULL any address @@ -921,14 +911,14 @@ rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv) * return: NULL == error or !=NULL bind and created RPC server instance */ rpc_srv_t * -rpc_srv_initServer(u_int regProgID, u_char regProcID, int concurentClients, - int netBuf, const char *csHost, u_short Port, int proto) +rpc_srv_initServer(u_char InstID, int concurentClients, int netBuf, + const char *csHost, u_short Port, int proto) { int n = 1; rpc_srv_t *srv = NULL; sockaddr_t sa = E_SOCKADDR_INIT; - if (!concurentClients || !regProgID || (proto < 0 || proto > SOCK_DGRAM)) { + if (!concurentClients || (proto < 0 || proto > SOCK_DGRAM)) { rpc_SetErr(EINVAL, "Invalid parameters can`t init RPC server"); return NULL; } @@ -961,8 +951,7 @@ rpc_srv_initServer(u_int regProgID, u_char regProcID, srv->srv_proto = proto; srv->srv_netbuf = netBuf; srv->srv_session.sess_version = RPC_VERSION; - srv->srv_session.sess_program = regProgID; - srv->srv_session.sess_process = regProcID; + srv->srv_session.sess_instance = InstID; srv->srv_server.cli_parent = srv; memcpy(&srv->srv_server.cli_sa, &sa, sizeof srv->srv_server.cli_sa);