#include "loc.h"
/* $Id: loc.c,v 1.1 2008/02/15 01:47:15 marka Exp $ */
/* Global variables */
short rr_errno;
/*
Prints the actual usage
*/
void
usage ()
{
"Usage: %s: [-v] [-d nnn] hostname\n", progname);
exit (2);
}
/*
Panics
*/
void
char *message;
{
exit (2);
}
/*
** IN_ADDR_ARPA -- Convert dotted quad string to reverse in-addr.arpa
** ------------------------------------------------------------------
**
** Returns:
** Pointer to appropriate reverse in-addr.arpa name
** with trailing dot to force absolute domain name.
** NULL in case of invalid dotted quad input string.
*/
#ifndef ARPA_ROOT
#endif
char *
char *dottedquad; /* input string with dotted quad */
{
unsigned int a[4];
register int n;
switch (n)
{
case 4:
break;
case 3:
break;
case 2:
break;
case 1:
a[0] & 0xff, ARPA_ROOT);
break;
default:
return (NULL);
}
while (--n >= 0)
if (a[n] > 255)
return (NULL);
return (addrbuf);
}
/*
Returns a human-readable version of the LOC information or
NULL if it failed. Argument is a name (of a network or a machine)
and a boolean telling is it is a network name or a machine name.
*/
char *
const char *name;
short is_network;
{
char *result;
{
if (debug >= 2)
return result;
}
else
{
if (!is_network)
{
if (debug >= 2)
{
{
if (debug >= 2)
return result;
}
return NULL;
}
else
{
if (debug >= 2)
return NULL;
}
}
else
{
if (debug >= 2)
return NULL;
}
}
}
/*
Returns a human-readable version of the LOC information or
NULL if it failed. Argument is an IP address.
*/
char *
{
u_int32_t a;
{
}
else
{
}
if (debug >= 2)
{
if (IN_CLASSA (a))
{
}
else if (IN_CLASSB (a))
{
}
else if (IN_CLASSC (a))
{
}
else
{
/* Error */
return NULL;
}
}
else
{
}
}
/*
Returns a human-readable LOC.
Argument is a network name in the 0.z.y.x.in-addr.arpa format
and the original address
*/
char *
char *name;
{
char *network;
char *result;
u_int32_t a;
if (debug >= 2)
/* Check if this network has an A RR */
{
/* Yes, it does. This A record will be used as the
* new mask for recursion if it is longer than
* the actual mask. */
{
/* compute the new arguments for recursion
* - compute the new network by applying the new mask
* to the address and get the in_addr_arpa representation
* of it.
* - the address remains unchanged
* - the new mask is the one given in the A record
*/
sizeof newname);
{
return result;
}
}
/* couldn't find a LOC. Fall through and try with name */
}
/* Check if this network has a name */
{
if (debug >= 2)
return NULL;
}
else
{
}
}
/*
The code for these two functions is stolen from the examples in Liu and Albitz
book "DNS and BIND" (O'Reilly).
*/
/****************************************************************
* skipName -- This routine skips over a domain name. If the *
* domain name expansion fails, it crashes. *
* dn_skipname() is probably not on your manual *
* page; it is similar to dn_expand() except that it just *
* skips over the name. dn_skipname() is in res_comp.c if *
* you need to find it. *
****************************************************************/
int
{
int n;
{
panic ("dn_skipname failed\n");
}
return (n);
}
/****************************************************************
* skipToData -- This routine advances the cp pointer to the *
* start of the resource record data portion. On the way, *
* it fills in the type, class, ttl, and data length *
****************************************************************/
int
{
/* Skip the domain name; it matches the name we looked up */
/*
* Grab the type, class, and ttl. GETSHORT and GETLONG
*/
}
/*
Returns a human-readable version of a DNS RR (resource record)
associated with the name 'domain'.
If it does not find, ir returns NULL and sets rr_errno to explain why.
The code for this function is stolen from the examples in Liu and Albitz
book "DNS and BIND" (O'Reilly).
*/
char *
char *domain;
int requested_type;
{
union
{
}
short found = 0;
int ptrNum = 0;
/*
* Look up the records for the given domain name.
* We expect the domain to be a fully qualified name, so
* we use res_query(). If we wanted the resolver search
* algorithm, we would have used res_search() instead.
*/
if ((responseLen =
C_IN, /* Internet class records */
requested_type, /* Look up name server records */
sizeof (response))) /*buffer size */
< 0)
{ /*If negative */
return NULL;
}
/*
* Keep track of the end of the message so we don't
* pass it while parsing the response. responseLen is
* the value returned by res_query.
*/
/*
* Set a pointer to the start of the question section,
* which begins immediately AFTER the header.
*/
/*
* Skip over the whole question section. The question
* section is comprised of a name, a type, and a class.
* the type and class portions, which is fixed. Therefore,
* we can skip the question section by skipping the
* name (at the beginning) and then advancing QFIXEDSZ.
* After this calculation, cp points to the start of the
* answer section, which is a list of NS records.
*/
while ((--count >= 0) /* still more records */
{ /* still inside the packet */
/* Skip to the data portion of the resource record */
if (type == requested_type)
{
switch (requested_type)
{
case (T_LOC):
return result;
break;
case (T_PTR):
{
panic ("Malloc failed");
}
endOfMsg, /* End of the packet */
cp, /* Position in the packet */
MAXDNAME) /* size of ptrList buffer */
< 0)
{ /* Negative: error */
panic ("dn_expand failed");
}
/*
* Check the name we've just unpacked and add it to
* the list if it is not a duplicate.
* If it is a duplicate, just ignore it.
*/
if (dup)
else
ptrNum++;
return result;
break;
case (T_A):
found = 1;
break;
default:
}
}
/* Advance the pointer over the resource record data */
} /* end of while */
if (found)
return result;
else
return NULL;
}
struct list_in_addr *
char *domain;
{
union
{
}
/*
* Look up the records for the given domain name.
* We expect the domain to be a fully qualified name, so
* we use res_query(). If we wanted the resolver search
* algorithm, we would have used res_search() instead.
*/
if ((responseLen =
C_IN, /* Internet class records */
T_A,
sizeof (response))) /*buffer size */
< 0)
{ /*If negative */
return NULL;
}
/*
* Keep track of the end of the message so we don't
* pass it while parsing the response. responseLen is
* the value returned by res_query.
*/
/*
* Set a pointer to the start of the question section,
* which begins immediately AFTER the header.
*/
/*
* Skip over the whole question section. The question
* section is comprised of a name, a type, and a class.
* the type and class portions, which is fixed. Therefore,
* we can skip the question section by skipping the
* name (at the beginning) and then advancing QFIXEDSZ.
* After this calculation, cp points to the start of the
* answer section, which is a list of NS records.
*/
while ((--count >= 0) /* still more records */
{ /* still inside the packet */
/* Skip to the data portion of the resource record */
{
{
}
else
{
}
}
/* Advance the pointer over the resource record data */
} /* end of while */
return result;
}