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

Public DNS-SD API for browsing, resolving, and publishing services #19

Closed
michaelrsweet opened this issue Aug 13, 2022 · 4 comments
Closed
Assignees
Labels
enhancement New feature or request priority-high
Milestone

Comments

@michaelrsweet
Copy link
Member

Currently the various bits of CUPS, PAPPL, etc. have a conditional mess of code that use the Avahi or mDNSResponder APIs to do DNS-SD discovery and sharing. This continues to be a major pain, and CUPS should have a common API that developers can use to access whatever the local API/service is for this. Goals:

  • Support the Avahi, mDNSResponder, and Win32 APIs, with potential for others (systemd/D-Bus) in the future
  • Support asynchronous browsing, resolution, and service publication with support for sub-types, domains, and LOC+TXT records
  • Provide callbacks as needed
  • Provide helper functions for renaming, getting the mDNS hostname, and getting/setting a list of DNS-SD domains
@michaelrsweet michaelrsweet self-assigned this Aug 13, 2022
@michaelrsweet michaelrsweet added enhancement New feature or request priority-high labels Aug 13, 2022
@michaelrsweet michaelrsweet added this to the v3.0 milestone Aug 13, 2022
@michaelrsweet
Copy link
Member Author

[dnssd d921af6] Initial skeleton of new DNS-SD API (Issue #19)

@michaelrsweet
Copy link
Member Author

The proposed API manages all DNS-SD requests/registrations on a separate thread represented by the cups_dnssd_t context structure/pointer. Deleting the DNS-SD context also deletes all pending requests/registrations. The semantics of the service API reflect Avahi's peculiar handling of services as part of a named group, but we can simulate that with mDNSResponder and WinDNS.

Create/destroy DNS-SD context:

void  cupsDNSSDDelete(cups_dnssd_t *dns);
cups_dnssd_t *cupsDNSSDNew(cups_dnssd_error_cb_t error_cb, void *cb_data);

Create/destroy browsing request:

void  cupsDNSSDBrowseDelete(cups_dnssd_browse_t *browser);
cups_dnssd_browse_t *cupsDNSSDBrowseNew(cups_dnssd_t *dns, uint32_t if_index, const char *types, const char *domains, cups_dnssd_browse_cb_t browse_cb, void *cb_data);

Create/destroy query request:

void  cupsDNSSDQueryDelete(cups_dnssd_query_t *query);
cups_dnssd_query_t *cupsDNSSDQueryNew(cups_dnssd_t *dns, uint32_t if_index, const char *types, const char *domains, cups_dnssd_query_cb_t query_cb, void *cb_data);

Create/restore resolve request:

void  cupsDNSSDResolveDelete(cups_dnssd_resolve_t *res);
cups_dnssd_resolve_t *cupsDNSSDResolveNew(cups_dnssd_t *dns, uint32_t if_index, const char *types, const char *domains, cups_dnssd_resolve_cb_t resolve_cb, void *cb_data);

Create/destroy named services. Each service has a name and one or more instances:

bool  cupsDNSSDServiceAdd(cups_dnssd_service_t *service, uint32_t if_index, const char *types, const char *domains, const char *host, uint16_t port, size_t num_txt, cups_option_t *txt);
void  cupsDNSSDServiceDelete(cups_dnssd_service_t *service);
cups_dnssd_service_t *cupsDNSSDServiceNew(cups_dnssd_t *dns, const char *name, cups_dnssd_service_cb_t cb, void *cb_data);
bool  cupsDNSSDServicePublish(cups_dnssd_service_t *service);
bool  cupsDNSSDServiceSetLocation(cups_dnssd_service_t *service, const char *geo_uri);

@michaelrsweet
Copy link
Member Author

Mostly done, just have the Windows DNS-SD APIs to support.

@michaelrsweet
Copy link
Member Author

Created #29 to track usage of the Windows DNS-SD APIs. Closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-high
Projects
Development

No branches or pull requests

1 participant