Compresses a domain name.
Standard C Library (libc.a)
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
int dn_comp (ExpDomNam, CompDomNam, Length, DomNamPtr, LastDomNamPtr)
u_char * ExpDomNam, * CompDomNam;
int Length;
u_char ** DomNamPtr, ** LastDomNamPtr;
The dn_comp subroutine compresses a domain name to conserve space. When compressing names, the client process must keep a record of suffixes that have appeared previously. The dn_comp subroutine compresses a full domain name by comparing suffixes to a list of previously used suffixes and removing the longest possible suffix.
The dn_comp subroutine compresses the domain name pointed to by the ExpDomNam parameter and stores it in the area pointed to by the CompDomNam parameter. The dn_comp subroutine inserts labels into the message as the name is compressed. The dn_comp subroutine also maintains a list of pointers to the message labels and updates the list of label pointers.
The dn_comp subroutine is one of a set of subroutines that form the resolver. The resolver is a set of functions that perform a translation between domain names and network addresses. Global information used by the resolver subroutines resides in the _res data structure. The /usr/include/resolv.h file contains the _res data structure definition.
All applications containing the dn_comp subroutine must be compiled with the _BSD macro set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.
Item | Description |
---|---|
ExpDomNam | Specifies the address of an expanded domain name. |
CompDomNam | Points to an array containing the compressed domain name. |
Length | Specifies the size of the array pointed to by the CompDomNam parameter. |
DomNamPtr | Specifies a list of pointers to previously compressed names in the current message. |
LastDomNamPtr | Points to the end of the array specified to by the CompDomNam parameter. |
Upon successful completion, the dn_comp subroutine returns the size of the compressed domain name.
If unsuccessful, the dn_comp subroutine returns a value of -1 to the calling program.
Item | Description |
---|---|
/usr/include/resolv.h | Contains global information used by the resolver subroutines. |