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