Contiki 3.x
resolv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2003, Adam Dunkels.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote
14  * products derived from this software without specific prior
15  * written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * This file is part of the uIP TCP/IP stack.
30  *
31  *
32  */
33 
34 /**
35  * \file
36  * uIP DNS resolver code header file.
37  * \author Adam Dunkels <adam@dunkels.com>
38  */
39 
40 #ifndef RESOLV_H_
41 #define RESOLV_H_
42 
43 #include "contiki.h"
44 #include "uip.h"
45 
46 /** If RESOLV_CONF_SUPPORTS_MDNS is set, then queries
47  * for domain names in the `local` TLD will use MDNS and
48  * will respond to MDNS queries for this device's hostname,
49  * as described by draft-cheshire-dnsext-multicastdns.
50  */
51 #ifndef RESOLV_CONF_SUPPORTS_MDNS
52 #define RESOLV_CONF_SUPPORTS_MDNS (1)
53 #endif
54 
55 /**
56  * Event that is broadcasted when a DNS name has been resolved.
57  */
58 CCIF extern process_event_t resolv_event_found;
59 
60 /* Functions. */
61 CCIF void resolv_conf(const uip_ipaddr_t * dnsserver);
62 
63 CCIF uip_ipaddr_t *resolv_getserver(void);
64 
65 enum {
66  /** Hostname is fresh and usable. This response is cached and will eventually
67  * expire to RESOLV_STATUS_EXPIRED.*/
69 
70  /** Hostname was not found in the cache. Use resolv_query() to look it up. */
72 
73  /** Hostname was found, but it's status has expired. The address returned
74  * should not be used. Use resolv_query() to freshen it up.
75  */
77 
78  /** The server has returned a not-found response for this domain name.
79  * This response is cached for the period described in the server.
80  * You may issue a new query at any time using resolv_query(), but
81  * you will generally want to wait until this domain's status becomes
82  * RESOLV_STATUS_EXPIRED.
83  */
85 
86  /** This hostname is in the process of being resolved. Try again soon. */
88 
89  /** Some sort of server error was encountered while trying to look up this
90  * record. This response is cached and will eventually expire to
91  * RESOLV_STATUS_EXPIRED.
92  */
94 };
95 
96 typedef uint8_t resolv_status_t;
97 
98 CCIF resolv_status_t resolv_lookup(const char *name, uip_ipaddr_t ** ipaddr);
99 
100 CCIF void resolv_query(const char *name);
101 
102 #if RESOLV_CONF_SUPPORTS_MDNS
103 CCIF void resolv_set_hostname(const char *hostname);
104 
105 CCIF const char *resolv_get_hostname(void);
106 #endif
107 
108 PROCESS_NAME(resolv_process);
109 
110 #endif /* RESOLV_H_ */
Hostname was not found in the cache.
Definition: resolv.h:71
Hostname is fresh and usable.
Definition: resolv.h:68
Header file for the uIP TCP/IP stack.
#define PROCESS_NAME(name)
Declare the name of a process.
Definition: process.h:286
This hostname is in the process of being resolved.
Definition: resolv.h:87
Hostname was found, but it&#39;s status has expired.
Definition: resolv.h:76
The server has returned a not-found response for this domain name.
Definition: resolv.h:84
CCIF process_event_t resolv_event_found
Event that is broadcasted when a DNS name has been resolved.
Some sort of server error was encountered while trying to look up this record.
Definition: resolv.h:93