Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect example #41

Closed
StackOverflowExcept1on opened this issue Dec 17, 2022 · 1 comment
Closed

Incorrect example #41

StackOverflowExcept1on opened this issue Dec 17, 2022 · 1 comment

Comments

@StackOverflowExcept1on
Copy link
Contributor

I'm trying to use custom udp packet builder with almost same code:
https://github.com/JulianSchmid/etherparse/blob/master/examples/write_ipv4_udp.rs

some context to show the error later

//setup the actual payload of the udp packet
let udp_payload = [1,2,3,4,5,6,7,8];

//source ip address
[192,168,1,42],
//destination ip address
[192,168,1,1]
$ cargo run --example=write_ipv4_udp
[1, 2, 3, 4, 5, 6, 11, 12, 13, 14, 15, 16, 8, 0, 69, 0, 0, 36, 0, 0, 64, 0, 20, 17, 227, 77, 192, 168, 1, 42, 192, 168, 1, 1, 0, 0, 0, 42, 0, 16, 108, 20]

IPv4: (start from 0x45/69)

[69, 0, 0, 36, 0, 0, 64, 0, 20, 17, 227, 77, 192, 168, 1, 42, 192, 168, 1, 1, 0, 0, 0, 42, 0, 16, 108, 20]

I'm using raw sockets to send it and Wireshark to view packets
image1
software shows that UDP packet is invalid
image2

payload length is calculated as udp_header_len + payload.len() = 8 + 8 = 16
but as we see there is no payload at the generated packet

@JulianSchmid
Copy link
Owner

Good catch & thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants