IP packet class in Swift

Has anyone made a Swift class for IP packets? This is just me being lazy -- the goal is to be able to print them out nicely, and possibly change the values, mainly for experimentation and fun. (I mean, I can do it in C, so I can always wrap that in ObjC and bridge to Swift.)

Swift class for IP packets

That's pretty vague spec !

  • V4 or V6 ?
  • Do you just want to display or have other func in the class ?

Here is for Python (I didn't look in details), maybe you can adapt:

https://github.com/mike01/pypacker

Full spec is in RFC791.

have a look, really complex to cover all cases. https://datatracker.ietf.org/doc/html/rfc791

Both v4 and v6, of course!

As I said, I can do it in ObjC pretty easily, I was just hopeful someone had already saved me a bit of work.

IP packet class in Swift
 
 
Q