Module Name:    src
Committed By:   pooka
Date:           Tue Jan 26 17:41:20 UTC 2010

Modified Files:
        src/sys/rump/net/lib/libsockin: sockin.c

Log Message:
support bpf


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/rump/net/lib/libsockin/sockin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/net/lib/libsockin/sockin.c
diff -u src/sys/rump/net/lib/libsockin/sockin.c:1.20 src/sys/rump/net/lib/libsockin/sockin.c:1.21
--- src/sys/rump/net/lib/libsockin/sockin.c:1.20	Tue Oct 20 12:17:44 2009
+++ src/sys/rump/net/lib/libsockin/sockin.c	Tue Jan 26 17:41:20 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sockin.c,v 1.20 2009/10/20 12:17:44 tron Exp $	*/
+/*	$NetBSD: sockin.c,v 1.21 2010/01/26 17:41:20 pooka Exp $	*/
 
 /*
  * Copyright (c) 2008, 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.20 2009/10/20 12:17:44 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.21 2010/01/26 17:41:20 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/condvar.h>
@@ -42,6 +42,8 @@
 #include <sys/socketvar.h>
 #include <sys/time.h>
 
+#include <net/bpf.h>
+#include <net/if.h>
 #include <net/radix.h>
 
 #include <netinet/in.h>
@@ -116,6 +118,10 @@
 static bool rebuild;
 static int nsock;
 
+/* XXX: for the bpf hack */
+static struct ifnet sockin_if;
+int ifpromisc(struct ifnet *ifp, int pswitch) { return 0; }
+
 static int
 registersock(struct socket *so, int news)
 {
@@ -207,6 +213,9 @@
 	}
 	m->m_len = m->m_pkthdr.len = n;
 
+	if (sockin_if.if_bpf)
+		bpf_ops->bpf_mtap_af(sockin_if.if_bpf, AF_UNSPEC, m);
+
 	mutex_enter(softnet_lock);
 	if (so->so_proto->pr_type == SOCK_DGRAM) {
 		if (!sbappendaddr(&so->so_rcv, rmsg.msg_name, m, NULL)) {
@@ -340,6 +349,8 @@
 		printf("sockin_init: no threads => no worker thread\n");
 	}
 	mutex_init(&su_mtx, MUTEX_DEFAULT, IPL_NONE);
+	strlcpy(sockin_if.if_xname, "sockin0", sizeof(sockin_if.if_xname));
+	bpf_ops->bpf_attach(&sockin_if, DLT_NULL, 0, &sockin_if.if_bpf);
 }
 
 static int
@@ -413,6 +424,9 @@
 		size_t tot;
 		int s;
 
+		if (sockin_if.if_bpf)
+			bpf_ops->bpf_mtap_af(sockin_if.if_bpf, AF_UNSPEC, m);
+
 		memset(&mhdr, 0, sizeof(mhdr));
 
 		iov_max = 0;

Reply via email to