summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>1999-03-24 21:20:12 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>1999-03-24 21:20:12 +0000
commitb56fecc80b328030a7f5992dad77a842921d9263 (patch)
treecba1e991246ab2e1138783cf32edacd41ab94087 /sys/net
parent902cb50a7682cfc8023aed15fbf226b850126a8c (diff)
Notes
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_tun.c43
-rw-r--r--sys/net/if_tun.h4
-rw-r--r--sys/net/if_tunvar.h3
3 files changed, 47 insertions, 3 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index c395ee3ae1ac..e9725bc35dce 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -338,7 +338,24 @@ tunoutput(ifp, m0, dst, rt)
bpf_mtap(ifp, &m);
}
-#endif
+#endif /* NBPFILTER > 0 */
+
+ /* prepend sockaddr? this may abort if the mbuf allocation fails */
+ if (tp->tun_flags & TUN_LMODE) {
+ /* allocate space for sockaddr */
+ M_PREPEND(m0, dst->sa_len, M_DONTWAIT);
+
+ /* if allocation failed drop packet */
+ if (m0 == NULL){
+ s = splimp(); /* spl on queue manipulation */
+ IF_DROP(&ifp->if_snd);
+ splx(s);
+ ifp->if_oerrors++;
+ return (ENOBUFS);
+ } else {
+ bcopy(dst, m0->m_data, dst->sa_len);
+ }
+ }
switch(dst->sa_family) {
#ifdef INET
@@ -406,6 +423,30 @@ tunioctl(dev, cmd, data, flag, p)
case TUNGDEBUG:
*(int *)data = tundebug;
break;
+ case TUNSLMODE:
+ if (*(int *)data)
+ tp->tun_flags |= TUN_LMODE;
+ else
+ tp->tun_flags &= ~TUN_LMODE;
+ break;
+ case TUNSIFMODE:
+ /* deny this if UP */
+ if (tp->tun_if.if_flags & IFF_UP)
+ return(EBUSY);
+
+ switch (*(int *)data) {
+ case IFF_POINTOPOINT:
+ tp->tun_if.if_flags |= IFF_POINTOPOINT;
+ tp->tun_if.if_flags &= ~IFF_BROADCAST;
+ break;
+ case IFF_BROADCAST:
+ tp->tun_if.if_flags &= ~IFF_POINTOPOINT;
+ tp->tun_if.if_flags |= IFF_BROADCAST;
+ break;
+ default:
+ return(EINVAL);
+ }
+ break;
case FIONBIO:
break;
case FIOASYNC:
diff --git a/sys/net/if_tun.h b/sys/net/if_tun.h
index 31730858e052..1a1fa6461954 100644
--- a/sys/net/if_tun.h
+++ b/sys/net/if_tun.h
@@ -13,7 +13,7 @@
* UCL. This driver is based much more on read/write/select mode of
* operation though.
*
- * $Id: if_tun.h,v 1.12 1998/01/26 19:52:34 brian Exp $
+ * $Id: if_tun.h,v 1.13 1998/04/17 22:36:56 des Exp $
*/
#ifndef _NET_IF_TUN_H_
@@ -39,5 +39,7 @@ struct tuninfo {
#define TUNGDEBUG _IOR('t', 89, int)
#define TUNSIFINFO _IOW('t', 91, struct tuninfo)
#define TUNGIFINFO _IOR('t', 92, struct tuninfo)
+#define TUNSLMODE _IOW('t', 93, int)
+#define TUNSIFMODE _IOW('t', 94, int)
#endif /* !_NET_IF_TUN_H_ */
diff --git a/sys/net/if_tunvar.h b/sys/net/if_tunvar.h
index 9e537d3abef8..496c4fb7c97a 100644
--- a/sys/net/if_tunvar.h
+++ b/sys/net/if_tunvar.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: if_tunvar.h,v 1.2 1998/11/11 10:04:10 truckman Exp $
+ * $Id: if_tunvar.h,v 1.3 1998/11/11 10:56:05 truckman Exp $
*/
#ifndef _NET_IF_TUNVAR_H_
@@ -36,6 +36,7 @@ struct tun_softc {
#define TUN_RCOLL 0x0004
#define TUN_IASET 0x0008
#define TUN_DSTADDR 0x0010
+#define TUN_LMODE 0x0020
#define TUN_RWAIT 0x0040
#define TUN_ASYNC 0x0080