]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - crypto/heimdal/lib/krb5/krb5_krbhst_init.3
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / crypto / heimdal / lib / krb5 / krb5_krbhst_init.3
1 .\" Copyright (c) 2001 Kungliga Tekniska Högskolan
2 .\" (Royal Institute of Technology, Stockholm, Sweden). 
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 .\"
9 .\" 1. Redistributions of source code must retain the above copyright 
10 .\"    notice, this list of conditions and the following disclaimer. 
11 .\"
12 .\" 2. Redistributions in binary form must reproduce the above copyright 
13 .\"    notice, this list of conditions and the following disclaimer in the 
14 .\"    documentation and/or other materials provided with the distribution. 
15 .\"
16 .\" 3. Neither the name of the Institute nor the names of its contributors 
17 .\"    may be used to endorse or promote products derived from this software 
18 .\"    without specific prior written permission. 
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
30 .\" SUCH DAMAGE. 
31 .\"
32 .\" $Id: krb5_krbhst_init.3,v 1.7 2003/04/16 13:58:16 lha Exp $
33 .\"
34 .Dd June 17, 2001
35 .Dt KRB5_KRBHST_INIT 3
36 .Os HEIMDAL
37 .Sh NAME
38 .Nm krb5_krbhst_init ,
39 .Nm krb5_krbhst_next ,
40 .Nm krb5_krbhst_next_as_string ,
41 .Nm krb5_krbhst_reset ,
42 .Nm krb5_krbhst_free ,
43 .Nm krb5_krbhst_format_string ,
44 .Nm krb5_krbhst_get_addrinfo
45 .Nd lookup Kerberos KDC hosts
46 .Sh LIBRARY
47 Kerberos 5 Library (libkrb5, -lkrb5)
48 .Sh SYNOPSIS
49 .In krb5.h
50 .Ft krb5_error_code
51 .Fn krb5_krbhst_init "krb5_context context" "const char *realm" "unsigned int type" "krb5_krbhst_handle *handle"
52 .Ft krb5_error_code
53 .Fn "krb5_krbhst_next" "krb5_context context" "krb5_krbhst_handle handle" "krb5_krbhst_info **host"
54 .Ft krb5_error_code
55 .Fn krb5_krbhst_next_as_string "krb5_context context" "krb5_krbhst_handle handle" "char *hostname" "size_t hostlen"
56 .Ft void
57 .Fn krb5_krbhst_reset "krb5_context context" "krb5_krbhst_handle handle"
58 .Ft void
59 .Fn krb5_krbhst_free "krb5_context context" "krb5_krbhst_handle handle"
60 .Ft krb5_error_code
61 .Fn krb5_krbhst_format_string "krb5_context context" "const krb5_krbhst_info *host" "char *hostname" "size_t hostlen"
62 .Ft krb5_error_code
63 .Fn krb5_krbhst_get_addrinfo "krb5_context context" "krb5_krbhst_info *host" "struct addrinfo **ai"
64 .Sh DESCRIPTION
65 These functions are used to sequence through all Kerberos hosts of a
66 particular realm and service. The service type can be the KDCs, the
67 administrative servers, the password changing servers, or the servers
68 for Kerberos 4 ticket conversion.
69 .Pp
70 First a handle to a particular service is obtained by calling
71 .Fn krb5_krbhst_init
72 with the
73 .Fa realm
74 of interest and the type of service to lookup. The
75 .Fa type
76 can be one of:
77 .Pp
78 .Bl -hang -compact -offset indent
79 .It KRB5_KRBHST_KDC
80 .It KRB5_KRBHST_ADMIN
81 .It KRB5_KRBHST_CHANGEPW
82 .It KRB5_KRBHST_KRB524
83 .El
84 .Pp
85 The
86 .Fa handle
87 is returned to the caller, and should be passed to the other
88 functions.
89 .Pp
90 For each call to
91 .Fn krb5_krbhst_next
92 information a new host is returned. The former function returns in
93 .Fa host
94 a pointer to a structure containing information about the host, such
95 as protocol, hostname, and port:
96 .Bd -literal -offset indent
97 typedef struct krb5_krbhst_info {
98     enum { KRB5_KRBHST_UDP,
99            KRB5_KRBHST_TCP,
100            KRB5_KRBHST_HTTP } proto;
101     unsigned short port;
102     struct addrinfo *ai;
103     struct krb5_krbhst_info *next;
104     char hostname[1];
105 } krb5_krbhst_info;
106 .Ed
107 .Pp
108 The related function,
109 .Fn krb5_krbhst_next_as_string ,
110 return the same information as a url-like string.
111 .Pp
112 When there are no more hosts, these functions return
113 .Dv KRB5_KDC_UNREACH .
114 .Pp
115 To re-iterate over all hosts, call
116 .Fn krb5_krbhst_reset
117 and the next call to
118 .Fn krb5_krbhst_next
119 will return the first host.
120 .Pp
121 When done with the handle,
122 .Fn krb5_krbhst_free
123 should be called.
124 .Pp
125 To use a
126 .Va krb5_krbhst_info ,
127 there are two functions:
128 .Fn krb5_krbhst_format_string
129 that will return a printable representation of that struct
130 and
131 .Fn krb5_krbhst_get_addrinfo
132 that will return a
133 .Va struct addrinfo
134 that can then be used for communicating with the server mentioned.
135 .Sh EXAMPLE
136 The following code will print the KDCs of the realm
137 .Dq MY.REALM .
138 .Bd -literal -offset indent
139 krb5_krbhst_handle handle;
140 char host[MAXHOSTNAMELEN];
141 krb5_krbhst_init(context, "MY.REALM", KRB5_KRBHST_KDC, &handle);
142 while(krb5_krbhst_next_as_string(context, handle,
143                                  host, sizeof(host)) == 0)
144     printf("%s\\n", host);
145 krb5_krbhst_free(context, handle);
146 .Ed
147 .\" .Sh BUGS
148 .Sh HISTORY
149 These functions first appeared in Heimdal 0.3g.
150 .Sh SEE ALSO
151 .Xr getaddrinfo 3 ,
152 .Xr krb5_get_krbhst 3