version 1.9.2.22, 2012/05/17 12:52:30
|
version 1.9.2.23, 2012/05/17 15:14:16
|
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; |