meh / rust-packet

Network packet handling for Rust.
90 stars 27 forks source link

any function to modify ICMP Packet code field? #10

Open Kilerd opened 4 years ago

Kilerd commented 4 years ago

I cant find any function to modify it.

meh commented 4 years ago

At the moment you can't as changing the code changes the type of packet entirely, do you have a use-case in mind so I can see how I can try and support it?

Kilerd commented 4 years ago

in fact, i just wanna build a customized icmp packet. currently the api only supports three types of icmp: echo, information, and timestamp. but based on the RFC, exclude those were deprecated, builder should be built into

most of them showed above cant be built through Builder. packet, as a common lib, i think should be more general, so adding type(type: ICMPType) and code(code: u8) into Builder would be better?

meh commented 4 years ago

Oh yeah, a lot of ICMP packet types are unimplemented, but the idea was to keep it type-safe and not allow you to build invalid ICMP packets.

Which packet types are you interested in right now? I'm also open to changing my mind on allowing building arbitrary ICMP packets, but it sort of goes against what I had in mind at the moment.

Kilerd commented 4 years ago

i agree that type-safe is quite important, but i think Builder should also have the unchecked method to create raw packet whose danger can be handled by user, just as Packet::unchecked. currently, what i am doing with packet in my project is using a specific ICMP packet as the information carrier between cluster nodes, this ICMP packet is a normal ICMP echo request and reply message witch a specific code(not zero). so now i cant built the packet from Builder, and this's one of my "non-standard" usages.

combined with raw socket, i can handle those non-standard packets in my program. the last, my point is that, maybe we can use a specific Builder for those common packet to keep the type-safe, like icmp::echo::Builder, icmp::information::Builder, and raw builder or kind of unchecked Builder should be provided to. it's ok not to provide those raw builders, i can build it from lower network packet.