3 * $Id: unet.h,v 1.1 2001/01/25 22:03:39 mdw Exp $
5 * User-space network device support.
7 * (c) 1998 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Usernet.
14 * Usernet is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * Usernet is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Usernet; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.1 2001/01/25 22:03:39 mdw
33 * Initial check-in (somewhat belated).
44 /*----- What's the story? -------------------------------------------------*
46 * Based on a conversation with Clive Jones about FreeBSD's tunnel device,
47 * I've decided to try to write something similar. The basic idea is to
48 * tie together a character device and a network interface, so that anything
49 * written to one pops out the other. I create a device /dev/unet.
50 * Each open(2) of my device creates a network device, whose name can be
51 * read by calling ioctl(2). A read(2) on the device fetches the next
52 * packet received from the network interface; conversely, a write(2) sends
53 * a network packet through the interface.
55 * Permissions on /dev/unet ought to be fairly strict. Remember that
56 * anyone who can get access to it can inject arbitrary IP packets.
58 * This is my first stab at hacking Linux, so there'll be mistakes and
59 * infelicities. All I ask is that you tell me what they are.
62 * mdw@excessus.demon.co.uk
65 /*----- @ioctl@(2) calls supported ----------------------------------------*/
67 /* --- @UNIOCGINFO@ --- *
69 * Reads useful information about a unet. The argument is a pointer to a
70 * @unet_info@ structure, which is filled in by the call. As a special case,
71 * the argument may be a null pointer, in which case the call does nothing
72 * and may be used to verify that a file descriptor refers to a Usernet
76 #define UNIOCGINFO _IOR('U', 0, sizeof(struct unet_info))
78 #define UNET_NAMEMAX 20
81 char uni_ifname[UNET_NAMEMAX]; /* Interface name string */
82 unsigned short uni_mtu; /* Maximum transmission unit */
83 unsigned short uni_family; /* My address family */
84 unsigned short uni_proto; /* Protocol to stamp on packets */
85 unsigned int uni_flags; /* Various useful flags */
88 #define UNIF_TRANS 1 /* This device is transient */
89 #define UNIF_OPEN 2 /* Not useful to users */
90 #define UNIF_DEBUG 4 /* Debugging enable flag */
92 /* --- @UNIOCSDEBUG@ --- *
94 * Sets the debugging state for the attachment. When the debug flag is set,
95 * all packets sent and received by the device will be logged, as will other
99 #define UNIOCSDEBUG _IO('U', 1)
101 /* --- @UNIOCGPROTO@ --- *
103 * Reads the protocol stamped on packets received through the character
104 * device interface. The default is @ETH_P_IP@; the various values are
105 * defined in @<linux/if_ether.h>@.
108 #define UNIOCGPROTO _IO('U', 2)
110 /* --- @UNIOCSPROTO@ --- *
112 * Sets the protocol to be stamped on outgoing packets.
115 #define UNIOCSPROTO _IO('U', 3)
117 /* --- @UNIOCGGDEBUG@ --- *
119 * Gets the global debugging flag.
122 #define UNIOCGGDEBUG _IO('U', 4)
124 /* --- @UNIOCSGDEBUG@ --- *
126 * Sets the global debugging flag. This is only available when runtime
127 * debugging configuration is compiled in.
130 #define UNIOCSGDEBUG _IO('U', 5)
132 /* --- @UNIOCDUMP@ --- *
134 * Dumps a unet block's information to the debug device.
137 #define UNIOCDUMP _IO('U', 6)
139 /* --- @UNIOCGMAXIF@ --- *
141 * Returns the maximum number of interfaces allowed.
144 #define UNIOCGMAXIF _IO('U', 7)
146 /* --- @UNIOCGMAXIF@ --- *
148 * Sets the maximum number of interfaces allowed. It's an error to lower
149 * this below the number of the highest currently-used interface.
152 #define UNIOCSMAXIF _IO('U', 8)
154 /*----- That's all, folks -------------------------------------------------*/