revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-unix / devs / networks / tap / tap.h
blob6731309e62759276695ca30e6921d0934e927df3
1 /*
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.
8 */
10 #ifndef _TAP_DEVICE_H
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>
25 #include <oop/oop.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
34 via fcntl.h */
35 #undef __unused
36 #include <fcntl.h>
37 #include <sys/ioctl.h>
39 #include <netinet/in.h>
40 #include <linux/if.h>
41 #include <linux/if_tun.h>
42 #include <linux/if_ether.h>
44 #include <poll.h>
45 #include <stdio.h>
47 #undef timeval
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"
65 struct tap_opener {
66 struct MinNode node;
68 struct MsgPort read_pending;
70 BOOL (*rx)(APTR, APTR, ULONG);
71 BOOL (*tx)(APTR, APTR, ULONG);
73 struct Hook *filter;
76 struct tap_tracker {
77 struct MinNode node;
78 ULONG refcount;
79 ULONG packet_type;
80 struct Sana2PacketTypeStats stats;
83 struct tap_unit
85 ULONG num;
86 ULONG refcount;
88 int fd;
90 char name[IFNAMSIZ];
91 unsigned char hwaddr[ETH_ALEN];
93 struct Sana2DeviceQuery info;
95 ULONG flags;
97 struct MinList openers;
99 struct MinList trackers;
100 struct Sana2DeviceStats stats;
102 struct MsgPort *iosyncport;
103 struct Task *iotask;
105 LONG abort_signal;
106 LONG io_signal;
108 struct MsgPort *write_queue;
110 struct uioInterrupt irq;
113 struct tap_base
115 struct Device tap_device;
116 struct tap_unit unit[MAX_TAP_UNITS];
117 OOP_AttrBase UnixIOAttrBase;
118 OOP_Object *unixio;
121 #undef HiddUnixIOAttrBase
122 #define HiddUnixIOAttrBase LIBBASE->UnixIOAttrBase
124 /* unit flags */
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);
135 #endif