After I change code to call GetVpnSendPacketBuffer in IVpnPlugin::Encapsulate, after some packets (no more than 100?) the IVpnPlugin::Encapsulate callback will not be called.
Good workaround:
In IVpnPlugin::Encapsulate call packets.RemoveAtBegin() to get the buf, then call packets.Append(buf) after you finish use that VpnPacketBuffer object.You can use channel.GetVpnSendPacketBuffer() and append it to encapulatedPackets. This way the bug will disappear.
may be workaround1:
Do not call GetVpnSendPacketBuffer in IVpnPlugin::Encapsulate, use the buffer in the packets.
Configure the mtu as the size of your udp content max size, not the size of the max size of ip packet. And change the mss field in tcp packet to mtu-40 to force the tcp packet fit in the vpn packet.(you need parse the ip header and tcp header in the packet and recompute ip checksum and tcp checksum after the mss change)(I do not know how to force udp and icmp packet fit in the vpn packet)
may be workaround2:
Do not call GetVpnSendPacketBuffer in IVpnPlugin::Encapsulate, use the buffer in the packets.
Using IVpnPlugin::connect connect to a 127.0.0.1 udp server which is in the same process, then the udp server treat this udp connection as a tun device, and send real encrypt packet in the other udp connection.
So if you want your vpn packet have more bytes than mtu of the tun nework device, you can not in this uwp vpn api because of this bug.
The vpn will not work when call GetVpnSendPacketBuffer in IVpnPlugin::Encapsulate.
After I change code to call GetVpnSendPacketBuffer in IVpnPlugin::Encapsulate, after some packets (no more than 100?) the IVpnPlugin::Encapsulate callback will not be called.
Good workaround:
may be workaround1:
may be workaround2:
So if you want your vpn packet have more bytes than mtu of the tun nework device, you can not in this uwp vpn api because of this bug.