version 1.22.6.2, 2014/11/26 00:50:04
|
version 1.23.2.3, 2015/01/18 01:11:35
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004 - 2014 | Copyright 2004 - 2015 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 350 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
Line 350 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 | else if (type == SOCK_EXT) |
| ret = rpc_Read(sock, type, 0, NULL, buf, blen); |
| else if (type == SOCK_BPF) { |
| ret = rpc_Read(sock, type, 0, sa, AIT_GET_BUF(pkt), AIT_LEN(pkt)); |
| if (ret > 0) |
| estlen = ret; |
| } else |
ret = rpc_Read(sock, type, !estlen ? MSG_PEEK : 0, sa, buf, blen); |
ret = rpc_Read(sock, type, !estlen ? MSG_PEEK : 0, sa, buf, blen); |
if (ret < 1) |
if (ret < 1) |
return ret; |
return ret; |
Line 638 rpc_cli_openClient2(u_char InstID, int netBuf, const c
|
Line 644 rpc_cli_openClient2(u_char InstID, int netBuf, const c
|
register int i; |
register int i; |
struct ifreq ifr; |
struct ifreq ifr; |
int n = 1; |
int n = 1; |
|
struct bpf_insn insns[] = { |
|
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12), |
|
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, RPC_DEFPORT, 0, 1), |
|
BPF_STMT(BPF_RET + BPF_K, -1), |
|
BPF_STMT(BPF_RET + BPF_K, 0), |
|
}; |
|
struct bpf_program fcode = { |
|
.bf_len = sizeof(insns) / sizeof(struct bpf_insn), |
|
.bf_insns = insns |
|
}; |
|
|
if (!csHost || !e_getlinkbyname(csHost, &sa)) |
if (!csHost || !e_getlinkbyname(csHost, &sa)) |
return NULL; |
return NULL; |
Line 646 rpc_cli_openClient2(u_char InstID, int netBuf, const c
|
Line 662 rpc_cli_openClient2(u_char InstID, int netBuf, const c
|
return NULL; |
return NULL; |
} else |
} else |
strlcpy(szIface, csIface, sizeof szIface); |
strlcpy(szIface, csIface, sizeof szIface); |
if (e_getifacebyname(szIface, &sal)) | if (!e_getifacebyname(szIface, &sal)) |
return NULL; |
return NULL; |
|
|
cli = e_malloc(sizeof(rpc_cli_t)); |
cli = e_malloc(sizeof(rpc_cli_t)); |
Line 689 rpc_cli_openClient2(u_char InstID, int netBuf, const c
|
Line 705 rpc_cli_openClient2(u_char InstID, int netBuf, const c
|
LOGERR; |
LOGERR; |
goto err; |
goto err; |
} |
} |
|
if (ioctl(cli->cli_sock, BIOCSETF, &fcode) == -1) { |
|
LOGERR; |
|
goto err; |
|
} |
n = (netBuf < RPC_MIN_BUFSIZ) ? getpagesize() : E_ALIGN(netBuf, 2); |
n = (netBuf < RPC_MIN_BUFSIZ) ? getpagesize() : E_ALIGN(netBuf, 2); |
if (ioctl(cli->cli_sock, BIOCSBLEN, &n) == -1) { |
if (ioctl(cli->cli_sock, BIOCSBLEN, &n) == -1) { |
LOGERR; |
LOGERR; |
Line 728 rpc_cli_closeClient2(rpc_cli_t ** __restrict cli)
|
Line 748 rpc_cli_closeClient2(rpc_cli_t ** __restrict cli)
|
return; |
return; |
|
|
close((*cli)->cli_sock); |
close((*cli)->cli_sock); |
|
|
|
AIT_FREE_VAL(&(*cli)->cli_buf); |
|
|
|
if ((*cli)->cli_parent) |
|
e_free((*cli)->cli_parent); |
|
|
|
e_free(*cli); |
|
*cli = NULL; |
|
} |
|
|
|
/* |
|
* rpc_cli_openClientExt() - Connect to pipe RPC Server |
|
* |
|
* @InstID = InstID for RPC session request |
|
* @netBuf = Network buffer length (min:512 bytes), if =0 == BUFSIZ (also meaning max RPC packet) |
|
* @fd = File descriptor |
|
* return: NULL == error or !=NULL connection to RPC server established |
|
*/ |
|
rpc_cli_t * |
|
rpc_cli_openClientExt(u_char InstID, int netBuf, int fd) |
|
{ |
|
rpc_cli_t *cli = NULL; |
|
int n; |
|
|
|
cli = e_malloc(sizeof(rpc_cli_t)); |
|
if (!cli) { |
|
LOGERR; |
|
return NULL; |
|
} else |
|
memset(cli, 0, sizeof(rpc_cli_t)); |
|
|
|
/* build session */ |
|
cli->cli_parent = e_malloc(sizeof(rpc_sess_t)); |
|
if (!cli->cli_parent) { |
|
LOGERR; |
|
e_free(cli); |
|
return NULL; |
|
} else { |
|
((rpc_sess_t*) cli->cli_parent)->sess_version = RPC_VERSION; |
|
((rpc_sess_t*) cli->cli_parent)->sess_instance = InstID; |
|
} |
|
|
|
cli->cli_id = SOCK_EXT; |
|
cli->cli_sock = fd; |
|
|
|
n = (netBuf < RPC_MIN_BUFSIZ) ? getpagesize() : E_ALIGN(netBuf, 2); |
|
AIT_SET_BUFSIZ(&cli->cli_buf, 0, n); |
|
|
|
fcntl(cli->cli_sock, F_SETFL, |
|
fcntl(cli->cli_sock, F_GETFL) | O_NONBLOCK); |
|
|
|
return cli; |
|
} |
|
|
|
/* |
|
* rpc_cli_closeClientExt() - Close pipe connection to RPC server and free resources |
|
* |
|
* @cli = RPC Client session |
|
* return: none |
|
*/ |
|
void |
|
rpc_cli_closeClientExt(rpc_cli_t ** __restrict cli) |
|
{ |
|
if (!cli || !*cli || (*cli)->cli_id != SOCK_EXT) |
|
return; |
|
|
AIT_FREE_VAL(&(*cli)->cli_buf); |
AIT_FREE_VAL(&(*cli)->cli_buf); |
|
|