--- libaitrpc/src/cli.c 2014/11/26 00:50:04 1.22.6.2 +++ libaitrpc/src/cli.c 2015/01/15 20:39:11 1.23.2.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.22.6.2 2014/11/26 00:50:04 misho Exp $ +* $Id: cli.c,v 1.23.2.1 2015/01/15 20:39:11 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2014 +Copyright 2004 - 2015 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -350,7 +350,11 @@ rpc_pkt_Receive(int sock, int type, sockaddr_t * __res do { if (type == SOCK_STREAM) ret = rpc_Read(sock, type, !estlen ? MSG_PEEK : 0, NULL, buf, blen); - else + 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); if (ret < 1) return ret; @@ -638,6 +642,16 @@ rpc_cli_openClient2(u_char InstID, int netBuf, const c register int i; struct ifreq ifr; 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)) return NULL; @@ -646,7 +660,7 @@ rpc_cli_openClient2(u_char InstID, int netBuf, const c return NULL; } else strlcpy(szIface, csIface, sizeof szIface); - if (e_getifacebyname(szIface, &sal)) + if (!e_getifacebyname(szIface, &sal)) return NULL; cli = e_malloc(sizeof(rpc_cli_t)); @@ -686,6 +700,10 @@ rpc_cli_openClient2(u_char InstID, int netBuf, const c } if (ioctl(cli->cli_sock, BIOCIMMEDIATE, &n) == -1) { + LOGERR; + goto err; + } + if (ioctl(cli->cli_sock, BIOCSETF, &fcode) == -1) { LOGERR; goto err; }