summaryrefslogtreecommitdiff
path: root/usr/src/lib/libpkg/common/pkgweb.h
blob: fe9dc372d9bc324b188d2e7f6615fccc941e4094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _PKGWEB_H
#define	_PKGWEB_H


#ifdef __cplusplus
extern "C" {
#endif

#include <netdb.h>
#include <boot_http.h>

/* shortest backoff delay possible (in seconds) */
#define	MIN_BACKOFF	1

/* how much to increase backoff time after each failure */
#define	BACKOFF_FACTOR	2

/* Maximum amount of backoff for a heavy network or flaky server */
#define	MAX_BACKOFF	128

typedef enum {
	HTTP_REQ_TYPE_HEAD,
	HTTP_REQ_TYPE_GET
} HTTPRequestType;

typedef enum {
	OCSPSuccess,
	OCSPMem,
	OCSPParse,
	OCSPConnect,
	OCSPRequest,
	OCSPResponder,
	OCSPUnsupported,
	OCSPVerify,
	OCSPInternal,
	OCSPNoURI
} OCSPStatus;

typedef enum {
	none,
	web_http,
	web_https,
	web_ftp
} WebScheme;

typedef enum {
    WEB_OK,
    WEB_TIMEOUT,
    WEB_CONNREFUSED,
    WEB_HOSTDOWN,
    WEB_VERIFY_SETUP,
    WEB_NOCONNECT,
    WEB_GET_FAIL
} WebStatus;

typedef struct {
	ulong_t prev_cont_length;
	ulong_t content_length;
	ulong_t cur_pos;
} DwnldData;

typedef struct {
	keystore_handle_t keystore;
	char *certfile;
	char *uniqfile;
	char *link;
	char *errstr;
	char *dwnld_dir;
	boolean_t	spool;
	void *content;
	int timeout;
	url_hport_t proxy;
	url_t url;
	DwnldData data;
	http_respinfo_t *resp;
	boot_http_ver_t *http_vers;
	http_handle_t *hps;
} WEB_SESSION;

extern boolean_t web_session_control(PKG_ERR *, char *, char *,
    keystore_handle_t, char *, ushort_t, int, int, int, char **);
extern boolean_t get_signature(PKG_ERR *, char *, struct pkgdev *,
    PKCS7 **);
extern boolean_t validate_signature(PKG_ERR *, char *, BIO *, PKCS7 *,
    STACK_OF(X509) *, url_hport_t *, int);
extern boolean_t ds_validate_signature(PKG_ERR *, struct pkgdev *, char **,
    char *, PKCS7 *, STACK_OF(X509) *, url_hport_t *, int);
extern boolean_t get_proxy_port(PKG_ERR *, char **, ushort_t *);
extern boolean_t path_valid(char *);
extern void web_cleanup(void);
extern ushort_t strip_port(char *proxy);
extern void set_web_install(void);
extern int is_web_install(void);
extern void echo_out(int, char *, ...);
extern void backoff(void);
extern void reset_backoff(void);
extern char *get_endof_string(char *, char);
extern char *get_startof_string(char *, char);

#ifdef __cplusplus
}
#endif

#endif /* _PKGWEB_H */