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;
24 struct rs_credentials {
25 enum rs_cred_type type;
37 struct rs_connection *conn;
38 struct rs_realm *realm;
39 struct evutil_addrinfo *addr;
41 char is_connecting; /* FIXME: replace with a single state member */
42 char is_connected; /* FIXME: replace with a single state member */
44 int timeout; /* client only */
45 int tries; /* client only */
51 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;
67 struct rs_connection {
68 struct rs_context *ctx;
69 struct event_base *evb;
70 struct bufferevent *bev;
71 enum rs_conn_type type;
72 struct rs_credentials transport_credentials;
73 struct rs_conn_callbacks callbacks;
75 struct rs_peer *peers;
76 struct rs_peer *active_peer;
79 int user_dispatch_flag : 1; /* User does the dispatching. */
80 #if defined(RS_ENABLE_TLS)
87 struct rs_connection *conn;
91 struct rs_packet *original;
95 struct rs_packet *pkt;
99 /* Nonpublic functions. */
100 struct rs_error *_rs_resolv(struct evutil_addrinfo **addr,
101 rs_conn_type_t type, const char *hostname,
102 const char *service);
103 struct rs_peer *_rs_peer_create(struct rs_context *ctx,
104 struct rs_peer **rootp);
105 struct rs_error *_rs_err_create(unsigned int code, const char *file,
106 int line, const char *fmt, ...);
107 int _rs_err_conn_push_err(struct rs_connection *conn,
108 struct rs_error *err);
111 /* Convenience macros. */
112 #define rs_calloc(h, nmemb, size) \
113 (h->alloc_scheme.calloc ? h->alloc_scheme.calloc : calloc)(nmemb, size)
114 #define rs_malloc(h, size) \
115 (h->alloc_scheme.malloc ? h->alloc_scheme.malloc : malloc)(size)
116 #define rs_free(h, ptr) \
117 (h->alloc_scheme.free ? h->alloc_scheme.free : free)(ptr)
118 #define rs_realloc(h, realloc, ptr, size) \
119 (h->alloc_scheme.realloc ? h->alloc_scheme.realloc : realloc)(ptr, size)
121 /* Local Variables: */
122 /* c-file-style: "stroustrup" */