troglobit / mdnsd

Jeremie Miller's original mdnsd
BSD 3-Clause "New" or "Revised" License
56 stars 35 forks source link

Add support for IPv6 #10

Open troglobit opened 6 years ago

troglobit commented 6 years ago

... should be fairly simple actually. Replace all the relevant parts of the code with struct sockaddr_storage

Muddasir-Shakil commented 2 years ago

Hello, is there any support for IPv6? Thank you .

troglobit commented 2 years ago

Hi! No that's why we keep this issue open :-)

IPv6 is targeted at v1.0, as hinted by the milestone on the right-hand side of this report.

fzs commented 2 years ago

I notice that currently only one (IPv4) address is supported per interface. The interface list is indexed by interface name, which allows for only one entry per interface, When adding IPv6 support, you will get multiple ifaddr elements with the same interface name (like when having multiple IPv4 addresses on one interface). Is the limitation to one address by design? Would you consider an interface with an IPv4 and an IPv6 address as two separate entries in the iface list, each with their own mdns_daemen_t instance?

troglobit commented 2 years ago

No, it's not by design. I've noticed this too, but not had time to look into it myself. Not sure yet what's the best approach, I'm open to ideas, even half baked RFC type pull requests are sometimes easier to discuss concepts around and prototype with.

fzs commented 2 years ago

Then I would probably for now ignore multiple IPv4 addresses on an interface, and check for interface name and address family, so that one iface per interface is created for IPv4 and IPv6 each.

troglobit commented 2 years ago

Sounds like a reasonable approach in the short-term, yes.

fzs commented 2 years ago

Well, my reasoning is that it needs separate iface instances for IPv4 and IPv6, because they are different address families. Having separate mdns_daemon_t instances should make the code easier. Since the daemon listens for multicast packages, it will receive the packet no matter what logical IPv4 net the sender is in on that interface's network. So the only question is which address to announce for a service and which address is used as the source address when sending an answer. (Not as easy for mquery.) I see that avahi decided to only use one address for a multi-homed interface, so I reckon this could be a good first approach, when adding IPv6 support.

Muddasir-Shakil commented 2 years ago

hi @fzs thanks for taking this over. I added ipv6 support to the one of the fork of mdnsd. You can find my work here mdnsdipv6. The goal was to support ipv6 in open62541 (OPC UA stack) for mdns discovery. I hope this also helps. The integration of ipv6 is done here.

troglobit commented 2 years ago

@fzs yeah I've been looking at the options myself, and really wanted to improve on things in this regard. Small incremental steps in the direction of where we want to go is better than a huge overhaul. If you want to take the lead on that it would be great!

@Muddasir-Shakil awesome, thank you for the input!

fzs commented 2 years ago

@Muddasir-Shakil , I did see your PR. I was a bit puzzled because we had to do quite a bit more changes to add IPv6 support than what I saw in your commits. I'm currently going over the code an adding in our changes, keeping yours in mind.

fzs commented 2 years ago

I am rethinking this. I would like to be able to send A and AAAA responses both over IPv4 and IPv6. So an interface that has an IPv4 and a IPv6 address should be able to be announced in one IPv4 mDNS response. Therefore a mdnsd instance would need to know both addresses.

I would currently still start with ignoring multiple addresses of the same address family, but add an struct in6_addr member to the mdnsd struct. I am not sure yet how to set both addresses when an interface has both assigned. I still think it makes sense to have separate mdnsd instances for the two address families in order to make socket handling easier. Just that each instance knows both the IPv4 and IPv6 address as an attribute so that they can both be added to responses.

troglobit commented 2 years ago

Hmm, yeah that sounds like a good idea ... I think. What does avahi do?

fzs commented 2 years ago

Uh, good question. I traced mDNS traffic from my iPhone and iPad, and saw that they will send A and AAAA records in mDNS responses over IPv4 (and IPv6).