Closed xmh0511 closed 9 months ago
I think providing the raw packet produced by tun for all the other cases other than tcp and udp has the maximum flexible because we may want to do the following things:
- process the packet by using the familiar crate.
- send the complete packet to the remote to be processed.
Even for Icmp packet, if we pre-process it to produce IpStackUnknownTransport
, we can only get the payload, or we must re-produce the original packet from the result, which is not necessary.
@xmh0511: could you please check examples/tun.rs in the main branch?
https://github.com/narrowlink/ipstack/blob/main/examples/tun.rs#L113-L134
@SajjadPourali I have tried the latest version. Currently, in the branch IpStackStream::UnknownTransport(u)
, u.payload()
will return the payload part of the IP packet, which is the ICMP message, and u.send
just need the ICMP message too, right?
@SajjadPourali I have tried the latest version. Currently, in the branch
IpStackStream::UnknownTransport(u)
,u.payload()
will return the payload part of the IP packet, which is the ICMP message, andu.send
just need the ICMP message too, right?
True, there also another one that called UnknownNetwork that is similar to the raw that you mentioned.
It is better to create two types for the
IpStackStream
: one forUnknownTransport
, which we know isIP
but is neitherTCP
norUDP
, and another forUnknowNetwork
for anything that is not IP. I believe these types allow users to implement their protocols manually.Since ICMP is not primarily designed to transfer data, we have to create an enum that supports the most useful types of ICMP in the IpStack usage scenarios, such as Echo.