Lines Matching +full:avahi +full:- +full:daemon
4 * Copyright © 2007-2018 by Apple Inc.
5 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
88 * 'cupsdDeregisterPrinter()' - Stop sending broadcast information for a
95 cupsd_printer_t *p, /* I - Printer to register */ in cupsdDeregisterPrinter()
96 int removeit) /* I - Printer being permanently removed */ in cupsdDeregisterPrinter()
103 "cupsdDeregisterPrinter(p=%p(%s), removeit=%d)", p, p->name, in cupsdDeregisterPrinter()
106 if (!Browsing || !p->shared || in cupsdDeregisterPrinter()
107 (p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_SCANNER))) in cupsdDeregisterPrinter()
122 * 'cupsdRegisterPrinter()' - Start sending broadcast information for a
127 cupsdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ in cupsdRegisterPrinter()
130 p->name); in cupsdRegisterPrinter()
133 (p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_SCANNER))) in cupsdRegisterPrinter()
144 * 'cupsdStartBrowsing()' - Start sending and receiving broadcast information.
167 "Unable to create master DNS-SD reference: %d", error); in cupsdStartBrowsing()
195 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create DNS-SD thread."); in cupsdStartBrowsing()
209 "Unable to communicate with avahi-daemon: %s", in cupsdStartBrowsing()
246 * 'cupsdStopBrowsing()' - Stop sending and receiving broadcast information.
257 * De-register the individual printers in cupsdStopBrowsing()
284 * 'cupsdUpdateDNSSDName()' - Update the computer name we use for browsing...
296 * 'dnssdAddAlias()' - Add a DNS-SD alias name.
300 dnssdAddAlias(const void *key, /* I - Key */ in dnssdAddAlias()
301 const void *value, /* I - Value (domain) */ in dnssdAddAlias()
302 void *context) /* I - Unused */ in dnssdAddAlias()
317 hostptr = hostname + strlen(hostname) - 1; in dnssdAddAlias()
336 * 'dnssdBuildTxtRecord()' - Build a TXT record from printer info.
339 static cupsd_txt_t /* O - TXT record */
341 cupsd_printer_t *p, /* I - Printer information */ in dnssdBuildTxtRecord()
342 int for_lpd) /* I - 1 = LPD, 0 = IPP */ in dnssdBuildTxtRecord()
351 air_str[1024], /* auth-info-required string buffer */ in dnssdBuildTxtRecord()
376 strlcpy(rp_str, p->name, sizeof(rp_str)); in dnssdBuildTxtRecord()
379 (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers", in dnssdBuildTxtRecord()
380 p->name); in dnssdBuildTxtRecord()
383 keyvalue[count++][1] = p->make_model ? p->make_model : "Unknown"; in dnssdBuildTxtRecord()
395 if ((ptr = DNSSDHostName + strlen(DNSSDHostName) - 1) >= DNSSDHostName && *ptr == '.') in dnssdBuildTxtRecord()
416 if (lis->encryption != HTTP_ENCRYPTION_NEVER) in dnssdBuildTxtRecord()
424 …, NULL, admin_hostname, DNSSDPort, "/%s/%s", (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printe… in dnssdBuildTxtRecord()
428 if (p->location) in dnssdBuildTxtRecord()
431 keyvalue[count++][1] = p->location; in dnssdBuildTxtRecord()
438 keyvalue[count++][1] = p->pc && p->pc->product ? p->pc->product : "Unknown"; in dnssdBuildTxtRecord()
441 keyvalue[count++][1] = p->pdl ? p->pdl : "application/postscript"; in dnssdBuildTxtRecord()
450 keyvalue[count++][1] = p->uuid + 9; in dnssdBuildTxtRecord()
457 if (p->type & CUPS_PRINTER_FAX) in dnssdBuildTxtRecord()
465 if (p->type & CUPS_PRINTER_COLOR) in dnssdBuildTxtRecord()
468 keyvalue[count++][1] = (p->type & CUPS_PRINTER_COLOR) ? "T" : "F"; in dnssdBuildTxtRecord()
471 if (p->type & CUPS_PRINTER_DUPLEX) in dnssdBuildTxtRecord()
474 keyvalue[count++][1] = (p->type & CUPS_PRINTER_DUPLEX) ? "T" : "F"; in dnssdBuildTxtRecord()
477 if (p->type & CUPS_PRINTER_STAPLE) in dnssdBuildTxtRecord()
480 keyvalue[count++][1] = (p->type & CUPS_PRINTER_STAPLE) ? "T" : "F"; in dnssdBuildTxtRecord()
483 if (p->type & CUPS_PRINTER_COPIES) in dnssdBuildTxtRecord()
486 keyvalue[count++][1] = (p->type & CUPS_PRINTER_COPIES) ? "T" : "F"; in dnssdBuildTxtRecord()
489 if (p->type & CUPS_PRINTER_COLLATE) in dnssdBuildTxtRecord()
492 keyvalue[count++][1] = (p->type & CUPS_PRINTER_COLLATE) ? "T" : "F"; in dnssdBuildTxtRecord()
495 if (p->type & CUPS_PRINTER_PUNCH) in dnssdBuildTxtRecord()
498 keyvalue[count++][1] = (p->type & CUPS_PRINTER_PUNCH) ? "T" : "F"; in dnssdBuildTxtRecord()
501 if (p->type & CUPS_PRINTER_BIND) in dnssdBuildTxtRecord()
504 keyvalue[count++][1] = (p->type & CUPS_PRINTER_BIND) ? "T" : "F"; in dnssdBuildTxtRecord()
507 if (p->type & CUPS_PRINTER_SORT) in dnssdBuildTxtRecord()
510 keyvalue[count++][1] = (p->type & CUPS_PRINTER_SORT) ? "T" : "F"; in dnssdBuildTxtRecord()
513 if (p->type & CUPS_PRINTER_MFP) in dnssdBuildTxtRecord()
516 keyvalue[count++][1] = (p->type & CUPS_PRINTER_MFP) ? "T" : "F"; in dnssdBuildTxtRecord()
519 snprintf(type_str, sizeof(type_str), "0x%X", p->type | CUPS_PRINTER_REMOTE); in dnssdBuildTxtRecord()
520 snprintf(state_str, sizeof(state_str), "%d", p->state); in dnssdBuildTxtRecord()
522 keyvalue[count ][0] = "printer-state"; in dnssdBuildTxtRecord()
525 keyvalue[count ][0] = "printer-type"; in dnssdBuildTxtRecord()
556 * 'dnssdClientCallback()' - Client callback for Avahi.
563 AvahiClient *c, /* I - Client */ in dnssdClientCallback()
564 AvahiClientState state, /* I - Current state */ in dnssdClientCallback()
565 void *userdata) /* I - User data (unused) */ in dnssdClientCallback()
589 …cupsdLogMessage(CUPSD_LOG_DEBUG, "Avahi server connection now available, registering printers for … in dnssdClientCallback()
592 * Mark that Avahi server is running... in dnssdClientCallback()
614 …cupsdLogMessage(CUPSD_LOG_DEBUG, "Avahi server disappeared, unregistering printers for Bonjour bro… in dnssdClientCallback()
626 * Mark that Avahi server is not running... in dnssdClientCallback()
632 * Renew Avahi client... in dnssdClientCallback()
639 …cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to communicate with avahi-daemon: %s", dnssdErrorString(e… in dnssdClientCallback()
646 …cupsdLogMessage(CUPSD_LOG_ERROR, "Communication with avahi-daemon has failed: %s", avahi_strerror(… in dnssdClientCallback()
660 * 'dnssdDeregisterAllPrinters()' - Deregister all printers.
665 int from_callback) /* I - Deregistering because of callback? */ in dnssdDeregisterAllPrinters()
676 if (!(p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_SCANNER))) in dnssdDeregisterAllPrinters()
682 * 'dnssdDeregisterInstance()' - Deregister a DNS-SD service instance.
687 cupsd_srv_t *srv, /* I - Service */ in dnssdDeregisterInstance()
688 int from_callback) /* I - Called from callback? */ in dnssdDeregisterInstance()
717 * 'dnssdDeregisterPrinter()' - Deregister all services for a printer.
722 cupsd_printer_t *p, /* I - Printer */ in dnssdDeregisterPrinter()
723 int clear_name, /* I - Clear the name? */ in dnssdDeregisterPrinter()
724 int from_callback) /* I - Called from callback? */ in dnssdDeregisterPrinter()
728 "dnssdDeregisterPrinter(p=%p(%s), clear_name=%d)", p, p->name, in dnssdDeregisterPrinter()
731 if (p->ipp_srv) in dnssdDeregisterPrinter()
733 dnssdDeregisterInstance(&p->ipp_srv, from_callback); in dnssdDeregisterPrinter()
737 dnssdDeregisterInstance(&p->ipps_srv, from_callback); in dnssdDeregisterPrinter()
739 dnssdDeregisterInstance(&p->printer_srv, from_callback); in dnssdDeregisterPrinter()
744 * Remove the printer from the array of DNS-SD printers but keep the in dnssdDeregisterPrinter()
755 cupsdClearString(&p->reg_name); in dnssdDeregisterPrinter()
760 * 'dnssdErrorString()' - Return an error string for an error code.
763 static const char * /* O - Error message */
764 dnssdErrorString(int error) /* I - Error number */ in dnssdErrorString()
834 return ("Unable to traverse double-NAT boundary."); in dnssdErrorString()
846 return ("Transient error occurred - please try again."); in dnssdErrorString()
852 return ("NAT doesn't support NAT-PMP or UPnP."); in dnssdErrorString()
855 return ("NAT supports NAT-PNP or UPnP but it is disabled."); in dnssdErrorString()
874 * 'dnssdRegisterCallback()' - Free a TXT record.
878 dnssdFreeTxtRecord(cupsd_txt_t *txt) /* I - TXT record */ in dnssdFreeTxtRecord()
891 * 'dnssdRegisterAllPrinters()' - Register all printers.
895 dnssdRegisterAllPrinters(int from_callback) /* I - Called from callback? */ in dnssdRegisterAllPrinters()
906 if (!(p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_SCANNER))) in dnssdRegisterAllPrinters()
912 * 'dnssdRegisterCallback()' - DNSServiceRegister callback.
918 DNSServiceRef sdRef, /* I - DNS Service reference */ in dnssdRegisterCallback()
919 DNSServiceFlags flags, /* I - Reserved for future use */ in dnssdRegisterCallback()
920 DNSServiceErrorType errorCode, /* I - Error code */ in dnssdRegisterCallback()
921 const char *name, /* I - Service name */ in dnssdRegisterCallback()
922 const char *regtype, /* I - Service type */ in dnssdRegisterCallback()
923 const char *domain, /* I - Domain. ".local" for now */ in dnssdRegisterCallback()
924 void *context) /* I - Printer */ in dnssdRegisterCallback()
935 name, regtype, p ? p->name : "Web Interface", in dnssdRegisterCallback()
936 p ? (p->reg_name ? p->reg_name : "(null)") : "NA"); in dnssdRegisterCallback()
944 else if (p && (!p->reg_name || _cups_strcasecmp(name, p->reg_name))) in dnssdRegisterCallback()
947 name, p->name); in dnssdRegisterCallback()
950 cupsdSetString(&p->reg_name, name); in dnssdRegisterCallback()
960 AvahiEntryGroup *srv, /* I - Service */ in dnssdRegisterCallback()
961 AvahiEntryGroupState state, /* I - Registration state */ in dnssdRegisterCallback()
962 void *context) /* I - Printer */ in dnssdRegisterCallback()
970 p ? p->name : "Web Interface", in dnssdRegisterCallback()
971 p ? (p->reg_name ? p->reg_name : "(null)") : "NA"); in dnssdRegisterCallback()
973 /* TODO: Handle collisions with avahi_alternate_service_name(p->reg_name)? */ in dnssdRegisterCallback()
979 * 'dnssdRegisterInstance()' - Register an instance of a printer service.
982 static int /* O - 1 on success, 0 on failure */
984 cupsd_srv_t *srv, /* O - Service */ in dnssdRegisterInstance()
985 cupsd_printer_t *p, /* I - Printer */ in dnssdRegisterInstance()
986 char *name, /* I - DNS-SD service name */ in dnssdRegisterInstance()
987 const char *type, /* I - DNS-SD service type */ in dnssdRegisterInstance()
988 const char *subtypes, /* I - Subtypes to register or NULL */ in dnssdRegisterInstance()
989 int port, /* I - Port number or 0 */ in dnssdRegisterInstance()
990 cupsd_txt_t *txt, /* I - TXT record */ in dnssdRegisterInstance()
991 int commit, /* I - Commit registration? */ in dnssdRegisterInstance()
992 int from_callback) /* I - Called from callback? */ in dnssdRegisterInstance()
1003 cupsdLogMessage(CUPSD_LOG_DEBUG, "Registering \"%s\" with DNS-SD type \"%s\".", name, type); in dnssdRegisterInstance()
1013 srv = &p->printer_srv; /* Target LPD service */ in dnssdRegisterInstance()
1016 srv = &p->ipps_srv; /* Target IPPS service */ in dnssdRegisterInstance()
1019 srv = &p->ipp_srv; /* Target IPP service */ in dnssdRegisterInstance()
1022 srv = &p->ipp_srv; /* Target service group */ in dnssdRegisterInstance()
1040 cupsdLogMessage(CUPSD_LOG_WARN, "DNS-SD registration of \"%s\" failed: %s", in dnssdRegisterInstance()
1048 * properly truncate any UTF-8 characters... in dnssdRegisterInstance()
1052 while ((ptr - name) > 63) in dnssdRegisterInstance()
1056 ptr --; in dnssdRegisterInstance()
1085 for (temptxt = *txt; temptxt; temptxt = temptxt->next) in dnssdRegisterInstance()
1086 cupsdLogMessage(CUPSD_LOG_DEBUG, "DNS_SD \"%s\" %s", name, temptxt->text); in dnssdRegisterInstance()
1094 cupsdLogMessage(CUPSD_LOG_DEBUG, "DNS-SD service add for \"%s\" failed.", in dnssdRegisterInstance()
1141 "DNS-SD subtype %s registration for \"%s\" failed." , in dnssdRegisterInstance()
1151 cupsdLogMessage(CUPSD_LOG_DEBUG, "DNS-SD commit of \"%s\" failed.", in dnssdRegisterInstance()
1161 cupsdLogMessage(CUPSD_LOG_WARN, "DNS-SD registration of \"%s\" failed: %s", in dnssdRegisterInstance()
1163 cupsdLogMessage(CUPSD_LOG_DEBUG, "DNS-SD type: %s", type); in dnssdRegisterInstance()
1165 cupsdLogMessage(CUPSD_LOG_DEBUG, "DNS-SD sub-types: %s", subtypes); in dnssdRegisterInstance()
1173 * 'dnssdRegisterPrinter()' - Start sending broadcast information for a printer
1179 cupsd_printer_t *p, /* I - Printer */ in dnssdRegisterPrinter()
1180 int from_callback) /* I - Called from callback? */ in dnssdRegisterPrinter()
1189 cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name, in dnssdRegisterPrinter()
1190 !p->ipp_srv ? "new" : "update"); in dnssdRegisterPrinter()
1199 * per-printer sharing was just disabled... in dnssdRegisterPrinter()
1204 if (!p->shared) in dnssdRegisterPrinter()
1209 * "<printer-info> @ <computer name>"... in dnssdRegisterPrinter()
1212 if (!p->reg_name) in dnssdRegisterPrinter()
1214 if (p->info && strlen(p->info) > 0) in dnssdRegisterPrinter()
1217 snprintf(name, sizeof(name), "%s @ %s", p->info, DNSSDComputerName); in dnssdRegisterPrinter()
1219 strlcpy(name, p->info, sizeof(name)); in dnssdRegisterPrinter()
1222 snprintf(name, sizeof(name), "%s @ %s", p->name, DNSSDComputerName); in dnssdRegisterPrinter()
1224 strlcpy(name, p->name, sizeof(name)); in dnssdRegisterPrinter()
1227 strlcpy(name, p->reg_name, sizeof(name)); in dnssdRegisterPrinter()
1233 * our name, but use port number 0 if we haven't actually configured cups-lpd in dnssdRegisterPrinter()
1255 * Use the "_fax-ipp" service type for fax queues, otherwise use "_ipp"... in dnssdRegisterPrinter()
1258 if (p->type & CUPS_PRINTER_FAX) in dnssdRegisterPrinter()
1259 …status = dnssdRegisterInstance(NULL, p, name, "_fax-ipp._tcp", DNSSDSubTypes, DNSSDPort, &ipp_txt,… in dnssdRegisterPrinter()
1270 * Save the registered name and add the printer to the array of DNS-SD in dnssdRegisterPrinter()
1274 cupsdSetString(&p->reg_name, name); in dnssdRegisterPrinter()
1283 dnssdDeregisterInstance(&p->ipp_srv, from_callback); in dnssdRegisterPrinter()
1287 dnssdDeregisterInstance(&p->ipps_srv, from_callback); in dnssdRegisterPrinter()
1289 dnssdDeregisterInstance(&p->printer_srv, from_callback); in dnssdRegisterPrinter()
1296 * 'dnssdStop()' - Stop all DNS-SD registrations.
1306 * De-register the individual printers in dnssdStop()
1352 * 'dnssdUpdate()' - Handle DNS-SD queries.
1373 * 'dnssdUpdateDNSSDName()' - Update the listen port, computer name, and web interface registration.
1377 dnssdUpdateDNSSDName(int from_callback) /* I - Called from callback? */ in dnssdUpdateDNSSDName()
1382 CFDictionaryRef btmm; /* Back-to-My-Mac domains */ in dnssdUpdateDNSSDName()
1385 char nameBuffer[1024]; /* C-string buffer */ in dnssdUpdateDNSSDName()
1390 * Only share the web interface and printers when non-local listening is in dnssdUpdateDNSSDName()
1398 * non-local ports, there is no sense sharing local printers via Bonjour... in dnssdUpdateDNSSDName()
1407 if (httpAddrLocalhost(&(lis->address))) in dnssdUpdateDNSSDName()
1410 DNSSDPort = httpAddrPort(&(lis->address)); in dnssdUpdateDNSSDName()
1419 * Get the computer name as a c-string... in dnssdUpdateDNSSDName()
1495 * Get any Back-to-My-Mac domains and add them as aliases... in dnssdUpdateDNSSDName()
1576 * 'get_auth_info_required()' - Get the auth-info-required value to advertise.
1579 static char * /* O - String or NULL if none */
1581 cupsd_printer_t *p, /* I - Printer */ in get_auth_info_required()
1582 char *buffer, /* I - Value buffer */ in get_auth_info_required()
1583 size_t bufsize) /* I - Size of value buffer */ in get_auth_info_required()
1590 * If auth-info-required is set for this printer, return that... in get_auth_info_required()
1593 if (p->num_auth_info_required > 0 && strcmp(p->auth_info_required[0], "none")) in get_auth_info_required()
1598 for (i = 0, bufptr = buffer; i < p->num_auth_info_required; i ++) in get_auth_info_required()
1600 if (bufptr >= (buffer + bufsize - 2)) in get_auth_info_required()
1606 strlcpy(bufptr, p->auth_info_required[i], bufsize - (size_t)(bufptr - buffer)); in get_auth_info_required()
1617 if (p->type & CUPS_PRINTER_CLASS) in get_auth_info_required()
1618 snprintf(resource, sizeof(resource), "/classes/%s", p->name); in get_auth_info_required()
1620 snprintf(resource, sizeof(resource), "/printers/%s", p->name); in get_auth_info_required()
1623 auth->type == CUPSD_AUTH_NONE) in get_auth_info_required()
1624 auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB); in get_auth_info_required()
1630 if ((auth_type = auth->type) == CUPSD_AUTH_DEFAULT) in get_auth_info_required()
1657 * 'get_hostconfig()' - Get an /etc/hostconfig service setting.
1660 static int /* O - 1 for YES or AUTOMATIC, 0 for NO */
1661 get_hostconfig(const char *name) /* I - Name of service */ in get_hostconfig()
1690 * Found the service, see if it is set to "-NO-"... in get_hostconfig()
1693 if (!_cups_strncasecmp(ptr, "-NO-", 4)) in get_hostconfig()
1708 * 'update_lpd()' - Update the LPD configuration as needed.
1712 update_lpd(int onoff) /* - 1 = turn on, 0 = turn off */ in update_lpd()
1720 * setting for backwards-compatibility. in update_lpd()
1730 * Enable/disable LPD via the xinetd.d config file for cups-lpd... in update_lpd()
1733 char newfile[1024]; /* New cups-lpd.N file */ in update_lpd()
1743 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"%s\" - %s", in update_lpd()
1750 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create \"%s\" - %s", in update_lpd()
1757 * Copy all of the lines from the cups-lpd file... in update_lpd()
1791 argv[2] = (char *)"-w"; in update_lpd()
1795 cupsdStartProcess("/bin/launchctl", argv, envp, -1, -1, -1, -1, -1, 1, in update_lpd()
1805 * 'update_smb()' - Update the SMB configuration as needed.
1809 update_smb(int onoff) /* I - 1 = turn on, 0 = turn off */ in update_smb()
1831 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"%s\" - %s", in update_smb()
1838 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create \"%s\" - %s", in update_smb()