Giter Club home page Giter Club logo

mdns's People

Contributors

albertvaka avatar bedzior avatar christianhillenbrand avatar darthgandalf avatar dmurzaikins avatar elgot avatar gocarlos avatar gregjesl avatar heweisheng avatar jeanshh avatar mariotaku avatar mateusz-plociennik avatar mathisloge avatar mjansson avatar muratbalaban43 avatar nikita240 avatar ruslo avatar stablebits avatar summershrimp avatar supersaiyanmode avatar xvitaly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mdns's Issues

compile with MSVC without warnings.

We compile our MSVC projects with the following flags:
/W4 /wd4200 /wd4127 /wd4100 /WX

  • /W4 displays level 1, level 2, and level 3 warnings, and all level 4 (informational) warnings that aren't off by default.
  • C4200 ignore nonstandard extension used : zero-sized array in struct (too many in libusb.h)
  • C4127: ignore conditional expression is constant
  • C4100: ignore unreferenced parameter; same as -Wno-unused-parameter
  • /WX same as -Werror

to get things to compile - we needed to do:

Free free to use or ignore. Thanks

--- ../mdns/mdns.h      2020-05-22 10:59:35.848102185 -0400
+++ ./mdns.h    2020-05-22 11:00:41.592646263 -0400
@@ -470,7 +471,9 @@
        size_t cur = *offset;
        size_t end = MDNS_INVALID_POS;
        mdns_string_pair_t substr;
-       mdns_string_t result = {str, 0};
+      mdns_string_t result;
+      result.str = str;
+      result.length = 0;
        char* dst = str;
        size_t remain = capacity;
        do {

error: ‘in4addr_any’ undeclared

$ gcc -o mdns mdns.c
mdns.c: In function ‘open_service_sockets’:
mdns.c:285:24: error: ‘in4addr_any’ undeclared (first use in this function); did you mean ‘in6addr_any’?
sock_addr.sin_addr = in4addr_any;
^~~~~~~~~~~
in6addr_any
mdns.c:285:24: note: each undeclared identifier is reported only once for each function it appears in
OS: Ubuntu 18.04.4 LTS

How to solve this problem?

thanks~

Multiple questions in muliquery responses

We noticed that when sending a multiquery on the same service, querying for SRV, PTR, A, and AAAA records, the response contained multiple questions. The mdns_query_recv function, however, discards all responses with questions > 1.

According to the RFC, the questions should simply be skipped (as is done later in the function):

   Multicast DNS responses MUST NOT contain any questions in the
   Question Section.  Any questions in the Question Section of a
   received Multicast DNS response MUST be silently ignored.  Multicast
   DNS queriers receiving Multicast DNS responses do not care what
   question elicited the response; they care only that the information
   in the response is true and accurate.

From what I've tested, simply removing the check for questions > 1 seems to be adequate.

Domain name irregularities

Issue:
./mdns --service _bensservice._tcp.local --hostname bens_hostname --port 1234
./mdns --query _bensservice._tcp.local

The above commands will not be able to receive a response for my query.
I think the issue has something to do with a period being added to the end of service names.
So the above name will become "_bensservice._tcp.local."
I did not see any requirement for domain names to end in .local. (ending with period).

It seems i am only able to success if i run my host service as:
./mdns --service _bensservice._tcp.local. --hostname bens_hostname --port 1234

Is this an mDns requirement i am missing, or a bug in the code?

Avahi.InvalidServiceTypeError: Invalid service type

Ubuntu2004, mdns 1.4.3
gcc -o mdns mdns.c
./mdns --service test_mdnsmw_service1._http._tcp.local. --port 10001 --hostname vbox2.local
./mdns --service test_mdnsmw_service1._dns-sd._tcp.local. --port 10001 --hostname vbox2.local
./mdns --service test._http._tcp.local.
opening avahi-discover came out the following:
Browsing domain 'local' on -1.-1 ...
Browsing for services of type '' in domain 'test._http._tcp.local' on 2.1 ...
ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 232, in maybe_handle_message
self._handler(*args, **kwargs)
File "/usr/bin/avahi-discover", line 182, in new_service_type
b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER)
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 147, in call
**keywords)
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 653, in call_blocking
message, timeout)
DBusException: org.freedesktop.Avahi.InvalidServiceTypeError: Invalid service type
Browsing for services of type '' in domain 'test._http._tcp.local' on 2.0 ...
ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 232, in maybe_handle_message
self._handler(*args, **kwargs)
File "/usr/bin/avahi-discover", line 182, in new_service_type
b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER)
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 147, in call
**keywords)
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 653, in call_blocking
message, timeout)
DBusException: org.freedesktop.Avahi.InvalidServiceTypeError: Invalid service type

Build fail on Linux

Hello,

I am getting the following error when attempting to build with make os=linux as described in mDNSPosix/ReadMe.txt

../mDNSShared/dnsextd_parser.y: In function ‘yyparse’:
../mDNSShared/dnsextd_parser.y:221:22: error: ‘context’ undeclared (first use in this function)
    ( ( DaemonInfo* ) context )->private_port = mDNSOpaque16fromIntVal( NUMBER );
                      ^
../mDNSShared/dnsextd_parser.y:221:22: note: each undeclared identifier is reported only once for each function it appears in
../mDNSShared/dnsextd_parser.y: In function ‘ParseConfig’:
../mDNSShared/dnsextd_parser.y:481:2: error: too many arguments to function ‘yyparse’
  err = yyparse( ( void* ) d );
  ^
objects/prod/dnsextd_parser.c:1125:1: note: declared here
 yyparse (void)
 ^
make: *** [objects/prod/dnsextd_parser.y.o] Error 1

OS:

# cat /etc/os-release 
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.5 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

Why avahi-browse shows more answers?

When I use avahi-browse --all I get more services than using your library. I send a request and wait for a response and this repeats in a loop. I use both ipv4 and ipv6

Transaction Id may violate the RFC definition?

The RFC documentation says

   In multicast query messages, the Query Identifier SHOULD be set to
   zero on transmission.
    In multicast responses, including unsolicited multicast responses,
   the Query Identifier MUST be set to zero on transmission, and MUST be
   ignored on reception.

So it seems the line

mdns/mdns.h

Line 870 in 244e578

uint16_t transaction_id = ++mdns_transaction_id;

violate the documentation

no internet at startup

Hello!

I have such situation

My app as service can start without internet connection

but I want other client app can see it on my machine and other instance client on other machine see it after apperence internet on service machine )) do you understand me?

first question is - it is possible run service without internet?
I need client and service see each other on the same machine in any case (with wifi or without)
And I need other client from net can see apperance of service after wifi will connected

(error: Failed to open any client sockets)

open_client_sockets bad local address

Hi Mattias.

When running on Linux, I get a print from the open_client_sockets() function:
Local IPv4 address: 0.0.0.0

However when running, it seems the local IP address used for the server, or other cases, is not 0.0.0.0, but the actual IP address of the network interface.
I suspect that the call to mdns_socket_open_ipv4() inside the function open_client_sockets(), changes the sockaddr structure and changes the source IP address to 0.0.0.0.
I added another print:
Once at the start of the for loop, iterating the network devices, and once at the end.
The result was:
Local IPv4 address: 10.5.205.79
Local IPv4 address: 0.0.0.0

So we can see the source ip address is modified in the sockaddr. probably because mdns_socket_open_ipv4().
The fact that all other mechanisms using the local IP address for server side work correctly is because the assignment:
if (first_ipv4)
{
service_address_ipv4 = *saddr;
first_ipv4 = 0;
}
Happens before the call that changes the source ip address.

Is it possible to move the print for the local ip address further up, before the call to mdns_socket_open_ipv4().
A similar issue may happen with ipv6. i have not tested that case.

splitting application vs mdns functions

Mattias:

First - thanks - we use this code in libiio windows builds; and would like to keep up with your changes.

However, we need to cut up the file a little (to split out your main, which we don't need, and a few other things, to make it easier to use as a leaf function). I was wondering if it made sense to do the same thing here, which would allow easier tracking for others?

Thanks again

  • Robin

[Question] Respond to A and AAAA queries?

Hi,

First of all thanks for this great library! I do however have a question.
Is it already possible to answer A and AAAA queries? I do see a generic answer function, but don't see any sample as to how to answer this. I did find the parse but that is used only when querying oneself?

Sincerely,
Bram Nijenkamp

mdns_string_equal needs to be modified

function mdns_string_equal should be modified like this
int mdns_string_equal(const void* buffer_lhs, size_t size_lhs, size_t* ofs_lhs, const void* buffer_rhs, size_t size_rhs, size_t* ofs_rhs)
{
……
size_t compare_res = 1;
do {
……
if (compare_res && lhs_substr.length != rhs_substr.length)
compare_res = 0;
// return 0;
if (compare_res && strncasecmp((const char *) MDNS_POINTER_OFFSET_CONST(buffer_rhs, rhs_substr.offset), (const char *) MDNS_POINTER_OFFSET_CONST(buffer_lhs, lhs_substr.offset), rhs_substr.length))
compare_res = 0;
// return 0;
……
} while (lhs_substr.length);

……

return compare_res;

}

Multiple Questions per Query

Hello,
I am looking for solution to implement LDS-ME for OPC UA. There I need multicast queries to discover SRV and TXT records of OPC UA Applications. I could send and receive them individually with mdns_query_send on port 5353. It allowed me to receive QM responses. Since I am working with embedded devices it would be a nice to have "Multiple Questions per Query".
How can I enable it in my application?
Problem: mdns_query_send only send one question per query.
Thank you
Muddasir Shakil

Not fully complaint due to UDP source port

I'm trying to communicate with a client running Zeroconf-python.
It has a custom service which avahi can find. Couldn't find it using this repo.

Identified this issue in mdns.c :

int sock = mdns_socket_open_ipv4(port);
if (sock < 0) {
   printf("Failed to open socket: %s\n", strerror(errno));
   return -1;
}

So running --discovery or --query would set the port to 0 making dynamic and random (right?)
RFC 6763 says the following:

A compliant Multicast DNS querier, which implements the rules
specified in this document, MUST send its Multicast DNS queries from
UDP source port 5353 (the well-known port assigned to mDNS), and MUST
listen for Multicast DNS replies sent to UDP destination port 5353 at
the mDNS link-local multicast address (224.0.0.251 and/or its IPv6
equivalent FF02::FB).

Tried setting mode <=2 instead but wasn't successful,

Not sure how to use

Hey there,

thanks for your library. Since documentation is very limited maybe you can give me a hint of how to get going. I compile an run your c file this is the output I get:

Opened IPv4 socket for mDNS/DNS-SD
Sending DNS-SD discovery
Reading DNS-SD replies
192.168.0.30:5353 : answer PTR _rfb._tcp.local. type 12 rclass 0x1 ttl 10 length 12
192.168.0.30:5353 : answer PTR _smb._tcp.local. type 12 rclass 0x1 ttl 10 length 7
192.168.0.30:5353 : answer PTR _companion-link._tcp.local. type 12 rclass 0x1 ttl 10 length 18
Sending mDNS query
Reading mDNS replies
Closed socket
Program ended with exit code: 0

I was expecting that if I run the same command line app in the network I will get more replies in either Reading DNS-SD replies or Reading mDNS replies, but whatever I do I can't ever get a different result than what is seen above. I'm working on MacOS.

Johannes

Static code analysis warnings

Hi Matias, I got warnings from my static code analysis. I am fixing them on my side.
I was wondering if you can also fix them. (If i have access to push branches i can also do it)
Here are the warnings I get. The line number might be off by 1 or 2.

MdnsLib.h:1140:29: warning: Either the condition '!data' is redundant or there is overflow in pointer subtraction. [nullPointerArithmeticRedundantCheck]
size_t remain = capacity - MDNS_POINTER_DIFF(data, buffer);
^
MdnsLib.h:1141:6: note: Assuming that condition '!data' is not redundant
if (!data || (remain <= 4))
^
MdnsLib.h:1140:29: note: Null pointer subtraction
size_t remain = capacity - MDNS_POINTER_DIFF(data, buffer);
^
MdnsLib.h:1155:29: warning: Either the condition '!data' is redundant or there is overflow in pointer subtraction. [nullPointerArithmeticRedundantCheck]
size_t remain = capacity - MDNS_POINTER_DIFF(data, buffer);
^
MdnsLib.h:1156:6: note: Assuming that condition '!data' is not redundant
if (!data || (remain < 10))
^
MdnsLib.h:1155:29: note: Null pointer subtraction
size_t remain = capacity - MDNS_POINTER_DIFF(data, buffer);
^
MdnsLib.h:1248:23: warning: Either the condition '!data' is redundant or there is overflow in pointer subtraction. [nullPointerArithmeticRedundantCheck]
remain = capacity - MDNS_POINTER_DIFF(data, buffer);
^
MdnsLib.h:1249:7: note: Assuming that condition '!data' is not redundant
if (!data || (remain <= string_length) || (string_length > 0x3FFF))
^
MdnsLib.h:1248:23: note: Null pointer subtraction
remain = capacity - MDNS_POINTER_DIFF(data, buffer);
^
MdnsLib.h:709:9: style: The scope of the variable 'pos' can be reduced. [variableScope]
size_t pos = 0;
^
MdnsLib.h:1461:9: style: The scope of the variable 'separator' can be reduced. [variableScope]
size_t separator, sublength;
^
MdnsLib.h:1461:20: style: The scope of the variable 'sublength' can be reduced. [variableScope]
size_t separator, sublength;
^
MdnsLib.h:709:13: style: Variable 'pos' is assigned a value that is never used. [unreadVariable]
size_t pos = 0;

There is no ipv6 addr when i specify hostname

when i use command like ./mdns_example --service _airdrop._tcp.local. --port 8770 it works fine
but when i use ./mdns_example --service _airdrop._tcp.local. --port 8770 --hostname sddwswdd it will never answer AAAA record

SIGBUS while parsing AAAA record

This is quite weird as this issue only happen when I try to use mdns on my webOS TV. (Which is cross compiled with GCC 6.2.0). I made a patch to fix this crash, but it seems too weird so I'd like to create an issue instead of PR, to let you decide if this should be changed or not.

Crash site:

mdns/mdns.h

Line 1210 in 58b5d16

addr->sin6_addr = *(const struct in6_addr*)((const char*)buffer + offset);

Patch:

@@ -1207,7 +1207,7 @@ mdns_record_parse_aaaa(const void* buffer, size_t size, size_t offset, size_t le
        addr->sin6_len = sizeof(struct sockaddr_in6);
 #endif
        if ((size >= offset + length) && (length == 16))
-               addr->sin6_addr = *(const struct in6_addr*)((const char*)buffer + offset);
+               memcpy(&(addr->sin6_addr), ((const char*)buffer + offset), 16);
        return addr;
 }

Discovery and Query issues

Building the latest version makes devices respond correctly. But the software doesn't handle the query responses. The responses are observable in Wireshark, but not by the software

The only responses I'm getting is the response from the client which sends the discovery query. In other words it is only responding to itself with the services it has available.

Tried simple printf-debugging but couldn't find any clues at all. It seems like the responses aren't even acquired in the mdns_query_recv

memcpy safety

Replace all memcpy calls with memmove.
memcpy is unsafe in calls where memory may overlap. The safe alternative are the same calls with memmove.

Howto listen to changes after first query.

Hi,

implementing this library in my own project, I very much want to know howto listen to changes like a host (with dns services) is showing upp or removed for example.
A socket/fd for every interface has to be listning to this (and watched by an eventloop). And then?

Stef

Support for continuous multicast DNS querying

In the current implementation the querying is done one-shot, in mdns_query_send the transaction id is set and it is checked in mdns_query_recv if the matching response if for this transaction (one-shot multicast DNS queries).
The implementation should also permit for continuous multicast DNS querying in which mdns_query_recv does not check the transaction id and the application is responsible if more responses are required, more information here

DNS

Hello,first of all thanks for this great library! I have a question. How to access by domain name? Can you give me an example? thank you.

Extraction of records from multi-record answers

Hello,

first, i'm not sure if I'm doing something wrong or your code is intended to be used differently.

But as far as i can tell, if an answer to a query is received using mdns_discovery_recv in a while-loop, as in your example query_callback is called only once. However, I don't see a method to extract the information of other than the first record in that callback.

--service response not valid

I try to use a mdns query service request from an ESP32. But the response is not valid. I try to find in your the problem in your code. Do you have some hints?

User data in mdns_discovery_recv callback

Hello!
In the current implementation the callback called by mdns_discovery_recv does not permit to pass a pointer to a user data. I need this feature in order to aggregate all the DNS records which are being retrieved for an IP address.
Would you accept a pull request which implements this feature?

mdns_multiquery_send can run over the buffer

Line 1112 to 1115 of mdns.h is:

if (!data)
    return -1;
// Record type
data = mdns_htons(data, query[iq].type);
//! Optional unicast response based on local port, class IN
data = mdns_htons(data, rclass);

While !data is checked it can still be pointing very near the end of the buffer, and mdns_htons will write memcpy past the end of the buffer. It should have the same check that is used elsewhere

if (!data)
    return -1;
// Record type
size_t remain = capacity - MDNS_POINTER_DIFF(data, buffer);
if (remain < 4)
    return 0;
data = mdns_htons(data, query[iq].type);
//! Optional unicast response based on local port, class IN
data = mdns_htons(data, rclass);

Probable typo for IPv6 size in MacOS

When compiling on MacOS Catalina:

mdns/mdns.h:646:27: error: use of undeclared identifier 'saddr6'
                addr6.sin6_len = sizeof(saddr6);

It looks like

mdns/mdns.h

Line 646 in 7e1050d

addr6.sin6_len = sizeof(saddr6);

should be

addr6.sin6_len = sizeof(addr6);

Plans for a library.

Hi,

first many thanks for writing! My software

https://github.com/stefbon/OSNS

relies on avahi for detection of services. I've been looking for something else, without the dependencies.
mdns.c is one file, do you want to make a library? Otherwise I have to take out the functions myself I think are usefull,
and that is not the way to do it. Better is a public library.

Stef
the Netherlands

Theoretical Issue

Hi there,
Since apologies for posting a theoretical query here. Well, this is not exactly related to the stack, however, it is about mDNS.

I have a server on my system, and when i run it, it advertises its services through mDNS in the network.
The documentation says, the services are advertised using SRV records. However, I see PTR,TXT records as well.

Also, since it is advertising, is it not the case that, only response should be seen on wireshark. I see query and response as well. Please let me know.

Regards,
Rakshan

Multicast client answer should not be discarded when doing one-shot discovery

We noticed that this library detect less devices than avahi or gstreamer mdns library (libmicrodns). It appears that when doing one shot query, some devices respond with multicast even if unicast is requested in the query.

This is actually accepted by the RFC:

The most basic kind of Multicast DNS client may simply send standard
   DNS queries blindly to 224.0.0.251:5[3](https://www.rfc-editor.org/rfc/rfc6762.html#section-3)53, without necessarily even
   being aware of what a multicast address is.  This change can
   typically be implemented with just a few lines of code in an existing
   DNS resolver library.  If a name being queried falls within one of
   the reserved Multicast DNS domains (see Sections 3 and [4](https://www.rfc-editor.org/rfc/rfc6762.html#section-4)), then,
   rather than using the configured Unicast DNS server address, the
   query is instead sent to 224.0.0.251:5353 (or its IPv6 equivalent
   [FF02::FB]:5353).

However this is not supported by this library.

can't be compiled on centos 6.5 with gcc 4.4.7

  • ENV:

[wangya@localhost mdns-1.3]$ cat /proc/version
Linux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013

  • COMPILE METHOD:

[wangya@localhost mdns-1.3]$ gcc -o mdns mdns.c -std=c99
In file included from mdns.c:8:
mdns.h: In function ‘mdns_socket_setup_ipv4’:
mdns.h:311: error: storage size of ‘req’ isn’t known
mdns.h: In function ‘mdns_string_equal’:
mdns.h:505: warning: implicit declaration of function ‘strncasecmp’
mdns.c: In function ‘ipv4_address_to_string’:
mdns.c:43: error: ‘NI_MAXHOST’ undeclared (first use in this function)
mdns.c:43: error: (Each undeclared identifier is reported only once
mdns.c:43: error: for each function it appears in.)
mdns.c:44: error: ‘NI_MAXSERV’ undeclared (first use in this function)
mdns.c:45: warning: implicit declaration of function ‘getnameinfo’
mdns.c:46: error: ‘NI_NUMERICSERV’ undeclared (first use in this function)
mdns.c:46: error: ‘NI_NUMERICHOST’ undeclared (first use in this function)
mdns.c: In function ‘ipv6_address_to_string’:
mdns.c:65: error: ‘NI_MAXHOST’ undeclared (first use in this function)
mdns.c:66: error: ‘NI_MAXSERV’ undeclared (first use in this function)
mdns.c:68: error: ‘NI_NUMERICSERV’ undeclared (first use in this function)
mdns.c:68: error: ‘NI_NUMERICHOST’ undeclared (first use in this function)
mdns.c: In function ‘send_dns_sd’:
mdns.c:482: error: storage size of ‘timeout’ isn’t known
mdns.c:487: error: ‘fd_set’ undeclared (first use in this function)
mdns.c:487: error: expected ‘;’ before ‘readfs’
mdns.c:488: warning: implicit declaration of function ‘FD_ZERO’
mdns.c:488: error: ‘readfs’ undeclared (first use in this function)
mdns.c:492: warning: implicit declaration of function ‘FD_SET’
mdns.c:496: warning: implicit declaration of function ‘select’
mdns.c:499: warning: implicit declaration of function ‘FD_ISSET’
mdns.c: In function ‘send_mdns_query’:
mdns.c:544: error: storage size of ‘timeout’ isn’t known
mdns.c:549: error: ‘fd_set’ undeclared (first use in this function)
mdns.c:549: error: expected ‘;’ before ‘readfs’
mdns.c:550: error: ‘readfs’ undeclared (first use in this function)
mdns.c: In function ‘service_mdns’:
mdns.c:605: error: ‘fd_set’ undeclared (first use in this function)
mdns.c:605: error: expected ‘;’ before ‘readfs’
mdns.c:606: error: ‘readfs’ undeclared (first use in this function)
mdns.c: In function ‘main’:
mdns.c:660: warning: implicit declaration of function ‘gethostname’

Howto receive discovery and query answers at the same time?

Hi,

I'm using the library in my software, and so far it works very fine. I've added the network socket to send and receive the mdns messages with to an eventloop, and it works very good.

Now howto deal with a situation that one host has send a discovery answer and your server/host has send a query, and another host hasn't even send an answer to the discovery message. In my eventloop, to process a reply, for one message the function mdns_query_recv has to be used, for the other mdns_discovery_recv. How to know what to use (since you cannot know what the message is...)?

Use a sequence number per remote fromaddress (starting at zero), and when it's zero, it must be a discovery reply, in all other cases it's "normal" query?

Stef

Overflows when adding/subtracting user-provided lengths

I wonder if there's a risk of out-of-bounds write when reading user-provided sizes and offsets and doing arithmetic operations with them. In network-facing libraries that deal with potential unsanitized input, I've often seen checks for overflow, eg:

int safe_subtract(int x, int y, int *result) {
    if (y > 0 && x < INT_MIN + y) {
        // Underflow would occur
        return 0;
    } else if (y < 0 && x > INT_MAX + y) {
        // Overflow would occur
        return 0;
    } else {
        // Safe to subtract
        *result = x - y;
        return 1;
    }
}

Query multiple network interfaces

I'm using your library to discover IIO services in my networks. It works fine for just one interface, however it looks like mdns_query_send, only sends out the query to the last enumerated interface (as far as I got with my tests). I can confirm this behavior in WireShark.
I have several devices that emulate a network interface using a RNDIS driver and run a mDNS server on their interface. The goal is to find all the devices that implement this IIO service across all my interfaces (RNDIS or regular)

I'm running Windows 10 & MS Visual Studio 2019
For reference:
https://github.com/analogdevicesinc/libiio/blob/dnssd-windows/dns_sd_windows.c#L126

What is `service_port` and when is it used?

In the example code mdns.c, service_port is provided as an argument to service_mDNS. But I don't see it being bound to any socket. The only place, I see the port being used is in the SRV record sent along with the answer to a query.

As the mDNS service listens to queries on port 5353, what exactly should the service_port argument be?

provided demo is not easy to modify

When I want to register many services at the same time, what should i do to call your code? It's difficult to understand your code in short time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.