if_tun.c (69781) | if_tun.c (71862) |
---|---|
1/* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $ */ 2 3/* 4 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk> 5 * Nottingham University 1987. 6 * 7 * This source may be freely distributed, however I would be interested 8 * in any changes that are made. 9 * 10 * This driver takes packets off the IP i/f and hands them up to a 11 * user process to have its wicked way with. This driver has it's 12 * roots in a similar driver written by Phil Cockcroft (formerly) at 13 * UCL. This driver is based much more on read/write/poll mode of 14 * operation though. 15 * | 1/* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $ */ 2 3/* 4 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk> 5 * Nottingham University 1987. 6 * 7 * This source may be freely distributed, however I would be interested 8 * in any changes that are made. 9 * 10 * This driver takes packets off the IP i/f and hands them up to a 11 * user process to have its wicked way with. This driver has it's 12 * roots in a similar driver written by Phil Cockcroft (formerly) at 13 * UCL. This driver is based much more on read/write/poll mode of 14 * operation though. 15 * |
16 * $FreeBSD: head/sys/net/if_tun.c 69781 2000-12-08 21:51:06Z dwmalone $ | 16 * $FreeBSD: head/sys/net/if_tun.c 71862 2001-01-31 07:58:58Z peter $ |
17 */ 18 19#include "opt_inet.h" 20 21#include <sys/param.h> 22#include <sys/proc.h> 23#include <sys/systm.h> 24#include <sys/mbuf.h> | 17 */ 18 19#include "opt_inet.h" 20 21#include <sys/param.h> 22#include <sys/proc.h> 23#include <sys/systm.h> 24#include <sys/mbuf.h> |
25#include <sys/module.h> |
|
25#include <sys/socket.h> 26#include <sys/filio.h> 27#include <sys/sockio.h> 28#include <sys/ttycom.h> 29#include <sys/poll.h> 30#include <sys/signalvar.h> 31#include <sys/filedesc.h> 32#include <sys/kernel.h> --- 14 unchanged lines hidden (view full) --- 47 48#include <net/bpf.h> 49 50#include <net/if_tunvar.h> 51#include <net/if_tun.h> 52 53static MALLOC_DEFINE(M_TUN, "tun", "Tunnel Interface"); 54 | 26#include <sys/socket.h> 27#include <sys/filio.h> 28#include <sys/sockio.h> 29#include <sys/ttycom.h> 30#include <sys/poll.h> 31#include <sys/signalvar.h> 32#include <sys/filedesc.h> 33#include <sys/kernel.h> --- 14 unchanged lines hidden (view full) --- 48 49#include <net/bpf.h> 50 51#include <net/if_tunvar.h> 52#include <net/if_tun.h> 53 54static MALLOC_DEFINE(M_TUN, "tun", "Tunnel Interface"); 55 |
55static void tunattach __P((void *)); 56PSEUDO_SET(tunattach, if_tun); 57 | |
58static void tuncreate __P((dev_t dev)); 59 60#define TUNDEBUG if (tundebug) printf 61static int tundebug = 0; 62SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, ""); 63 64static int tunoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, 65 struct rtentry *rt)); --- 42 unchanged lines hidden (view full) --- 108 if (dev_stdclone(name, NULL, "tun", &u) != 1) 109 return; 110 /* XXX: minor encoding if u > 255 */ 111 *dev = make_dev(&tun_cdevsw, u, 112 UID_UUCP, GID_DIALER, 0600, "tun%d", u); 113 114} 115 | 56static void tuncreate __P((dev_t dev)); 57 58#define TUNDEBUG if (tundebug) printf 59static int tundebug = 0; 60SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, ""); 61 62static int tunoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, 63 struct rtentry *rt)); --- 42 unchanged lines hidden (view full) --- 106 if (dev_stdclone(name, NULL, "tun", &u) != 1) 107 return; 108 /* XXX: minor encoding if u > 255 */ 109 *dev = make_dev(&tun_cdevsw, u, 110 UID_UUCP, GID_DIALER, 0600, "tun%d", u); 111 112} 113 |
116static void 117tunattach(dummy) 118 void *dummy; 119{ | 114static int 115tun_modevent(module_t mod, int type, void *data) 116{ 117 switch (type) { 118 case MOD_LOAD: 119 EVENTHANDLER_REGISTER(dev_clone, tun_clone, 0, 1000); 120 cdevsw_add(&tun_cdevsw); 121 break; 122 case MOD_UNLOAD: 123 printf("if_tun module unload - not possible for this module type\n"); 124 return EINVAL; 125 } 126 return 0; 127} |
120 | 128 |
121 EVENTHANDLER_REGISTER(dev_clone, tun_clone, 0, 1000); 122 cdevsw_add(&tun_cdevsw); 123} | 129static moduledata_t tun_mod = { 130 "if_tun", 131 tun_modevent, 132 0 133}; |
124 | 134 |
135DECLARE_MODULE(if_tun, tun_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); 136 |
|
125static void 126tunstart(ifp) 127 struct ifnet *ifp; 128{ 129 struct tun_softc *tp = ifp->if_softc; 130 131 if (tp->tun_flags & TUN_RWAIT) { 132 tp->tun_flags &= ~TUN_RWAIT; --- 611 unchanged lines hidden --- | 137static void 138tunstart(ifp) 139 struct ifnet *ifp; 140{ 141 struct tun_softc *tp = ifp->if_softc; 142 143 if (tp->tun_flags & TUN_RWAIT) { 144 tp->tun_flags &= ~TUN_RWAIT; --- 611 unchanged lines hidden --- |