diff options
Diffstat (limited to 'lib/include/radsec')
-rw-r--r-- | lib/include/radsec/radsec-impl.h | 44 | ||||
-rw-r--r-- | lib/include/radsec/radsec.h | 14 | ||||
-rw-r--r-- | lib/include/radsec/request-impl.h | 1 |
3 files changed, 33 insertions, 26 deletions
diff --git a/lib/include/radsec/radsec-impl.h b/lib/include/radsec/radsec-impl.h index 963c821..9bcd208 100644 --- a/lib/include/radsec/radsec-impl.h +++ b/lib/include/radsec/radsec-impl.h @@ -32,7 +32,6 @@ struct rs_credentials { struct rs_error { int code; - char *msg; char buf[1024]; }; @@ -69,7 +68,6 @@ struct rs_connection { struct rs_context *ctx; struct rs_realm *realm; /* Owned by ctx. */ struct event_base *evb; /* Event base. */ - struct bufferevent *bev; /* Buffer event. */ struct event *tev; /* Timeout event. */ struct rs_credentials transport_credentials; struct rs_conn_callbacks callbacks; @@ -77,26 +75,37 @@ struct rs_connection { struct rs_peer *peers; struct rs_peer *active_peer; struct rs_error *err; + struct timeval timeout; char is_connecting; /* FIXME: replace with a single state member */ char is_connected; /* FIXME: replace with a single state member */ int fd; /* Socket. */ - int tryagain; - int nextid; - int user_dispatch_flag : 1; /* User does the dispatching. */ + int tryagain; /* For server failover. */ + int nextid; /* Next RADIUS packet identifier. */ + /* TCP transport specifics. */ + struct bufferevent *bev; /* Buffer event. */ + /* UDP transport specifics. */ + struct event *wev; /* Write event (for UDP). */ + struct event *rev; /* Read event (for UDP). */ + struct rs_packet *out_queue; /* Queue for outgoing UDP packets. */ #if defined(RS_ENABLE_TLS) + /* TLS specifics. */ SSL_CTX *tls_ctx; SSL *tls_ssl; #endif }; +enum rs_packet_flags { + rs_packet_hdr_read_flag, + rs_packet_received_flag, + rs_packet_sent_flag, +}; + struct rs_packet { struct rs_connection *conn; - char hdr_read_flag; - uint8_t hdr[4]; + unsigned int flags; + uint8_t hdr[RS_HEADER_LEN]; RADIUS_PACKET *rpkt; - struct rs_packet *original; - char valid_flag; - char written_flag; + struct rs_packet *next; /* Used for UDP output queue. */ }; struct rs_attr { @@ -104,18 +113,11 @@ struct rs_attr { VALUE_PAIR *vp; }; -/* Nonpublic functions. */ -struct rs_error *_rs_resolv(struct evutil_addrinfo **addr, - rs_conn_type_t type, const char *hostname, +/* Nonpublic functions (in radsec.c -- FIXME: move?). */ +struct rs_error *rs_resolv (struct evutil_addrinfo **addr, + rs_conn_type_t type, + const char *hostname, const char *service); -struct rs_peer *_rs_peer_create(struct rs_context *ctx, - struct rs_peer **rootp); -struct rs_error *_rs_err_create(unsigned int code, const char *file, - int line, const char *fmt, ...); -int _rs_err_conn_push_err(struct rs_connection *conn, - struct rs_error *err); - - #if defined (__cplusplus) } #endif diff --git a/lib/include/radsec/radsec.h b/lib/include/radsec/radsec.h index fcd391d..971fc17 100644 --- a/lib/include/radsec/radsec.h +++ b/lib/include/radsec/radsec.h @@ -3,8 +3,9 @@ /* See the file COPYING for licensing information. */ #include <unistd.h> +#include <sys/time.h> -enum rs_err_code { +enum rs_error_code { RSE_OK = 0, RSE_NOMEM = 1, RSE_NOSYS = 2, @@ -21,9 +22,11 @@ enum rs_err_code { RSE_INTERNAL = 13, RSE_SSLERR = 14, /* OpenSSL error. */ RSE_INVALID_PKT = 15, - RSE_TIMEOUT_CONN = 16, - RSE_INVAL = 17, - RSE_TIMEOUT_IO = 18, + RSE_TIMEOUT_CONN = 16, /* Connection timeout. */ + RSE_INVAL = 17, /* Invalid argument. */ + RSE_TIMEOUT_IO = 18, /* I/O timeout. */ + RSE_TIMEOUT = 19, /* High level timeout. */ + RSE_DISCO = 20, }; enum rs_conn_type { @@ -111,6 +114,7 @@ int rs_conn_receive_packet(struct rs_connection *conn, struct rs_packet *request, struct rs_packet **pkt_out); int rs_conn_fd(struct rs_connection *conn); +void rs_conn_set_timeout(struct rs_connection *conn, struct timeval *tv); /* Peer -- client and server. */ int rs_peer_create(struct rs_connection *conn, struct rs_peer **peer_out); @@ -164,7 +168,7 @@ int rs_err_conn_push_fl(struct rs_connection *conn, struct rs_error *rs_err_conn_pop(struct rs_connection *conn); int rs_err_conn_peek_code (struct rs_connection *conn); void rs_err_free(struct rs_error *err); -char *rs_err_msg(struct rs_error *err, int dofree_flag); +char *rs_err_msg(struct rs_error *err); int rs_err_code(struct rs_error *err, int dofree_flag); #if defined (__cplusplus) diff --git a/lib/include/radsec/request-impl.h b/lib/include/radsec/request-impl.h index 4f50d44..19aef66 100644 --- a/lib/include/radsec/request-impl.h +++ b/lib/include/radsec/request-impl.h @@ -11,6 +11,7 @@ struct rs_request struct rs_packet *req_msg; struct rs_packet *resp_msg; struct rs_conn_callbacks saved_cb; + void *saved_user_data; }; #if defined (__cplusplus) |