Imported Upstream version 1.12.0
[platform/upstream/c-ares.git] / ares_get_servers.3
1 .\"
2 .\" Copyright 1998 by the Massachusetts Institute of Technology.
3 .\" Copyright (C) 2008-2010 by Daniel Stenberg
4 .\"
5 .\" Permission to use, copy, modify, and distribute this
6 .\" software and its documentation for any purpose and without
7 .\" fee is hereby granted, provided that the above copyright
8 .\" notice appear in all copies and that both that copyright
9 .\" notice and this permission notice appear in supporting
10 .\" documentation, and that the name of M.I.T. not be used in
11 .\" advertising or publicity pertaining to distribution of the
12 .\" software without specific, written prior permission.
13 .\" M.I.T. makes no representations about the suitability of
14 .\" this software for any purpose.  It is provided "as is"
15 .\" without express or implied warranty.
16 .\"
17 .TH ARES_GET_SERVERS 3 "5 March 2010"
18 .SH NAME
19 ares_get_servers, ares_get_servers_ports \- Retrieve name servers from an initialized ares_channel
20 .SH SYNOPSIS
21 .nf
22 .B #include <ares.h>
23 .PP
24 .B int ares_get_servers(ares_channel \fIchannel\fP, struct ares_addr_node **\fIservers\fP)
25 .B int ares_get_servers_ports(ares_channel \fIchannel\fP, struct ares_addr_port_node **\fIservers\fP)
26 .fi
27 .SH DESCRIPTION
28 The \fBares_get_servers(3)\fP function retrieves name servers configuration
29 from the
30 channel data identified by
31 .IR channel ,
32 as a linked list of ares_addr_node structs storing a pointer to the first
33 node at the address specified by
34 .IR servers .
35
36 The \fBares_get_servers_ports(3)\fP function also retrieves any per-server
37 port information that may have been previously configured, returning a linked
38 list of ares_addr_port structures.
39
40 Function caller may traverse the returned name server linked list, or may use
41 it directly as suitable input for the \fBares_set_servers(3)\fP /
42 \fBares_set_servers_ports(3)\fP functions, but
43 shall not shrink or extend the list on its own.
44
45 Each node of the name server linked list is stored in memory dynamically
46 allocated and managed by c-ares. It is the caller's responsibility to free
47 the resulting linked list, using \fBares_free_data(3)\fP , once the caller
48 does not need it any longer.
49
50 This function is capable of handling IPv4 and IPv6 name server
51 addresses simultaneously, rendering \fBares_save_options(3)\fP with
52 optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
53 IPv4-only name server usage.
54
55 .SH RETURN VALUES
56 This function may return any of the following values:
57 .TP 15
58 .B ARES_SUCCESS
59 The name servers configuration was successfully retrieved
60 .TP 15
61 .B ARES_ENOMEM
62 The memory was exhausted
63 .TP 15
64 .B ARES_ENODATA
65 The channel data identified by
66 .IR channel
67 was invalid.
68 .SH SEE ALSO
69 .BR ares_set_servers (3),
70 .BR ares_init_options (3),
71 .BR ares_save_options(3)
72 .SH AVAILABILITY
73 \fBares_get_servers(3)\fP was added in c-ares 1.7.1;
74 \fBares_get_servers_ports(3)\fP was added in c-ares 1.11.0.
75 .SH AUTHOR
76 Implementation of this function and associated library internals are based
77 on code, comments and feedback provided in November and December of 2008 by
78 Daniel Stenberg, Gregor Jasny, Phil Blundell and Yang Tse, December 2009
79 by Cedric Bail, February 2010 by Jakub Hrozek. On March 2010 Yang Tse
80 shuffled all the bits and this function popped out.
81 .br
82 Copyright 1998 by the Massachusetts Institute of Technology.
83 .br
84 Copyright (C) 2008-2010 by Daniel Stenberg