629e7e102870add98fdf6efaed46a088e92cd554
[radsecproxy.git] / lib / libradsec.h
1 /** @file libradsec.h
2     @brief Header file for libradsec.  */
3 /* See the file COPYING for licensing information.  */
4
5 #include <unistd.h>
6
7 enum rs_err_code {
8     RSE_OK = 0,
9     RSE_NOMEM = 1,
10     RSE_NOSYS = 2,
11     RSE_INVALID_CTX = 3,
12     RSE_INVALID_CONN = 4,
13     RSE_SOME_ERROR = 21
14 };
15
16 enum rs_conn_type {
17     RS_CONN_TYPE_UDP = 0,
18     RS_CONN_TYPE_TCP,
19     RS_CONN_TYPE_TLS,
20     RS_CONN_TYPE_DTLS,
21 };
22 typedef unsigned int rs_conn_type_t;
23
24
25 /* Data types.  */
26 struct rs_handle;               /* radsec-impl.h */
27 struct rs_alloc_scheme;         /* radsec-impl.h */
28 struct rs_connection;           /* radsec-impl.h */
29 struct rs_conn_callbacks;       /* radsec-impl.h */
30 struct rs_packet;               /* radsec-impl.h */
31 struct rs_conn;                 /* radsec-impl.h */
32 struct rs_attr;                 /* radsec-impl.h */
33 struct rs_error;                /* radsec-impl.h */
34 struct event_base;              /* <event.h> */
35
36 /* Function prototypes.  */
37 int rs_context_create(struct rs_handle **ctx, const char *dict);
38 void rs_context_destroy(struct rs_handle *ctx);
39 int rs_context_set_alloc_scheme(struct rs_handle *ctx, struct rs_alloc_scheme *scheme);
40 int rs_context_config_read(struct rs_handle *ctx, const char *config_file);
41
42 int rs_conn_create(const struct rs_handle *ctx, struct rs_connection **conn);
43 int rs_conn_add_server(struct rs_connection  *conn, rs_conn_type_t type, const char *host, int port, int timeout, int tries, const char *secret);
44 int rs_conn_add_listener(struct rs_connection  *conn, rs_conn_type_t type, const char *host, int port, const char *secret);
45 int rs_conn_destroy(struct rs_connection  *conn);
46 int rs_conn_set_eventbase(struct rs_connection *conn, struct event_base *eb);
47 int rs_conn_set_callbacks(struct rs_connection *conn, struct rs_conn_callbacks *cb);
48 int rs_conn_set_server(struct rs_connection *conn, const char *name);
49 int rs_conn_get_server(const struct rs_connection *conn, const char *name, size_t buflen); /* NAME <-- most recent server we spoke to */
50
51 int rs_packet_create_acc_request(struct rs_connection *conn, struct rs_packet **pkt, const char *user_name, const char *user_pw);
52 //int rs_packet_create_acc_accept(cstruct rs_connection *conn, struct rs_packet **pkt);
53 //int rs_packet_create_acc_reject(struct rs_connection *conn, struct rs_packet **pkt);
54 //int rs_packet_create_acc_challenge(struct rs_connection *conn, struct rs_packet **pkt);
55 void rs_packet_destroy(struct rs_packet *pkt);
56 int rs_packet_add_attr(struct rs_packet *pkt, const struct rs_attr *attr);
57 //int rs_packet_add_new_attr(struct rs_packet *pkt, const char *attr_name, const char *attr_val);
58
59 int rs_attr_create(struct rs_connection *conn, struct rs_attr **attr, const char *type, const char *val);
60 void rs_attr_destroy(struct rs_attr *attr);
61
62 int rs_packet_send(struct rs_conn *conn, const struct rs_packet *pkt, void *user_data);
63 int rs_packet_receive(struct rs_conn *conn, struct rs_packet **pkt);
64
65
66 int rs_ctx_err_push (struct rs_handle *ctx, int code, const char *msg);
67 int rs_conn_err_push (struct rs_connection *conn, int code, const char *msg);
68 struct rs_error *rs_ctx_err_pop (struct rs_handle *ctx);
69 struct rs_error *rs_conn_err_pop (struct rs_connection *conn);
70 void rs_err_free (struct rs_error *err);
71 char *rs_err_msg (struct rs_error *err);
72 int rs_err_code (struct rs_error *err);
73
74 /* Local Variables: */
75 /* c-file-style: "stroustrup" */
76 /* End: */
77
78
79
80 /* Local Variables: */
81 /* c-file-style: "stroustrup" */
82 /* End: */