diff options
Diffstat (limited to 'lib/libradsec.h')
-rw-r--r-- | lib/libradsec.h | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/libradsec.h b/lib/libradsec.h index 2ccafe2..29fb1f6 100644 --- a/lib/libradsec.h +++ b/lib/libradsec.h @@ -31,9 +31,7 @@ typedef unsigned int rs_conn_type_t; /* Data types. */ struct rs_handle; /* radsec-impl.h */ -struct rs_alloc_scheme; /* radsec-impl.h */ struct rs_connection; /* radsec-impl.h */ -struct rs_conn_callbacks; /* radsec-impl.h */ struct rs_packet; /* radsec-impl.h */ struct rs_conn; /* radsec-impl.h */ struct rs_attr; /* radsec-impl.h */ @@ -41,6 +39,33 @@ struct rs_error; /* radsec-impl.h */ struct rs_peer; /* radsec-impl.h */ struct event_base; /* <event.h> */ +typedef void * (*rs_calloc_fp)(size_t nmemb, size_t size); +typedef void * (*rs_malloc_fp)(size_t size); +typedef void (*rs_free_fp)(void *ptr); +typedef void * (*rs_realloc_fp)(void *ptr, size_t size); +struct rs_alloc_scheme { + rs_calloc_fp calloc; + rs_malloc_fp malloc; + rs_free_fp free; + rs_realloc_fp realloc; +}; + +typedef void (*rs_conn_connected_cb)(void *user_data /* FIXME: peer? */); +typedef void (*rs_conn_disconnected_cb)(void *user_data /* FIXME: reason? */); +typedef void (*rs_conn_packet_received_cb)(const struct rs_packet *packet, + void *user_data); +typedef void (*rs_conn_packet_sent_cb)(void *user_data); +struct rs_conn_callbacks { + /** Callback invoked when the connection has been established. */ + rs_conn_connected_cb connected_cb; + /** Callback invoked when the connection has been torn down. */ + rs_conn_disconnected_cb disconnected_cb; + /** Callback invoked when a packet was received. */ + rs_conn_packet_received_cb received_cb; + /** Callback invoked when a packet was successfully sent. */ + rs_conn_packet_sent_cb sent_cb; +}; + /* Function prototypes. */ int rs_context_create(struct rs_handle **ctx, const char *dict); void rs_context_destroy(struct rs_handle *ctx); @@ -72,7 +97,7 @@ int rs_attr_create(struct rs_connection *conn, struct rs_attr **attr, const char void rs_attr_destroy(struct rs_attr *attr); int rs_packet_send(struct rs_connection *conn, struct rs_packet *pkt, void *data); -int rs_packet_recv(struct rs_connection *conn, struct rs_packet **pkt); +int rs_packet_receive(struct rs_connection *conn, struct rs_packet **pkt_out); int rs_ctx_err_push(struct rs_handle *ctx, int code, const char *fmt, ...); int rs_ctx_err_push_fl(struct rs_handle *ctx, int code, const char *file, int line, const char *fmt, ...); |