Top | ![]() |
![]() |
![]() |
![]() |
enum | prelude_client_exit_status_t |
enum | prelude_client_flags_t |
typedef | prelude_client_t |
prelude_ident_t *
prelude_client_get_unique_ident (prelude_client_t *client
);
void prelude_client_set_connection_pool (prelude_client_t *client
,prelude_connection_pool_t *pool
);
Use this function in order to set your own list of peer that client
should send message too. This might be usefull in case you don't want
this to be automated by prelude_client_init()
.
client |
pointer to a prelude_client_t object. |
|
pool |
pointer to a prelude_client_pool_t object. |
prelude_connection_pool_t *
prelude_client_get_connection_pool (prelude_client_t *client
);
Return a pointer to the prelude_connection_pool_t object used by client
to send messages.
int
prelude_client_start (prelude_client_t *client
);
This function start the client
object, triggering
a connection from the client to it's server if any were
specified, and sending the initial client
heartbeat.
If client
was not initialized, then prelude_client_init()
will be called and thus this function might fail if the
client was not registered.
int
prelude_client_init (prelude_client_t *client
);
This function initialize the client
object, meaning reading generic
options from the prelude_client_new()
provided configuration file
and the array of arguments specified through prelude_init()
.
Calling this function is optional and should be done only if you need more
granularity between prelude_client_new()
and prelude_client_start()
:
prelude_client_start() will call prelude_client_init()
for you if needed.
int prelude_client_new (prelude_client_t **client
,const char *profile
);
This function initialize the client
object.
idmef_analyzer_t *
prelude_client_get_analyzer (prelude_client_t *client
);
Provide access to the idmef_analyzer_t object associated to client
.
This analyzer object is sent along with every alerts and heartbeats emited
by this client. The analyzer object is created by prelude_client_init()
.
prelude_client_flags_t
prelude_client_get_flags (prelude_client_t *client
);
Get flags set through prelude_client_set_flags()
.
void prelude_client_set_required_permission (prelude_client_t *client
,prelude_connection_permission_t permission
);
Set the required permission
for client
.
The default is PRELUDE_CONNECTION_PERMISSION_IDMEF_WRITE | PRELUDE_CONNECTION_PERMISSION_ADMIN_READ.
Value set through this function should be set before prelude_client_start()
.
If the client certificate for connecting to one of the specified manager doesn't have theses permission the client will reject the certificate and ask for registration.
prelude_connection_permission_t
prelude_client_get_required_permission
(prelude_client_t *client
);
void prelude_client_send_msg (prelude_client_t *client
,prelude_msg_t *msg
);
Send msg
to the peers client
is communicating with.
The message will be sent asynchronously if PRELUDE_CLIENT_FLAGS_ASYNC_SEND
was set using prelude_client_set_flags()
in which case the caller should
not call prelude_msg_destroy()
on msg
.
client |
Pointer to a prelude_client_t object. |
|
msg |
pointer to a message that |
int prelude_client_recv_msg (prelude_client_t *client
,int timeout
,prelude_msg_t **msg
);
Wait timeout
second for a message on client
connection pool.
A timeout
of -1, mean prelude_client_recv_msg()
will block until
a message is received. A timeout
of 0 mean that it will return
immediatly.
client |
Pointer to a prelude_client_t object. |
|
timeout |
Number of millisecond to wait for a message. |
|
msg |
Pointer where the received prelude_msg_t should be stored. |
void prelude_client_set_heartbeat_cb (prelude_client_t *client
,void (*cb) (prelude_client_t *client, idmef_message_t *hb)
);
Use if you want to override the default function used to
automatically send heartbeat to client
peers.
client |
pointer to a prelude_client_t object. |
|
cb |
pointer to a function handling heartbeat sending. |
void prelude_client_send_idmef (prelude_client_t *client
,idmef_message_t *msg
);
Send msg
to the peers client
is communicating with.
The message will be sent asynchronously if PRELUDE_CLIENT_FLAGS_ASYNC_SEND
was set using prelude_client_set_flags()
.
client |
Pointer to a prelude_client_t object. |
|
msg |
pointer to an IDMEF message to be sent to |
int prelude_client_recv_idmef (prelude_client_t *client
,int timeout
,idmef_message_t **idmef
);
Wait timeout
second for a message on client
connection pool.
A timeout
of -1, mean prelude_client_recv_idmef()
will block until
a message is received. A timeout
of 0 mean that it will return
immediatly.
client |
Pointer to a prelude_client_t object. |
|
timeout |
Number of second to wait for a message. |
|
idmef |
Pointer where the received idmef_message_t should be stored. |
void prelude_client_destroy (prelude_client_t *client
,prelude_client_exit_status_t status
);
Destroy client
, and send an heartbeat containing the 'exiting'
status in case status
is PRELUDE_CLIENT_EXIT_STATUS_SUCCESS.
This is useful for analyzer expected to be running periodically, and that shouldn't be treated as behaving anormaly in case no heartbeat is sent.
Please note that your are not supposed to run this function from a signal handler.
int prelude_client_set_flags (prelude_client_t *client
,prelude_client_flags_t flags
);
Set specific flags in the client
structure.
This function can be called anytime after the creation of the
client
object.
When settings asynchronous flags such as PRELUDE_CLIENT_FLAGS_ASYNC_SEND
or PRELUDE_CLIENT_FLAGS_ASYNC_TIMER, be carefull to call
prelude_client_set_flags()
in the same process you want to use the
asynchronous API from. Threads aren't copied accross fork()
.
int prelude_client_set_config_filename (prelude_client_t *client
,const char *filename
);
The default for a client is to use a template configuration file (idmef-client.conf).
By using this function you might override the default and provide your own
configuration file to use for client
. The format of the configuration file need
to be compatible with the Prelude format.
client |
pointer on a prelude_client_t object. |
|
filename |
Configuration file to use for this client. |
const char *
prelude_client_get_config_filename (prelude_client_t *client
);
Return the filename where client
configuration is stored.
This filename is originally set by the prelude_client_new()
function.
prelude_bool_t
prelude_client_is_setup_needed (int error
);
prelude_client_is_setup_needed
is deprecated and should not be used in newly-written code.
use standard error API.
This function should be called as a result of an error by
the prelude_client_start()
function, to know if the analyzer
need to be registered.
prelude_client_profile_t *
prelude_client_get_profile (prelude_client_t *client
);
int prelude_client_new_msgbuf (prelude_client_t *client
,prelude_msgbuf_t **msgbuf
);
int prelude_client_handle_msg_default (prelude_client_t *client
,prelude_msg_t *msg
,prelude_msgbuf_t *msgbuf
);
const char *
prelude_client_get_setup_error (prelude_client_t *client
);
prelude_client_get_setup_error
is deprecated and should not be used in newly-written code.
void
prelude_client_print_setup_error (prelude_client_t *client
);