* copy vendor drop to trunk
[lab.git] / Dev / utvpn / utvpn-unix-v101-7101-public / src / Mayaqua / TunTap.h
1 // SoftEther UT-VPN SourceCode\r
2 // \r
3 // Copyright (C) 2004-2010 SoftEther Corporation.\r
4 // Copyright (C) 2004-2010 University of Tsukuba, Japan.\r
5 // Copyright (C) 2003-2010 Daiyuu Nobori.\r
6 // All Rights Reserved.\r
7 // \r
8 // http://utvpn.tsukuba.ac.jp/\r
9 // \r
10 // This program is free software; you can redistribute it and/or\r
11 // modify it under the terms of the GNU General Public License\r
12 // version 2 as published by the Free Software Foundation.\r
13 // \r
14 // This program is distributed in the hope that it will be useful,\r
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
17 // GNU General Public License for more details.\r
18 // \r
19 // You should have received a copy of the GNU General Public License version 2\r
20 // along with this program; if not, write to the Free Software\r
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
22 // \r
23 // このファイルは GPL バージョン 2 ライセンスで公開されています。\r
24 // 誰でもこのファイルの内容を複製、改変したり、改変したバージョンを再配布\r
25 // することができます。ただし、原著作物を改変した場合は、原著作物の著作権表示\r
26 // を除去することはできません。改変した著作物を配布する場合は、改変実施者の\r
27 // 著作権表示を原著作物の著作権表示に付随して記載するようにしてください。\r
28 // \r
29 // この SoftEther UT-VPN オープンソース・プロジェクトは、日本国の\r
30 // ソフトイーサ株式会社 (SoftEther Corporation, http://www.softether.co.jp/ )\r
31 // および筑波大学 (University of Tsukuba, http://www.tsukuba.ac.jp/ ) によって\r
32 // ホストされています。\r
33 // 本プログラムの配布者は、本プログラムを、業としての利用以外のため、\r
34 // および、試験または研究のために利用が行われることを想定して配布\r
35 // しています。\r
36 // SoftEther UT-VPN プロジェクトの Web サイトは http://utvpn.tsukuba.ac.jp/ に\r
37 // あります。\r
38 // 本ソフトウェアの不具合の修正、機能改良、セキュリティホールの修復などのコード\r
39 // の改変を行った場合で、その成果物を SoftEther UT-VPN プロジェクトに提出して\r
40 // いただける場合は、 http://utvpn.tsukuba.ac.jp/ までソースコードを送付して\r
41 // ください。SoftEther UT-VPN プロジェクトの本体リリースまたはブランチリリース\r
42 // に組み込みさせていただきます。\r
43 // \r
44 // GPL に基づいて原著作物が提供される本ソフトウェアの改良版を配布、販売する\r
45 // 場合は、そのソースコードを GPL に基づいて誰にでも開示する義務が生じます。\r
46 // \r
47 // 本ソフトウェアに関連する著作権、特許権、商標権はソフトイーサ株式会社\r
48 // (SoftEther Corporation) およびその他の著作権保持者が保有しています。\r
49 // ソフトイーサ株式会社等はこれらの権利を放棄していません。本ソフトウェアの\r
50 // 二次著作物を配布、販売する場合は、これらの権利を侵害しないようにご注意\r
51 // ください。\r
52 // \r
53 // お願い: どのような通信ソフトウェアにも通常は必ず未発見の\r
54 // セキュリティホールが潜んでいます。本ソースコードをご覧いただいた結果、\r
55 // UT-VPN にセキュリティホールを発見された場合は、当該セキュリティホールの\r
56 // 情報を不特定多数に開示される前に、必ず、ソフトイーサ株式会社\r
57 // および脆弱性情報の届出を受け付ける公的機関まで通報いただき、\r
58 // 公益保護にご協力いただきますようお願い申し上げます。\r
59 // \r
60 // ソフトイーサ株式会社は、当該セキュリティホールについて迅速に対処を\r
61 // 行い、UT-VPN および UT-VPN に関連するソフトウェアのユーザー・顧客\r
62 // を保護するための努力を行います。\r
63 // \r
64 // ソフトイーサへの届出先: http://www.softether.co.jp/jp/contact/\r
65 // 日本国内の脆弱性情報届出受付公的機関:\r
66 //         独立行政法人 情報処理推進機構\r
67 //         http://www.ipa.go.jp/security/vuln/report/\r
68 // \r
69 // 上記各事項について不明な点は、ソフトイーサ株式会社までご連絡ください。\r
70 // 連絡先: http://www.softether.co.jp/jp/contact/\r
71 \r
72 // -----------------------------------------------\r
73 // [ChangeLog]\r
74 // 2010.05.20\r
75 //  新規リリース by SoftEther\r
76 // -----------------------------------------------\r
77 \r
78 #ifndef TUNTAP_H\r
79 #define TUNTAP_H\r
80 \r
81 #ifdef  UNIX_LINUX\r
82 \r
83 // -----------------------------------------------------------------\r
84 // Linux 用 tap ヘッダ\r
85 // -----------------------------------------------------------------\r
86 /*\r
87  *  Universal TUN/TAP device driver.\r
88  *  Copyright (C) 1999-2000 Maxim Krasnyansky <max_mk@yahoo.com>\r
89  *\r
90  *  This program is free software; you can redistribute it and/or modify\r
91  *  it under the terms of the GNU General Public License as published by\r
92  *  the Free Software Foundation; either version 2 of the License, or\r
93  *  (at your option) any later version.\r
94  *\r
95  *  This program is distributed in the hope that it will be useful,\r
96  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
97  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
98  *  GNU General Public License for more details.\r
99  *\r
100  *  $Id: if_tun.h,v 1.2 2001/10/31 15:27:57 arjanv Exp $\r
101  */\r
102 \r
103 #ifndef __IF_TUN_H\r
104 #define __IF_TUN_H\r
105 \r
106 /* Uncomment to enable debugging */\r
107 /* #define TUN_DEBUG 1 */\r
108 \r
109 \r
110 \r
111 /* Read queue size */\r
112 #define TUN_READQ_SIZE  10\r
113 \r
114 /* TUN device flags */\r
115 #define TUN_TUN_DEV     0x0001  \r
116 #define TUN_TAP_DEV     0x0002\r
117 #define TUN_TYPE_MASK   0x000f\r
118 \r
119 #define TUN_FASYNC      0x0010\r
120 #define TUN_NOCHECKSUM  0x0020\r
121 #define TUN_NO_PI       0x0040\r
122 #define TUN_ONE_QUEUE   0x0080\r
123 #define TUN_PERSIST     0x0100  \r
124 \r
125 /* Ioctl defines */\r
126 #define TUNSETNOCSUM  _IOW('T', 200, int) \r
127 #define TUNSETDEBUG   _IOW('T', 201, int) \r
128 #define TUNSETIFF     _IOW('T', 202, int) \r
129 #define TUNSETPERSIST _IOW('T', 203, int) \r
130 #define TUNSETOWNER   _IOW('T', 204, int)\r
131 \r
132 /* TUNSETIFF ifr flags */\r
133 #define IFF_TUN         0x0001\r
134 #define IFF_TAP         0x0002\r
135 #define IFF_NO_PI       0x1000\r
136 #define IFF_ONE_QUEUE   0x2000\r
137 \r
138 struct tun_pi {\r
139         unsigned short flags;\r
140         unsigned short proto;\r
141 };\r
142 #define TUN_PKT_STRIP   0x0001\r
143 \r
144 #endif /* __IF_TUN_H */\r
145 #else   // UNIX_LINUX\r
146 \r
147 #ifdef  UNIX_SOLARIS\r
148 \r
149 // -----------------------------------------------------------------\r
150 // Solaris 用 tap ヘッダ\r
151 // -----------------------------------------------------------------\r
152 /*\r
153  *  Universal TUN/TAP device driver.\r
154  *\r
155  *  Multithreaded STREAMS tun pseudo device driver.\r
156  *\r
157  *  Copyright (C) 1999-2000 Maxim Krasnyansky <max_mk@yahoo.com>\r
158  *  \r
159  *  This program is free software; you can redistribute it and/or modify\r
160  *  it under the terms of the GNU General Public License as published by\r
161  *  the Free Software Foundation; either version 2 of the License, or\r
162  *  (at your option) any later version.\r
163  *  \r
164  *  This program is distributed in the hope that it will be useful,\r
165  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
166  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
167  *  GNU General Public License for more details.\r
168  *\r
169  *  $Id: if_tun.h,v 1.4 2000/05/01 12:23:27 maxk Exp $\r
170  */\r
171 \r
172 #ifndef _SYS_IF_TUN_H\r
173 #define _SYS_IF_TUN_H\r
174 \r
175 #ifdef _KERNEL\r
176 /* Uncomment to enable debuging */\r
177 /* #define TUN_DEBUG 1 */\r
178 \r
179 #ifdef TUN_DEBUG\r
180 #define DBG      cmn_err\r
181 #else\r
182 #define DBG( a... )\r
183 #endif\r
184 \r
185 /* PPA structure, one per TUN iface */ \r
186 struct tunppa {\r
187   unsigned int id;              /* Iface number         */\r
188   queue_t *rq;                  /* Control Stream RQ    */\r
189   struct tunstr * p_str;        /* Protocol Streams     */\r
190 }; \r
191 #define TUNMAXPPA       20\r
192 \r
193 /* Stream structure, one per Stream */\r
194 struct tunstr {\r
195   struct tunstr *s_next;        /* next in streams list */\r
196   struct tunstr *p_next;        /* next in ppa list */\r
197   queue_t *rq;                  /* pointer to rq */\r
198 \r
199   struct tunppa *ppa;           /* assigned PPA */\r
200   u_long flags;                 /* flags */\r
201   u_long state;                 /* DL state */\r
202   u_long sap;                   /* bound sap */\r
203   u_long minor;                 /* minor device number */\r
204 };\r
205 \r
206 /* Flags */\r
207 #define TUN_CONTROL     0x0001\r
208 \r
209 #define TUN_RAW         0x0100\r
210 #define TUN_FAST        0x0200\r
211 \r
212 #define TUN_ALL_PHY     0x0010\r
213 #define TUN_ALL_SAP     0x0020\r
214 #define TUN_ALL_MUL     0x0040\r
215 \r
216 #define SNIFFER(a) ( (a & TUN_ALL_SAP) || (a & TUN_ALL_PHY) )\r
217 \r
218 struct tundladdr {\r
219   u_short sap;\r
220 };\r
221 #define TUN_ADDR_LEN    (sizeof(struct tundladdr))\r
222 \r
223 #define TUN_QUEUE       0\r
224 #define TUN_DROP        1\r
225 \r
226 #endif /* _KERNEL */\r
227 \r
228 /* IOCTL defines */\r
229 #define TUNNEWPPA       (('T'<<16) | 0x0001)\r
230 #define TUNSETPPA       (('T'<<16) | 0x0002)\r
231 \r
232 #endif  /* _SYS_IF_TUN_H */\r
233 \r
234 #else   // UNIX_SOLARIS\r
235 \r
236 #ifdef  UNIX_BSD\r
237 \r
238 // -----------------------------------------------------------------\r
239 // FreeBSD 用 tap ヘッダ\r
240 // -----------------------------------------------------------------\r
241 /*      $NetBSD: if_tun.h,v 1.5 1994/06/29 06:36:27 cgd Exp $   */\r
242 \r
243 /*\r
244  * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>\r
245  * Nottingham University 1987.\r
246  *\r
247  * This source may be freely distributed, however I would be interested\r
248  * in any changes that are made.\r
249  *\r
250  * This driver takes packets off the IP i/f and hands them up to a\r
251  * user process to have its wicked way with. This driver has it's\r
252  * roots in a similar driver written by Phil Cockcroft (formerly) at\r
253  * UCL. This driver is based much more on read/write/select mode of\r
254  * operation though.\r
255  *\r
256  * $FreeBSD: src/sys/net/if_tun.h,v 1.17 2000/01/23 01:47:12 brian Exp $\r
257  */\r
258 \r
259 #ifndef _NET_IF_TUN_H_\r
260 #define _NET_IF_TUN_H_\r
261 \r
262 /* Refer to if_tunvar.h for the softc stuff */\r
263 \r
264 /* Maximum transmit packet size (default) */\r
265 #define TUNMTU          1500\r
266 \r
267 /* Maximum receive packet size (hard limit) */\r
268 #define TUNMRU          16384\r
269 \r
270 struct tuninfo {\r
271         int     baudrate;               /* linespeed */\r
272         short   mtu;                    /* maximum transmission unit */\r
273         u_char  type;                   /* ethernet, tokenring, etc. */\r
274         u_char  dummy;                  /* place holder */\r
275 };\r
276 \r
277 /* ioctl's for get/set debug */\r
278 #define TUNSDEBUG       _IOW('t', 90, int)\r
279 #define TUNGDEBUG       _IOR('t', 89, int)\r
280 #define TUNSIFINFO      _IOW('t', 91, struct tuninfo)\r
281 #define TUNGIFINFO      _IOR('t', 92, struct tuninfo)\r
282 #define TUNSLMODE       _IOW('t', 93, int)\r
283 #define TUNSIFMODE      _IOW('t', 94, int)\r
284 #define TUNSIFPID       _IO('t', 95)\r
285 #define TUNSIFHEAD      _IOW('t', 96, int)\r
286 #define TUNGIFHEAD      _IOR('t', 97, int)\r
287 \r
288 #endif /* !_NET_IF_TUN_H_ */\r
289 \r
290 #else   // UNIX_BSD\r
291 \r
292 #ifdef  UNIX_MACOS\r
293 \r
294 // -----------------------------------------------------------------\r
295 // MacOS 用 tap ヘッダ\r
296 // -----------------------------------------------------------------\r
297 \r
298 #else   // UNIX_MACOS\r
299 \r
300 #endif  // UNIX_MACOS\r
301 \r
302 #endif  // UNIX_BSD\r
303 \r
304 #endif  // UNIX_SOLARIS\r
305 \r
306 #endif  // UNIX_LINUX\r
307 \r
308 #endif  // TUNTAP_H\r