Contents

WinSock Helper 2.0 MIT Information Services

To display a list of topics by category, click any of the contents entries below. To display an alphabetical list of topics, choose the Index button.

An Introduction to WSHELPER and WSHELP32

Authors and Copyright

Introduction

End User Configuration

Using WSHELPER, for the programmer

C Elements

BIND-Compatible DNS Resolver API

MIT Hesiod API

Other useful functions

All exported functions

Structures and Enums

Appendices

Modules

Help file built: 11/20/96

About Autoduck


About Autoduck

The sources for this Help file were generated by Autoduck, the source code documentation tool that generates Print or Help files from tagged comments in C, C++, Assembly, and Basic source files.

For more information, contact Eric Artzt (erica@microsoft.com).

Current source and binaries can be found at http://www.accessone.com/~ericartzt/


All exported functions

  • dn_comp
  • gethinfobyname
  • getmxbyname
  • getrecordbyname
  • getRegKey
  • herror
  • hes_error
  • hes_getmailhost
  • hes_getpwnam
  • hes_getpwuid
  • hes_getservbyname
  • hes_init
  • hes_resolve
  • hes_to_bind
  • inet_aton
  • rdn_expand
  • res_getopts
  • res_init
  • res_mkquery
  • res_query
  • res_querydomain
  • res_search
  • res_send
  • res_setopts
  • rgethostbyaddr
  • rgethostbyname
  • rgetservbyname
  • rrhost
  • WhichOS
  • WSHGetHostID


  • Authors and Copyright

    This software is being provided to you, the LICENSEE, by the Massachusetts Institute of Technology (M.I.T.) under the following license. By obtaining, using and/or copying this software, you agree that you have read, understood, and will comply with these terms and conditions. Permission to use, copy, modify and distribute this software and its documentation for any purpose and without fee or royalty is hereby granted, provided that you agree to comply with the following copyright notice and statements, including the disclaimer, and that the same appear on ALL copies of the software and documentation, including modifications that you make for internal use or for distribution: Copyright 1994, 1995, 1996 by the Massachusetts Institute of Technology. All rights reserved.

    THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. By way of example, but not limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

    The name of the Massachusetts Institute of Technology or M.I.T. may NOT be used in advertising or publicity pertaining to distribution of the software. Title to copyright in this software and any associated documentation shall at all times remain with M.I.T., and USER agrees to preserve same.

    This product includes software developed by the University of California, Berkeley and its contributors.


    BIND-Compatible DNS Resolver API

    While the standard WinSock GetXbyY function calls suit many development needs, some applications require true nameserver resolution capability to function. WSHelper provides true resolver functions and resolver-based replacements to WinSock's gethostbyname() and gethostbyaddr() functions.

  • dn_comp
  • inet_aton
  • rdn_expand
  • res_getopts
  • res_init
  • res_mkquery
  • res_query
  • res_querydomain
  • res_search
  • res_send
  • res_setopts
  • rgethostbyaddr
  • rgethostbyname
  • rgetservbyname


  • Constants


    End User Configuration

    This version of wshelper and wshelp32 tries to make the end user configuration as simple as possible. By default the libraries should support the following Winsock TCP/IP implementations: Microsoft's TCP/IP as provided on Windows 95 and NT, Novell's LAN WorkPlace, FTP, Inc's PCTCP (and some other their other products), Trumpet Winsock, CORE Winsock. By using environment variables, simple text files, or a resource editor, you should also be able to support your own local configuration if these defaults do not suffice.

    When running under Windows 95 or Windows NT both the 16 bit and 32 DLL will attempt to read the IP addresses of the nameservers, also known as the BIND servers, from the registry. The libraries will also attempt to read the default domain from the registry.

    This version assumes the registry values are those that Microsoft currently uses for Windows 95 and NT 4.0. However these values may be configured differently on other stacks or changed by Microsoft in the future. The actual values used are defined in the header file mitwhich.h. These values are used to build string resources in the DLL. So in most cases the string resource is what is actually used. This means that you may use a resource editor to change the default registry values without needing to recompile the source code.

    When running on Windows 3.x, WFWG, or if the libraries are unable to find the correct registry values, the library will try to find the configuration information in a file. The file will be looked for in a variety of places. First it will check 4 different environment variables, ETC, EXCELAN, NDIR, and PCTCP. If the ETC environment variable is found the library will look for a file named resolv.cfg in the directory named by the ETC variable. If the EXCELAN environment variable is found then the library will use this value as a base directory name and then search the subdirectories etc and tcp for the resolv.cfg file. If the PCTCP environment variable is found the library expects this to point to a fully qualified pctcp.ini file as supported by products from FTP, Inc.

    The library goes to even more extreme lengths to get the users configuration data. It will also look on the user's path for resolv.cfg, trumpwsk.ini, core.ini, and pctcp.ini. The library does understand the format of the trumpwsk.ini, core.ini, and pctcp.ini files. The library will also search for the file defined by the string resource IDS_DEF_RESCONF_PATH, which is initially controlled by the _PATH_RESCONF defined in the resolv.h header file of the source code.

    If all else fails the user will be notified that the machine is not properly configured but they will be given a chance to continue. In this case some hard coded defaults will be used. These are defined as string resources. Site administrators please use a resource editor to change these to your defaults rather than MIT's. It will provide your users and ours with better performance.

    Here is a sample resolv.cfg file:

    domain mit.edu
    nameserver 18.70.0.160
    nameserver 18.71.0.151
    nameserver 18.72.0.3

    If you have to create a resolv.cfg file for your machine please determine the correct IP address for your domain and change mit.edu to your own local domain.

    See Also

    res_init

    For Hesiod support we do not go to quite such elaborate lengths to find the configuration information. The library will check for a HES_DOMAIN environment variable. If it is present then this will be used as the RHS or the Hesiod domain, e.g. ATHENA.MIT.EDU. The LHS and RHS defaults are stringtable entries of IDS_DEF_HES_LHS and IDS_DEF_HES_RHS. So these may be changed by modifying the source or editing the resource. The string resource IDS_DEF_HES_CONFIG_FILE is also checked. In this case the libraries will look to see if a Hesiod config file is present and if so it will use the RHS and LHS defined in the file. Note that the environment variable will take precedence over the config file, the config file takes precedence over the default LHS and RHS string table entries.

    hes_init

    Here is a sample hesiod.cfg file:
    lhs .ns
    rhs .ATHENA.MIT.EDU

    At Stanford the proper values would be:
    lhs .ns
    rhs .STANFORD.EDU

    A more formal description of the resolv.cfg and hesiod.cfg syntax:

    To use either the DNS or Hesiod resolution functions, a resolver configuration file (by default, C:\\NET\\TCP\\RESOLV.CFG - change _PATH_RESCONF in resolv.h) must be set up. This should contain at least one entry of the form:

    nameserver\tab < ip-address >

    , where < ip-address > is the dotted-decimal IP address of a known BIND server. If no nameserver is specified, the resolver code will assume that the local machine is capable of handling resolver queries. If no BIND server is running locally, the resolver routines will search a local hosts file (by default, C:\\TCP\\HOSTS, change _PATH_HOSTS in gethna.c). If you wish the resolver functions to search a default domain, add an entry of the form:

    domain\tab \tab < default.domain >

    to the resolver configuration file. Note that

    domain\tab \tab MIT.EDU

    would be valid whereas

    domain\tab \tab .MIT.EDU

    includes an unncecessary first dot.



    To configure Hesiod name service lookup, create a Hesiod configuration file (by default C:\\NET\\HESIOD.CFG) with two entries of the form:

    lhs\tab \tab .ns
    rhs\tab \tab .your.hesiod.domain

    , noting that here a first dot is needed.


    Introduction

    The WSHelper (Windows Sockets Helper) library was created in an effort to fill a gap in the current WinSock specification (1.1). This specification, while requiring implementors to provide getXbyY() style "database" functions which retrieve host address, service port, and protocol information, does not explicitly state how the functions should go about this. At the simple level, implementors could have the database functions search local files, which is fine for finding standard service and protocol information, but impractical for modern applications which could possibly require a canonical Internet host table, and thus this approach is suitable only for PC's that use TCP/IP on a LAN basis. More reasonably, implementors could search a local host table, then, failing that, go on to make a resolver query to a known nameserver, or vice versa. This is precisely what many implementors do, but since this functionality is abstracted at a fairly high level (the actual resolver functions are inaccessible to de velopers), and because the specification is as vague as it is, a need exists for true WinSock-based BIND resolver functions, which WSHelper provides. In addition, WSHelper complements its BIND support with MIT Hesiod Name Service support, for queries on sites which support the Hesiod query class.

    We have also found that in many Winsock 1.1 implementations the getXbyY() functions are poorly implemented. By provding the alternate implementation for which full source code is available we hope to improve this situation. At this time we have not attempted to implement non-blocking versions of these function nor have we implemented thread safe versions. We may provide this functionality in the future.


    Messages


    MIT Hesiod API

    WSHelper also provides an interface to MIT Hesiod Name Service resolution functions.

  • herror
  • hes_error
  • hes_getmailhost
  • hes_getpwnam
  • hes_getpwuid
  • hes_getservbyname
  • hes_init
  • hes_resolve
  • hes_to_bind


  • Modules

  • gethna.c
  • herror.c
  • hesiod.c
  • hesmailh.c
  • hespwnam.c
  • hesservb.c
  • inetaton.c
  • mitwhich.h
  • res_comp.c
  • res_debu.c
  • res_init.c
  • res_mkqu.c
  • res_quer.c
  • res_send.c
  • resolve.c
  • resscan.h


  • Other useful functions

    WSHelper also provides an interface to other functions, most are related to name resolution.

  • gethinfobyname
  • getmxbyname
  • getrecordbyname
  • getRegKey
  • rrhost
  • WhichOS
  • WSHGetHostID


  • Overviews


    Structures and Enums

  • _res
  • nsmsg_t
  • retransXretry
  • rr_t


  • Using WSHELPER, for the programmer

    First and foremost, it is the responsibility of the module calling WSHelper to take measures to ensure that a valid WINSOCK.DLL exists on the system and has been loaded (either automatically or dynamically), and as well that WSAStartup() has been called and successfully. The WinSock documentation describes how this is done.

    The wshelper and wshelp32 DLLs consist of a set of C functions that may be used by any application developer. The exported functions which are accessible to applications are described individually in the C elements section of this document.

    The wshelper.dll is a 16 bit DLL. It has been tested on Windows 3.11, WFWG 3.11, Windows 95 and Windows NT 3.x and 4.0. The wshelp32.dll is the 32 bit version of the same library. Currently we are only distributing the i386 build. This has been tested on Windows 95, and Windows 4.0 with the Microsoft supplied TCP/IP stacks. Please see the end user configuration section for more installation/configuration information.

    Bugs may be reported to bugs@mit.edu.


    Filename: C:/WORK/WSHELPER/MIT-COPY.H

    Description

    mit-copy.h


    gethna.c

    Filename: C:/WORK/WSHELPER/GETHNA.C

    Description

    This file contains the function definitions for: rgethostbyname, rgethostbyaddr, rdn_expand, gethinfobyname, getmxbyname, getrecordbyname, rrhost, rgetservbyname, WSHGetHostID and some other internal functions called by these functions.

    WSHelper DNS/Hesiod Library for WINSOCK


    herror.c

    Filename: C:/WORK/WSHELPER/HERROR.C

    Description

    The definition of herror is in this module.


    hesiod.c

    Filename: C:/WORK/WSHELPER/HESIOD.C

    Description

    This module contains the defintions for the exported functions: hes_to_bind hes_resolve hes_error as well as the internal function hes_init. The hes_init function is the one that determines what the Hesiod servers are for your site and will parse the configuration files, if any are present.

    WSHelper DNS/Hesiod Library for WINSOCK


    hesmailh.c

    Filename: C:/WORK/WSHELPER/HESMAILH.C

    Description

    This file contains hes_postoffice, which retrieves post-office information for a user.

    For copying and distribution information, see the file < mit-copyright.h >

    Original version by Steve Dyer, IBM/Project Athena.

    WSHelper DNS/Hesiod Library for WINSOCK


    hespwnam.c

    Filename: C:/WORK/WSHELPER/HESPWNAM.C

    Description

    This file contains hes_getpwnam, for retrieving passwd information about a user.

    For copying and distribution information, see the file < mit-copyright.h >

    Original version by Steve Dyer, IBM/Project Athena.

    WSHelper DNS/Hesiod Library for WINSOCK


    hesservb.c

    Filename: C:/WORK/WSHELPER/HESSERVB.C

    Description

    Contains the definition for hes_getservbyname,

    WSHelper DNS/Hesiod Library for WINSOCK


    inetaton.c

    Filename: C:/WORK/WSHELPER/INETATON.C

    Description

    from the BIND 4.9.x inetaddr.c

    Contains implementation of inet_aton

    WSHelper DNS/Hesiod Library for WINSOCK


    mitwhich.h

    Filename: C:/LOCALH/MITWHICH.H

    Description

    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.

    Comments

    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.
    #define DNS1\tab "18.70.0.160"
    #define DNS2\tab "18.71.0.151"
    #define DNS3\tab "18.72.0.3"

    #define DEFAULT_DOMAIN "mit.edu"

    Notes on different Winsock stack configuration files.

    The Microsoft stacks for Windows95 and NT 3.x, 4.x use the registry to store the default domain and the IP addresses of the DNS servers. The wshelper and wshelp32 will use the registry information when possible.

    Novell's LAN WorkPlace stack and the much older Excelan products use a resolv.cfg file to store this information. The resolv.cfg file could be located in a number of places over the years. Our DLL will try to search for it in:

    C:\\etc\\resolv.cfg
    C:\\excelan\\tcp\\resolv.cfg
    C:\\net\\tcp\\resolv.cfg
    %NDIR%\\etc\\resolv.cfg
    %NDIR%\\tcp\\resolv.cfg

    where %NDIR% is the expansion of the local environment variable NDIR. So setting NDIR to be N:\\COMMON\\NET would mean that we would also look in N:\\common\\net\\etc\\resolv.cfg and N:\\common\\net\\tcp\\resolv.cfg for the domain and nameserver information.

    Here is a sample resolv.cfg file

    LAN WorkPlace resolver configuration file
    domain mit.edu

    nameserver 18.70.0.160
    nameserver 18.71.0.151
    nameserver 18.72.0.3
    end of file

    The TRUMPET Winsock stack uses a TRUMPETWSK.INI file to store the domain and nameserver configuration information. The section tag is [Trumpet Winsock]. The domain information is identified by domain= and the nameserver information is identified by a single name, dns=, multiple nameservers may be specified on the same line and they should be space delimited.

    trupwsk.ini
    [Trumpet Winsock]
    dns=18.71.0.151 18.70.0.160 18.72.0.3
    domain=mit.edu

    Core Internet-Connect uses a CORE.INI file, nameservers are comma delimited.
    [winsock]
    domainname=mit.edu
    nameservers=18.71.0.151, 18.70.0.160, 18.72.0.3

    FTP software uses a PCTCP.INI file. This file may be located by use of the environment variable PCTCP.
    [pctcp general]
    domain=mit.edu
    [pctcp addresses]
    domain-name-server=18.70.0.160
    domain-name-server=18.71.0.151
    domain-name-server=18.72.0.3


    res_comp.c

    Filename: C:/WORK/WSHELPER/RES_COMP.C

    Description

    Contains the implementations for dn_comp and rdn_expand as well as some other functions used internally by these two functions.

    WSHelper DNS/Hesiod Library for WINSOCK


    res_debu.c

    Filename: C:/WORK/WSHELPER/RES_DEBU.C

    Description

    Contains implimentations for debugging information, including result codes and specified where the debugging log is to be written.

    WSHelper DNS/Hesiod Library for WINSOCK


    res_init.c

    Filename: C:/WORK/WSHELPER/RES_INIT.C

    Description

    Contains the implementation for res_init, res_getopts, res_setopts and supplementary internal functions. If you are adding support for a new TCP/IP stack of resolver configuration information this is where it will go.

    See Also

    res_init res_setopts res_getopts WhichOS getRegKey

    WSHelper DNS/Hesiod Library for WINSOCK


    res_mkqu.c

    Filename: C:/WORK/WSHELPER/RES_MKQU.C

    Description

    Contains the implementation of res_mkquery

    WSHelper DNS/Hesiod Library for WINSOCK


    res_quer.c

    Filename: C:/WORK/WSHELPER/RES_QUER.C

    Description

    Contains the implementation of res_query, res_search, and res_querydomain

    WSHelper DNS/Hesiod Library for WINSOCK


    res_send.c

    Filename: C:/WORK/WSHELPER/RES_SEND.C

    Description

    Contains the implementation of res_send

    WSHelper DNS/Hesiod Library for WINSOCK


    resolve.c

    Filename: C:/WORK/WSHELPER/RESOLVE.C

    Description

    Contains the implementation of resolve and some internally defined functions.

    WSHelper DNS/Hesiod Library for WINSOCK


    resscan.h

    Filename: C:/WORK/WSHELPER/RESSCAN.H

    Description

    WSHelper DNS/Hesiod Library for WINSOCK


    dn_comp

    EXPORT32 int EXPORT WINAPI dn_comp(void)

    Compress domain name 'exp_dn' into 'comp_dn'. Return the size of the compressed name or -1. 'length' is the size of the array pointed to by 'comp_dn'. 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0] is a pointer to the beginning of the message. The list ends with NULL. 'lastdnptr' is 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.

    Defined in: C:/WORK/WSHELPER/RES_COMP.C


    gethinfobyname

    EXPORT32 LPSTR EXPORT WINAPI gethinfobyname(LPSTR name)

    Given the name of a host query the nameservers for the T_HINFO information associated with the host.

    Defined in: C:/WORK/WSHELPER/GETHNA.C

    Return Value

    NULL or a pointer to the T_HINFO.

    Parameters

    name
    pointer to the name of the host that the query is about.

    getmxbyname

    EXPORT32 struct mxent FAR * EXPORT WINAPI getmxbyname(LPSTR name)

    This function will query the nameservers for the MX records associated with the given hostname. Note that the return is a pointer to the mxent structure so an application making this call can iterate through the different records returned and can also reference the preference information associated with each hostname returned.

    Defined in: C:/WORK/WSHELPER/GETHNA.C

    Return Value

    NULL or a pointer to a mxent structure.

    Parameters

    name
    The name of the host for which we want MX records.

    getrecordbyname

    EXPORT32 LPSTR EXPORT WINAPI getrecordbyname(LPSTR name, int rectype)

    This function will query the nameservers about the given hostname for and DNS record type that the application wishes to query.

    Defined in: C:/WORK/WSHELPER/GETHNA.C

    Return Value

    The return is NULL or a pointer to a string containing the data returned. It is up to the calling application to parse the string appropriately for the rectype queried.

    Parameters

    name
    a pointer to the hostname
    rectype
    a DNS record type, e.g. T_MX, T_HINFO, ...

    getRegKey

    int getRegKey(const HKEY key, const char * subkey, const char * value, char * buf)

    This function is only used when the library is running under a known 32 bit Microsoft Operating system

    Defined in: C:/WORK/WSHELPER/RES_INIT.C

    Return Value

    Returns an int that can mean:

    FALSE - if the subkey cannot be queried or possibly opened. TRUE - if the subkey can be queried but it is not of type: REG_EXPAND_SZ If the subkey can be queried, and its type is REG_EXPAND_SZ, and it can be expanded the return value is the number of characters stored in the buf parameter. If the number of characters is greater than the size of the of the destination buffer, the return value should be the size of the buffer required to hold the value.

    Parameters

    key
    Specifies a a currently open key or any of the following predefined reserved handle values: HKEY_CLASSES_ROOT KEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS
    subkey
    Specifies a pointer to a null-terminated string containing the name of the subkey to open. If this parameter is NULL or a pointer to an empty string, the function will open a new handle of the key identified by the key parameter.
    value
    Specifiea a pointer to a null-terminated string containing the name of the value to be queried.
    buf
    Specifies a pointer to a buffer that recieves the key's data. This parameter can be NULL if the data is not required.

    herror

    void herror(char * s)

    print the error indicated by the h_errno value in a MessageBox.

    Defined in: C:/WORK/WSHELPER/HERROR.C

    Parameters

    s
    OK so we don't actually use this parameter. This is left over UNIX code where it was used to get the error message. We just make a call to WSAGetLastError under Windows and then play with some offsets.

    hes_error

    EXPORT32 int EXPORT WINAPI hes_error(void)

    The function hes_error may be called to determine the source of the error. It will return one of the HES_ER_* codes defined in hesiod.h. It does not take an argument.

    Defined in: C:/WORK/WSHELPER/HESIOD.C


    hes_getmailhost

    struct hes_postoffice FAR * WINAPI hes_getmailhost(LPSTR user)

    This will a pointer to a hes_postoffice structure. 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: C:/WORK/WSHELPER/HESMAILH.C

    Return Value

    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.

    Parameters

    user
    The username to be used when querying for the Hesiod Name Type POBOX.

    hes_getpwnam

    EXPORT32 struct passwd * EXPORT WINAPI hes_getpwnam(char * 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: C:/WORK/WSHELPER/HESPWNAM.C

    Return Value

    NULL or a pointer to the passwd structure.

    Parameters

    nam
    a pointer to the username

    hes_getpwuid

    EXPORT32 struct passwd * EXPORT 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: C:/WORK/WSHELPER/HESPWNAM.C

    Return Value

    NULL or a pointer to the passwd structure.

    Parameters

    uid
    The user ID

    hes_getservbyname

    EXPORT32 struct servent * EXPORT WINAPI hes_getservbyname(char * name, char * 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: C:/WORK/WSHELPER/HESSERVB.C

    Return Value

    NULL or a pointer to a servent structure.

    Parameters

    name
    pointer to the official name of the service, eg "POP3".
    proto
    pointer to the protocol to use when contacting the service, e.g. "TCP"

    hes_init

    int hes_init(void)

    This function is not exported. It takes no arguments. However it is important to understand how this works. It sets the global variables Hes_LHS and Hes_RHS which are used to form the Hesiod queries. Understanding how this works and setting up the correct configuration will determine if the Hesiod queries will work at your site. Settings can be configured by makgin source code changes and rebuilding the DLL, editing resources in the DLL, using a co9nfiguration file, or setting an environment variable.

    The function first tries to open the HesConfigFile and set the Hes_RHS and Hes_LHS variables from this. If there is no config file then the function tries to load a string resource from the DLL to set the LHS and RHS. If the string resources cannot be loaded then the LHS and RHS will be set by the values of DEF_LHS and DEF_RHS, these are defined in hesiod.h. Note that the string resources are by default set to these same values since the RC files include hesiod.h

    Finally if the user sets the environment variable HES_DOMAIN the RHS will be overridden by the value of the HES_DOMAIN value.

    Note that LoadString requires us to first find the module handle of the DLL. We have to use the internal module name as defined in the DEF file. If you change the library name within the DEF file you also need to change the appropriate string in hesiod.c

    Defined in: C:/WORK/WSHELPER/HESIOD.C


    hes_resolve

    EXPORT32 char ** EXPORT WINAPI hes_resolve(LPSTR HesiodName, LPSTR HesiodNameType)

    is the primary interface to the Hesiod name server. It takes two arguments, a name to be resolved and a string, known as a HesiodNameType. Remarks\tab If the environment variable HES_DOMAIN is set, this domain will override what is in /etc/athena/hesiod.conf. FILES: hesiod.h, hesiod.conf

    Defined in: C:/WORK/WSHELPER/HESIOD.C

    Return Value

    It 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.

    Parameters

    HesiodName
    The name to be resovled.
    HesiodNameType
    A valid Hesiod name type.

    hes_to_bind

    EXPORT32 char * EXPORT WINAPI hes_to_bind(LPSTR HesiodName, LPSTR HesiodNameType)

    The 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: C:/WORK/WSHELPER/HESIOD.C

    Return Value

    Reterns NULL if there was an error. Otherwise the pointer to a string containing a valid query is returned.

    Parameters

    HesiodName
    The Hesiod name such as a username or service name
    HesiodNameType
    The Hesiod name type such as pobox, passwd, or sloc

    inet_aton

    EXPORT32 unsigned long EXPORT WINAPI inet_aton(register const char * cp, struct in_addr * addr)

    Check whether "cp" is a valid ascii representation of an Internet address and convert to a binary address. Returns 1 if the address is valid, 0 if not. This replaces inet_addr, the return value from which cannot distinguish between failure and a local broadcast address.

    Defined in: C:/WORK/WSHELPER/INETATON.C

    Return Value

    1 if the address is valid 0 if not.

    Parameters

    cp
    pointer to a string to be checked
    addr
    pointer to the in_addr structure for the first parameter if successfull.

    rdn_expand

    EXPORT32 int EXPORT WINAPI rdn_expand(u_char * msg, u_char * eomorig, u_char * comp_dn, u_char * expn_dn, int length)

    Our replacement for dn_expand called rdn_expand. Older versions of the DLL used to export 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: C:/WORK/WSHELPER/RES_COMP.C

    Return Value

    The size of compressed name is returned or - 1 if there was an error.

    Parameters

    msg
    msg is a pointer to the beginning of the message,
    eomorig
    (I don't remember at the moment. Feed it a NULL)
    comp_dn
    the compressed domain name.
    expn_dn
    expn_dn a pointer to the result buffer
    length
    size of the result in expn_dn

    res_getopts

    EXPORT32 void EXPORT WINAPI res_getopts(void)

    Global information that is used by the resolver routines is kept in the variable _res. Most of the values have reasonable defaults and can be ignored. Options are a simple bit mask and are OR'ed in to enable. Options stored in _res.options are defined in < resolv.h > and are as follows.

    Defined in: C:/WORK/WSHELPER/RES_INIT.C

    Return Value

    returns a long which is the resolver option flags

    Comments

    RES_INIT True if the initial name server address and default domain name are initialized (that is, res_init() has been called).

    RES_DEBUG Print debugging messages.

    RES_AAONLY Accept authoritative answers only. res_send() will continue until it finds an authoritative answer or finds an error. Currently this is not implemented.

    RES_USEVC Use TCP connections for queries instead of UDP.

    RES_PRIMARY Query primary server only.

    RES_IGNTC Unused currently (ignore truncation errors, that is, do not retry with TCP).

    RES_RECURSE Set the recursion desired bit in queries. This is the default. res_send() does not do iterative queries and expects the name server to handle recursion.

    RES_DEFNAMES Append the default domain name to single label queries. This is the default.

    RES_STAYOPEN Used with RES_USEVC to keep the TCP connection open between queries. This is useful only in programs that regularly do many queries. UDP should be the normal mode used.

    RES_DNSRCH Search up local domain tree.


    res_init

    EXPORT32 int EXPORT WINAPI res_init(void)

    This function reads the resolver configuration files and retrieves the default domain name, search order and name server address(es). If no server is given, the local host is tried. If no domain is given, that associated with the local host is used. It can be overriden with the environment variable LOCALDOMAIN. This function is normally executed by the first call to one of the other resolver functions.

    Defined in: C:/WORK/WSHELPER/RES_INIT.C

    Return Value

    The return value is 0 if the operation was successful. Otherwise the value -1 is returned.


    res_mkquery

    EXPORT32 int EXPORT 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)

    Form all types of queries.

    Defined in: C:/WORK/WSHELPER/RES_MKQU.C

    Return Value

    Returns the size of the result or -1.

    Parameters

    op
    opcode of query
    dname
    domain name
    qclass
    class of query
    type
    type of query
    data
    resource record data
    datalen
    length of data
    newrr
    new rr for modify or append
    buf
    buffer to put query
    buflen
    size of buffer

    res_query

    EXPORT32 int EXPORT WINAPI res_query(char * name, int qclass, int type, u_char * answer, int anslen)

    Formulate a normal query, send, and await answer. Returned answer is placed in supplied buffer "answer". Perform preliminary check of answer, returning success only if no error is indicated and the answer count is nonzero. Return the size of the response on success, -1 on error. Error number is left in h_errno. Caller must parse answer and determine whether it answers the question.

    Defined in: C:/WORK/WSHELPER/RES_QUER.C

    Parameters

    name
    domain name
    qclass
    class of query
    type
    type of query
    answer
    buffer to put answer in
    anslen
    size of answer buffer

    res_querydomain

    int WINAPI res_querydomain(char * name, char * domain, int qclass, int type, u_char * answer, int anslen)

    Perform a call on res_query on the concatenation of name and domain, removing a trailing dot from name if domain is NULL.

    Defined in: C:/WORK/WSHELPER/RES_QUER.C

    Parameters

    name
    name
    domain
    domain
    qclass
    query class
    type
    query type
    answer
    buffer for answer
    anslen
    length of buffer

    res_search

    EXPORT32 int EXPORT WINAPI res_search(char * name, int qclass, int type, u_char * answer, int anslen)

    Formulate a normal query, send, and retrieve answer in supplied buffer. Return the size of the response on success, -1 on error. If enabled, implement search rules until answer or unrecoverable failure is detected. Error number is left in h_errno. Only useful for queries in the same name hierarchy as the local host (not, for example, for host address-to-name lookups in domain in-addr.arpa).

    Defined in: C:/WORK/WSHELPER/RES_QUER.C

    Parameters

    name
    domain name
    qclass
    class of query
    type
    type of query
    answer
    buffer to put answer in
    anslen
    size of the answer buffer

    res_send

    EXPORT32 int EXPORT WINAPI res_send(const char * buf, int buflen, char * answer, int anslen)

    sends a query to name servers and returns an answer. It will call res_init() if RES_INIT is not set, send the query to the local name server, and handle timeouts and retries. The length of the message is returned or -1 if there were errors.

    Remarks

    RES_AAONLY \tab Accept authoritative answers only. res_send() will continue until it finds an authoritative answer or finds an error. Currently this is not implemented.

    RES_RECURSE Set the recursion desired bit in queries. This is the default. res_send() does not do iterative queries and expects the name server to handle recursion.

    Defined in: C:/WORK/WSHELPER/RES_SEND.C

    Return Value

    The length of the message is returned or -1 if there were errors.

    Parameters

    buf
    contains the query to send
    buflen
    the length of the query
    answer
    the answer returned if any
    anslen
    the length of the answer

    res_setopts

    EXPORT32 void EXPORT WINAPI res_setopts(long opts)

    Global information that is used by the resolver routines is kept in the variable _res. Most of the values have reasonable defaults and can be ignored. Options are a simple bit mask and are OR'ed in to enable. Options stored in _res.options are defined in < resolv.h > and are as follows.

    Defined in: C:/WORK/WSHELPER/RES_INIT.C

    Parameters

    opts
    the resolver option flags

    Comments

    RES_INIT True if the initial name server address and default domain name are initialized (that is, res_init() has been called).

    RES_DEBUG Print debugging messages.

    RES_AAONLY Accept authoritative answers only. res_send() will continue until it finds an authoritative answer or finds an error. Currently this is not implemented.

    RES_USEVC Use TCP connections for queries instead of UDP.

    RES_PRIMARY Query primary server only.

    RES_IGNTC Unused currently (ignore truncation errors, that is, do not retry with TCP).

    RES_RECURSE Set the recursion desired bit in queries. This is the default. res_send() does not do iterative queries and expects the name server to handle recursion.

    RES_DEFNAMES Append the default domain name to single label queries. This is the default.

    RES_STAYOPEN Used with RES_USEVC to keep the TCP connection open between queries. This is useful only in programs that regularly do many queries. UDP should be the normal mode used.

    RES_DNSRCH Search up local domain tree.


    rgethostbyaddr

    EXPORT32 struct hostent * EXPORT WINAPI rgethostbyaddr(const char * addr, int len, int type)

    Our replacement for gethostbyaddr, called rgethostbyaddr These functions are used to obtain entries describing hosts. Gethostbyaddr() searches for information for a host with a given host address. The parameter type specifies the family of the address. This should be one of the address families defined in < sys/socket.h >. The parameter addr must be a pointer to a buffer containing the address. The address is given in a form specific to the address family. See the NOTES section below for more information. The parameter len specifies the length of the buffer indicated by addr.

    Defined in: C:/WORK/WSHELPER/GETHNA.C

    Parameters

    addr
    The parameter addr must be a pointer to a buffer containing the address. The address is given in a form specific to the address family.
    len
    The length of the address
    type
    The parameter type specifies the family of the address.

    rgethostbyname

    EXPORT32 struct hostent * EXPORT WINAPI rgethostbyname(const char * name)

    Searches for information for a host with the hostname specified by the character string parameter name.

    Defined in: C:/WORK/WSHELPER/GETHNA.C

    Return Value

    The functions rgethostbyname(), rgethostbyname_r(), each return a pointer to a struct hostent if they successfully locate the requested entry; otherwise they return NULL.

    Parameters

    name
    A pointer to the hostname.

    rgetservbyname

    EXPORT32 struct servent FAR * EXPORT WINAPI rgetservbyname(LPCSTR name, LPCSTR proto)

    This is equivalent to getservbyname but instead of just looking up the service entry in the local host file it will first query the Hesiod server(s) for the information. This allows a site to add new services in a centrally managed fashion instead of relying on propagation of a new services file to all machines on the network.

    If the Hesiod query fails the function will fall back to the Winsock version of getservbyname which is usually implementated as a simple lookup in a local host file.

    Defined in: C:/WORK/WSHELPER/GETHNA.C

    Return Value

    It will a pointer the servent structure filled with data received from the Hesiod server or it will return the result of the Winsock getservbyname function.

    Parameters

    name
    a pointer to the service name to look up.
    proto
    which protcol do you want for the service (UDP or TCP)?

    rrhost

    EXPORT32 DWORD EXPORT WINAPI rrhost(LPSTR lpHost)

    This function emulates the rhost function that was part of Excelan / Novell's LAN WorkPlace TCP/IP API. Given a pointer to an IP hostname it will return the IP address as a 32 bit integer.

    Defined in: C:/WORK/WSHELPER/GETHNA.C

    Return Value

    0 or the IP address as a 32 bit integer.

    Parameters

    lpHost
    a pointer to the hostname.

    WhichOS

    EXPORT32 DWORD EXPORT WhichOS(DWORD * check)

    This function will attempt to determine which Operating System and subsystem is being used by the application. It should function under Win16, Windows NT amd Windows 95 at least. It does call WSAStartup() and WSACleanup(). This function does have side effects on some global variables. See the comments below.

    Defined in: C:/WORK/WSHELPER/RES_INIT.C

    Return Value

    a NULL will indicate that we could not determine what OS is being used. The high word contains:

    MS_OS_WIN (1)
    The application is running under Windows or WFWG

    MS_OS_95\tab (2)
    The application is running under Microsoft Windows 95

    MS_OS_NT\tab (3)
    The application is running under Microsoft NT

    MS_OS_UNKNOWN (0)
    It looks like Windows but not any version that we know of.


    these are defined in mitwhich.h
    The low word contains one of the following, which is derived from the winsock implementation:

    MS_NT_32 (1)
    The MS 32 bit Winsock stack for NT is being used

    MS_NT_16 (2)
    The MS 16 bit Winsock stack under NT is being used

    MS_95_32 (3)
    The MS 32 bit Winsock stack under 95 is being used

    MS_95_16 (4)
    The MS 16 bit Winsock stack under 95 is being used

    NOVELL_LWP_16 (5)
    The Novell 16 Winsock stack is being used

    UNKNOWN_16_UNDER_32 (-2)
    We don't know the stack.

    UNKNOWN_16_UNDER_16 (-3)
    We don't know the stack.

    UNKNOWN_32_UNDER_32 (-4)
    We don't know the stack.

    UNKNOWN_32_UNDER_16 (-5)
    We don't know the stack.

    Parameters

    check
    a pointer to a DWORD, a value indicating which operating system and/or subsystem is being used will be stored in this parameter upon return.

    WSHGetHostID

    EXPORT32 LONG FAR EXPORT WSHGetHostID(void)

    Get the local IP address using the following algorithm:
    get local host name with gethostname()
    attempt to resolve local host name with gethostbyname()
    If it fails:
    get a UDP socket
    connect UDP socket to aribitrary address and port
    use getsockname() to get local address

    Defined in: C:/WORK/WSHELPER/GETHNA.C

    Comments

    This function code was borrowed from the book, "Windows Sockets Network Programming" by Bob Quinn and Dave Shute, Copyright 1996 Addision-Welsley Publishing Company, Inc., ISBN 0-201-63372-8


    _res structure

    struct {
    	 RES_TIMEOUT;
    	 4;
    	 RES_DEFAULT;
    	 1;
    } _res;
    
    a structure of this type holds the state information for the resolver options

    Defined in: C:/WORK/WSHELPER/RES_INIT.C

    Members

    RES_TIMEOUT
    retransmition time interval
    4
    number of times to retransmit
    RES_DEFAULT
    options flags
    1
    number of name servers

    nsmsg_t structure

    struct {
    	int len;
    	int ns_off;
    	int ar_off;
    	int count;
    	HEADER far * hd;
    	rr_t rr;
    } nsmsg_t;
    
    name server message structure

    Defined in: C:/WORK/WSHELPER/RESSCAN.H

    Members

    len
    sizeof(msg)
    ns_off
    offset to name server RRs
    ar_off
    offset to additional RRs
    count
    total number of RRs
    hd
    message header
    rr
    vector of (stripped-down) RR descriptors

    retransXretry structure

    struct {
    	short retrans;
    	short retry;
    } retransXretry;
    
    holds the retransmit and retry values

    Defined in: C:/WORK/WSHELPER/RESSCAN.H

    Members

    retrans
    retransmit count
    retry
    retry count

    rr_t structure

    struct {
    	short type;
    	short class;
    	int dlen;
    	LPSTR data;
    } rr_t;
    
    This structure is used by the resolve code

    Defined in: C:/WORK/WSHELPER/RESSCAN.H

    Members

    type
    RR type
    class
    RR class
    dlen
    len of data section
    data
    pointer to data