diff options
| author | Sam Hartman <hartmans@mit.edu> | 2011-09-28 20:54:16 +0000 |
|---|---|---|
| committer | Sam Hartman <hartmans@mit.edu> | 2011-09-28 20:54:16 +0000 |
| commit | 6a45252bb3a6a808bb6f3dc32a7f1d85a7c04df1 (patch) | |
| tree | 301620431d615b612ef8adbc741e304719759a01 /src/include | |
| parent | 52ea04b2b732f73396dc945f23bae64e4f851299 (diff) | |
| download | krb5-6a45252bb3a6a808bb6f3dc32a7f1d85a7c04df1.tar.gz krb5-6a45252bb3a6a808bb6f3dc32a7f1d85a7c04df1.tar.xz krb5-6a45252bb3a6a808bb6f3dc32a7f1d85a7c04df1.zip | |
Added leashdll/wshelper related files from KFW
From: Alexey Melnikov <alexey.melnikov@isode.com>
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25243 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/arpa/nameser.h | 263 | ||||
| -rw-r--r-- | src/include/hesiod.h | 217 | ||||
| -rw-r--r-- | src/include/mitwhich.h | 84 | ||||
| -rw-r--r-- | src/include/resolv.h | 284 | ||||
| -rw-r--r-- | src/include/wshelper.h | 148 |
5 files changed, 996 insertions, 0 deletions
diff --git a/src/include/arpa/nameser.h b/src/include/arpa/nameser.h new file mode 100644 index 0000000000..f9ddafce96 --- /dev/null +++ b/src/include/arpa/nameser.h @@ -0,0 +1,263 @@ +/* + * @doc + * @module nameser.h | + * Copyright (c) 1983, 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)nameser.h 5.25 (Berkeley) 4/3/91 + */ + +#ifndef _NAMESER_H_ +#define _NAMESER_H_ + +/* + * Define constants based on rfc883 + */ +#define PACKETSZ 512 /* maximum packet size */ +#define MAXDNAME 256 /* maximum domain name */ +#define MAXCDNAME 255 /* maximum compressed domain name */ +#define MAXLABEL 63 /* maximum length of domain label */ + /* Number of bytes of fixed size data in query structure */ +#define QFIXEDSZ 4 + /* number of bytes of fixed size data in resource record */ +#define RRFIXEDSZ 10 + +#if !defined(MAXHOSTNAME) +#define MAXHOSTNAME MAXCDNAME +#endif + +/* + * Internet nameserver port number + */ +#define NAMESERVER_PORT 53 + +/* + * Currently defined opcodes + */ +#define QUERY 0x0 /* standard query */ +#define IQUERY 0x1 /* inverse query */ +#define STATUS 0x2 /* nameserver status query */ +/*#define xxx 0x3 /* 0x3 reserved */ + /* non standard */ +#define UPDATEA 0x9 /* add resource record */ +#define UPDATED 0xa /* delete a specific resource record */ +#define UPDATEDA 0xb /* delete all nemed resource record */ +#define UPDATEM 0xc /* modify a specific resource record */ +#define UPDATEMA 0xd /* modify all named resource record */ + +#define ZONEINIT 0xe /* initial zone transfer */ +#define ZONEREF 0xf /* incremental zone referesh */ + +/* + * Currently defined response codes + */ +#define NOERROR 0 /* no error */ +#define FORMERR 1 /* format error */ +#define SERVFAIL 2 /* server failure */ +#define NXDOMAIN 3 /* non existent domain */ +#define NOTIMP 4 /* not implemented */ +#define REFUSED 5 /* query refused */ + /* non standard */ +#define NOCHANGE 0xf /* update failed to change db */ + +/* + * Type values for resources and queries + */ +#define T_A 1 /* host address */ +#define T_NS 2 /* authoritative server */ +#define T_MD 3 /* mail destination */ +#define T_MF 4 /* mail forwarder */ +#define T_CNAME 5 /* connonical name */ +#define T_SOA 6 /* start of authority zone */ +#define T_MB 7 /* mailbox domain name */ +#define T_MG 8 /* mail group member */ +#define T_MR 9 /* mail rename name */ +#define T_NULL 10 /* null resource record */ +#define T_WKS 11 /* well known service */ +#define T_PTR 12 /* domain name pointer */ +#define T_HINFO 13 /* host information */ +#define T_MINFO 14 /* mailbox information */ +#define T_MX 15 /* mail routing information */ +#define T_TXT 16 /* text strings */ + /* non standard */ +#define T_UINFO 100 /* user (finger) information */ +#define T_UID 101 /* user ID */ +#define T_GID 102 /* group ID */ +#define T_UNSPEC 103 /* Unspecified format (binary data) */ + /* Query type values which do not appear in resource records */ +#define T_AXFR 252 /* transfer zone of authority */ +#define T_MAILB 253 /* transfer mailbox records */ +#define T_MAILA 254 /* transfer mail agent records */ +#define T_ANY 255 /* wildcard match */ + +/* + * Values for class field + */ + +#define C_IN 1 /* the arpa internet */ +#define C_CHAOS 3 /* for chaos net at MIT */ +#define C_HS 4 /* for Hesiod name server at MIT */ + /* Query class values which do not appear in resource records */ +#define C_ANY 255 /* wildcard match */ + +/* + * Status return codes for T_UNSPEC conversion routines + */ +#define CONV_SUCCESS 0 +#define CONV_OVERFLOW -1 +#define CONV_BADFMT -2 +#define CONV_BADCKSUM -3 +#define CONV_BADBUFLEN -4 + +#ifndef BYTE_ORDER +#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ +#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ + +#if defined(vax) || defined(ns32000) || defined(sun386) || defined(MIPSEL) || \ + defined(BIT_ZERO_ON_RIGHT) +#define BYTE_ORDER LITTLE_ENDIAN + +#endif +#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ + defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ + defined(MIPSEB) || defined (BIT_ZERO_ON_LEFT) +#define BYTE_ORDER BIG_ENDIAN +#endif +#endif /* BYTE_ORDER */ + +#ifndef BYTE_ORDER + /* you must determine what the correct bit order is for your compiler */ + #define BYTE_ORDER LITTLE_ENDIAN /* for Intel x86 series */ +#endif +/* + * Structure for query header, the order of the fields is machine and + * compiler dependent, in our case, the bits within a byte are assignd + * least significant first, while the order of transmition is most + * significant first. This requires a somewhat confusing rearrangement. + */ + +#if defined (_WINDLL) || (_WIN32) +/* define UNIX types */ +#include <winsock.h> +#endif + +typedef struct { + u_short id; /* query identification number */ +#if BYTE_ORDER == BIG_ENDIAN + /* fields in third byte */ + u_char qr:1; /* response flag */ + u_char opcode:4; /* purpose of message */ + u_char aa:1; /* authoritive answer */ + u_char tc:1; /* truncated message */ + u_char rd:1; /* recursion desired */ + /* fields in fourth byte */ + u_char ra:1; /* recursion available */ + u_char pr:1; /* primary server required (non standard) */ + u_char unused:2; /* unused bits */ + u_char rcode:4; /* response code */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* fields in third byte */ + u_char rd:1; /* recursion desired */ + u_char tc:1; /* truncated message */ + u_char aa:1; /* authoritive answer */ + u_char opcode:4; /* purpose of message */ + u_char qr:1; /* response flag */ + /* fields in fourth byte */ + u_char rcode:4; /* response code */ + u_char unused:2; /* unused bits */ + u_char pr:1; /* primary server required (non standard) */ + u_char ra:1; /* recursion available */ +#endif + /* remaining bytes */ + u_short qdcount; /* number of question entries */ + u_short ancount; /* number of answer entries */ + u_short nscount; /* number of authority entries */ + u_short arcount; /* number of resource entries */ +} HEADER; + +/* + * Defines for handling compressed domain names + */ +#define INDIR_MASK 0xc0 + +/* + * Structure for passing resource records around. + */ +struct rrec { + short r_zone; /* zone number */ + short r_class; /* class number */ + short r_type; /* type number */ + u_long r_ttl; /* time to live */ + int r_size; /* size of data area */ + char *r_data; /* pointer to data */ +}; + +extern u_short _getshort(); +extern u_long _getlong(); + +/* + * Inline versions of get/put short/long. + * Pointer is advanced; we assume that both arguments + * are lvalues and will already be in registers. + * cp MUST be u_char *. + */ +#define GETSHORT(s, cp) { \ + (s) = *(cp)++ << 8; \ + (s) |= *(cp)++; \ +} + +#define GETLONG(l, cp) { \ + (l) = *(cp)++ << 8; \ + (l) |= *(cp)++; (l) <<= 8; \ + (l) |= *(cp)++; (l) <<= 8; \ + (l) |= *(cp)++; \ +} + + +#define PUTSHORT(s, cp) { \ + *(cp)++ = (s) >> 8; \ + *(cp)++ = (s); \ +} + +/* + * Warning: PUTLONG destroys its first argument. + */ +#define PUTLONG(l, cp) { \ + (cp)[3] = l; \ + (cp)[2] = (l >>= 8); \ + (cp)[1] = (l >>= 8); \ + (cp)[0] = l >> 8; \ + (cp) += sizeof(u_long); \ +} + +#endif /* !_NAMESER_H_ */ diff --git a/src/include/hesiod.h b/src/include/hesiod.h new file mode 100644 index 0000000000..3005929fce --- /dev/null +++ b/src/include/hesiod.h @@ -0,0 +1,217 @@ +/*! \file hesiod.h + * WSHelper DNS/Hesiod Library + * + * This file contains the function declaration for: \n + * hes_to_bind() \n + * hes_resolve() \n + * hes_error() \n + * hes_free() \n + * hes_getmailhost() \n + * hes_getservbyname() \n + * hes_getpwnam() \n + * hes_getpwuid() \n +*/ + +#ifndef _HESIOD_ +#define _HESIOD_ + + +#include <windows.h> + +/*! \def HESIOD_CONF + * name of the hesiod configuration file. We will look at the file to determine the RHS AND LHS value before using the default. + * Here is a sample hesiod.cfg file: \n + * lhs .ns \n + * rhs .ATHENA.MIT.EDU \n + */ +#define HESIOD_CONF "c:\\net\\tcp\\hesiod.cfg" + +/*! \def DEF_RHS + * default RHS value is the hesiod configuration file is not present + */ +#define DEF_RHS ".Athena.MIT.EDU" + +/*! \def DEF_LHS + * default LHS value is the hesiod configuration file is not present + */ +#define DEF_LHS ".ns" + +/*! \def HES_ER_UNINIT + * HES error code: uninitialized + */ +#define HES_ER_UNINIT -1 + +/*! \def HES_ER_OK + * HES error code: no error + */ +#define HES_ER_OK 0 + +/*! \def HES_ER_NOTFOUND + * HES error code: Hesiod name not found by server + */ +#define HES_ER_NOTFOUND 1 + +/*! \def HES_ER_CONFIG + * HES error code: local problem (no config file?) + */ +#define HES_ER_CONFIG 2 + +/*! \def HES_ER_NET + * HES error code: network problem + */ +#define HES_ER_NET 3 + + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \fn LPSTR WINAPI hes_to_bind(LPSTR HesiodName, LPSTR HesiodNameType) + * hes_to_bind function use the LHS and RHS values and + * binds them with the parameters so that a well formed DNS query may + * be performed. + * + * defined in hesiod.c + * + * \param[in] HesiodName The Hesiod name such as a username or service name + * \param[in] HesiodNameType The Hesiod name type such as pobox, passwd, or sloc + * \retval Returns NULL if there was an error. Otherwise the pointer to a string containing a valid query is returned. + * + */ +LPSTR WINAPI +hes_to_bind( + LPSTR HesiodName, + LPSTR HesiodNameType + ); + + +/*! \fn LPSTR * WINAPI hes_resolve(LPSTR HesiodName, LPSTR HesiodNameType) + * This function calls hes_to_bind to form a valid hesiod query, then queries the dns database. + * + * defined in hesiod.c + * + * \param[in] HesiodName The Hesiod name such as a username or service name + * \param[in] HesiodNameType The Hesiod name type such as pobox, passwd, or sloc + * \retval returns a NULL terminated vector of strings (a la argv), + * one for each resource record containing Hesiod data, or NULL if + * there is any error. If there is an error call hes_error() to get + * further information. You will need to call hes_free to free the result + * + */ + +LPSTR * WINAPI +hes_resolve( + LPSTR HesiodName, + LPSTR HesiodNameType + ); + +/*! \fn int WINAPI hes_error(void) + * The function hes_error may be called to determine the + * source of the error. It does not take an argument. + * + * defined in hesiod.c + * + * \retval return one of the HES_ER_* codes defined in hesiod.h. + */ + +int WINAPI +hes_error( + void + ); + + +/*! \fn void WINAPI hes_free(LPSTR* hesinfo) + * The function hes_free should be called to free up memeory returned by hes_resolve + * + * defined in hesiod.c + * + * \param[in] hesinfo a NULL terminiated array of strings returned by hes_resolve + */ +void WINAPI +hes_free( + LPSTR* hesinfo + ); + + +/*! \struct hes_postoffice + * For use in getting post-office information. + */ +struct hes_postoffice { + /*! The post office type, e.g. POP, IMAP */ + LPSTR po_type; + /*! The post office host, e.g. PO10.MIT.EDU */ + LPSTR po_host; + /*! The account name on the post office, e.g. tom */ + LPSTR po_name; +}; + +/*! \fn struct hes_postoffice * WINAPI hes_getmailhost(LPSTR user) + * This call is used to obtain a user's type of mail account and the location of that + * account. E.g. POP PO10.MIT.EDU or IMAP IMAP-TEST.MIT.EDU + * + * defined in hesmailh.c + * + * \param[in] user The username to be used when querying for the Hesiod Name Type POBOX. + * \retval NULL if there was an error or if there was no entry for the + * username. Otherwise a pointer to a hes_postoffice structure is + * returned. The caller must never attempt to modify this structure or to free + * any of its components. Furthermore, only one copy of this structure is allocated per call per thread, so the application should copy any information it needs before + * issuing another getmailhost call + */ +struct hes_postoffice * WINAPI hes_getmailhost(LPSTR user); + +/*! \fn struct servent * WINAPI hes_getservbyname(LPSTR name, LPSTR proto) + * This function will query a Hesiod server for a servent structure given + * a service name and protocol. This is a replacement for the Winsock + * getservbyname function which normally just uses a local services + * file. This allows a site to use a centralized database for adding new + * services. + * + * defined in hesservb.c + * + * \param[in] name pointer to the official name of the service, eg "POP3". + * \param[in] proto pointer to the protocol to use when contacting the service, e.g. "TCP" + * \retval NULL if there was an error or a pointer to a servent structure. The caller must + * never attempt to modify this structure or to free any of its components. + * Furthermore, only one copy of this structure is allocated per call per thread, so the application should copy any information it needs before + * issuing another hes_getservbyname call + * + */ +struct servent * WINAPI hes_getservbyname(LPSTR name, + LPSTR proto); + +/*! \fn struct passwd * WINAPI hes_getpwnam(LPSTR nam) + * Given a username this function will return the pwd information, eg + * username, uid, gid, fullname, office location, phone number, home + * directory, and default shell + * + * defined in hespwnam.c + * + * \param nam a pointer to the username + * \retval NULL if there was an error or a pointer to the passwd structure. The caller must + * never attempt to modify this structure or to free any of its components. + * Furthermore, only one copy of this structure is allocated per call per thread, so the application should copy any information it needs before + * issuing another hes_getpwnam call + * + */ +struct passwd * WINAPI hes_getpwnam(LPSTR nam); + +/*! struct passwd * WINAPI hes_getpwuid(int uid) + * Given a UID this function will return the pwd information, eg username, uid, + * gid, fullname, office location, phone number, home directory, and default shell + * + * defined in hespwnam.c + * + * \param uid The user ID + * \retval NULL if there was an error or a pointer to the passwd structure. The caller must + * never attempt to modify this structure or to free any of its components. + * Furthermore, only one copy of this structure is allocated per call per thread, so the application should copy any information it needs before + * issuing another hes_getpwuid call + */ +struct passwd * WINAPI hes_getpwuid(int uid); + +#ifdef __cplusplus +} +#endif + +#endif /* _HESIOD_ */ diff --git a/src/include/mitwhich.h b/src/include/mitwhich.h new file mode 100644 index 0000000000..47ee5dab63 --- /dev/null +++ b/src/include/mitwhich.h @@ -0,0 +1,84 @@ +/*! \file mitwhich.h + * some defines so that we can figure out which MS OS and subsystem an + * application is running under. Also support for finding out which + * TCP/IP stack is being used. This is useful when you need to find out + * about the domain or the nameservers. + */ + +#if !defined( __MIT_WHICH_H ) +#define __MIT_WHICH_H + +// these should become resources and loaded at run time +#define NT_32 "Winsock 2.0" +#define NT_16 "Windows NT 16-bit Windows Sockets" +#define W95_32 "Microsoft Windows Sockets Version 1.1." +#define W95_16 "Microsoft Windows Sockets Version 1.1." +#define LWP_16 "Novell Winsock version 1.1" +// Note that these are currently in wshelper.h and should be somewhere else +#define MS_NT_32 1 +#define MS_NT_16 2 +#define MS_95_32 3 +#define MS_95_16 4 +#define NOVELL_LWP_16 5 + +#define MS_OS_WIN 1 +#define MS_OS_95 2 +#define MS_OS_NT 4 +#define MS_OS_2000 12 +#define MS_OS_XP 28 +#define MS_OS_2003 60 +#define MS_OS_NT_UNKNOWN 124 +#define MS_OS_UNKNOWN 0 + +#define STACK_UNKNOWN 0 +#define UNKNOWN_16_UNDER_32 -2 +#define UNKNOWN_16_UNDER_16 -3 +#define UNKNOWN_32_UNDER_32 -4 +#define UNKNOWN_32_UNDER_16 -5 + + +/* + @comm these are the current MIT DNS servers, the wshelper and + wshelp32 DLLs will do their best to find the correct DNS servers + for the local machine however, if all else fails these will be used + as a last resort. Site administrators outside of the MIT domain + should change these defaults to their own defaults either by + editing this file and recompiling or by editing the string tables + of the binaries. Don't use App Studio to edit the .RC files. +\n + #define DNS1 "18.70.0.160" \n + #define DNS2 "18.71.0.151" \n + #define DNS3 "18.72.0.3" \n +\n + #define DEFAULT_DOMAIN "mit.edu" \n +*/ + +#define DNS1 "18.70.0.160" +#define DNS2 "18.71.0.151" +#define DNS3 "18.72.0.3" + +#define DEFAULT_DOMAIN "mit.edu" + + +#ifndef _PATH_RESCONF +#if !defined(WINDOWS) && !defined(_WINDOWS) && !defined(_WIN32) +#define _PATH_RESCONF "/etc/resolv.conf" +#else +#define _PATH_RESCONF "c:/net/tcp/resolv.cfg" +#endif +#endif + + +/* Microsoft TCP/IP registry values that we care about */ +#define NT_TCP_PATH "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters" +#define NT_TCP_PATH_TRANS "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Transient" +#define W95_TCP_PATH "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP" + +#define NT_DOMAIN_KEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Domain" +#define NT_NS_KEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\NameServer" + +#define W95_DOMAIN_KEY "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP\\Domain" +#define W95_NS_KEY "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP\\NameServer" + + +#endif // __MIT_WHICH_H diff --git a/src/include/resolv.h b/src/include/resolv.h new file mode 100644 index 0000000000..929795957d --- /dev/null +++ b/src/include/resolv.h @@ -0,0 +1,284 @@ +/*! \file resolv.h + * WSHelper DNS/Hesiod Library header + * This file contains the function declaration for:\n + * res_init() \n + * res_search() \n + * dn_comp() \n + * rdn_expand() \n \n + * and unsupported functions: \n + * res_setopts() \n + * res_getopts() \n + * res_querydomain() \n + * res_mkquery() \n + * res_send() \n +*/ + +#ifndef _RESOLV_H_ +#define _RESOLV_H_ + +#include <windows.h> +#ifndef MAXDNAME +#include <arpa/nameser.h> +#endif + +/*! \def MAXNS + * max # name servers we'll track + */ +#define MAXNS 3 + +/*! \def MAXDFLSRCH + * # default domain levels to try + */ +#define MAXDFLSRCH 3 + +/*! \def MAXDNSRCH + * max # domains in search path + */ +#define MAXDNSRCH 6 + +/*! \def LOCALDOMAINPARTS + * min levels in name that is "local" + */ +#define LOCALDOMAINPARTS 2 + +/*! \def RES_TIMEOUT + * min. seconds between retries + */ +#define RES_TIMEOUT 5 + +/*! \def MAXMXRECS + * number of records in the preference array in the MX record + */ +#define MAXMXRECS 8 + +/*! \struct mxent + * structure to hold the MX record + */ +struct mxent { + /*! number of records in the preference field */ + int numrecs; + /*! holds a 16 bit integer which specifies the preference given to this RR */ + u_short pref[MAXMXRECS]; + /*! a host willing to act as a mail exchange */ + char ** hostname; +}; + + +/*! \struct state + * This structure holds the state for the resolver query + */ +struct state { + /*! retransmition time interval */ + int retrans; + /*! number of times to retransmit */ + int retry; + /*! field option flags - see below. */ + long options; + /*! field number of name servers */ + int nscount; + /*! address of name server */ + struct sockaddr_in nsaddr_list[MAXNS]; +#define nsaddr nsaddr_list[0] + /*! current packet id */ + u_short id; + /*! field default domain */ + char defdname[MAXDNAME]; + /*! field components of domain to search */ + char *dnsrch[MAXDNSRCH+1]; +}; + +/*! \def RES_INIT + * resolver option: address initialized + */ +#define RES_INIT 0x0001 + +/*! \def RES_DEBUG + * resolver option: print debug messages + */ +#define RES_DEBUG 0x0002 + +/*! \def RES_AAONLY + * resolver option: authoritative answers only + */ +#define RES_AAONLY 0x0004 + +/*! \def RES_USEVC + * resolver option: use virtual circuit + */ +#define RES_USEVC 0x0008 + +/*! \def RES_PRIMARY + * resolver option: query primary server only + */ +#define RES_PRIMARY 0x0010 + +/*! \def RES_IGNTC + * resolver option: ignore trucation errors + */ +#define RES_IGNTC 0x0020 + +/*! \def RES_RECURSE + * resolver option: recursion desired + */ +#define RES_RECURSE 0x0040 + +/*! \def RES_DEFNAMES + * resolver option: use default domain name + */ +#define RES_DEFNAMES 0x0080 + +/*! \def RES_STAYOPEN + * resolver option: Keep TCP socket ope + */ +#define RES_STAYOPEN 0x0100 + +/*! \def RES_DNSRCH + * resolver option: search up local domain tree + */ +#define RES_DNSRCH 0x0200 + +/*! \def RES_DEFAULT + * resolver option: Default RES options (RES_RECURSE + RES_DEFNAMES + RES_DNSRCH) + */ +#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) + +extern struct state _res; + +#include <stdio.h> + +/* Private routines shared between libc/net, named, nslookup and others. */ +#define fp_query __fp_query +#define hostalias __hostalias +#define putlong __putlong +#define putshort __putshort +#define p_class __p_class +#define p_time __p_time +#define p_type __p_type + + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \fn int WINAPI res_init() + * \brief retrieves the default domain name and search order. It will look to see if an environment variable LOCALDOMAIN is defined. Otherwise, + * the domain associated with the local host is used. Otherwise, it will try to find the domain name from the registry + * + * defined in res_init.c + * + * \retval The return value is 0 if the operation was successful. Otherwise the value -1 is returned. + */ +int WINAPI res_init(); + + +/*! \fn int WINAPI res_search(const char* name, int qclass, int type, u_char* answer, int anslen) + * \brief a generic query interface to the DNS name space. The query is performed with the dnsapi and + * the answer buffer is populated based on the returned RR set. + * + * defined in res_quer.c + + * \param[in] name domain name + * \param[in] qclass class of query(such as DNS_CLASS_INTERNET, DNS_CLASS_CSNET, DNS_CLASS_CHAOS, + * DNS_CLASS_HESIOD. Defined in windns.h) + * \param[in] type type of query(such as DNS_TYPE_A, DNS_TYPE_NS, DNS_TYPE_MX, DNS_TYPE_SRV. Defined in + * windns.h) + * \param[in] answer buffer to put answer in + * \param[in] anslen size of the answer buffer. compare the anslen with the return value, if the return + * value is bigger than anslen, it means the answer buffer doesn't contain the complete + * response. You will need to call this function again with a bigger answer buffer if + * you care about the complete response + * + * \retval return the size of the response on success, -1 on error + * + */ +int WINAPI res_search(const char *name, + int qclass, int type, + u_char *answer, int anslen); + +/*! \fn int WINAPI dn_comp(const u_char* exp_dn, u_char* comp_dn, int length, u_char** dnptrs, u_char** lastdnptr) + * \brief Compress domain name 'exp_dn' into 'comp_dn' + * + * defined in res_comp.c + * + * \param[in] exp_dn name to compress + * \param[in, out] comp_dn result of the compression + * \param[in] length the size of the array pointed to by 'comp_dn'. + * \param[in, out] dnptrs a list of pointers to previous compressed names. dnptrs[0] + * is a pointer to the beginning of the message. The list ends with NULL. + * \param[in] lastdnptr a pointer to the end of the arrary pointed to by 'dnptrs'. Side effect + * is to update the list of pointers for labels inserted into the + * message as we compress the name. If 'dnptr' is NULL, we don't try to + * compress names. If 'lastdnptr' is NULL, we don't update the list. + * \retval Return the size of the compressed name or -1 + */ +int WINAPI dn_comp(const u_char *exp_dn, + u_char *comp_dn, + int length, u_char **dnptrs, + u_char * *lastdnptr); + +/*! \fn int WINAPI rdn_expand(const u_char *msg, const u_char *eomorig, const u_char *comp_dn, u_char *exp_dn, + int length); + * \brief replacement for dn_expand called rdn_expand. Older versions of the DLL used to this as dn_expand + * but this has caused some conflict with more recent versions of the MSDEV libraries. rdn_expand() + * expands the compressed domain name comp_dn to a full domain name. Expanded names are converted to upper case. + * + * defined in res_comp.c + * + * \param[in] msg msg is a pointer to the beginning of the message + * \param[in] eomorig + * \param[in] comp_dn the compressed domain name. + * \param[in, out] exp_dn a pointer to the result buffer + * \param[in] length size of the result in expn_dn + * \retval the size of compressed name is returned or -1 if there was an error. +*/ +int WINAPI rdn_expand(const u_char *msg, + const u_char *eomorig, + const u_char *comp_dn, + u_char *exp_dn, + int length); +/* Microsoft includes an implementation of dn_expand() in winsock */ +/* Make sure we do not use it. jaltman@columbia.edu */ +#define dn_expand(a,b,c,d,e) rdn_expand(a,b,c,d,e) + + +/*! \fn void WINAPI res_setopts(long opts) + * unsupported +*/ +void WINAPI res_setopts(long opts); + +/*! \fn long WINAPI res_getopts(void) + * unsupported +*/ +long WINAPI res_getopts(void); + +/*! \fn int WINAPI res_mkquery(int op, const char *dname, int qclass, int type, const char *data, int datalen, + * const struct rrec *newrr, char *buf, int buflen) + * unsupported + */ +int WINAPI res_mkquery(int op, const char *dname, + int qclass, int type, + const char *data, int datalen, + const struct rrec *newrr, + char *buf, int buflen); + +/*! \fn int WINAPI res_send(const char *msg, int msglen, char *answer, int anslen) + * unsupported +*/ +int WINAPI res_send(const char *msg, int msglen, + char *answer, int anslen); + +/*! \fn int WINAPI res_querydomain(const char *name, const char *domain, int qclass, int type, + u_char *answer, int anslen); +* unsupported +*/ +int WINAPI res_querydomain(const char *name, + const char *domain, + int qclass, int type, + u_char *answer, int anslen); + + +#ifdef __cplusplus +} +#endif + +#endif /* !_RESOLV_H_ */ diff --git a/src/include/wshelper.h b/src/include/wshelper.h new file mode 100644 index 0000000000..1bd31f0468 --- /dev/null +++ b/src/include/wshelper.h @@ -0,0 +1,148 @@ +/*! \file wshelper.h + * WSHelper DNS/Hesiod Library + * + * This file contains the function declaration for: \n + * rgethostbyname() \n + * rgethostbyaddr() \n + * rgetservbyname() \n + * inet_aton() \n + * wsh_gethostname() \n + * wsh_getdomainname() \n \n + * and unsupported functions: \n + * gethinfobyname() \n + * getmxbyname() \n + * getrecordbyname() \n + * rrhost() \n + */ + +#ifndef _WSHELPER_ +#define _WSHELPER_ + +#include <winsock.h> +#include <mitwhich.h> +#include <resolv.h> +#include <hesiod.h> + +#ifdef __cplusplus +extern "C" { +#endif +/*! \fn struct hostent * WINAPI rgethostbyname(char *name) + * retrieves host information corresponding to a host name in the DNS database + * + * defined in gethna.c + * + * \param[in] name Pointer to the null-terminated name of the host to resolve. It can be a fully qualified host name such as x.mit.edu + * or it can be a simple host name such as x. If it is a simple host name, the default domain name is + * appended to do the search. + * \retval a pointer to the structure hostent. a structure allocated by the library. The hostent structure contains + * the results of a successful search for the host specified in the name parameter. The caller must never + * attempt to modify this structure or to free any of its components. Furthermore, only one copy of this + * structure is allocated per call per thread, so the application should copy any information it needs before + * issuing another rgethostbyname. + * NULL if the search has failed + * +*/ +struct hostent * WINAPI rgethostbyname(char *name); + +/*! \fn struct hostent * WINAPI rgethostbyaddr(char *addr, int len, int type) + * retrieves the host information corresponding to a network address in the DNS database + * + * defined in gethna.c + * + * \param[in] addr Pointer to an address in network byte order + * \param[in] len Length of the address, in bytes + * \param[in] type Type of the address, such as the AF_INET address family type (defined as TCP, + * UDP, and other associated Internet protocols). Address family types and their corresponding + * values are defined in the Winsock2.h header file. + * \retval returns a pointer to the hostent structure that contains the name and address corresponding + * to the given network address. The structure is allocated by the library. The caller must never + * attempt to modify this structure or to free any of its components. Furthermore, only one copy of this + * structure is allocated per call per thread, so the application should copy any information it needs before + * issuing another rgethostbyaddr. + * NULL if the search has failed + * +*/ +struct hostent * WINAPI rgethostbyaddr(char *addr, int len, int type); + +/*! \fn struct servent * WINAPI rgetservbyname(LPSTR name, LPSTR proto) + * retrieves service information corresponding to a service name and protocol. + * + * defined in gethna.c + * + * \param[in] name Pointer to a null-terminated service name. + * \param[in] proto pointer to a null-terminated protocol name. getservbyname should match both + * the name and the proto. + * \retval a pointer to the servent structure containing the name(s) and service number that match the name and proto + * parameters. The structure is allocated by the library. The caller must never + * attempt to modify this structure or to free any of its components. Furthermore, only one copy of this + * structure is allocated per call per thread, so the application should copy any information it needs before + * issuing another rgetservbyname. + * NULL if the search has failed + * + */ +struct servent * WINAPI rgetservbyname(LPSTR name, LPSTR proto); + +/*! \fn LPSTR WINAPI gethinfobyname(LPSTR name) + * unsupported + */ +LPSTR WINAPI gethinfobyname(LPSTR name); + +/*! \fn LPSTR WINAPI getmxbyname(LPSTR name) + * unsupported + */ +LPSTR WINAPI getmxbyname(LPSTR name); + +/*! \fn LPSTR WINAPI getrecordbyname(LPSTR name, int rectype) + * unsupported + */ +LPSTR WINAPI getrecordbyname(LPSTR name, int rectype); + +/*! \fn DWORD WINAPI rrhost( LPSTR lpHost ) + * unsupported + */ +DWORD WINAPI rrhost( LPSTR lpHost ); + +/*! \fn unsigned long WINAPI inet_aton(register const char *cp, struct in_addr *addr) + * converts a string containing an (Ipv4) Internet Protocol dotted address into a proper address for the in_addr structure + * + * defined in inetaton.c + * + * \param[in] cp Null-terminated character string representing a number expressed in the + * Internet standard ".'' (dotted) notation. + * \param[in, out] addr pointer to the in_addr structure. The s_addr memeber will be populated + * \retval Returns 1 if the address is valid, 0 if not. + */ +unsigned long WINAPI inet_aton(register const char *cp, struct in_addr *addr); + + +/*! \fn int WINAPI wsh_gethostname(char* name, int size) + * Gets the base part of the hostname + * + * defined in res_init.c + * + * \param[in, out] name pointer to a buffer that receives a null-terminated string containing the computer name + * \param[in] size specifies the size of the buffer, in chars (must be large + * enough to hold NULL-terminated host name) + * \retval return 0 ifsuccess, -1 on error. +*/ +int WINAPI wsh_gethostname(char* name, int size); + +/*! \fn int WINAPI wsh_getdomainname(char* name, int size) + * Gets the machine's domain name + * + * defined in res_init.c + * + * \param[in, out] name pointer to a buffer that receives a null-terminated string containing the domain name + * \param[in] size specifies the size of the buffer, in chars (must be large + * enough to hold NULL-terminated domain name) + * + * \retval return 0 ifsuccess, -1 on error. + */ +int WINAPI wsh_getdomainname(char* name, int size); + + +#ifdef __cplusplus +} +#endif + +#endif /* _WSHELPER_ */ |
