Multicast DNS
This module defines platform APIs for Multicast DNS (mDNS) socket.
Summary
Typedefs |
|
---|---|
otPlatMdnsAddressInfo
|
typedefstruct otPlatMdnsAddressInfo
Represents a socket address info. |
Functions |
|
---|---|
otPlatMdnsHandleReceive(otInstance *aInstance, otMessage *aMessage, bool aIsUnicast, const otPlatMdnsAddressInfo *aAddress)
|
void
Callback to notify OpenThread mDNS module of a received message on UDP port 5353.
|
otPlatMdnsSendMulticast(otInstance *aInstance, otMessage *aMessage, uint32_t aInfraIfIndex)
|
void
Sends an mDNS message as multicast.
|
otPlatMdnsSendUnicast(otInstance *aInstance, otMessage *aMessage, const otPlatMdnsAddressInfo *aAddress)
|
void
Sends an mDNS message as unicast.
|
otPlatMdnsSetListeningEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex)
|
Enables or disables listening for mDNS messages sent to mDNS port 5353.
|
Structs |
|
---|---|
otPlatMdnsAddressInfo |
Represents a socket address info. |
Typedefs
otPlatMdnsAddressInfo
struct otPlatMdnsAddressInfo otPlatMdnsAddressInfo
Represents a socket address info.
Functions
otPlatMdnsHandleReceive
void otPlatMdnsHandleReceive( otInstance *aInstance, otMessage *aMessage, bool aIsUnicast, const otPlatMdnsAddressInfo *aAddress )
Callback to notify OpenThread mDNS module of a received message on UDP port 5353.
aMessage
MUST contain DNS message starting with the DNS header at offset zero. This function passes the ownership of aMessage
from the platform layer to the OpenThread stack. The OpenThread stack will free the message once processed.
The aAddress
fields are as follows:
mAddress
specifies the sender's address. IPv4-mapped IPv6 format is used to represent an IPv4 destination.mPort
specifies the sender's port.mInfraIndex
specifies the interface index.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
otPlatMdnsSendMulticast
void otPlatMdnsSendMulticast( otInstance *aInstance, otMessage *aMessage, uint32_t aInfraIfIndex )
Sends an mDNS message as multicast.
The platform MUST multicast the prepared mDNS message in aMessage
as a UDP message using the mDNS well-known port number 5353 for both source and destination ports. The message MUST be sent to the mDNS link-local multicast address 224.0.0.251
and/or its IPv6 equivalent ff02::fb
.
aMessage
contains the mDNS message starting with DNS header at offset zero. It does not include IP or UDP headers. This function passes the ownership of aMessage
to the platform layer and platform implementation MUST free aMessage
once sent and no longer needed.
The platform MUST allow multicast loopback, i.e., the multicast message aMessage
MUST also be received and passed back to OpenThread stack using otPlatMdnsHandleReceive()
callback. This behavior is essential for the OpenThread mDNS stack to process and potentially respond to its own queries, while allowing other mDNS receivers to also receive the query and its response.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otPlatMdnsSendUnicast
void otPlatMdnsSendUnicast( otInstance *aInstance, otMessage *aMessage, const otPlatMdnsAddressInfo *aAddress )
Sends an mDNS message as unicast.
The platform MUST send the prepared mDNS message in aMessage
as a UDP message using source UDP port 5353 to the destination address and port number specified by aAddress
.
aMessage
contains the DNS message starting with the DNS header at offset zero. It does not include IP or UDP headers. This function passes the ownership of aMessage
to the platform layer and platform implementation MUST free aMessage
once sent and no longer needed.
The aAddress
fields are as follows:
mAddress
specifies the destination address. IPv4-mapped IPv6 format is used to represent an IPv4 destination.mPort
specifies the destination port.mInfraIndex
specifies the interface index.
If the matches this devices address, the platform MUST ensure to receive and pass the message back to the OpenThread stack using otPlatMdnsHandleReceive()
for processing.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otPlatMdnsSetListeningEnabled
otError otPlatMdnsSetListeningEnabled( otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex )
Enables or disables listening for mDNS messages sent to mDNS port 5353.
When listening is enabled, the platform MUST listen for multicast messages sent to UDP destination port 5353 at the mDNS link-local multicast address 224.0.0.251
and its IPv6 equivalent ff02::fb
.
The platform SHOULD also listen for any unicast messages sent to UDP destination port 5353. If this is not possible, then OpenThread mDNS module can be configured to not use any "QU" questions requesting unicast response.
While enabled, all received messages MUST be reported back using otPlatMdnsHandleReceive()
callback.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
Resources
OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.