version 1.14, 2013/03/07 23:10:50
|
version 1.16.2.1, 2013/07/15 14:16:52
|
Line 67 static sched_task_func_t cbProto[SOCK_RAW + 1][4] = {
|
Line 67 static sched_task_func_t cbProto[SOCK_RAW + 1][4] = {
|
}; |
}; |
|
|
|
|
inline void | void |
rpc_freeCli(rpc_cli_t * __restrict c) |
rpc_freeCli(rpc_cli_t * __restrict c) |
{ |
{ |
rpc_srv_t *s = c->cli_parent; |
rpc_srv_t *s = c->cli_parent; |
Line 193 txPacket(sched_task_t *task)
|
Line 193 txPacket(sched_task_t *task)
|
|
|
rpc->call_len = htons(wlen); |
rpc->call_len = htons(wlen); |
|
|
|
#if 0 |
/* calculate CRC */ |
/* calculate CRC */ |
rpc->call_crc ^= rpc->call_crc; |
rpc->call_crc ^= rpc->call_crc; |
rpc->call_crc = htons(crcFletcher16((u_short*) buf, wlen / 2)); |
rpc->call_crc = htons(crcFletcher16((u_short*) buf, wlen / 2)); |
|
#endif |
|
|
/* send reply */ |
/* send reply */ |
ret = send(TASK_FD(task), buf, wlen, MSG_NOSIGNAL); |
ret = send(TASK_FD(task), buf, wlen, MSG_NOSIGNAL); |
Line 269 rxPacket(sched_task_t *task)
|
Line 271 rxPacket(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; |
int len, rlen, noreply; |
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); |
u_char *buf = AIT_GET_BUF(&c->cli_buf); |
struct tagRPCCall *rpc; |
struct tagRPCCall *rpc; |
|
|
Line 308 rxPacket(sched_task_t *task)
|
Line 313 rxPacket(sched_task_t *task)
|
break; |
break; |
} |
} |
|
|
|
#if 0 |
/* check integrity of packet */ |
/* check integrity of packet */ |
crc = ntohs(rpc->call_crc); |
crc = ntohs(rpc->call_crc); |
rpc->call_crc ^= rpc->call_crc; |
rpc->call_crc ^= rpc->call_crc; |
Line 318 rxPacket(sched_task_t *task)
|
Line 324 rxPacket(sched_task_t *task)
|
/* try next packet remaining into buffer */ |
/* try next packet remaining into buffer */ |
continue; |
continue; |
} |
} |
|
#endif |
|
|
noreply = RPC_CHK_NOREPLY(rpc); |
noreply = RPC_CHK_NOREPLY(rpc); |
|
|
Line 522 end:
|
Line 529 end:
|
|
|
/* ------------------------------------------------------ */ |
/* ------------------------------------------------------ */ |
|
|
inline void | void |
rpc_freeBLOBCli(rpc_cli_t * __restrict c) |
rpc_freeBLOBCli(rpc_cli_t * __restrict c) |
{ |
{ |
rpc_srv_t *s = c->cli_parent; |
rpc_srv_t *s = c->cli_parent; |
Line 552 closeBLOBClient(sched_task_t *task)
|
Line 559 closeBLOBClient(sched_task_t *task)
|
} |
} |
|
|
static void * |
static void * |
|
toutBLOB(sched_task_t *task) |
|
{ |
|
rpc_cli_t *c = TASK_DATA(task); |
|
|
|
rpc_srv_unregisterBLOB((rpc_srv_t*) c->cli_parent, (uint32_t) TASK_ARG(task)); |
|
|
|
return NULL; |
|
} |
|
|
|
static void * |
txBLOB(sched_task_t *task) |
txBLOB(sched_task_t *task) |
{ |
{ |
rpc_cli_t *c = TASK_ARG(task); |
rpc_cli_t *c = TASK_ARG(task); |
u_char *buf = AIT_GET_BUF(&c->cli_buf); |
u_char *buf = AIT_GET_BUF(&c->cli_buf); |
struct tagBLOBHdr *blob = (struct tagBLOBHdr *) buf; |
|
int wlen = sizeof(struct tagBLOBHdr); |
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 */ |
/* send reply */ |
wlen = send(TASK_FD(task), buf, wlen, MSG_NOSIGNAL); |
wlen = send(TASK_FD(task), buf, wlen, MSG_NOSIGNAL); |
if (wlen == -1 || wlen != sizeof(struct tagBLOBHdr)) { |
if (wlen == -1 || wlen != sizeof(struct tagBLOBHdr)) { |
Line 581 rxBLOB(sched_task_t *task)
|
Line 593 rxBLOB(sched_task_t *task)
|
rpc_blob_t *b; |
rpc_blob_t *b; |
struct tagBLOBHdr blob; |
struct tagBLOBHdr blob; |
int rlen; |
int rlen; |
u_short crc; | struct timespec ts = { RPC_BLOB_TIMEOUT, 0 }; |
|
|
memset(&blob, 0, sizeof blob); |
memset(&blob, 0, sizeof blob); |
rlen = recv(TASK_FD(task), &blob, sizeof blob, 0); |
rlen = recv(TASK_FD(task), &blob, sizeof blob, 0); |
Line 599 rxBLOB(sched_task_t *task)
|
Line 611 rxBLOB(sched_task_t *task)
|
return NULL; |
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 */ |
/* 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"); |
rpc_SetErr(ERPCMISMATCH, "Get invalid RPC session"); |
blob.hdr_cmd = error; |
blob.hdr_cmd = error; |
goto end; |
goto end; |
Line 641 rxBLOB(sched_task_t *task)
|
Line 643 rxBLOB(sched_task_t *task)
|
/* 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); |
|
|
|
/* set live BLOB timeout */ |
|
ts.tv_sec = blob.hdr_ret ? blob.hdr_ret : RPC_BLOB_TIMEOUT; |
|
|
/* 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); |
|
|
|
schedTimer(TASK_ROOT(task), toutBLOB, |
|
(void*) (intptr_t) ntohl(blob.hdr_var), ts, |
|
TASK_ARG(task), ntohl(blob.hdr_len)); |
} else { |
} else { |
blob.hdr_cmd = error; |
blob.hdr_cmd = error; |
blob.hdr_ret = RPC_ERROR(-1); |
blob.hdr_ret = RPC_ERROR(-1); |
Line 654 rxBLOB(sched_task_t *task)
|
Line 663 rxBLOB(sched_task_t *task)
|
blob.hdr_cmd = error; |
blob.hdr_cmd = error; |
blob.hdr_ret = RPC_ERROR(-1); |
blob.hdr_ret = RPC_ERROR(-1); |
} |
} |
|
|
|
schedCancelby(TASK_ROOT(task), taskTIMER, CRITERIA_ARG, |
|
(void*) (intptr_t) ntohl(blob.hdr_var), NULL); |
break; |
break; |
default: |
default: |
rpc_SetErr(EPROCUNAVAIL, "Unsupported BLOB command %d", blob.hdr_cmd); |
rpc_SetErr(EPROCUNAVAIL, "Unsupported BLOB command %d", blob.hdr_cmd); |
Line 835 rpc_srv_initBLOBServer(rpc_srv_t * __restrict srv, u_s
|
Line 847 rpc_srv_initBLOBServer(rpc_srv_t * __restrict srv, u_s
|
* @srv = RPC Server instance |
* @srv = RPC Server instance |
* return: none |
* return: none |
*/ |
*/ |
inline void | void |
rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv) |
rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv) |
{ |
{ |
if (!srv) |
if (!srv) |
Line 911 rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv)
|
Line 923 rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv)
|
/* |
/* |
* rpc_srv_initServer() - Init & create RPC Server |
* rpc_srv_initServer() - Init & create RPC Server |
* |
* |
* @regProgID = ProgramID for authentication & recognition | * @InstID = Instance 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 (min:512 bytes), 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 |
Line 921 rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv)
|
Line 932 rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv)
|
* return: NULL == error or !=NULL bind and created RPC server instance |
* return: NULL == error or !=NULL bind and created RPC server instance |
*/ |
*/ |
rpc_srv_t * |
rpc_srv_t * |
rpc_srv_initServer(u_int regProgID, u_char regProcID, int concurentClients, | rpc_srv_initServer(u_char InstID, int concurentClients, int netBuf, |
int netBuf, const char *csHost, u_short Port, int proto) | const char *csHost, u_short Port, int proto) |
{ |
{ |
int n = 1; |
int n = 1; |
rpc_srv_t *srv = NULL; |
rpc_srv_t *srv = NULL; |
sockaddr_t sa = E_SOCKADDR_INIT; |
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"); |
rpc_SetErr(EINVAL, "Invalid parameters can`t init RPC server"); |
return NULL; |
return NULL; |
} |
} |
Line 961 rpc_srv_initServer(u_int regProgID, u_char regProcID,
|
Line 972 rpc_srv_initServer(u_int regProgID, u_char regProcID,
|
srv->srv_proto = proto; |
srv->srv_proto = proto; |
srv->srv_netbuf = netBuf; |
srv->srv_netbuf = netBuf; |
srv->srv_session.sess_version = RPC_VERSION; |
srv->srv_session.sess_version = RPC_VERSION; |
srv->srv_session.sess_program = regProgID; | srv->srv_session.sess_instance = InstID; |
srv->srv_session.sess_process = regProcID; | |
|
|
srv->srv_server.cli_parent = srv; |
srv->srv_server.cli_parent = srv; |
memcpy(&srv->srv_server.cli_sa, &sa, sizeof srv->srv_server.cli_sa); |
memcpy(&srv->srv_server.cli_sa, &sa, sizeof srv->srv_server.cli_sa); |
Line 1040 err: /* error condition */
|
Line 1050 err: /* error condition */
|
* @psrv = RPC Server instance |
* @psrv = RPC Server instance |
* return: none |
* return: none |
*/ |
*/ |
inline void | void |
rpc_srv_endServer(rpc_srv_t ** __restrict psrv) |
rpc_srv_endServer(rpc_srv_t ** __restrict psrv) |
{ |
{ |
if (!psrv || !*psrv) |
if (!psrv || !*psrv) |