src/apps/mdns/mdns.c: In function 'mdns_debug_print_answer':
src/apps/mdns/mdns.c:796:24: warning: ', rdata = ' directive output may be truncated writing 10 bytes into a region of size between 8 and 15 [-Wformat-truncation=]
snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/apps/mdns/mdns.c:796:3: note: 'snprintf' output between 31 and 38 bytes into a destination of size 35
snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:56: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);
/home/dziegel/lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:3: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 256
snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);
Reduce subdir string length by 3 bytes to make the warning go away. The whole file path including directory AND filename is limited to MAX_PATH_LEN - so it is reasonable to reserve 3 bytes less for directory - the filename won't fit anyway in the remaining 3 bytes.
If the host observes a response (after probing) containing RR's
that he thought were unique to him, there is a conflict. If a host
observes such conflict, it resets back to probing and the probing
procedures will resolve the conflict. (RFC6762 section 9)
Update mdns.txt for below API changes:
* mdns_resp_add_netif() no longer has dns_ttl argument
* mdns_resp_add_service() no longer has dns_ttl arguemnt
* mdns_resp_add_service() uses enum mdns_sd_proto for proto argument
* Add missing const qualifier at appropriate places
Signed-off-by: Axel Lin <axel.lin@ingics.com>
by replacing strnlen with strlen. It's a user-supplied string, so we can assume it is correctly \0 terminated (as done several times elsewhere in the code)
According to RFC6762 section 8.1:
If fifteen conflicts occur within any ten-second period, then the
host MUST wait at least five seconds before each successive
additional probe attempt.
If the host restarts mDNS, instead of a probe wait timeout randomly
chosen between 0 and 250ms, we wait 5s if more then 15 conflicts
occured in 10seconds. This flag is reset from the moment probing
succeeded.
mDNS: first version probe tiebreaking added
This first version works for our MCU boards but does only compare
the first question and answer. It does not sort the list of answers
and it does not search for answers or questions.
mDNS: improved probe question handling
For every probe question in our packet, we check the presence
in the incomming packet until we find a match. then we perform
the tiebreaking. At the moment we still only look at the first
answer.
mDNS: evaluate all answers in the authoritative section
The authoritative sections of both messages are evaluated.
The records that answer the probe question are sorted in to lists.
Then the lists are compared pairwise. A winner and a loser are
chosen and the host reacts on the outcome (ignore or stop probing).
mDNS: add support for name decompression in rdata when comparing.
For probe tiebreaking we need to compare RR's. It is possible that
the rdata of an RR contains compessed names (SRV record). We need
to decompress it first before we do the comparison.
Probe packet creation -> by splitting the definition and the sending
we can use the definition function for probe tiebreaking.
outpkt creation -> by splitting the creation and sending we can use
the creation function for probe tiebreaking.
The host only responded to a probe query via unicast because
according to the RFC, a probe should have the QU bit on.
This is a should and not a must so we need to be careful.
We added multicast probe answering support with the needed timouts.
Avahi for example probes with the QM queries. With this commit the
conflict is resolved.
It should be SYS_MBOX_EMPTY, not SYS_ARCH_TIMEOUT.
SYS_MBOX_EMPTY is defined to SYS_ARCH_TIMEOUT, so there is no bug.
But for good readability of the code, SYS_MBOX_EMPTY should be used.
The implementation was not fully to the standard. This commit adds
a nicer state machine implementation and multiple announce messages
with a minimum of 2.
See below commit messages for more information
mDNS: support for direct and delayed sends
There are two ways to send a response, directly and after a delay.
A probe or an announce msg are now send via the direct way and
all responses are send via the delayed way.
mDNS improved delay vs direct send behavior on questions
All multicast answers are delayed at the moment. While all unicast
answers are send out directly. A unicast answer is send when this
is requested by the QU bit, when a unicast question was send or
when the question originated from a legacy querier.
mDNS: add probe query detection.
If a probe query is detected a direct unicast respond is send.
Independent of the QU/QM bit.
mDNS split delayed multicast msgs into ipv4 and ipv6 buffers.
We are implementing a two resolvers in one (IPv6 and IPv4 together).
For directly send answers, this does not matter. But for delayed
answers, we need to make a separate buffer for both.
mDNS: addr bug, we should not clear full outmsg
memset deleted also the dest_addr and dest_port, which should remain
and is constant. This commit contains a function that resets only the
needed parts of the outmsg struct.
mDNS: do not multicast a rr within one second.
RFC6762 section 6: prevent network flooding. When a multicast packet
is send out, we start a timeout of 1s within this 1 second all
multicast requests are ignored. We do not make a difference between
the records, we set the delay for all records.
mDNS: improved split for unicast vs multicast and direct vs delayed
unicast delayed message are now possible and multicast direct msgs to.
MDNS: changed printfs to lwip debug messages
MDNS: change timeouts from max time to random time
mDNS: send multicast response on QU questions if not multicasted recently.
If a QU question is received, the responder should multicast the
answer if it did not multicast that record within 25% of it's ttl.
we implemented a stripped down version, meaning that we look at the
records as one set and use one timer for all records. So if the
responder multicasted a record within 30s of the QU question it
will respond with a unicast answer. if not, it will respond
multicast.
mDNS: timeouts -> create function for mdns timeout handling
mdns_set_timeout will check if the timer is running or not and will
update the flag to running after starting the timer.
Multicast timeouts were not set everywhere they needed to be. This
is solved.
mulit <-> multi typo fixed.
mDNS: solve commenting and style issues
mDNS: add #if LWIP_IPVx to new code
LWIP_IPV4/6 can be enabled or disabled, all combination should work.
it's more practical to use netif as a wrapper instead of wrapping
netif in the mdns packets. netif contains all information.
Netif is passed along were needed.
MDNS_TTL changed to MDNS_IP_TTL for clarity.
The mDNS RR ttl does not need to be settalbe, this is against the
RFC. RFC6762 states that for rr's with the hostname in them
somewhere, the ttl should be 120s. If it's not in their it should
be 75 minutes and if the answer is send to a legacy dns querier,
it should be no more then 10s.
This patch corrects the ttl behavior to the RFC.
see RFC 6762 section 8.2: for tiebreaking to work correctly in all
cases, the Authority section must contain all the records and
proposed rdata being probed for uniqueness.
mDNS.c needed to become cleaner. Domain related functions are
moved to the mdns_domain.c util module. The output related
functions are split off (clear separation between defining the
packet and generating the packet). The output functions can
now be found in mdns_out.c.
mDNS move probe question packet generation to mdns_send_outpacket
The probe any questions were added to the pbuf in the send_probe
routine. It is better if we move all pbuf generation to the output
function so later on packets can be delayed etc. keep it all in
one place.
mDNS: move legacy question generation to mdns_send_outpacket
It's better to do the pbuf generation in one place.
Especially important for message delaying etc.
mDNS take out domain related functionality and put in other file.
The mDNS file is getting very big and a lot still needs to be added.
For clarity reasons it's better to split these domain functions
from the main mDNS file.
mDNS split off output related functionality and put in other file
A lot of functions are only needed for the generation of the pbuf,
by separating them into another file we clean up the mdns file.
We only need the mdns_send_outpacket function as interface.
Packet definition is now completely separated from packet
generation.
This reverts commit 684adaca29.
It changes the behaviour to assert for applications running good so far.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
lwip_getsockopt_internal/lwip_setsockopt_internal were renamed to
lwip_getsockopt_impl/lwip_setsockopt_impl. Update the comment accordingly.
Signed-off-by: Axel Lin <axel.lin@ingics.com>