… | |
… | |
61 | #define ifdebug(subsys) if (0) |
61 | #define ifdebug(subsys) if (0) |
62 | |
62 | |
63 | #define cp() |
63 | #define cp() |
64 | #define lookup_config(config_tree,key) (key) |
64 | #define lookup_config(config_tree,key) (key) |
65 | |
65 | |
66 | #define MTU MAXSIZE |
66 | #define MTU MAX_MTU |
67 | |
67 | |
68 | // BIGGEST hack of 'em all |
68 | // BIGGEST hack of 'em all |
69 | // will be casted to data_packet, due to structural similarity |
69 | // will be casted to data_packet, due to structural similarity |
70 | struct vpn_packet_t : net_packet { |
70 | struct vpn_packet_t : net_packet { |
71 | u8 data[MAXSIZE]; |
71 | u8 data[MAXSIZE]; |
… | |
… | |
78 | { |
78 | { |
79 | if (!strcmp (key, "Interface")) |
79 | if (!strcmp (key, "Interface")) |
80 | *res = conf.ifname; |
80 | *res = conf.ifname; |
81 | else if (!strcmp (key, "Device")) |
81 | else if (!strcmp (key, "Device")) |
82 | *res = 0; |
82 | *res = 0; |
|
|
83 | else if (!strcmp (key, "DeviceType")) |
|
|
84 | *res = "tap"; |
83 | else |
85 | else |
84 | { |
86 | { |
85 | slog (L_ERR, _("tincd layer asking for unknown config '%s'"), key); |
87 | slog (L_ERR, _("tincd layer asking for unknown config '%s'"), key); |
86 | *res = 0; |
88 | *res = 0; |
87 | } |
89 | } |
… | |
… | |
91 | |
93 | |
92 | #define netname conf.ifname |
94 | #define netname conf.ifname |
93 | |
95 | |
94 | #if IF_linux |
96 | #if IF_linux |
95 | # include "tincd/linux/device.c" |
97 | # include "tincd/linux/device.c" |
|
|
98 | const char * tap_device::if_up () { return "/sbin/ifconfig $IFNAME hw ether $MAC mtu $MTU"; } |
|
|
99 | |
|
|
100 | #elif IF_bsd |
|
|
101 | # include "tincd/bsd/device.c" |
|
|
102 | const char * tap_device::if_up () { return "/sbin/ifconfig $IFNAME ether $MAC mtu $MTU"; } |
96 | |
103 | |
97 | #elif IF_freebsd |
104 | #elif IF_freebsd |
98 | # include "tincd/freebsd/device.c" |
105 | # include "tincd/freebsd/device.c" |
|
|
106 | const char * tap_device::if_up () { return "/sbin/ifconfig $IFNAME ether $MAC mtu $MTU"; } |
99 | |
107 | |
100 | #elif IF_netbsd |
108 | #elif IF_netbsd |
101 | # define IF_istun 1 |
109 | # define IF_istun 1 |
102 | # include "tincd/netbsd/device.c" |
110 | # include "tincd/netbsd/device.c" |
|
|
111 | const char * tap_device::if_up () { return "/sbin/ifconfig $IFNAME mtu $MTU"; } |
103 | |
112 | |
104 | #elif IF_openbsd |
113 | #elif IF_openbsd |
105 | # define IF_istun 1 |
114 | # define IF_istun 1 |
106 | # include "tincd/openbsd/device.c" |
115 | # include "tincd/openbsd/device.c" |
|
|
116 | const char * tap_device::if_up () { return "/sbin/ifconfig $IFNAME mtu $MTU"; } |
107 | |
117 | |
108 | #elif IF_solaris |
118 | #elif IF_solaris |
109 | # define IF_istun 1 |
119 | # define IF_istun 1 |
110 | # include "tincd/solaris/device.c" |
120 | # include "tincd/solaris/device.c" |
|
|
121 | const char * tap_device::if_up () { return ""; } |
111 | |
122 | |
112 | #elif IF_cygwin |
123 | #elif IF_cygwin |
113 | # include "tincd/cygwin/device.c" |
124 | # include "tincd/cygwin/device.c" |
|
|
125 | const char * tap_device::if_up () { return ""; } |
114 | |
126 | |
115 | #elif IF_mingw |
127 | #elif IF_mingw |
116 | # include "tincd/mingw/device.c" |
128 | # include "tincd/mingw/device.c" |
|
|
129 | const char * tap_device::if_up () { return ""; } |
117 | |
130 | |
118 | #elif IF_darwin |
131 | #elif IF_darwin |
119 | # define IF_istun 1 |
132 | # define IF_istun 1 |
120 | # include "tincd/darwin/device.c" |
133 | # include "tincd/darwin/device.c" |
|
|
134 | const char * tap_device::if_up () { return "/sbin/ifconfig $IFNAME ether $MAC mtu $MTU"; } |
121 | |
135 | |
122 | #elif IF_raw_socket |
136 | #elif IF_raw_socket |
123 | # define IF_istun 1 |
|
|
124 | # include "tincd/raw_socket/device.c" |
137 | # include "tincd/raw_socket/device.c" |
|
|
138 | const char * tap_device::if_up () { return "/sbin/ifconfig $IFNAME ether $MAC mtu $MTU"; } |
125 | |
139 | |
126 | #elif IF_uml_socket |
140 | #elif IF_uml_socket |
127 | # include "tincd/uml_socket/device.c" |
141 | # include "tincd/uml_socket/device.c" |
|
|
142 | const char * tap_device::if_up () { return 0; } |
128 | |
143 | |
129 | #else |
144 | #else |
130 | # error No interface implementation for your IFTYPE/IFSUBTYPE combination. |
145 | # error No interface implementation for your IFTYPE/IFSUBTYPE combination. |
131 | #endif |
146 | #endif |
132 | |
147 | |