Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Simon Rozman <simon@rozman.si>
To: Markus F <hybrid87@gmail.com>,
	"wireguard@lists.zx2c4.com" <wireguard@lists.zx2c4.com>
Subject: RE: WINTUN: Error registering rings (Error 87, INVALID_ARGUMENT)
Date: Thu, 23 Jul 2020 12:29:02 +0000	[thread overview]
Message-ID: <99D61A626FDA8A4B90A270669121BE10D0DE25F6@PLANJAVA.amebis.doma> (raw)
In-Reply-To: <CALvS7dHi_pOtLB6rvNuM8Lu9jQ73ijzihrXZ_WUptkbhNWUGkQ@mail.gmail.com>

Hi,

> I am currently trying to create a testtool using the WINTUN driver to
> establish a 1:1 connection to another client and see what wintun is
> capable of. Unfortunately I cannot get the rings to register. I have
> written a small testprogram in order to reproduce this.
> 
>     #include <windows.h>
>     #include <winioctl.h>
>     #include <IPHlpApi.h>
>     #include <ndisguid.h>
>     #include <TlHelp32.h>
>     #include <tchar.h>
>     #include <securitybaseapi.h>
>     #include <cfgmgr32.h>
> 
>     #include <stdint.h>
>     #include <stdio.h>
>     #include <string>
>     #include <assert.h>
> 
>     #pragma pack(push, 1)

Remove the #pragma pack(push, 1)!!!

>     typedef struct _TUN_PACKET_PROTO {
>         ULONG Size;
>         UCHAR Data[]; // max packet size as defined by the driver.
>     } TUN_PACKET_PROTO;
> 
>     typedef struct _TUN_RING_PROTO {
>         volatile ULONG Head;
>         volatile ULONG Tail;
>         volatile LONG Alertable;
>         UCHAR Data[];
>     } TUN_RING_PROTO;

.
.
.

>     typedef struct _TUN_RING {
>         volatile ULONG Head;
>         volatile ULONG Tail;
>         volatile LONG Alertable;
>         UCHAR Data[WINTUN_RING_CAPACITY + (TUN_MAX_PACKET_SIZE-
> TUN_ALIGNMENT)];
>     } TUN_RING;
> 
>     typedef struct _TUN_PACKET {
>         ULONG Size;
>         UCHAR Data[WINTUN_MAX_PACKET_SIZE]; // max packet size as
> defined by the driver.
>     } TUN_PACKET;
> 
>     typedef struct _TUN_REGISTER_RINGS {
>         struct {
>             ULONG RingSize;
>             TUN_RING *Ring;
>             HANDLE TailMoved;
>         } Send, Receive;
>     } TUN_REGISTER_RINGS;
>     #pragma pack(pop)

Remove #pragma pack(pop)
 
> I cannot figure out what I am doing wrong. Can somebody point out the
> error for me? Thanks!

With the #pragma removed, your test program kind of works:

Output with #pragma pack:
Opened wintun device.
Could not register ring buffers (87).
Experiment failed.
Size TUNRING: 8454156 (8454156)
Capacity: 8388608

Output without #pragma pack:
Opened wintun device.
Size TUNRING: 8454156 (8454156)
Capacity: 8388608

And one more thing... Markus, please: why all the profanity in your code? Code is a work of art. A poetry. I understand Microsoft is silly a lot of times and difficult to go along with. But don't let that turn *you* into a silly grumpy geek. :)

Regards,
Simon


      reply	other threads:[~2020-07-23 12:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06  7:36 Markus F
2020-07-23 12:29 ` Simon Rozman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=99D61A626FDA8A4B90A270669121BE10D0DE25F6@PLANJAVA.amebis.doma \
    --to=simon@rozman.si \
    --cc=hybrid87@gmail.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).