Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix windows packet creation #5

Merged
merged 1 commit into from
Jul 7, 2020
Merged

Fix windows packet creation #5

merged 1 commit into from
Jul 7, 2020

Conversation

bltavares
Copy link
Owner

Windows packets were being generated with the wrong address. Packats
leaving the machine were using the address as 0.0.0.0 on the source,
which was then not propagated by any network stack.

This was caused by the in_pktinfo on Windows not using the interface
address if the socket ipi_ifindex is defined.

On Linux, the in_pktinfo structure has an extra field, the ipi_spec_dst,
which is used as the first source of information, then the ipi_ifindex
next.

On windows, if we set the ipi_ifindex, the ipi_addr will be used
regardless of what is the interface ip.

Given that we were only filling the field with a value if the interface
passed was a Interface::Address, the field would go out as mem::zeroed,
so 0.0.0.0

To avoid producing invalid packets, during the windows socket startup,
we investigate all the addresses and build a hashmap of ifindex ->
address.

So, when we use the information, we lookup the table and also fill the
address part of the request.

To avoid erros when sending packets with Interface::Default, the CMSGHDR
for control is not being created, and instead is added as an empty
buffer.

This was enough to have a system using multicast-socket to start
listening to packets once again and finding each-other with win x win
communicaiton.

It also fixed the win x linux communication producing things as 0.0.0.0
when listening to the messages.

Windows packets were being generated with the wrong address. Packats
leaving the machine were using the address as 0.0.0.0 on the source,
which was then not propagated by any network stack.

This was caused by the in_pktinfo on Windows not using the interface
address if the socket ipi_ifindex is defined.

On Linux, the in_pktinfo structure has an extra field, the ipi_spec_dst,
which is used as the first source of information, then the ipi_ifindex
next.

On windows, if we set the ipi_ifindex, the ipi_addr will be used
regardless of what is the interface ip.

Given that we were only filling the field with a value if the interface
passed was a Interface::Address, the field would go out as mem::zeroed,
so 0.0.0.0

To avoid producing invalid packets, during the windows socket startup,
we investigate all the addresses and build a hashmap of ifindex ->
address.

So, when we use the information, we lookup the table and also fill the
address part of the request.

To avoid erros when sending packets with Interface::Default, the CMSGHDR
for control is not being created, and instead is added as an empty
buffer.

This was enough to have a system using multicast-socket to start
listening to packets once again and finding each-other with win x win
communicaiton.

It also fixed the win x linux communication producing things as 0.0.0.0
when listening to the messages.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant