Lines Matching defs:uctx
263 request_soa(updatectx_t *uctx);
267 send_update(updatectx_t *uctx);
1815 update_sendevent(updatectx_t *uctx, isc_result_t result) {
1818 dns_message_detach(&uctx->updatemsg);
1819 if (uctx->tsigkey != NULL) {
1820 dns_tsigkey_detach(&uctx->tsigkey);
1822 if (uctx->sig0key != NULL) {
1823 dst_key_free(&uctx->sig0key);
1826 if (uctx->canceled) {
1827 uctx->event->result = ISC_R_CANCELED;
1829 uctx->event->result = result;
1831 uctx->event->state = uctx->state;
1832 task = uctx->event->ev_sender;
1833 uctx->event->ev_sender = uctx;
1834 isc_task_sendanddetach(&task, ISC_EVENT_PTR(&uctx->event));
1843 updatectx_t *uctx = event->ev_arg;
1852 REQUIRE(UCTX_VALID(uctx));
1853 client = uctx->client;
1862 uctx->state = dns_clientupdatestate_done;
1875 LOCK(&uctx->lock);
1876 uctx->currentserver = ISC_LIST_NEXT(uctx->currentserver, link);
1877 dns_request_destroy(&uctx->updatereq);
1891 !uctx->canceled && uctx->currentserver != NULL)
1893 dns_message_renderreset(uctx->updatemsg);
1894 dns_message_settsigkey(uctx->updatemsg, NULL);
1896 timeout = client->update_timeout / uctx->nservers;
1901 if (uctx->want_tcp) {
1905 uctx->view->requestmgr, uctx->updatemsg, NULL,
1906 uctx->currentserver, -1, reqoptions, uctx->tsigkey,
1909 uctx, &uctx->updatereq);
1910 UNLOCK(&uctx->lock);
1914 uctx->state = dns_clientupdatestate_sent;
1918 UNLOCK(&uctx->lock);
1921 update_sendevent(uctx, result);
1925 send_update(updatectx_t *uctx) {
1929 dns_client_t *client = uctx->client;
1932 REQUIRE(uctx->zonename != NULL && uctx->currentserver != NULL);
1934 result = dns_message_gettempname(uctx->updatemsg, &name);
1939 dns_name_clone(uctx->zonename, name);
1940 result = dns_message_gettemprdataset(uctx->updatemsg, &rdataset);
1942 dns_message_puttempname(uctx->updatemsg, &name);
1945 dns_rdataset_makequestion(rdataset, uctx->rdclass, dns_rdatatype_soa);
1948 dns_message_addname(uctx->updatemsg, name, DNS_SECTION_ZONE);
1949 if (uctx->tsigkey == NULL && uctx->sig0key != NULL) {
1950 result = dns_message_setsig0key(uctx->updatemsg, uctx->sig0key);
1955 timeout = client->update_timeout / uctx->nservers;
1960 if (uctx->want_tcp) {
1964 uctx->view->requestmgr, uctx->updatemsg, NULL,
1965 uctx->currentserver, -1, reqoptions, uctx->tsigkey, timeout,
1967 client->task, update_done, uctx, &uctx->updatereq);
1969 uctx->state == dns_clientupdatestate_prepare) {
1970 uctx->state = dns_clientupdatestate_sent;
1984 updatectx_t *uctx;
1990 uctx = *(updatectx_t **)event->ev_arg;
1991 REQUIRE(UCTX_VALID(uctx));
1993 if (event->ev_arg == &uctx->bp4) {
1996 LOCK(&uctx->lock);
1997 dns_client_destroyrestrans(&uctx->restrans);
1998 UNLOCK(&uctx->lock);
2000 INSIST(event->ev_arg == &uctx->bp6);
2003 LOCK(&uctx->lock);
2004 dns_client_destroyrestrans(&uctx->restrans2);
2005 UNLOCK(&uctx->lock);
2035 sa = isc_mem_get(uctx->client->mctx,
2061 ISC_LIST_APPEND(uctx->servers, sa, link);
2062 uctx->nservers++;
2068 dns_client_freeresanswer(uctx->client, &rev->answerlist);
2071 LOCK(&uctx->lock);
2072 if (uctx->restrans == NULL && uctx->restrans2 == NULL) {
2075 UNLOCK(&uctx->lock);
2078 INSIST(uctx->currentserver == NULL);
2079 uctx->currentserver = ISC_LIST_HEAD(uctx->servers);
2080 if (uctx->currentserver != NULL && !uctx->canceled) {
2081 send_update(uctx);
2086 update_sendevent(uctx, result);
2092 process_soa(updatectx_t *uctx, dns_rdataset_t *soaset,
2114 if (uctx->zonename == NULL) {
2115 uctx->zonename = dns_fixedname_name(&uctx->zonefname);
2116 dns_name_copynf(soaname, uctx->zonename);
2119 if (uctx->currentserver != NULL) {
2120 result = send_update(uctx);
2126 LOCK(&uctx->lock);
2127 uctx->bp4 = uctx;
2129 if (uctx->want_tcp) {
2133 uctx->client, &primary, uctx->rdclass, dns_rdatatype_a,
2134 resoptions, uctx->client->task, resolveaddr_done,
2135 &uctx->bp4, &uctx->restrans);
2137 uctx->bp6 = uctx;
2139 uctx->client, &primary, uctx->rdclass,
2141 uctx->client->task, resolveaddr_done,
2142 &uctx->bp6, &uctx->restrans2);
2144 UNLOCK(&uctx->lock);
2155 updatectx_t *uctx;
2178 uctx = reqev->ev_arg;
2179 client = uctx->client;
2180 soaquery = uctx->soaquery;
2181 addr = uctx->currentserver;
2191 dns_message_create(uctx->client->mctx, DNS_MESSAGE_INTENTPARSE,
2201 dns_message_renderreset(uctx->soaquery);
2203 if (uctx->want_tcp) {
2207 uctx->view->requestmgr, uctx->soaquery, NULL, addr, -1,
2209 client->find_timeout, 3, uctx->client->task,
2210 receive_soa, uctx, &newrequest);
2212 LOCK(&uctx->lock);
2213 dns_request_destroy(&uctx->soareq);
2214 uctx->soareq = newrequest;
2215 UNLOCK(&uctx->lock);
2280 result = process_soa(uctx, soaset, name);
2296 LOCK(&uctx->lock);
2297 uctx->soareq = NULL;
2298 UNLOCK(&uctx->lock);
2302 if (uctx->want_tcp) {
2306 uctx->view->requestmgr, soaquery, NULL,
2307 uctx->currentserver, -1, reqoptions,
2308 uctx->tsigkey, client->find_timeout * 20,
2310 receive_soa, uctx, &uctx->soareq);
2315 dns_message_detach(&uctx->soaquery);
2316 LOCK(&uctx->lock);
2317 dns_request_destroy(&uctx->soareq);
2318 UNLOCK(&uctx->lock);
2326 update_sendevent(uctx, result);
2331 request_soa(updatectx_t *uctx) {
2333 dns_message_t *soaquery = uctx->soaquery;
2339 dns_message_create(uctx->client->mctx, DNS_MESSAGE_INTENTRENDER,
2351 dns_rdataset_makequestion(rdataset, uctx->rdclass, dns_rdatatype_soa);
2352 dns_name_clone(uctx->firstname, name);
2358 if (uctx->want_tcp) {
2363 uctx->view->requestmgr, soaquery, NULL, uctx->currentserver, -1,
2364 reqoptions, uctx->tsigkey, uctx->client->find_timeout * 20,
2365 uctx->client->find_timeout, 3, uctx->client->task, receive_soa,
2366 uctx, &uctx->soareq);
2368 uctx->soaquery = soaquery;
2388 updatectx_t *uctx;
2396 uctx = event->ev_arg;
2397 REQUIRE(UCTX_VALID(uctx));
2399 LOCK(&uctx->lock);
2400 dns_client_destroyrestrans(&uctx->restrans);
2401 UNLOCK(&uctx->lock);
2403 uctx = event->ev_arg;
2426 nlabels = dns_name_countlabels(&uctx->soaqname);
2432 dns_name_getlabelsequence(&uctx->soaqname, 1, nlabels - 1,
2434 dns_name_clone(&tname, &uctx->soaqname);
2436 if (uctx->want_tcp) {
2441 uctx->client, &uctx->soaqname, uctx->rdclass,
2442 dns_rdatatype_soa, resoptions, uctx->client->task,
2443 resolvesoa_done, uctx, &uctx->restrans);
2445 result = process_soa(uctx, rdataset, &uctx->soaqname);
2449 dns_client_freeresanswer(uctx->client, &rev->answerlist);
2453 update_sendevent(uctx, result);
2646 updatectx_t *uctx;
2654 uctx = event->ev_arg;
2656 if (uctx->zonename != NULL && uctx->currentserver != NULL) {
2657 result = send_update(uctx);
2661 } else if (uctx
2662 result = request_soa(uctx);
2668 if (uctx->want_tcp) {
2671 dns_name_clone(uctx->firstname, &uctx->soaqname);
2673 uctx->client, &uctx->soaqname, uctx->rdclass,
2674 dns_rdatatype_soa, resoptions, uctx->client->task,
2675 resolvesoa_done, uctx, &uctx->restrans);
2685 update_sendevent(uctx, result);
2700 updatectx_t *uctx;
2735 uctx = isc_mem_get(client->mctx, sizeof(*uctx));
2737 isc_mutex_init(&uctx->lock);
2741 uctx->client = client;
2742 ISC_LINK_INIT(uctx, link);
2743 uctx->state = dns_clientupdatestate_prepare;
2744 uctx->view = view;
2745 uctx->rdclass = rdclass;
2746 uctx->canceled = false;
2747 uctx->updatemsg = NULL;
2748 uctx->soaquery = NULL;
2749 uctx->updatereq = NULL;
2750 uctx->restrans = NULL;
2751 uctx->restrans2 = NULL;
2752 uctx->bp4 = NULL;
2753 uctx->bp6 = NULL;
2754 uctx->soareq = NULL;
2755 uctx->event = NULL;
2756 uctx->tsigkey = NULL;
2757 uctx->sig0key = NULL;
2758 uctx->zonename = NULL;
2759 uctx->want_tcp = want_tcp;
2760 dns_name_init(&uctx->soaqname, NULL);
2761 ISC_LIST_INIT(uctx->servers);
2762 uctx->nservers = 0;
2763 uctx->currentserver = NULL;
2764 dns_fixedname_init(&uctx->zonefname);
2766 dns_tsec_getkey(tsec, &uctx->tsigkey);
2768 uctx->event = (dns_clientupdateevent_t *)isc_event_allocate(
2770 sizeof(*uctx->event));
2772 uctx->zonename = dns_fixedname_name(&uctx->zonefname);
2773 dns_name_copynf(zonename, uctx->zonename);
2783 ISC_LIST_APPEND(uctx->servers, sa, link);
2784 if (uctx->currentserver == NULL) {
2785 uctx->currentserver = sa;
2787 uctx->nservers++;
2793 &uctx->updatemsg);
2794 uctx->updatemsg->opcode = dns_opcode_update;
2801 result = copy_name(client->mctx, uctx->updatemsg, name,
2806 dns_message_addname(uctx->updatemsg, newname,
2815 result = copy_name(client->mctx, uctx->updatemsg, name,
2820 dns_message_addname(uctx->updatemsg, newname,
2824 uctx->firstname = NULL;
2825 result = dns_message_firstname(uctx->updatemsg, section);
2828 result = dns_message_firstname(uctx->updatemsg, section);
2833 dns_message_currentname(uctx->updatemsg, section, &uctx->firstname);
2835 uctx->magic = UCTX_MAGIC;
2838 ISC_LIST_APPEND(client->updatectxs, uctx, link);
2842 *transp = (dns_clientupdatetrans_t *)uctx;
2844 startupdate, uctx);
2849 uctx, sizeof(*event));
2861 if (ISC_LINK_LINKED(uctx, link)) {
2863 ISC_LIST_UNLINK(client->updatectxs, uctx, link);
2866 if (uctx->updatemsg != NULL) {
2867 dns_message_detach(&uctx->updatemsg);
2869 while ((sa = ISC_LIST_HEAD(uctx->servers)) != NULL) {
2870 ISC_LIST_UNLINK(uctx->servers, sa, link);
2873 if (uctx->event != NULL) {
2874 isc_event_free(ISC_EVENT_PTR(&uctx->event));
2876 if (uctx->tsigkey != NULL) {
2877 dns_tsigkey_detach(&uctx->tsigkey);
2880 isc_mutex_destroy(&uctx->lock);
2881 uctx->magic = 0;
2882 isc_mem_put(client->mctx, uctx, sizeof(*uctx));
2890 updatectx_t *uctx;
2893 uctx = (updatectx_t *)trans;
2894 REQUIRE(UCTX_VALID(uctx));
2896 LOCK(&uctx->lock);
2898 if (!uctx->canceled) {
2899 uctx->canceled = true;
2900 if (uctx->updatereq != NULL) {
2901 dns_request_cancel(uctx->updatereq);
2903 if (uctx->soareq != NULL) {
2904 dns_request_cancel(uctx->soareq);
2906 if (uctx->restrans != NULL) {
2907 dns_client_cancelresolve(uctx->restrans);
2909 if (uctx->restrans2 != NULL) {
2910 dns_client_cancelresolve(uctx->restrans2);
2914 UNLOCK(&uctx->lock);
2919 updatectx_t *uctx;
2925 uctx = (updatectx_t *)*transp;
2927 REQUIRE(UCTX_VALID(uctx));
2928 client = uctx->client;
2930 REQUIRE(uctx->updatereq == NULL && uctx->updatemsg == NULL &&
2931 uctx->soareq == NULL && uctx->soaquery == NULL &&
2932 uctx->event == NULL && uctx->tsigkey == NULL &&
2933 uctx->sig0key == NULL);
2936 dns_view_detach(&uctx->view);
2937 while ((sa = ISC_LIST_HEAD(uctx->servers)) != NULL) {
2938 ISC_LIST_UNLINK(uctx->servers, sa, link);
2944 INSIST(ISC_LINK_LINKED(uctx, link));
2945 ISC_LIST_UNLINK(client->updatectxs, uctx, link);
2949 isc_mutex_destroy(&uctx->lock);
2950 uctx->magic = 0;
2952 isc_mem_put(mctx, uctx, sizeof(*uctx));