Contiki-NG
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 extern process_event_t resolv_event_found;
59 
60 enum {
61  /** Hostname is fresh and usable. This response is cached and will eventually
62  * expire to RESOLV_STATUS_EXPIRED.*/
64 
65  /** Hostname was not found in the cache. Use resolv_query() to look it up. */
67 
68  /** Hostname was found, but it's status has expired. The address returned
69  * should not be used. Use resolv_query() to freshen it up.
70  */
72 
73  /** The server has returned a not-found response for this domain name.
74  * This response is cached for the period described in the server.
75  * You may issue a new query at any time using resolv_query(), but
76  * you will generally want to wait until this domain's status becomes
77  * RESOLV_STATUS_EXPIRED.
78  */
80 
81  /** This hostname is in the process of being resolved. Try again soon. */
83 
84  /** Some sort of server error was encountered while trying to look up this
85  * record. This response is cached and will eventually expire to
86  * RESOLV_STATUS_EXPIRED.
87  */
89 };
90 
91 typedef uint8_t resolv_status_t;
92 
93 /* Functions. */
94 resolv_status_t resolv_lookup(const char *name, uip_ipaddr_t ** ipaddr);
95 
96 void resolv_query(const char *name);
97 
98 #if RESOLV_CONF_SUPPORTS_MDNS
99 void resolv_set_hostname(const char *hostname);
100 
101 const char *resolv_get_hostname(void);
102 #endif
103 
104 PROCESS_NAME(resolv_process);
105 
106 #endif /* RESOLV_H_ */
process_event_t resolv_event_found
Event that is broadcasted when a DNS name has been resolved.
Definition: resolv.c:241
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition: uip-nd6.c:116
Hostname was not found in the cache.
Definition: resolv.h:66
void resolv_set_hostname(const char *hostname)
Changes the local hostname advertised by MDNS.
Definition: resolv.c:1022
resolv_status_t resolv_lookup(const char *name, uip_ipaddr_t **ipaddr)
Look up a hostname in the array of known hostnames.
Definition: resolv.c:1277
Hostname is fresh and usable.
Definition: resolv.h:63
#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:82
Some sort of server error was encountered while trying to look up this record.
Definition: resolv.h:88
Hostname was found, but it&#39;s status has expired.
Definition: resolv.h:71
Header file for the uIP TCP/IP stack.
const char * resolv_get_hostname(void)
Returns the local hostname being advertised via MDNS.
Definition: resolv.c:1042
The server has returned a not-found response for this domain name.
Definition: resolv.h:79
void resolv_query(const char *name)
Queues a name so that a question for the name will be sent out.
Definition: resolv.c:1198