OpenPrinting / libcups

OpenPrinting CUPS Library Sources
https://openprinting.github.io/cups/cups3.html
Apache License 2.0
27 stars 15 forks source link

Wrong port number is reported by Bonjour \"service_uri\" on MacOS" #30

Closed sahusara closed 1 year ago

sahusara commented 1 year ago

In MacOS with MDNSRESPONDER, DNSServiceRegister API takes port number argument in "Network Byte Order". But in dnssd.c port number is pass in "Host Byte Order", because of which ippserver or ippeveprinter from https://github.com/istopwg/ippsample are advertising wrong port number through bonjour service.

It works fine in Ubuntu Linux, which is using Avahi.

In below picture's left terminal ippserver is run with port number 8631, in right terminal ippfind tool is used to find the "test printer" which is reporting 46881 as port number in service_uri. 46881 is in host byte order, converting it to network byte order will give 8631.

image

Please let me know if additional information is required for this pull request.

michaelrsweet commented 1 year ago

Thanks! Also added some more unit tests to catch this kind of error in the future.