]>
Commit | Line | Data |
---|---|---|
1b4f8140 | 1 | /* |
5e0de328 | 2 | * Copyright (C) 2009-2012 the libgit2 contributors |
bb742ede VM |
3 | * |
4 | * This file is part of libgit2, distributed under the GNU GPL v2 with | |
5 | * a Linking Exception. For full terms see the included COPYING file. | |
1b4f8140 CMN |
6 | */ |
7 | #ifndef INCLUDE_netops_h__ | |
8 | #define INCLUDE_netops_h__ | |
9 | ||
44ef8b1b | 10 | #include "posix.h" |
a6f24a5b | 11 | #include "common.h" |
74bd343a | 12 | |
41fb1ca0 PK |
13 | #ifdef GIT_SSL |
14 | # include <openssl/ssl.h> | |
15 | #endif | |
16 | ||
17 | struct gitno_ssl { | |
18 | #ifdef GIT_SSL | |
19 | SSL_CTX *ctx; | |
20 | SSL *ssl; | |
21 | #else | |
22 | size_t dummy; | |
23 | #endif | |
24 | }; | |
25 | ||
26 | typedef struct gitno_ssl gitno_ssl; | |
27 | ||
28 | /* Represents a socket that may or may not be using SSL */ | |
29 | struct gitno_socket { | |
30 | GIT_SOCKET socket; | |
31 | gitno_ssl ssl; | |
32 | }; | |
33 | ||
34 | typedef struct gitno_socket gitno_socket; | |
35 | ||
64d01de8 | 36 | struct gitno_buffer { |
c7c787ce | 37 | char *data; |
0bd594b6 VM |
38 | size_t len; |
39 | size_t offset; | |
41fb1ca0 PK |
40 | gitno_socket *socket; |
41 | int (*recv)(struct gitno_buffer *buffer); | |
b49c8f71 | 42 | void *cb_data; |
64d01de8 | 43 | }; |
ea7a5452 | 44 | |
41fb1ca0 PK |
45 | typedef struct gitno_buffer gitno_buffer; |
46 | ||
47 | /* Flags to gitno_connect */ | |
48 | enum { | |
49 | /* Attempt to create an SSL connection. */ | |
50 | GITNO_CONNECT_SSL = 1, | |
51 | ||
52 | /* Valid only when GITNO_CONNECT_SSL is also specified. | |
53 | * Indicates that the server certificate should not be validated. */ | |
54 | GITNO_CONNECT_SSL_NO_CHECK_CERT = 2, | |
55 | }; | |
56 | ||
57 | void gitno_buffer_setup(gitno_socket *t, gitno_buffer *buf, char *data, size_t len); | |
58 | void gitno_buffer_setup_callback(gitno_socket *t, gitno_buffer *buf, char *data, size_t len, int (*recv)(gitno_buffer *buf), void *cb_data); | |
ea7a5452 | 59 | int gitno_recv(gitno_buffer *buf); |
66024c7c | 60 | |
c7c787ce | 61 | void gitno_consume(gitno_buffer *buf, const char *ptr); |
0bd594b6 | 62 | void gitno_consume_n(gitno_buffer *buf, size_t cons); |
ea7a5452 | 63 | |
41fb1ca0 PK |
64 | int gitno_connect(gitno_socket *socket, const char *host, const char *port, int flags); |
65 | int gitno_send(gitno_socket *socket, const char *msg, size_t len, int flags); | |
66 | int gitno_close(gitno_socket *s); | |
74bd343a | 67 | int gitno_select_in(gitno_buffer *buf, long int sec, long int usec); |
1b4f8140 | 68 | |
db84b798 CMN |
69 | int gitno_extract_host_and_port(char **host, char **port, const char *url, const char *default_port); |
70 | ||
1b4f8140 | 71 | #endif |