| 1 |
#ifndef AWS_HTTP_WEBSOCKET_IMPL_H |
| 2 |
#define AWS_HTTP_WEBSOCKET_IMPL_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/http/websocket.h> |
| 10 |
|
| 11 |
struct aws_http_client_connection_options; |
| 12 |
struct aws_http_connection; |
| 13 |
struct aws_http_make_request_options; |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#define AWS_WEBSOCKET_7BIT_VALUE_FOR_2BYTE_EXTENDED_LENGTH 126 |
| 33 |
#define AWS_WEBSOCKET_7BIT_VALUE_FOR_8BYTE_EXTENDED_LENGTH 127 |
| 34 |
|
| 35 |
#define AWS_WEBSOCKET_2BYTE_EXTENDED_LENGTH_MIN_VALUE AWS_WEBSOCKET_7BIT_VALUE_FOR_2BYTE_EXTENDED_LENGTH |
| 36 |
#define AWS_WEBSOCKET_2BYTE_EXTENDED_LENGTH_MAX_VALUE 0x000000000000FFFF |
| 37 |
|
| 38 |
#define AWS_WEBSOCKET_8BYTE_EXTENDED_LENGTH_MIN_VALUE 0x0000000000010000 |
| 39 |
#define AWS_WEBSOCKET_8BYTE_EXTENDED_LENGTH_MAX_VALUE 0x7FFFFFFFFFFFFFFF |
| 40 |
|
| 41 |
|
| 42 |
#define AWS_WEBSOCKET_MAX_FRAME_OVERHEAD (2 + 8 + 4) |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
struct aws_websocket_frame { |
| 48 |
bool fin; |
| 49 |
bool rsv[3]; |
| 50 |
bool masked; |
| 51 |
uint8_t opcode; |
| 52 |
uint64_t payload_length; |
| 53 |
uint8_t masking_key[4]; |
| 54 |
}; |
| 55 |
|
| 56 |
struct aws_websocket_handler_options { |
| 57 |
struct aws_allocator *allocator; |
| 58 |
struct aws_channel *channel; |
| 59 |
size_t initial_window_size; |
| 60 |
|
| 61 |
void *user_data; |
| 62 |
aws_websocket_on_incoming_frame_begin_fn *on_incoming_frame_begin; |
| 63 |
aws_websocket_on_incoming_frame_payload_fn *on_incoming_frame_payload; |
| 64 |
aws_websocket_on_incoming_frame_complete_fn *on_incoming_frame_complete; |
| 65 |
|
| 66 |
bool is_server; |
| 67 |
bool manual_window_update; |
| 68 |
}; |
| 69 |
|
| 70 |
struct aws_websocket_client_bootstrap_system_vtable { |
| 71 |
int (*aws_http_client_connect)(const struct aws_http_client_connection_options *options); |
| 72 |
void (*aws_http_connection_release)(struct aws_http_connection *connection); |
| 73 |
void (*aws_http_connection_close)(struct aws_http_connection *connection); |
| 74 |
struct aws_channel *(*aws_http_connection_get_channel)(struct aws_http_connection *connection); |
| 75 |
struct aws_http_stream *(*aws_http_connection_make_request)( |
| 76 |
struct aws_http_connection *client_connection, |
| 77 |
const struct aws_http_make_request_options *options); |
| 78 |
int (*aws_http_stream_activate)(struct aws_http_stream *stream); |
| 79 |
void (*aws_http_stream_release)(struct aws_http_stream *stream); |
| 80 |
struct aws_http_connection *(*aws_http_stream_get_connection)(const struct aws_http_stream *stream); |
| 81 |
void (*aws_http_stream_update_window)(struct aws_http_stream *stream, size_t increment_size); |
| 82 |
int (*aws_http_stream_get_incoming_response_status)(const struct aws_http_stream *stream, int *out_status); |
| 83 |
struct aws_websocket *(*aws_websocket_handler_new)(const struct aws_websocket_handler_options *options); |
| 84 |
}; |
| 85 |
|
| 86 |
AWS_EXTERN_C_BEGIN |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
AWS_HTTP_API |
| 92 |
const char *aws_websocket_opcode_str(uint8_t opcode); |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
AWS_HTTP_API |
| 98 |
uint64_t aws_websocket_frame_encoded_size(const struct aws_websocket_frame *frame); |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
AWS_HTTP_API |
| 104 |
struct aws_websocket *aws_websocket_handler_new(const struct aws_websocket_handler_options *options); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
AWS_HTTP_API |
| 111 |
void aws_websocket_client_bootstrap_set_system_vtable( |
| 112 |
const struct aws_websocket_client_bootstrap_system_vtable *system_vtable); |
| 113 |
|
| 114 |
AWS_EXTERN_C_END |
| 115 |
#endif |