]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
c07d5b2d | 2 | * "$Id: http-private.h 181 2006-06-22 20:01:18Z jlovell $" |
ef416fc2 | 3 | * |
4 | * Private HTTP definitions for the Common UNIX Printing System (CUPS). | |
5 | * | |
6 | * Copyright 1997-2005 by Easy Software Products, all rights reserved. | |
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 | ||
4400e98d | 58 | # if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T)) |
ef416fc2 | 59 | /* |
4400e98d | 60 | * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of |
ef416fc2 | 61 | * unsigned type for length values... |
62 | */ | |
63 | ||
64 | typedef int socklen_t; | |
4400e98d | 65 | # endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */ |
ef416fc2 | 66 | |
67 | # include "http.h" | |
fa73b229 | 68 | # include "ipp-private.h" |
ef416fc2 | 69 | |
70 | # if defined HAVE_LIBSSL | |
71 | /* | |
72 | * The OpenSSL library provides its own SSL/TLS context structure for its | |
73 | * IO and protocol management... | |
74 | */ | |
75 | ||
76 | # include <openssl/err.h> | |
77 | # include <openssl/rand.h> | |
78 | # include <openssl/ssl.h> | |
79 | ||
80 | typedef SSL http_tls_t; | |
81 | ||
82 | # elif defined HAVE_GNUTLS | |
83 | /* | |
84 | * The GNU TLS library is more of a "bare metal" SSL/TLS library... | |
85 | */ | |
86 | # include <gnutls/gnutls.h> | |
87 | ||
88 | typedef struct | |
89 | { | |
90 | gnutls_session session; /* GNU TLS session object */ | |
91 | void *credentials; /* GNU TLS credentials object */ | |
92 | } http_tls_t; | |
93 | ||
94 | # elif defined(HAVE_CDSASSL) | |
95 | /* | |
96 | * Darwin's Security framework provides its own SSL/TLS context structure | |
97 | * for its IO and protocol management... | |
98 | */ | |
99 | ||
100 | # include <Security/SecureTransport.h> | |
101 | ||
89d46774 | 102 | typedef struct /**** CDSA connection information ****/ |
103 | { | |
104 | SSLContextRef session; /* CDSA session object */ | |
105 | CFArrayRef certsArray; /* Certificates array */ | |
106 | } http_tls_t; | |
ef416fc2 | 107 | |
e53920b9 | 108 | typedef union _cdsa_conn_ref_u /**** CDSA Connection reference union |
109 | **** used to resolve 64-bit casting | |
110 | **** warnings. | |
111 | ****/ | |
112 | { | |
113 | SSLConnectionRef connection; /* SSL connection pointer */ | |
114 | int sock; /* Socket */ | |
115 | } cdsa_conn_ref_t; | |
116 | ||
ef416fc2 | 117 | extern OSStatus _httpReadCDSA(SSLConnectionRef connection, void *data, |
118 | size_t *dataLength); | |
119 | extern OSStatus _httpWriteCDSA(SSLConnectionRef connection, const void *data, | |
120 | size_t *dataLength); | |
121 | # endif /* HAVE_LIBSSL */ | |
122 | ||
ed486911 | 123 | |
124 | struct _http_s /**** HTTP connection structure. ****/ | |
125 | { | |
126 | int fd; /* File descriptor for this socket */ | |
127 | int blocking; /* To block or not to block */ | |
128 | int error; /* Last error on read */ | |
129 | time_t activity; /* Time since last read/write */ | |
130 | http_state_t state; /* State of client */ | |
131 | http_status_t status; /* Status of last request */ | |
132 | http_version_t version; /* Protocol version */ | |
133 | http_keepalive_t keep_alive; /* Keep-alive supported? */ | |
134 | struct sockaddr_in _hostaddr; /* Address of connected host @deprecated@ */ | |
135 | char hostname[HTTP_MAX_HOST], | |
136 | /* Name of connected host */ | |
137 | fields[HTTP_FIELD_MAX][HTTP_MAX_VALUE]; | |
138 | /* Field values */ | |
139 | char *data; /* Pointer to data buffer */ | |
140 | http_encoding_t data_encoding; /* Chunked or not */ | |
141 | int _data_remaining;/* Number of bytes left @deprecated@ */ | |
142 | int used; /* Number of bytes used in buffer */ | |
143 | char buffer[HTTP_MAX_BUFFER]; | |
144 | /* Buffer for incoming data */ | |
145 | int auth_type; /* Authentication in use */ | |
146 | _cups_md5_state_t md5_state; /* MD5 state */ | |
147 | char nonce[HTTP_MAX_VALUE]; | |
148 | /* Nonce value */ | |
149 | int nonce_count; /* Nonce count */ | |
150 | void *tls; /* TLS state information */ | |
151 | http_encryption_t encryption; /* Encryption requirements */ | |
152 | /**** New in CUPS 1.1.19 ****/ | |
153 | fd_set *input_set; /* select() set for httpWait() @since CUPS 1.1.19@ */ | |
154 | http_status_t expect; /* Expect: header @since CUPS 1.1.19@ */ | |
155 | char *cookie; /* Cookie value(s) @since CUPS 1.1.19@ */ | |
156 | /**** New in CUPS 1.1.20 ****/ | |
157 | char authstring[HTTP_MAX_VALUE], | |
158 | /* Current Authentication value @since CUPS 1.1.20@ */ | |
159 | userpass[HTTP_MAX_VALUE]; | |
160 | /* Username:password string @since CUPS 1.1.20@ */ | |
161 | int digest_tries; /* Number of tries for digest auth @since CUPS 1.1.20@ */ | |
162 | /**** New in CUPS 1.2 ****/ | |
163 | off_t data_remaining; /* Number of bytes left @since CUPS 1.2@ */ | |
164 | http_addr_t *hostaddr; /* Current host address and port @since CUPS 1.2@ */ | |
165 | http_addrlist_t *addrlist; /* List of valid addresses @since CUPS 1.2@ */ | |
166 | char wbuffer[HTTP_MAX_BUFFER]; | |
167 | /* Buffer for outgoing data */ | |
168 | int wused; /* Write buffer bytes used @since CUPS 1.2@ */ | |
169 | }; | |
170 | ||
171 | ||
ef416fc2 | 172 | /* |
173 | * Some OS's don't have hstrerror(), most notably Solaris... | |
174 | */ | |
175 | ||
176 | # ifndef HAVE_HSTRERROR | |
177 | extern const char *_cups_hstrerror(int error); | |
178 | # define hstrerror _cups_hstrerror | |
179 | # elif defined(_AIX) || defined(__osf__) | |
180 | /* | |
181 | * AIX and Tru64 UNIX don't provide a prototype but do provide the function... | |
182 | */ | |
183 | extern const char *hstrerror(int error); | |
184 | # endif /* !HAVE_HSTRERROR */ | |
185 | ||
89d46774 | 186 | |
187 | /* | |
188 | * Some OS's don't have getifaddrs() and freeifaddrs()... | |
189 | */ | |
190 | ||
191 | # include <net/if.h> | |
192 | # ifdef HAVE_GETIFADDRS | |
193 | # include <ifaddrs.h> | |
194 | # else | |
195 | # include <sys/ioctl.h> | |
196 | # ifdef HAVE_SYS_SOCKIO_H | |
197 | # include <sys/sockio.h> | |
198 | # endif /* HAVE_SYS_SOCKIO_H */ | |
199 | ||
200 | # ifdef ifa_dstaddr | |
201 | # undef ifa_dstaddr | |
202 | # endif /* ifa_dstaddr */ | |
203 | # ifndef ifr_netmask | |
204 | # define ifr_netmask ifr_addr | |
205 | # endif /* !ifr_netmask */ | |
206 | ||
207 | struct ifaddrs /**** Interface Structure ****/ | |
208 | { | |
209 | struct ifaddrs *ifa_next; /* Next interface in list */ | |
210 | char *ifa_name; /* Name of interface */ | |
211 | unsigned int ifa_flags; /* Flags (up, point-to-point, etc.) */ | |
212 | struct sockaddr *ifa_addr, /* Network address */ | |
f301802f | 213 | *ifa_netmask; /* Address mask */ |
214 | union | |
215 | { | |
216 | struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */ | |
217 | struct sockaddr *ifu_dstaddr; /* Point-to-point destination address. */ | |
218 | } ifa_ifu; | |
219 | ||
89d46774 | 220 | void *ifa_data; /* Interface statistics */ |
221 | }; | |
222 | ||
f301802f | 223 | # ifndef ifa_broadaddr |
224 | # define ifa_broadaddr ifa_ifu.ifu_broadaddr | |
225 | # endif /* !ifa_broadaddr */ | |
226 | # ifndef ifa_dstaddr | |
227 | # define ifa_dstaddr ifa_ifu.ifu_dstaddr | |
228 | # endif /* !ifa_dstaddr */ | |
229 | ||
a74454a7 | 230 | extern int _cups_getifaddrs(struct ifaddrs **addrs); |
89d46774 | 231 | # define getifaddrs _cups_getifaddrs |
a74454a7 | 232 | extern void _cups_freeifaddrs(struct ifaddrs *addrs); |
89d46774 | 233 | # define freeifaddrs _cups_freeifaddrs |
234 | # endif /* HAVE_GETIFADDRS */ | |
235 | ||
ef416fc2 | 236 | #endif /* !_CUPS_HTTP_PRIVATE_H_ */ |
237 | ||
238 | /* | |
c07d5b2d | 239 | * End of "$Id: http-private.h 181 2006-06-22 20:01:18Z jlovell $". |
ef416fc2 | 240 | */ |