]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/http-private.h
Merge changes from CUPS 1.5svn-r9062.
[thirdparty/cups.git] / cups / http-private.h
index ee2f9485152a57afa5577a73ebb0d37e24e6af90..4a08eb9e3b7dcfb251b5ff4c75cc6c046a414205 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id$"
+ * "$Id: http-private.h 7850 2008-08-20 00:07:25Z mike $"
  *
- *   Private HTTP definitions for the Common UNIX Printing System (CUPS).
+ *   Private HTTP definitions for CUPS.
  *
- *   Copyright 1997-2005 by Easy Software Products, all rights reserved.
+ *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products and are protected by Federal
- *   copyright law.  Distribution and use rights are outlined in the file
- *   "LICENSE.txt" which should have been included with this file.  If this
- *   file is missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
  *
  *   This file is subject to the Apple OS-Developed Software exception.
  */
  * Include necessary headers...
  */
 
+#  include "config.h"
+#  include <stddef.h>
 #  include <stdlib.h>
-#  include <config.h>
 
 #  ifdef __sun
-/*
- * Define FD_SETSIZE to CUPS_MAX_FDS on Solaris to get the correct version of
- * select() for large numbers of file descriptors.
- */
-
-#    define FD_SETSIZE CUPS_MAX_FDS
 #    include <sys/select.h>
 #  endif /* __sun */
 
 #    define closesocket(f) close(f)
 #  endif /* WIN32 */
 
+#  ifdef HAVE_GSSAPI
+#    ifdef HAVE_GSSAPI_GSSAPI_H
+#      include <gssapi/gssapi.h>
+#    endif /* HAVE_GSSAPI_GSSAPI_H */
+#    ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H
+#      include <gssapi/gssapi_generic.h>
+#    endif /* HAVE_GSSAPI_GSSAPI_GENERIC_H */
+#    ifdef HAVE_GSSAPI_GSSAPI_KRB5_H
+#      include <gssapi/gssapi_krb5.h>
+#    endif /* HAVE_GSSAPI_GSSAPI_KRB5_H */
+#    ifdef HAVE_GSSAPI_H
+#      include <gssapi.h>
+#    endif /* HAVE_GSSAPI_H */
+#    ifndef HAVE_GSS_C_NT_HOSTBASED_SERVICE
+#      define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
+#    endif /* !HAVE_GSS_C_NT_HOSTBASED_SERVICE */
+#    ifdef HAVE_KRB5_H
+#      include <krb5.h>
+#    endif /* HAVE_KRB5_H */
+#  endif /* HAVE_GSSAPI */
+
+#  ifdef HAVE_AUTHORIZATION_H
+#    include <Security/Authorization.h>
+#  endif /* HAVE_AUTHORIZATION_H */
+
 #  if defined(__sgi) || (defined(__APPLE__) && !defined(_SOCKLEN_T))
 /*
  * IRIX and MacOS X 10.2.x do not define socklen_t, and in fact use an int instead of
 typedef int socklen_t;
 #  endif /* __sgi || (__APPLE__ && !_SOCKLEN_T) */
 
-#  include "http.h"
+#  include <cups/http.h>
+#  include "md5-private.h"
 #  include "ipp-private.h"
 
 #  if defined HAVE_LIBSSL
 /*
  * The OpenSSL library provides its own SSL/TLS context structure for its
- * IO and protocol management...
+ * IO and protocol management.  However, we need to provide our own BIO
+ * (basic IO) implementation to do timeouts...
  */
 
 #    include <openssl/err.h>
@@ -79,6 +92,8 @@ typedef int socklen_t;
 
 typedef SSL http_tls_t;
 
+extern BIO_METHOD *_httpBIOMethods(void);
+
 #  elif defined HAVE_GNUTLS
 /*
  * The GNU TLS library is more of a "bare metal" SSL/TLS library...
@@ -91,6 +106,11 @@ typedef struct
   void                 *credentials;   /* GNU TLS credentials object */
 } http_tls_t;
 
+extern ssize_t _httpReadGNUTLS(gnutls_transport_ptr ptr, void *data,
+                               size_t length);
+extern ssize_t _httpWriteGNUTLS(gnutls_transport_ptr ptr, const void *data,
+                                size_t length);
+
 #  elif defined(HAVE_CDSASSL)
 /*
  * Darwin's Security framework provides its own SSL/TLS context structure
@@ -105,15 +125,6 @@ typedef struct                             /**** CDSA connection information ****/
   CFArrayRef           certsArray;     /* Certificates array */
 } http_tls_t;
 
-typedef union _cdsa_conn_ref_u         /**** CDSA Connection reference union
-                                        **** used to resolve 64-bit casting
-                                        **** warnings.
-                                        ****/
-{
-  SSLConnectionRef connection;         /* SSL connection pointer */
-  int             sock;                /* Socket */
-} cdsa_conn_ref_t;
-
 extern OSStatus        _httpReadCDSA(SSLConnectionRef connection, void *data,
                              size_t *dataLength);
 extern OSStatus        _httpWriteCDSA(SSLConnectionRef connection, const void *data,
@@ -150,12 +161,12 @@ struct _http_s                            /**** HTTP connection structure. ****/
   void                 *tls;           /* TLS state information */
   http_encryption_t    encryption;     /* Encryption requirements */
   /**** New in CUPS 1.1.19 ****/
-  fd_set               *input_set;     /* select() set for httpWait() @since CUPS 1.1.19@ */
+  fd_set               *input_set;     /* select() set for httpWait() @deprecated@ */
   http_status_t                expect;         /* Expect: header @since CUPS 1.1.19@ */
   char                 *cookie;        /* Cookie value(s) @since CUPS 1.1.19@ */
   /**** New in CUPS 1.1.20 ****/
-  char                 authstring[HTTP_MAX_VALUE],
-                                       /* Current Authentication value @since CUPS 1.1.20@ */
+  char                 _authstring[HTTP_MAX_VALUE],
+                                       /* Current Authentication value. @deprecated@ */
                        userpass[HTTP_MAX_VALUE];
                                        /* Username:password string @since CUPS 1.1.20@ */
   int                  digest_tries;   /* Number of tries for digest auth @since CUPS 1.1.20@ */
@@ -166,6 +177,18 @@ struct _http_s                             /**** HTTP connection structure. ****/
   char                 wbuffer[HTTP_MAX_BUFFER];
                                        /* Buffer for outgoing data */
   int                  wused;          /* Write buffer bytes used @since CUPS 1.2@ */
+  /**** New in CUPS 1.3 ****/
+  char                 *field_authorization;
+                                       /* Authorization field @since CUPS 1.3@ */
+  char                 *authstring;    /* Current authorization field @since CUPS 1.3 */
+#  ifdef HAVE_GSSAPI
+  gss_OID              gssmech;        /* Authentication mechanism @since CUPS 1.3@ */
+  gss_ctx_id_t         gssctx;         /* Authentication context @since CUPS 1.3@ */
+  gss_name_t           gssname;        /* Authentication server name @since CUPS 1.3@ */
+#  endif /* HAVE_GSSAPI */
+#  ifdef HAVE_AUTHORIZATION_H
+  AuthorizationRef     auth_ref;       /* Authorization ref */
+#  endif /* HAVE_AUTHORIZATION_H */
 };
 
 
@@ -188,21 +211,22 @@ extern const char *hstrerror(int error);
  * Some OS's don't have getifaddrs() and freeifaddrs()...
  */
 
-#  include <net/if.h>
-#  ifdef HAVE_GETIFADDRS
-#    include <ifaddrs.h>
-#  else
-#    include <sys/ioctl.h>
-#    ifdef HAVE_SYS_SOCKIO_H
-#      include <sys/sockio.h>
-#    endif /* HAVE_SYS_SOCKIO_H */
-
-#  ifdef ifa_dstaddr
-#    undef ifa_dstaddr
-#  endif /* ifa_dstaddr */
-#  ifndef ifr_netmask
-#    define ifr_netmask ifr_addr
-#  endif /* !ifr_netmask */
+#  ifndef WIN32
+#    include <net/if.h>
+#    ifdef HAVE_GETIFADDRS
+#      include <ifaddrs.h>
+#    else
+#      include <sys/ioctl.h>
+#      ifdef HAVE_SYS_SOCKIO_H
+#        include <sys/sockio.h>
+#      endif /* HAVE_SYS_SOCKIO_H */
+
+#      ifdef ifa_dstaddr
+#        undef ifa_dstaddr
+#      endif /* ifa_dstaddr */
+#      ifndef ifr_netmask
+#        define ifr_netmask ifr_addr
+#      endif /* !ifr_netmask */
 
 struct ifaddrs                         /**** Interface Structure ****/
 {
@@ -220,21 +244,34 @@ struct ifaddrs                            /**** Interface Structure ****/
   void                 *ifa_data;      /* Interface statistics */
 };
 
-#  ifndef ifa_broadaddr
-#    define ifa_broadaddr ifa_ifu.ifu_broadaddr
-#  endif /* !ifa_broadaddr */
-#  ifndef ifa_dstaddr
-#    define ifa_dstaddr ifa_ifu.ifu_dstaddr
-#  endif /* !ifa_dstaddr */
+#      ifndef ifa_broadaddr
+#        define ifa_broadaddr ifa_ifu.ifu_broadaddr
+#      endif /* !ifa_broadaddr */
+#      ifndef ifa_dstaddr
+#        define ifa_dstaddr ifa_ifu.ifu_dstaddr
+#      endif /* !ifa_dstaddr */
 
 extern int     _cups_getifaddrs(struct ifaddrs **addrs);
-#    define getifaddrs _cups_getifaddrs
+#      define getifaddrs _cups_getifaddrs
 extern void    _cups_freeifaddrs(struct ifaddrs *addrs);
-#    define freeifaddrs _cups_freeifaddrs
-#  endif /* HAVE_GETIFADDRS */
+#      define freeifaddrs _cups_freeifaddrs
+#    endif /* HAVE_GETIFADDRS */
+#  endif /* !WIN32 */
+
+/*
+ * Prototypes...
+ */
 
+extern int             _httpAddrPort(http_addr_t *addr);
+extern http_t          *_httpCreate(const char *host, int port,
+                                    http_encryption_t encryption);
+extern char            *_httpEncodeURI(char *dst, const char *src,
+                                       size_t dstsize);
+extern const char      *_httpResolveURI(const char *uri, char *resolved_uri,
+                                        size_t resolved_size, int log);
+extern int             _httpWait(http_t *http, int msec, int usessl);
 #endif /* !_CUPS_HTTP_PRIVATE_H_ */
 
 /*
- * End of "$Id$".
+ * End of "$Id: http-private.h 7850 2008-08-20 00:07:25Z mike $".
  */