Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

/opentcp/include/inet/dns/dns.h File Reference


Detailed Description

Author:
Version:
1.0
Date:
10.9.2002
OpenTCP DNS protocol function declarations, constants, etc.

Definition in file dns.h.

Go to the source code of this file.

Defines

#define DNS_UDP_PORT   53
#define DNS_SERVER_IP   0xac100201
#define DNS_RESEND_PERIOD   2
#define DNS_NUM_RETRIES   5
#define DNS_EVENT_ERROR   0
#define DNS_EVENT_SUCCESS   1
#define DNS_ERROR_FORMAT   1
#define DNS_ERROR_SERVER_FAILURE   2
#define DNS_ERROR_NAME_ERROR   3
#define DNS_ERROR_NOT_IMPLEMENTED   4
#define DNS_ERROR_REFUSED   5
#define DNS_ERROR_TIMEOUT   16
#define DNS_ERROR_GENERAL   17
#define DNS_ERROR_BUSY   -4
#define DNS_ERROR_LABEL   -5
#define DNS_ERROR_NAME   -6
#define DNS_ERROR_OVERFLOW   -7

Functions

UINT8 get_host_by_name (UINT8 *host_name_ptr, void(*listener)(UINT8, UINT32))
 Invokes DNS resolver.

void dns_init (void)
 Initialize resources needed for the DNS client.

void dns_run (void)
 DNS client main loop.

INT32 dns_eventlistener (INT8, UINT8, UINT32, UINT16, UINT16, UINT16)
 DNS client event listener.


Define Documentation

#define DNS_UDP_PORT   53
 

DNS client will use this port for sending and receiving of DNS packets

Definition at line 69 of file dns.h.

Referenced by dns_init(), and get_host_by_name().

#define DNS_SERVER_IP   0xac100201
 

DNS server's IP address

Definition at line 73 of file dns.h.

Referenced by get_host_by_name().

#define DNS_RESEND_PERIOD   2
 

Period in seconds for resending DNS requests

Definition at line 75 of file dns.h.

Referenced by dns_retransmit(), and get_host_by_name().

#define DNS_NUM_RETRIES   5
 

Number of retries that DNS client will perform before aborting name resolving

Definition at line 78 of file dns.h.

Referenced by get_host_by_name().

#define DNS_EVENT_ERROR   0
 

Error event reported by DNS client to event_listener

Definition at line 84 of file dns.h.

Referenced by dns_eventlistener(), and dns_retransmit().

#define DNS_EVENT_SUCCESS   1
 

Resolving successfull event reported by DNS client to event_listener

Definition at line 87 of file dns.h.

Referenced by dns_eventlistener().

#define DNS_ERROR_FORMAT   1
 

The name server was unable to interpret the query (RFC1035)

Definition at line 95 of file dns.h.

#define DNS_ERROR_SERVER_FAILURE   2
 

The name server was unable to process this query due to a problem with the name server (RFC1035)

Definition at line 98 of file dns.h.

#define DNS_ERROR_NAME_ERROR   3
 

Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist (RFC1035)

Definition at line 103 of file dns.h.

#define DNS_ERROR_NOT_IMPLEMENTED   4
 

The name server does not support the requested kind of query (RFC1035)

Definition at line 110 of file dns.h.

#define DNS_ERROR_REFUSED   5
 

The name server refuses to perform the specified operation for policy reasons. (RFC 1035)

Definition at line 114 of file dns.h.

#define DNS_ERROR_TIMEOUT   16
 

Timeout occured while DNS was trying to resolve the host name. New request should be issued if the address is needed

Definition at line 119 of file dns.h.

Referenced by dns_retransmit().

#define DNS_ERROR_GENERAL   17
 

General (not specific) error occured while resolving host name.

Definition at line 124 of file dns.h.

Referenced by dns_eventlistener().

#define DNS_ERROR_BUSY   -4
 

Returned from get_host_by_name(): DNS client is currently busy with another request and is unable the process a new one

Definition at line 135 of file dns.h.

Referenced by get_host_by_name().

#define DNS_ERROR_LABEL   -5
 

Returned from get_host_by_name(): Part of the host name (label) consists of more than 63 characters.

Definition at line 140 of file dns.h.

#define DNS_ERROR_NAME   -6
 

Returned from get_host_by_name(): Host name too long (more than 263 bytes)

Definition at line 144 of file dns.h.

#define DNS_ERROR_OVERFLOW   -7
 

net_buf too small for the entire DNS request to be stored in it.

Definition at line 147 of file dns.h.


Function Documentation

UINT8 get_host_by_name UINT8 *    host_name_ptr,
void(*    listener)(UINT8, UINT32)
 

Author:
Date:
10.10.2002
Parameters:
host_name_ptr  Pointer to null-terminated host name to be resolved
listener  Pointer to DNS listener function that listens to events from DNS client. This function takes two parameters: first one can take a value of DNS_EVENT_SUCCESS or DNS_EVENT_ERROR and thus determine the meaning of the second parameter. If first parameter is DNS_EVENT_SUCCESS, second parameter represents requested IP address. In case of DNS_EVENT_ERROR, second parameter can be one of the: DNS_ERROR_FORMAT, DNS_ERROR_SERVER_FAILURE, DNS_ERROR_NAME_ERROR, DNS_ERROR_NOT_IMPLEMENTED, DNS_ERROR_REFUSED, DNS_ERROR_TIMEOUT, DNS_ERROR_GENERAL
Returns:
  • DNS_ERROR_BUSY - Signals that DNS is currently processing another request so it is not possible to process a new one
  • DNS_ERROR_OVERFLOW - Network transmit buffer too small to hold DNS request
  • DNS_ERROR_LABEL - Label in host name longer than 63 bytes. Error
  • DNS_ERROR_NAME - Host name longer than 264 bytes. Error
Invoke this function to start name-resolving process. Note that currently DNS client can process only one request at a time and will not allow multiple requests.

Definition at line 445 of file dns.c.

References DNS_ERROR_BUSY, dns_hostptr, DNS_NUM_RETRIES, DNS_RESEND_PERIOD, dns_retries, DNS_SERVER_IP, dns_socket, dns_state, dns_timer, dns_tmp_ip, DNS_UDP_PORT, init_timer(), NETWORK_TX_BUFFER_SIZE, RESET_SYSTEM, TIMERTIC, UDP_APP_OFFSET, and udp_send().

Referenced by dns_retransmit().

void dns_init void   
 

Author:
Date:
10.10.2002
Invoke this function at startup to properly initialize DNS resources.

Definition at line 108 of file dns.c.

References dns_eventlistener(), dns_socket, dns_state, dns_timer, DNS_UDP_PORT, get_timer(), udp_getsocket(), udp_open(), UDP_OPT_CHECK_CS, and UDP_OPT_SEND_CS.

void dns_run void   
 

Author:
Date:
10.10.2002
Simple main loop that checks whether DNS requests should be sent or not (based on timer timeout). If yes, and DNS is in appropriate state, dns_retransmit() function is invoked.

Definition at line 168 of file dns.c.

References check_timer(), dns_retransmit(), dns_state, and dns_timer.

INT32 dns_eventlistener INT8    cbhandle,
UINT8    event,
UINT32    ipaddr,
UINT16    port,
UINT16    buffindex,
UINT16    datalen
 

Author:
Date:
10.10.2002
Parameters:
cbhandle  handle of the socket this packet is intended for.
event  event that is notified. For UDP, only UDP_EVENT_DATA.
ipaddr  IP address of remote host who sent the UDP datagram
port  port number of remote host who sent the UDP datagram
buffindex  buffer index in RTL8019AS
Returns:
  • - 1 - error in processing
  • 0 - DNS reply successfully processed
Note:
  • Event listeners are NOT to be invoked directly. They are callback functions invoked by the TCP/IP stack to notify events.
This, of course, is where responses from DNS server are processed and checked whether they contain the IP address we requested or if they contain authorative name server to which we should proceed.

If we received the IP address we requested, DNS_EVENT_SUCCESS is reported to application DNS event listener. Otherwise DNS_EVENT_ERROR is reported.

Definition at line 205 of file dns.c.

References DNS_ERROR_GENERAL, DNS_EVENT_ERROR, DNS_EVENT_SUCCESS, dns_hostptr, dns_retransmit(), dns_socket, dns_state, dns_tmp_ip, RECEIVE_NETWORK_B, and UDP_EVENT_DATA.

Referenced by dns_init().


Generated on Sun Aug 3 20:33:00 2003 for OpenTCP by doxygen1.2.18