MCPcopy Create free account
hub / github.com/OpenPrinting/cups / resolve_callback

Function resolve_callback

tools/ippfind.c:2473–2550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2471
2472#ifdef HAVE_MDNSRESPONDER
2473static void DNSSD_API
2474resolve_callback(
2475 DNSServiceRef sdRef, /* I - Service reference */
2476 DNSServiceFlags flags, /* I - Data flags */
2477 uint32_t interfaceIndex, /* I - Interface */
2478 DNSServiceErrorType errorCode, /* I - Error, if any */
2479 const char *fullName, /* I - Full service name */
2480 const char *hostTarget, /* I - Hostname */
2481 uint16_t port, /* I - Port number (network byte order) */
2482 uint16_t txtLen, /* I - Length of TXT record data */
2483 const unsigned char *txtRecord, /* I - TXT record data */
2484 void *context) /* I - Service */
2485{
2486 char key[256], /* TXT key value */
2487 *value; /* Value from TXT record */
2488 const unsigned char *txtEnd; /* End of TXT record */
2489 uint8_t valueLen; /* Length of value */
2490 ippfind_srv_t *service = (ippfind_srv_t *)context;
2491 /* Service */
2492
2493
2494 last_update = _cupsGetClock();
2495
2496 /*
2497 * Only process "add" data...
2498 */
2499
2500 (void)sdRef;
2501 (void)flags;
2502 (void)interfaceIndex;
2503 (void)fullName;
2504
2505 if (errorCode != kDNSServiceErr_NoError)
2506 {
2507 _cupsLangPrintf(stderr, _("ippfind: Unable to browse or resolve: %s"),
2508 dnssd_error_string(errorCode));
2509 bonjour_error = 1;
2510 return;
2511 }
2512
2513 service->is_resolved = 1;
2514 service->host = strdup(hostTarget);
2515 service->port = ntohs(port);
2516
2517 value = service->host + strlen(service->host) - 1;
2518 if (value >= service->host && *value == '.')
2519 *value = '\0';
2520
2521 /*
2522 * Loop through the TXT key/value pairs and add them to an array...
2523 */
2524
2525 for (txtEnd = txtRecord + txtLen; txtRecord < txtEnd; txtRecord += valueLen)
2526 {
2527 /*
2528 * Ignore bogus strings...
2529 */
2530

Callers

nothing calls this directly

Calls 5

_cupsGetClockFunction · 0.85
_cupsLangPrintfFunction · 0.85
dnssd_error_stringFunction · 0.85
cupsAddOptionFunction · 0.85
set_service_uriFunction · 0.85

Tested by

no test coverage detected