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>
7 #include <event2/util.h>
9 #if defined(RS_ENABLE_TLS)
10 #include <openssl/ssl.h>
14 #define RS_HEADER_LEN 4
19 RS_CRED_TLS_PSK_RSA, /* RFC 4279. */
21 typedef unsigned int rs_cred_type_t;
23 #if defined (__cplusplus)
27 struct rs_credentials {
28 enum rs_cred_type type;
39 struct rs_peer { /* Config object for a connection. */
40 struct rs_connection *conn;
41 struct rs_realm *realm;
42 struct evutil_addrinfo *addr;
47 struct rs_realm { /* Config object for a RADIUS realm. */
49 enum rs_conn_type type;
56 struct rs_peer *peers;
57 struct rs_realm *next;
61 struct rs_realm *realms;
62 struct rs_alloc_scheme alloc_scheme;
64 fr_randctx fr_randctx;
68 struct rs_connection {
69 struct rs_context *ctx;
70 struct rs_realm *realm; /* Owned by ctx. */
71 struct event_base *evb; /* Event base. */
72 struct bufferevent *bev; /* Buffer event. */
73 struct event *tev; /* Timeout event. */
74 struct rs_credentials transport_credentials;
75 struct rs_conn_callbacks callbacks;
77 struct rs_peer *peers;
78 struct rs_peer *active_peer;
80 char is_connecting; /* FIXME: replace with a single state member */
81 char is_connected; /* FIXME: replace with a single state member */
85 int user_dispatch_flag : 1; /* User does the dispatching. */
86 #if defined(RS_ENABLE_TLS)
93 struct rs_connection *conn;
97 struct rs_packet *original;
103 struct rs_packet *pkt;
107 /* Nonpublic functions. */
108 struct rs_error *_rs_resolv(struct evutil_addrinfo **addr,
109 rs_conn_type_t type, const char *hostname,
110 const char *service);
111 struct rs_peer *_rs_peer_create(struct rs_context *ctx,
112 struct rs_peer **rootp);
113 struct rs_error *_rs_err_create(unsigned int code, const char *file,
114 int line, const char *fmt, ...);
115 int _rs_err_conn_push_err(struct rs_connection *conn,
116 struct rs_error *err);
119 #if defined (__cplusplus)
123 /* Convenience macros. */
124 #define rs_calloc(h, nmemb, size) \
125 (h->alloc_scheme.calloc ? h->alloc_scheme.calloc : calloc)(nmemb, size)
126 #define rs_malloc(h, size) \
127 (h->alloc_scheme.malloc ? h->alloc_scheme.malloc : malloc)(size)
128 #define rs_free(h, ptr) \
129 (h->alloc_scheme.free ? h->alloc_scheme.free : free)(ptr)
130 #define rs_realloc(h, realloc, ptr, size) \
131 (h->alloc_scheme.realloc ? h->alloc_scheme.realloc : realloc)(ptr, size)
132 #define min(a, b) ((a) < (b) ? (a) : (b))
133 #define max(a, b) ((a) > (b) ? (a) : (b))
135 /* Local Variables: */
136 /* c-file-style: "stroustrup" */