JulianSchmid / etherparse

A rust library for parsing ethernet & ethernet using protocols.
Apache License 2.0
299 stars 53 forks source link

Randomize `identification` in Ipv4Header #44

Closed StackOverflowExcept1on closed 1 year ago

StackOverflowExcept1on commented 1 year ago

I see that it defaults to zero and that's not good. If you are going to generate fake IP packets, then this feature can detect you image

StackOverflowExcept1on commented 1 year ago

Oh, it breaks tests but I think for PacketBuilder::ipv4(...) randomization should be useful

JulianSchmid commented 1 year ago

Hi,

Thanks for the PR, but I think I will not merge it for the following reasons:

  1. I would like to keep the dependencies to a minimum. Adding rand as a dependency is something I would like to avoid.
  2. Generating random network data is not something the library currently has as a target. If random data is needed I would prefer if it lives in a separate crate. In the mean time this is something that can easily done on the user side.

Sorry Julian

StackOverflowExcept1on commented 1 year ago

I don't know how to add ipv4(..., identification) without break compatibility with existing API. Well, we could make an internal function for this, add a parameter there like Option<u16>. Then do something like ipv4_with_identification(..., _: u16)

Update: maybe it does not comfortable enough but there is packet_builder.ip() to solve that