<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 7/1/2011 2:40 AM, Vignesh Gadiyar wrote:
    <blockquote
      cite="mid:BANLkTimS8RSdXybQBUr+ArztDOtGnjyvxQ@mail.gmail.com"
      type="cite">I have created a static zone file for "<a
        moz-do-not-send="true" href="http://www.abcd.com">www.abcd.com</a>"
      with the Answer section entries </blockquote>
    <br>
    Hold it right there. A zone file doesn't contain "answer sections",
    it contains zone data. That's an important, fundamental distinction.
    "Answer sections" sometimes form part of "responses", which are
    produced through the name-resolution process/algorithm, and then
    rendered in "wire format" for passing back to the client. Hopefully
    you understand both the differences and interrelationship of a
    nameserver's "private" data structures and data storage mechanisms,
    on the one hand, and, on the other hand, the standards-defined
    network protocol for sending bits and bytes of data between the
    server and the client. Any given RRset is going to be formatted
    differently, depending on whether it's in text form in a zone file
    (defined by standard), held in binary form in some sort of organized
    data structure in volatile memory while named is running
    (proprietary to BIND), or "on the wire" being passed between a
    nameserver and one of its clients (also defined by standard).<br>
    <br>
    <blockquote
      cite="mid:BANLkTimS8RSdXybQBUr+ArztDOtGnjyvxQ@mail.gmail.com"
      type="cite">containing 2 IP addresses like 1.1.1.1 and 2.2.2.2. I
      tried to print these addresses in the towiresorted function for
      the random order like ->
      <div><br>
      </div>
      <div>for(i=0;i<count;i++)</div>
      <div>{<br>
                        char adstr[40];</div>
      <div>                isc_uint32_t ip_host=(*(isc_uint32_t
        *)sorted[i].rdata->data);</div>
      <div>               
        inet_ntop(AF_INET,&(ip_host),adstr,adstr,40);</div>
      <div>                printf("%s  \n",adstr);</div>
      <div>}</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>thinking that rdata->data contains the IP addresses of the
        answer section. But i am getting different IP addresses when i'm
        running named and using dig <a moz-do-not-send="true"
          href="http://www.abcd.com">www.abcd.com</a>. Some help as to
        what exactly stores the IPs contained in the Answer section
        would be really great.</div>
    </blockquote>
    towiresorted() is just an internal BIND conversion function, and the
    product of towiresorted() would *not* be suitable, I don't think,
    for feeding directly to inet_ntop(), since inet_ntop() won't be able
    to handle DNS-style label compression (it doesn't have the whole
    context of the response packet, so how could it?).<br>
    <br>
    What exactly are you trying to do here?<br>
    <br>
    If you just want a program to read a text file containing IP
    addresses and then spit them out in random order, then that's not
    even DNS-related and you don't need BIND libraries for that. Heck,
    you could just use the "sort" command.<br>
    <br>
    If you're trying to query some particular DNS name and then present
    the results in random order, then I think the modern algorithm --
    although I haven't done any network programming in C for years now
    -- would be to call getaddrinfo(), which will return a linked list
    of addrinfo structures. Parse through that linked list and randomize
    to your heart's content. Please understand, however, that the vast
    majority of DNS resolver implementations will *already* randomize
    the results (with a notable exception being Windows' default, but
    de-configurable behavior of "subnet prioritization"), so
    re-randomizing in a client program may be wasted effort.<br>
    <br>
                                                                       
                                            - Kevin<br>
  </body>
</html>