* Design of the libraray
* Features
** Not implemented
+- reading config file
+- server fail over
+- resending packets
+- matching responses
+- TLS, DTLS
+- TLS PSK
+- autoconf/automake/libtool
** Not tested
- short read
- short write
libradsec.a: $(OFILES)
ar rc $@ $^
+$(OFILES): libradsec.h libradsec-impl.h
+
doc:
doxygen
+/* See the file COPYING for licensing information. */
+
#include <freeradius/libradius.h>
#include "libradsec.h"
#include "libradsec-impl.h"
+/* See the file COPYING for licensing information. */
+
#include <stdio.h>
#include <freeradius/libradius.h>
#include "libradsec.h"
+/* See the file COPYING for licensing information. */
+
#define hd(p, l) { int i; \
for (i = 1; i <= l; i++) { \
printf ("%02x ", p[i-1]); \
+/* See the file COPYING for licensing information. */
+
#include <stdio.h>
#include <string.h>
#include <assert.h>
rs_conn_packet_sent_cb sent_cb;
};
+
/* Function prototypes. */
+/* Context. */
int rs_context_create(struct rs_handle **ctx, const char *dict);
void rs_context_destroy(struct rs_handle *ctx);
int rs_context_set_alloc_scheme(struct rs_handle *ctx, struct rs_alloc_scheme *scheme);
int rs_context_config_read(struct rs_handle *ctx, const char *config_file);
+/* Connection. */
int rs_conn_create(struct rs_handle *ctx, struct rs_connection **conn);
int rs_conn_add_server(struct rs_connection *conn, struct rs_peer **server, rs_conn_type_t type, const char *hostname, int port);
int rs_conn_add_listener(struct rs_connection *conn, rs_conn_type_t type, const char *hostname, int port);
int rs_conn_select_server(struct rs_connection *conn, const char *name);
int rs_conn_get_current_server(struct rs_connection *conn, const char *name, size_t buflen);
+/* Server and client configuration. */
void rs_server_set_timeout(struct rs_peer *server, int timeout);
void rs_server_set_tries(struct rs_peer *server, int tries);
int rs_server_set_secret(struct rs_peer *server, const char *secret);
+/* Packet. */
int rs_packet_create_acc_request(struct rs_connection *conn, struct rs_packet **pkt, const char *user_name, const char *user_pw);
//int rs_packet_create_acc_accept(cstruct rs_connection *conn, struct rs_packet **pkt);
//int rs_packet_create_acc_reject(struct rs_connection *conn, struct rs_packet **pkt);
//int rs_packet_create_acc_challenge(struct rs_connection *conn, struct rs_packet **pkt);
void rs_packet_destroy(struct rs_packet *pkt);
void rs_packet_add_attr(struct rs_packet *pkt, struct rs_attr *attr);
-//int rs_packet_add_new_attr(struct rs_packet *pkt, const char *attr_name, const char *attr_val);
+int rs_packet_send(struct rs_connection *conn, struct rs_packet *pkt, void *data);
+int rs_packet_receive(struct rs_connection *conn, struct rs_packet **pkt_out);
+/* Attribute. */
int rs_attr_create(struct rs_connection *conn, struct rs_attr **attr, const char *type, const char *val);
void rs_attr_destroy(struct rs_attr *attr);
-int rs_packet_send(struct rs_connection *conn, struct rs_packet *pkt, void *data);
-int rs_packet_receive(struct rs_connection *conn, struct rs_packet **pkt_out);
-
+/* Error. */
int rs_ctx_err_push(struct rs_handle *ctx, int code, const char *fmt, ...);
int rs_ctx_err_push_fl(struct rs_handle *ctx, int code, const char *file, int line, const char *fmt, ...);
struct rs_error *rs_ctx_err_pop (struct rs_handle *ctx);
+/* See the file COPYING for licensing information. */
+
#include <string.h>
#include <assert.h>
#include <freeradius/libradius.h>
assert (pkt->conn);
if (!pkt->hdr_read_flag)
{
- n = bufferevent_read (pkt->conn->bev, pkt->hdr, 4);
- if (n == 4)
+ n = bufferevent_read (pkt->conn->bev, pkt->hdr, RS_HEADER_LEN;
+ if (n == RS_HEADER_LEN)
{
uint16_t len = (pkt->hdr[2] << 8) + pkt->hdr[3];
uint8_t *buf = rs_malloc (pkt->conn->ctx, len);
}
pkt->rpkt->data = buf;
pkt->rpkt->data_len = len;
- bufferevent_setwatermark (pkt->conn->bev, EV_READ, len - 4, 0);
+ bufferevent_setwatermark (pkt->conn->bev, EV_READ,
+ len - RS_HEADER_LEN, 0);
#if defined (DEBUG)
fprintf (stderr, "%s: packet header read, pkt len=%d\n", __func__,
len);
return; /* Buffer frozen, i suppose. Let's hope it thaws. */
else
{
- assert (n < 4);
+ assert (n < RS_HEADER_LEN);
return; /* Need more to complete header. */
}
}
- printf ("%s: trying to read %d octets of packet data\n", __func__, pkt->rpkt->data_len - 4);
- n = bufferevent_read (pkt->conn->bev, pkt->rpkt->data, pkt->rpkt->data_len - 4);
+ printf ("%s: trying to read %d octets of packet data\n", __func__, pkt->rpkt->data_len - RS_HEADER_LEN;
+ n = bufferevent_read (pkt->conn->bev, pkt->rpkt->data,
+ pkt->rpkt->data_len - RS_HEADER_LEN);
printf ("%s: read %d octets of packet data\n", __func__, n);
- if (n == pkt->rpkt->data_len - 4)
+ if (n == pkt->rpkt->data_len - RS_HEADER_LEN)
{
bufferevent_disable (pkt->conn->bev, EV_READ);
pkt->hdr_read_flag = 0;
assert (conn->active_peer);
assert (conn->active_peer->s >= 0);
- bufferevent_setwatermark (conn->bev, EV_READ, 4, 0);
+ bufferevent_setwatermark (conn->bev, EV_READ, RS_HEADER_LEN, 0);
bufferevent_enable (conn->bev, EV_READ);
event_base_dispatch (conn->evb);
#if defined (DEBUG)
+/* See the file COPYING for licensing information. */
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>