summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/HACKING7
-rw-r--r--lib/Makefile2
-rw-r--r--lib/attr.c2
-rw-r--r--lib/debug.c2
-rw-r--r--lib/debug.h2
-rw-r--r--lib/err.c2
-rw-r--r--lib/libradsec.h13
-rw-r--r--lib/packet.c20
-rw-r--r--lib/radsec.c2
9 files changed, 40 insertions, 12 deletions
diff --git a/lib/HACKING b/lib/HACKING
index cf42339..ed9717d 100644
--- a/lib/HACKING
+++ b/lib/HACKING
@@ -2,6 +2,13 @@ HACKING file for libradsec (in Emacs -*- org -*- mode).
* 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
diff --git a/lib/Makefile b/lib/Makefile
index ed4af51..1b26f04 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -11,6 +11,8 @@ all: libradsec.a
libradsec.a: $(OFILES)
ar rc $@ $^
+$(OFILES): libradsec.h libradsec-impl.h
+
doc:
doxygen
diff --git a/lib/attr.c b/lib/attr.c
index 4bd44f7..0b1542e 100644
--- a/lib/attr.c
+++ b/lib/attr.c
@@ -1,3 +1,5 @@
+/* See the file COPYING for licensing information. */
+
#include <freeradius/libradius.h>
#include "libradsec.h"
#include "libradsec-impl.h"
diff --git a/lib/debug.c b/lib/debug.c
index 34f4885..d2d8d9c 100644
--- a/lib/debug.c
+++ b/lib/debug.c
@@ -1,3 +1,5 @@
+/* See the file COPYING for licensing information. */
+
#include <stdio.h>
#include <freeradius/libradius.h>
#include "libradsec.h"
diff --git a/lib/debug.h b/lib/debug.h
index a541555..1dada4e 100644
--- a/lib/debug.h
+++ b/lib/debug.h
@@ -1,3 +1,5 @@
+/* See the file COPYING for licensing information. */
+
#define hd(p, l) { int i; \
for (i = 1; i <= l; i++) { \
printf ("%02x ", p[i-1]); \
diff --git a/lib/err.c b/lib/err.c
index 4c88ce1..f81644a 100644
--- a/lib/err.c
+++ b/lib/err.c
@@ -1,3 +1,5 @@
+/* See the file COPYING for licensing information. */
+
#include <stdio.h>
#include <string.h>
#include <assert.h>
diff --git a/lib/libradsec.h b/lib/libradsec.h
index 29fb1f6..e487064 100644
--- a/lib/libradsec.h
+++ b/lib/libradsec.h
@@ -66,12 +66,15 @@ struct rs_conn_callbacks {
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);
@@ -81,24 +84,26 @@ int rs_conn_set_callbacks(struct rs_connection *conn, struct rs_conn_callbacks *
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);
diff --git a/lib/packet.c b/lib/packet.c
index c90511b..5f7293c 100644
--- a/lib/packet.c
+++ b/lib/packet.c
@@ -1,3 +1,5 @@
+/* See the file COPYING for licensing information. */
+
#include <string.h>
#include <assert.h>
#include <freeradius/libradius.h>
@@ -128,8 +130,8 @@ _read_cb (struct bufferevent *bev, void *ctx)
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);
@@ -143,7 +145,8 @@ _read_cb (struct bufferevent *bev, void *ctx)
}
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);
@@ -153,15 +156,16 @@ _read_cb (struct bufferevent *bev, void *ctx)
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;
@@ -305,7 +309,7 @@ rs_packet_receive(struct rs_connection *conn, struct rs_packet **pkt_out)
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)
diff --git a/lib/radsec.c b/lib/radsec.c
index 72d7f5f..3d8c5c2 100644
--- a/lib/radsec.c
+++ b/lib/radsec.c
@@ -1,3 +1,5 @@
+/* See the file COPYING for licensing information. */
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>