Lines Matching refs:instance
608 mDNSlocal void external_start_advertising_helper(service_instance *const instance)
610 AuthRecord *st = instance->subtypes;
614 if (mDNSIPPortIsZero(instance->request->u.servicereg.port))
628 if (instance->external_advertise) LogMsg("external_start_advertising_helper: external_advertise already set!");
630 for ( i = 0; i < instance->request->u.servicereg.num_subtypes; i++)
633 external_start_advertising_service(&instance->srs.RR_PTR.resrec);
634 external_start_advertising_service(&instance->srs.RR_TXT.resrec);
636 for (e = instance->srs.Extras; e; e = e->next)
639 instance->external_advertise = mDNStrue;
642 mDNSlocal void external_stop_advertising_helper(service_instance *const instance)
644 AuthRecord *st = instance->subtypes;
648 if (!instance->external_advertise) return;
652 for ( i = 0; i < instance->request->u.servicereg.num_subtypes; i++)
655 external_stop_advertising_service(&instance->srs.RR_PTR.resrec);
656 external_stop_advertising_service(&instance->srs.RR_TXT.resrec);
658 for (e = instance->srs.Extras; e; e = e->next)
661 instance->external_advertise = mDNSfalse;
748 service_instance *instance = srs->ServiceContext;
749 if (GenerateNTDResponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, instance->request, &rep, reg_service_reply_op, 0, mStatus_NoError) != mStatus_NoError)
750 LogMsg("%3d: SendServiceRemovalNotification: %##s is not valid DNS-SD SRV name", instance->request->sd, srs->RR_SRV.resrec.name->c);
751 else { append_reply(instance->request, rep); instance->clientnotified = mDNSfalse; }
760 service_instance *instance;
766 instance = srs->ServiceContext;
767 if (!instance) { LogMsg("regservice_callback: srs->ServiceContext is NULL %d", result); return; }
770 if (instance->request &&
771 instance->request->u.servicereg.default_domain &&
772 !instance->default_local)
783 if (instance->request) mDNS_snprintf(prefix, sizeof(prefix), "%3d:", instance->request->sd);
788 if (!instance->request && result != mStatus_MemFree) { LogMsg("regservice_callback: instance->request is NULL %d", result); return; }
792 if (instance->request->u.servicereg.allowremotequery)
799 for (e = instance->srs.Extras; e; e = e->next) e->r.AllowRemoteQuery = mDNStrue;
802 if (GenerateNTDResponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, instance->request, &rep, reg_service_reply_op, kDNSServiceFlagsAdd, result) != mStatus_NoError)
803 LogMsg("%3d: regservice_callback: %##s is not valid DNS-SD SRV name", instance->request->sd, srs->RR_SRV.resrec.name->c);
804 else { append_reply(instance->request, rep); instance->clientnotified = mDNStrue; }
806 if (instance->request->u.servicereg.InterfaceID == mDNSInterface_P2P || (!instance->request->u.servicereg.InterfaceID && SameDomainName(&instance->domain, &localdomain) && (instance->request->flags & kDNSServiceFlagsIncludeP2P)))
809 external_start_advertising_helper(instance);
811 if (instance->request->u.servicereg.autoname && CountPeerRegistrations(m, srs) == 0)
816 if (instance->request && instance->renameonmemfree)
818 external_stop_advertising_helper(instance);
819 instance->renameonmemfree = 0;
820 err = mDNS_RenameAndReregisterService(m, srs, &instance->request->u.servicereg.name);
825 unlink_and_free_service_instance(instance);
829 if (instance->request->u.servicereg.autorename)
831 external_stop_advertising_helper(instance);
832 if (instance->request->u.servicereg.autoname && CountPeerRegistrations(m, srs) == 0)
840 if (instance->clientnotified) SendServiceRemovalNotification(srs);
848 if (GenerateNTDResponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, instance->request, &rep, reg_service_reply_op, kDNSServiceFlagsAdd, result) != mStatus_NoError)
849 LogMsg("%3d: regservice_callback: %##s is not valid DNS-SD SRV name", instance->request->sd, srs->RR_SRV.resrec.name->c);
850 else { append_reply(instance->request, rep); instance->clientnotified = mDNStrue; }
852 unlink_and_free_service_instance(instance);
859 if (GenerateNTDResponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, instance->request, &rep, reg_service_reply_op, kDNSServiceFlagsAdd, result) != mStatus_NoError)
860 LogMsg("%3d: regservice_callback: %##s is not valid DNS-SD SRV name", instance->request->sd, srs->RR_SRV.resrec.name->c);
861 else { append_reply(instance->request, rep); instance->clientnotified = mDNStrue; }
1091 mDNSlocal mStatus add_record_to_service(request_state *request, service_instance *instance, mDNSu16 rrtype, mDNSu16 rdlen, const char *rdata, mDNSu32 ttl)
1093 ServiceRecordSet *srs = &instance->srs;
1110 if (instance->external_advertise && (instance->request->u.servicereg.InterfaceID == mDNSInterface_P2P || (!instance->request->u.servicereg.InterfaceID && SameDomainName(&instance->domain, &localdomain) && (instance->request->flags & kDNSServiceFlagsIncludeP2P))))
1440 service_instance **ptr, *instance;
1488 instance = mallocL("service_instance", sizeof(*instance) + extra_size);
1489 if (!instance) { my_perror("ERROR: malloc"); return mStatus_NoMemoryErr; }
1491 instance->next = mDNSNULL;
1492 instance->request = request;
1493 instance->subtypes = AllocateSubTypes(request->u.servicereg.num_subtypes, request->u.servicereg.type_as_string);
1494 instance->renameonmemfree = 0;
1495 instance->clientnotified = mDNSfalse;
1496 instance->default_local = (request->u.servicereg.default_domain && DomainIsLocal);
1497 instance->external_advertise = mDNSfalse;
1498 AssignDomainName(&instance->domain, domain);
1500 if (request->u.servicereg.num_subtypes && !instance->subtypes)
1501 { unlink_and_free_service_instance(instance); instance = NULL; FatalError("ERROR: malloc"); }
1503 result = mDNS_RegisterService(&mDNSStorage, &instance->srs,
1508 instance->subtypes, request->u.servicereg.num_subtypes,
1509 interfaceID, regservice_callback, instance, regFlags);
1513 *ptr = instance; // Append this to the end of our request->u.servicereg.instances list
1515 instance->request->sd, instance->srs.RR_SRV.resrec.name->c, mDNSVal16(request->u.servicereg.port));
1521 unlink_and_free_service_instance(instance);
1552 // Normally we should not fail to find the specified instance
1554 // and regservice_callback then calls unlink_and_free_service_instance and disposes of that instance.
1575 // instance, clearing the backpointers, and then disposing the parent request_state object.