sig0_test.c revision bf7c02293f883118784f7952944fa3e2bce98078
f3064bfd1b75f7408cff6dbdb864ad62390307d3Mark Andrews * Copyright (C) 1999 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer * purpose with or without fee is hereby granted, provided that the above
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
3d711f2f75cb9a9ddcbf1fca9b2de192e75340e6Mark Andrews if ((x) != ISC_R_SUCCESS) { \
0e0e575ec135a983a53c501cf48734b823361ab4Brian Wellington printf("%s: %s\n", (str), isc_result_totext(x)); \
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyersenddone(isc_task_t *task, isc_event_t *event) {
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer isc_socketevent_t *sevent = (isc_socketevent_t *)event;
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer REQUIRE(sevent->ev_type == ISC_SOCKEVENT_SENDDONE);
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellingtonrecvdone(isc_task_t *task, isc_event_t *event) {
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington isc_socketevent_t *sevent = (isc_socketevent_t *)event;
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer REQUIRE(sevent->ev_type == ISC_SOCKEVENT_RECVDONE);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer isc_buffer_init(&source, sevent->region.base, sevent->region.length);
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
36c754f274dd439e5a7ebf2401427c1d51b21302Brian Wellington result = dns_message_parse(response, &source, ISC_FALSE);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer isc_buffer_init(&outbuf, output, sizeof(output));
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer result = dns_message_totext(response, 0, &outbuf);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer printf("%.*s\n", (int)isc_buffer_usedlength(&outbuf),
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington result = dns_message_setsig0key(query, key);
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington result = dns_message_gettemprdataset(query, &question);
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer CHECK("dns_message_gettemprdataset", result);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington dns_rdataset_makequestion(question, dns_rdataclass_in,
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = dns_message_gettempname(query, &qname);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington isc_buffer_init(&namesrc, nametext, strlen(nametext));
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington isc_buffer_add(&namesrc, strlen(nametext));
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington isc_buffer_init(&namedst, namedata, sizeof namedata);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = dns_name_fromtext(qname, &namesrc, dns_rootname, ISC_FALSE,
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington dns_message_addname(query, qname, DNS_SECTION_QUESTION);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington isc_buffer_init(&qbuffer, qdata, sizeof(qdata));
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = dns_message_renderbegin(query, &qbuffer);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = dns_message_rendersection(query, DNS_SECTION_QUESTION, 0);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington CHECK("dns_message_rendersection(question)", result);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = dns_message_rendersection(query, DNS_SECTION_ANSWER, 0);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington CHECK("dns_message_rendersection(answer)", result);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = dns_message_rendersection(query, DNS_SECTION_AUTHORITY, 0);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington CHECK("dns_message_rendersection(auth)", result);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = dns_message_rendersection(query, DNS_SECTION_ADDITIONAL, 0);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington CHECK("dns_message_rendersection(add)", result);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington isc_buffer_init(&outbuf, output, sizeof(output));
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = dns_message_totext(query, 0, &outbuf);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington printf("%.*s\n", (int)isc_buffer_usedlength(&outbuf),
1ae75c1024eb0475c2be352b8707772e16332ad0Mark Andrews result = isc_socket_sendto(s, &r, task1, senddone, NULL, &address,
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington result = isc_socket_recv(s, &inr, 1, task1, recvdone, NULL);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington RUNTIME_CHECK(isc_mutex_init(&lock) == ISC_R_SUCCESS);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
e56101fa6876c876d9957c23784b6493cdb05e09Brian Wellington while ((ch = isc_commandline_parse(argc, argv, "vp:")) != -1) {
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer port = (unsigned int)atoi(isc_commandline_argument);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer RUNTIME_CHECK(isc_entropy_create(mctx, &ent) == ISC_R_SUCCESS);
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson RUNTIME_CHECK(dst_lib_init(mctx, ent, 0) == ISC_R_SUCCESS);
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer RUNTIME_CHECK(isc_taskmgr_create(mctx, 2, 0, &taskmgr) ==
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task1) == ISC_R_SUCCESS);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson RUNTIME_CHECK(isc_socket_create(socketmgr, PF_INET,
93988fb202645e5d06b337b8e3e20765a467149dAndreas Gustafsson isc_sockaddr_fromin(&address, &inaddr, port);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer isc_buffer_init(&b, "child.example.", strlen("child.example."));
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer isc_buffer_add(&b, strlen("child.example."));
93988fb202645e5d06b337b8e3e20765a467149dAndreas Gustafsson result = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL);