Remove struct rs_attr and all use of it.
authorLinus Nordberg <linus@nordu.net>
Mon, 14 Mar 2011 12:27:39 +0000 (13:27 +0100)
committerLinus Nordberg <linus@nordu.net>
Mon, 14 Mar 2011 12:27:39 +0000 (13:27 +0100)
A new API for attributes will be added once we've decided how to deal
with RADIUS packets internally.  For now, removing the half baked
wrapping seems more sensible than trying to free rs_attr objects and
their VALUE_PAIR's.

lib/Makefile.am
lib/attr.c
lib/debug.c
lib/debug.h
lib/include/radsec/radsec-impl.h
lib/include/radsec/radsec.h
lib/packet.c

index d4d9b78..e81ee77 100644 (file)
@@ -9,7 +9,6 @@ AM_CFLAGS = -Wall -g
 lib_LTLIBRARIES = libradsec.la
 
 libradsec_la_SOURCES = \
-       attr.c \
        compat.c \
        conf.c \
        conn.c \
index 2face5f..16a6d39 100644 (file)
@@ -1,6 +1,8 @@
 /* Copyright 2010, 2011 NORDUnet A/S. All rights reserved.
    See the file COPYING for licensing information.  */
 
+/* NOTE: This file is not in use at the moment (libradsec-0.0.1).  */
+
 #if defined HAVE_CONFIG_H
 #include <config.h>
 #endif
index 59f25c1..3d3a2b9 100644 (file)
@@ -28,12 +28,6 @@ rs_dump_packet (const struct rs_packet *pkt)
   fflush (stderr);
 }
 
-void
-rs_dump_attr (const struct rs_attr *attr)
-{
-  vp_printlist (stderr, attr->vp);
-}
-
 #if defined DEBUG
 int
 _rs_debug (const char *fmt, ...)
index a8d8632..0bf6129 100644 (file)
@@ -13,9 +13,7 @@ extern "C" {
 #endif
 
 struct rs_packet;
-struct rs_attr;
 void rs_dump_packet (const struct rs_packet *pkt);
-void rs_dump_attr (const struct rs_attr *attr);
 int _rs_debug (const char *fmt, ...);
 
 #if defined (DEBUG)
index 9bcd208..3c1c53c 100644 (file)
@@ -104,15 +104,10 @@ struct rs_packet {
     struct rs_connection *conn;
     unsigned int flags;
     uint8_t hdr[RS_HEADER_LEN];
-    RADIUS_PACKET *rpkt;
+    RADIUS_PACKET *rpkt;       /* FreeRADIUS object.  */
     struct rs_packet *next;    /* Used for UDP output queue.  */
 };
 
-struct rs_attr {
-    struct rs_packet *pkt;
-    VALUE_PAIR *vp;
-};
-
 /* Nonpublic functions (in radsec.c -- FIXME: move?).  */
 struct rs_error *rs_resolv (struct evutil_addrinfo **addr,
                            rs_conn_type_t type,
index 66c55f3..6b0a69c 100644 (file)
@@ -49,7 +49,6 @@ struct rs_context;            /* radsec-impl.h */
 struct rs_connection;          /* radsec-impl.h */
 struct rs_packet;              /* radsec-impl.h */
 struct rs_conn;                        /* radsec-impl.h */
-struct rs_attr;                        /* radsec-impl.h */
 struct rs_error;               /* radsec-impl.h */
 struct rs_peer;                        /* radsec-impl.h */
 struct radius_packet;          /* <freeradius/libradius.h> */
@@ -222,9 +221,6 @@ int rs_packet_create(struct rs_connection *conn, struct rs_packet **pkt_out);
 /** Free all memory allocated for packet \a pkt.  */
 void rs_packet_destroy(struct rs_packet *pkt);
 
-/** Add attribute \a attr to packet \a pkt.  */
-void rs_packet_add_attr(struct rs_packet *pkt, struct rs_attr *attr);
-
 /** Send packet \a pkt on the connection associated with \a pkt.  \a
     user_data is sent to the \a rs_conn_packet_received_cb callback
     registered with the connection.  If no callback is registered with
@@ -249,19 +245,6 @@ int rs_packet_create_authn_request(struct rs_connection *conn,
                                   const char *user_name,
                                   const char *user_pw);
 
-/***************/
-/* Attribute.  */
-/***************/
-/* FIXME: Replace (or complement) with a wrapper for paircreate().  */
-/** Create a RADIUS attribute of type \a type and with the value \a
-    val.  */
-int rs_attr_create(struct rs_connection *conn,
-                  struct rs_attr **attr,
-                  const char *type,
-                  const char *val);
-/** Free memory for RADIUS attribute \a attr.  */
-void rs_attr_destroy(struct rs_attr *attr);
-
 /************/
 /* Config.  */
 /************/
index 48fb55e..3519c1c 100644 (file)
@@ -150,7 +150,7 @@ rs_packet_create_authn_request (struct rs_connection *conn,
                                const char *user_name, const char *user_pw)
 {
   struct rs_packet *pkt;
-  struct rs_attr *attr;
+  VALUE_PAIR *vp = NULL;
 
   if (rs_packet_create (conn, pkt_out))
     return -1;
@@ -159,26 +159,23 @@ rs_packet_create_authn_request (struct rs_connection *conn,
 
   if (user_name)
     {
-      if (rs_attr_create (conn, &attr, "User-Name", user_name))
-       return -1;
-      rs_packet_add_attr (pkt, attr);
-
-      if (user_pw)
-       {
-         if (rs_attr_create (conn, &attr, "User-Password", user_pw))
-           return -1;
-         rs_packet_add_attr (pkt, attr);
-       }
+      vp = pairmake ("User-Name", user_name, T_OP_EQ);
+      if (vp == NULL)
+       return rs_err_conn_push_fl (conn, RSE_FR, __FILE__, __LINE__,
+                                   "pairmake: %s", fr_strerror ());
+      pairadd (&pkt->rpkt->vps, vp);
     }
 
-  return RSE_OK;
-}
+  if (user_pw)
+    {
+      vp = pairmake ("User-Password", user_pw, T_OP_EQ);
+      if (vp == NULL)
+       return rs_err_conn_push_fl (conn, RSE_FR, __FILE__, __LINE__,
+                                   "pairmake: %s", fr_strerror ());
+      pairadd (&pkt->rpkt->vps, vp);
+    }
 
-void
-rs_packet_add_attr (struct rs_packet *pkt, struct rs_attr *attr)
-{
-  pairadd (&pkt->rpkt->vps, attr->vp);
-  attr->pkt = pkt;
+  return RSE_OK;
 }
 
 struct radius_packet *