33 Commits
Author SHA1 Message Date
basil00 1543e958e6 Dual-license WinDivert under the LGPLv3 and GPLv2.
This allows projects that are strictly "GPLv2
only" to use WinDivert without licensing issues.
See the FSF's compatibility matrix here:
https://www.gnu.org/licenses/gpl-faq.en.html

This change does not affect existing projects
that can continue to use the LGPLv3 as before.

Also, bump the WinDivert version to 1.4.1.
2018-04-04 18:41:45 +08:00
basil00 fb68612176 Cleanup protocol header definitions.
Now use a single version.
Also prepare for 1.4.0-rc release.
2017-11-21 09:16:06 +08:00
basil00 ba5e893f8f Update the test suite. 2017-11-14 20:41:18 +08:00
basil00 dbb6b0fe60 Invert the checksum flags.
Zeroing the addr will default to full checksums.
2017-11-14 20:20:18 +08:00
basil00 80b31815b2 Implement "impostor" packets.
WinDivert will now mark any packet injected by
another driver as an "impostor", meaning that it
did not originate from the network.  Changes are:
- User programs may filter impostor packets.
- WinDivertSend() automatically decrements the TTL
  for imposter packets, see #41.
2017-11-13 09:38:06 +08:00
basil00 aea3a3a858 Add support for pseudo IP/TCP/UDP checksums.
Most NIC cards support checksum offloading,
meaning that it is not necessary to calculate the
full IP/TCP/UDP checksums for injected packets.
WINDIVERT_ADDRESS has been extended to include 3
extra flags that indicate if the packet has full
or pseudo checksums.  This is a WIP.
2017-11-09 22:11:13 +08:00
basil00 bbf6a34aa6 Add Loopback and Timestamp fields to addresses.
- Loopback=1 for loopback packets, 0 otherwise.
- Timestamp is the time when packet captured.
2017-11-05 12:12:19 +08:00
basil00 4c4f586f4d Add WINDIVERT_FLAG_DEBUG for WinDivertOpen() 2017-10-31 10:53:06 +08:00
basil00 b2fd7eb891 Bump version to 1.4 2017-10-22 21:07:06 +08:00
basil00 bd4265897a Increase packet queue limits.
Queued packets use PagedPool, so increase limits:
- Queue length (min=16,max=16384,default=2048)
- Queue time (min=20,max=8000,default=1000ms)
2017-10-21 18:13:58 +08:00
basil00 910a2e3050 Add new WINDIVERT_PARAM_QUEUE_SIZE parameter.
Controls the number of bytes used by the packet queue.
2017-10-01 15:33:58 +08:00
basil00 e69cc09cce Update WinDivert sublayer GUIDs for version 1.3. 2017-09-24 16:24:37 +08:00
basil00 7b7d92cd26 Bump version to WinDivert 1.3.0
This prevents the old 1.2 driver from being used by new 1.3 software.

Also, clean up the driver code.
2017-09-24 15:48:38 +08:00
basil00 cd1bfff998 Bump copyright year. 2016-01-19 11:15:48 +08:00
basil00 609ab63594 Add a NO_REPLACE for WinDivertHelperCalcChecksums
The WINDIVERT_HELPER_NO_REPLACE flag tells WinDivertHelperCalcChecksums not to
recalculate and replace non-zero checksum fields.  This is useful for
reconstructing the checksums for packets returned by WinDivertRecv(), where
all non-zero checksum fields are already valid.  This allows WinDivert1.2
to achieve similar efficiency as WinDivert1.1, where checksums were calculated
by the driver.

Note that for modified packets, the WINDIVERT_HELPER_NO_REPLACE flag should
not be used, as all checksums need to be recalculated from scratch anyway.
2015-07-25 13:24:28 +08:00
basil00 130e25c05b Bump copyright year. 2015-07-17 19:13:55 +08:00
basil00 fdd5825f5d Bump version to WinDivert 1.2
Bump version and change magic numbers to make the driver incompatible with
older versions.  Also cleanup some driver checksum code missed by previous
commit.
2015-07-17 18:24:30 +08:00
basil00 e247f01c43 Remove automatic checksum calculation & legacy API
- As discussed in #37, the WINDIVERT_FLAG_NO_CHECKSUM behavior has become the
  default.  This means that outbound packets returned by WinDivertRecv() are
  no longer guaranteed to have valid checksums, thanks to TCP checksum
  offloading by the Windows TCP/IP stack.  The checksums can still be
  recovered by calling WinDivertHelperCalcChecksums() manually.
- Remove the old WinDivert1.0 legacy API, as nobody should still be using it.
2015-07-02 21:19:27 +08:00
basil00 e1ea77f1d3 Implement a filter compiler with new features.
Replaces the old filter compiler with a new version that:
- Is a cleaner, more extensible, implementation.
- Can report specific error messages (e.g. bad token vs parse error).
- Supports the new C-style if-then-else expression "(A? B: C)" syntax.

Two new WinDivert helper API functions have been implemented:
- WinDivertHelperCheckFilter() can be used to check a filter string for
  errors.
- WinDivertHelperEvalFilter() evaluates a filter on a given packet.  Will be
  useful for testing.
2015-06-21 12:38:49 +08:00
basil00 874d147b9b - Update copyright year.
- Use exact version number in driver binary.
2014-03-24 18:15:05 +08:00
basil00 57934712c6 - Refactor the WFP interface:
* WinDivert sublayers are created and inserted when the driver is loaded.
  * All WinDivert callouts are installed at the same sublayer.
- Clean-up the implementation of priorities.
- Re-introduce deep copying for SNIFF mode.  This avoids referencing the
  sniffed packets.
- Fix-up the netfilter example:
  * Don't send RSTs to RST/FINs, this can start a RST war.
  * Don't inject ICMP outbound - this may not be a problem despite 1233 errors.
2013-12-23 11:03:02 +08:00
basil00 03fbfa74d6 - Increase the maximum filter length to 128. 2013-11-02 11:43:21 +08:00
basil00 0b15b26d45 - (Missing from last commit) remove the PASSTHRU flag from windivert_device.h 2013-09-10 17:58:08 +08:00
basil00 835d604d4e - Remove the PASSTHRU flag; The same result can be achieved with a "false"
filter.
2013-09-10 17:52:43 +08:00
basil00 09b7cd45a2 - Add support for the legacy WinDivert API. 2013-07-26 18:01:49 +08:00
basil00 38f1f3a16d - Towards WinDivert 1.1:
* Re-brand "DIVERT" to "WINDIVERT" throughout the code-base.
* New flags:
  > WINDIVERT_FLAG_PASSTHRU: Do not drop nor capture packets.  Useful
    for injection-only handles.
  > WINDIVERT_FLAG_NO_CHECKSUM: Do not guarantee that diverted packets
    have a correct checksum.
  NOTE: Not yet tested!
* New default values and limits for various WinDivert parameters,
  including WINDIVERT_PARAM_QUEUE_LEN, WINDIVERT_PARAM_QUEUE_TIME, and
  the maximum filter length.
* New extended WinDivert functions that support asynchronous I/O:
  > WinDivertRecvEx(..)
  > WinDivertSendEx(..)
  NOTE: Not yet tested!
* The WinDivert driver now services reads (receives) out-of-band.
  The motivation is because WFP callouts are run at DISPATCH_LEVEL, so
  we should not be doing expensive work in the ClassifyFn.  This is also
  the same reason why the filter length has been restricted.
2013-06-30 15:58:21 +08:00
basil00 3d881423d6 - Replace (110) errors with more meaningful error codes.
- Add two new helper API functions: DivertHelperParseIPv?Addr(..)
- Document these new features.
2013-04-06 23:41:00 +08:00
basil00 934019aec5 - In divert_filter_compile(), do not use the stack for filter0; instead
allocate from the heap.  Stacks are small (12Kb on x86).
2012-10-24 21:30:27 +08:00
basil00 13b2ab4418 ***MAJOR UPDATE***
Name and version:

* Now officially called 'WinDivert'
* Now officially working towards a version 1.0 release

New features:

* WinDivert now supports a packet-sniffing mode.  This mode merely
  copies packets, and does not drop the original.
* WinDivert now also supports a packet-dropping mode.
* WinDivert now supports filter priorities.
* WinDivert now supports a forwarded packet layer (WARNING: untested).
* WinDivert now supports get/set parameters such as packet queue length and
  time.
* WinDivert now supports larger filters (but use at own risk).
* WinDivert now uninstalls the driver on program exit/library unload
* Different versions of WinDivert can co-exist on the same machine
  (WARNING: untested, as there is currently only one version).

New License:

* WinDivert is now LGPL.  This is less restrictive than the GPL so WinDivert
  can be linked to by commercial software (under the terms of the LGPL
  license).

Technical:

* Cleaner IOCTL interface.
* Cleaner driver implementation.
* Thread local events in WinDivert.dll
* Many minor tweaks and fixes.
2012-02-21 23:18:45 +08:00
basil00 f1b7ead828 The divert.dll library can now be build with MinGW Linux cross-compilation.
This is useful for projects that use MinGW instead of MSVC.  Otherwise, the
.dlls are incompatible.
2011-10-15 17:40:18 +08:00
basil00 0ff63cda99 - Make the package compile for i386
- Make the pAddr arg for DivertRecv() optional
- Make the i386 user binaries compatible with an amd64 driver.
  (useful for projects not yet ported to amd64)
2011-08-23 22:18:02 +08:00
basil00 ee386df032 Figured out a way to split the "address" part of the buffer from the packet
data itself.  This makes for a much cleaner interface.

sys/divert.c
dll/divert.c
include/*.h
	DivertRecv and DivertSend now use IOCTLs instead of reads/writes.
	The 'address' parameter is passed by pointer to the driver, which
	writes directly to it (after sanity checks).
	This means that the data buffer now only contains the packet, which
	help to avoid some messy code.

examples/*/*.c
	Update the examples to reflect the new API.

doc/divert.html
	Update the documentation to reflect the new API.
2011-08-21 17:59:13 +08:00
basil00 019f9d509b First commit of the Windows Divert project 2011-08-19 20:11:17 +08:00