Lines Matching defs:uctx
247 static isc_result_t request_soa(updatectx_t *uctx);
249 static isc_result_t send_update(updatectx_t *uctx);
1921 update_sendevent(updatectx_t *uctx, isc_result_t result) {
1924 dns_message_destroy(&uctx->updatemsg);
1925 if (uctx->tsigkey != NULL)
1926 dns_tsigkey_detach(&uctx->tsigkey);
1927 if (uctx->sig0key != NULL)
1928 dst_key_free(&uctx->sig0key);
1930 if (uctx->canceled)
1931 uctx->event->result = ISC_R_CANCELED;
1933 uctx->event->result = result;
1934 uctx->event->state = uctx->state;
1935 task = uctx->event->ev_sender;
1936 uctx->event->ev_sender = uctx;
1937 isc_task_sendanddetach(&task, ISC_EVENT_PTR(&uctx->event));
1946 updatectx_t *uctx = event->ev_arg;
1955 REQUIRE(UCTX_VALID(uctx));
1956 client = uctx->client;
1967 uctx->state = dns_clientupdatestate_done;
1978 LOCK(&uctx->lock);
1979 uctx->currentserver = ISC_LIST_NEXT(uctx->currentserver, link);
1980 dns_request_destroy(&uctx->updatereq);
1994 !uctx->canceled && uctx->currentserver != NULL)
1996 dns_message_renderreset(uctx->updatemsg);
1997 dns_message_settsigkey(uctx->updatemsg, NULL);
1999 timeout = client->update_timeout / uctx->nservers;
2003 if (uctx->want_tcp)
2005 result = dns_request_createvia3(uctx->view->requestmgr,
2006 uctx->updatemsg,
2008 uctx->currentserver,
2010 uctx->tsigkey,
2015 update_done, uctx,
2016 &uctx->updatereq);
2017 UNLOCK(&uctx->lock);
2021 uctx->state = dns_clientupdatestate_sent;
2025 UNLOCK(&uctx->lock);
2027 update_sendevent(uctx, result);
2031 send_update(updatectx_t *uctx) {
2035 dns_client_t *client = uctx->client;
2038 REQUIRE(uctx->zonename != NULL && uctx->currentserver != NULL);
2040 result = dns_message_gettempname(uctx->updatemsg, &name);
2044 dns_name_clone(uctx->zonename, name);
2045 result = dns_message_gettemprdataset(uctx->updatemsg, &rdataset);
2047 dns_message_puttempname(uctx->updatemsg, &name);
2050 dns_rdataset_makequestion(rdataset, uctx->rdclass, dns_rdatatype_soa);
2053 dns_message_addname(uctx->updatemsg, name, DNS_SECTION_ZONE);
2054 if (uctx->tsigkey == NULL && uctx->sig0key != NULL) {
2055 result = dns_message_setsig0key(uctx->updatemsg,
2056 uctx->sig0key);
2060 timeout = client->update_timeout / uctx->nservers;
2064 if (uctx->want_tcp)
2066 result = dns_request_createvia3(uctx->view->requestmgr,
2067 uctx->updatemsg,
2068 NULL, uctx->currentserver,
2069 reqoptions, uctx->tsigkey, timeout,
2072 client->task, update_done, uctx,
2073 &uctx->updatereq);
2075 uctx->state == dns_clientupdatestate_prepare) {
2076 uctx->state = dns_clientupdatestate_sent;
2090 updatectx_t *uctx;
2096 uctx = *(updatectx_t **)event->ev_arg;
2097 REQUIRE(UCTX_VALID(uctx));
2099 if (event->ev_arg == &uctx->bp4) {
2102 LOCK(&uctx->lock);
2103 dns_client_destroyrestrans(&uctx->restrans);
2104 UNLOCK(&uctx->lock);
2106 INSIST(event->ev_arg == &uctx->bp6);
2109 LOCK(&uctx->lock);
2110 dns_client_destroyrestrans(&uctx->restrans2);
2111 UNLOCK(&uctx->lock);
2136 sa = isc_mem_get(uctx->client->mctx,
2172 ISC_LIST_APPEND(uctx->servers, sa, link);
2173 uctx->nservers++;
2179 dns_client_freeresanswer(uctx->client, &rev->answerlist);
2182 LOCK(&uctx->lock);
2183 if (uctx->restrans == NULL && uctx->restrans2 == NULL)
2185 UNLOCK(&uctx->lock);
2188 INSIST(uctx->currentserver == NULL);
2189 uctx->currentserver = ISC_LIST_HEAD(uctx->servers);
2190 if (uctx->currentserver != NULL && !uctx->canceled)
2191 send_update(uctx);
2195 update_sendevent(uctx, result);
2201 process_soa(updatectx_t *uctx, dns_rdataset_t *soaset, dns_name_t *soaname) {
2220 if (uctx->zonename == NULL) {
2221 uctx->zonename = dns_fixedname_name(&uctx->zonefname);
2222 result = dns_name_copy(soaname, uctx->zonename, NULL);
2227 if (uctx->currentserver != NULL)
2228 result = send_update(uctx);
2234 LOCK(&uctx->lock);
2235 uctx->bp4 = uctx;
2237 if (uctx->want_tcp)
2239 result = dns_client_startresolve(uctx->client, &primary,
2240 uctx->rdclass,
2243 uctx->client->task,
2244 resolveaddr_done, &uctx->bp4,
2245 &uctx->restrans);
2247 uctx->bp6 = uctx;
2248 result = dns_client_startresolve(uctx->client,
2250 uctx->rdclass,
2253 uctx->client->task,
2255 &uctx->bp6,
2256 &uctx->restrans2);
2258 UNLOCK(&uctx->lock);
2270 updatectx_t *uctx;
2293 uctx = reqev->ev_arg;
2294 client = uctx->client;
2295 soaquery = uctx->soaquery;
2296 addr = uctx->currentserver;
2306 result = dns_message_create(uctx->client->mctx,
2318 dns_message_renderreset(uctx->soaquery);
2320 if (uctx->want_tcp)
2322 result = dns_request_createvia3(uctx->view->requestmgr,
2323 uctx->soaquery, NULL, addr,
2327 uctx->client->task,
2328 receive_soa, uctx,
2331 LOCK(&uctx->lock);
2332 dns_request_destroy(&uctx->soareq);
2333 uctx->soareq = newrequest;
2334 UNLOCK(&uctx->lock);
2400 result = process_soa(uctx, soaset, name);
2417 LOCK(&uctx->lock);
2418 uctx->soareq = NULL;
2419 UNLOCK(&uctx->lock);
2423 if (uctx->want_tcp)
2425 result = dns_request_createvia3(uctx->view->requestmgr,
2427 uctx->currentserver,
2429 uctx->tsigkey,
2434 receive_soa, uctx,
2435 &uctx->soareq);
2440 dns_message_destroy(&uctx->soaquery);
2441 LOCK(&uctx->lock);
2442 dns_request_destroy(&uctx->soareq);
2443 UNLOCK(&uctx->lock);
2450 update_sendevent(uctx, result);
2454 request_soa(updatectx_t *uctx) {
2456 dns_message_t *soaquery = uctx->soaquery;
2462 result = dns_message_create(uctx->client->mctx,
2475 dns_rdataset_makequestion(rdataset, uctx->rdclass, dns_rdatatype_soa);
2476 dns_name_clone(uctx->firstname, name);
2482 if (uctx->want_tcp)
2485 result = dns_request_createvia3(uctx->view->requestmgr,
2486 soaquery, NULL, uctx->currentserver,
2487 reqoptions, uctx->tsigkey,
2488 uctx->client->find_timeout * 20,
2489 uctx->client->find_timeout, 3,
2490 uctx->client->task, receive_soa, uctx,
2491 &uctx->soareq);
2493 uctx->soaquery = soaquery;
2512 updatectx_t *uctx;
2520 uctx = event->ev_arg;
2521 REQUIRE(UCTX_VALID(uctx));
2523 LOCK(&uctx->lock);
2524 dns_client_destroyrestrans(&uctx->restrans);
2525 UNLOCK(&uctx->lock);
2527 uctx = event->ev_arg;
2548 nlabels = dns_name_countlabels(&uctx->soaqname);
2554 dns_name_getlabelsequence(&uctx->soaqname, 1, nlabels - 1,
2556 dns_name_clone(&tname, &uctx->soaqname);
2558 if (uctx->want_tcp)
2561 result = dns_client_startresolve(uctx->client, &uctx->soaqname,
2562 uctx->rdclass,
2565 uctx->client->task,
2566 resolvesoa_done, uctx,
2567 &uctx->restrans);
2569 result = process_soa(uctx, rdataset, &uctx->soaqname);
2572 dns_client_freeresanswer(uctx->client, &rev->answerlist);
2576 update_sendevent(uctx, result);
2777 updatectx_t *uctx;
2785 uctx = event->ev_arg;
2787 if (uctx->zonename != NULL && uctx->currentserver != NULL) {
2788 result = send_update(uctx);
2791 } else if (uctx->currentserver != NULL) {
2792 result = request_soa(uctx);
2797 if (uctx->want_tcp)
2799 dns_name_clone(uctx->firstname, &uctx->soaqname);
2800 result = dns_client_startresolve(uctx->client, &uctx->soaqname,
2801 uctx->rdclass,
2803 uctx->client->task,
2804 resolvesoa_done, uctx,
2805 &uctx->restrans);
2814 update_sendevent(uctx, result);
2828 updatectx_t *uctx;
2861 uctx = isc_mem_get(client->mctx, sizeof(*uctx));
2862 if (uctx == NULL) {
2867 result = isc_mutex_init(&uctx->lock);
2870 isc_mem_put(client->mctx, uctx, sizeof(*uctx));
2876 uctx->client = client;
2877 ISC_LINK_INIT(uctx, link);
2878 uctx->state = dns_clientupdatestate_prepare;
2879 uctx->view = view;
2880 uctx->rdclass = rdclass;
2881 uctx->canceled = ISC_FALSE;
2882 uctx->updatemsg = NULL;
2883 uctx->soaquery = NULL;
2884 uctx->updatereq = NULL;
2885 uctx->restrans = NULL;
2886 uctx->restrans2 = NULL;
2887 uctx->bp4 = NULL;
2888 uctx->bp6 = NULL;
2889 uctx->soareq = NULL;
2890 uctx->event = NULL;
2891 uctx->tsigkey = NULL;
2892 uctx->sig0key = NULL;
2893 uctx->zonename = NULL;
2894 uctx->want_tcp = want_tcp;
2895 dns_name_init(&uctx->soaqname, NULL);
2896 ISC_LIST_INIT(uctx->servers);
2897 uctx->nservers = 0;
2898 uctx->currentserver = NULL;
2899 dns_fixedname_init(&uctx->zonefname);
2901 dns_tsec_getkey(tsec, &uctx->tsigkey);
2902 uctx->event = (dns_clientupdateevent_t *)
2904 action, arg, sizeof(*uctx->event));
2905 if (uctx->event == NULL)
2908 uctx->zonename = dns_fixedname_name(&uctx->zonefname);
2909 result = dns_name_copy(zonename, uctx->zonename, NULL);
2921 ISC_LIST_APPEND(uctx->servers, sa, link);
2922 if (uctx->currentserver == NULL)
2923 uctx->currentserver = sa;
2924 uctx->nservers++;
2930 &uctx->updatemsg);
2933 uctx->updatemsg->opcode = dns_opcode_update;
2939 result = copy_name(client->mctx, uctx->updatemsg,
2943 dns_message_addname(uctx->updatemsg, newname,
2951 result = copy_name(client->mctx, uctx->updatemsg, name,
2955 dns_message_addname(uctx->updatemsg, newname,
2959 uctx->firstname = NULL;
2960 result = dns_message_firstname(uctx->updatemsg, section);
2963 result = dns_message_firstname(uctx->updatemsg, section);
2967 dns_message_currentname(uctx->updatemsg, section, &uctx->firstname);
2969 uctx->magic = UCTX_MAGIC;
2972 ISC_LIST_APPEND(client->updatectxs, uctx, link);
2975 *transp = (dns_clientupdatetrans_t *)uctx;
2977 startupdate, uctx);
2982 uctx, sizeof(*event));
2994 if (ISC_LINK_LINKED(uctx, link)) {
2996 ISC_LIST_UNLINK(client->updatectxs, uctx, link);
2999 if (uctx->updatemsg != NULL)
3000 dns_message_destroy(&uctx->updatemsg);
3001 while ((sa = ISC_LIST_HEAD(uctx->servers)) != NULL) {
3002 ISC_LIST_UNLINK(uctx->servers, sa, link);
3005 if (uctx->event != NULL)
3006 isc_event_free(ISC_EVENT_PTR(&uctx->event));
3007 if (uctx->tsigkey != NULL)
3008 dns_tsigkey_detach(&uctx->tsigkey);
3010 DESTROYLOCK(&uctx->lock);
3011 uctx->magic = 0;
3012 isc_mem_put(client->mctx, uctx, sizeof(*uctx));
3020 updatectx_t *uctx;
3023 uctx = (updatectx_t *)trans;
3024 REQUIRE(UCTX_VALID(uctx));
3026 LOCK(&uctx->lock);
3028 if (!uctx->canceled) {
3029 uctx->canceled = ISC_TRUE;
3030 if (uctx->updatereq != NULL)
3031 dns_request_cancel(uctx->updatereq);
3032 if (uctx->soareq != NULL)
3033 dns_request_cancel(uctx->soareq);
3034 if (uctx->restrans != NULL)
3035 dns_client_cancelresolve(uctx->restrans);
3036 if (uctx->restrans2 != NULL)
3037 dns_client_cancelresolve(uctx->restrans2);
3040 UNLOCK(&uctx->lock);
3045 updatectx_t *uctx;
3052 uctx = (updatectx_t *)*transp;
3053 REQUIRE(UCTX_VALID(uctx));
3054 client = uctx->client;
3056 REQUIRE(uctx->updatereq == NULL && uctx->updatemsg == NULL &&
3057 uctx->soareq == NULL && uctx->soaquery == NULL &&
3058 uctx->event == NULL && uctx->tsigkey == NULL &&
3059 uctx->sig0key == NULL);
3062 dns_view_detach(&uctx->view);
3063 while ((sa = ISC_LIST_HEAD(uctx->servers)) != NULL) {
3064 ISC_LIST_UNLINK(uctx->servers, sa, link);
3070 INSIST(ISC_LINK_LINKED(uctx, link));
3071 ISC_LIST_UNLINK(client->updatectxs, uctx, link);
3080 DESTROYLOCK(&uctx->lock);
3081 uctx->magic = 0;
3083 isc_mem_put(mctx, uctx, sizeof(*uctx));