]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
f7deaa1a | 2 | * "$Id: http-private.h 6187 2007-01-10 16:20:42Z mike $" |
ef416fc2 | 3 | * |
4 | * Private HTTP definitions for the Common UNIX Printing System (CUPS). | |
5 | * | |
b86bc4cf | 6 | * Copyright 1997-2007 by Easy Software Products, all rights reserved. |
ef416fc2 | 7 | * |
8 | * These coded instructions, statements, and computer programs are the | |
9 | * property of Easy Software Products and are protected by Federal | |
10 | * copyright law. Distribution and use rights are outlined in the file | |
11 | * "LICENSE.txt" which should have been included with this file. If this | |
12 | * file is missing or damaged please contact Easy Software Products | |
13 | * at: | |
14 | * | |
15 | * Attn: CUPS Licensing Information | |
16 | * Easy Software Products | |
17 | * 44141 Airport View Drive, Suite 204 | |
18 | * Hollywood, Maryland 20636 USA | |
19 | * | |
20 | * Voice: (301) 373-9600 | |
21 | * EMail: cups-info@cups.org | |
22 | * WWW: http://www.cups.org | |
23 | * | |
24 | * This file is subject to the Apple OS-Developed Software exception. | |
25 | */ | |
26 | ||
27 | #ifndef _CUPS_HTTP_PRIVATE_H_ | |
28 | # define _CUPS_HTTP_PRIVATE_H_ | |
29 | ||
30 | /* | |
31 | * Include necessary headers... | |
32 | */ | |
33 | ||
a74454a7 | 34 | # include <stdlib.h> |
35 | # include <config.h> | |
ef416fc2 | 36 | |
37 | # ifdef __sun | |
38 | /* | |
39 | * Define FD_SETSIZE to CUPS_MAX_FDS on Solaris to get the correct version of | |
40 | * select() for large numbers of file descriptors. | |
41 | */ | |
42 | ||
43 | # define FD_SETSIZE CUPS_MAX_FDS | |
44 | # include <sys/select.h> | |
45 | # endif /* __sun */ | |
46 | ||
47 | # include <limits.h> | |
48 | # ifdef WIN32 | |
49 | # include <io.h> | |
50 | # include <winsock2.h> | |
51 | # else | |
52 | # include <unistd.h> | |
53 | # include <fcntl.h> | |
54 | # include <sys/socket.h> | |
55 | # define closesocket(f) close(f) | |
56 | # endif /* WIN32 */ | |
57 | ||
f7deaa1a | 58 | # ifdef HAVE_GSSAPI |
59 | # ifdef HAVE_GSSAPI_GSSAPI_H | |
60 | # include <gssapi/gssapi.h> | |
61 | # endif /* HAVE_GSSAPI_GSSAPI_H */ | |
62 | # ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H | |
63 | # include <gssapi/gssapi_generic.h> | |
64 | # endif /* HAVE_GSSAPI_GSSAPI_GENERIC_H */ | |
65 | # ifdef HAVE_GSSAPI_GSSAPI_KRB5_H | |
66 | # include <gssapi/gssapi_krb5.h> | |
67 | # endif /* HAVE_GSSAPI_GSSAPI_KRB5_H */ | |
68 | # ifdef HAVE_GSSAPI_H | |
69 | # include <gssapi.h> | |
70 | # endif /* HAVE_GSSAPI_H */ | |
71 | # ifndef HAVE_GSS_C_NT_HOSTBASED_SERVICE | |
72 | # define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name | |
73 | # endif /* !HAVE_GSS_C_NT_HOSTBASED_SERVICE */ | |
74 | # endif /* HAVE_GSSAPI */ | |
75 | ||
4400e98d | 76 | # if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T)) |
ef416fc2 | 77 | /* |
4400e98d | 78 | * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of |
ef416fc2 | 79 | * unsigned type for length values... |
80 | */ | |
81 | ||
82 | typedef int socklen_t; | |
4400e98d | 83 | # endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */ |
ef416fc2 | 84 | |
85 | # include "http.h" | |
f7deaa1a | 86 | # include "md5.h" |
fa73b229 | 87 | # include "ipp-private.h" |
ef416fc2 | 88 | |
89 | # if defined HAVE_LIBSSL | |
90 | /* | |
91 | * The OpenSSL library provides its own SSL/TLS context structure for its | |
411affcf | 92 | * IO and protocol management. However, we need to provide our own BIO |
93 | * (basic IO) implementation to do timeouts... | |
ef416fc2 | 94 | */ |
95 | ||
96 | # include <openssl/err.h> | |
97 | # include <openssl/rand.h> | |
98 | # include <openssl/ssl.h> | |
99 | ||
100 | typedef SSL http_tls_t; | |
101 | ||
411affcf | 102 | extern BIO_METHOD *_httpBIOMethods(void); |
103 | ||
ef416fc2 | 104 | # elif defined HAVE_GNUTLS |
105 | /* | |
106 | * The GNU TLS library is more of a "bare metal" SSL/TLS library... | |
107 | */ | |
108 | # include <gnutls/gnutls.h> | |
109 | ||
110 | typedef struct | |
111 | { | |
112 | gnutls_session session; /* GNU TLS session object */ | |
113 | void *credentials; /* GNU TLS credentials object */ | |
114 | } http_tls_t; | |
115 | ||
411affcf | 116 | extern ssize_t _httpReadGNUTLS(gnutls_transport_ptr ptr, void *data, |
117 | size_t length); | |
118 | extern ssize_t _httpWriteGNUTLS(gnutls_transport_ptr ptr, const void *data, | |
119 | size_t length); | |
120 | ||
ef416fc2 | 121 | # elif defined(HAVE_CDSASSL) |
122 | /* | |
123 | * Darwin's Security framework provides its own SSL/TLS context structure | |
124 | * for its IO and protocol management... | |
125 | */ | |
126 | ||
127 | # include <Security/SecureTransport.h> | |
128 | ||
89d46774 | 129 | typedef struct /**** CDSA connection information ****/ |
130 | { | |
131 | SSLContextRef session; /* CDSA session object */ | |
132 | CFArrayRef certsArray; /* Certificates array */ | |
133 | } http_tls_t; | |
ef416fc2 | 134 | |
135 | extern OSStatus _httpReadCDSA(SSLConnectionRef connection, void *data, | |
136 | size_t *dataLength); | |
137 | extern OSStatus _httpWriteCDSA(SSLConnectionRef connection, const void *data, | |
138 | size_t *dataLength); | |
139 | # endif /* HAVE_LIBSSL */ | |
140 | ||
f7deaa1a | 141 | |
142 | struct _http_s /**** HTTP connection structure. ****/ | |
143 | { | |
144 | int fd; /* File descriptor for this socket */ | |
145 | int blocking; /* To block or not to block */ | |
146 | int error; /* Last error on read */ | |
147 | time_t activity; /* Time since last read/write */ | |
148 | http_state_t state; /* State of client */ | |
149 | http_status_t status; /* Status of last request */ | |
150 | http_version_t version; /* Protocol version */ | |
151 | http_keepalive_t keep_alive; /* Keep-alive supported? */ | |
152 | struct sockaddr_in _hostaddr; /* Address of connected host @deprecated@ */ | |
153 | char hostname[HTTP_MAX_HOST], | |
154 | /* Name of connected host */ | |
155 | fields[HTTP_FIELD_MAX][HTTP_MAX_VALUE]; | |
156 | /* Field values */ | |
157 | char *data; /* Pointer to data buffer */ | |
158 | http_encoding_t data_encoding; /* Chunked or not */ | |
159 | int _data_remaining;/* Number of bytes left @deprecated@ */ | |
160 | int used; /* Number of bytes used in buffer */ | |
161 | char buffer[HTTP_MAX_BUFFER]; | |
162 | /* Buffer for incoming data */ | |
163 | int auth_type; /* Authentication in use */ | |
164 | _cups_md5_state_t md5_state; /* MD5 state */ | |
165 | char nonce[HTTP_MAX_VALUE]; | |
166 | /* Nonce value */ | |
167 | int nonce_count; /* Nonce count */ | |
168 | void *tls; /* TLS state information */ | |
169 | http_encryption_t encryption; /* Encryption requirements */ | |
170 | /**** New in CUPS 1.1.19 ****/ | |
171 | fd_set *input_set; /* select() set for httpWait() @deprecated@ */ | |
172 | http_status_t expect; /* Expect: header @since CUPS 1.1.19@ */ | |
173 | char *cookie; /* Cookie value(s) @since CUPS 1.1.19@ */ | |
174 | /**** New in CUPS 1.1.20 ****/ | |
175 | char _authstring[HTTP_MAX_VALUE], | |
176 | /* Current Authentication value. @deprecated@ */ | |
177 | userpass[HTTP_MAX_VALUE]; | |
178 | /* Username:password string @since CUPS 1.1.20@ */ | |
179 | int digest_tries; /* Number of tries for digest auth @since CUPS 1.1.20@ */ | |
180 | /**** New in CUPS 1.2 ****/ | |
181 | off_t data_remaining; /* Number of bytes left @since CUPS 1.2@ */ | |
182 | http_addr_t *hostaddr; /* Current host address and port @since CUPS 1.2@ */ | |
183 | http_addrlist_t *addrlist; /* List of valid addresses @since CUPS 1.2@ */ | |
184 | char wbuffer[HTTP_MAX_BUFFER]; | |
185 | /* Buffer for outgoing data */ | |
186 | int wused; /* Write buffer bytes used @since CUPS 1.2@ */ | |
187 | /**** New in CUPS 1.3 ****/ | |
188 | char *field_authorization; | |
189 | /* Authorization field @since CUPS 1.3@ */ | |
190 | char *authstring; /* Current authorization field @since CUPS 1.3 */ | |
191 | # ifdef HAVE_GSSAPI | |
192 | gss_OID gssmech; /* Authentication mechanism @since CUPS 1.3@ */ | |
193 | gss_ctx_id_t gssctx; /* Authentication context @since CUPS 1.3@ */ | |
194 | gss_name_t gssname; /* Authentication server name @since CUPS 1.3@ */ | |
195 | # endif /* HAVE_GSSAPI */ | |
196 | }; | |
197 | ||
198 | ||
ef416fc2 | 199 | /* |
200 | * Some OS's don't have hstrerror(), most notably Solaris... | |
201 | */ | |
202 | ||
203 | # ifndef HAVE_HSTRERROR | |
204 | extern const char *_cups_hstrerror(int error); | |
205 | # define hstrerror _cups_hstrerror | |
206 | # elif defined(_AIX) || defined(__osf__) | |
207 | /* | |
208 | * AIX and Tru64 UNIX don't provide a prototype but do provide the function... | |
209 | */ | |
210 | extern const char *hstrerror(int error); | |
211 | # endif /* !HAVE_HSTRERROR */ | |
212 | ||
89d46774 | 213 | |
214 | /* | |
215 | * Some OS's don't have getifaddrs() and freeifaddrs()... | |
216 | */ | |
217 | ||
b86bc4cf | 218 | # ifndef WIN32 |
219 | # include <net/if.h> | |
220 | # ifdef HAVE_GETIFADDRS | |
221 | # include <ifaddrs.h> | |
222 | # else | |
223 | # include <sys/ioctl.h> | |
224 | # ifdef HAVE_SYS_SOCKIO_H | |
225 | # include <sys/sockio.h> | |
226 | # endif /* HAVE_SYS_SOCKIO_H */ | |
227 | ||
228 | # ifdef ifa_dstaddr | |
229 | # undef ifa_dstaddr | |
230 | # endif /* ifa_dstaddr */ | |
231 | # ifndef ifr_netmask | |
232 | # define ifr_netmask ifr_addr | |
233 | # endif /* !ifr_netmask */ | |
89d46774 | 234 | |
235 | struct ifaddrs /**** Interface Structure ****/ | |
236 | { | |
237 | struct ifaddrs *ifa_next; /* Next interface in list */ | |
238 | char *ifa_name; /* Name of interface */ | |
239 | unsigned int ifa_flags; /* Flags (up, point-to-point, etc.) */ | |
240 | struct sockaddr *ifa_addr, /* Network address */ | |
f301802f | 241 | *ifa_netmask; /* Address mask */ |
242 | union | |
243 | { | |
244 | struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */ | |
245 | struct sockaddr *ifu_dstaddr; /* Point-to-point destination address. */ | |
246 | } ifa_ifu; | |
247 | ||
89d46774 | 248 | void *ifa_data; /* Interface statistics */ |
249 | }; | |
250 | ||
b86bc4cf | 251 | # ifndef ifa_broadaddr |
252 | # define ifa_broadaddr ifa_ifu.ifu_broadaddr | |
253 | # endif /* !ifa_broadaddr */ | |
254 | # ifndef ifa_dstaddr | |
255 | # define ifa_dstaddr ifa_ifu.ifu_dstaddr | |
256 | # endif /* !ifa_dstaddr */ | |
f301802f | 257 | |
a74454a7 | 258 | extern int _cups_getifaddrs(struct ifaddrs **addrs); |
b86bc4cf | 259 | # define getifaddrs _cups_getifaddrs |
a74454a7 | 260 | extern void _cups_freeifaddrs(struct ifaddrs *addrs); |
b86bc4cf | 261 | # define freeifaddrs _cups_freeifaddrs |
262 | # endif /* HAVE_GETIFADDRS */ | |
263 | # endif /* !WIN32 */ | |
89d46774 | 264 | |
ef416fc2 | 265 | #endif /* !_CUPS_HTTP_PRIVATE_H_ */ |
266 | ||
267 | /* | |
f7deaa1a | 268 | * End of "$Id: http-private.h 6187 2007-01-10 16:20:42Z mike $". |
ef416fc2 | 269 | */ |