Implement TUNSIFMODE and TUNSLMODE.
Submitted by: Alfred Perlstein <bright@cygnus.rush.net>
This commit is contained in:
parent
16fa182f0f
commit
c42abfb1fe
@ -338,7 +338,24 @@ tunoutput(ifp, m0, dst, rt)
|
|||||||
|
|
||||||
bpf_mtap(ifp, &m);
|
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) {
|
switch(dst->sa_family) {
|
||||||
#ifdef INET
|
#ifdef INET
|
||||||
@ -406,6 +423,30 @@ tunioctl(dev, cmd, data, flag, p)
|
|||||||
case TUNGDEBUG:
|
case TUNGDEBUG:
|
||||||
*(int *)data = tundebug;
|
*(int *)data = tundebug;
|
||||||
break;
|
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:
|
case FIONBIO:
|
||||||
break;
|
break;
|
||||||
case FIOASYNC:
|
case FIOASYNC:
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* UCL. This driver is based much more on read/write/select mode of
|
* UCL. This driver is based much more on read/write/select mode of
|
||||||
* operation though.
|
* 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_
|
#ifndef _NET_IF_TUN_H_
|
||||||
@ -39,5 +39,7 @@ struct tuninfo {
|
|||||||
#define TUNGDEBUG _IOR('t', 89, int)
|
#define TUNGDEBUG _IOR('t', 89, int)
|
||||||
#define TUNSIFINFO _IOW('t', 91, struct tuninfo)
|
#define TUNSIFINFO _IOW('t', 91, struct tuninfo)
|
||||||
#define TUNGIFINFO _IOR('t', 92, 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_ */
|
#endif /* !_NET_IF_TUN_H_ */
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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_
|
#ifndef _NET_IF_TUNVAR_H_
|
||||||
@ -36,6 +36,7 @@ struct tun_softc {
|
|||||||
#define TUN_RCOLL 0x0004
|
#define TUN_RCOLL 0x0004
|
||||||
#define TUN_IASET 0x0008
|
#define TUN_IASET 0x0008
|
||||||
#define TUN_DSTADDR 0x0010
|
#define TUN_DSTADDR 0x0010
|
||||||
|
#define TUN_LMODE 0x0020
|
||||||
#define TUN_RWAIT 0x0040
|
#define TUN_RWAIT 0x0040
|
||||||
#define TUN_ASYNC 0x0080
|
#define TUN_ASYNC 0x0080
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user