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>
8 #if defined(RS_ENABLE_TLS)
9 #include <openssl/ssl.h>
13 #define RS_HEADER_LEN 4
18 RS_CRED_TLS_PSK_RSA, /* RFC 4279. */
20 typedef unsigned int rs_cred_type_t;
22 #if defined (__cplusplus)
26 struct rs_credentials {
27 enum rs_cred_type type;
38 struct rs_peer { /* Config object for a connection. */
39 struct rs_connection *conn;
40 struct rs_realm *realm;
41 struct evutil_addrinfo *addr;
46 struct rs_realm { /* Config object for a RADIUS realm. */
48 enum rs_conn_type type;
55 struct rs_peer *peers;
56 struct rs_realm *next;
60 struct rs_realm *realms;
61 struct rs_alloc_scheme alloc_scheme;
63 fr_randctx fr_randctx;
66 struct rs_connection {
67 struct rs_context *ctx;
68 struct rs_realm *realm; /* Owned by ctx. */
69 struct event_base *evb; /* Event base. */
70 struct bufferevent *bev; /* Buffer event. */
71 struct event *tev; /* Timeout event. */
72 struct rs_credentials transport_credentials;
73 struct rs_conn_callbacks callbacks;
75 struct rs_peer *peers;
76 struct rs_peer *active_peer;
78 char is_connecting; /* FIXME: replace with a single state member */
79 char is_connected; /* FIXME: replace with a single state member */
83 int user_dispatch_flag : 1; /* User does the dispatching. */
84 #if defined(RS_ENABLE_TLS)
91 struct rs_connection *conn;
95 struct rs_packet *original;
101 struct rs_packet *pkt;
105 /* Nonpublic functions. */
106 struct rs_error *_rs_resolv(struct evutil_addrinfo **addr,
107 rs_conn_type_t type, const char *hostname,
108 const char *service);
109 struct rs_peer *_rs_peer_create(struct rs_context *ctx,
110 struct rs_peer **rootp);
111 struct rs_error *_rs_err_create(unsigned int code, const char *file,
112 int line, const char *fmt, ...);
113 int _rs_err_conn_push_err(struct rs_connection *conn,
114 struct rs_error *err);
117 #if defined (__cplusplus)
121 /* Convenience macros. */
122 #define rs_calloc(h, nmemb, size) \
123 (h->alloc_scheme.calloc ? h->alloc_scheme.calloc : calloc)(nmemb, size)
124 #define rs_malloc(h, size) \
125 (h->alloc_scheme.malloc ? h->alloc_scheme.malloc : malloc)(size)
126 #define rs_free(h, ptr) \
127 (h->alloc_scheme.free ? h->alloc_scheme.free : free)(ptr)
128 #define rs_realloc(h, realloc, ptr, size) \
129 (h->alloc_scheme.realloc ? h->alloc_scheme.realloc : realloc)(ptr, size)
130 #define min(a, b) ((a) < (b) ? (a) : (b))
131 #define max(a, b) ((a) > (b) ? (a) : (b))
133 /* Local Variables: */
134 /* c-file-style: "stroustrup" */