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