Diff for /libaitrpc/src/srv.c between versions 1.9.2.22 and 1.9.2.24

version 1.9.2.22, 2012/05/17 12:52:30 version 1.9.2.24, 2012/05/17 15:18:48
Line 346  rxBLOB(sched_task_t *task) Line 346  rxBLOB(sched_task_t *task)
         rpc_cli_t *c = TASK_ARG(task);          rpc_cli_t *c = TASK_ARG(task);
         rpc_srv_t *s = c->cli_parent;          rpc_srv_t *s = c->cli_parent;
         rpc_blob_t *b;          rpc_blob_t *b;
        u_char *buf = AIT_GET_BUF(&c->cli_buf);        struct tagBLOBHdr blob;
        struct tagBLOBHdr *blob = (struct tagBLOBHdr *) buf; 
         int rlen;          int rlen;
         u_short crc;          u_short crc;
   
        memset(buf, 0, AIT_LEN(&c->cli_buf));        memset(&blob, 0, sizeof blob);
        rlen = recv(TASK_FD(task), buf, AIT_LEN(&c->cli_buf), 0);        rlen = recv(TASK_FD(task), &blob, sizeof blob, 0);
         if (rlen < 1) {          if (rlen < 1) {
                 /* close blob connection */                  /* close blob connection */
                 schedEvent(TASK_ROOT(task), closeBLOBClient, c, 42, NULL, 0);                  schedEvent(TASK_ROOT(task), closeBLOBClient, c, 42, NULL, 0);
Line 368  rxBLOB(sched_task_t *task) Line 367  rxBLOB(sched_task_t *task)
         }          }
   
         /* check integrity of packet */          /* check integrity of packet */
        crc = ntohs(blob->hdr_crc);        crc = ntohs(blob.hdr_crc);
        blob->hdr_crc ^= blob->hdr_crc;        blob.hdr_crc ^= blob.hdr_crc;
        if (crc != crcFletcher16((u_short*) buf, rlen / 2)) {        if (crc != crcFletcher16((u_short*) &blob, rlen / 2)) {
                 rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet");                  rpc_SetErr(ERPCMISMATCH, "Bad CRC BLOB packet");
   
                 schedReadSelf(task);                  schedReadSelf(task);
Line 378  rxBLOB(sched_task_t *task) Line 377  rxBLOB(sched_task_t *task)
         }          }
   
         /* check RPC packet session info */          /* check RPC packet session info */
        if ((crc = rpc_chkPktSession(&blob->hdr_session, &s->srv_session))) {        if ((crc = rpc_chkPktSession(&blob.hdr_session, &s->srv_session))) {
                 rpc_SetErr(ERPCMISMATCH, "Get invalid RPC session");                  rpc_SetErr(ERPCMISMATCH, "Get invalid RPC session");
                blob->hdr_cmd = error;                blob.hdr_cmd = error;
                 goto end;                  goto end;
         }          }
   
         /* Go to proceed packet ... */          /* Go to proceed packet ... */
        switch (blob->hdr_cmd) {        switch (blob.hdr_cmd) {
                 case get:                  case get:
                        if (!(b = rpc_srv_getBLOB(s, ntohl(blob->hdr_var)))) {                        if (!(b = rpc_srv_getBLOB(s, ntohl(blob.hdr_var)))) {
                                rpc_SetErr(EINVAL, "Var=%x not found", ntohl(blob->hdr_var));                                rpc_SetErr(EINVAL, "Var=%x not found", ntohl(blob.hdr_var));
                                blob->hdr_cmd = no;                                blob.hdr_cmd = no;
                                blob->hdr_ret = RPC_ERROR(-1);                                blob.hdr_ret = RPC_ERROR(-1);
                                 break;                                  break;
                         } else                          } else
                                blob->hdr_len = htonl(b->blob_len);                                blob.hdr_len = htonl(b->blob_len);
   
                         if (rpc_srv_blobMap(s, b) != -1) {                          if (rpc_srv_blobMap(s, b) != -1) {
                                 /* deliver BLOB variable to client */                                  /* deliver BLOB variable to client */
                                blob->hdr_ret = htonl(rpc_srv_sendBLOB(c, b));                                blob.hdr_ret = htonl(rpc_srv_sendBLOB(c, b));
                                 rpc_srv_blobUnmap(b);                                  rpc_srv_blobUnmap(b);
                         } else {                          } else {
                                blob->hdr_cmd = error;                                blob.hdr_cmd = error;
                                blob->hdr_ret = RPC_ERROR(-1);                                blob.hdr_ret = RPC_ERROR(-1);
                         }                          }
                         break;                          break;
                 case set:                  case set:
                        if ((b = rpc_srv_registerBLOB(s, ntohl(blob->hdr_len)))) {                        if ((b = rpc_srv_registerBLOB(s, ntohl(blob.hdr_len)))) {
                                 /* set new BLOB variable for reply :) */                                  /* set new BLOB variable for reply :) */
                                blob->hdr_var = htonl(b->blob_var);                                blob.hdr_var = htonl(b->blob_var);
   
                                 /* receive BLOB from client */                                  /* receive BLOB from client */
                                blob->hdr_ret = htonl(rpc_srv_recvBLOB(c, b));                                blob.hdr_ret = htonl(rpc_srv_recvBLOB(c, b));
                                 rpc_srv_blobUnmap(b);                                  rpc_srv_blobUnmap(b);
                         } else {                          } else {
                                blob->hdr_cmd = error;                                blob.hdr_cmd = error;
                                blob->hdr_ret = RPC_ERROR(-1);                                blob.hdr_ret = RPC_ERROR(-1);
                         }                          }
                         break;                          break;
                 case unset:                  case unset:
                        if (rpc_srv_unregisterBLOB(s, blob->hdr_var) == -1) {                        if (rpc_srv_unregisterBLOB(s, blob.hdr_var) == -1) {
                                blob->hdr_cmd = error;                                blob.hdr_cmd = error;
                                blob->hdr_ret = RPC_ERROR(-1);                                blob.hdr_ret = RPC_ERROR(-1);
                         }                          }
                         break;                          break;
                 default:                  default:
                        rpc_SetErr(EPROCUNAVAIL, "Unsupported BLOB command %d", blob->hdr_cmd);                        rpc_SetErr(EPROCUNAVAIL, "Unsupported BLOB command %d", blob.hdr_cmd);
                        blob->hdr_cmd = error;                        blob.hdr_cmd = error;
                        blob->hdr_ret = RPC_ERROR(-1);                        blob.hdr_ret = RPC_ERROR(-1);
         }          }
   
 end:  end:
           memcpy(AIT_ADDR(&c->cli_buf), &blob, sizeof blob);
         schedWrite(TASK_ROOT(task), txBLOB, TASK_ARG(task), TASK_FD(task), NULL, 0);          schedWrite(TASK_ROOT(task), txBLOB, TASK_ARG(task), TASK_FD(task), NULL, 0);
         schedReadSelf(task);          schedReadSelf(task);
         return NULL;          return NULL;
Line 675  rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv) Line 675  rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv)
  * @regProgID = ProgramID for authentication & recognition   * @regProgID = ProgramID for authentication & recognition
  * @regProcID = ProcessID for authentication & recognition   * @regProcID = ProcessID for authentication & recognition
  * @concurentClients = Concurent clients at same time to this server   * @concurentClients = Concurent clients at same time to this server
 * @netBuf = Network buffer length, if =0 == BUFSIZ (also meaning max RPC packet) * @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   * @csHost = Host name or address for bind server, if NULL any address
  * @Port = Port for bind server, if Port == 0 default port is selected   * @Port = Port for bind server, if Port == 0 default port is selected
  * return: NULL == error or !=NULL bind and created RPC server instance   * return: NULL == error or !=NULL bind and created RPC server instance
Line 696  rpc_srv_initServer(u_int regProgID, u_char regProcID,  Line 696  rpc_srv_initServer(u_int regProgID, u_char regProcID, 
                 return NULL;                  return NULL;
         if (!Port)          if (!Port)
                 Port = RPC_DEFPORT;                  Port = RPC_DEFPORT;
        if (!netBuf)        if (netBuf < RPC_MIN_BUFSIZ)
                 netBuf = BUFSIZ;                  netBuf = BUFSIZ;
         else          else
                 netBuf = io_align(netBuf, 1);   /* align netBuf length */                  netBuf = io_align(netBuf, 1);   /* align netBuf length */

Removed from v.1.9.2.22  
changed lines
  Added in v.1.9.2.24


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>