| 1 |
/* |
|---|
| 2 |
* Copyright (c) 2007, OmniTI Computer Consulting, Inc. |
|---|
| 3 |
* All rights reserved. |
|---|
| 4 |
*/ |
|---|
| 5 |
|
|---|
| 6 |
#ifndef _STRATCON_LOG_STREAMER_H |
|---|
| 7 |
#define _STRATCON_LOG_STREAMER_H |
|---|
| 8 |
|
|---|
| 9 |
#include "noit_conf.h" |
|---|
| 10 |
#include "jlog/jlog.h" |
|---|
| 11 |
#include <netinet/in.h> |
|---|
| 12 |
#include <sys/un.h> |
|---|
| 13 |
#include <arpa/inet.h> |
|---|
| 14 |
#include "stratcon_datastore.h" |
|---|
| 15 |
|
|---|
| 16 |
typedef struct noit_connection_ctx_t { |
|---|
| 17 |
union { |
|---|
| 18 |
struct sockaddr remote; |
|---|
| 19 |
struct sockaddr_un remote_un; |
|---|
| 20 |
struct sockaddr_in remote_in; |
|---|
| 21 |
struct sockaddr_in6 remote_in6; |
|---|
| 22 |
} r; |
|---|
| 23 |
socklen_t remote_len; |
|---|
| 24 |
char *remote_cn; |
|---|
| 25 |
u_int32_t current_backoff; |
|---|
| 26 |
int wants_shutdown; |
|---|
| 27 |
noit_hash_table *config; |
|---|
| 28 |
noit_hash_table *sslconfig; |
|---|
| 29 |
eventer_t timeout_event; |
|---|
| 30 |
|
|---|
| 31 |
eventer_func_t consumer_callback; |
|---|
| 32 |
void (*consumer_free)(void *); |
|---|
| 33 |
void *consumer_ctx; |
|---|
| 34 |
} noit_connection_ctx_t; |
|---|
| 35 |
|
|---|
| 36 |
typedef struct jlog_streamer_ctx_t { |
|---|
| 37 |
u_int32_t jlog_feed_cmd; |
|---|
| 38 |
int bytes_expected; |
|---|
| 39 |
int bytes_read; |
|---|
| 40 |
char *buffer; /* These guys are for doing partial reads */ |
|---|
| 41 |
|
|---|
| 42 |
enum { |
|---|
| 43 |
JLOG_STREAMER_WANT_INITIATE = 0, |
|---|
| 44 |
JLOG_STREAMER_WANT_COUNT = 1, |
|---|
| 45 |
JLOG_STREAMER_WANT_HEADER = 2, |
|---|
| 46 |
JLOG_STREAMER_WANT_BODY = 3, |
|---|
| 47 |
JLOG_STREAMER_WANT_CHKPT = 4, |
|---|
| 48 |
} state; |
|---|
| 49 |
int count; /* Number of jlog messages we need to read */ |
|---|
| 50 |
struct { |
|---|
| 51 |
jlog_id chkpt; |
|---|
| 52 |
u_int32_t tv_sec; |
|---|
| 53 |
u_int32_t tv_usec; |
|---|
| 54 |
u_int32_t message_len; |
|---|
| 55 |
} header; |
|---|
| 56 |
|
|---|
| 57 |
void (*push)(stratcon_datastore_op_t, struct sockaddr *, void *); |
|---|
| 58 |
} jlog_streamer_ctx_t; |
|---|
| 59 |
|
|---|
| 60 |
API_EXPORT(void) |
|---|
| 61 |
stratcon_jlog_streamer_init(const char *toplevel); |
|---|
| 62 |
API_EXPORT(void) |
|---|
| 63 |
stratcon_jlog_streamer_reload(const char *toplevel); |
|---|
| 64 |
API_EXPORT(int) |
|---|
| 65 |
stratcon_jlog_recv_handler(eventer_t e, int mask, void *closure, |
|---|
| 66 |
struct timeval *now); |
|---|
| 67 |
API_EXPORT(jlog_streamer_ctx_t *) |
|---|
| 68 |
stratcon_jlog_streamer_ctx_alloc(void); |
|---|
| 69 |
API_EXPORT(void) |
|---|
| 70 |
jlog_streamer_ctx_free(void *cl); |
|---|
| 71 |
API_EXPORT(void) |
|---|
| 72 |
stratcon_streamer_connection(const char *toplevel, const char *destination, |
|---|
| 73 |
eventer_func_t handler, |
|---|
| 74 |
void *(*handler_alloc)(void), void *handler_ctx, |
|---|
| 75 |
void (*handler_free)(void *)); |
|---|
| 76 |
|
|---|
| 77 |
#endif |
|---|