version 1.23.2.2, 2015/01/18 01:03:49
|
version 1.24.2.2, 2015/01/28 00:06:22
|
Line 161 rpc_cli_openClient(u_char InstID, int netBuf, const ch
|
Line 161 rpc_cli_openClient(u_char InstID, int netBuf, const ch
|
rpc_cli_t *cli = NULL; |
rpc_cli_t *cli = NULL; |
sockaddr_t sa = E_SOCKADDR_INIT; |
sockaddr_t sa = E_SOCKADDR_INIT; |
|
|
|
if (proto < 0 || proto > SOCK_RAW) { |
|
rpc_SetErr(EINVAL, "Invalid parameters can`t open RPC client"); |
|
return NULL; |
|
} |
|
|
if (!e_gethostbyname(csHost, Port, &sa)) |
if (!e_gethostbyname(csHost, Port, &sa)) |
return NULL; |
return NULL; |
if (!Port) |
if (!Port) |
Line 195 rpc_cli_openClient(u_char InstID, int netBuf, const ch
|
Line 200 rpc_cli_openClient(u_char InstID, int netBuf, const ch
|
AIT_SET_BUFSIZ(&cli->cli_buf, 0, netBuf); |
AIT_SET_BUFSIZ(&cli->cli_buf, 0, netBuf); |
|
|
/* connect to RPC server */ |
/* connect to RPC server */ |
cli->cli_sock = socket(cli->cli_sa.sa.sa_family, cli->cli_id, 0); | cli->cli_sock = socket(cli->cli_sa.sa.sa_family, cli->cli_id, |
| cli->cli_id == SOCK_RAW ? IPPROTO_ERPC : 0); |
if (cli->cli_sock == -1) { |
if (cli->cli_sock == -1) { |
LOGERR; |
LOGERR; |
goto err; |
goto err; |
Line 350 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
Line 356 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
do { |
do { |
if (type == SOCK_STREAM) |
if (type == SOCK_STREAM) |
ret = rpc_Read(sock, type, !estlen ? MSG_PEEK : 0, NULL, buf, blen); |
ret = rpc_Read(sock, type, !estlen ? MSG_PEEK : 0, NULL, buf, blen); |
else if (type == SOCK_BPF) { | else if (type == SOCK_EXT) { |
| ret = rpc_Read(sock, type, 0, NULL, buf, blen); |
| if (estlen) /* hack for skip sanity checks */ |
| ret += sizeof(struct tagRPCCall); |
| } else if (type == SOCK_BPF) { |
ret = rpc_Read(sock, type, 0, sa, AIT_GET_BUF(pkt), AIT_LEN(pkt)); |
ret = rpc_Read(sock, type, 0, sa, AIT_GET_BUF(pkt), AIT_LEN(pkt)); |
if (ret > 0) |
if (ret > 0) |
estlen = ret; |
estlen = ret; |
Line 359 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
Line 369 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
if (ret < 1) |
if (ret < 1) |
return ret; |
return ret; |
|
|
|
/* 1st read for RPC header */ |
|
if (ret < sizeof(struct tagRPCCall)) { |
|
rpc_SetErr(ERPCMISMATCH, "Short RPC packet %d bytes", ret); |
|
return -1; |
|
} |
|
|
|
/* check for loop request */ |
|
if (!estlen && !(rpc->call_io & RPC_ACK)) |
|
continue; |
|
|
/* check for response from known address */ |
/* check for response from known address */ |
if (!estlen) { |
if (!estlen) { |
/* 1st read for RPC header */ |
|
if (ret < sizeof(struct tagRPCCall)) { |
|
rpc_SetErr(ERPCMISMATCH, "Short RPC packet %d bytes", ret); |
|
return -1; |
|
} |
|
|
|
/* calc estimated length */ |
/* calc estimated length */ |
estlen = ntohl(rpc->call_len); |
estlen = ntohl(rpc->call_len); |
if (estlen > AIT_LEN(pkt)) |
if (estlen > AIT_LEN(pkt)) |
AIT_RE_BUF(pkt, estlen); |
AIT_RE_BUF(pkt, estlen); |
|
blen = estlen; |
buf = AIT_GET_BUF(pkt); |
buf = AIT_GET_BUF(pkt); |
|
|
|
if (type == SOCK_EXT) { |
|
blen -= sizeof(struct tagRPCCall); |
|
buf += sizeof(struct tagRPCCall); |
|
} |
|
|
rpc = (struct tagRPCCall*) buf; |
rpc = (struct tagRPCCall*) buf; |
blen = estlen; |
|
continue; |
continue; |
} |
} |
|
|
Line 381 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
Line 401 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
break; |
break; |
} while (42); |
} while (42); |
|
|
if (ret < sizeof(struct tagRPCCall) || estlen != ret) { | if (estlen != ret) { |
rpc_SetErr(ERPCMISMATCH, "RPC packet mismatch estimate %d bytes, but received %d\n", |
rpc_SetErr(ERPCMISMATCH, "RPC packet mismatch estimate %d bytes, but received %d\n", |
estlen, ret); |
estlen, ret); |
return -1; |
return -1; |
Line 427 rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t
|
Line 447 rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t
|
if (!vars) |
if (!vars) |
rpc->call_argc = 0; |
rpc->call_argc = 0; |
else |
else |
rpc->call_argc = htons(array_Size(vars)); | rpc->call_argc = (u_char) array_Size(vars); |
|
|
/* set reply */ |
/* set reply */ |
rpc->call_req.flags = (uint64_t) htonl(noreply ? RPC_NOREPLY : RPC_REPLY); |
rpc->call_req.flags = (uint64_t) htonl(noreply ? RPC_NOREPLY : RPC_REPLY); |
Line 444 rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t
|
Line 464 rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t
|
|
|
/* total packet length */ |
/* total packet length */ |
rpc->call_len = htonl(len); |
rpc->call_len = htonl(len); |
|
rpc->call_io = RPC_REQ; |
|
|
if (!nocrc) { |
if (!nocrc) { |
/* calculate CRC */ |
/* calculate CRC */ |
Line 459 rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t
|
Line 480 rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t
|
* |
* |
* @pkt = Packet buffer |
* @pkt = Packet buffer |
* @sess = RPC session info, if =NULL don't check session |
* @sess = RPC session info, if =NULL don't check session |
* @tag = Function tag | * @tag = Function tag, if =CALL_TAG_MAX don't check tag |
* @vars = Function argument array of values, may be NULL |
* @vars = Function argument array of values, may be NULL |
* @nocrc = Without CRC calculation |
* @nocrc = Without CRC calculation |
* return: -1 error or != -1 return value from function |
* return: -1 error or != -1 return value from function |
Line 495 rpc_pkt_Replay(ait_val_t * __restrict pkt, rpc_sess_t
|
Line 516 rpc_pkt_Replay(ait_val_t * __restrict pkt, rpc_sess_t
|
rpc_SetErr(ERPCMISMATCH, "Get invalid RPC session"); |
rpc_SetErr(ERPCMISMATCH, "Get invalid RPC session"); |
return -1; |
return -1; |
} |
} |
if (ntohs(rpc->call_tag) != tag) { | if (tag != CALL_TAG_MAX && ntohs(rpc->call_tag) != tag) { |
rpc_SetErr(ERPCMISMATCH, "Get wrong RPC reply"); |
rpc_SetErr(ERPCMISMATCH, "Get wrong RPC reply"); |
return -1; |
return -1; |
} |
} |
Line 505 rpc_pkt_Replay(ait_val_t * __restrict pkt, rpc_sess_t
|
Line 526 rpc_pkt_Replay(ait_val_t * __restrict pkt, rpc_sess_t
|
strerror(ntohl(rpc->call_rep.eno))); |
strerror(ntohl(rpc->call_rep.eno))); |
return -1; |
return -1; |
} |
} |
len = ntohs(rpc->call_argc) * sizeof(ait_val_t); | len = rpc->call_argc * sizeof(ait_val_t); |
if (len > AIT_LEN(pkt) - sizeof(struct tagRPCCall)) { |
if (len > AIT_LEN(pkt) - sizeof(struct tagRPCCall)) { |
rpc_SetErr(EMSGSIZE, "Reply RPC packet not enough buffer space ..."); |
rpc_SetErr(EMSGSIZE, "Reply RPC packet not enough buffer space ..."); |
return -1; |
return -1; |
Line 516 rpc_pkt_Replay(ait_val_t * __restrict pkt, rpc_sess_t
|
Line 537 rpc_pkt_Replay(ait_val_t * __restrict pkt, rpc_sess_t
|
} |
} |
|
|
/* RPC is OK! Go de-marshaling variables ... */ |
/* RPC is OK! Go de-marshaling variables ... */ |
if (vars && ntohs(rpc->call_argc)) { | if (vars && rpc->call_argc) { |
#ifdef CLI_RES_ZCOPY |
#ifdef CLI_RES_ZCOPY |
*vars = ait_buffer2vars(buf + sizeof(struct tagRPCCall), len, |
*vars = ait_buffer2vars(buf + sizeof(struct tagRPCCall), len, |
ntohs(rpc->call_argc), 42); | rpc->call_argc, 42); |
#else |
#else |
*vars = ait_buffer2vars(buf + sizeof(struct tagRPCCall), len, |
*vars = ait_buffer2vars(buf + sizeof(struct tagRPCCall), len, |
ntohs(rpc->call_argc), 0); | rpc->call_argc, 0); |
#endif |
#endif |
if (!*vars) { |
if (!*vars) { |
rpc_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
rpc_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
Line 554 rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short
|
Line 575 rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short
|
rpc_SetErr(EINVAL, "Can`t execute call because parameter is null or invalid!"); |
rpc_SetErr(EINVAL, "Can`t execute call because parameter is null or invalid!"); |
return -1; |
return -1; |
} else { |
} else { |
if (cli->cli_id == SOCK_STREAM) | if (cli->cli_id == SOCK_STREAM || cli->cli_id == SOCK_EXT) |
type = cli->cli_id; |
type = cli->cli_id; |
buf = AIT_GET_BUF(&cli->cli_buf); |
buf = AIT_GET_BUF(&cli->cli_buf); |
} |
} |