-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
The Internet Checksum can be incrementally updated if one knows the old and new value of a particular field. The details are in https://www.rfc-editor.org/rfc/rfc1624.html.
Effectively, you just subtract the old value from the checksum and add the new one to it.
I wrote a small module for a recent project here that does this: https://github.com/firezone/firezone/blob/main/rust/relay/ebpf-turn-router/src/checksum.rs
Is this something that people are interested in having upstreamed? There is the internet-checksum crate as well which has an update function but it is unnecessarily restrictive (e.g. only works if old and new have the same length).
etherparse already has a pretty solid checksum module. All we'd need is to extend that one to support:
- Creating a
Sum16BitWordsfrom an initial checksum (i.e. taking the one's complement from the sum) - Adding functions to subtract a value (which means adding the one's complement of a value)
Metadata
Metadata
Assignees
Labels
No labels