]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/radius/radiusclient/lib/buildreq.c
Add support for radius Class attribute. Possibly broken if chap is set to
[ppp.git] / pppd / plugins / radius / radiusclient / lib / buildreq.c
index 507a25c63fce0d869dcfa54ad6e07bea3744af38..d8a52c9535c3c82144c8196846b3e4e10e2c5370 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: buildreq.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: buildreq.c,v 1.3 2002/04/02 14:09:35 dfs Exp $
  *
  * Copyright (C) 1995,1997 Lars Fenneberg
  *
@@ -120,13 +120,39 @@ unsigned char rc_get_seqnbr(void)
  */
 
 int rc_auth(UINT4 client_port, VALUE_PAIR *send, VALUE_PAIR **received,
-           char *msg)
+           char *msg, REQUEST_INFO *info)
+{
+    SERVER *authserver = rc_conf_srv("authserver");
+
+    if (!authserver) {
+       return (ERROR_RC);
+    }
+    return rc_auth_using_server(authserver, client_port, send, received,
+                               msg, info);
+}
+
+/*
+ * Function: rc_auth_using_server
+ *
+ * Purpose: Builds an authentication request for port id client_port
+ *         with the value_pairs send and submits it to a server.  You
+ *          explicitly supply a server list.
+ *
+ * Returns: received value_pairs in received, messages from the server in msg
+ *         and 0 on success, negative on failure as return value
+ *
+ */
+
+int rc_auth_using_server(SERVER *authserver,
+                        UINT4 client_port,
+                        VALUE_PAIR *send,
+                        VALUE_PAIR **received,
+                        char *msg, REQUEST_INFO *info)
 {
        SEND_DATA       data;
        UINT4           client_id;
        int             result;
        int             i;
-       SERVER          *authserver = rc_conf_srv("authserver");
        int             timeout = rc_conf_int("radius_timeout");
        int             retries = rc_conf_int("radius_retries");
 
@@ -161,7 +187,7 @@ int rc_auth(UINT4 client_port, VALUE_PAIR *send, VALUE_PAIR **received,
                rc_buildreq(&data, PW_ACCESS_REQUEST, authserver->name[i],
                            authserver->port[i], timeout, retries);
 
-               result = rc_send_server (&data, msg);
+               result = rc_send_server (&data, msg, info);
        }
 
        *received = data.receive_pairs;
@@ -205,7 +231,7 @@ int rc_auth_proxy(VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
                rc_buildreq(&data, PW_ACCESS_REQUEST, authserver->name[i],
                            authserver->port[i], timeout, retries);
 
-               result = rc_send_server (&data, msg);
+               result = rc_send_server (&data, msg, NULL);
        }
 
        *received = data.receive_pairs;
@@ -215,16 +241,18 @@ int rc_auth_proxy(VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
 
 
 /*
- * Function: rc_acct
+ * Function: rc_acct_using_server
  *
  * Purpose: Builds an accounting request for port id client_port
- *         with the value_pairs send
+ *         with the value_pairs send.  You explicitly supply server list.
  *
  * Remarks: NAS-IP-Address, NAS-Port and Acct-Delay-Time get filled
  *         in by this function, the rest has to be supplied.
  */
 
-int rc_acct(UINT4 client_port, VALUE_PAIR *send)
+int rc_acct_using_server(SERVER *acctserver,
+                        UINT4 client_port,
+                        VALUE_PAIR *send)
 {
        SEND_DATA       data;
        VALUE_PAIR      *adt_vp;
@@ -233,7 +261,6 @@ int rc_acct(UINT4 client_port, VALUE_PAIR *send)
        time_t          start_time, dtime;
        char            msg[4096];
        int             i;
-       SERVER          *acctserver = rc_conf_srv("acctserver");
        int             timeout = rc_conf_int("radius_timeout");
        int             retries = rc_conf_int("radius_retries");
 
@@ -280,7 +307,7 @@ int rc_acct(UINT4 client_port, VALUE_PAIR *send)
                dtime = time(NULL) - start_time;
                rc_avpair_assign(adt_vp, &dtime, 0);
 
-               result = rc_send_server (&data, msg);
+               result = rc_send_server (&data, msg, NULL);
        }
 
        rc_avpair_free(data.receive_pairs);
@@ -288,6 +315,24 @@ int rc_acct(UINT4 client_port, VALUE_PAIR *send)
        return result;
 }
 
+/*
+ * Function: rc_acct
+ *
+ * Purpose: Builds an accounting request for port id client_port
+ *         with the value_pairs send
+ *
+ * Remarks: NAS-IP-Address, NAS-Port and Acct-Delay-Time get filled
+ *         in by this function, the rest has to be supplied.
+ */
+
+int rc_acct(UINT4 client_port, VALUE_PAIR *send)
+{
+    SERVER *acctserver = rc_conf_srv("acctserver");
+    if (!acctserver) return (ERROR_RC);
+
+    return rc_acct_using_server(acctserver, client_port, send);
+}
+
 /*
  * Function: rc_acct_proxy
  *
@@ -319,7 +364,7 @@ int rc_acct_proxy(VALUE_PAIR *send)
                rc_buildreq(&data, PW_ACCOUNTING_REQUEST, acctserver->name[i],
                            acctserver->port[i], timeout, retries);
 
-               result = rc_send_server (&data, msg);
+               result = rc_send_server (&data, msg, NULL);
        }
 
        rc_avpair_free(data.receive_pairs);
@@ -362,7 +407,7 @@ int rc_check(char *host, unsigned short port, char *msg)
        rc_avpair_add(&(data.send_pairs), PW_SERVICE_TYPE, &service_type, 0, VENDOR_NONE);
 
        rc_buildreq(&data, PW_STATUS_SERVER, host, port, timeout, retries);
-       result = rc_send_server (&data, msg);
+       result = rc_send_server (&data, msg, NULL);
 
        rc_avpair_free(data.receive_pairs);