Jack Jansen | f16d5fa | 1995-03-02 14:41:55 +0000 | [diff] [blame] | 1 | |
| 2 | \section{Built-in module \sectcode{macdnr}} |
| 3 | \bimodindex{macdnr} |
| 4 | |
| 5 | This module provides an interface to the Macintosh Domain Name |
| 6 | Resolver. It is usually used in conjunction with the \var{mactcp} module, to |
| 7 | map hostnames to IP-addresses. |
| 8 | |
| 9 | The \code{macdnr} module defines the following functions: |
| 10 | |
| 11 | \renewcommand{\indexsubitem}{(in module macdnr)} |
| 12 | |
| 13 | \begin{funcdesc}{Open}{\optional{filename}} |
| 14 | Open the domain name resolver extension. If \var{filename} is given it |
| 15 | should be the pathname of the extension, otherwise a default is |
| 16 | used. Normally, this call is not needed since the other calls will |
| 17 | open the extension automatically. |
| 18 | \end{funcdesc} |
| 19 | |
| 20 | \begin{funcdesc}{Close}{} |
| 21 | Close the resolver extension. Again, not needed for normal use. |
| 22 | \end{funcdesc} |
| 23 | |
| 24 | \begin{funcdesc}{StrToAddr}{hostname} |
| 25 | Look up the IP address for \var{hostname}. This call returns a dnr |
| 26 | result object of the ``address'' variation. |
| 27 | \end{funcdesc} |
| 28 | |
| 29 | \begin{funcdesc}{AddrToName}{addr} |
| 30 | Do a reverse lookup on the 32-bit integer IP-address |
| 31 | \var{addr}. Returns a dnr result object of the ``address'' variation. |
| 32 | \end{funcdesc} |
| 33 | |
| 34 | \begin{funcdesc}{AddrToStr}{addr} |
| 35 | Convert the 32-bit integer IP-address \var{addr} to a dotted-decimal |
| 36 | string. Returns the string. |
| 37 | \end{funcdesc} |
| 38 | |
| 39 | \begin{funcdesc}{HInfo}{hostname} |
| 40 | Query the nameservers for a \code{HInfo} record for host |
| 41 | \var{hostname}. These records contain hardware and software |
| 42 | information about the machine in question (if they are available in |
| 43 | the first place). Returns a dnr result object of the ``hinfo'' |
| 44 | variety. |
| 45 | \end{funcdesc} |
| 46 | |
| 47 | \begin{funcdesc}{MXInfo}{domain} |
| 48 | Query the nameservers for a mail exchanger for \var{domain}. This is |
| 49 | the hostname of a host willing to accept SMTP mail for the given |
| 50 | domain. Returns a dnr result object of the ``mx'' variety. |
| 51 | \end{funcdesc} |
| 52 | |
| 53 | \subsection{dnr result object} |
| 54 | |
| 55 | Since the DNR calls all execute asynchronously you do not get the |
| 56 | results back immedeately. In stead, you get a dnr result object. You |
| 57 | can check this object to see whether the query is complete, and access |
| 58 | its attributes to obtain the information when it is. |
| 59 | |
| 60 | Alternatively, you can also reference the result attributes directly, |
| 61 | this will result in an implicit wait for the query to complete. |
| 62 | |
| 63 | The \var{rtnCode} and \var{cname} attributes are always available, the |
| 64 | others depend on the type of query (address, hinfo or mx). |
| 65 | |
| 66 | \renewcommand{\indexsubitem}{(dnr result object method)} |
| 67 | |
| 68 | % Add args, as in {arg1\, arg2 \optional{\, arg3}} |
| 69 | \begin{funcdesc}{wait}{} |
| 70 | Wait for the query to complete. |
| 71 | \end{funcdesc} |
| 72 | |
| 73 | % Add args, as in {arg1\, arg2 \optional{\, arg3}} |
| 74 | \begin{funcdesc}{isdone}{} |
| 75 | Return 1 if the query is complete. |
| 76 | \end{funcdesc} |
| 77 | |
| 78 | \begin{datadesc}{rtnCode} |
| 79 | The error code returned by the query. |
| 80 | \end{datadesc} |
| 81 | |
| 82 | \begin{datadesc}{cname} |
| 83 | The canonical name of the host that was queried. |
| 84 | \end{datadesc} |
| 85 | |
| 86 | \begin{datadesc}{ip0} |
| 87 | \dataline{ip1} |
| 88 | \dataline{ip2} |
| 89 | \dataline{ip3} |
| 90 | At most four integer IP addresses for this host. Unused entries are |
| 91 | zero. Valid only for address queries. |
| 92 | \end{datadesc} |
| 93 | |
| 94 | \begin{datadesc}{cpuType} |
| 95 | \dataline{osType} |
| 96 | Textual strings giving the machine type an OS name. Valid for hinfo |
| 97 | queries. |
| 98 | \end{datadesc} |
| 99 | |
| 100 | \begin{datadesc}{exchange} |
| 101 | The name of a mail-exchanger host. Valid for mx queries. |
| 102 | \end{datadesc} |
| 103 | |
| 104 | \begin{datadesc}{preference} |
| 105 | The preference of this mx record. Not too useful, since the Macintosh |
| 106 | will only return a single mx record. Mx queries only. |
| 107 | \end{datadesc} |
| 108 | |
| 109 | The simplest way to use the module to convert names to dotted-decimal |
| 110 | strings, without worrying about idle time, etc: |
| 111 | \begin{verbatim} |
| 112 | >>> def gethostname(name): |
| 113 | ... import macdnr |
| 114 | ... dnrr = macdnr.StrToAddr(name) |
| 115 | ... return macdnr.AddrToStr(dnrr.ip0) |
| 116 | \end{verbatim} |