日期:2014-05-16  浏览次数:20705 次

代码如何理解···菜鸟初学···求高手帮忙
下列代码如何理解,是否可用类C进行编写。


[sigma]# dig @ 10.1.1.100 version.bind chaos txt
;<<>\>Dig 8.1 <<>\>@ 10.1.1.100 version.bind chaos txt
;{ 1 server found }
;;res options: init recurs defnam dnsrch
;;got answer:
;;->\>HEADER<<- opcode: QUERY, status: NOERROR, id: 10
;;flags: qr aa rd ra ; QUERY: 1, ANSWER: 1,AUTHORITY: 0,ADDITIONAL: 0
;;QUERY SECTION:
;;version.bind, type-txt, class-CHAOS
;;ANSWER SECTION:
  VERSION BIND, OS CHAOS TXT “8.2.2”



 [itchy]# nolookup
  Defailt server:localhost.attackers.org
  Address: 127.0.0.1
> server 10.1.1.100
Default server:dns.victim.net
Address: 10.1.1.100
> hash.attackers.org
Server:dns.victim.net
Address:10.1.1.100


------解决方案--------------------
在贴一点 还是没贴完
C/C++ code

void
dighost_shutdown(void) {
        isc_event_t *event = global_event;

        flush_lookup_list();
        debug("dighost_shutdown()");

        if (!in_use) {
                isc_app_shutdown();
                return;
        }

        isc_task_send(global_task, &event);
}

static void
printsoa(dns_rdata_t *rdata) {
        dns_rdata_soa_t soa;
        isc_result_t result;
        char namebuf[DNS_NAME_FORMATSIZE];

        result = dns_rdata_tostruct(rdata, &soa, NULL);
        check_result(result, "dns_rdata_tostruct");

        dns_name_format(&soa.origin, namebuf, sizeof(namebuf));
        printf("\torigin = %s\n", namebuf);
        dns_name_format(&soa.contact, namebuf, sizeof(namebuf));
        printf("\tmail addr = %s\n", namebuf);
        printf("\tserial = %u\n", soa.serial);
        printf("\trefresh = %u\n", soa.refresh);
        printf("\tretry = %u\n", soa.retry);
        printf("\texpire = %u\n", soa.expire);
        printf("\tminimum = %u\n", soa.minimum);
        dns_rdata_freestruct(&soa);
}

static void
printa(dns_rdata_t *rdata) {
        isc_result_t result;
        char text[sizeof("255.255.255.255")];
        isc_buffer_t b;

        isc_buffer_init(&b, text, sizeof(text));
        result = dns_rdata_totext(rdata, NULL, &b);
        check_result(result, "dns_rdata_totext");
        printf("Address: %.*s\n", (int)isc_buffer_usedlength(&b),
               (char *)isc_buffer_base(&b));
}
#ifdef DIG_SIGCHASE
/* Just for compatibility : not use in host program */
isc_result_t
printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
              isc_buffer_t *target)
{
        UNUSED(owner_name);
        UNUSED(rdataset);
        UNUSED(target);
        return(ISC_FALSE);
}
#endif
static void
printrdata(dns_rdata_t *rdata) {
        isc_result_t result;
        isc_buffer_t *b = NULL;
        unsigned int size = 1024;
        isc_boolean_t done = ISC_FALSE;

        if (rdata->type < N_KNOWN_RRTYPES)
                printf("%s", rtypetext[rdata->type]);
        else
                printf("rdata_%d = ", rdata->type);

        while (!done) {
                result = isc_buffer_allocate(mctx, &b, size);
                if (result != ISC_R_SUCCESS)
                        check_result(result, "isc_buffer_allocate");
                result = dns_rdata_totext(rdata, NULL, b);
                if (result == ISC_R_SUCCESS) {
                        printf("%.*s\n", (int)isc_buffer_usedlength(b),
                               (char *)isc_buffer_base(b));
                        done = ISC_TRUE;
                } else if (result != ISC_R_NOSPACE)
                        check_result(result, "dns_rdata_totext");
                isc_buffer_free(&b);
                size *=