Line data Source code
1 : #ifndef HEADER_fd_src_discof_restore_utils_fd_sshttp_h 2 : #define HEADER_fd_src_discof_restore_utils_fd_sshttp_h 3 : 4 : struct fd_sshttp_private; 5 : typedef struct fd_sshttp_private fd_sshttp_t; 6 : 7 : #include "../../../util/net/fd_net_headers.h" 8 : 9 : FD_PROTOTYPES_BEGIN 10 : 11 : FD_FN_CONST ulong 12 : fd_sshttp_align( void ); 13 : 14 : FD_FN_CONST ulong 15 : fd_sshttp_footprint( void ); 16 : 17 : void * 18 : fd_sshttp_new( void * shmem, 19 : int epoll_fd ); 20 : 21 : fd_sshttp_t * 22 : fd_sshttp_join( void * sshttp ); 23 : 24 : /* fd_sshttp_load_ca_store loads the system CA certificate bundle for 25 : TLS certificate chain validation. If no bundle is found, subsequent 26 : fd_sshttp_init calls with is_https set fail before connecting. */ 27 : 28 : void 29 : fd_sshttp_load_ca_store( fd_sshttp_t * http ); 30 : 31 : char const * 32 : fd_sshttp_snapshot_name( fd_sshttp_t const * http ); 33 : 34 : ulong 35 : fd_sshttp_content_len( fd_sshttp_t const * http ); 36 : 37 : ulong 38 : fd_sshttp_resolved_slot( fd_sshttp_t const * http ); 39 : 40 : uchar const * 41 : fd_sshttp_resolved_hash( fd_sshttp_t const * http ); 42 : 43 : /* fd_sshttp_init initializes an sshttp connection to the given server. 44 : addr is the resolved IP address and port. hostname is a 45 : null-terminated string used for the Host header and TLS SNI. The 46 : hostname and path are copied; no caller memory is borrowed. 47 : is_https indicates whether TLS should be used. path points to the 48 : URL path of length path_len. hops is the maximum number of HTTP 49 : redirects to follow, pass ULONG_MAX to preserve the current hops 50 : value (e.g. when following a redirect internally). now is the 51 : current timestamp. Returns 0 on success and -1 on failure. */ 52 : 53 : int 54 : fd_sshttp_init( fd_sshttp_t * http, 55 : fd_ip4_port_t addr, 56 : char const * hostname, 57 : int is_https, 58 : char const * path, 59 : ulong path_len, 60 : ulong hops, 61 : long now ); 62 : 63 : void 64 : fd_sshttp_cancel( fd_sshttp_t * http ); 65 : 66 : /* fd_sshttp_deadline returns the wallclock at which the current step 67 : times out, or LONG_MAX when idle. */ 68 : 69 : long 70 : fd_sshttp_deadline( fd_sshttp_t const * http ); 71 : 72 0 : #define FD_SSHTTP_ADVANCE_ERROR (-1) 73 0 : #define FD_SSHTTP_ADVANCE_AGAIN ( 0) 74 0 : #define FD_SSHTTP_ADVANCE_DATA ( 1) 75 0 : #define FD_SSHTTP_ADVANCE_DONE ( 2) 76 : 77 : int 78 : fd_sshttp_advance( fd_sshttp_t * http, 79 : ulong * data_len, 80 : uchar * data, 81 : int * downloading, 82 : long now ); 83 : 84 : FD_PROTOTYPES_END 85 : 86 : #endif /* HEADER_fd_src_discof_restore_utils_fd_sshttp_h */