aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-snoop.c
diff options
context:
space:
mode:
authorguy <guy>2004-03-23 19:18:04 +0000
committerguy <guy>2004-03-23 19:18:04 +0000
commit2d2890dd3774c9b1f90828f41d06e4998191d2f7 (patch)
treeff0fffc64592d13d9a4a364b9fb2ca051f28d686 /pcap-snoop.c
parent3380fa10dbcb28d2c58ba852f1539ef67f3bbcca (diff)
Add support for sending packets; includes contributions from Mark
Pizzolato <List-tcpdump-workers@subscriptions.pizzolato.net>.
Diffstat (limited to 'pcap-snoop.c')
-rw-r--r--pcap-snoop.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/pcap-snoop.c b/pcap-snoop.c
index d847444..288ae70 100644
--- a/pcap-snoop.c
+++ b/pcap-snoop.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.51 2004-03-21 08:32:06 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.52 2004-03-23 19:18:06 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -126,6 +126,22 @@ again:
}
static int
+pcap_inject_snoop(pcap_t *p, const void *buf, size_t size)
+{
+ /*
+ * XXX - libnet overwrites the source address with what I
+ * presume is the interface's address; is that required?
+ */
+ ret = write(p->fd, buf, size);
+ if (ret == -1) {
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
+ pcap_strerror(errno));
+ return (-1);
+ }
+ return (ret);
+}
+
+static int
pcap_stats_snoop(pcap_t *p, struct pcap_stat *ps)
{
register struct rawstats *rs;
@@ -358,6 +374,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
p->selectable_fd = p->fd;
p->read_op = pcap_read_snoop;
+ p->inject_op = pcap_inject_snoop;
p->setfilter_op = install_bpf_program; /* no kernel filtering */
p->set_datalink_op = NULL; /* can't change data link type */
p->getnonblock_op = pcap_getnonblock_fd;