Lines Matching defs:req
280 mDNSlocal void LogMcastClientInfo(request_state *req);
281 mDNSlocal void GetMcastClients(request_state *req);
349 mDNSlocal void LogMcastQuestion(mDNS *const m, const DNSQuestion *const q, request_state *req, q_state status)
366 req->process_id, req->pid_name);
374 mDNSlocal void LogMcastService(mDNS *const m, const AuthRecord *const ar, request_state *req, reg_state status)
391 req->process_id, req->pid_name);
408 request_state *req, *r;
409 for (req = all_requests; req; req=req->next)
411 if (req->primary) // If this is a subbordinate operation, check that the parent is in the list
413 for (r = all_requests; r && r != req; r=r->next)
414 if (r == req->primary)
418 GetMcastClients(req);
441 request_state *req, *r;
442 for (req = all_requests; req; req=req->next)
444 if (req->primary) // If this is a subbordinate operation, check that the parent is in the list
446 for (r = all_requests; r && r != req; r=r->next)
447 if (r == req->primary)
449 LogMcastNoIdent("%3d: Orphan operation; parent not found in request list", req->sd);
452 LogMcastClientInfo(req);
469 mDNSlocal void abort_request(request_state *req)
471 if (req->terminate == (req_termination_fn) ~0)
472 { LogMsg("abort_request: ERROR: Attempt to abort operation %p with req->terminate %p", req, req->terminate); return; }
475 // If this is actually a shared connection operation, then its req->terminate function will scan
477 if (req->terminate) req->terminate(req);
479 if (!dnssd_SocketValid(req->sd))
480 { LogMsg("abort_request: ERROR: Attempt to abort operation %p with invalid fd %d", req, req->sd); return; }
483 if (!req->primary)
485 if (req->errsd != req->sd) LogOperation("%3d: Removing FD and closing errsd %d", req->sd, req->errsd);
486 else LogOperation("%3d: Removing FD", req->sd);
487 udsSupportRemoveFDFromEventLoop(req->sd, req->platform_data); // Note: This also closes file descriptor req->sd for us
488 if (req->errsd != req->sd) { dnssd_close(req->errsd); req->errsd = req->sd; }
490 while (req->replies) // free pending replies
492 reply_state *ptr = req->replies;
493 req->replies = req->replies->next;
498 // Set req->sd to something invalid, so that udsserver_idle knows to unlink and free this structure
502 req->sd = req->errsd = -2;
504 req->sd = req->errsd = dnssd_InvalidSocket;
506 // We also set req->terminate to a bogus value so we know if abort_request() gets called again for this request
507 req->terminate = (req_termination_fn) ~0;
510 mDNSlocal void AbortUnlinkAndFree(request_state *req)
513 abort_request(req);
514 while (*p && *p != req) p=&(*p)->next;
515 if (*p) { *p = req->next; freeL("request_state/AbortUnlinkAndFree", req); }
516 else LogMsg("AbortUnlinkAndFree: ERROR: Attempt to abort operation %p not in list", req);
549 mDNSlocal void append_reply(request_state *req, reply_state *rep)
554 if (req->no_reply)
560 r = req->primary ? req->primary : req;
1179 request_state **req = &all_requests;
1183 while (*req)
1185 if ((*req)->primary == request)
1188 request_state *tmp = *req;
1189 if (tmp->primary == tmp) LogMsg("connection_termination ERROR (*req)->primary == *req for %p %d", tmp, tmp->sd);
1190 if (tmp->replies) LogMsg("connection_termination ERROR How can subordinate req %p %d have replies queued?", tmp, tmp->sd);
1192 *req = tmp->next;
1196 req = &(*req)->next;
1218 request_state **req = &all_requests;
1220 while (*req)
1222 if ((*req)->primary == request &&
1223 (*req)->hdr.client_context.u32[0] == request->hdr.client_context.u32[0] &&
1224 (*req)->hdr.client_context.u32[1] == request->hdr.client_context.u32[1])
1227 request_state *tmp = *req;
1229 *req = tmp->next;
1233 req = &(*req)->next;
1341 request_state *req;
1342 for (req = all_requests; req; req = req->next)
1343 if (req->primary == request &&
1344 req->hdr.client_context.u32[0] == request->hdr.client_context.u32[0] &&
1345 req->hdr.client_context.u32[1] == request->hdr.client_context.u32[1]) return(req);
2202 request_state *req = question->QuestionContext;
2207 { LogMsg("%3d: FoundInstance: Should not be called with rrtype %d (not a PTR record)", req->sd, answer->rrtype); return; }
2214 if (GenerateNTDResponse(&answer->rdata->u.name, answer->InterfaceID, req, &rep, browse_reply_op, flags, mStatus_NoError) != mStatus_NoError)
2216 if (SameDomainName(&req->u.browser.regtype, (const domainname*)"\x09_services\x07_dns-sd\x04_udp"))
2220 GenerateBonjourBrowserResponse(&answer->rdata->u.name, answer->InterfaceID, req, &rep, browse_reply_op, flags, mStatus_NoError);
2225 req->sd, answer->name->c, answer->rdata->u.name.c);
2232 req->sd, question->qname.c, DNSTypeName(question->qtype), AddRecord ? "Add" : "Rmv",
2235 append_reply(req, rep);
2477 request_state *req;
2480 for (req = all_requests; req; req = req->next)
2482 if (req->terminate == regservice_termination_callback && req->u.servicereg.autoname && req->interfaceIndex != kDNSServiceInterfaceIndexLocalOnly)
2514 request_state *req;
2523 for (req = all_requests; req; req = req->next)
2524 if (req->terminate == regservice_termination_callback)
2525 if (req->u.servicereg.autoname && !SameDomainLabelCS(req->u.servicereg.name.c, m->nicelabel.c))
2527 req->u.servicereg.name = m->nicelabel;
2528 for (ptr = req->u.servicereg.instances; ptr; ptr = ptr->next)
2740 request_state *req = question->QuestionContext;
2743 LogOperation("%3d: DNSServiceResolve(%##s) %s %s", req->sd, question->qname.c, AddRecord ? "ADD" : "RMV", RRDisplayString(m, answer));
2747 if (req->u.resolve.srv == answer) req->u.resolve.srv = mDNSNULL;
2748 if (req->u.resolve.txt == answer) req->u.resolve.txt = mDNSNULL;
2752 if (answer->rrtype == kDNSType_SRV) req->u.resolve.srv = answer;
2753 if (answer->rrtype == kDNSType_TXT) req->u.resolve.txt = answer;
2755 if (!req->u.resolve.txt || !req->u.resolve.srv) return; // only deliver result to client if we have both answers
2758 ConvertDomainNameToCString(&req->u.resolve.srv->rdata->u.srv.target, target);
2767 len += req->u.resolve.txt->rdlength;
2770 rep = create_reply(resolve_reply_op, len, req);
2780 *data++ = req->u.resolve.srv->rdata->u.srv.port.b[0];
2781 *data++ = req->u.resolve.srv->rdata->u.srv.port.b[1];
2782 put_uint16(req->u.resolve.txt->rdlength, &data);
2783 put_rdata (req->u.resolve.txt->rdlength, req->u.resolve.txt->rdata->u.data, &data);
2785 LogOperation("%3d: DNSServiceResolve(%s) RESULT %s:%d", req->sd, fullname, target, mDNSVal16(req->u.resolve.srv->rdata->u.srv.port));
2786 append_reply(req, rep);
3212 mDNSlocal mDNSBool RetryQuestionWithSearchDomains(mDNS *const m, DNSQuestion *question, request_state *req, QC_result AddRecord)
3238 LogOperation("%3d: RetryQuestionWithSearchDomains(%##s, %s), retrying after appending search domain", req->sd, question->qname.c, DNSTypeName(question->qtype));
3246 LogMsg("%3d: ERROR: RetryQuestionWithSearchDomains %##s %s mDNS_StartQuery: %d, while retrying with search domains", req->sd, question->qname.c, DNSTypeName(question->qtype), (int)err);
3255 LogInfo("%3d: RetryQuestionWithSearchDomains: Not appending search domains - SuppressQuery %d, SearchListIndex %d, AppendSearchDomains %d", req->sd, AddRecord, question->SearchListIndex, question->AppendSearchDomains);
3260 mDNSlocal void queryrecord_result_reply(mDNS *const m, request_state *req, DNSQuestion *question, const ResourceRecord *const answer, QC_result AddRecord,
3271 LogOperation("%3d: %s(%##s, %s) %s %s", req->sd,
3272 req->hdr.op == query_request ? "DNSServiceQueryRecord" : "DNSServiceGetAddrInfo",
3283 rep = create_reply(req->hdr.op == query_request ? query_reply_op : addrinfo_reply_op, len, req);
3337 append_reply(req, rep);
3345 else if ((AddRecord == QC_add) && req->hdr.op == addrinfo_request)
3351 req->u.addrinfo.v4ans = 1;
3353 req->u.addrinfo.v6ans = 1;
3355 else if ((AddRecord == QC_add) && req->hdr.op == query_request)
3358 req->u.queryrecord.ans = 1;
3370 if (getsockopt(req->sd, 0, LOCAL_PEERCRED, &x, &xucredlen) >= 0 &&
3442 request_state *req = question->QuestionContext;
3450 if (!req)
3455 if (req->hdr.op == query_request && question == req->u.queryrecord.q2)
3456 q = &req->u.queryrecord.q;
3457 else if (req->hdr.op == addrinfo_request && question == req->u.addrinfo.q42)
3458 q = &req->u.addrinfo.q4;
3459 else if (req->hdr.op == addrinfo_request && question == req->u.addrinfo.q62)
3460 q = &req->u.addrinfo.q6;
3492 LogOperation("%3d: DNSServiceQueryRecord(%##s, %s) unicast, context %p", req->sd, question->qname.c, DNSTypeName(question->qtype), question->QuestionContext);
3496 question->QuestionContext = req;
3498 if (err) LogMsg("%3d: ERROR: queryrecord_result_callback %##s %s mDNS_StartQuery: %d", req->sd, question->qname.c, DNSTypeName(question->qtype), (int)err);
3520 if (RetryQuestionWithSearchDomains(m, question, req, AddRecord))
3545 queryrecord_result_reply(m, req, question, answer, AddRecord, kDNSServiceErr_NoSuchRecord);
3610 if (RetryQuestionWithSearchDomains(m, question, req, AddRecord))
3616 err = SendAdditionalQuery(question, req, err);
3623 queryrecord_result_reply(m, req, question, answer, AddRecord, error);
3693 mDNSlocal void SetQuestionPolicy(DNSQuestion *q, request_state *req)
3696 q->euid = req->uid;
3707 if (req->validUUID)
3711 q->uuid[i] = req->uuid[i];
3717 q->pid = req->process_id;
3720 //debugf("SetQuestionPolicy: q->euid[%d] q->pid[%d] uuid is valid : %s", q->euid, q->pid, req->validUUID ? "true" : "false");
4156 const request_state *req;
4164 for (req = all_requests; req; req=req->next)
4166 if (req->hdr.op == query_request)
4167 q = &req->u.queryrecord.q;
4168 else if (req->hdr.op == addrinfo_request)
4169 q = &req->u.addrinfo.q4;
4170 else if (req->hdr.op == addrinfo_request)
4171 q = &req->u.addrinfo.q6;
4178 pid = req->process_id;
4179 LogMsg("DNSServiceGetPID: srcport %d, pid %d [%s] question %##s", htons(srcport), pid, req->pid_name, q->qname.c);
4630 // read_msg may be called any time when the transfer state (req->ts) is t_morecoming.
4632 mDNSlocal void read_msg(request_state *req)
4634 if (req->ts == t_terminated || req->ts == t_error)
4635 { LogMsg("%3d: ERROR: read_msg called with transfer state terminated or error", req->sd); req->ts = t_error; return; }
4637 if (req->ts == t_complete) // this must be death or something is wrong
4640 int nread = udsSupportReadFD(req->sd, buf, 4, 0, req->platform_data);
4641 if (!nread) { req->ts = t_terminated; return; }
4643 LogMsg("%3d: ERROR: read data from a completed request", req->sd);
4644 req->ts = t_error;
4648 if (req->ts != t_morecoming)
4649 { LogMsg("%3d: ERROR: read_msg called with invalid transfer state (%d)", req->sd, req->ts); req->ts = t_error; return; }
4651 if (req->hdr_bytes < sizeof(ipc_msg_hdr))
4653 mDNSu32 nleft = sizeof(ipc_msg_hdr) - req->hdr_bytes;
4654 int nread = udsSupportReadFD(req->sd, (char *)&req->hdr + req->hdr_bytes, nleft, 0, req->platform_data);
4655 if (nread == 0) { req->ts = t_terminated; return; }
4657 req->hdr_bytes += nread;
4658 if (req->hdr_bytes > sizeof(ipc_msg_hdr))
4659 { LogMsg("%3d: ERROR: read_msg - read too many header bytes", req->sd); req->ts = t_error; return; }
4662 if (req->hdr_bytes == sizeof(ipc_msg_hdr))
4664 ConvertHeaderBytes(&req->hdr);
4665 if (req->hdr.version != VERSION)
4666 { LogMsg("%3d: ERROR: client version 0x%08X daemon version 0x%08X", req->sd, req->hdr.version, VERSION); req->ts = t_error; return; }
4671 if (req->hdr.datalen > 70000)
4672 { LogMsg("%3d: ERROR: read_msg: hdr.datalen %u (0x%X) > 70000", req->sd, req->hdr.datalen, req->hdr.datalen); req->ts = t_error; return; }
4673 req->msgbuf = mallocL("request_state msgbuf", req->hdr.datalen + MSG_PAD_BYTES);
4674 if (!req->msgbuf) { my_perror("ERROR: malloc"); req->ts = t_error; return; }
4675 req->msgptr = req->msgbuf;
4676 req->msgend = req->msgbuf + req->hdr.datalen;
4677 mDNSPlatformMemZero(req->msgbuf, req->hdr.datalen + MSG_PAD_BYTES);
4682 // Note: For cancel_request req->hdr.datalen == 0, but there's no error return socket for cancel_request
4685 if (req->hdr_bytes == sizeof(ipc_msg_hdr) && req->data_bytes < req->hdr.datalen)
4687 mDNSu32 nleft = req->hdr.datalen - req->data_bytes;
4690 struct iovec vec = { req->msgbuf + req->data_bytes, nleft }; // Tell recvmsg where we want the bytes put
4701 nread = recvmsg(req->sd, &msg, 0);
4703 nread = udsSupportReadFD(req->sd, (char *)req->msgbuf + req->data_bytes, nleft, 0, req->platform_data);
4705 if (nread == 0) { req->ts = t_terminated; return; }
4707 req->data_bytes += nread;
4708 if (req->data_bytes > req->hdr.datalen)
4709 { LogMsg("%3d: ERROR: read_msg - read too many data bytes", req->sd); req->ts = t_error; return; }
4713 LogMsg("%3d: Expecting %d %d %d %d", req->sd, sizeof(cbuf), sizeof(cbuf), SOL_SOCKET, SCM_RIGHTS);
4714 LogMsg("%3d: Got %d %d %d %d", req->sd, msg.msg_controllen, cmsg ? cmsg->cmsg_len : -1, cmsg ? cmsg->cmsg_level : -1, cmsg ? cmsg->cmsg_type : -1);
4722 if (req->hdr.op == send_bpf)
4725 LogOperation("%3d: Got len %d, BPF %d", req->sd, cmsg->cmsg_len, x);
4730 req->errsd = *(dnssd_sock_t *)CMSG_DATA(cmsg);
4732 LogMsg("%3d: read req->errsd %d", req->sd, req->errsd);
4734 if (req->data_bytes < req->hdr.datalen)
4736 LogMsg("%3d: Client(PID [%d](%s)) sent result code socket %d via SCM_RIGHTS with req->data_bytes %d < req->hdr.datalen %d",
4737 req->sd, req->process_id, req->pid_name, req->errsd, req->data_bytes, req->hdr.datalen);
4738 req->ts = t_error;
4746 if (req->hdr_bytes == sizeof(ipc_msg_hdr) && req->data_bytes == req->hdr.datalen)
4748 if (req->terminate && req->hdr.op != cancel_request)
4754 port.b[0] = req->msgptr[0];
4755 port.b[1] = req->msgptr[1];
4756 req->msgptr += 2;
4762 get_string(&req->msgptr, req->msgend, ctrl_path, MAX_CTLPATH); // path is first element in message buffer
4771 if (req->errsd == req->sd)
4772 { LogMsg("%3d: read_msg: ERROR failed to get errsd via SCM_RIGHTS", req->sd); req->ts = t_error; return; }
4777 req->errsd = socket(AF_DNSSD, SOCK_STREAM, 0);
4778 if (!dnssd_SocketValid(req->errsd))
4781 req->ts = t_error;
4785 if (connect(req->errsd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0)
4790 req->sd, cliaddr.sun_path, dnssd_errno, dnssd_strerror(dnssd_errno));
4792 LogMsg("%3d: read_msg: stat failed ā%sā errno %d (%s)", req->sd, cliaddr.sun_path, dnssd_errno, dnssd_strerror(dnssd_errno));
4794 LogMsg("%3d: read_msg: file ā%sā mode %o (octal) uid %d gid %d", req->sd, cliaddr.sun_path, sb.st_mode, sb.st_uid, sb.st_gid);
4796 req->ts = t_error;
4803 LogOperation("%3d: Result code socket %d created %08X %08X", req->sd, req->errsd, req->hdr.client_context.u32[1], req->hdr.client_context.u32[0]);
4805 if (ioctlsocket(req->errsd, FIONBIO, &opt) != 0)
4807 if (fcntl(req->errsd, F_SETFL, fcntl(req->errsd, F_GETFL, 0) | O_NONBLOCK) != 0)
4811 req->sd, dnssd_errno, dnssd_strerror(dnssd_errno));
4812 req->ts = t_error;
4817 req->ts = t_complete;
4824 LogMsg("%3d: ERROR: read_msg errno %d (%s)", req->sd, dnssd_errno, dnssd_strerror(dnssd_errno));
4825 req->ts = t_error;
4837 request_state *req = info;
4844 read_msg(req);
4845 if (req->ts == t_morecoming)
4847 if (req->ts == t_terminated || req->ts == t_error)
4849 AbortUnlinkAndFree(req);
4852 if (req->ts != t_complete)
4854 LogMsg("request_callback: req->ts %d != t_complete PID[%d][%s]", req->ts, req->process_id, req->pid_name);
4855 AbortUnlinkAndFree(req);
4858 if (req->hdr.version != VERSION)
4861 req->hdr.version, VERSION, req->process_id, req->pid_name);
4862 AbortUnlinkAndFree(req);
4866 switch(req->hdr.op) // Interface + other data
4888 default: LogMsg("request_callback: ERROR: validate_message - unsupported req type: %d PID[%d][%s]",
4889 req->hdr.op, req->process_id, req->pid_name);
4893 if ((mDNSs32)req->data_bytes < min_size)
4896 req->data_bytes, req->hdr.op, min_size, req->process_id, req->pid_name);
4897 AbortUnlinkAndFree(req);
4900 if (LightweightOp(req->hdr.op) && !req->terminate)
4903 req->hdr.op, req->process_id, req->pid_name);
4904 AbortUnlinkAndFree(req);
4908 // If req->terminate is already set, this means this operation is sharing an existing connection
4909 if (req->terminate && !LightweightOp(req->hdr.op))
4912 newreq->primary = req;
4913 newreq->sd = req->sd;
4914 newreq->errsd = req->errsd;
4915 newreq->uid = req->uid;
4916 newreq->hdr = req->hdr;
4917 newreq->msgbuf = req->msgbuf;
4918 newreq->msgptr = req->msgptr;
4919 newreq->msgend = req->msgend;
4922 if (req->validUUID)
4928 newreq->uuid[i] = req->uuid[i];
4933 if (req->process_id)
4935 newreq->process_id = req->process_id;
4942 req = newreq;
4946 if (req->hdr.ipc_flags & IPC_FLAGS_NOREPLY) req->no_reply = 1;
4950 if (mDNSStorage.ShutdownTime && req->hdr.op != cancel_request && req->hdr.op != getproperty_request)
4956 switch(req->hdr.op)
4961 req->sd, req->process_id, req->pid_name);
4962 req->terminate = connection_termination;
4966 req->sd, req->process_id, req->pid_name);
4967 req->terminate = connection_termination;
4968 handle_connection_delegate_request(req);
4970 case resolve_request: err = handle_resolve_request (req); break;
4971 case query_request: err = handle_queryrecord_request (req); break;
4972 case browse_request: err = handle_browse_request (req); break;
4973 case reg_service_request: err = handle_regservice_request (req); break;
4974 case enumeration_request: err = handle_enum_request (req); break;
4975 case reconfirm_record_request: err = handle_reconfirm_request (req); break;
4976 case setdomain_request: err = handle_setdomain_request (req); break;
4977 case getproperty_request: handle_getproperty_request (req); break;
4978 case getpid_request: handle_getpid_request (req); break;
4979 case port_mapping_request: err = handle_port_mapping_request(req); break;
4980 case addrinfo_request: err = handle_addrinfo_request (req); break;
4984 case reg_record_request: err = handle_regrecord_request (req); break;
4985 case add_record_request: err = handle_add_request (req); break;
4986 case update_record_request: err = handle_update_request (req); break;
4987 case remove_record_request: err = handle_removerecord_request(req); break;
4988 case cancel_request: handle_cancel_request (req); break;
4989 case release_request: err = handle_release_request (req); break;
4990 default: LogMsg("request_callback: %3d:ERROR: Unsupported UDS req:%d PID[%d][%s]",
4991 req->sd, req->hdr.op, req->process_id, req->pid_name); break;
4994 // req->msgbuf may be NULL, e.g. for connection_request or remove_record_request
4995 if (req->msgbuf) freeL("request_state msgbuf", req->msgbuf);
4999 if (req->hdr.op != cancel_request && req->hdr.op != getproperty_request && req->hdr.op != send_bpf && req->hdr.op != getpid_request)
5002 send_all(req->errsd, (const char *)&err_netorder, sizeof(err_netorder));
5003 if (req->errsd != req->sd)
5006 req->sd, req->errsd, req->hdr.client_context.u32[1], req->hdr.client_context.u32[0], err);
5007 dnssd_close(req->errsd);
5008 req->errsd = req->sd;
5010 if (req->primary) req->primary->errsd = req->primary->sd;
5014 // Reset ready to accept the next req on this pipe
5015 if (req->primary) req = req->primary;
5016 req->ts = t_morecoming;
5017 req->hdr_bytes = 0;
5018 req->data_bytes = 0;
5019 req->msgbuf = mDNSNULL;
5020 req->msgptr = mDNSNULL;
5021 req->msgend = 0;
5277 mDNSlocal void LogClientInfo(mDNS *const m, request_state *req)
5280 if (req->primary)
5283 mDNS_snprintf(prefix, sizeof(prefix), "%3d:", req->sd);
5285 if (!req->terminate)
5287 else if (req->terminate == connection_termination)
5292 for (p = req->u.reg_recs; p; p=p->next) num_records++;
5293 for (r = req->next; r; r=r->next) if (r->primary == req) num_ops++;
5296 req->process_id, req->pid_name);
5297 for (p = req->u.reg_recs; p; p=p->next)
5299 req->flags, req->interfaceIndex, p->key, ARDisplayString(m, p->rr), req->process_id, req->pid_name);
5300 for (r = req->next; r; r=r->next) if (r->primary == req) LogClientInfo(m, r);
5302 else if (req->terminate == regservice_termination_callback)
5306 for (ptr = req->u.servicereg.instances; ptr; ptr = ptr->next)
5308 (ptr == req->u.servicereg.instances) ? prefix : " ", req->flags, req->interfaceIndex, ptr->srs.RR_SRV.resrec.name->c,
5309 AnonDataToString(ptr->srs.AnonData, 0, anonstr, sizeof(anonstr)), mDNSVal16(req->u.servicereg.port),
5310 SRS_PORT(&ptr->srs), req->process_id, req->pid_name);
5312 else if (req->terminate == browse_termination_callback)
5316 for (blist = req->u.browser.browsers; blist; blist = blist->next)
5318 (blist == req->u.browser.browsers) ? prefix : " ", req->flags, req->interfaceIndex, blist->q.qname.c,
5319 AnonDataToString(req->u.browser.AnonData, 0, anonstr, sizeof(anonstr)), req->process_id, req->pid_name);
5321 else if (req->terminate == resolve_termination_callback)
5323 prefix, req->flags, req->interfaceIndex, req->u.resolve.qsrv.qname.c, req->process_id, req->pid_name);
5324 else if (req->terminate == queryrecord_termination_callback)
5326 prefix, req->flags, req->interfaceIndex, req->u.queryrecord.q.qname.c, DNSTypeName(req->u.queryrecord.q.qtype), req->process_id, req->pid_name);
5327 else if (req->terminate == enum_termination_callback)
5329 prefix, req->flags, req->interfaceIndex, req->u.enumeration.q_all.qname.c, req->process_id, req->pid_name);
5330 else if (req->terminate == port_mapping_termination_callback)
5333 req->flags,
5334 req->interfaceIndex,
5335 req->u.pm.NATinfo.Protocol & NATOp_MapTCP ? "TCP" : " ",
5336 req->u.pm.NATinfo.Protocol & NATOp_MapUDP ? "UDP" : " ",
5337 mDNSVal16(req->u.pm.NATinfo.IntPort),
5338 mDNSVal16(req->u.pm.ReqExt),
5339 &req->u.pm.NATinfo.ExternalAddress,
5340 mDNSVal16(req->u.pm.NATinfo.ExternalPort),
5341 req->u.pm.NATinfo.NATLease,
5342 req->u.pm.NATinfo.Lifetime,
5343 req->process_id, req->pid_name);
5344 else if (req->terminate == addrinfo_termination_callback)
5346 prefix, req->flags, req->interfaceIndex,
5347 req->u.addrinfo.protocol & kDNSServiceProtocol_IPv4 ? "v4" : " ",
5348 req->u.addrinfo.protocol & kDNSServiceProtocol_IPv6 ? "v6" : " ",
5349 req->u.addrinfo.q4.qname.c, req->process_id, req->pid_name);
5351 LogMsgNoIdent("%s Unrecognized operation %p", prefix, req->terminate);
5354 mDNSlocal void GetMcastClients(request_state *req)
5356 if (req->terminate == connection_termination)
5361 for (p = req->u.reg_recs; p; p=p->next)
5363 for (r = req->next; r; r=r->next)
5364 if (r->primary == req)
5366 for (p = req->u.reg_recs; p; p=p->next)
5371 for (r = req->next; r; r=r->next)
5372 if (r->primary == req)
5375 else if (req->terminate == regservice_termination_callback)
5378 for (ptr = req->u.servicereg.instances; ptr; ptr = ptr->next)
5384 else if (req->terminate == browse_termination_callback)
5387 for (blist = req->u.browser.browsers; blist; blist = blist->next)
5393 else if (req->terminate == resolve_termination_callback)
5395 if ((mDNSOpaque16IsZero(req->u.resolve.qsrv.TargetQID)) && (req->u.resolve.qsrv.ThisQInterval > 0))
5398 else if (req->terminate == queryrecord_termination_callback)
5400 if ((mDNSOpaque16IsZero(req->u.queryrecord.q.TargetQID)) && (req->u.queryrecord.q.ThisQInterval > 0))
5403 else if (req->terminate == addrinfo_termination_callback)
5405 if ((mDNSOpaque16IsZero(req->u.addrinfo.q4.TargetQID)) && (req->u.addrinfo.q4.ThisQInterval > 0))
5415 mDNSlocal void LogMcastClientInfo(request_state *req)
5417 if (!req->terminate)
5419 else if (req->terminate == connection_termination)
5424 for (p = req->u.reg_recs; p; p=p->next)
5426 for (r = req->next; r; r=r->next)
5427 if (r->primary == req)
5429 for (p = req->u.reg_recs; p; p=p->next)
5433 DNSTypeName(p->rr->resrec.rrtype), req->process_id, req->pid_name, i_mcount++);
5435 for (r = req->next; r; r=r->next)
5436 if (r->primary == req)
5439 else if (req->terminate == regservice_termination_callback)
5442 for (ptr = req->u.servicereg.instances; ptr; ptr = ptr->next)
5445 LogMcastNoIdent("R: DNSServiceRegister: %##s %u/%u PID[%d](%s)", ptr->srs.RR_SRV.resrec.name->c, mDNSVal16(req->u.servicereg.port),
5446 SRS_PORT(&ptr->srs), req->process_id, req->pid_name, i_mcount++);
5449 else if (req->terminate == browse_termination_callback)
5452 for (blist = req->u.browser.browsers; blist; blist = blist->next)
5456 req->process_id, req->pid_name, i_mcount++);
5459 else if (req->terminate == resolve_termination_callback)
5461 if ((mDNSOpaque16IsZero(req->u.resolve.qsrv.TargetQID)) && (req->u.resolve.qsrv.ThisQInterval > 0))
5462 LogMcastNoIdent("Q: DNSServiceResolve %##s %s PID[%d](%s)", req->u.resolve.qsrv.qname.c, DNSTypeName(req->u.resolve.qsrv.qtype),
5463 req->process_id, req->pid_name, i_mcount++);
5465 else if (req->terminate == queryrecord_termination_callback)
5467 if ((mDNSOpaque16IsZero(req->u.queryrecord.q.TargetQID)) && (req->u.queryrecord.q.ThisQInterval > 0))
5468 LogMcastNoIdent("Q: DNSServiceQueryRecord %##s %s PID[%d](%s)", req->u.queryrecord.q.qname.c, DNSTypeName(req->u.queryrecord.q.qtype),
5469 req->process_id, req->pid_name, i_mcount++);
5471 else if (req->terminate == addrinfo_termination_callback)
5473 if ((mDNSOpaque16IsZero(req->u.addrinfo.q4.TargetQID)) && (req->u.addrinfo.q4.ThisQInterval > 0))
5475 req->u.addrinfo.protocol & kDNSServiceProtocol_IPv4 ? "v4" : " ",
5476 req->u.addrinfo.protocol & kDNSServiceProtocol_IPv6 ? "v6" : " ",
5477 req->u.addrinfo.q4.qname.c, req->process_id, req->pid_name, i_mcount++);
5866 request_state *req, *r;
5867 for (req = all_requests; req; req=req->next)
5869 if (req->primary) // If this is a subbordinate operation, check that the parent is in the list
5871 for (r = all_requests; r && r != req; r=r->next) if (r == req->primary) goto foundparent;
5872 LogMsgNoIdent("%3d: Orhpan operation %p; parent %p not found in request list", req->sd);
5875 LogClientInfo(m, req);
6083 const request_state *req, *p;
6084 for (req = all_requests; req; req=req->next)
6086 if (req->next == (request_state *)~0 || (req->sd < 0 && req->sd != -2))
6087 LogMemCorruption("UDS request list: %p is garbage (%d)", req, req->sd);
6089 if (req->primary == req)
6090 LogMemCorruption("UDS request list: req->primary should not point to self %p/%d", req, req->sd);
6092 if (req->primary && req->replies)
6094 req, req->sd, req->primary && req->replies);
6096 p = req->primary;
6098 LogMemCorruption("UDS request list: req %p primary %p is misaligned (%d)", req, p, req->sd);
6100 LogMemCorruption("UDS request list: req %p primary %p is garbage (%d)", req, p, p->sd);
6103 for (rep = req->replies; rep; rep=rep->next)
6105 LogMemCorruption("UDS req->replies: %p is garbage", rep);
6107 if (req->terminate == connection_termination)
6110 for (r = req->u.reg_recs; r; r=r->next)
6112 LogMemCorruption("UDS req->u.reg_recs: %p is garbage", r);
6114 else if (req->terminate == regservice_termination_callback)
6117 for (s = req->u.servicereg.instances; s; s=s->next)
6119 LogMemCorruption("UDS req->u.servicereg.instances: %p is garbage", s);
6121 else if (req->terminate == browse_termination_callback)
6124 for (b = req->u.browser.browsers; b; b=b->next)
6126 LogMemCorruption("UDS req->u.browser.browsers: %p is garbage", b);
6150 mDNSlocal int send_msg(request_state *const req)
6152 reply_state *const rep = req->replies; // Send the first waiting reply
6156 nwriten = send(req->sd, (char *)&rep->mhdr + rep->nwriten, rep->totallen - rep->nwriten, 0);
6166 return(req->ts = t_terminated);
6171 rep->totallen - rep->nwriten, rep->totallen, req->sd, dnssd_errno, dnssd_strerror(dnssd_errno));
6183 request_state **req = &all_requests;
6185 while (*req)
6187 request_state *const r = *req;
6197 // Note: Only primary req's have reply lists, not subordinate req's.
6254 *req = r->next;
6258 req = &r->next;