public void Encapsulate(VpnChannel channel, VpnPacketBufferList packets, VpnPacketBufferList encapulatedPackets) { var vpnSendPacketBuffer = channel.GetVpnSendPacketBuffer(); while (packets.Size > 0) //can't iterate over packets { var packet = packets.RemoveAtEnd(); var packetAppId = packet.AppId; var packetBuffer = packet.Buffer; var fromBuffer = DataReader.FromBuffer(packetBuffer); var fromBufferUnconsumedBufferLength = fromBuffer.UnconsumedBufferLength; var bytes = new byte[fromBufferUnconsumedBufferLength]; fromBuffer.ReadBytes(bytes); var bytesRead = 0; var ipv4Header = Ipv4Header.Create(bytes, ref bytesRead); var vpnPacketBufferStatus = packet.Status; var packetTransportAffinity = packet.TransportAffinity; var packetTransportContext = packet.TransportContext; encapulatedPackets.Append(packet); //parse ip datagram and inspect destination IP //if destIP isn't found in peer list, drop and send ICMP "no route to host"? } }
public void GetKeepAlivePayload(VpnChannel channel, out VpnPacketBuffer keepAlivePacket) { keepAlivePacket = channel.GetVpnSendPacketBuffer(); }