Add a simplified pcap_inject() from libpcap-0.9.3.

Required for wpa_supplicant and hostapd tools.
This commit is contained in:
scw 2005-10-01 09:55:00 +00:00
parent 17269a9baf
commit f552876f7c
4 changed files with 42 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcap-bpf.c,v 1.14 2005/06/10 19:00:09 dyoung Exp $ */
/* $NetBSD: pcap-bpf.c,v 1.15 2005/10/01 09:55:00 scw Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1998
@ -26,7 +26,7 @@
static const char rcsid[] =
"@(#) Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.67.2.4 2003/11/22 00:06:28 guy Exp (LBL)";
#else
__RCSID("$NetBSD: pcap-bpf.c,v 1.14 2005/06/10 19:00:09 dyoung Exp $");
__RCSID("$NetBSD: pcap-bpf.c,v 1.15 2005/10/01 09:55:00 scw Exp $");
#endif
#endif
@ -302,6 +302,24 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
return (n);
}
/*
* XXXSCW: Temporary addition for the benefit of wpa_supplicant and hostapd,
* until libpcap >= 0.9.3 is imported.
*/
static int
pcap_inject_bpf(pcap_t *p, const void *buf, size_t size)
{
int ret;
ret = write(p->fd, buf, size);
if (ret == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
pcap_strerror(errno));
return (-1);
}
return (ret);
}
#ifdef _AIX
static int
bpf_odminit(char *errbuf)
@ -856,6 +874,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
}
p->read_op = pcap_read_bpf;
p->inject_op = pcap_inject_bpf;
p->setfilter_op = pcap_setfilter_bpf;
p->set_datalink_op = pcap_set_datalink_bpf;
p->getnonblock_op = pcap_getnonblock_fd;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcap-int.h,v 1.10 2004/09/27 23:02:53 dyoung Exp $ */
/* $NetBSD: pcap-int.h,v 1.11 2005/10/01 09:55:01 scw Exp $ */
/*
* Copyright (c) 1994, 1995, 1996
@ -132,6 +132,7 @@ struct pcap {
* Methods.
*/
int (*read_op)(pcap_t *, int cnt, pcap_handler, u_char *);
int (*inject_op)(pcap_t *, const void *buf, size_t);
int (*setfilter_op)(pcap_t *, struct bpf_program *);
int (*set_datalink_op)(pcap_t *, int);
int (*getnonblock_op)(pcap_t *, char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcap.c,v 1.10 2004/09/27 23:02:53 dyoung Exp $ */
/* $NetBSD: pcap.c,v 1.11 2005/10/01 09:55:00 scw Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998
@ -39,7 +39,7 @@
static const char rcsid[] =
"@(#) Header: /tcpdump/master/libpcap/pcap.c,v 1.63.2.9 2004/03/25 22:40:52 guy Exp (LBL)";
#else
__RCSID("$NetBSD: pcap.c,v 1.10 2004/09/27 23:02:53 dyoung Exp $");
__RCSID("$NetBSD: pcap.c,v 1.11 2005/10/01 09:55:00 scw Exp $");
#endif
#endif
@ -777,3 +777,13 @@ pcap_lib_version(void)
return (pcap_version_string);
}
#endif
/*
* XXXSCW: Temporary addition for the benefit of wpa_supplicant and hostapd,
* until libpcap >= 0.9.3 is imported.
*/
int
pcap_inject(pcap_t *p, const void *buf, size_t size)
{
return (p->inject_op(p, buf, size));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcap.h,v 1.11 2004/09/27 23:02:53 dyoung Exp $ */
/* $NetBSD: pcap.h,v 1.12 2005/10/01 09:55:00 scw Exp $ */
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
@ -226,6 +226,12 @@ int bpf_validate(struct bpf_insn *f, int len);
char *bpf_image(struct bpf_insn *, int);
void bpf_dump(struct bpf_program *, int);
/*
* XXXSCW: Temporary addition for the benefit of wpa_supplicant and hostapd,
* until libpcap >= 0.9.3 is imported.
*/
int pcap_inject(pcap_t *, const void *, size_t);
#ifdef WIN32
/*
* Win32 definitions