Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 #ifndef _tls_hooks_h
00036 #define _tls_hooks_h
00037
00038 #ifdef TLS_HOOKS
00039
00040 #ifndef USE_TLS
00041 #error "USE_TLS required and not defined (please compile with make \
00042 TLS_HOOKS=1)"
00043 #endif
00044
00045 #ifdef CORE_TLS
00046 #error "Conflict: CORE_TLS and TLS_HOOKS cannot be defined in the same time"
00047 #endif
00048
00049 #include "tcp_conn.h"
00050
00051
00052
00053 struct tls_hooks{
00054
00055
00056 int (*read)(struct tcp_connection* c, int* flags);
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 int (*encode)(struct tcp_connection* c,
00070 const char** pbuf, unsigned int* plen,
00071 const char** rest_buf, unsigned int* rest_len,
00072 snd_flags_t* send_flags);
00073 int (*on_tcpconn_init)(struct tcp_connection *c, int sock);
00074 void (*tcpconn_clean)(struct tcp_connection* c);
00075 void (*tcpconn_close)(struct tcp_connection*c , int fd);
00076
00077
00078
00079 int (*init_si)(struct socket_info* si);
00080
00081
00082 int (*init)(void);
00083
00084
00085 void (*destroy)(void);
00086 };
00087
00088
00089 extern struct tls_hooks tls_hook;
00090
00091 #ifdef __SUNPRO_C
00092 #define tls_hook_call(name, ret_not_set, ...) \
00093 ((tls_hook.name)?(tls_hook.name(__VA_ARGS__)): (ret_not_set))
00094 #define tls_hook_call_v(name, __VA_ARGS__) \
00095 do{ \
00096 if (tls_hook.name) tls_hook.name(__VA_ARGS__); \
00097 }while(0)
00098 #else
00099 #define tls_hook_call(name, ret_not_set, args...) \
00100 ((tls_hook.name)?(tls_hook.name(args)): (ret_not_set))
00101 #define tls_hook_call_v(name, args...) \
00102 do{ \
00103 if (tls_hook.name) tls_hook.name(args); \
00104 }while(0)
00105 #endif
00106
00107
00108
00109 #define tls_tcpconn_init(c, s) tls_hook_call(on_tcpconn_init, 0, (c), (s))
00110 #define tls_tcpconn_clean(c) tls_hook_call_v(tcpconn_clean, (c))
00111 #define tls_encode(c, pbuf, plen, rbuf, rlen, sflags) \
00112 tls_hook_call(encode, -1, (c), (pbuf), (plen), (rbuf), (rlen), (sflags))
00113 #define tls_close(conn, fd) tls_hook_call_v(tcpconn_close, (conn), (fd))
00114 #define tls_read(c, flags) tls_hook_call(read, -1, (c), (flags))
00115
00116 int register_tls_hooks(struct tls_hooks* h);
00117
00118 #endif
00119 #endif