Releases: JulianSchmid/etherparse
v0.17.0 Add ARP support
v0.16.0 Add IP Packet Defragmentation Support
What's Changed
- typo by @ugur-a in #106
- Add etherparse-defrag by @JulianSchmid in #92
New Contributors
- @ugur-a made their first contribution in #106
Full Changelog: v0.15.0...v0.16.0
v0.15.0 Linux SLL Support & SlicedPacket::from_ether_type Bugfix
What's Changed
- Add linux sll support by @RabadanDotDev in #99
- Migrate to codecov actions v4 by @JulianSchmid in #101
- Corrected SlicedPacket::from_ether_type so it sets the link field by @JulianSchmid in #102
New Contributors
- @RabadanDotDev made their first contribution in #99
Full Changelog: v0.14.3...v0.15.0
v0.14.3 Resolve compile error on 16bit systems & add 'ether_payload' & 'ip_payload' methods to SlicedPacket
What's Changed
- Add 'ether_payload' & 'ip_payload' methods to SlicedPacket types by @JulianSchmid in #88
- Enable build for 16 bit systems by @JulianSchmid in #94
- Update version to 0.14.3 by @JulianSchmid in #96
Full Changelog: v0.14.2...v0.14.3
v0.14.2 Corrected docs.rs links of enums in README
What's Changed
- Corrected docs.rs links in README by @JulianSchmid in #87
Full Changelog: v0.14.1...v0.14.2
v0.14.1 Correct example in Readme
v0.14.0
Highlights
SlicedPacket
&PacketHeaders
now use the length fields in the headers to determine the payload length.- The payload(s) in
SlicedPacket
now can be accessed via the layer slices (e.g.link.unwrap().payload()
). - Added
LaxSlicedPacket
&LaxPacketHeaders
to allow for parsing of packets without length checks & other inconsistency checks present inSlicedPacket
&PacketHeaders
. SlicedPacket.ip
&PacketHeaders.ip
have been renamed toSlicedPacket.net
&PacketHeaders.net
- Added
no_std
support. - Errors are now more fine granular (in case you want a general error type you can convert all errors via
into
&from
intoerr::FromSliceError
orerr::ReadError
). - Added
to_bytes()
methods to most header types. - Added slice types which contain both the header(s) and payload (e.g.
IpSlice
,UdpSlice
). - Added payload types (e.g.
IpPayloadSlice
,EtherPayloadSlice
) which contain the slice & information about the payload type (e.g. the IpNumber in case of anIpPayloadSlice
).
What happened?
This version took more then a year to complete. Which for sure was not my plan when starting out.
I started out trying to implement correct handing of "payload lengths" (aka actually using the length fields in headers to determine the payload). This was needed, as without it, incorrect data would sometimes creep into the payload of and IP packet (see #35 ). But this "simple" feature triggered a chain reaction of changes that required me to re-architect big parts of the crate. Specifically the error types were an major issue, which I did not forsee costing so much time and at some time.
But no matter, now it is done. Sadly there are quiet some breaking changes, but I think the crate is now in a better position for future changes & behaves correcter then in the past. There are also quiet a lot of quality of life changes.
New
- Added non-allocating
to_bytes()
methods that returnarrayvec::ArrayVec<u8, Header::MAX_LEN>
to the following headers:Ipv4Header
- Added
LaxSlicedPacket
&LaxPacketHeaders
to allow for parsing of packets without length checks & other inconsistency checks present inSlicedPacket
&PacketHeaders
. no_std
Support was added. To enable use etherparse without default features:etherparse = { version = "0.14", default-features = false }
- Added
LEN
orMIN_LEN
&MAX_LEN
constants to all headers & packets. - Added
InternetSlice::source_addr
&InternetSlice::destination_addr
to get the source & destination asstd::net::IpAddr
(thanks to @nagy)
Changes in Behavior
SlicedPacket
&PacketHeaders
now also verify the total_length and payload length fields present in the IPv4 & IPv6 header. This means the*from_slice*
methods newly throw an error not enough data is present and also newly limit the resulting payload size.- The payload(s) in
SlicedPacket
now can be accessed via the layer fields (e.g.link.unwrap().payload()
). - The payload in
PacketHeaders
now is an enum that indicates from which layer the payload came. - Removed
ReadError::Ipv6TooManyHeaderExtensions
error when callingIpv6Header::skip_all_header_extensions
andIpv6Header::skip_all_header_extensions_in_slice
. - The slice returned by
IpHeader::from_slice
is now the payload of the IP packet (determined by the length specified in the IP header). Previously whatever was left over from the input slice after parsing the IP header and extensions was returned. Now the slice length is limited based on the "payload length" field (IPv6) or "total length" field IPv4. Ipv4Header::from_slice
no longer verifies that thetotal_len
has enough data to contain the header itself. This check is done when the complete packet is parsed. The check was removed as thetotal_len
is sometimes set at a later stage (e.g. in the kernel) in some systems and I would still like to enable people to at least decode the header even if the total length was not yet set.
Breaking Changes:
ip
as been renamed tonet
inSlicedPacket
andPacketHeaders
packet_filter
has been removed- Refactored error types so functions & methods (mostly) only return error types that they can cause.
- Removed
SerializedSize
trait and deprecatedSERIALIZED_SIZE
. Newly added constantsHeader::LEN
,Header::MIN_LEN
&Header::MAX_LEN
to the headers as an replacement. Ipv4Header.fragments_offset
renamed toIpv4Header.fragment_offset
.- Removed
IPV6_MAX_NUM_HEADER_EXTENSIONS
as it is no longer used by the skip functions. - Type of
fragment_offset
inIpv4Header
&Ipv6FragmentHeader
changed fromu16
toIpFragOffset
. Ipv4Header.differentiated_services_code_point
renamed toIpv4Header.dscp
.Ipv4Header.explicit_congestion_notification
renamed toIpv4Header.ecn
.Ipv4Header.fragments_offset
renamed toIpv4Header.fragment_offset
.SingleVlanHeader.vlan_identifier
renamed toSingleVlanHeader.vlan_id
.- Type of
vlan_id
inSingleVlanHeader
changed fromu16
toVlanId
. - Moved options of
Ipv4Header
andTcpHeader
into separate structs and made all fields inIpv4Header
&TcpHeader
public for easier default initialization.
Bugfixes
-
PacketHeaders::from_ip_slice
now only tries to decode the transport layer if the packet is not fragmented. Previously it would also try to decode the transport layer even if the packet contained only a fragment. -
The IPv6 extension header skipping functions were previously checking that the slice length is at least 2 before checking if an extension header is even present. If less then two bytes were present an error was returned. This was wrong behavior, as there are no guarantees for other protocols that there are 2 bytes of data present. A check has been added, that validates the header type before checking the slice length. The following functions were corrected:
Ipv6Header::skip_header_extension_in_slice
Ipv6Header::skip_all_header_extensions_in_slice
-
Previously the manual
core::fmt::Debug
implementations for some types were not correctly inserting newlines & indentation when{:#?}
was used for debug printing. This has been corrected for the following types:Ipv4Header
IpAuthHeader
Ipv6RawExtHeader
Deprecations / Renames:
- The following types have been renamed (alias with the old name exist for backwards compatibility but will trigger a deprecation warning):
InternetSlice
toNetSlice
&IpSlice
IpAuthenticationHeader
toIpAuthHeader
IpAuthenticationHeaderSlice
toIpAuthHeaderSlice
Ipv6RawExtensionHeader
toIpv6RawExtHeader
Ipv6RawExtensionHeaderSlice
toIpv6RawExtHeaderSlice
Internal Changes:
- Separated proptest generators into separate library
etherparse_proptest_generators
- Split modules up into one file per struct/enum and moved tests there
- Applied rust fmt
Pull Requests
- Don't forget about writing UDP payload in examples/write_ipv4_udp.rs (closes #41) by @StackOverflowExcept1on in #42
- code cleanup & bump rust to 2021 edition by @StackOverflowExcept1on in #53
- Add fn for source and destination on InternetSlice by @nagy in #54
- Fix typo: ipv6->ipv4 by @joel0 in #55
- Payload length checking, error rework & rust fmt pass by @JulianSchmid in #47
- Change representations of EtherType and IpNumber enums to single-value structs by @0xcrust in #57
- Adding no-std support by @JulianSchmid in #59
- Add "catch all" error types. by @JulianSchmid in #60
- Added IpHeader length checks to header parsing paths by @JulianSchmid in #62
- Switched to IpNumber in headers by @JulianSchmid in #63
- Introduce encapsulating types & replace IPv4 payload_len with total_length by @JulianSchmid in #64
- Seperate TCP options and update feature documentation by @JulianSchmid in #65
- Added PacketBuilder::tcp_header() by @robs-zeynet in #66
- Fix typo in README.md by @john-g-g in #68
- Fix examples links in README.md by @timlyo in #70
- Add default impl for IpAuthHeader and Ipv6RawExtHeader #67 by @0xcrust in #72
- correct typo by @myasinkaji in #74
- Fix spelling errors in packet builder by @zheylmun in #79
- Reworked layer slicing to include payloads & add lax parsing methods by @JulianSchmid in #71
- Aligned packet slicing errors & update doc for release by @JulianSchmid in #84
- Update changelog by @JulianSchmid in #85
New Contributors
- @StackOverflowExcept1on made their first contribution in #42
- @nagy made their first contribution in #54
- @joel0 made their first contribution in #55
- @0xcrust made their first contribution in #57
- @john-g-g made their first contribution in https://github.c...
Switched license to MIT OR Apache-2.0
The open source license is switched from the "BSD 3 Clause License" to "MIT or Apache 2.0" with version 0.13.0 to make the library easier to use in command line tools.
No code changes are present in this release.
Add `payload_ether_type` method to `SlicedPacket`& `PacketHeaders`
- Add
payload_ether_type
method toSlicedPacket
&PacketHeaders
ICMP & Additional Methods
New Features:
- Added partial ICMP and ICMPv6 support (thanks to @robs-zeynet for the PR with the initial implementation).
- Added
PacketBuilder::<IpHeader>::write
that allows writing without specifying a transport protocol (thanks to @karpawich for the PR) - Added functions SlicedPacket::from_ether_type & PacketHeaders::from_ether_type to slice & decode messages based on the starting
ether type
IpHeader::set_payload_len
added to set the length fields in the ip header (thanks to @agrover for the PR).InternetSlice::is_fragmenting_payload
added to check for fragmentation (thanks to @agrover for the PR).
Breaking Changes:
Ipv4Header::new
changedprotocol
argument type fromIpNumber
tou8
. Use the constants in ip_number instead or cast the IpNumber to an u8 (e.g.IpNumber::Udp as u8
).TransportHeader::Icmpv4
&TransportHeader::Icmpv6
enum values addedTransportSlice::Icmpv4
&TransportSlice::Icmpv6
enum values added