Decrease alignment requirements to 4
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
a0f031c692
commit
7437155446
@ -98,6 +98,7 @@ StatementMacros: [
|
|||||||
'__drv_preferredFunction',
|
'__drv_preferredFunction',
|
||||||
'__drv_allocatesMem',
|
'__drv_allocatesMem',
|
||||||
'__drv_freesMem',
|
'__drv_freesMem',
|
||||||
|
'_Field_size_bytes_',
|
||||||
]
|
]
|
||||||
TabWidth: '4'
|
TabWidth: '4'
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
|
19
README.md
19
README.md
@ -89,11 +89,6 @@ After loading the driver and creating a network interface the typical way using
|
|||||||
| 4 bytes, native endian |
|
| 4 bytes, native endian |
|
||||||
+------------------------------+
|
+------------------------------+
|
||||||
| |
|
| |
|
||||||
| padding |
|
|
||||||
| 12 bytes, all zero |
|
|
||||||
| |
|
|
||||||
+------------------------------+
|
|
||||||
| |
|
|
||||||
| packet_0 |
|
| packet_0 |
|
||||||
| size_0 bytes |
|
| size_0 bytes |
|
||||||
| |
|
| |
|
||||||
@ -101,22 +96,22 @@ After loading the driver and creating a network interface the typical way using
|
|||||||
| |
|
| |
|
||||||
+------------------------------+
|
+------------------------------+
|
||||||
| padding |
|
| padding |
|
||||||
| 16-(size_0&15) bytes, |
|
| 4-(size_0&3) bytes |
|
||||||
| all zero |
|
|
||||||
+------------------------------+
|
+------------------------------+
|
||||||
| size_1 |
|
| size_1 |
|
||||||
| 4 bytes, native endian |
|
| 4 bytes, native endian |
|
||||||
+------------------------------+
|
+------------------------------+
|
||||||
| |
|
| |
|
||||||
| padding |
|
|
||||||
| 12 bytes, all zero |
|
|
||||||
| |
|
|
||||||
+------------------------------+
|
|
||||||
| |
|
|
||||||
| packet_1 |
|
| packet_1 |
|
||||||
| size_1 bytes |
|
| size_1 bytes |
|
||||||
| |
|
| |
|
||||||
~ ~
|
~ ~
|
||||||
|
| |
|
||||||
|
+------------------------------+
|
||||||
|
| padding |
|
||||||
|
| 4-(size_1&3) bytes |
|
||||||
|
+------------------------------+
|
||||||
|
~ ~
|
||||||
```
|
```
|
||||||
|
|
||||||
Each packet segment should contain a layer 3 IPv4 or IPv6 packet. Up to 15728640 bytes may be read or written during each call to `ReadFile` or `WriteFile`. All calls to `ReadFile` must be called with the same virtual address, for a given handle. This virtual address must reference pages that are writable for the same length as passed to the first call of `ReadFile`.
|
Each packet segment should contain a layer 3 IPv4 or IPv6 packet. Up to 15728640 bytes may be read or written during each call to `ReadFile` or `WriteFile`. All calls to `ReadFile` must be called with the same virtual address, for a given handle. This virtual address must reference pages that are writable for the same length as passed to the first call of `ReadFile`.
|
||||||
|
5
wintun.c
5
wintun.c
@ -32,7 +32,7 @@
|
|||||||
#define TUN_EXCH_MAX_PACKETS 256
|
#define TUN_EXCH_MAX_PACKETS 256
|
||||||
/* Maximum exchange packet size - empirically determined by net buffer list (pool) limitations */
|
/* Maximum exchange packet size - empirically determined by net buffer list (pool) limitations */
|
||||||
#define TUN_EXCH_MAX_PACKET_SIZE 0xF000
|
#define TUN_EXCH_MAX_PACKET_SIZE 0xF000
|
||||||
#define TUN_EXCH_ALIGNMENT 16 /* Memory alignment in exchange buffers */
|
#define TUN_EXCH_ALIGNMENT sizeof(ULONG) /* Memory alignment in exchange buffers */
|
||||||
/* Maximum IP packet size (headers + payload) */
|
/* Maximum IP packet size (headers + payload) */
|
||||||
#define TUN_EXCH_MAX_IP_PACKET_SIZE (TUN_EXCH_MAX_PACKET_SIZE - sizeof(TUN_PACKET))
|
#define TUN_EXCH_MAX_IP_PACKET_SIZE (TUN_EXCH_MAX_PACKET_SIZE - sizeof(TUN_PACKET))
|
||||||
/* Maximum size of read/write exchange buffer */
|
/* Maximum size of read/write exchange buffer */
|
||||||
@ -60,7 +60,8 @@
|
|||||||
typedef struct _TUN_PACKET
|
typedef struct _TUN_PACKET
|
||||||
{
|
{
|
||||||
ULONG Size; /* Size of packet data (TUN_EXCH_MAX_IP_PACKET_SIZE max) */
|
ULONG Size; /* Size of packet data (TUN_EXCH_MAX_IP_PACKET_SIZE max) */
|
||||||
_Field_size_bytes_(Size) __declspec(align(TUN_EXCH_ALIGNMENT)) UCHAR Data[]; /* Packet data */
|
_Field_size_bytes_(Size)
|
||||||
|
UCHAR Data[]; /* Packet data */
|
||||||
} TUN_PACKET;
|
} TUN_PACKET;
|
||||||
|
|
||||||
typedef enum _TUN_FLAGS
|
typedef enum _TUN_FLAGS
|
||||||
|
Loading…
Reference in New Issue
Block a user