prelude-connection: libprelude Reference Manual

## prelude-connection prelude-connection |

## Functions

void | prelude_connection_destroy ()
int | prelude_connection_send ()
int | prelude_connection_recv ()
int | prelude_connection_recv_idmef ()
int | prelude_connection_connect ()
ssize_t | prelude_connection_forward ()
const char * | prelude_connection_get_local_addr ()
unsigned int | prelude_connection_get_local_port ()
const char * | prelude_connection_get_peer_addr ()
unsigned int | prelude_connection_get_peer_port ()
prelude_bool_t | prelude_connection_is_alive ()
prelude_io_t * | prelude_connection_get_fd ()
int | prelude_connection_close ()
void | prelude_connection_set_fd_ref ()
void | prelude_connection_set_fd_nodup ()
void | prelude_connection_set_state ()
prelude_connection_state_t | prelude_connection_get_state ()
void | prelude_connection_set_data ()
void * | prelude_connection_get_data ()
const char * | prelude_connection_get_default_socket_filename ()
prelude_connection_permission_t | prelude_connection_get_permission ()
uint64_t | prelude_connection_get_peer_analyzerid ()
void | prelude_connection_set_peer_analyzerid ()
int | prelude_connection_new ()
prelude_connection_t * | prelude_connection_ref ()
int | prelude_connection_new_msgbuf ()
int | prelude_connection_permission_to_string ()
int | prelude_connection_permission_new_from_string ()

## Types and Values

enum | prelude_connection_permission_t
enum | prelude_connection_state_t
typedef | prelude_connection_t

## Description

## Functions

### prelude_connection_destroy ()

    void
    prelude_connection_destroy (prelude_connection_t *conn);

Destroy the connection referenced by `conn` .

In case the connection is still alive, it is closed in a blocking manner. Use `prelude_connection_close()` if you want to close the connection in a non blocking manner prior `prelude_connection_destroy()`.

#### Parameters

conn | Pointer to a prelude_connection_t object. |

### prelude_connection_send ()

    int
    prelude_connection_send (prelude_connection_t *cnx,
                             prelude_msg_t *msg);

### prelude_connection_recv ()

    int
    prelude_connection_recv (prelude_connection_t *cnx,
                             prelude_msg_t **outmsg);

### prelude_connection_recv_idmef ()

    int
    prelude_connection_recv_idmef (prelude_connection_t *con,
                                   idmef_message_t **idmef);

### prelude_connection_connect ()

    int
    prelude_connection_connect (prelude_connection_t *cnx,
                                prelude_client_profile_t *profile,
                                prelude_connection_permission_t permission);

### prelude_connection_forward ()

    ssize_t
    prelude_connection_forward (prelude_connection_t *cnx,
                                prelude_io_t *src,
                                size_t count);

### prelude_connection_get_local_addr ()

    const char *
    prelude_connection_get_local_addr (prelude_connection_t *cnx);

#### Parameters

cnx | Pointer to a prelude_connection_t object. |

#### Returns

the local address used to connect.

### prelude_connection_get_local_port ()

    unsigned int
    prelude_connection_get_local_port (prelude_connection_t *cnx);

#### Parameters

cnx | Pointer to a prelude_connection_t object. |

#### Returns

the local port used to connect.

### prelude_connection_get_peer_addr ()

    const char *
    prelude_connection_get_peer_addr (prelude_connection_t *cnx);

### prelude_connection_get_peer_port ()

    unsigned int
    prelude_connection_get_peer_port (prelude_connection_t *cnx);

### prelude_connection_is_alive ()

    prelude_bool_t
    prelude_connection_is_alive (prelude_connection_t *cnx);

#### Parameters

cnx | Pointer to a prelude_connection_t object. |

#### Returns

0 if the connection associated with `cnx` is alive, -1 otherwise.

### prelude_connection_get_fd ()

    prelude_io_t *
    prelude_connection_get_fd (prelude_connection_t *cnx);

#### Parameters

cnx | Pointer to a prelude_connection_t object. |

#### Returns

A pointer to the prelude_io_t object used for communicating with the peer.

### prelude_connection_close ()

    int
    prelude_connection_close (prelude_connection_t *cnx);

### prelude_connection_set_fd_ref ()

    void
    prelude_connection_set_fd_ref (prelude_connection_t *cnx,
                                   prelude_io_t *fd);

### prelude_connection_set_fd_nodup ()

    void
    prelude_connection_set_fd_nodup (prelude_connection_t *cnx,
                                     prelude_io_t *fd);

### prelude_connection_set_state ()

    void
    prelude_connection_set_state (prelude_connection_t *cnx,
                                  prelude_connection_state_t state);

### prelude_connection_get_state ()

    prelude_connection_state_t
    prelude_connection_get_state (prelude_connection_t *cnx);

### prelude_connection_set_data ()

    void
    prelude_connection_set_data (prelude_connection_t *cnx,
                                 void *data);

### prelude_connection_get_data ()

    void *
    prelude_connection_get_data (prelude_connection_t *cnx);

### prelude_connection_get_default_socket_filename ()

    const char *
    prelude_connection_get_default_socket_filename
                                   (void);

### prelude_connection_get_permission ()

    prelude_connection_permission_t
    prelude_connection_get_permission (prelude_connection_t *conn);

### prelude_connection_get_peer_analyzerid ()

    uint64_t
    prelude_connection_get_peer_analyzerid
                                   (prelude_connection_t *cnx);

### prelude_connection_set_peer_analyzerid ()

    void
    prelude_connection_set_peer_analyzerid
                                   (prelude_connection_t *cnx,
                                    uint64_t analyzerid);

### prelude_connection_new ()

    int
    prelude_connection_new (prelude_connection_t **ret,
                            const char *addr);

### prelude_connection_ref ()

    prelude_connection_t *
    prelude_connection_ref (prelude_connection_t *conn);

Increases `conn` reference count.

prelude_connection_destroy() will decrease the refcount until it reaches 0, at which point `conn` will be destroyed.

#### Parameters

conn | Pointer to a prelude_connection_t object to reference. |

#### Returns

`conn` .

### prelude_connection_new_msgbuf ()

    int
    prelude_connection_new_msgbuf (prelude_connection_t *connection,
                                   prelude_msgbuf_t **msgbuf);

### prelude_connection_permission_to_string ()

    int
    prelude_connection_permission_to_string
                                   (prelude_connection_permission_t perm,
                                    prelude_string_t *out);

### prelude_connection_permission_new_from_string ()

    int
    prelude_connection_permission_new_from_string
                                   (prelude_connection_permission_t *out,
                                    const char *buf);

## Types and Values

### enum prelude_connection_permission_t

#### Members

PRELUDE_CONNECTION_PERMISSION_IDMEF_READ |  |
PRELUDE_CONNECTION_PERMISSION_ADMIN_READ |  |
PRELUDE_CONNECTION_PERMISSION_IDMEF_WRITE |  |
PRELUDE_CONNECTION_PERMISSION_ADMIN_WRITE |  |

### enum prelude_connection_state_t

#### Members

PRELUDE_CONNECTION_STATE_ESTABLISHED |  |

### prelude_connection_t

    typedef struct prelude_connection prelude_connection_t;