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 111568 2003-02-26 20:20:58Z phk $
17 */
18
19#include "opt_inet.h"
20#include "opt_mac.h"
21
22#include <sys/param.h>
23#include <sys/proc.h>
24#include <sys/systm.h>
--- 646 unchanged lines hidden (view full) ---
671 }
672 }
673 } while (m == NULL);
674 splx(s);
675
676 while (m && uio->uio_resid > 0 && error == 0) {
677 len = min(uio->uio_resid, m->m_len);
678 if (len != 0)
679 error = uiomove(mtod(m, caddr_t), len, uio);
680 m = m_free(m);
681 }
682
683 if (m) {
684 TUNDEBUG("%s%d: Dropping mbuf\n", ifp->if_name, ifp->if_unit);
685 m_freem(m);
686 }
687 return (error);
--- 32 unchanged lines hidden (view full) ---
720 if (m == NULL)
721 return (ENOBUFS);
722 mlen = MHLEN;
723
724 top = 0;
725 mp = ⊤
726 while (error == 0 && uio->uio_resid > 0) {
727 m->m_len = min(mlen, uio->uio_resid);
728 error = uiomove(mtod (m, caddr_t), m->m_len, uio);
729 *mp = m;
730 mp = &m->m_next;
731 if (uio->uio_resid > 0) {
732 MGET (m, M_DONTWAIT, MT_DATA);
733 if (m == 0) {
734 error = ENOBUFS;
735 break;
736 }
--- 97 unchanged lines hidden ---
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 111568 2003-02-26 20:20:58Z phk $
17 */
18
19#include "opt_inet.h"
20#include "opt_mac.h"
21
22#include <sys/param.h>
23#include <sys/proc.h>
24#include <sys/systm.h>
--- 646 unchanged lines hidden (view full) ---
671 }
672 }
673 } while (m == NULL);
674 splx(s);
675
676 while (m && uio->uio_resid > 0 && error == 0) {
677 len = min(uio->uio_resid, m->m_len);
678 if (len != 0)
679 error = uiomove(mtod(m, caddr_t), len, uio);
680 m = m_free(m);
681 }
682
683 if (m) {
684 TUNDEBUG("%s%d: Dropping mbuf\n", ifp->if_name, ifp->if_unit);
685 m_freem(m);
686 }
687 return (error);
--- 32 unchanged lines hidden (view full) ---
720 if (m == NULL)
721 return (ENOBUFS);
722 mlen = MHLEN;
723
724 top = 0;
725 mp = ⊤
726 while (error == 0 && uio->uio_resid > 0) {
727 m->m_len = min(mlen, uio->uio_resid);
728 error = uiomove(mtod (m, caddr_t), m->m_len, uio);
729 *mp = m;
730 mp = &m->m_next;
731 if (uio->uio_resid > 0) {
732 MGET (m, M_DONTWAIT, MT_DATA);
733 if (m == 0) {
734 error = ENOBUFS;
735 break;
736 }
--- 97 unchanged lines hidden ---