rust-lang / rust-lang/libc

ETH_P_* constants should be c_ushort

Open
#2,057 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breakage-candidate C-bug S-waiting-on-decision
Dominant language
Rust
Stars
2.6k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
69

Description

ETH_P_* constants (and probably more I haven't stumbled across) should be defined as c_ushorton linux x86-64 rather than c_int for 2 related reasons:

  1. To improve ease of use with the various sockaddr_* structs where they most often get used.
  2. Because when they are converted to big endian network ordering for use in those structs, (0x00000003).to_be() != (0x0003).to_be(), which is a really irritating gotcha.

I'm happy to do a find-and-replace to get those (and any others which people think should be changed) if you think it's a sane change.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ETH_P_* definitions and the related sockaddr_* bindings for Linux x86-64, then inspect how their constant types are represented and tested. Done means the applicable constants use c_ushort and relevant existing tests or checks pass without breaking other platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.