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