~ubuntu-branches/ubuntu/saucy/sssd/saucy

« back to all changes in this revision

Viewing changes to src/resolv/async_resolv.h

  • Committer: Stéphane Graber
  • Date: 2011-06-15 16:23:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: stgraber@ubuntu.com-20110615162314-rbhoppnpaxfqo5q7
Merge 1.5.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   SSSD
 
3
 
 
4
   Async resolver header
 
5
 
 
6
   Authors:
 
7
        Martin Nagy <mnagy@redhat.com>
 
8
        Jakub Hrozek <jhrozek@redhat.com>
 
9
 
 
10
   Copyright (C) Red Hat, Inc 2009
 
11
 
 
12
   This program is free software; you can redistribute it and/or modify
 
13
   it under the terms of the GNU General Public License as published by
 
14
   the Free Software Foundation; either version 3 of the License, or
 
15
   (at your option) any later version.
 
16
 
 
17
   This program is distributed in the hope that it will be useful,
 
18
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
   GNU General Public License for more details.
 
21
 
 
22
   You should have received a copy of the GNU General Public License
 
23
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
*/
 
25
 
 
26
#ifndef __ASYNC_RESOLV_H__
 
27
#define __ASYNC_RESOLV_H__
 
28
 
 
29
#include <netdb.h>
 
30
#include <ares.h>
 
31
 
 
32
#include "config.h"
 
33
 
 
34
#ifndef HAVE_ARES_DATA
 
35
#include "resolv/ares/ares_parse_srv_reply.h"
 
36
#include "resolv/ares/ares_parse_txt_reply.h"
 
37
#include "resolv/ares/ares_data.h"
 
38
#endif /* HAVE_ARES_DATA */
 
39
 
 
40
/*
 
41
 * An opaque structure which holds context for a module using the async
 
42
 * resolver. Is should be used as a "local-global" variable - in sssd,
 
43
 * every backend should have its own.
 
44
 
 
45
 * Do NOT free the context until there are any pending resolv_ calls
 
46
 */
 
47
struct resolv_ctx;
 
48
 
 
49
int resolv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
 
50
                int timeout, struct resolv_ctx **ctxp);
 
51
 
 
52
void resolv_reread_configuration(void);
 
53
 
 
54
const char *resolv_strerror(int ares_code);
 
55
 
 
56
struct hostent *resolv_copy_hostent(TALLOC_CTX *mem_ctx,
 
57
                                    struct hostent *src);
 
58
 
 
59
/** Get host by name **/
 
60
enum restrict_family {
 
61
    IPV4_ONLY,
 
62
    IPV4_FIRST,
 
63
    IPV6_ONLY,
 
64
    IPV6_FIRST
 
65
};
 
66
 
 
67
struct tevent_req *resolv_gethostbyname_send(TALLOC_CTX *mem_ctx,
 
68
                                            struct tevent_context *ev,
 
69
                                            struct resolv_ctx *ctx,
 
70
                                            const char *name,
 
71
                                            enum restrict_family family_order);
 
72
 
 
73
int resolv_gethostbyname_recv(struct tevent_req *req,
 
74
                              TALLOC_CTX *mem_ctx,
 
75
                              int *status,
 
76
                              int *timeouts,
 
77
                              struct hostent **hostent);
 
78
 
 
79
/** Get SRV record **/
 
80
struct tevent_req *resolv_getsrv_send(TALLOC_CTX *mem_ctx,
 
81
                                      struct tevent_context *ev,
 
82
                                      struct resolv_ctx *ctx,
 
83
                                      const char *query);
 
84
 
 
85
int resolv_getsrv_recv(TALLOC_CTX *mem_ctx,
 
86
                       struct tevent_req *req,
 
87
                       int *status,
 
88
                       int *timeouts,
 
89
                       struct ares_srv_reply **reply_list);
 
90
 
 
91
/* This is an implementation of section "Usage rules" of RFC 2782 */
 
92
int
 
93
resolv_sort_srv_reply(TALLOC_CTX *mem_ctx, struct ares_srv_reply **reply);
 
94
 
 
95
/** Get TXT record **/
 
96
struct tevent_req *resolv_gettxt_send(TALLOC_CTX *mem_ctx,
 
97
                                      struct tevent_context *ev,
 
98
                                      struct resolv_ctx *ctx,
 
99
                                      const char *query);
 
100
 
 
101
int resolv_gettxt_recv(TALLOC_CTX *mem_ctx,
 
102
                       struct tevent_req *req,
 
103
                       int *status,
 
104
                       int *timeouts,
 
105
                       struct ares_txt_reply **reply_list);
 
106
 
 
107
#endif /* __ASYNC_RESOLV_H__ */