Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

ares_gethostbyaddr.c File Reference

#include "ares_private.h"

Include dependency graph for ares_gethostbyaddr.c:

Go to the source code of this file.

Data Structures

struct  addr_query

Defines

#define htons   HTONS
#define htonl   HTONL

Functions

int sprintf (char *str, const char *format,...)
void next_lookup (struct addr_query *aquery)
void addr_callback (void *arg, int status, unsigned char *abuf, int alen)
void end_aquery (struct addr_query *aquery, int status, struct hostent *host)
void ares_gethostbyaddr (ares_channel channel, const void *addr, int addrlen, int family, ares_host_callback callback, void *arg)


Define Documentation

#define htonl   HTONL
 

Definition at line 26 of file ares_gethostbyaddr.c.

Referenced by dhcp_bind(), dhcp_create_request(), dhcp_handle_ack(), dhcp_handle_offer(), inet_aton(), init_by_defaults(), main(), and sock_udpclient().

#define htons   HTONS
 

Definition at line 25 of file ares_gethostbyaddr.c.

Referenced by arp_arp_input(), arp_query(), chksum(), etharp_arp_input(), etharp_output(), etharp_query(), icmp_input(), inet_chksum_pseudo(), init_by_defaults(), ip_frag(), ip_input(), ip_output_if(), ip_reass(), lwip_accept(), lwip_chksum(), lwip_getpeername(), lwip_getsockname(), lwip_recvfrom(), main(), rt_3c905cif_input(), rt_rtl8139if_input(), rtl_3COM905C_start_up_device(), sock_udpclient(), and update_arp_entry().


Function Documentation

void addr_callback void *  arg,
int  status,
unsigned char *  abuf,
int  alen
[static]
 

Definition at line 101 of file ares_gethostbyaddr.c.

References AF_INET, ARES_EDESTRUCTION, ares_parse_ptr_reply(), ARES_SUCCESS, end_aquery(), next_lookup(), NULL, and status.

Referenced by next_lookup().

00102 {
00103   struct addr_query *aquery = (struct addr_query *) arg;
00104   struct hostent *host;
00105 
00106   if (status == ARES_SUCCESS)
00107     {
00108       status = ares_parse_ptr_reply(abuf, alen, &aquery->addr,
00109                                     sizeof(struct in_addr), AF_INET, &host);
00110       end_aquery(aquery, status, host);
00111     }
00112   else if (status == ARES_EDESTRUCTION)
00113     end_aquery(aquery, status, NULL);
00114   else
00115     next_lookup(aquery);
00116 }

Here is the call graph for this function:

void ares_gethostbyaddr ares_channel  channel,
const void *  addr,
int  addrlen,
int  family,
ares_host_callback  callback,
void *  arg
 

Definition at line 46 of file ares_gethostbyaddr.c.

References AF_INET, ares_channel, ARES_ENOMEM, ARES_ENOTIMP, ares_host_callback, callback(), ares_channeldata::lookups, malloc, next_lookup(), and NULL.

Referenced by dns_client(), and gethostbynameaddr().

00048 {
00049   struct addr_query *aquery;
00050 
00051   if (family != AF_INET || addrlen != sizeof(struct in_addr))
00052     {
00053       callback(arg, ARES_ENOTIMP, NULL);
00054       return;
00055     }
00056 
00057   aquery = malloc(sizeof(struct addr_query));
00058   if (!aquery)
00059     {
00060       callback(arg, ARES_ENOMEM, NULL);
00061       return;
00062     }
00063   aquery->channel = channel;
00064   memcpy(&aquery->addr, addr, sizeof(aquery->addr));
00065   aquery->callback = callback;
00066   aquery->arg = arg;
00067   aquery->remaining_lookups = channel->lookups;
00068 
00069   next_lookup(aquery);
00070 }

Here is the call graph for this function:

void end_aquery struct addr_query aquery,
int  status,
struct hostent host
[static]
 

Definition at line 118 of file ares_gethostbyaddr.c.

References ares_free_hostent(), addr_query::arg, addr_query::callback, free, and status.

Referenced by addr_callback(), and next_lookup().

00120 {
00121   aquery->callback(aquery->arg, status, host);
00122   if (host)
00123     ares_free_hostent(host);
00124   free(aquery);
00125 }

Here is the call graph for this function:

void next_lookup struct addr_query aquery  )  [static]
 

Definition at line 72 of file ares_gethostbyaddr.c.

References addr_query::addr, addr_callback(), ARES_ENOTFOUND, ares_query(), C_IN, addr_query::channel, end_aquery(), name, ntohl, NULL, addr_query::remaining_lookups, in_addr::s_addr, sprintf(), and T_PTR.

00073 {
00074   const char *p;
00075   char name[64];
00076   int a1, a2, a3, a4;
00077   unsigned long addr;
00078 
00079   for (p = aquery->remaining_lookups; *p; p++)
00080     {
00081       switch (*p)
00082         {
00083         case 'b':
00084           addr = ntohl(aquery->addr.s_addr);
00085           a1 = addr >> 24;
00086           a2 = (addr >> 16) & 0xff;
00087           a3 = (addr >> 8) & 0xff;
00088           a4 = addr & 0xff;
00089           sprintf(name, "%d.%d.%d.%d.in-addr.arpa", a4, a3, a2, a1);
00090           aquery->remaining_lookups = p + 1;
00091           ares_query(aquery->channel, name, C_IN, T_PTR, addr_callback,
00092                      aquery);
00093           return;
00094         case 'f':
00095           break;
00096         }
00097     }
00098   end_aquery(aquery, ARES_ENOTFOUND, NULL);
00099 }

Here is the call graph for this function:

int sprintf char *  str,
const char *  format,
... 
 

Referenced by main(), and next_lookup().


Generated on Wed Jan 14 12:59:00 2004 for RTL-lwIP-0.4 by doxygen 1.3.4