JulianSchmid / etherparse

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

Atempting to compile in a no_std crate results in an error with Sum16BitWords #93

Closed DeepHorizons closed 3 months ago

DeepHorizons commented 3 months ago

Hello, I'm trying to compile etherparse 0.14.2 in a no_std crate but im getting errors about add_2bytes (among others) not existing.

cargo build
   Compiling etherparse v0.14.2
error[E0599]: no method named `add_2bytes` found for struct `Sum16BitWords` in the current scope
   --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/etherparse-0.14.2/src/net/ipv4_header.rs:648:14
    |
647 | /         checksum::Sum16BitWords::new()
648 | |             .add_2bytes([
    | |_____________-^^^^^^^^^^
    |
   ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/etherparse-0.14.2/src/checksum.rs:4:1
    |
4   |   pub struct Sum16BitWords {
    |   ------------------------ method `add_2bytes` not found for this struct
    |
help: there is a method `add_16bytes` with a similar name
    |
648 |             .add_16bytes([
    |              ~~~~~~~~~~~

...

rror[E0560]: struct `Sum16BitWords` has no field named `sum`
  --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/etherparse-0.14.2/src/checksum.rs:16:25
   |
16 |         Sum16BitWords { sum: 0 }
   |                         ^^^ `Sum16BitWords` does not have this field
   |
   = note: all struct fields are already assigned
JulianSchmid commented 3 months ago

Hi @DeepHorizons ,

I will have a look in a few days what the issue is.

Greets Julian

JulianSchmid commented 3 months ago

Hi @DeepHorizons ,

I tried to reproduce your error message by setting up a project and pulling in the crate with default-features = false , but I could not reproduce it.

Can you give me a minimal example? Or more infos about the architecture you are trying to compile for? Is it a 64, 32 or 16 bit platform?

Greets Julian

DeepHorizons commented 3 months ago

@JulianSchmid

I have a sample repo here: https://github.com/DeepHorizons/rust-attiny85-etherparse-test

I am trying to compile for the AVR arch, ultimate goal is to target the ATTiny85 and ATTiny404 but im just trying to get it to work on an Arduino first. It is an 8-bit platform.

JulianSchmid commented 3 months ago

Thanks for the sample repo, I could reproduce the error. So far I only tested 64 & 32 bit systems. I will have a look if I can at least partially support the platform.

Is there something specifically you want to use the crate for? Then I can put a focus on that.

DeepHorizons commented 3 months ago

I'm looking at using the crate for parsing udp data grams, over ipv6 packets, over Ethernet frames. Focus will be on DHCP.

Thanks for looking into this!

On Sun, Mar 31, 2024, 2:07 PM Julian Schmid @.***> wrote:

Thanks for the sample repo, I could reproduce the error. So far I only tested 64 & 32 bit systems. I will have a look if I can at least partially support the platform.

Is there something specifically you want to use the crate for? Then I can put a focus on that.

— Reply to this email directly, view it on GitHub https://github.com/JulianSchmid/etherparse/issues/93#issuecomment-2028848872, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKLJKOPTMTM6VPHH5OCJPDY3BGE5AVCNFSM6AAAAABFJ2HFF6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYHA2DQOBXGI . You are receiving this because you were mentioned.Message ID: @.***>

JulianSchmid commented 3 months ago

I fixed the compile errors in https://github.com/JulianSchmid/etherparse/pull/94 and merged it. Your sample project now builds on my system

But a word of warning, I never tested 16 bit platforms. So I don't 100% know if there are not issues in my implementation for 16 bit platforms. If you hit anything strange, let me know.

In the mean time I opened https://github.com/JulianSchmid/etherparse/issues/95 for later to setup some CI for 16 bit systems.

JulianSchmid commented 3 months ago

I released the fix as part of https://github.com/JulianSchmid/etherparse/releases/tag/v0.14.3