> >Yes, but since BSD wont let you choose if you want it or not, and the > chance of changing Linux-TUN-drivers now is slim, I guess it has to be > the application that takes care of this. I'll try to make a patch and > test it, and send you the diff later. > > Some thoughts: > > * probably the best place to add/remove the AF_INET is by calling some > routine in the main event loop in openvpn.c, conditional on --remote-is-bsd. > > * add and remove u_int_32 by manipulating struct buffer (see buf_prepend and > buf_advance in particular). > > * remember that when you add a new buffer prepend item, you must modify the > appropriate struct frame which will contain the MTU parms, so that > everything gets sized right. For an example, see > crypto_adjust_frame_parameters().
I have made an attempt but I must warn you, I'm no guru on pointers
and stuff, so I'd like you to check my calls to see that I'm on the
right track please:
I will test this asap and tell you if it works.
diff -ru openvpn-1.0.3/openvpn.c new_openvpn-1.0.3/openvpn.c
--- openvpn-1.0.3/openvpn.c Fri Mar 29 01:43:12 2002
+++ new_openvpn-1.0.3/openvpn.c Thu Apr 4 12:09:32 2002
@@ -91,6 +91,8 @@
" : 8 -- show all debug info\n"
"--gremlin : Simulate dropped & corrupted packets + network outages\n"
" to test robustness of protocol (for debugging only).\n"
+ "--remote-bsd : If the remote system is using BSD tun devices that add\n"
+ " protocol info on each packet sent.\n"
#ifdef USE_LZO
"--comp-lzo : Use fast LZO compression -- may add up to 1 byte per\n"
" packet for uncompressible data.\n"
@@ -210,6 +212,7 @@
o->verbosity = 1;
o->bind_local = true;
o->tun_mtu = DEFAULT_TUN_MTU;
+ o->remotebsd = false;
#ifdef USE_LZO
o->comp_lzo_adaptive = true;
#endif
@@ -262,6 +265,7 @@
SHOW_INT (nice);
SHOW_INT (verbosity);
SHOW_BOOL (gremlin);
+ SHOW_BOOL (remotebsd);
#ifdef USE_LZO
SHOW_BOOL (comp_lzo);
@@ -426,6 +430,11 @@
static void frame_finalize(struct frame *frame, const struct options *options)
{
+ if (options->remotebsd)
+ {
+ frame->extra_frame += 4;
+ }
+
if (options->tun_mtu_defined)
{
frame->mtu = options->tun_mtu;
@@ -872,6 +881,11 @@
check_status (buf.len, "read from tun");
if (buf.len > 0)
{
+ if (options->remotebsd)
+ {
+ buf_advance(&buf, sizeof(u_int32_t));
+ }
+
#ifdef USE_LZO
if (options->comp_lzo)
lzo_compress (&buf, lzo_compress_buf, &lzo_compwork,
&frame, current);
@@ -905,6 +919,13 @@
if (FD_ISSET (td, &writes))
{
int size;
+
+ if (options->remotebsd)
+ {
+ u_int32_t af = htonl(AF_INET);
+ buf_write_prepend(&to_tun, &af ,sizeof (u_int32_t));
+ }
+
ASSERT (to_tun.len > 0 && to_tun.len <= MAX_RW_SIZE_TUN(&frame));
size = write (td, BPTR (&to_tun), BLEN (&to_tun));
check_status (size, "write to tun");
@@ -1155,6 +1176,10 @@
{
options.bind_local = false;
}
+ else if (streq (p1, "--remote-bsd"))
+ {
+ options.remotebsd = true;
+ }
#ifdef USE_LZO
else if (streq (p1, "--comp-lzo"))
{
diff -ru openvpn-1.0.3/openvpn.h new_openvpn-1.0.3/openvpn.h
--- openvpn-1.0.3/openvpn.h Sat Mar 30 03:24:00 2002
+++ new_openvpn-1.0.3/openvpn.h Thu Apr 4 11:16:46 2002
@@ -53,6 +53,7 @@
int nice;
int verbosity;
bool gremlin;
+ bool remotebsd;
#ifdef USE_LZO
bool comp_lzo;
--
Janne Johansson
[email protected]
BioMat Systems AB
Klarabergsg 37 3tr
111 21 Stockholm
signature.asc
Description: This is a digitally signed message part
