Lines Matching refs:request
93 typedef void (*req_termination_fn)(request_state *request);
100 request_state *request; member
112 request_state *request; member
358 … reply_state *create_reply(const reply_op_t op, const size_t datalen, request_state *const request) in create_reply() argument
379 reply->mhdr->client_context = request->hdr.client_context; in create_reply()
400 …request_state *const request, reply_state **const rep, reply_op_t op, DNSServiceFlags flags, mStat… in GenerateNTDResponse() argument
428 *rep = create_reply(op, len, request); in GenerateNTDResponse()
446 …request_state *const request, reply_state **const rep, reply_op_t op, DNSServiceFlags flags, mStat… in GenerateBonjourBrowserResponse() argument
471 *rep = create_reply(op, len, request); in GenerateBonjourBrowserResponse()
486 mDNSlocal AuthRecord *read_rr_from_ipc_msg(request_state *request, int GetTTL, int validate_flags) in read_rr_from_ipc_msg() argument
488 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in read_rr_from_ipc_msg()
489 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in read_rr_from_ipc_msg()
491 int str_err = get_string(&request->msgptr, request->msgend, name, sizeof(name)); in read_rr_from_ipc_msg()
492 mDNSu16 type = get_uint16(&request->msgptr, request->msgend); in read_rr_from_ipc_msg()
493 mDNSu16 class = get_uint16(&request->msgptr, request->msgend); in read_rr_from_ipc_msg()
494 mDNSu16 rdlen = get_uint16(&request->msgptr, request->msgend); in read_rr_from_ipc_msg()
495 const char *rdata = get_rdata (&request->msgptr, request->msgend, rdlen); in read_rr_from_ipc_msg()
496 mDNSu32 ttl = GetTTL ? get_uint32(&request->msgptr, request->msgend) : 0; in read_rr_from_ipc_msg()
502 request->flags = flags; in read_rr_from_ipc_msg()
506 if (!request->msgptr) { LogMsg("Error reading Resource Record from client"); return NULL; } in read_rr_from_ipc_msg()
574 mDNSlocal mDNSBool AuthorizedDomain(const request_state * const request, const domainname * const d…
581 if (SystemUID(request->uid)) return mDNStrue;
593 allow = (allow || (delem->uid == request->uid));
614 if (mDNSIPPortIsZero(instance->request->u.servicereg.port)) in external_start_advertising_helper()
630 for ( i = 0; i < instance->request->u.servicereg.num_subtypes; i++) in external_start_advertising_helper()
652 for ( i = 0; i < instance->request->u.servicereg.num_subtypes; i++) in external_stop_advertising_helper()
691 if (srv->request) in unlink_and_free_service_instance()
693 service_instance **p = &srv->request->u.servicereg.instances; in unlink_and_free_service_instance()
749 …if (GenerateNTDResponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, instance->request… in SendServiceRemovalNotification()
750 …erviceRemovalNotification: %##s is not valid DNS-SD SRV name", instance->request->sd, srs->RR_SRV.… in SendServiceRemovalNotification()
751 else { append_reply(instance->request, rep); instance->clientnotified = mDNSfalse; } in SendServiceRemovalNotification()
770 if (instance->request && in regservice_callback()
771 instance->request->u.servicereg.default_domain && in regservice_callback()
783 if (instance->request) mDNS_snprintf(prefix, sizeof(prefix), "%3d:", instance->request->sd); in regservice_callback()
788 …if (!instance->request && result != mStatus_MemFree) { LogMsg("regservice_callback: instance->requ… in regservice_callback()
792 if (instance->request->u.servicereg.allowremotequery) in regservice_callback()
802 …ponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, instance->request, &rep, reg_servic… in regservice_callback()
803 …LogMsg("%3d: regservice_callback: %##s is not valid DNS-SD SRV name", instance->request->sd, srs->… in regservice_callback()
804 else { append_reply(instance->request, rep); instance->clientnotified = mDNStrue; } in regservice_callback()
806 …request->u.servicereg.InterfaceID == mDNSInterface_P2P || (!instance->request->u.servicereg.Interf… in regservice_callback()
811 if (instance->request->u.servicereg.autoname && CountPeerRegistrations(m, srs) == 0) in regservice_callback()
816 if (instance->request && instance->renameonmemfree) in regservice_callback()
820 err = mDNS_RenameAndReregisterService(m, srs, &instance->request->u.servicereg.name); in regservice_callback()
829 if (instance->request->u.servicereg.autorename) in regservice_callback()
832 if (instance->request->u.servicereg.autoname && CountPeerRegistrations(m, srs) == 0) in regservice_callback()
848 …ponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, instance->request, &rep, reg_servic… in regservice_callback()
849 …LogMsg("%3d: regservice_callback: %##s is not valid DNS-SD SRV name", instance->request->sd, srs->… in regservice_callback()
850 else { append_reply(instance->request, rep); instance->clientnotified = mDNStrue; } in regservice_callback()
859 …ponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, instance->request, &rep, reg_servic… in regservice_callback()
860 …LogMsg("%3d: regservice_callback: %##s is not valid DNS-SD SRV name", instance->request->sd, srs->… in regservice_callback()
861 else { append_reply(instance->request, rep); instance->clientnotified = mDNStrue; } in regservice_callback()
888 request_state *request = re->request; in regrecord_callback() local
896 LogOperation(fmt, request->sd, re->key, RRDisplayString(m, &rr->resrec), result); in regrecord_callback()
902 reply_state *reply = create_reply(reg_record_reply_op, len, request); in regrecord_callback()
907 append_reply(request, reply); in regrecord_callback()
913 registered_record_entry **ptr = &request->u.reg_recs; in regrecord_callback()
924 …face_P2P || (!re->origInterfaceID && IsLocalDomain(&rr->namestorage) && (request->flags & kDNSServ… in regrecord_callback()
934 mDNSlocal void connection_termination(request_state *request) in connection_termination() argument
940 LogOperation("%3d: DNSServiceCreateConnection STOP", request->sd); in connection_termination()
944 if ((*req)->primary == request) in connection_termination()
958 while (request->u.reg_recs) in connection_termination()
960 registered_record_entry *ptr = request->u.reg_recs; in connection_termination()
961 …LogOperation("%3d: DNSServiceRegisterRecord(%u %s) STOP", request->sd, ptr->key, RRDisplayString(&… in connection_termination()
962 request->u.reg_recs = request->u.reg_recs->next; in connection_termination()
974 mDNSlocal void handle_cancel_request(request_state *request) in handle_cancel_request() argument
977 …LogOperation("%3d: Cancel %08X %08X", request->sd, request->hdr.client_context.u32[1], request->hd… in handle_cancel_request()
980 if ((*req)->primary == request && in handle_cancel_request()
981 (*req)->hdr.client_context.u32[0] == request->hdr.client_context.u32[0] && in handle_cancel_request()
982 (*req)->hdr.client_context.u32[1] == request->hdr.client_context.u32[1]) in handle_cancel_request()
995 mDNSlocal mStatus handle_regrecord_request(request_state *request) in handle_regrecord_request() argument
998 AuthRecord *rr = read_rr_from_ipc_msg(request, 1, 1); in handle_regrecord_request()
1014 re->key = request->hdr.reg_index; in handle_regrecord_request()
1016 re->regrec_client_context = request->hdr.client_context; in handle_regrecord_request()
1017 re->request = request; in handle_regrecord_request()
1025 …if (!AuthorizedDomain(request, rr->resrec.name, AutoRegistrationDomains)) return (mStatus_NoError); in handle_regrecord_request()
1030 …LogOperation("%3d: DNSServiceRegisterRecord(%u %s) START", request->sd, re->key, RRDisplayString(&… in handle_regrecord_request()
1034 …LogOperation("%3d: DNSServiceRegisterRecord(%u %s) ERROR (%d)", request->sd, re->key, RRDisplayStr… in handle_regrecord_request()
1040 re->next = request->u.reg_recs; in handle_regrecord_request()
1041 request->u.reg_recs = re; in handle_regrecord_request()
1049 mDNSlocal void regservice_termination_callback(request_state *request) in regservice_termination_callback() argument
1051 if (!request) { LogMsg("regservice_termination_callback context is NULL"); return; } in regservice_termination_callback()
1052 while (request->u.servicereg.instances) in regservice_termination_callback()
1054 service_instance *p = request->u.servicereg.instances; in regservice_termination_callback()
1055 request->u.servicereg.instances = request->u.servicereg.instances->next; in regservice_termination_callback()
1058 request->sd, p->srs.RR_SRV.resrec.name->c, mDNSVal16(p->srs.RR_SRV.resrec.rdata->u.srv.port)); in regservice_termination_callback()
1067 p->request = NULL; in regservice_termination_callback()
1071 if (request->u.servicereg.txtdata) in regservice_termination_callback()
1072 …{ freeL("service_info txtdata", request->u.servicereg.txtdata); request->u.servicereg.txtdata = NU… in regservice_termination_callback()
1073 if (request->u.servicereg.autoname) in regservice_termination_callback()
1076 request->u.servicereg.autoname = mDNSfalse; in regservice_termination_callback()
1081 mDNSlocal request_state *LocateSubordinateRequest(request_state *request) in LocateSubordinateRequest() argument
1085 if (req->primary == request && in LocateSubordinateRequest()
1086 req->hdr.client_context.u32[0] == request->hdr.client_context.u32[0] && in LocateSubordinateRequest()
1087 req->hdr.client_context.u32[1] == request->hdr.client_context.u32[1]) return(req); in LocateSubordinateRequest()
1088 return(request); in LocateSubordinateRequest()
1091 mDNSlocal mStatus add_record_to_service(request_state *request, service_instance *instance, mDNSu16… in add_record_to_service() argument
1106 (request->flags & kDNSServiceFlagsIncludeP2P) ? 1: 0); in add_record_to_service()
1109 extra->ClientID = request->hdr.reg_index; in add_record_to_service()
1110 …request->u.servicereg.InterfaceID == mDNSInterface_P2P || (!instance->request->u.servicereg.Interf… in add_record_to_service()
1118 mDNSlocal mStatus handle_add_request(request_state *request) in handle_add_request() argument
1122 DNSServiceFlags flags = get_flags (&request->msgptr, request->msgend); in handle_add_request()
1123 mDNSu16 rrtype = get_uint16(&request->msgptr, request->msgend); in handle_add_request()
1124 mDNSu16 rdlen = get_uint16(&request->msgptr, request->msgend); in handle_add_request()
1125 const char *rdata = get_rdata (&request->msgptr, request->msgend, rdlen); in handle_add_request()
1126 mDNSu32 ttl = get_uint32(&request->msgptr, request->msgend); in handle_add_request()
1130 …if (!request->msgptr) { LogMsg("%3d: DNSServiceAddRecord(unreadable parameters)", request->sd); re… in handle_add_request()
1133 if (request->terminate == connection_termination) request = LocateSubordinateRequest(request); in handle_add_request()
1135 if (request->terminate != regservice_termination_callback) in handle_add_request()
1136 …{ LogMsg("%3d: DNSServiceAddRecord(not a registered service ref)", request->sd); return(mStatus_Ba… in handle_add_request()
1140 if (mDNSIPPortIsZero(request->u.servicereg.port)) in handle_add_request()
1141 …ServiceAddRecord: adding record to a service registered with zero port", request->sd); return(mSta… in handle_add_request()
1143 LogOperation("%3d: DNSServiceAddRecord(%X, %##s, %s, %d)", request->sd, flags, in handle_add_request()
1144 …(request->u.servicereg.instances) ? request->u.servicereg.instances->srs.RR_SRV.resrec.name->c : N… in handle_add_request()
1146 for (i = request->u.servicereg.instances; i; i = i->next) in handle_add_request()
1148 result = add_record_to_service(request, i, rrtype, rdlen, rdata, ttl); in handle_add_request()
1204 mDNSlocal mStatus handle_update_request(request_state *request) in handle_update_request() argument
1206 const ipc_msg_hdr *const hdr = &request->hdr; in handle_update_request()
1212 DNSServiceFlags flags = get_flags (&request->msgptr, request->msgend); // flags unused in handle_update_request()
1213 mDNSu16 rdlen = get_uint16(&request->msgptr, request->msgend); in handle_update_request()
1214 const char *rdata = get_rdata (&request->msgptr, request->msgend, rdlen); in handle_update_request()
1215 mDNSu32 ttl = get_uint32(&request->msgptr, request->msgend); in handle_update_request()
1218 …if (!request->msgptr) { LogMsg("%3d: DNSServiceUpdateRecord(unreadable parameters)", request->sd);… in handle_update_request()
1221 if (request->terminate == connection_termination) request = LocateSubordinateRequest(request); in handle_update_request()
1223 if (request->terminate == connection_termination) in handle_update_request()
1227 for (reptr = request->u.reg_recs; reptr; reptr = reptr->next) in handle_update_request()
1233 …request->sd, reptr->rr->resrec.name->c, reptr->rr ? DNSTypeName(reptr->rr->resrec.rrtype) : "<NONE… in handle_update_request()
1241 if (request->terminate != regservice_termination_callback) in handle_update_request()
1242 …{ LogMsg("%3d: DNSServiceUpdateRecord(not a registered service ref)", request->sd); return(mStatus… in handle_update_request()
1245 if (mDNSIPPortIsZero(request->u.servicereg.port)) in handle_update_request()
1246 …dateRecord: updating the record of a service registered with zero port", request->sd); return(mSta… in handle_update_request()
1251 if (request->u.servicereg.txtdata) in handle_update_request()
1252 …{ freeL("service_info txtdata", request->u.servicereg.txtdata); request->u.servicereg.txtdata = NU… in handle_update_request()
1255 request->u.servicereg.txtdata = mallocL("service_info txtdata", rdlen); in handle_update_request()
1256 if (!request->u.servicereg.txtdata) FatalError("ERROR: handle_update_request - malloc"); in handle_update_request()
1257 mDNSPlatformMemCopy(request->u.servicereg.txtdata, rdata, rdlen); in handle_update_request()
1259 request->u.servicereg.txtlen = rdlen; in handle_update_request()
1263 for (i = request->u.servicereg.instances; i; i = i->next) in handle_update_request()
1280 if (request->terminate == regservice_termination_callback) in handle_update_request()
1281 LogOperation("%3d: DNSServiceUpdateRecord(%##s, %s)", request->sd, in handle_update_request()
1282 …(request->u.servicereg.instances) ? request->u.servicereg.instances->srs.RR_SRV.resrec.name->c : N… in handle_update_request()
1289 mDNSlocal mStatus remove_record(request_state *request) in remove_record() argument
1292 registered_record_entry *e, **ptr = &request->u.reg_recs; in remove_record()
1294 while (*ptr && (*ptr)->key != request->hdr.reg_index) ptr = &(*ptr)->next; in remove_record()
1295 …if (!*ptr) { LogMsg("%3d: DNSServiceRemoveRecord(%u) not found", request->sd, request->hdr.reg_ind… in remove_record()
1299 …LogOperation("%3d: DNSServiceRemoveRecord(%u %s)", request->sd, e->key, RRDisplayString(&mDNSStora… in remove_record()
1317 mDNSlocal mStatus remove_extra(const request_state *const request, service_instance *const serv, mD… in remove_extra() argument
1324 if (ptr->ClientID == request->hdr.reg_index) // found match in remove_extra()
1335 mDNSlocal mStatus handle_removerecord_request(request_state *request) in handle_removerecord_request() argument
1338 get_flags(&request->msgptr, request->msgend); // flags unused in handle_removerecord_request()
1340 …if (!request->msgptr) { LogMsg("%3d: DNSServiceRemoveRecord(unreadable parameters)", request->sd);… in handle_removerecord_request()
1343 if (request->terminate == connection_termination) request = LocateSubordinateRequest(request); in handle_removerecord_request()
1345 if (request->terminate == connection_termination) in handle_removerecord_request()
1346 err = remove_record(request); // remove individually registered record in handle_removerecord_request()
1347 else if (request->terminate != regservice_termination_callback) in handle_removerecord_request()
1348 …{ LogMsg("%3d: DNSServiceRemoveRecord(not a registered service ref)", request->sd); return(mStatus… in handle_removerecord_request()
1353 LogOperation("%3d: DNSServiceRemoveRecord(%##s, %s)", request->sd, in handle_removerecord_request()
1354 …(request->u.servicereg.instances) ? request->u.servicereg.instances->srs.RR_SRV.resrec.name->c : N… in handle_removerecord_request()
1356 for (i = request->u.servicereg.instances; i; i = i->next) in handle_removerecord_request()
1358 err = remove_extra(request, i, &rrtype); in handle_removerecord_request()
1438 mDNSlocal mStatus register_service_instance(request_state *request, const domainname *domain) in register_service_instance() argument
1441 …const int extra_size = (request->u.servicereg.txtlen > sizeof(RDataBody)) ? (request->u.servicereg… in register_service_instance()
1444 mDNSInterfaceID interfaceID = request->u.servicereg.InterfaceID; in register_service_instance()
1452 else if (request->flags & kDNSServiceFlagsIncludeP2P) in register_service_instance()
1456 if (request->flags & kDNSServiceFlagsForce) in register_service_instance()
1464 if (request->u.servicereg.default_domain && !DomainIsLocal) interfaceID = mDNSInterface_Any; in register_service_instance()
1466 for (ptr = &request->u.servicereg.instances; *ptr; ptr = &(*ptr)->next) in register_service_instance()
1471 domain->c, &request->u.servicereg.name, &request->u.servicereg.type); in register_service_instance()
1481 if (SameDomainName(&request->u.servicereg.type, (const domainname *) "\x4" "_smb" "\x4" "_tcp")) in register_service_instance()
1492 instance->request = request; in register_service_instance()
1493 …instance->subtypes = AllocateSubTypes(request->u.servicereg.num_subtypes, request->u.servicer… in register_service_instance()
1496 instance->default_local = (request->u.servicereg.default_domain && DomainIsLocal); in register_service_instance()
1500 if (request->u.servicereg.num_subtypes && !instance->subtypes) in register_service_instance()
1504 &request->u.servicereg.name, &request->u.servicereg.type, domain, in register_service_instance()
1505 request->u.servicereg.host.c[0] ? &request->u.servicereg.host : NULL, in register_service_instance()
1506 request->u.servicereg.port, in register_service_instance()
1507 request->u.servicereg.txtdata, request->u.servicereg.txtlen, in register_service_instance()
1508 instance->subtypes, request->u.servicereg.num_subtypes, in register_service_instance()
1515 …instance->request->sd, instance->srs.RR_SRV.resrec.name->c, mDNSVal16(request->u.servicereg.port)); in register_service_instance()
1520 &request->u.servicereg.name, &request->u.servicereg.type, domain->c, result); in register_service_instance()
1529 request_state *request; in udsserver_default_reg_domain_changed() local
1536 for (request = all_requests; request; request = request->next) in udsserver_default_reg_domain_changed()
1538 if (request->terminate != regservice_termination_callback) continue; in udsserver_default_reg_domain_changed()
1539 if (!request->u.servicereg.default_domain) continue; in udsserver_default_reg_domain_changed()
1540 if (!d->uid || SystemUID(request->uid) || request->uid == d->uid) in udsserver_default_reg_domain_changed()
1542 service_instance **ptr = &request->u.servicereg.instances; in udsserver_default_reg_domain_changed()
1547 if (!*ptr) register_service_instance(request, &d->name); in udsserver_default_reg_domain_changed()
1557 &d->name, request->u.servicereg.name.c, request->u.servicereg.type_as_string); in udsserver_default_reg_domain_changed()
1562 if (!p->uid || SystemUID(request->uid) || request->uid == p->uid) in udsserver_default_reg_domain_changed()
1580 si->request = NULL; in udsserver_default_reg_domain_changed()
1590 mDNSlocal mStatus handle_regservice_request(request_state *request) in handle_regservice_request() argument
1599 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_regservice_request()
1600 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_regservice_request()
1605 if (get_string(&request->msgptr, request->msgend, name, sizeof(name)) < 0 || in handle_regservice_request()
1606 get_string(&request->msgptr, request->msgend, type_as_string, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_regservice_request()
1607 get_string(&request->msgptr, request->msgend, domain, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_regservice_request()
1608 get_string(&request->msgptr, request->msgend, host, MAX_ESCAPED_DOMAIN_NAME) < 0) in handle_regservice_request()
1611 request->flags = flags; in handle_regservice_request()
1612 request->u.servicereg.InterfaceID = InterfaceID; in handle_regservice_request()
1613 request->u.servicereg.instances = NULL; in handle_regservice_request()
1614 request->u.servicereg.txtlen = 0; in handle_regservice_request()
1615 request->u.servicereg.txtdata = NULL; in handle_regservice_request()
1616 …mDNSPlatformStrLCopy(request->u.servicereg.type_as_string, type_as_string, sizeof(request->u.servi… in handle_regservice_request()
1618 if (request->msgptr + 2 > request->msgend) request->msgptr = NULL; in handle_regservice_request()
1621 request->u.servicereg.port.b[0] = *request->msgptr++; in handle_regservice_request()
1622 request->u.servicereg.port.b[1] = *request->msgptr++; in handle_regservice_request()
1625 request->u.servicereg.txtlen = get_uint16(&request->msgptr, request->msgend); in handle_regservice_request()
1626 msgTXTData = get_rdata(&request->msgptr, request->msgend, request->u.servicereg.txtlen); in handle_regservice_request()
1627 if (!request->msgptr) in handle_regservice_request()
1629 LogMsg("%3d: DNSServiceRegister(unreadable parameters)", request->sd); in handle_regservice_request()
1633 if (request->u.servicereg.txtlen) in handle_regservice_request()
1635 request->u.servicereg.txtdata = mallocL("service_info txtdata", request->u.servicereg.txtlen); in handle_regservice_request()
1636 if (!request->u.servicereg.txtdata) FatalError("ERROR: handle_regservice_request - malloc"); in handle_regservice_request()
1637 mDNSPlatformMemCopy(request->u.servicereg.txtdata, msgTXTData, request->u.servicereg.txtlen); in handle_regservice_request()
1641 …request->u.servicereg.num_subtypes = ChopSubTypes(request->u.servicereg.type_as_string); // Note: … in handle_regservice_request()
1642 if (request->u.servicereg.num_subtypes < 0) in handle_regservice_request()
1643 …{ LogMsg("ERROR: handle_regservice_request - ChopSubTypes failed %s", request->u.servicereg.type_a… in handle_regservice_request()
1646 …if (!*request->u.servicereg.type_as_string || !MakeDomainNameFromDNSNameString(&request->u.service… in handle_regservice_request()
1647 …{ LogMsg("ERROR: handle_regservice_request - type_as_string bad %s", request->u.servicereg.type_as… in handle_regservice_request()
1651 request->u.servicereg.name = mDNSStorage.nicelabel; in handle_regservice_request()
1652 request->u.servicereg.autoname = mDNStrue; in handle_regservice_request()
1662 if (!MakeDomainLabelFromLiteralString(&request->u.servicereg.name, name)) in handle_regservice_request()
1664 request->u.servicereg.autoname = mDNSfalse; in handle_regservice_request()
1669 request->u.servicereg.default_domain = mDNSfalse; in handle_regservice_request()
1675 request->u.servicereg.default_domain = mDNStrue; in handle_regservice_request()
1679 if (!ConstructServiceName(&srv, &request->u.servicereg.name, &request->u.servicereg.type, &d)) in handle_regservice_request()
1682 request->u.servicereg.name.c, request->u.servicereg.type.c, d.c); return(mStatus_BadParamErr); in handle_regservice_request()
1685 if (!MakeDomainNameFromDNSNameString(&request->u.servicereg.host, host)) in handle_regservice_request()
1687 request->u.servicereg.autorename = (flags & kDNSServiceFlagsNoAutoRename ) == 0; in handle_regservice_request()
1688 request->u.servicereg.allowremotequery = (flags & kDNSServiceFlagsAllowRemoteQuery) != 0; in handle_regservice_request()
1693 if (!mDNSIPPortIsZero(request->u.servicereg.port)) in handle_regservice_request()
1695 int count = CountExistingRegistrations(&srv, request->u.servicereg.port); in handle_regservice_request()
1698 count+1, srv.c, mDNSVal16(request->u.servicereg.port)); in handle_regservice_request()
1702 …request->sd, flags, interfaceIndex, name, request->u.servicereg.type_as_string, domain, host, mDNS… in handle_regservice_request()
1710 request->terminate = regservice_termination_callback; in handle_regservice_request()
1712 err = register_service_instance(request, &d); in handle_regservice_request()
1715 …err = AuthorizedDomain(request, &d, AutoRegistrationDomains) ? register_service_instance(request, … in handle_regservice_request()
1719 if (request->u.servicereg.autoname) UpdateDeviceInfoRecord(&mDNSStorage); in handle_regservice_request()
1726 if (!ptr->uid || SystemUID(request->uid) || request->uid == ptr->uid) in handle_regservice_request()
1727 register_service_instance(request, &ptr->name); in handle_regservice_request()
1834 request_state *request; in udsserver_automatic_browse_domain_changed() local
1841 for (request = all_requests; request; request = request->next) in udsserver_automatic_browse_domain_changed()
1843 if (request->terminate != browse_termination_callback) continue; // Not a browse operation in udsserver_automatic_browse_domain_changed()
1844 if (!request->u.browser.default_domain) continue; // Not an auto-browse operation in udsserver_automatic_browse_domain_changed()
1845 if (!d->uid || SystemUID(request->uid) || request->uid == d->uid) in udsserver_automatic_browse_domain_changed()
1847 browser_t **ptr = &request->u.browser.browsers; in udsserver_automatic_browse_domain_changed()
1852 if (!*ptr) add_domain_to_browser(request, &d->name); in udsserver_automatic_browse_domain_changed()
1862 if (!p->uid || SystemUID(request->uid) || request->uid == p->uid) in udsserver_automatic_browse_domain_changed()
2126 mDNSlocal mStatus handle_sethost_request(request_state *request) in handle_sethost_request() argument
2128 get_flags(&request->msgptr, request->msgend); in handle_sethost_request()
2131 if (get_string(&request->msgptr, request->msgend, hostName, in handle_sethost_request()
2134 request->sd, request->flags); in handle_sethost_request()
2149 mDNSlocal mStatus handle_browse_request(request_state *request) in handle_browse_request() argument
2156 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_browse_request()
2157 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_browse_request()
2161 if (get_string(&request->msgptr, request->msgend, regtype, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_browse_request()
2162 …get_string(&request->msgptr, request->msgend, domain, MAX_ESCAPED_DOMAIN_NAME) < 0) return(mStatus… in handle_browse_request()
2164 …if (!request->msgptr) { LogMsg("%3d: DNSServiceBrowse(unreadable parameters)", request->sd); retur… in handle_browse_request()
2168 request->flags = flags; in handle_browse_request()
2181 request->u.browser.ForceMCast = (flags & kDNSServiceFlagsForceMulticast) != 0; in handle_browse_request()
2182 request->u.browser.interface_id = InterfaceID; in handle_browse_request()
2183 AssignDomainName(&request->u.browser.regtype, &typedn); in handle_browse_request()
2184 request->u.browser.default_domain = !domain[0]; in handle_browse_request()
2185 request->u.browser.browsers = NULL; in handle_browse_request()
2188 request->sd, request->flags, interfaceIndex, request->u.browser.regtype.c, domain); in handle_browse_request()
2193 request->terminate = browse_termination_callback; in handle_browse_request()
2198 err = add_domain_to_browser(request, &d); in handle_browse_request()
2200 …err = AuthorizedDomain(request, &d, AutoBrowseDomains) ? add_domain_to_browser(request, &d) : mSta… in handle_browse_request()
2207 if (!sdom->uid || SystemUID(request->uid) || request->uid == sdom->uid) in handle_browse_request()
2209 err = add_domain_to_browser(request, &sdom->name); in handle_browse_request()
2282 mDNSlocal void resolve_termination_callback(request_state *request) in resolve_termination_callback() argument
2284 LogOperation("%3d: DNSServiceResolve(%##s) STOP", request->sd, request->u.resolve.qtxt.qname.c); in resolve_termination_callback()
2285 mDNS_StopQuery(&mDNSStorage, &request->u.resolve.qtxt); in resolve_termination_callback()
2286 mDNS_StopQuery(&mDNSStorage, &request->u.resolve.qsrv); in resolve_termination_callback()
2287 …if (request->u.resolve.external_advertise) external_stop_resolving_service(&request->u.resolve.qsr… in resolve_termination_callback()
2290 mDNSlocal mStatus handle_resolve_request(request_state *request) in handle_resolve_request() argument
2297 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_resolve_request()
2298 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_resolve_request()
2303 request->flags = flags; in handle_resolve_request()
2310 if (get_string(&request->msgptr, request->msgend, name, 256) < 0 || in handle_resolve_request()
2311 get_string(&request->msgptr, request->msgend, regtype, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_resolve_request()
2312 get_string(&request->msgptr, request->msgend, domain, MAX_ESCAPED_DOMAIN_NAME) < 0) in handle_resolve_request()
2315 …if (!request->msgptr) { LogMsg("%3d: DNSServiceResolve(unreadable parameters)", request->sd); retu… in handle_resolve_request()
2320 mDNSPlatformMemZero(&request->u.resolve, sizeof(request->u.resolve)); in handle_resolve_request()
2323 request->u.resolve.qsrv.InterfaceID = InterfaceID; in handle_resolve_request()
2324 request->u.resolve.qsrv.Target = zeroAddr; in handle_resolve_request()
2325 AssignDomainName(&request->u.resolve.qsrv.qname, &fqdn); in handle_resolve_request()
2326 request->u.resolve.qsrv.qtype = kDNSType_SRV; in handle_resolve_request()
2327 request->u.resolve.qsrv.qclass = kDNSClass_IN; in handle_resolve_request()
2328 request->u.resolve.qsrv.LongLived = (flags & kDNSServiceFlagsLongLivedQuery ) != 0; in handle_resolve_request()
2329 request->u.resolve.qsrv.ExpectUnique = mDNStrue; in handle_resolve_request()
2330 request->u.resolve.qsrv.ForceMCast = (flags & kDNSServiceFlagsForceMulticast ) != 0; in handle_resolve_request()
2331 request->u.resolve.qsrv.ReturnIntermed = (flags & kDNSServiceFlagsReturnIntermediates) != 0; in handle_resolve_request()
2332 request->u.resolve.qsrv.SuppressUnusable = mDNSfalse; in handle_resolve_request()
2333 request->u.resolve.qsrv.SearchListIndex = 0; in handle_resolve_request()
2334 request->u.resolve.qsrv.AppendSearchDomains = 0; in handle_resolve_request()
2335 request->u.resolve.qsrv.RetryWithSearchDomains = mDNSfalse; in handle_resolve_request()
2336 request->u.resolve.qsrv.TimeoutQuestion = 0; in handle_resolve_request()
2337 request->u.resolve.qsrv.WakeOnResolve = (flags & kDNSServiceFlagsWakeOnResolve) != 0; in handle_resolve_request()
2338 request->u.resolve.qsrv.qnameOrig = mDNSNULL; in handle_resolve_request()
2339 request->u.resolve.qsrv.QuestionCallback = resolve_result_callback; in handle_resolve_request()
2340 request->u.resolve.qsrv.QuestionContext = request; in handle_resolve_request()
2342 request->u.resolve.qtxt.InterfaceID = InterfaceID; in handle_resolve_request()
2343 request->u.resolve.qtxt.Target = zeroAddr; in handle_resolve_request()
2344 AssignDomainName(&request->u.resolve.qtxt.qname, &fqdn); in handle_resolve_request()
2345 request->u.resolve.qtxt.qtype = kDNSType_TXT; in handle_resolve_request()
2346 request->u.resolve.qtxt.qclass = kDNSClass_IN; in handle_resolve_request()
2347 request->u.resolve.qtxt.LongLived = (flags & kDNSServiceFlagsLongLivedQuery ) != 0; in handle_resolve_request()
2348 request->u.resolve.qtxt.ExpectUnique = mDNStrue; in handle_resolve_request()
2349 request->u.resolve.qtxt.ForceMCast = (flags & kDNSServiceFlagsForceMulticast ) != 0; in handle_resolve_request()
2350 request->u.resolve.qtxt.ReturnIntermed = (flags & kDNSServiceFlagsReturnIntermediates) != 0; in handle_resolve_request()
2351 request->u.resolve.qtxt.SuppressUnusable = mDNSfalse; in handle_resolve_request()
2352 request->u.resolve.qtxt.SearchListIndex = 0; in handle_resolve_request()
2353 request->u.resolve.qtxt.AppendSearchDomains = 0; in handle_resolve_request()
2354 request->u.resolve.qtxt.RetryWithSearchDomains = mDNSfalse; in handle_resolve_request()
2355 request->u.resolve.qtxt.TimeoutQuestion = 0; in handle_resolve_request()
2356 request->u.resolve.qtxt.WakeOnResolve = 0; in handle_resolve_request()
2357 request->u.resolve.qtxt.qnameOrig = mDNSNULL; in handle_resolve_request()
2358 request->u.resolve.qtxt.QuestionCallback = resolve_result_callback; in handle_resolve_request()
2359 request->u.resolve.qtxt.QuestionContext = request; in handle_resolve_request()
2361 …request->u.resolve.ReportTime = NonZeroTime(mDNS_TimeNow(&mDNSStorage) + 130 * mDNSPlat… in handle_resolve_request()
2363 request->u.resolve.external_advertise = mDNSfalse; in handle_resolve_request()
2366 if (!AuthorizedDomain(request, &fqdn, AutoBrowseDomains)) return(mStatus_NoError); in handle_resolve_request()
2370 LogOperation("%3d: DNSServiceResolve(%##s) START", request->sd, request->u.resolve.qsrv.qname.c); in handle_resolve_request()
2371 err = mDNS_StartQuery(&mDNSStorage, &request->u.resolve.qsrv); in handle_resolve_request()
2374 err = mDNS_StartQuery(&mDNSStorage, &request->u.resolve.qtxt); in handle_resolve_request()
2375 if (err) mDNS_StopQuery(&mDNSStorage, &request->u.resolve.qsrv); in handle_resolve_request()
2378 request->terminate = resolve_termination_callback; in handle_resolve_request()
2380 …if (wasP2P || (!InterfaceID && IsLocalDomain(&fqdn) && (request->flags & kDNSServiceFlagsIncludeP2… in handle_resolve_request()
2382 request->u.resolve.external_advertise = mDNStrue; in handle_resolve_request()
2490 mDNSlocal mStatus SendAdditionalQuery(DNSQuestion *q, request_state *request, mStatus err) in SendAdditionalQuery() argument
2498 if (request->hdr.op == query_request) in SendAdditionalQuery()
2499 question2 = &request->u.queryrecord.q2; in SendAdditionalQuery()
2500 else if (request->hdr.op == addrinfo_request) in SendAdditionalQuery()
2503 question2 = &request->u.addrinfo.q42; in SendAdditionalQuery()
2505 question2 = &request->u.addrinfo.q62; in SendAdditionalQuery()
2578 …LogOperation("%3d: DNSServiceQueryRecord(%##s, %s) unicast", request->sd, q2->qname.c, DNSTypeName… in SendAdditionalQuery()
2580 …if (err) LogMsg("%3d: ERROR: DNSServiceQueryRecord %##s %s mDNS_StartQuery: %d", request->sd, q2->… in SendAdditionalQuery()
2920 mDNSlocal void queryrecord_termination_callback(request_state *request) in queryrecord_termination_callback() argument
2923 request->sd, request->u.queryrecord.q.qname.c, DNSTypeName(request->u.queryrecord.q.qtype)); in queryrecord_termination_callback()
2924 if (request->u.queryrecord.q.QuestionContext) in queryrecord_termination_callback()
2926 mDNS_StopQuery(&mDNSStorage, &request->u.queryrecord.q); // no need to error check in queryrecord_termination_callback()
2927 request->u.queryrecord.q.QuestionContext = mDNSNULL; in queryrecord_termination_callback()
2931 DNSQuestion *question = &request->u.queryrecord.q; in queryrecord_termination_callback()
2935 if (request->u.queryrecord.q.qnameOrig) in queryrecord_termination_callback()
2937 freeL("QueryTermination", request->u.queryrecord.q.qnameOrig); in queryrecord_termination_callback()
2938 request->u.queryrecord.q.qnameOrig = mDNSNULL; in queryrecord_termination_callback()
2940 …request->u.queryrecord.q.InterfaceID == mDNSInterface_P2P || (!request->u.queryrecord.q.InterfaceI… in queryrecord_termination_callback()
2943 …external_stop_browsing_for_service(&mDNSStorage, &request->u.queryrecord.q.qname, request->u.query… in queryrecord_termination_callback()
2945 if (request->u.queryrecord.q2) in queryrecord_termination_callback()
2947 if (request->u.queryrecord.q2->QuestionContext) in queryrecord_termination_callback()
2949 … LogInfo("queryrecord_termination_callback: Stopping q2 %##s", request->u.queryrecord.q2->qname.c); in queryrecord_termination_callback()
2950 mDNS_StopQuery(&mDNSStorage, request->u.queryrecord.q2); in queryrecord_termination_callback()
2954 DNSQuestion *question = request->u.queryrecord.q2; in queryrecord_termination_callback()
2957 if (request->u.queryrecord.q2->qnameOrig) in queryrecord_termination_callback()
2959 …LogInfo("queryrecord_termination_callback: freeing q2 qnameOrig %##s", request->u.queryrecord.q2->… in queryrecord_termination_callback()
2960 freeL("QueryTermination q2", request->u.queryrecord.q2->qnameOrig); in queryrecord_termination_callback()
2961 request->u.queryrecord.q2->qnameOrig = mDNSNULL; in queryrecord_termination_callback()
2963 freeL("queryrecord Q2", request->u.queryrecord.q2); in queryrecord_termination_callback()
2964 request->u.queryrecord.q2 = mDNSNULL; in queryrecord_termination_callback()
2968 mDNSlocal mStatus handle_queryrecord_request(request_state *request) in handle_queryrecord_request() argument
2970 DNSQuestion *const q = &request->u.queryrecord.q; in handle_queryrecord_request()
2975 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_queryrecord_request()
2976 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_queryrecord_request()
2980 if (get_string(&request->msgptr, request->msgend, name, 256) < 0) return(mStatus_BadParamErr); in handle_queryrecord_request()
2981 rrtype = get_uint16(&request->msgptr, request->msgend); in handle_queryrecord_request()
2982 rrclass = get_uint16(&request->msgptr, request->msgend); in handle_queryrecord_request()
2984 if (!request->msgptr) in handle_queryrecord_request()
2985 …{ LogMsg("%3d: DNSServiceQueryRecord(unreadable parameters)", request->sd); return(mStatus_BadPara… in handle_queryrecord_request()
2987 request->flags = flags; in handle_queryrecord_request()
2988 mDNSPlatformMemZero(&request->u.queryrecord, sizeof(request->u.queryrecord)); in handle_queryrecord_request()
2994 if (!AuthorizedDomain(request, &q->qname, AutoBrowseDomains)) return (mStatus_NoError); in handle_queryrecord_request()
3006 q->QuestionContext = request; in handle_queryrecord_request()
3037 …LogOperation("%3d: DNSServiceQueryRecord(%X, %d, %##s, %s) START", request->sd, flags, interfaceIn… in handle_queryrecord_request()
3039 …if (err) LogMsg("%3d: ERROR: DNSServiceQueryRecord %##s %s mDNS_StartQuery: %d", request->sd, q->q… in handle_queryrecord_request()
3042 request->terminate = queryrecord_termination_callback; in handle_queryrecord_request()
3051 err = SendAdditionalQuery(q, request, err); in handle_queryrecord_request()
3063 mDNSlocal reply_state *format_enumeration_reply(request_state *request, in format_enumeration_reply() argument
3075 reply = create_reply(enumeration_reply_op, len, request); in format_enumeration_reply()
3084 mDNSlocal void enum_termination_callback(request_state *request) in enum_termination_callback() argument
3086 mDNS_StopGetDomains(&mDNSStorage, &request->u.enumeration.q_all); in enum_termination_callback()
3087 mDNS_StopGetDomains(&mDNSStorage, &request->u.enumeration.q_default); in enum_termination_callback()
3094 request_state *request = question->QuestionContext; in enum_result_callback() local
3102 …if (!AuthorizedDomain(request, &answer->rdata->u.name, request->u.enumeration.flags ? AutoRegistra… in enum_result_callback()
3107 if (question == &request->u.enumeration.q_default && !AddRecord) return; in enum_result_callback()
3112 if (question == &request->u.enumeration.q_default) flags |= kDNSServiceFlagsDefault; in enum_result_callback()
3119 …reply = format_enumeration_reply(request, domain, flags, kDNSServiceInterfaceIndexAny, kDNSService… in enum_result_callback()
3122 …LogOperation("%3d: DNSServiceEnumerateDomains(%#2s) RESULT %s: %s", request->sd, question->qname.c… in enum_result_callback()
3124 append_reply(request, reply); in enum_result_callback()
3127 mDNSlocal mStatus handle_enum_request(request_state *request) in handle_enum_request() argument
3130 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_enum_request()
3134 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_enum_request()
3138 if (!request->msgptr) in handle_enum_request()
3139 …{ LogMsg("%3d: DNSServiceEnumerateDomains(unreadable parameters)", request->sd); return(mStatus_Ba… in handle_enum_request()
3146 request->u.enumeration.flags = reg; in handle_enum_request()
3151 request->u.enumeration.q_all .QuestionContext = request; in handle_enum_request()
3152 request->u.enumeration.q_default.QuestionContext = request; in handle_enum_request()
3158 LogOperation("%3d: DNSServiceEnumerateDomains(%X=%s)", request->sd, flags, in handle_enum_request()
3161 … = mDNS_GetDomains(&mDNSStorage, &request->u.enumeration.q_all, t_all, NULL, InterfaceID, enum_res… in handle_enum_request()
3164 …DNS_GetDomains(&mDNSStorage, &request->u.enumeration.q_default, t_default, NULL, InterfaceID, enum… in handle_enum_request()
3165 if (err) mDNS_StopGetDomains(&mDNSStorage, &request->u.enumeration.q_all); in handle_enum_request()
3166 else request->terminate = enum_termination_callback; in handle_enum_request()
3178 mDNSlocal mStatus handle_reconfirm_request(request_state *request) in handle_reconfirm_request() argument
3181 AuthRecord *rr = read_rr_from_ipc_msg(request, 0, 0); in handle_reconfirm_request()
3189 request->sd, RRDisplayString(&mDNSStorage, &rr->resrec), in handle_reconfirm_request()
3196 mDNSlocal mStatus handle_setdomain_request(request_state *request) in handle_setdomain_request() argument
3200 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_setdomain_request()
3202 if (get_string(&request->msgptr, request->msgend, domainstr, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_setdomain_request()
3204 …{ LogMsg("%3d: DNSServiceSetDefaultDomainForUser(unreadable parameters)", request->sd); return(mSt… in handle_setdomain_request()
3206 LogOperation("%3d: DNSServiceSetDefaultDomainForUser(%##s)", request->sd, domain.c); in handle_setdomain_request()
3217 mDNSlocal void handle_getproperty_request(request_state *request) in handle_getproperty_request() argument
3221 if (get_string(&request->msgptr, request->msgend, prop, sizeof(prop)) >= 0) in handle_getproperty_request()
3223 LogOperation("%3d: DNSServiceGetProperty(%s)", request->sd, prop); in handle_getproperty_request()
3227 send_all(request->sd, (const char *)&x, sizeof(x)); in handle_getproperty_request()
3233 send_all(request->sd, (const char *)&BadParamErr, sizeof(BadParamErr)); in handle_getproperty_request()
3244 mDNSlocal void port_mapping_termination_callback(request_state *request) in port_mapping_termination_callback() argument
3246 LogOperation("%3d: DNSServiceNATPortMappingCreate(%X, %u, %u, %d) STOP", request->sd, in port_mapping_termination_callback()
3247 DNSServiceProtocol(request->u.pm.NATinfo.Protocol), in port_mapping_termination_callback()
3248 …mDNSVal16(request->u.pm.NATinfo.IntPort), mDNSVal16(request->u.pm.ReqExt), request->u.pm.NATinfo.N… in port_mapping_termination_callback()
3249 mDNS_StopNATOperation(&mDNSStorage, &request->u.pm.NATinfo); in port_mapping_termination_callback()
3255 request_state *request = (request_state *)n->clientContext; in port_mapping_create_request_callback() local
3260 …if (!request) { LogMsg("port_mapping_create_request_callback called with unknown request_state obj… in port_mapping_create_request_callback()
3269 rep = create_reply(port_mapping_reply_op, replyLen, request); in port_mapping_create_request_callback()
3277 *data++ = request->u.pm.NATinfo.ExternalAddress.b[0]; in port_mapping_create_request_callback()
3278 *data++ = request->u.pm.NATinfo.ExternalAddress.b[1]; in port_mapping_create_request_callback()
3279 *data++ = request->u.pm.NATinfo.ExternalAddress.b[2]; in port_mapping_create_request_callback()
3280 *data++ = request->u.pm.NATinfo.ExternalAddress.b[3]; in port_mapping_create_request_callback()
3281 *data++ = DNSServiceProtocol(request->u.pm.NATinfo.Protocol); in port_mapping_create_request_callback()
3282 *data++ = request->u.pm.NATinfo.IntPort.b[0]; in port_mapping_create_request_callback()
3283 *data++ = request->u.pm.NATinfo.IntPort.b[1]; in port_mapping_create_request_callback()
3284 *data++ = request->u.pm.NATinfo.ExternalPort.b[0]; in port_mapping_create_request_callback()
3285 *data++ = request->u.pm.NATinfo.ExternalPort.b[1]; in port_mapping_create_request_callback()
3286 put_uint32(request->u.pm.NATinfo.Lifetime, &data); in port_mapping_create_request_callback()
3288 …LogOperation("%3d: DNSServiceNATPortMappingCreate(%X, %u, %u, %d) RESULT %.4a:%u TTL %u", request-… in port_mapping_create_request_callback()
3289 DNSServiceProtocol(request->u.pm.NATinfo.Protocol), in port_mapping_create_request_callback()
3290 …mDNSVal16(request->u.pm.NATinfo.IntPort), mDNSVal16(request->u.pm.ReqExt), request->u.pm.NATinfo.N… in port_mapping_create_request_callback()
3291 …&request->u.pm.NATinfo.ExternalAddress, mDNSVal16(request->u.pm.NATinfo.ExternalPort), request->u.… in port_mapping_create_request_callback()
3293 append_reply(request, rep); in port_mapping_create_request_callback()
3296 mDNSlocal mStatus handle_port_mapping_request(request_state *request) in handle_port_mapping_request() argument
3301 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_port_mapping_request()
3302 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_port_mapping_request()
3304 mDNSu8 protocol = (mDNSu8)get_uint32(&request->msgptr, request->msgend); in handle_port_mapping_request()
3307 if (request->msgptr + 8 > request->msgend) request->msgptr = NULL; in handle_port_mapping_request()
3310 request->u.pm.NATinfo.IntPort.b[0] = *request->msgptr++; in handle_port_mapping_request()
3311 request->u.pm.NATinfo.IntPort.b[1] = *request->msgptr++; in handle_port_mapping_request()
3312 request->u.pm.ReqExt.b[0] = *request->msgptr++; in handle_port_mapping_request()
3313 request->u.pm.ReqExt.b[1] = *request->msgptr++; in handle_port_mapping_request()
3314 ttl = get_uint32(&request->msgptr, request->msgend); in handle_port_mapping_request()
3317 if (!request->msgptr) in handle_port_mapping_request()
3318 …{ LogMsg("%3d: DNSServiceNATPortMappingCreate(unreadable parameters)", request->sd); return(mStatu… in handle_port_mapping_request()
3322 …if (!mDNSIPPortIsZero(request->u.pm.NATinfo.IntPort) || !mDNSIPPortIsZero(request->u.pm.ReqExt) ||… in handle_port_mapping_request()
3326 if (mDNSIPPortIsZero(request->u.pm.NATinfo.IntPort)) return(mStatus_BadParamErr); in handle_port_mapping_request()
3330 …request->u.pm.NATinfo.Protocol = !protocol ? NATOp_AddrRequest : (protocol == kDNSServicePro… in handle_port_mapping_request()
3332 request->u.pm.NATinfo.RequestedPort = request->u.pm.ReqExt; in handle_port_mapping_request()
3333 request->u.pm.NATinfo.NATLease = ttl; in handle_port_mapping_request()
3334 request->u.pm.NATinfo.clientCallback = port_mapping_create_request_callback; in handle_port_mapping_request()
3335 request->u.pm.NATinfo.clientContext = request; in handle_port_mapping_request()
3337 LogOperation("%3d: DNSServiceNATPortMappingCreate(%X, %u, %u, %d) START", request->sd, in handle_port_mapping_request()
3338 …protocol, mDNSVal16(request->u.pm.NATinfo.IntPort), mDNSVal16(request->u.pm.ReqExt), request->u.pm… in handle_port_mapping_request()
3339 err = mDNS_StartNATOperation(&mDNSStorage, &request->u.pm.NATinfo); in handle_port_mapping_request()
3341 else request->terminate = port_mapping_termination_callback; in handle_port_mapping_request()
3352 mDNSlocal void addrinfo_termination_callback(request_state *request) in addrinfo_termination_callback() argument
3354 LogOperation("%3d: DNSServiceGetAddrInfo(%##s) STOP", request->sd, request->u.addrinfo.q4.qname.c); in addrinfo_termination_callback()
3356 if (request->u.addrinfo.q4.QuestionContext) in addrinfo_termination_callback()
3358 mDNS_StopQuery(&mDNSStorage, &request->u.addrinfo.q4); in addrinfo_termination_callback()
3359 request->u.addrinfo.q4.QuestionContext = mDNSNULL; in addrinfo_termination_callback()
3361 if (request->u.addrinfo.q4.qnameOrig) in addrinfo_termination_callback()
3363 freeL("QueryTermination", request->u.addrinfo.q4.qnameOrig); in addrinfo_termination_callback()
3364 request->u.addrinfo.q4.qnameOrig = mDNSNULL; in addrinfo_termination_callback()
3366 if (request->u.addrinfo.q42) in addrinfo_termination_callback()
3368 if (request->u.addrinfo.q42->QuestionContext) in addrinfo_termination_callback()
3370 LogInfo("addrinfo_termination_callback: Stopping q42 %##s", request->u.addrinfo.q42->qname.c); in addrinfo_termination_callback()
3371 mDNS_StopQuery(&mDNSStorage, request->u.addrinfo.q42); in addrinfo_termination_callback()
3373 if (request->u.addrinfo.q42->qnameOrig) in addrinfo_termination_callback()
3375 …LogInfo("addrinfo_termination_callback: freeing q42 qnameOrig %##s", request->u.addrinfo.q42->qnam… in addrinfo_termination_callback()
3376 freeL("QueryTermination q42", request->u.addrinfo.q42->qnameOrig); in addrinfo_termination_callback()
3377 request->u.addrinfo.q42->qnameOrig = mDNSNULL; in addrinfo_termination_callback()
3379 freeL("addrinfo Q42", request->u.addrinfo.q42); in addrinfo_termination_callback()
3380 request->u.addrinfo.q42 = mDNSNULL; in addrinfo_termination_callback()
3383 if (request->u.addrinfo.q6.QuestionContext) in addrinfo_termination_callback()
3385 mDNS_StopQuery(&mDNSStorage, &request->u.addrinfo.q6); in addrinfo_termination_callback()
3386 request->u.addrinfo.q6.QuestionContext = mDNSNULL; in addrinfo_termination_callback()
3388 if (request->u.addrinfo.q6.qnameOrig) in addrinfo_termination_callback()
3390 freeL("QueryTermination", request->u.addrinfo.q6.qnameOrig); in addrinfo_termination_callback()
3391 request->u.addrinfo.q6.qnameOrig = mDNSNULL; in addrinfo_termination_callback()
3393 if (request->u.addrinfo.q62) in addrinfo_termination_callback()
3395 if (request->u.addrinfo.q62->QuestionContext) in addrinfo_termination_callback()
3397 LogInfo("addrinfo_termination_callback: Stopping q62 %##s", request->u.addrinfo.q62->qname.c); in addrinfo_termination_callback()
3398 mDNS_StopQuery(&mDNSStorage, request->u.addrinfo.q62); in addrinfo_termination_callback()
3400 if (request->u.addrinfo.q62->qnameOrig) in addrinfo_termination_callback()
3402 …LogInfo("addrinfo_termination_callback: freeing q62 qnameOrig %##s", request->u.addrinfo.q62->qnam… in addrinfo_termination_callback()
3403 freeL("QueryTermination q62", request->u.addrinfo.q62->qnameOrig); in addrinfo_termination_callback()
3404 request->u.addrinfo.q62->qnameOrig = mDNSNULL; in addrinfo_termination_callback()
3406 freeL("addrinfo Q62", request->u.addrinfo.q62); in addrinfo_termination_callback()
3407 request->u.addrinfo.q62 = mDNSNULL; in addrinfo_termination_callback()
3411 mDNSlocal mStatus handle_addrinfo_request(request_state *request) in handle_addrinfo_request() argument
3417 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_addrinfo_request()
3418 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_addrinfo_request()
3420 mDNSPlatformMemZero(&request->u.addrinfo, sizeof(request->u.addrinfo)); in handle_addrinfo_request()
3421 …request->u.addrinfo.interface_id = mDNSPlatformInterfaceIDfromInterfaceIndex(&mDNSStorage, interfa… in handle_addrinfo_request()
3422 request->u.addrinfo.flags = flags; in handle_addrinfo_request()
3423 request->u.addrinfo.protocol = get_uint32(&request->msgptr, request->msgend); in handle_addrinfo_request()
3425 if (interfaceIndex && !request->u.addrinfo.interface_id) return(mStatus_BadParamErr); in handle_addrinfo_request()
3426 …if (request->u.addrinfo.protocol > (kDNSServiceProtocol_IPv4|kDNSServiceProtocol_IPv6)) return(mSt… in handle_addrinfo_request()
3428 if (get_string(&request->msgptr, request->msgend, hostname, 256) < 0) return(mStatus_BadParamErr); in handle_addrinfo_request()
3430 …if (!request->msgptr) { LogMsg("%3d: DNSServiceGetAddrInfo(unreadable parameters)", request->sd); … in handle_addrinfo_request()
3436 if (!AuthorizedDomain(request, &d, AutoBrowseDomains)) return (mStatus_NoError); in handle_addrinfo_request()
3439 if (!request->u.addrinfo.protocol) in handle_addrinfo_request()
3442 request->u.addrinfo.protocol = (kDNSServiceProtocol_IPv4 | kDNSServiceProtocol_IPv6); in handle_addrinfo_request()
3445 …request->u.addrinfo.q4.InterfaceID = request->u.addrinfo.q6.InterfaceID = request->u.add… in handle_addrinfo_request()
3446 request->u.addrinfo.q4.Target = request->u.addrinfo.q6.Target = zeroAddr; in handle_addrinfo_request()
3447 request->u.addrinfo.q4.qname = request->u.addrinfo.q6.qname = d; in handle_addrinfo_request()
3448 …request->u.addrinfo.q4.qclass = request->u.addrinfo.q6.qclass = kDNSServiceCla… in handle_addrinfo_request()
3449 …request->u.addrinfo.q4.LongLived = request->u.addrinfo.q6.LongLived = (flags & kDNSS… in handle_addrinfo_request()
3450 request->u.addrinfo.q4.ExpectUnique = request->u.addrinfo.q6.ExpectUnique = mDNSfalse; in handle_addrinfo_request()
3451 …request->u.addrinfo.q4.ForceMCast = request->u.addrinfo.q6.ForceMCast = (flags & kDNSS… in handle_addrinfo_request()
3452 …request->u.addrinfo.q4.ReturnIntermed = request->u.addrinfo.q6.ReturnIntermed = (flags & kDNSS… in handle_addrinfo_request()
3453 …request->u.addrinfo.q4.SuppressUnusable = request->u.addrinfo.q6.SuppressUnusable = (flags & kDNSS… in handle_addrinfo_request()
3454 …request->u.addrinfo.q4.TimeoutQuestion = request->u.addrinfo.q6.TimeoutQuestion = (flags & kDNSS… in handle_addrinfo_request()
3455 request->u.addrinfo.q4.WakeOnResolve = request->u.addrinfo.q6.WakeOnResolve = 0; in handle_addrinfo_request()
3456 request->u.addrinfo.q4.qnameOrig = request->u.addrinfo.q6.qnameOrig = mDNSNULL; in handle_addrinfo_request()
3458 if (request->u.addrinfo.protocol & kDNSServiceProtocol_IPv4) in handle_addrinfo_request()
3460 request->u.addrinfo.q4.qtype = kDNSServiceType_A; in handle_addrinfo_request()
3461 request->u.addrinfo.q4.SearchListIndex = 0; in handle_addrinfo_request()
3468 request->u.addrinfo.q4.AppendSearchDomains = 1; in handle_addrinfo_request()
3469 request->u.addrinfo.q4.AppendLocalSearchDomains = 1; in handle_addrinfo_request()
3473 request->u.addrinfo.q4.AppendSearchDomains = 0; in handle_addrinfo_request()
3474 request->u.addrinfo.q4.AppendLocalSearchDomains = 0; in handle_addrinfo_request()
3476 …request->u.addrinfo.q4.RetryWithSearchDomains = (ApplySearchDomainsFirst(&request->u.addrinfo.q4) … in handle_addrinfo_request()
3477 request->u.addrinfo.q4.QuestionCallback = queryrecord_result_callback; in handle_addrinfo_request()
3478 request->u.addrinfo.q4.QuestionContext = request; in handle_addrinfo_request()
3479 err = mDNS_StartQuery(&mDNSStorage, &request->u.addrinfo.q4); in handle_addrinfo_request()
3483 request->u.addrinfo.q4.QuestionContext = mDNSNULL; in handle_addrinfo_request()
3486 err = SendAdditionalQuery(&request->u.addrinfo.q4, request, err); in handle_addrinfo_request()
3490 if (!err && (request->u.addrinfo.protocol & kDNSServiceProtocol_IPv6)) in handle_addrinfo_request()
3492 request->u.addrinfo.q6.qtype = kDNSServiceType_AAAA; in handle_addrinfo_request()
3493 request->u.addrinfo.q6.SearchListIndex = 0; in handle_addrinfo_request()
3496 request->u.addrinfo.q6.AppendSearchDomains = 1; in handle_addrinfo_request()
3497 request->u.addrinfo.q6.AppendLocalSearchDomains = 1; in handle_addrinfo_request()
3501 request->u.addrinfo.q6.AppendSearchDomains = 0; in handle_addrinfo_request()
3502 request->u.addrinfo.q6.AppendLocalSearchDomains = 0; in handle_addrinfo_request()
3504 …request->u.addrinfo.q6.RetryWithSearchDomains = (ApplySearchDomainsFirst(&request->u.addrinfo.q6) … in handle_addrinfo_request()
3505 request->u.addrinfo.q6.QuestionCallback = queryrecord_result_callback; in handle_addrinfo_request()
3506 request->u.addrinfo.q6.QuestionContext = request; in handle_addrinfo_request()
3507 err = mDNS_StartQuery(&mDNSStorage, &request->u.addrinfo.q6); in handle_addrinfo_request()
3511 request->u.addrinfo.q6.QuestionContext = mDNSNULL; in handle_addrinfo_request()
3512 if (request->u.addrinfo.protocol & kDNSServiceProtocol_IPv4) in handle_addrinfo_request()
3515 mDNS_StopQuery(&mDNSStorage, &request->u.addrinfo.q4); in handle_addrinfo_request()
3516 request->u.addrinfo.q4.QuestionContext = mDNSNULL; in handle_addrinfo_request()
3520 err = SendAdditionalQuery(&request->u.addrinfo.q6, request, err); in handle_addrinfo_request()
3525 request->sd, flags, interfaceIndex, request->u.addrinfo.protocol, d.c); in handle_addrinfo_request()
3527 if (!err) request->terminate = addrinfo_termination_callback; in handle_addrinfo_request()
3919 request_state *request = NewRequest(); in connect_callback() local
3920 request->ts = t_morecoming; in connect_callback()
3921 request->sd = sd; in connect_callback()
3922 request->errsd = sd; in connect_callback()
3926 …0, LOCAL_PEERCRED, &x, &xucredlen) >= 0 && x.cr_version == XUCRED_VERSION) request->uid = x.cr_uid; in connect_callback()
3930 LogOperation("%3d: Adding FD for uid %u", request->sd, request->uid); in connect_callback()
3931 udsSupportAddFDToEventLoop(sd, request_callback, request, &request->platform_data); in connect_callback()