• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision066158ba81701c0ff591246de25e2717ad7d8f27 (tree)
l'heure2015-11-03 14:37:54
Auteurphabrics <phabrics@phab...>
Commiterphabrics

Message de Log

Changed openvpn host to use openvpn ethernet access methods.

Change Summary

Modification

--- a/contrib/tme-0.8/host/bsd/bsd-bpf.c
+++ b/contrib/tme-0.8/host/bsd/bsd-bpf.c
@@ -275,9 +275,9 @@ _tme_bsd_bpf_config(struct tme_ethernet_connection *conn_eth,
275275 TME_BSD_BPF_LEN(program) = bpf_filter_size - first_pc;
276276 TME_BSD_BPF_INSNS(program) = bpf_filter + first_pc;
277277 #ifdef HAVE_LSF
278- if (setsockopt(bpf->tme_eth_fd, SOL_SOCKET, SO_ATTACH_FILTER, &program, sizeof(program)) == -1) {
278+ if (setsockopt(bpf->tme_eth_handle, SOL_SOCKET, SO_ATTACH_FILTER, &program, sizeof(program)) == -1) {
279279 #else
280- if (ioctl(bpf->tme_eth_fd, BIOCSETF, &program) < 0) {
280+ if (ioctl(bpf->tme_eth_handle, BIOCSETF, &program) < 0) {
281281 #endif
282282 tme_log(&bpf->tme_eth_element->tme_element_log_handle, 0, errno,
283283 (&bpf->tme_eth_element->tme_element_log_handle,
--- a/contrib/tme-0.8/host/eth/eth-if.h
+++ b/contrib/tme-0.8/host/eth/eth-if.h
@@ -122,6 +122,16 @@ _TME_RCSID("$Id: eth-impl.h,v 1.1 2003/05/18 00:02:23 fredette Exp $");
122122 #ifdef HAVE_IFADDRS_H
123123 #include <ifaddrs.h>
124124 #endif
125+#ifdef OPENVPN_HOST
126+#include "syshead.h"
127+#include "tun.h"
128+#define _tme_eth_static static
129+#ifndef TME_THREADS_SJLJ
130+#define OPENVPN_ETH
131+#endif
132+#else
133+#define _tme_eth_static
134+#endif
125135
126136 /* structures: */
127137
@@ -147,8 +157,12 @@ struct tme_ethernet {
147157 struct tme_ethernet_connection *tme_eth_eth_connection;
148158
149159 /* the Ethernet file descriptor: */
150- int tme_eth_fd;
151-
160+#ifdef OPENVPN_ETH
161+ struct tuntap *tme_eth_handle;
162+#else
163+ int tme_eth_handle;
164+#endif
165+
152166 /* the size of the packet buffer for the interface: */
153167 size_t tme_eth_buffer_size;
154168
@@ -177,6 +191,7 @@ struct tme_ethernet {
177191 };
178192
179193 /* prototypes: */
194+#ifndef OPENVPN_HOST
180195 #if 0
181196 int tme_eth_if_find _TME_P((_tme_const char *,
182197 struct ifreq **,
@@ -199,11 +214,15 @@ int tme_eth_connections_new _TME_P((struct tme_element *element,
199214 const char * const *args,
200215 struct tme_connection **_conns));
201216
202-int tme_eth_init _TME_P((struct tme_element *element,
203- int fd,
217+int tme_eth_init _TME_P((struct tme_element *element,
218+#ifdef OPENVPN_ETH
219+ struct tuntap *tt,
220+#else
221+ int fd,
222+#endif
204223 unsigned int sz,
205224 void *data,
206225 unsigned char *addr,
207226 typeof(tme_eth_connections_new) eth_connections_new));
208-
227+#endif // !_tme_eth_static
209228 #endif /* !_HOST_ETH_IMPL_H */
--- a/contrib/tme-0.8/host/eth/eth-impl.c
+++ b/contrib/tme-0.8/host/eth/eth-impl.c
@@ -99,7 +99,7 @@ _tme_eth_callout(struct tme_ethernet *eth, int new_callouts)
9999 if (eth->tme_eth_callout_flags & TME_ETH_CALLOUT_RUNNING) {
100100 return;
101101 }
102-
102+
103103 /* callouts are now running: */
104104 eth->tme_eth_callout_flags |= TME_ETH_CALLOUT_RUNNING;
105105
@@ -177,8 +177,11 @@ _tme_eth_callout(struct tme_ethernet *eth, int new_callouts)
177177 assert(rc <= sizeof(frame));
178178
179179 /* do the write: */
180- status = tme_thread_write(eth->tme_eth_fd, frame, rc);
181-
180+#ifdef OPENVPN_ETH
181+ status = write_tun(eth->tme_eth_handle, frame, rc);
182+#else
183+ status = tme_thread_write(eth->tme_eth_handle, frame, rc);
184+#endif
182185 /* writes must succeed: */
183186 assert (status == rc);
184187
@@ -259,7 +262,7 @@ _tme_eth_th_reader(struct tme_ethernet *eth)
259262 (&eth->tme_eth_element->tme_element_log_handle,
260263 _("calling read")));
261264 #if 0
262- rc = tme_thread_select_yield(eth->tme_eth_fd + 1,
265+ rc = tme_thread_select_yield(eth->tme_eth_handle + 1,
263266 &fdset_read_in,
264267 NULL,
265268 NULL,
@@ -268,9 +271,14 @@ _tme_eth_th_reader(struct tme_ethernet *eth)
268271
269272 }
270273
274+#elif defined(OPENVPN_ETH)
275+ buffer_end =
276+ read_tun(eth->tme_eth_handle,
277+ eth->tme_eth_buffer,
278+ eth->tme_eth_buffer_size);
271279 #else
272280 buffer_end =
273- tme_thread_read_yield(eth->tme_eth_fd,
281+ tme_thread_read_yield(eth->tme_eth_handle,
274282 eth->tme_eth_buffer,
275283 eth->tme_eth_buffer_size);
276284 #endif
@@ -477,7 +485,7 @@ _tme_eth_read(struct tme_ethernet_connection *conn_eth,
477485
478486 #if 0
479487 /* this finds a network interface via traditional ioctls: */
480-int
488+_tme_eth_static int
481489 tme_eth_if_find(const char *ifr_name_user, struct ifreq **_ifreq, tme_uint8_t **_if_addr, unsigned int *_if_addr_size)
482490 {
483491 int saved_errno;
@@ -647,7 +655,7 @@ tme_eth_if_find(const char *ifr_name_user, struct ifreq **_ifreq, tme_uint8_t **
647655
648656 #ifdef HAVE_IFADDRS_H
649657 /* this finds a network interface via the ifaddrs api: */
650-int
658+_tme_eth_static int
651659 tme_eth_ifaddrs_find(const char *ifa_name_user, int family, struct ifaddrs **_ifaddr, tme_uint8_t **_if_addr, unsigned int *_if_addr_size)
652660 {
653661 struct ifaddrs *ifaddr, *ifa;
@@ -793,7 +801,7 @@ tme_eth_ifaddrs_find(const char *ifa_name_user, int family, struct ifaddrs **_if
793801 #endif // HAVE_IFADDRS_H
794802
795803 /* Allocate an ethernet device */
796-int tme_eth_alloc(char *dev_filename, char **_output)
804+_tme_eth_static int tme_eth_alloc(char *dev_filename, char **_output)
797805 {
798806 int fd, minor;
799807 char dev_minor[4];
@@ -829,7 +837,7 @@ int tme_eth_alloc(char *dev_filename, char **_output)
829837 }
830838
831839 /* this makes a new connection side for a ETH: */
832-int
840+_tme_eth_static int
833841 tme_eth_connections_new(struct tme_element *element,
834842 const char * const *args,
835843 struct tme_connection **_conns)
@@ -869,8 +877,12 @@ tme_eth_connections_new(struct tme_element *element,
869877 return (TME_OK);
870878 }
871879
872-int tme_eth_init(struct tme_element *element,
873- int fd,
880+_tme_eth_static int tme_eth_init(struct tme_element *element,
881+#ifdef OPENVPN_ETH
882+ struct tuntap *handle,
883+#else
884+ int handle,
885+#endif
874886 unsigned int sz,
875887 void *data,
876888 unsigned char *addr,
@@ -881,7 +893,7 @@ int tme_eth_init(struct tme_element *element,
881893 /* start our data structure: */
882894 eth = tme_new0(struct tme_ethernet, 1);
883895 eth->tme_eth_element = element;
884- eth->tme_eth_fd = fd;
896+ eth->tme_eth_handle = handle;
885897 eth->tme_eth_buffer_size = sz;
886898 eth->tme_eth_buffer = tme_new(tme_uint8_t, sz);
887899 eth->tme_eth_data = data;
--- a/contrib/tme-0.8/host/openvpn/Makefile.am
+++ b/contrib/tme-0.8/host/openvpn/Makefile.am
@@ -88,8 +88,9 @@ tme_host_openvpn_la_SOURCES = \
8888 tap.c \
8989 win32.h win32.c \
9090 cryptoapi.h cryptoapi.c
91+
9192 tme_host_openvpn_la_LIBADD = \
92- ../eth/libeth.la \
93+ $(top_builddir)/generic/libtme-generic.la \
9394 $(SOCKETS_LIBS) \
9495 $(OPTIONAL_LZO_LIBS) \
9596 $(OPTIONAL_PKCS11_HELPER_LIBS) \
@@ -97,6 +98,7 @@ tme_host_openvpn_la_LIBADD = \
9798 $(OPTIONAL_SELINUX_LIBS) \
9899 $(OPTIONAL_SYSTEMD_LIBS) \
99100 $(OPTIONAL_DL_LIBS)
101+
100102 if WIN32
101103 tme_host_openvpn_la_SOURCES += openvpn_win32_resources.rc
102104 tme_host_openvpn_la_LIBADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm
@@ -106,7 +108,4 @@ tme_host_openvpn_la_LDFLAGS = -module -version-info 0:0:0
106108
107109 include $(top_srcdir)/modules
108110
109-$(pkglib_LTLIBRARIES): ../eth/libeth.la
110-../eth/libeth.la: force
111- cd `dirname $@` && $(MAKE) `basename $@`
112-force: ;
111+tap.lo: ../eth/eth-impl.c
--- a/contrib/tme-0.8/host/openvpn/tap.c
+++ b/contrib/tme-0.8/host/openvpn/tap.c
@@ -34,9 +34,8 @@
3434 #include <tme/common.h>
3535
3636 /* includes: */
37-#include "eth-if.h"
38-#include "syshead.h"
39-#include "tun.h"
37+#define OPENVPN_HOST
38+#include "eth-impl.c"
4039
4140 /* the new TAP function: */
4241 TME_ELEMENT_SUB_NEW_DECL(tme_host_openvpn,tap) {
@@ -181,9 +180,10 @@ TME_ELEMENT_SUB_NEW_DECL(tme_host_openvpn,tap) {
181180 do_ifconfig(tt, guess, TME_ETHERNET_FRAME_MAX, NULL);
182181 }
183182
183+#ifndef OPENVPN_ETH
184184 /* temporarily turn off ipv6 to disable protocol info being prepended to packets on Linux */
185185 tt->ipv6 = FALSE;
186-
186+#endif
187187 /* open the tun device */
188188 open_tun(dev,
189189 dev_type,
@@ -220,6 +220,12 @@ TME_ELEMENT_SUB_NEW_DECL(tme_host_openvpn,tap) {
220220 hwaddr[5]));
221221 }
222222 #endif
223- return tme_eth_init(element, tt->fd, 4096, NULL, hwaddr, NULL);
223+ return tme_eth_init(element,
224+#ifdef OPENVPN_ETH
225+ tt,
226+#else
227+ tt->fd,
228+#endif
229+ 4096, NULL, hwaddr, NULL);
224230
225231 }
--- a/contrib/tme-0.8/host/tun/tun-tap.c
+++ b/contrib/tme-0.8/host/tun/tun-tap.c
@@ -248,7 +248,7 @@ _tme_tun_tap_config(struct tme_ethernet_connection *conn_eth,
248248
249249 /* set the filter on the TAP device: */
250250 TME_TUN_TAP_LEN((TME_TUN_TAP_PROG *)tap_filter) = tap_filter_size;
251- if (ioctl(tap->tme_eth_fd, TUNSETTXFILTER, tap_filter) < 0) {
251+ if (ioctl(tap->tme_eth_handle, TUNSETTXFILTER, tap_filter) < 0) {
252252 tme_log(&tap->tme_eth_element->tme_element_log_handle, 0, errno,
253253 (&tap->tme_eth_element->tme_element_log_handle,
254254 _("failed to set the filter")));