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
1598 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_regservice_request()
1599 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_regservice_request()
1604 if (get_string(&request->msgptr, request->msgend, name, sizeof(name)) < 0 || in handle_regservice_request()
1605 get_string(&request->msgptr, request->msgend, type_as_string, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_regservice_request()
1606 get_string(&request->msgptr, request->msgend, domain, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_regservice_request()
1607 get_string(&request->msgptr, request->msgend, host, MAX_ESCAPED_DOMAIN_NAME) < 0) in handle_regservice_request()
1610 request->flags = flags; in handle_regservice_request()
1611 request->u.servicereg.InterfaceID = InterfaceID; in handle_regservice_request()
1612 request->u.servicereg.instances = NULL; in handle_regservice_request()
1613 request->u.servicereg.txtlen = 0; in handle_regservice_request()
1614 request->u.servicereg.txtdata = NULL; in handle_regservice_request()
1615 mDNSPlatformStrCopy(request->u.servicereg.type_as_string, type_as_string); in handle_regservice_request()
1617 if (request->msgptr + 2 > request->msgend) request->msgptr = NULL; in handle_regservice_request()
1620 request->u.servicereg.port.b[0] = *request->msgptr++; in handle_regservice_request()
1621 request->u.servicereg.port.b[1] = *request->msgptr++; in handle_regservice_request()
1624 request->u.servicereg.txtlen = get_uint16(&request->msgptr, request->msgend); in handle_regservice_request()
1625 if (request->u.servicereg.txtlen) in handle_regservice_request()
1627 request->u.servicereg.txtdata = mallocL("service_info txtdata", request->u.servicereg.txtlen); in handle_regservice_request()
1628 if (!request->u.servicereg.txtdata) FatalError("ERROR: handle_regservice_request - malloc"); in handle_regservice_request()
1629 …DNSPlatformMemCopy(request->u.servicereg.txtdata, get_rdata(&request->msgptr, request->msgend, req… in handle_regservice_request()
1632 …if (!request->msgptr) { LogMsg("%3d: DNSServiceRegister(unreadable parameters)", request->sd); ret… in handle_regservice_request()
1635 …request->u.servicereg.num_subtypes = ChopSubTypes(request->u.servicereg.type_as_string); // Note: … in handle_regservice_request()
1636 if (request->u.servicereg.num_subtypes < 0) in handle_regservice_request()
1637 …{ LogMsg("ERROR: handle_regservice_request - ChopSubTypes failed %s", request->u.servicereg.type_a… in handle_regservice_request()
1640 …if (!*request->u.servicereg.type_as_string || !MakeDomainNameFromDNSNameString(&request->u.service… in handle_regservice_request()
1641 …{ LogMsg("ERROR: handle_regservice_request - type_as_string bad %s", request->u.servicereg.type_as… in handle_regservice_request()
1645 request->u.servicereg.name = mDNSStorage.nicelabel; in handle_regservice_request()
1646 request->u.servicereg.autoname = mDNStrue; in handle_regservice_request()
1656 if (!MakeDomainLabelFromLiteralString(&request->u.servicereg.name, name)) in handle_regservice_request()
1658 request->u.servicereg.autoname = mDNSfalse; in handle_regservice_request()
1663 request->u.servicereg.default_domain = mDNSfalse; in handle_regservice_request()
1669 request->u.servicereg.default_domain = mDNStrue; in handle_regservice_request()
1673 if (!ConstructServiceName(&srv, &request->u.servicereg.name, &request->u.servicereg.type, &d)) in handle_regservice_request()
1676 request->u.servicereg.name.c, request->u.servicereg.type.c, d.c); return(mStatus_BadParamErr); in handle_regservice_request()
1679 if (!MakeDomainNameFromDNSNameString(&request->u.servicereg.host, host)) in handle_regservice_request()
1681 request->u.servicereg.autorename = (flags & kDNSServiceFlagsNoAutoRename ) == 0; in handle_regservice_request()
1682 request->u.servicereg.allowremotequery = (flags & kDNSServiceFlagsAllowRemoteQuery) != 0; in handle_regservice_request()
1687 if (!mDNSIPPortIsZero(request->u.servicereg.port)) in handle_regservice_request()
1689 int count = CountExistingRegistrations(&srv, request->u.servicereg.port); in handle_regservice_request()
1692 count+1, srv.c, mDNSVal16(request->u.servicereg.port)); in handle_regservice_request()
1696 …request->sd, flags, interfaceIndex, name, request->u.servicereg.type_as_string, domain, host, mDNS… in handle_regservice_request()
1704 request->terminate = regservice_termination_callback; in handle_regservice_request()
1706 err = register_service_instance(request, &d); in handle_regservice_request()
1709 …err = AuthorizedDomain(request, &d, AutoRegistrationDomains) ? register_service_instance(request, … in handle_regservice_request()
1713 if (request->u.servicereg.autoname) UpdateDeviceInfoRecord(&mDNSStorage); in handle_regservice_request()
1720 if (!ptr->uid || SystemUID(request->uid) || request->uid == ptr->uid) in handle_regservice_request()
1721 register_service_instance(request, &ptr->name); in handle_regservice_request()
1828 request_state *request; in udsserver_automatic_browse_domain_changed() local
1835 for (request = all_requests; request; request = request->next) in udsserver_automatic_browse_domain_changed()
1837 if (request->terminate != browse_termination_callback) continue; // Not a browse operation in udsserver_automatic_browse_domain_changed()
1838 if (!request->u.browser.default_domain) continue; // Not an auto-browse operation in udsserver_automatic_browse_domain_changed()
1839 if (!d->uid || SystemUID(request->uid) || request->uid == d->uid) in udsserver_automatic_browse_domain_changed()
1841 browser_t **ptr = &request->u.browser.browsers; in udsserver_automatic_browse_domain_changed()
1846 if (!*ptr) add_domain_to_browser(request, &d->name); in udsserver_automatic_browse_domain_changed()
1856 if (!p->uid || SystemUID(request->uid) || request->uid == p->uid) in udsserver_automatic_browse_domain_changed()
2120 mDNSlocal mStatus handle_sethost_request(request_state *request) in handle_sethost_request() argument
2122 get_flags(&request->msgptr, request->msgend); in handle_sethost_request()
2125 if (get_string(&request->msgptr, request->msgend, hostName, in handle_sethost_request()
2128 request->sd, request->flags); in handle_sethost_request()
2143 mDNSlocal mStatus handle_browse_request(request_state *request) in handle_browse_request() argument
2150 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_browse_request()
2151 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_browse_request()
2155 if (get_string(&request->msgptr, request->msgend, regtype, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_browse_request()
2156 …get_string(&request->msgptr, request->msgend, domain, MAX_ESCAPED_DOMAIN_NAME) < 0) return(mStatus… in handle_browse_request()
2158 …if (!request->msgptr) { LogMsg("%3d: DNSServiceBrowse(unreadable parameters)", request->sd); retur… in handle_browse_request()
2162 request->flags = flags; in handle_browse_request()
2175 request->u.browser.ForceMCast = (flags & kDNSServiceFlagsForceMulticast) != 0; in handle_browse_request()
2176 request->u.browser.interface_id = InterfaceID; in handle_browse_request()
2177 AssignDomainName(&request->u.browser.regtype, &typedn); in handle_browse_request()
2178 request->u.browser.default_domain = !domain[0]; in handle_browse_request()
2179 request->u.browser.browsers = NULL; in handle_browse_request()
2182 request->sd, request->flags, interfaceIndex, request->u.browser.regtype.c, domain); in handle_browse_request()
2187 request->terminate = browse_termination_callback; in handle_browse_request()
2192 err = add_domain_to_browser(request, &d); in handle_browse_request()
2194 …err = AuthorizedDomain(request, &d, AutoBrowseDomains) ? add_domain_to_browser(request, &d) : mSta… in handle_browse_request()
2201 if (!sdom->uid || SystemUID(request->uid) || request->uid == sdom->uid) in handle_browse_request()
2203 err = add_domain_to_browser(request, &sdom->name); in handle_browse_request()
2276 mDNSlocal void resolve_termination_callback(request_state *request) in resolve_termination_callback() argument
2278 LogOperation("%3d: DNSServiceResolve(%##s) STOP", request->sd, request->u.resolve.qtxt.qname.c); in resolve_termination_callback()
2279 mDNS_StopQuery(&mDNSStorage, &request->u.resolve.qtxt); in resolve_termination_callback()
2280 mDNS_StopQuery(&mDNSStorage, &request->u.resolve.qsrv); in resolve_termination_callback()
2281 …if (request->u.resolve.external_advertise) external_stop_resolving_service(&request->u.resolve.qsr… in resolve_termination_callback()
2284 mDNSlocal mStatus handle_resolve_request(request_state *request) in handle_resolve_request() argument
2291 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_resolve_request()
2292 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_resolve_request()
2297 request->flags = flags; in handle_resolve_request()
2304 if (get_string(&request->msgptr, request->msgend, name, 256) < 0 || in handle_resolve_request()
2305 get_string(&request->msgptr, request->msgend, regtype, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_resolve_request()
2306 get_string(&request->msgptr, request->msgend, domain, MAX_ESCAPED_DOMAIN_NAME) < 0) in handle_resolve_request()
2309 …if (!request->msgptr) { LogMsg("%3d: DNSServiceResolve(unreadable parameters)", request->sd); retu… in handle_resolve_request()
2314 mDNSPlatformMemZero(&request->u.resolve, sizeof(request->u.resolve)); in handle_resolve_request()
2317 request->u.resolve.qsrv.InterfaceID = InterfaceID; in handle_resolve_request()
2318 request->u.resolve.qsrv.Target = zeroAddr; in handle_resolve_request()
2319 AssignDomainName(&request->u.resolve.qsrv.qname, &fqdn); in handle_resolve_request()
2320 request->u.resolve.qsrv.qtype = kDNSType_SRV; in handle_resolve_request()
2321 request->u.resolve.qsrv.qclass = kDNSClass_IN; in handle_resolve_request()
2322 request->u.resolve.qsrv.LongLived = (flags & kDNSServiceFlagsLongLivedQuery ) != 0; in handle_resolve_request()
2323 request->u.resolve.qsrv.ExpectUnique = mDNStrue; in handle_resolve_request()
2324 request->u.resolve.qsrv.ForceMCast = (flags & kDNSServiceFlagsForceMulticast ) != 0; in handle_resolve_request()
2325 request->u.resolve.qsrv.ReturnIntermed = (flags & kDNSServiceFlagsReturnIntermediates) != 0; in handle_resolve_request()
2326 request->u.resolve.qsrv.SuppressUnusable = mDNSfalse; in handle_resolve_request()
2327 request->u.resolve.qsrv.SearchListIndex = 0; in handle_resolve_request()
2328 request->u.resolve.qsrv.AppendSearchDomains = 0; in handle_resolve_request()
2329 request->u.resolve.qsrv.RetryWithSearchDomains = mDNSfalse; in handle_resolve_request()
2330 request->u.resolve.qsrv.TimeoutQuestion = 0; in handle_resolve_request()
2331 request->u.resolve.qsrv.WakeOnResolve = (flags & kDNSServiceFlagsWakeOnResolve) != 0; in handle_resolve_request()
2332 request->u.resolve.qsrv.qnameOrig = mDNSNULL; in handle_resolve_request()
2333 request->u.resolve.qsrv.QuestionCallback = resolve_result_callback; in handle_resolve_request()
2334 request->u.resolve.qsrv.QuestionContext = request; in handle_resolve_request()
2336 request->u.resolve.qtxt.InterfaceID = InterfaceID; in handle_resolve_request()
2337 request->u.resolve.qtxt.Target = zeroAddr; in handle_resolve_request()
2338 AssignDomainName(&request->u.resolve.qtxt.qname, &fqdn); in handle_resolve_request()
2339 request->u.resolve.qtxt.qtype = kDNSType_TXT; in handle_resolve_request()
2340 request->u.resolve.qtxt.qclass = kDNSClass_IN; in handle_resolve_request()
2341 request->u.resolve.qtxt.LongLived = (flags & kDNSServiceFlagsLongLivedQuery ) != 0; in handle_resolve_request()
2342 request->u.resolve.qtxt.ExpectUnique = mDNStrue; in handle_resolve_request()
2343 request->u.resolve.qtxt.ForceMCast = (flags & kDNSServiceFlagsForceMulticast ) != 0; in handle_resolve_request()
2344 request->u.resolve.qtxt.ReturnIntermed = (flags & kDNSServiceFlagsReturnIntermediates) != 0; in handle_resolve_request()
2345 request->u.resolve.qtxt.SuppressUnusable = mDNSfalse; in handle_resolve_request()
2346 request->u.resolve.qtxt.SearchListIndex = 0; in handle_resolve_request()
2347 request->u.resolve.qtxt.AppendSearchDomains = 0; in handle_resolve_request()
2348 request->u.resolve.qtxt.RetryWithSearchDomains = mDNSfalse; in handle_resolve_request()
2349 request->u.resolve.qtxt.TimeoutQuestion = 0; in handle_resolve_request()
2350 request->u.resolve.qtxt.WakeOnResolve = 0; in handle_resolve_request()
2351 request->u.resolve.qtxt.qnameOrig = mDNSNULL; in handle_resolve_request()
2352 request->u.resolve.qtxt.QuestionCallback = resolve_result_callback; in handle_resolve_request()
2353 request->u.resolve.qtxt.QuestionContext = request; in handle_resolve_request()
2355 …request->u.resolve.ReportTime = NonZeroTime(mDNS_TimeNow(&mDNSStorage) + 130 * mDNSPlat… in handle_resolve_request()
2357 request->u.resolve.external_advertise = mDNSfalse; in handle_resolve_request()
2360 if (!AuthorizedDomain(request, &fqdn, AutoBrowseDomains)) return(mStatus_NoError); in handle_resolve_request()
2364 LogOperation("%3d: DNSServiceResolve(%##s) START", request->sd, request->u.resolve.qsrv.qname.c); in handle_resolve_request()
2365 err = mDNS_StartQuery(&mDNSStorage, &request->u.resolve.qsrv); in handle_resolve_request()
2368 err = mDNS_StartQuery(&mDNSStorage, &request->u.resolve.qtxt); in handle_resolve_request()
2369 if (err) mDNS_StopQuery(&mDNSStorage, &request->u.resolve.qsrv); in handle_resolve_request()
2372 request->terminate = resolve_termination_callback; in handle_resolve_request()
2374 …if (wasP2P || (!InterfaceID && IsLocalDomain(&fqdn) && (request->flags & kDNSServiceFlagsIncludeP2… in handle_resolve_request()
2376 request->u.resolve.external_advertise = mDNStrue; in handle_resolve_request()
2484 mDNSlocal mStatus SendAdditionalQuery(DNSQuestion *q, request_state *request, mStatus err) in SendAdditionalQuery() argument
2492 if (request->hdr.op == query_request) in SendAdditionalQuery()
2493 question2 = &request->u.queryrecord.q2; in SendAdditionalQuery()
2494 else if (request->hdr.op == addrinfo_request) in SendAdditionalQuery()
2497 question2 = &request->u.addrinfo.q42; in SendAdditionalQuery()
2499 question2 = &request->u.addrinfo.q62; in SendAdditionalQuery()
2572 …LogOperation("%3d: DNSServiceQueryRecord(%##s, %s) unicast", request->sd, q2->qname.c, DNSTypeName… in SendAdditionalQuery()
2574 …if (err) LogMsg("%3d: ERROR: DNSServiceQueryRecord %##s %s mDNS_StartQuery: %d", request->sd, q2->… in SendAdditionalQuery()
2914 mDNSlocal void queryrecord_termination_callback(request_state *request) in queryrecord_termination_callback() argument
2917 request->sd, request->u.queryrecord.q.qname.c, DNSTypeName(request->u.queryrecord.q.qtype)); in queryrecord_termination_callback()
2918 if (request->u.queryrecord.q.QuestionContext) in queryrecord_termination_callback()
2920 mDNS_StopQuery(&mDNSStorage, &request->u.queryrecord.q); // no need to error check in queryrecord_termination_callback()
2921 request->u.queryrecord.q.QuestionContext = mDNSNULL; in queryrecord_termination_callback()
2925 DNSQuestion *question = &request->u.queryrecord.q; in queryrecord_termination_callback()
2929 if (request->u.queryrecord.q.qnameOrig) in queryrecord_termination_callback()
2931 freeL("QueryTermination", request->u.queryrecord.q.qnameOrig); in queryrecord_termination_callback()
2932 request->u.queryrecord.q.qnameOrig = mDNSNULL; in queryrecord_termination_callback()
2934 …request->u.queryrecord.q.InterfaceID == mDNSInterface_P2P || (!request->u.queryrecord.q.InterfaceI… in queryrecord_termination_callback()
2937 …external_stop_browsing_for_service(&mDNSStorage, &request->u.queryrecord.q.qname, request->u.query… in queryrecord_termination_callback()
2939 if (request->u.queryrecord.q2) in queryrecord_termination_callback()
2941 if (request->u.queryrecord.q2->QuestionContext) in queryrecord_termination_callback()
2943 … LogInfo("queryrecord_termination_callback: Stopping q2 %##s", request->u.queryrecord.q2->qname.c); in queryrecord_termination_callback()
2944 mDNS_StopQuery(&mDNSStorage, request->u.queryrecord.q2); in queryrecord_termination_callback()
2948 DNSQuestion *question = request->u.queryrecord.q2; in queryrecord_termination_callback()
2951 if (request->u.queryrecord.q2->qnameOrig) in queryrecord_termination_callback()
2953 …LogInfo("queryrecord_termination_callback: freeing q2 qnameOrig %##s", request->u.queryrecord.q2->… in queryrecord_termination_callback()
2954 freeL("QueryTermination q2", request->u.queryrecord.q2->qnameOrig); in queryrecord_termination_callback()
2955 request->u.queryrecord.q2->qnameOrig = mDNSNULL; in queryrecord_termination_callback()
2957 freeL("queryrecord Q2", request->u.queryrecord.q2); in queryrecord_termination_callback()
2958 request->u.queryrecord.q2 = mDNSNULL; in queryrecord_termination_callback()
2962 mDNSlocal mStatus handle_queryrecord_request(request_state *request) in handle_queryrecord_request() argument
2964 DNSQuestion *const q = &request->u.queryrecord.q; in handle_queryrecord_request()
2969 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_queryrecord_request()
2970 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_queryrecord_request()
2974 if (get_string(&request->msgptr, request->msgend, name, 256) < 0) return(mStatus_BadParamErr); in handle_queryrecord_request()
2975 rrtype = get_uint16(&request->msgptr, request->msgend); in handle_queryrecord_request()
2976 rrclass = get_uint16(&request->msgptr, request->msgend); in handle_queryrecord_request()
2978 if (!request->msgptr) in handle_queryrecord_request()
2979 …{ LogMsg("%3d: DNSServiceQueryRecord(unreadable parameters)", request->sd); return(mStatus_BadPara… in handle_queryrecord_request()
2981 request->flags = flags; in handle_queryrecord_request()
2982 mDNSPlatformMemZero(&request->u.queryrecord, sizeof(request->u.queryrecord)); in handle_queryrecord_request()
2988 if (!AuthorizedDomain(request, &q->qname, AutoBrowseDomains)) return (mStatus_NoError); in handle_queryrecord_request()
3000 q->QuestionContext = request; in handle_queryrecord_request()
3031 …LogOperation("%3d: DNSServiceQueryRecord(%X, %d, %##s, %s) START", request->sd, flags, interfaceIn… in handle_queryrecord_request()
3033 …if (err) LogMsg("%3d: ERROR: DNSServiceQueryRecord %##s %s mDNS_StartQuery: %d", request->sd, q->q… in handle_queryrecord_request()
3036 request->terminate = queryrecord_termination_callback; in handle_queryrecord_request()
3045 err = SendAdditionalQuery(q, request, err); in handle_queryrecord_request()
3057 mDNSlocal reply_state *format_enumeration_reply(request_state *request, in format_enumeration_reply() argument
3069 reply = create_reply(enumeration_reply_op, len, request); in format_enumeration_reply()
3078 mDNSlocal void enum_termination_callback(request_state *request) in enum_termination_callback() argument
3080 mDNS_StopGetDomains(&mDNSStorage, &request->u.enumeration.q_all); in enum_termination_callback()
3081 mDNS_StopGetDomains(&mDNSStorage, &request->u.enumeration.q_default); in enum_termination_callback()
3088 request_state *request = question->QuestionContext; in enum_result_callback() local
3096 …if (!AuthorizedDomain(request, &answer->rdata->u.name, request->u.enumeration.flags ? AutoRegistra… in enum_result_callback()
3101 if (question == &request->u.enumeration.q_default && !AddRecord) return; in enum_result_callback()
3106 if (question == &request->u.enumeration.q_default) flags |= kDNSServiceFlagsDefault; in enum_result_callback()
3113 …reply = format_enumeration_reply(request, domain, flags, kDNSServiceInterfaceIndexAny, kDNSService… in enum_result_callback()
3116 …LogOperation("%3d: DNSServiceEnumerateDomains(%#2s) RESULT %s: %s", request->sd, question->qname.c… in enum_result_callback()
3118 append_reply(request, reply); in enum_result_callback()
3121 mDNSlocal mStatus handle_enum_request(request_state *request) in handle_enum_request() argument
3124 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_enum_request()
3128 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_enum_request()
3132 if (!request->msgptr) in handle_enum_request()
3133 …{ LogMsg("%3d: DNSServiceEnumerateDomains(unreadable parameters)", request->sd); return(mStatus_Ba… in handle_enum_request()
3140 request->u.enumeration.flags = reg; in handle_enum_request()
3145 request->u.enumeration.q_all .QuestionContext = request; in handle_enum_request()
3146 request->u.enumeration.q_default.QuestionContext = request; in handle_enum_request()
3152 LogOperation("%3d: DNSServiceEnumerateDomains(%X=%s)", request->sd, flags, in handle_enum_request()
3155 … = mDNS_GetDomains(&mDNSStorage, &request->u.enumeration.q_all, t_all, NULL, InterfaceID, enum_res… in handle_enum_request()
3158 …DNS_GetDomains(&mDNSStorage, &request->u.enumeration.q_default, t_default, NULL, InterfaceID, enum… in handle_enum_request()
3159 if (err) mDNS_StopGetDomains(&mDNSStorage, &request->u.enumeration.q_all); in handle_enum_request()
3160 else request->terminate = enum_termination_callback; in handle_enum_request()
3172 mDNSlocal mStatus handle_reconfirm_request(request_state *request) in handle_reconfirm_request() argument
3175 AuthRecord *rr = read_rr_from_ipc_msg(request, 0, 0); in handle_reconfirm_request()
3183 request->sd, RRDisplayString(&mDNSStorage, &rr->resrec), in handle_reconfirm_request()
3190 mDNSlocal mStatus handle_setdomain_request(request_state *request) in handle_setdomain_request() argument
3194 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_setdomain_request()
3196 if (get_string(&request->msgptr, request->msgend, domainstr, MAX_ESCAPED_DOMAIN_NAME) < 0 || in handle_setdomain_request()
3198 …{ LogMsg("%3d: DNSServiceSetDefaultDomainForUser(unreadable parameters)", request->sd); return(mSt… in handle_setdomain_request()
3200 LogOperation("%3d: DNSServiceSetDefaultDomainForUser(%##s)", request->sd, domain.c); in handle_setdomain_request()
3211 mDNSlocal void handle_getproperty_request(request_state *request) in handle_getproperty_request() argument
3215 if (get_string(&request->msgptr, request->msgend, prop, sizeof(prop)) >= 0) in handle_getproperty_request()
3217 LogOperation("%3d: DNSServiceGetProperty(%s)", request->sd, prop); in handle_getproperty_request()
3221 send_all(request->sd, (const char *)&x, sizeof(x)); in handle_getproperty_request()
3227 send_all(request->sd, (const char *)&BadParamErr, sizeof(BadParamErr)); in handle_getproperty_request()
3238 mDNSlocal void port_mapping_termination_callback(request_state *request) in port_mapping_termination_callback() argument
3240 LogOperation("%3d: DNSServiceNATPortMappingCreate(%X, %u, %u, %d) STOP", request->sd, in port_mapping_termination_callback()
3241 DNSServiceProtocol(request->u.pm.NATinfo.Protocol), in port_mapping_termination_callback()
3242 …mDNSVal16(request->u.pm.NATinfo.IntPort), mDNSVal16(request->u.pm.ReqExt), request->u.pm.NATinfo.N… in port_mapping_termination_callback()
3243 mDNS_StopNATOperation(&mDNSStorage, &request->u.pm.NATinfo); in port_mapping_termination_callback()
3249 request_state *request = (request_state *)n->clientContext; in port_mapping_create_request_callback() local
3254 …if (!request) { LogMsg("port_mapping_create_request_callback called with unknown request_state obj… in port_mapping_create_request_callback()
3263 rep = create_reply(port_mapping_reply_op, replyLen, request); in port_mapping_create_request_callback()
3271 *data++ = request->u.pm.NATinfo.ExternalAddress.b[0]; in port_mapping_create_request_callback()
3272 *data++ = request->u.pm.NATinfo.ExternalAddress.b[1]; in port_mapping_create_request_callback()
3273 *data++ = request->u.pm.NATinfo.ExternalAddress.b[2]; in port_mapping_create_request_callback()
3274 *data++ = request->u.pm.NATinfo.ExternalAddress.b[3]; in port_mapping_create_request_callback()
3275 *data++ = DNSServiceProtocol(request->u.pm.NATinfo.Protocol); in port_mapping_create_request_callback()
3276 *data++ = request->u.pm.NATinfo.IntPort.b[0]; in port_mapping_create_request_callback()
3277 *data++ = request->u.pm.NATinfo.IntPort.b[1]; in port_mapping_create_request_callback()
3278 *data++ = request->u.pm.NATinfo.ExternalPort.b[0]; in port_mapping_create_request_callback()
3279 *data++ = request->u.pm.NATinfo.ExternalPort.b[1]; in port_mapping_create_request_callback()
3280 put_uint32(request->u.pm.NATinfo.Lifetime, &data); in port_mapping_create_request_callback()
3282 …LogOperation("%3d: DNSServiceNATPortMappingCreate(%X, %u, %u, %d) RESULT %.4a:%u TTL %u", request-… in port_mapping_create_request_callback()
3283 DNSServiceProtocol(request->u.pm.NATinfo.Protocol), in port_mapping_create_request_callback()
3284 …mDNSVal16(request->u.pm.NATinfo.IntPort), mDNSVal16(request->u.pm.ReqExt), request->u.pm.NATinfo.N… in port_mapping_create_request_callback()
3285 …&request->u.pm.NATinfo.ExternalAddress, mDNSVal16(request->u.pm.NATinfo.ExternalPort), request->u.… in port_mapping_create_request_callback()
3287 append_reply(request, rep); in port_mapping_create_request_callback()
3290 mDNSlocal mStatus handle_port_mapping_request(request_state *request) in handle_port_mapping_request() argument
3295 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_port_mapping_request()
3296 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_port_mapping_request()
3298 mDNSu8 protocol = (mDNSu8)get_uint32(&request->msgptr, request->msgend); in handle_port_mapping_request()
3301 if (request->msgptr + 8 > request->msgend) request->msgptr = NULL; in handle_port_mapping_request()
3304 request->u.pm.NATinfo.IntPort.b[0] = *request->msgptr++; in handle_port_mapping_request()
3305 request->u.pm.NATinfo.IntPort.b[1] = *request->msgptr++; in handle_port_mapping_request()
3306 request->u.pm.ReqExt.b[0] = *request->msgptr++; in handle_port_mapping_request()
3307 request->u.pm.ReqExt.b[1] = *request->msgptr++; in handle_port_mapping_request()
3308 ttl = get_uint32(&request->msgptr, request->msgend); in handle_port_mapping_request()
3311 if (!request->msgptr) in handle_port_mapping_request()
3312 …{ LogMsg("%3d: DNSServiceNATPortMappingCreate(unreadable parameters)", request->sd); return(mStatu… in handle_port_mapping_request()
3316 …if (!mDNSIPPortIsZero(request->u.pm.NATinfo.IntPort) || !mDNSIPPortIsZero(request->u.pm.ReqExt) ||… in handle_port_mapping_request()
3320 if (mDNSIPPortIsZero(request->u.pm.NATinfo.IntPort)) return(mStatus_BadParamErr); in handle_port_mapping_request()
3324 …request->u.pm.NATinfo.Protocol = !protocol ? NATOp_AddrRequest : (protocol == kDNSServicePro… in handle_port_mapping_request()
3326 request->u.pm.NATinfo.RequestedPort = request->u.pm.ReqExt; in handle_port_mapping_request()
3327 request->u.pm.NATinfo.NATLease = ttl; in handle_port_mapping_request()
3328 request->u.pm.NATinfo.clientCallback = port_mapping_create_request_callback; in handle_port_mapping_request()
3329 request->u.pm.NATinfo.clientContext = request; in handle_port_mapping_request()
3331 LogOperation("%3d: DNSServiceNATPortMappingCreate(%X, %u, %u, %d) START", request->sd, in handle_port_mapping_request()
3332 …protocol, mDNSVal16(request->u.pm.NATinfo.IntPort), mDNSVal16(request->u.pm.ReqExt), request->u.pm… in handle_port_mapping_request()
3333 err = mDNS_StartNATOperation(&mDNSStorage, &request->u.pm.NATinfo); in handle_port_mapping_request()
3335 else request->terminate = port_mapping_termination_callback; in handle_port_mapping_request()
3346 mDNSlocal void addrinfo_termination_callback(request_state *request) in addrinfo_termination_callback() argument
3348 LogOperation("%3d: DNSServiceGetAddrInfo(%##s) STOP", request->sd, request->u.addrinfo.q4.qname.c); in addrinfo_termination_callback()
3350 if (request->u.addrinfo.q4.QuestionContext) in addrinfo_termination_callback()
3352 mDNS_StopQuery(&mDNSStorage, &request->u.addrinfo.q4); in addrinfo_termination_callback()
3353 request->u.addrinfo.q4.QuestionContext = mDNSNULL; in addrinfo_termination_callback()
3355 if (request->u.addrinfo.q4.qnameOrig) in addrinfo_termination_callback()
3357 freeL("QueryTermination", request->u.addrinfo.q4.qnameOrig); in addrinfo_termination_callback()
3358 request->u.addrinfo.q4.qnameOrig = mDNSNULL; in addrinfo_termination_callback()
3360 if (request->u.addrinfo.q42) in addrinfo_termination_callback()
3362 if (request->u.addrinfo.q42->QuestionContext) in addrinfo_termination_callback()
3364 LogInfo("addrinfo_termination_callback: Stopping q42 %##s", request->u.addrinfo.q42->qname.c); in addrinfo_termination_callback()
3365 mDNS_StopQuery(&mDNSStorage, request->u.addrinfo.q42); in addrinfo_termination_callback()
3367 if (request->u.addrinfo.q42->qnameOrig) in addrinfo_termination_callback()
3369 …LogInfo("addrinfo_termination_callback: freeing q42 qnameOrig %##s", request->u.addrinfo.q42->qnam… in addrinfo_termination_callback()
3370 freeL("QueryTermination q42", request->u.addrinfo.q42->qnameOrig); in addrinfo_termination_callback()
3371 request->u.addrinfo.q42->qnameOrig = mDNSNULL; in addrinfo_termination_callback()
3373 freeL("addrinfo Q42", request->u.addrinfo.q42); in addrinfo_termination_callback()
3374 request->u.addrinfo.q42 = mDNSNULL; in addrinfo_termination_callback()
3377 if (request->u.addrinfo.q6.QuestionContext) in addrinfo_termination_callback()
3379 mDNS_StopQuery(&mDNSStorage, &request->u.addrinfo.q6); in addrinfo_termination_callback()
3380 request->u.addrinfo.q6.QuestionContext = mDNSNULL; in addrinfo_termination_callback()
3382 if (request->u.addrinfo.q6.qnameOrig) in addrinfo_termination_callback()
3384 freeL("QueryTermination", request->u.addrinfo.q6.qnameOrig); in addrinfo_termination_callback()
3385 request->u.addrinfo.q6.qnameOrig = mDNSNULL; in addrinfo_termination_callback()
3387 if (request->u.addrinfo.q62) in addrinfo_termination_callback()
3389 if (request->u.addrinfo.q62->QuestionContext) in addrinfo_termination_callback()
3391 LogInfo("addrinfo_termination_callback: Stopping q62 %##s", request->u.addrinfo.q62->qname.c); in addrinfo_termination_callback()
3392 mDNS_StopQuery(&mDNSStorage, request->u.addrinfo.q62); in addrinfo_termination_callback()
3394 if (request->u.addrinfo.q62->qnameOrig) in addrinfo_termination_callback()
3396 …LogInfo("addrinfo_termination_callback: freeing q62 qnameOrig %##s", request->u.addrinfo.q62->qnam… in addrinfo_termination_callback()
3397 freeL("QueryTermination q62", request->u.addrinfo.q62->qnameOrig); in addrinfo_termination_callback()
3398 request->u.addrinfo.q62->qnameOrig = mDNSNULL; in addrinfo_termination_callback()
3400 freeL("addrinfo Q62", request->u.addrinfo.q62); in addrinfo_termination_callback()
3401 request->u.addrinfo.q62 = mDNSNULL; in addrinfo_termination_callback()
3405 mDNSlocal mStatus handle_addrinfo_request(request_state *request) in handle_addrinfo_request() argument
3411 DNSServiceFlags flags = get_flags(&request->msgptr, request->msgend); in handle_addrinfo_request()
3412 mDNSu32 interfaceIndex = get_uint32(&request->msgptr, request->msgend); in handle_addrinfo_request()
3414 mDNSPlatformMemZero(&request->u.addrinfo, sizeof(request->u.addrinfo)); in handle_addrinfo_request()
3415 …request->u.addrinfo.interface_id = mDNSPlatformInterfaceIDfromInterfaceIndex(&mDNSStorage, interfa… in handle_addrinfo_request()
3416 request->u.addrinfo.flags = flags; in handle_addrinfo_request()
3417 request->u.addrinfo.protocol = get_uint32(&request->msgptr, request->msgend); in handle_addrinfo_request()
3419 if (interfaceIndex && !request->u.addrinfo.interface_id) return(mStatus_BadParamErr); in handle_addrinfo_request()
3420 …if (request->u.addrinfo.protocol > (kDNSServiceProtocol_IPv4|kDNSServiceProtocol_IPv6)) return(mSt… in handle_addrinfo_request()
3422 if (get_string(&request->msgptr, request->msgend, hostname, 256) < 0) return(mStatus_BadParamErr); in handle_addrinfo_request()
3424 …if (!request->msgptr) { LogMsg("%3d: DNSServiceGetAddrInfo(unreadable parameters)", request->sd); … in handle_addrinfo_request()
3430 if (!AuthorizedDomain(request, &d, AutoBrowseDomains)) return (mStatus_NoError); in handle_addrinfo_request()
3433 if (!request->u.addrinfo.protocol) in handle_addrinfo_request()
3436 request->u.addrinfo.protocol = (kDNSServiceProtocol_IPv4 | kDNSServiceProtocol_IPv6); in handle_addrinfo_request()
3439 …request->u.addrinfo.q4.InterfaceID = request->u.addrinfo.q6.InterfaceID = request->u.add… in handle_addrinfo_request()
3440 request->u.addrinfo.q4.Target = request->u.addrinfo.q6.Target = zeroAddr; in handle_addrinfo_request()
3441 request->u.addrinfo.q4.qname = request->u.addrinfo.q6.qname = d; in handle_addrinfo_request()
3442 …request->u.addrinfo.q4.qclass = request->u.addrinfo.q6.qclass = kDNSServiceCla… in handle_addrinfo_request()
3443 …request->u.addrinfo.q4.LongLived = request->u.addrinfo.q6.LongLived = (flags & kDNSS… in handle_addrinfo_request()
3444 request->u.addrinfo.q4.ExpectUnique = request->u.addrinfo.q6.ExpectUnique = mDNSfalse; in handle_addrinfo_request()
3445 …request->u.addrinfo.q4.ForceMCast = request->u.addrinfo.q6.ForceMCast = (flags & kDNSS… in handle_addrinfo_request()
3446 …request->u.addrinfo.q4.ReturnIntermed = request->u.addrinfo.q6.ReturnIntermed = (flags & kDNSS… in handle_addrinfo_request()
3447 …request->u.addrinfo.q4.SuppressUnusable = request->u.addrinfo.q6.SuppressUnusable = (flags & kDNSS… in handle_addrinfo_request()
3448 …request->u.addrinfo.q4.TimeoutQuestion = request->u.addrinfo.q6.TimeoutQuestion = (flags & kDNSS… in handle_addrinfo_request()
3449 request->u.addrinfo.q4.WakeOnResolve = request->u.addrinfo.q6.WakeOnResolve = 0; in handle_addrinfo_request()
3450 request->u.addrinfo.q4.qnameOrig = request->u.addrinfo.q6.qnameOrig = mDNSNULL; in handle_addrinfo_request()
3452 if (request->u.addrinfo.protocol & kDNSServiceProtocol_IPv4) in handle_addrinfo_request()
3454 request->u.addrinfo.q4.qtype = kDNSServiceType_A; in handle_addrinfo_request()
3455 request->u.addrinfo.q4.SearchListIndex = 0; in handle_addrinfo_request()
3462 request->u.addrinfo.q4.AppendSearchDomains = 1; in handle_addrinfo_request()
3463 request->u.addrinfo.q4.AppendLocalSearchDomains = 1; in handle_addrinfo_request()
3467 request->u.addrinfo.q4.AppendSearchDomains = 0; in handle_addrinfo_request()
3468 request->u.addrinfo.q4.AppendLocalSearchDomains = 0; in handle_addrinfo_request()
3470 …request->u.addrinfo.q4.RetryWithSearchDomains = (ApplySearchDomainsFirst(&request->u.addrinfo.q4) … in handle_addrinfo_request()
3471 request->u.addrinfo.q4.QuestionCallback = queryrecord_result_callback; in handle_addrinfo_request()
3472 request->u.addrinfo.q4.QuestionContext = request; in handle_addrinfo_request()
3473 err = mDNS_StartQuery(&mDNSStorage, &request->u.addrinfo.q4); in handle_addrinfo_request()
3477 request->u.addrinfo.q4.QuestionContext = mDNSNULL; in handle_addrinfo_request()
3480 err = SendAdditionalQuery(&request->u.addrinfo.q4, request, err); in handle_addrinfo_request()
3484 if (!err && (request->u.addrinfo.protocol & kDNSServiceProtocol_IPv6)) in handle_addrinfo_request()
3486 request->u.addrinfo.q6.qtype = kDNSServiceType_AAAA; in handle_addrinfo_request()
3487 request->u.addrinfo.q6.SearchListIndex = 0; in handle_addrinfo_request()
3490 request->u.addrinfo.q6.AppendSearchDomains = 1; in handle_addrinfo_request()
3491 request->u.addrinfo.q6.AppendLocalSearchDomains = 1; in handle_addrinfo_request()
3495 request->u.addrinfo.q6.AppendSearchDomains = 0; in handle_addrinfo_request()
3496 request->u.addrinfo.q6.AppendLocalSearchDomains = 0; in handle_addrinfo_request()
3498 …request->u.addrinfo.q6.RetryWithSearchDomains = (ApplySearchDomainsFirst(&request->u.addrinfo.q6) … in handle_addrinfo_request()
3499 request->u.addrinfo.q6.QuestionCallback = queryrecord_result_callback; in handle_addrinfo_request()
3500 request->u.addrinfo.q6.QuestionContext = request; in handle_addrinfo_request()
3501 err = mDNS_StartQuery(&mDNSStorage, &request->u.addrinfo.q6); in handle_addrinfo_request()
3505 request->u.addrinfo.q6.QuestionContext = mDNSNULL; in handle_addrinfo_request()
3506 if (request->u.addrinfo.protocol & kDNSServiceProtocol_IPv4) in handle_addrinfo_request()
3509 mDNS_StopQuery(&mDNSStorage, &request->u.addrinfo.q4); in handle_addrinfo_request()
3510 request->u.addrinfo.q4.QuestionContext = mDNSNULL; in handle_addrinfo_request()
3514 err = SendAdditionalQuery(&request->u.addrinfo.q6, request, err); in handle_addrinfo_request()
3519 request->sd, flags, interfaceIndex, request->u.addrinfo.protocol, d.c); in handle_addrinfo_request()
3521 if (!err) request->terminate = addrinfo_termination_callback; in handle_addrinfo_request()
3913 request_state *request = NewRequest(); in connect_callback() local
3914 request->ts = t_morecoming; in connect_callback()
3915 request->sd = sd; in connect_callback()
3916 request->errsd = sd; in connect_callback()
3920 …0, LOCAL_PEERCRED, &x, &xucredlen) >= 0 && x.cr_version == XUCRED_VERSION) request->uid = x.cr_uid; in connect_callback()
3924 LogOperation("%3d: Adding FD for uid %u", request->sd, request->uid); in connect_callback()
3925 udsSupportAddFDToEventLoop(sd, request_callback, request, &request->platform_data); in connect_callback()