| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: evdns.3,v 1.4 2009/04/28 03:11:45 reed Exp $ | | 1 | .\" $NetBSD: evdns.3,v 1.5 2009/04/28 07:51:59 wiz Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2006 Niels Provos <provos@citi.umich.edu> | | 3 | .\" Copyright (c) 2006 Niels Provos <provos@citi.umich.edu> |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" Redistribution and use in source and binary forms, with or without | | 6 | .\" Redistribution and use in source and binary forms, with or without |
7 | .\" modification, are permitted provided that the following conditions | | 7 | .\" modification, are permitted provided that the following conditions |
8 | .\" are met: | | 8 | .\" are met: |
9 | .\" | | 9 | .\" |
10 | .\" 1. Redistributions of source code must retain the above copyright | | 10 | .\" 1. Redistributions of source code must retain the above copyright |
11 | .\" notice, this list of conditions and the following disclaimer. | | 11 | .\" notice, this list of conditions and the following disclaimer. |
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 12 | .\" 2. Redistributions in binary form must reproduce the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer in the | | 13 | .\" notice, this list of conditions and the following disclaimer in the |
14 | .\" documentation and/or other materials provided with the distribution. | | 14 | .\" documentation and/or other materials provided with the distribution. |
| @@ -92,27 +92,27 @@ can do the job for you with the modern a | | | @@ -92,27 +92,27 @@ can do the job for you with the modern a |
92 | Otherwise, please continue. | | 92 | Otherwise, please continue. |
93 | .Pp | | 93 | .Pp |
94 | This code is based on libevent and you must call | | 94 | This code is based on libevent and you must call |
95 | .Fn event_init | | 95 | .Fn event_init |
96 | before | | 96 | before |
97 | any of the APIs in this file. | | 97 | any of the APIs in this file. |
98 | You must also seed the OpenSSL random | | 98 | You must also seed the OpenSSL random |
99 | source if you are using OpenSSL for ids (see below). | | 99 | source if you are using OpenSSL for ids (see below). |
100 | .Pp | | 100 | .Pp |
101 | This library is designed to be included and shipped with your source | | 101 | This library is designed to be included and shipped with your source |
102 | code. | | 102 | code. |
103 | You statically link with it. | | 103 | You statically link with it. |
104 | You should also test for the existence of | | 104 | You should also test for the existence of |
105 | .Dv strtok_r | | 105 | .Xr strtok_r 3 |
106 | and define | | 106 | and define |
107 | .Dv HAVE_STRTOK_R | | 107 | .Dv HAVE_STRTOK_R |
108 | if you have it. | | 108 | if you have it. |
109 | .Pp | | 109 | .Pp |
110 | The DNS protocol requires a good source of id numbers and these | | 110 | The DNS protocol requires a good source of id numbers and these |
111 | numbers should be unpredictable for spoofing reasons. | | 111 | numbers should be unpredictable for spoofing reasons. |
112 | There are three methods for generating them here and you must define | | 112 | There are three methods for generating them here and you must define |
113 | exactly one of them. | | 113 | exactly one of them. |
114 | In increasing order of preference: | | 114 | In increasing order of preference: |
115 | .Pp | | 115 | .Pp |
116 | .Bl -tag -width "DNS_USE_GETTIMEOFDAY_FOR_ID" -compact -offset indent | | 116 | .Bl -tag -width "DNS_USE_GETTIMEOFDAY_FOR_ID" -compact -offset indent |
117 | .It Dv DNS_USE_GETTIMEOFDAY_FOR_ID | | 117 | .It Dv DNS_USE_GETTIMEOFDAY_FOR_ID |
118 | Using the bottom 16 bits of the usec result from gettimeofday. | | 118 | Using the bottom 16 bits of the usec result from gettimeofday. |
| @@ -136,27 +136,27 @@ Otherwise it will round robin between th | | | @@ -136,27 +136,27 @@ Otherwise it will round robin between th |
136 | .Pp | | 136 | .Pp |
137 | Quick start guide: | | 137 | Quick start guide: |
138 | .Bd -literal | | 138 | .Bd -literal |
139 | #include \*[Lt]evdns.h\*[Gt] | | 139 | #include \*[Lt]evdns.h\*[Gt] |
140 | void callback(int result, char type, int count, int ttl, | | 140 | void callback(int result, char type, int count, int ttl, |
141 | void *addresses, void *arg); | | 141 | void *addresses, void *arg); |
142 | | | 142 | |
143 | evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf"); | | 143 | evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf"); |
144 | evdns_resolve("www.hostname.com", 0, callback, NULL); | | 144 | evdns_resolve("www.hostname.com", 0, callback, NULL); |
145 | .Ed | | 145 | .Ed |
146 | .Pp | | 146 | .Pp |
147 | When the lookup is complete the callback function is called. | | 147 | When the lookup is complete the callback function is called. |
148 | The first argument will be one of the DNS_ERR_* defines in evdns.h. | | 148 | The first argument will be one of the DNS_ERR_* defines in evdns.h. |
149 | Hopefully it will be | | 149 | Hopefully it will be |
150 | .Dv DNS_ERR_NONE , | | 150 | .Dv DNS_ERR_NONE , |
151 | in which case type will be | | 151 | in which case type will be |
152 | .Dv DNS_IPv4_A , | | 152 | .Dv DNS_IPv4_A , |
153 | count will be the number of IP addresses, ttl is the time | | 153 | count will be the number of IP addresses, ttl is the time |
154 | which the data can be cached for (in seconds), addresses will point | | 154 | which the data can be cached for (in seconds), addresses will point |
155 | to an array of uint32_t's and arg will be whatever you passed to | | 155 | to an array of uint32_t's and arg will be whatever you passed to |
156 | .Fn evdns_resolve . | | 156 | .Fn evdns_resolve . |
157 | .Pp | | 157 | .Pp |
158 | Searching: | | 158 | Searching: |
159 | .Pp | | 159 | .Pp |
160 | In order for this library to be a good replacement for glibc's resolver it | | 160 | In order for this library to be a good replacement for glibc's resolver it |
161 | supports searching. | | 161 | supports searching. |
162 | This involves setting a list of default domains, in which names | | 162 | This involves setting a list of default domains, in which names |