2 * tap - TUN/TAP network driver for AROS
3 * Copyright (c) 2007 Robert Norris. All rights reserved.
4 * Copyright (c) 2010-2011 The AROS Development Team. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
11 #define _TAP_DEVICE_H 1
13 #include <aros/debug.h>
14 #include <exec/types.h>
15 #include <exec/libraries.h>
16 #include <exec/semaphores.h>
17 #include <exec/devices.h>
18 #include <exec/interrupts.h>
19 #include <exec/errors.h>
20 #include <exec/lists.h>
21 #include <devices/sana2.h>
22 #include <devices/sana2specialstats.h>
23 #include <devices/newstyle.h>
24 #include <hidd/unixio.h>
26 #include <proto/exec.h>
27 #include <proto/utility.h>
28 #include <aros/libcall.h>
29 #include <aros/symbolsets.h>
31 #define timeval sys_timeval
33 /* avoid conflicts between our __unused define and the ones that might come in
37 #include <sys/ioctl.h>
39 #include <netinet/in.h>
41 #include <linux/if_tun.h>
42 #include <linux/if_ether.h>
49 #include LC_LIBDEFS_FILE
51 /* explicitly prototype rand() so we don't have pull in stdlib.h */
52 extern int rand(void);
54 /* NewStyle device support */
55 #define NEWSTYLE_DEVICE 1
57 #define MAX_TAP_UNITS (4)
59 #define TAP_DEV_NODE "/dev/net/tun"
61 #define TAP_IFACE_FORMAT "aros%ld"
62 #define TAP_TASK_FORMAT "TAP IO: unit %d"
68 struct MsgPort read_pending
;
70 BOOL (*rx
)(APTR
, APTR
, ULONG
);
71 BOOL (*tx
)(APTR
, APTR
, ULONG
);
80 struct Sana2PacketTypeStats stats
;
91 unsigned char hwaddr
[ETH_ALEN
];
93 struct Sana2DeviceQuery info
;
97 struct MinList openers
;
99 struct MinList trackers
;
100 struct Sana2DeviceStats stats
;
102 struct MsgPort
*iosyncport
;
108 struct MsgPort
*write_queue
;
110 struct uioInterrupt irq
;
115 struct Device tap_device
;
116 struct tap_unit unit
[MAX_TAP_UNITS
];
117 OOP_AttrBase UnixIOAttrBase
;
121 #undef HiddUnixIOAttrBase
122 #define HiddUnixIOAttrBase LIBBASE->UnixIOAttrBase
125 #define tu_CONFIGURED (1<<0)
126 #define tu_ONLINE (1<<1)
129 extern void tap_handle_request(struct IOSana2Req
*req
);
131 extern void tap_hexdump(unsigned char *buf
, int bufsz
);
133 extern void tap_iotask(struct tap_base
*TAPBase
, struct tap_unit
*unit
);