ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/evdns.c
(Generate patch)

Comparing libev/evdns.c (file contents):
Revision 1.2 by root, Thu Nov 1 17:29:19 2007 UTC vs.
Revision 1.5 by root, Sat Nov 3 09:19:58 2007 UTC

1#define DNS_USE_GETTIMEOFDAY_FOR_ID 1 1#define DNS_USE_GETTIMEOFDAY_FOR_ID 1
2/* $Id: evdns.c,v 1.2 2007/11/01 17:29:19 root Exp $ */ 2#define HAVE_STRUCT_IN6_ADDR 1
3 3
4/* The original version of this module was written by Adam Langley; for 4/* The original version of this module was written by Adam Langley; for
5 * a history of modifications, check out the subversion logs. 5 * a history of modifications, check out the subversion logs.
6 * 6 *
7 * When editing this module, try to keep it re-mergeable by Adam. Don't 7 * When editing this module, try to keep it re-mergeable by Adam. Don't
39#ifdef HAVE_CONFIG_H 39#ifdef HAVE_CONFIG_H
40#include "config.h" 40#include "config.h"
41#endif 41#endif
42 42
43#ifdef WIN32 43#ifdef WIN32
44#include "misc.h"
45#endif 44#endif
46 45
47/* #define NDEBUG */ 46/* #define NDEBUG */
48 47
49#ifndef DNS_USE_CPU_CLOCK_FOR_ID 48#ifndef DNS_USE_CPU_CLOCK_FOR_ID
174 char request_appended; /* true if the request pointer is data which follows this struct */ 173 char request_appended; /* true if the request pointer is data which follows this struct */
175 char transmit_me; /* needs to be transmitted */ 174 char transmit_me; /* needs to be transmitted */
176}; 175};
177 176
178#ifndef HAVE_STRUCT_IN6_ADDR 177#ifndef HAVE_STRUCT_IN6_ADDR
179struct xin6_addr { 178struct in6_addr {
180 u8 s6_addr[16]; 179 u8 s6_addr[16];
181}; 180};
182#endif 181#endif
183 182
184struct reply { 183struct reply {
189 u32 addrcount; 188 u32 addrcount;
190 u32 addresses[MAX_ADDRS]; 189 u32 addresses[MAX_ADDRS];
191 } a; 190 } a;
192 struct { 191 struct {
193 u32 addrcount; 192 u32 addrcount;
194 struct xin6_addr addresses[MAX_ADDRS]; 193 struct in6_addr addresses[MAX_ADDRS];
195 } aaaa; 194 } aaaa;
196 struct { 195 struct {
197 char name[HOST_NAME_MAX]; 196 char name[HOST_NAME_MAX];
198 } ptr; 197 } ptr;
199 } data; 198 } data;
2264 if (!req) return 1; 2263 if (!req) return 1;
2265 request_submit(req); 2264 request_submit(req);
2266 return 0; 2265 return 0;
2267} 2266}
2268 2267
2269int evdns_resolve_reverse_ipv6(struct xin6_addr *in, int flags, evdns_callback_type callback, void *ptr) { 2268int evdns_resolve_reverse_ipv6(struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr) {
2270 char buf[64]; 2269 char buf[96];
2271 char *cp; 2270 char *cp;
2272 struct request *req; 2271 struct request *req;
2273 int i; 2272 int i;
2274 assert(in); 2273 assert(in);
2275 cp = buf; 2274 cp = buf;
2543 /* if the file isn't found then we assume a local resolver */ 2542 /* if the file isn't found then we assume a local resolver */
2544 if (flags & DNS_OPTION_SEARCH) search_set_from_hostname(); 2543 if (flags & DNS_OPTION_SEARCH) search_set_from_hostname();
2545 if (flags & DNS_OPTION_NAMESERVERS) evdns_nameserver_ip_add("127.0.0.1"); 2544 if (flags & DNS_OPTION_NAMESERVERS) evdns_nameserver_ip_add("127.0.0.1");
2546} 2545}
2547 2546
2547#ifndef HAVE_STRTOK_R
2548static char *
2549fake_strtok_r(char *s, const char *delim, char **state) {
2550 return strtok(s, delim);
2551}
2552#endif
2548 2553
2549/* helper version of atoi which returns -1 on error */ 2554/* helper version of atoi which returns -1 on error */
2550static int 2555static int
2551strtoint(const char *const str) { 2556strtoint(const char *const str) {
2552 char *endptr; 2557 char *endptr;
2615 2620
2616static void 2621static void
2617resolv_conf_parse_line(char *const start, int flags) { 2622resolv_conf_parse_line(char *const start, int flags) {
2618 char *strtok_state; 2623 char *strtok_state;
2619 static const char *const delims = " \t"; 2624 static const char *const delims = " \t";
2620#define NEXT_TOKEN strtok(NULL, delims, &strtok_state) 2625#define NEXT_TOKEN fake_strtok_r(NULL, delims, &strtok_state)
2621 2626
2622 char *const first_token = strtok(start, delims, &strtok_state); 2627 char *const first_token = fake_strtok_r(start, delims, &strtok_state);
2623 if (!first_token) return; 2628 if (!first_token) return;
2624 2629
2625 if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) { 2630 if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) {
2626 const char *const nameserver = NEXT_TOKEN; 2631 const char *const nameserver = NEXT_TOKEN;
2627 struct in_addr ina; 2632 struct in_addr ina;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines