libasyncd
|
ad_server header file More...
Go to the source code of this file.
Data Structures | |
struct | ad_server_s |
Server info container. More... | |
struct | ad_conn_s |
Connection structure. More... | |
Macros | |
#define | AD_OK (0) |
#define | AD_TAKEOVER (1) |
#define | AD_DONE (2) |
#define | AD_CLOSE (3) |
#define | AD_SERVER_OPTIONS |
Server option names and default values. More... | |
#define | AD_EVENT_INIT (1) |
Event types. More... | |
#define | AD_EVENT_READ (1 << 1) |
#define | AD_EVENT_WRITE (1 << 2) |
#define | AD_EVENT_CLOSE (1 << 3) |
#define | AD_EVENT_TIMEOUT (1 << 4) |
#define | AD_EVENT_SHUTDOWN (1 << 5) |
#define | AD_NUM_USERDATA (2) |
Defaults. More... | |
Typedefs | |
typedef struct ad_server_s | ad_server_t |
typedef struct ad_conn_s | ad_conn_t |
typedef int(* | ad_callback )(short event, ad_conn_t *conn, void *userdata) |
User callback(hook) prototype. More... | |
typedef void(* | ad_userdata_free_cb )(ad_conn_t *conn, void *userdata) |
Enumerations | |
enum | ad_log_e { AD_LOG_DISABLE = 0, AD_LOG_ERROR, AD_LOG_WARN, AD_LOG_INFO, AD_LOG_DEBUG, AD_LOG_DEBUG2 } |
Functions | |
enum ad_log_e | ad_log_level (enum ad_log_e log_level) |
Set debug output level. More... | |
ad_server_t * | ad_server_new (void) |
Create a server object. More... | |
int | ad_server_start (ad_server_t *server) |
Start server. More... | |
void | ad_server_stop (ad_server_t *server) |
Stop server. More... | |
void | ad_server_free (ad_server_t *server) |
Release server object and all the resources. More... | |
void | ad_server_global_free (void) |
Clean up all the global objects. More... | |
void | ad_server_set_option (ad_server_t *server, const char *key, const char *value) |
Set server option. More... | |
char * | ad_server_get_option (ad_server_t *server, const char *key) |
Retrieve server option. More... | |
int | ad_server_get_option_int (ad_server_t *server, const char *key) |
Retrieve server option in integer format. More... | |
SSL_CTX * | ad_server_ssl_ctx_create_simple (const char *cert_path, const char *pkey_path) |
Helper method for creating minimal OpenSSL SSL_CTX object. More... | |
void | ad_server_set_ssl_ctx (ad_server_t *server, SSL_CTX *sslctx) |
Attach OpenSSL SSL_CTX to the server. More... | |
SSL_CTX * | ad_server_get_ssl_ctx (ad_server_t *server) |
Get OpenSSL SSL_CTX object. More... | |
qhashtbl_t * | ad_server_get_stats (ad_server_t *server, const char *key) |
Return internal statistic counter map. More... | |
void | ad_server_register_hook (ad_server_t *server, ad_callback cb, void *userdata) |
Register user hook. More... | |
void | ad_server_register_hook_on_method (ad_server_t *server, const char *method, ad_callback cb, void *userdata) |
Register user hook on method name. More... | |
void * | ad_conn_set_userdata (ad_conn_t *conn, const void *userdata, ad_userdata_free_cb free_cb) |
Attach userdata into the connection. More... | |
void * | ad_conn_get_userdata (ad_conn_t *conn) |
Get userdata attached in the connection. More... | |
void * | ad_conn_set_extra (ad_conn_t *conn, const void *extra, ad_userdata_free_cb free_cb) |
Set extra userdata into the connection. More... | |
void * | ad_conn_get_extra (ad_conn_t *conn) |
Get extra userdata attached in this connection. More... | |
void | ad_conn_set_method (ad_conn_t *conn, char *method) |
Set method name on this connection. More... | |
int | ad_conn_get_socket (ad_conn_t *conn) |
Return socket file descriptor associated with a connection. More... | |
ad_server header file
Definition in file ad_server.h.
#define AD_OK (0) |
I'm done with this request. Escalate to other hooks.
Definition at line 57 of file ad_server.h.
#define AD_TAKEOVER (1) |
I'll handle the buffer directly this time, skip next hook
Definition at line 58 of file ad_server.h.
#define AD_DONE (2) |
We're done with this request but keep the connection open.
Definition at line 59 of file ad_server.h.
#define AD_CLOSE (3) |
We're done with this request. Close as soon as we sent all data out.
Definition at line 60 of file ad_server.h.
#define AD_SERVER_OPTIONS |
Server option names and default values.
Definition at line 81 of file ad_server.h.
#define AD_EVENT_INIT (1) |
#define AD_EVENT_READ (1 << 1) |
Call on read
Definition at line 124 of file ad_server.h.
#define AD_EVENT_WRITE (1 << 2) |
Call on write.
Definition at line 125 of file ad_server.h.
#define AD_EVENT_CLOSE (1 << 3) |
Call before closing.
Definition at line 126 of file ad_server.h.
#define AD_EVENT_TIMEOUT (1 << 4) |
Timeout indicator, this flag will be set with AD_EVENT_CLOSE.
Definition at line 127 of file ad_server.h.
#define AD_EVENT_SHUTDOWN (1 << 5) |
Shutdown indicator, this flag will be set with AD_EVENT_CLOSE.
Definition at line 128 of file ad_server.h.
#define AD_NUM_USERDATA (2) |
Defaults.
Number of userdata. Currently 0 is for userdata, 1 is for extra.
Definition at line 133 of file ad_server.h.
typedef struct ad_server_s ad_server_t |
Definition at line 51 of file ad_server.h.
Definition at line 52 of file ad_server.h.
typedef int(* ad_callback)(short event, ad_conn_t *conn, void *userdata) |
User callback(hook) prototype.
Definition at line 117 of file ad_server.h.
typedef void(* ad_userdata_free_cb)(ad_conn_t *conn, void *userdata) |
Definition at line 118 of file ad_server.h.
enum ad_log_e |
Enumerator | |
---|---|
AD_LOG_DISABLE | |
AD_LOG_ERROR | |
AD_LOG_WARN | |
AD_LOG_INFO | |
AD_LOG_DEBUG | |
AD_LOG_DEBUG2 |
Definition at line 65 of file ad_server.h.
Set debug output level.
debug_level | debug output level. 0 to disable. |
Definition at line 126 of file ad_server.c.
ad_server_t* ad_server_new | ( | void | ) |
Create a server object.
Definition at line 135 of file ad_server.c.
int ad_server_start | ( | ad_server_t * | server | ) |
void ad_server_stop | ( | ad_server_t * | server | ) |
Stop server.
This call is be used to stop a server from different thread.
Definition at line 287 of file ad_server.c.
void ad_server_free | ( | ad_server_t * | server | ) |
Release server object and all the resources.
Definition at line 303 of file ad_server.c.
void ad_server_global_free | ( | void | ) |
Clean up all the global objects.
This will make memory-leak checkers happy. There are globally shared resources in libevent and openssl and it's usually not a problem since they don't grow but having these can confuse some debugging tools into thinking as memory leak. If you need to make sure that libasyncd has released all internal library-global data structures, call this.
Definition at line 352 of file ad_server.c.
void ad_server_set_option | ( | ad_server_t * | server, |
const char * | key, | ||
const char * | value | ||
) |
char* ad_server_get_option | ( | ad_server_t * | server, |
const char * | key | ||
) |
Retrieve server option.
Definition at line 377 of file ad_server.c.
int ad_server_get_option_int | ( | ad_server_t * | server, |
const char * | key | ||
) |
Retrieve server option in integer format.
Definition at line 384 of file ad_server.c.
SSL_CTX* ad_server_ssl_ctx_create_simple | ( | const char * | cert_path, |
const char * | pkey_path | ||
) |
Helper method for creating minimal OpenSSL SSL_CTX object.
cert_path | path to a PEM encoded certificate file |
pkey_path | path to a PEM encoded private key file |
Definition at line 404 of file ad_server.c.
void ad_server_set_ssl_ctx | ( | ad_server_t * | server, |
SSL_CTX * | sslctx | ||
) |
Attach OpenSSL SSL_CTX to the server.
server | a valid server instance |
sslctx | allocated and configured SSL_CTX object |
Definition at line 434 of file ad_server.c.
SSL_CTX* ad_server_get_ssl_ctx | ( | ad_server_t * | server | ) |
Get OpenSSL SSL_CTX object.
server | a valid server instance |
Definition at line 454 of file ad_server.c.
qhashtbl_t* ad_server_get_stats | ( | ad_server_t * | server, |
const char * | key | ||
) |
Return internal statistic counter map.
Definition at line 461 of file ad_server.c.
void ad_server_register_hook | ( | ad_server_t * | server, |
ad_callback | cb, | ||
void * | userdata | ||
) |
Register user hook.
Definition at line 468 of file ad_server.c.
void ad_server_register_hook_on_method | ( | ad_server_t * | server, |
const char * | method, | ||
ad_callback | cb, | ||
void * | userdata | ||
) |
Register user hook on method name.
Definition at line 475 of file ad_server.c.
void* ad_conn_set_userdata | ( | ad_conn_t * | conn, |
const void * | userdata, | ||
ad_userdata_free_cb | free_cb | ||
) |
Attach userdata into the connection.
Definition at line 490 of file ad_server.c.
void* ad_conn_get_userdata | ( | ad_conn_t * | conn | ) |
Get userdata attached in the connection.
Definition at line 499 of file ad_server.c.
void* ad_conn_set_extra | ( | ad_conn_t * | conn, |
const void * | extra, | ||
ad_userdata_free_cb | free_cb | ||
) |
Set extra userdata into the connection.
Definition at line 513 of file ad_server.c.
void* ad_conn_get_extra | ( | ad_conn_t * | conn | ) |
Get extra userdata attached in this connection.
Definition at line 520 of file ad_server.c.
void ad_conn_set_method | ( | ad_conn_t * | conn, |
char * | method | ||
) |
Set method name on this connection.
Once the method name is set, hooks registered by ad_server_register_hook_on_method() will be called if method name matches with the registered name.
Definition at line 532 of file ad_server.c.
int ad_conn_get_socket | ( | ad_conn_t * | conn | ) |
Return socket file descriptor associated with a connection.
Definition at line 543 of file ad_server.c.