kinetic-c  v0.12.0
Seagate Kinetic Protocol Client Library for C
bus_internal_types.h
Go to the documentation of this file.
1 /*
2 * kinetic-c
3 * Copyright (C) 2015 Seagate Technology.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20 #ifndef BUS_INTERNAL_TYPES_H
21 #define BUS_INTERNAL_TYPES_H
22 
23 #include <stdlib.h>
24 #include <stdint.h>
25 #include <pthread.h>
26 
27 #include <openssl/ssl.h>
28 #include <openssl/err.h>
29 
30 #include "bus.h"
31 #include "yacht.h"
32 
33 /* Struct for a message that will be passed from client to listener to
34  * threadpool, proceeding directly to the threadpool if there is an error
35  * along the way. This must only have a single owner at a time. */
36 typedef struct boxed_msg {
37 
41 
43  time_t timeout_sec;
44 
47  void *udata;
48 
50  struct timeval tv_send_start;
51  struct timeval tv_send_done;
52 
54  int fd;
55  SSL *ssl;
56  int64_t out_seq_id;
57  uint8_t *out_msg;
58  size_t out_msg_size;
59  size_t out_sent_size;
60 } boxed_msg;
61 
63 #define BUS_NO_SSL ((SSL *)-2)
64 
65 typedef enum {
70 
72 typedef struct bus {
75  bus_unexpected_msg_cb *unexpected_msg_cb; //< Unexpected message callback
77  void *udata;
78 
79  int log_level;
81 
82  uint8_t listener_count;
83  struct listener **listeners;
84 
85  bool *joined;
86  pthread_t *threads;
88 
90  SSL_CTX *ssl_ctx;
91 
93  struct yacht *fd_set;
94  pthread_mutex_t fd_set_lock;
95 } bus;
96 
98 #define TIMEOUT_NOT_YET_SET ((time_t)(-1))
99 
100 typedef enum {
108 } rx_error_t;
109 
111 typedef struct {
112  /* Shared */
113  const int fd;
115  void *udata;
116 
117  /* Shared, cleaned up by client */
118  SSL *ssl;
119 
122 
123  /* Set by listener thread */
125  size_t to_read_size;
127 
129 #define LISTENER_MSG_TAG 0x15
130 
132 #define DEF_FD_SET_SIZE2 4
133 
134 #endif
time_t timeout_sec
Message send timeout.
bus_sink_cb_res_t( bus_sink_cb)(uint8_t *read_buf, size_t read_size, void *socket_udata)
Definition: bus_types.h:130
int64_t largest_wr_seq_id_seen
Set by client thread.
const bus_socket_t type
bus_msg_result_t result
Result message, constructed in place after the request/response cycle has completed or failed due to ...
pthread_mutex_t fd_set_lock
Receiver of responses.
shutdown_state_t
bus_unexpected_msg_cb * unexpected_msg_cb
size_t out_sent_size
bool * joined
Which threads have joined.
SSL * ssl
SSL handle. Must be valid or BUS_NO_SSL.
bus_unpack_cb * unpack_cb
Message unpacking callback.
struct listener ** listeners
Listener array.
shutdown_state_t shutdown_state
Current shutdown state.
Internal threadpool state.
struct timeval tv_send_start
Event timestamps to track timeouts.
Message bus.
struct threadpool * threadpool
Thread pool.
bus_unpack_cb_res_t( bus_unpack_cb)(void *msg, void *socket_udata)
Definition: bus_types.h:151
void * udata
User data for callbacks.
uint8_t listener_count
Number of listeners.
uint8_t * out_msg
int64_t out_seq_id
bus_error_cb * error_cb
Error handling callback.
SSL_CTX * ssl_ctx
SSL context.
int log_level
Log level.
void * udata
user connection data
void( bus_msg_cb)(bus_msg_result_t *res, void *udata)
Definition: bus_types.h:229
SSL * ssl
valid pointer or BUS_BOXED_MSG_NO_SSL
bus_msg_cb * cb
Callback and userdata to which the bus_msg_result_t above will be sunk.
pthread_t * threads
Threads.
bus_socket_t
Definition: bus_types.h:231
Per-socket connection context.
void( bus_log_cb)(log_event_t event, int log_level, const char *msg, void *udata)
Definition: bus_types.h:110
struct timeval tv_send_done
bus_sink_cb * sink_cb
IO sink callback.
size_t out_msg_size
void( bus_unexpected_msg_cb)(void *msg, int64_t seq_id, void *bus_udata, void *socket_udata)
Definition: bus_types.h:159
struct yacht * fd_set
Locked hash table for fd -> connection_info.
int fd
Destination filename and message body.
bus_log_cb * log_cb
Logging callback.
void( bus_error_cb)(bus_unpack_cb_res_t result, void *socket_udata)
Definition: bus_types.h:154