summaryrefslogtreecommitdiff
path: root/lib/packet.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2010-09-28 22:27:04 +0200
committerLinus Nordberg <linus@nordu.net>2010-09-28 22:27:04 +0200
commite981fbcf3909fbaba462c7b578f29fa67b3bc74b (patch)
treef67203b602b71600020e95ff6805d6aa71331237 /lib/packet.c
parent07fa3839c8bddd1ad91f86243dd582c0359ba3e1 (diff)
WIP.
Diffstat (limited to 'lib/packet.c')
-rw-r--r--lib/packet.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/packet.c b/lib/packet.c
index e734452..68adf2b 100644
--- a/lib/packet.c
+++ b/lib/packet.c
@@ -1,8 +1,11 @@
#include <string.h>
+#include <assert.h>
#include <freeradius/libradius.h>
#include "libradsec.h"
#include "libradsec-impl.h"
-
+#if defined DEBUG
+#include "debug.h"
+#endif
int
_packet_create (struct rs_connection *conn, struct rs_packet **pkt_out,
@@ -45,33 +48,45 @@ rs_packet_create_acc_request (struct rs_connection *conn,
if (rs_attr_create (conn, &attr, "User-Name", user_name))
return -1;
- if (rs_packet_add_attr (pkt, attr))
- return -1;
+ rs_packet_add_attr (pkt, attr);
if (rs_attr_create (conn, &attr, "User-Password", user_name))
return -1;
- if (rs_packet_add_attr (pkt, attr))
- return -1;
+ /* FIXME: need this too? rad_pwencode(user_pw, &pwlen, SECRET, reqauth) */
+ rs_packet_add_attr (pkt, attr);
return RSE_OK;
}
int
-rs_packet_send (struct rs_conn *conn, const struct rs_packet *pkt,
+rs_packet_send (struct rs_connection *conn, const struct rs_packet *pkt,
void *user_data)
{
- rad_encode (pkt->rpkt, NULL, pkt->conn->secret);
+ assert (pkt->rpkt);
+
+ if (!conn->active_peer)
+ {
+ int err = rs_conn_open (conn);
+ if (err)
+ return err;
+ }
+ rad_encode (pkt->rpkt, NULL, conn->active_peer->secret);
#if defined (DEBUG)
- fprintf (stderr, "%s: about to send this to %"
- print_hex (pkt);
+ fprintf (stderr, "%s: about to send this to %s", __func__, "fixme");
+ rs_dump_packet (pkt);
#endif
-
-
return RSE_NOSYS;
}
-int rs_packet_receive(struct rs_conn *conn, struct rs_packet **pkt)
+int rs_packet_receive(struct rs_connection *conn, struct rs_packet **pkt)
{
return RSE_NOSYS;
}
+
+void
+rs_packet_add_attr(struct rs_packet *pkt, struct rs_attr *attr)
+{
+ pairadd (&pkt->rpkt->vps, attr->vp);
+ attr->pkt = pkt;
+}