version 1.5.2.5, 2011/10/31 14:58:33
|
version 1.5.2.7, 2011/11/03 14:28:48
|
Line 65 rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli,
|
Line 65 rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli,
|
rpc_SetErr(EINVAL, "Error:: Invalid parameters can`t connect to BLOB server ...\n"); |
rpc_SetErr(EINVAL, "Error:: Invalid parameters can`t connect to BLOB server ...\n"); |
return NULL; |
return NULL; |
} |
} |
if (!Port) |
|
Port = RPC_DEFPORT + 1; |
|
|
|
cli = malloc(sizeof(rpc_cli_t)); |
cli = malloc(sizeof(rpc_cli_t)); |
if (!cli) { |
if (!cli) { |
Line 76 rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli,
|
Line 74 rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli,
|
memcpy(cli, rpccli, sizeof(rpc_cli_t)); |
memcpy(cli, rpccli, sizeof(rpc_cli_t)); |
|
|
memcpy(&sa, &rpccli->cli_sa, sizeof sa); |
memcpy(&sa, &rpccli->cli_sa, sizeof sa); |
switch (rpccli->cli_sa.sa.sa_family) { | switch (sa.sa.sa_family) { |
case AF_INET: |
case AF_INET: |
sa.sin.sin_port = htons(Port); | sa.sin.sin_port = htons(Port ? Port : ntohs(sa.sin.sin_port) + 1); |
break; |
break; |
case AF_INET6: |
case AF_INET6: |
sa.sin6.sin6_port = htons(Port); | sa.sin6.sin6_port = htons(Port ? Port : ntohs(sa.sin6.sin6_port) + 1); |
break; |
break; |
case AF_LOCAL: |
case AF_LOCAL: |
strlcat(sa.sun.sun_path, ".blob", sizeof sa.sun.sun_path); |
strlcat(sa.sun.sun_path, ".blob", sizeof sa.sun.sun_path); |
Line 323 rpc_cli_execCall(rpc_cli_t *cli, const char *csModule,
|
Line 321 rpc_cli_execCall(rpc_cli_t *cli, const char *csModule,
|
/* prepare RPC call */ |
/* prepare RPC call */ |
rpc = (struct tagRPCCall*) buf; |
rpc = (struct tagRPCCall*) buf; |
rpc_addPktSession(&rpc->call_session, cli->cli_parent); |
rpc_addPktSession(&rpc->call_session, cli->cli_parent); |
rpc->call_argc = htons(in_vars ? io_arraySize(in_vars) : 0); | rpc->call_argc = htons(io_arraySize(in_vars)); |
rpc->call_tag = tag = htons(crcFletcher16((u_short*) str, sizeof str / 2)); |
rpc->call_tag = tag = htons(crcFletcher16((u_short*) str, sizeof str / 2)); |
rpc->call_hash = hash = htonl(hash_fnv((char*) str, sizeof str)); |
rpc->call_hash = hash = htonl(hash_fnv((char*) str, sizeof str)); |
Limit = sizeof(struct tagRPCCall); |
Limit = sizeof(struct tagRPCCall); |
|
|
if (in_vars && io_arraySize(in_vars)) { | if (io_arraySize(in_vars)) { |
/* marshaling variables */ |
/* marshaling variables */ |
ret = io_vals2buffer(buf + Limit, cli->cli_netbuf - Limit, in_vars); | ret = io_vars2buffer(buf + Limit, cli->cli_netbuf - Limit, in_vars); |
if (ret == -1) { |
if (ret == -1) { |
rpc_SetErr(EBADRPC, "Error:: in prepare RPC packet values (-7) ...\n"); |
rpc_SetErr(EBADRPC, "Error:: in prepare RPC packet values (-7) ...\n"); |
free(buf); |
free(buf); |
Line 387 rpc_cli_execCall(rpc_cli_t *cli, const char *csModule,
|
Line 385 rpc_cli_execCall(rpc_cli_t *cli, const char *csModule,
|
} else |
} else |
Limit = sizeof(struct tagRPCRet); |
Limit = sizeof(struct tagRPCRet); |
if (rrpc->ret_tag != tag || rrpc->ret_hash != hash) { |
if (rrpc->ret_tag != tag || rrpc->ret_hash != hash) { |
printf("tag=%x/%x hash=%x/%x\n", rrpc->ret_tag, tag, rrpc->ret_hash, hash); |
|
rpc_SetErr(ERPCMISMATCH, "Error:: get wrong RPC reply ...\n"); |
rpc_SetErr(ERPCMISMATCH, "Error:: get wrong RPC reply ...\n"); |
free(buf); |
free(buf); |
return -5; |
return -5; |
Line 407 rpc_cli_execCall(rpc_cli_t *cli, const char *csModule,
|
Line 404 rpc_cli_execCall(rpc_cli_t *cli, const char *csModule,
|
|
|
/* RPC is OK! Go de-marshaling variables ... */ |
/* RPC is OK! Go de-marshaling variables ... */ |
if (ntohs(rrpc->ret_argc)) { |
if (ntohs(rrpc->ret_argc)) { |
*out_vars = io_buffer2vals(buf + Limit, cli->cli_netbuf - Limit, | *out_vars = io_buffer2vars(buf + Limit, cli->cli_netbuf - Limit, |
ntohs(rrpc->ret_argc), 0); |
ntohs(rrpc->ret_argc), 0); |
if (!*out_vars) { |
if (!*out_vars) { |
free(buf); |
free(buf); |
Line 418 rpc_cli_execCall(rpc_cli_t *cli, const char *csModule,
|
Line 415 rpc_cli_execCall(rpc_cli_t *cli, const char *csModule,
|
ret = ntohl(rrpc->ret_retcode); |
ret = ntohl(rrpc->ret_retcode); |
free(buf); |
free(buf); |
return ret; |
return ret; |
} |
|
|
|
/* |
|
* rpc_cli_freeVals() Free ait_val_t array returned from RPC call |
|
* @vars = Variable array |
|
* return: none |
|
*/ |
|
inline void |
|
rpc_cli_freeVals(array_t ** __restrict vars) |
|
{ |
|
register int i; |
|
|
|
if (!vars || !*vars) |
|
return; |
|
|
|
for (i = 0; i < io_arraySize(*vars); i++) |
|
if (io_arrayGet(*vars, i)) |
|
AIT_FREE_VAL(io_array(*vars, i, ait_val_t*)); |
|
|
|
io_arrayFree(*vars); |
|
io_arrayDestroy(vars); |
|
} |
|
|
|
/* |
|
* rpc_cli_allocVals() Allocate ait_val_t array for RPC call |
|
* @args = Number of arguments |
|
* return: =NULL error or !=NULL allocated array |
|
*/ |
|
inline array_t * |
|
rpc_cli_allocVals(u_short args) |
|
{ |
|
array_t *arr; |
|
register int i; |
|
ait_val_t *v; |
|
|
|
if (!args) |
|
return NULL; |
|
|
|
if (!(arr = io_arrayInit(args))) |
|
return NULL; |
|
|
|
for (i = 0; i < io_arraySize(arr); i++) { |
|
v = malloc(sizeof(ait_val_t)); |
|
if (!v) { |
|
LOGERR; |
|
rpc_cli_freeVals(&arr); |
|
return NULL; |
|
} else { |
|
memset(v, 0, sizeof(ait_val_t)); |
|
io_arraySet(arr, i, v); |
|
} |
|
} |
|
|
|
return arr; |
|
} |
} |