xref: /onnv-gate/usr/src/common/net/wanboot/boot_http.h (revision 1279:4878337043bb)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
231275Svh115876  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_BOOT_HTTP_H
280Sstevel@tonic-gate #define	_BOOT_HTTP_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/types.h>
340Sstevel@tonic-gate #include <sys/errno.h>
350Sstevel@tonic-gate #include <parseURL.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /* State information returned by http_conn_info() */
420Sstevel@tonic-gate typedef struct {
430Sstevel@tonic-gate 	url_t		uri;		/* URI last loaded */
440Sstevel@tonic-gate 	url_hport_t	proxy;		/* proxy, if any being used */
450Sstevel@tonic-gate 	boolean_t	keepalive;	/* Keepalive setting being used */
460Sstevel@tonic-gate 	uint_t		read_timeout;	/* Timeout to use for socket reads */
470Sstevel@tonic-gate } http_conninfo_t;
480Sstevel@tonic-gate 
490Sstevel@tonic-gate 
500Sstevel@tonic-gate /* Structure for version of the http file */
510Sstevel@tonic-gate typedef struct {
520Sstevel@tonic-gate 	uint_t	maj_ver;	/* Major version */
530Sstevel@tonic-gate 	uint_t	min_ver;	/* Minor version */
540Sstevel@tonic-gate 	uint_t	micro_ver;	/* Micro version */
550Sstevel@tonic-gate } boot_http_ver_t;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /* Internal Libhttp errors */
580Sstevel@tonic-gate #define	EHTTP_BADARG	1	/* Function called with one+ bad arguments */
590Sstevel@tonic-gate #define	EHTTP_NOMEM	2	/* Out of memory error detected */
600Sstevel@tonic-gate #define	EHTTP_CONCLOSED	3	/* The ssl connection was closed (but not */
610Sstevel@tonic-gate 				/* necessarily the underlying transport */
620Sstevel@tonic-gate 				/* connection). */
630Sstevel@tonic-gate #define	EHTTP_UNEXPECTED 4	/* A SSL I/O request returned an unexpected */
640Sstevel@tonic-gate 				/* error. */
650Sstevel@tonic-gate #define	EHTTP_EOFERR	5	/* Unexpected/premature EOF */
660Sstevel@tonic-gate #define	EHTTP_NOCERT	6	/* No certificate was persented */
670Sstevel@tonic-gate #define	EHTTP_NOMATCH	7	/* Peer cert doesn't match hostname or */
680Sstevel@tonic-gate 				/* No matching entry */
690Sstevel@tonic-gate #define	EHTTP_NODATA	8	/* No data was returned */
700Sstevel@tonic-gate #define	EHTTP_NOT_1_1	9	/* This was not a HTTP/1.1 response */
710Sstevel@tonic-gate #define	EHTTP_BADHDR	10	/* The header doesn't look to be valid */
720Sstevel@tonic-gate #define	EHTTP_OORANGE	11	/* Requests header line is out of range */
730Sstevel@tonic-gate #define	EHTTP_NORESP	12	/* No or partial response returned */
740Sstevel@tonic-gate #define	EHTTP_BADRESP	13	/* Bad response or error returned */
750Sstevel@tonic-gate #define	EHTTP_NOHEADER	14	/* Chunked header expected but not found */
760Sstevel@tonic-gate #define	EHTTP_NOBOUNDARY 15	/* Boundary line expected but not found */
770Sstevel@tonic-gate #define	EHTTP_NOTMULTI	16	/* This is not a multipart transfer */
780Sstevel@tonic-gate #define	EHTTP_BADSIZE	17	/* Could not determine msg body size */
790Sstevel@tonic-gate 
800Sstevel@tonic-gate 
810Sstevel@tonic-gate 
820Sstevel@tonic-gate /* Sources of errors */
830Sstevel@tonic-gate #define	ERRSRC_SYSTEM	1	/* System error occurred */
840Sstevel@tonic-gate #define	ERRSRC_LIBHTTP	2	/* Internal (libhttp) error */
850Sstevel@tonic-gate #define	ERRSRC_RESOLVE	3	/* Libresolv error */
860Sstevel@tonic-gate #define	ERRSRC_VERIFERR	4	/* Verify error occurred */
870Sstevel@tonic-gate #define	ERRSRC_LIBSSL	5	/* Libssl/libcrypto error */
880Sstevel@tonic-gate 
890Sstevel@tonic-gate 
900Sstevel@tonic-gate typedef struct {
910Sstevel@tonic-gate 	uint_t	code;		/* status code */
920Sstevel@tonic-gate 	char	*statusmsg;	/* status message */
930Sstevel@tonic-gate 	uint_t	nresphdrs;	/* number of response headers */
940Sstevel@tonic-gate } http_respinfo_t;
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 
970Sstevel@tonic-gate typedef void *http_handle_t;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate boot_http_ver_t const *http_get_version(void);
1000Sstevel@tonic-gate void http_set_p12_format(int);
1010Sstevel@tonic-gate void http_set_verbose(boolean_t);
1020Sstevel@tonic-gate int  http_set_cipher_list(const char *);
1030Sstevel@tonic-gate http_handle_t http_srv_init(const url_t *);
1040Sstevel@tonic-gate int  http_set_proxy(http_handle_t, const url_hport_t *);
1050Sstevel@tonic-gate int  http_set_keepalive(http_handle_t, boolean_t);
1060Sstevel@tonic-gate int  http_set_socket_read_timeout(http_handle_t, uint_t);
1070Sstevel@tonic-gate int  http_set_basic_auth(http_handle_t, const char *, const char *);
1080Sstevel@tonic-gate int  http_set_random_file(http_handle_t, const char *);
1090Sstevel@tonic-gate int  http_set_certificate_authority_file(const char *);
1100Sstevel@tonic-gate int  http_set_client_certificate_file(http_handle_t, const char *);
1110Sstevel@tonic-gate int  http_set_password(http_handle_t, const char *);
1120Sstevel@tonic-gate int  http_set_key_file_password(http_handle_t, const char *);
1130Sstevel@tonic-gate int  http_set_private_key_file(http_handle_t, const char *);
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate int   http_srv_connect(http_handle_t);
1160Sstevel@tonic-gate int   http_head_request(http_handle_t, const char *);
1170Sstevel@tonic-gate int   http_get_request(http_handle_t, const char *);
118*1279Svh115876 int   http_get_range_request(http_handle_t, const char *, offset_t, offset_t);
1190Sstevel@tonic-gate void  http_free_respinfo(http_respinfo_t *);
1200Sstevel@tonic-gate int   http_process_headers(http_handle_t, http_respinfo_t **);
1210Sstevel@tonic-gate int   http_process_part_headers(http_handle_t, http_respinfo_t **);
1220Sstevel@tonic-gate char *http_get_header_value(http_handle_t, const char *);
1230Sstevel@tonic-gate char *http_get_response_header(http_handle_t, uint_t);
1240Sstevel@tonic-gate int   http_read_body(http_handle_t, char *, size_t);
1250Sstevel@tonic-gate int   http_srv_disconnect(http_handle_t);
1260Sstevel@tonic-gate int   http_srv_close(http_handle_t);
1270Sstevel@tonic-gate http_conninfo_t *http_get_conn_info(http_handle_t);
1280Sstevel@tonic-gate int   http_conn_is_https(http_handle_t, boolean_t *);
1290Sstevel@tonic-gate ulong_t http_get_lasterr(http_handle_t, uint_t *);
1300Sstevel@tonic-gate void http_decode_err(ulong_t, int *, int *, int *);
1310Sstevel@tonic-gate char const *http_errorstr(uint_t, ulong_t);
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate #ifdef	__cplusplus
1340Sstevel@tonic-gate }
1350Sstevel@tonic-gate #endif
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate #endif	/* _BOOT_HTTP_H */
138