1 /** @file libradsec-impl.h
2 @brief Libraray internal header file for libradsec. */
4 /* See the file COPYING for licensing information. */
6 #include <freeradius/libradius.h>
9 #define RS_HEADER_LEN 4
14 RS_CRED_TLS_PSK_RSA, /* RFC 4279. */
16 typedef unsigned int rs_cred_type_t;
20 struct rs_credentials {
21 enum rs_cred_type type;
32 typedef void * (*rs_calloc_fp)(size_t nmemb, size_t size);
33 typedef void * (*rs_malloc_fp)(size_t size);
34 typedef void (*rs_free_fp)(void *ptr);
35 typedef void * (*rs_realloc_fp)(void *ptr, size_t size);
36 struct rs_alloc_scheme {
40 rs_realloc_fp realloc;
43 typedef void (*rs_conn_connected_cb)(void *user_data /* FIXME: peer? */);
44 typedef void (*rs_conn_disconnected_cb)(void *user_data /* FIXME: reason? */);
45 typedef void (*rs_conn_packet_received_cb)(const struct rs_packet *packet,
47 typedef void (*rs_conn_packet_sent_cb)(void *user_data);
49 /** Connection callbacks. */
50 struct rs_conn_callbacks {
51 /** Callback invoked when the connection has been established. */
52 rs_conn_connected_cb connected_cb;
53 /** Callback invoked when the connection has been torn down. */
54 rs_conn_disconnected_cb disconnected_cb;
55 /** Callback invoked when a packet was received. */
56 rs_conn_packet_received_cb received_cb;
57 /** Callback invoked when a packet was successfully sent. */
58 rs_conn_packet_sent_cb sent_cb;
62 struct rs_alloc_scheme alloc_scheme;
64 fr_randctx fr_randctx;
66 /* TODO: dictionary? */
70 struct rs_connection *conn;
71 struct addrinfo *addr;
73 int timeout; /* client only */
74 int tries; /* client only */
78 struct rs_connection {
79 struct rs_handle *ctx;
80 enum rs_conn_type type;
81 struct rs_credentials transport_credentials;
82 struct rs_conn_callbacks callbacks;
84 struct rs_peer *active_peer;
89 struct rs_connection *conn;
94 struct rs_packet *pkt;
98 /* Internal functions. */
99 int rs_conn_open(struct rs_connection *conn);
101 /* Convenience macros. */
102 #define rs_calloc(h, nmemb, size) \
103 (h->alloc_scheme.calloc ? h->alloc_scheme.calloc : calloc)(nmemb, size)
104 #define rs_malloc(h, size) \
105 (h->alloc_scheme.malloc ? h->alloc_scheme.malloc : malloc)(size)
106 #define rs_free(h, ptr) \
107 (h->alloc_scheme.free ? h->alloc_scheme.free : free)(ptr)
108 #define rs_realloc(h, realloc, ptr, size) \
109 (h->alloc_scheme.realloc ? h->alloc_scheme.realloc : realloc)(ptr, size)
111 /* Local Variables: */
112 /* c-file-style: "stroustrup" */