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

multicast receive address #101

Merged
merged 2 commits into from
Jun 22, 2024

Conversation

michieldwitte
Copy link
Contributor

When using send_all_coap and using a create_receiver_for receiving all the responses,
we had a requirement to also know where the responses came from.

This fixes that, however I'm not really happy with the exact state of this MR yet.
I'm open for suggestions/improvements to implement!

@Covertness
Copy link
Owner

My advice is to add a new function rather than change the existed function. Like recv and recv_from in the UdpSocket. Add a new function will make minimal changes.

@michieldwitte
Copy link
Contributor Author

It all relies on the TransportSynchronizer containing UnboundedSender<IoResult<Packet>> which I need to change to AddressedPacket either way. This forces a lot of changes, I can't find a way around that ...

@Covertness
Copy link
Owner

Maybe you can extend the defination of the packet. I don't think it's appropriate that do this in the client.

@michieldwitte
Copy link
Contributor Author

The packet inside coap-lite is the implementation of the RFC message format https://datatracker.ietf.org/doc/html/rfc7252#page-16
Also as far as I can see coap-lite is agnostic of transport, so I don't think it should be done there ...

@Covertness
Copy link
Owner

The source of a packet is an attribute of packet. The Clang CoAP library implement it by this way: https://github.com/obgm/libcoap/blob/develop/include/coap3/coap_io_internal.h#L224

@michieldwitte
Copy link
Contributor Author

It's different naming, but boils down to the same thing.
libcoap's coap_packet_t would be AddressedPacket
and payload would be Packet
Maybe coap-lite's "Packet" could better be renamed to "Message".

Maybe we could do this in the client

use coap_lite::Packet as Message

#[derive(Debug, Clone)]
pub struct Packet {
    pub address: SocketAddr,
    pub message: Message,
}

This would probably make the diff smaller, but would eventually be the same thing.

@Covertness
Copy link
Owner

I think it's better. A terse word reduce the difficulty of code reader.

@michieldwitte michieldwitte force-pushed the multicast_receive_address branch from f395d9a to cc0c3ee Compare June 20, 2024 21:32
@michieldwitte
Copy link
Contributor Author

Should be in a better state now

@Covertness
Copy link
Owner

@michieldwitte michieldwitte force-pushed the multicast_receive_address branch from cc0c3ee to 759258b Compare June 22, 2024 12:53
@Covertness Covertness merged commit 231bb6e into Covertness:master Jun 22, 2024
2 checks passed
@coveralls
Copy link

Coverage Status

coverage: 82.19% (+0.02%) from 82.169%
when pulling 759258b on michieldwitte:multicast_receive_address
into c120146 on Covertness:master.

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

Successfully merging this pull request may close these issues.

3 participants