25RCSID(
"$Id: b8d3d4188a5ab477d12609ecdcaa1a4c6ce69acd $")
 
   29#include <freeradius-devel/ldap/base.h> 
   30#ifdef LDAP_CONTROL_X_SESSION_TRACKING 
   31#include <freeradius-devel/radius/radius.h> 
   49                            LDAPControl *clientctrls_out[],
 
   50                            size_t serverctrls_len,
 
   51                            size_t clientctrls_len,
 
   53                            LDAPControl *serverctrls_in[],
 
   54                            LDAPControl *clientctrls_in[])
 
   56        size_t i, num_serverctrls = 0, num_clientctrls = 0;
 
   60                        serverctrls_out[num_serverctrls++] = serverctrls_in[i];
 
   66                        clientctrls_out[num_clientctrls++] = clientctrls_in[i];
 
   78        serverctrls_out[num_serverctrls] = NULL;
 
   79        clientctrls_out[num_clientctrls] = NULL;
 
 
  153#ifdef LDAP_CONTROL_X_SESSION_TRACKING 
  174        static char             username_oid[] = LDAP_CONTROL_X_SESSION_TRACKING_USERNAME;
 
  175        static char             acctsessionid_oid[] = LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID;
 
  176        static char             acctmultisessionid_oid[] = LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID;
 
  180        char                    ipaddress[INET6_ADDRSTRLEN];
 
  182        char                    *acctsessionid = NULL;
 
  183        char                    *acctmultisessionid = NULL;
 
  186        LDAPControl             *username_control = NULL;
 
  187        LDAPControl             *acctsessionid_control = NULL;
 
  188        LDAPControl             *acctmultisessionid_control = NULL;
 
  189        struct berval           tracking_id;
 
  202                case FR_NAS_IP_ADDRESS:
 
  203                case FR_NAS_IPV6_ADDRESS:
 
  211                case FR_ACCT_SESSION_ID:
 
  212                        memcpy(&acctsessionid, &
vp->vp_strvalue, 
sizeof(acctsessionid));
 
  215                case FR_ACCT_MULTI_SESSION_ID:
 
  216                        memcpy(&acctmultisessionid, &
vp->vp_strvalue, 
sizeof(acctmultisessionid));
 
  223                tracking_id.bv_len = talloc_array_length(
username) - 1;
 
  225                ret = ldap_create_session_tracking_control(conn->
handle, ipaddress,
 
  230                if (ret != LDAP_SUCCESS) {
 
  231                        REDEBUG(
"Failed creating username session tracking control: %s", ldap_err2string(ret));
 
  233                        if (username_control) ldap_control_free(username_control);
 
  234                        if (acctsessionid_control) ldap_control_free(acctsessionid_control);
 
  235                        if (acctmultisessionid_control) ldap_control_free(acctmultisessionid_control);
 
  241                tracking_id.bv_val = acctsessionid;
 
  242                tracking_id.bv_len = talloc_array_length(acctsessionid) - 1;
 
  244                ret = ldap_create_session_tracking_control(conn->
handle, ipaddress,
 
  248                                                           &acctsessionid_control);
 
  249                if (ret != LDAP_SUCCESS) {
 
  250                        REDEBUG(
"Failed creating acctsessionid session tracking control: %s", ldap_err2string(ret));
 
  255        if (acctmultisessionid) {
 
  256                tracking_id.bv_val = acctmultisessionid;
 
  257                tracking_id.bv_len = talloc_array_length(acctmultisessionid) - 1;
 
  259                ret = ldap_create_session_tracking_control(conn->
handle, ipaddress,
 
  261                                                           acctmultisessionid_oid,
 
  263                                                           &acctmultisessionid_control);
 
  264                if (ret != LDAP_SUCCESS) {
 
  265                        REDEBUG(
"Failed creating acctmultisessionid session tracking control: %s",
 
  266                                ldap_err2string(ret));
 
  272                REDEBUG(
"Insufficient space to add session tracking controls");
 
#define USES_APPLE_DEPRECATED_API
static bool fr_dict_attr_is_top_level(fr_dict_attr_t const *da)
Return true if this attribute is parented directly off the dictionary root.
int fr_ldap_control_add_session_tracking(fr_ldap_connection_t *conn, request_t *request)
LDAP * handle
libldap handle.
int serverctrls_cnt
Number of server controls associated with the handle.
bool freeit
Whether the control should be freed after we've finished using it.
fr_ldap_control_t clientctrls[LDAP_MAX_CONTROLS+1]
Client controls to use for all operations with this handle.
int clientctrls_cnt
Number of client controls associated with the handle.
#define LDAP_MAX_CONTROLS
Maximum number of client/server controls.
LDAPControl * control
LDAP control.
fr_ldap_control_t serverctrls[LDAP_MAX_CONTROLS+1]
Server controls to use for all operations with this handle.
Tracks the state of a libldap connection handle.
void fr_ldap_control_clear(fr_ldap_connection_t *conn)
Clear and free any controls associated with a connection.
int fr_ldap_control_add_server(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit)
Add a serverctrl to a connection handle.
int fr_ldap_control_add_client(fr_ldap_connection_t *conn, LDAPControl *ctrl, bool freeit)
Add a clientctrl to a connection handle.
USES_APPLE_DEPRECATED_API void fr_ldap_control_merge(LDAPControl *serverctrls_out[], LDAPControl *clientctrls_out[], size_t serverctrls_len, size_t clientctrls_len, fr_ldap_connection_t *conn, LDAPControl *serverctrls_in[], LDAPControl *clientctrls_in[])
Merge connection and call specific client and server controls.
main_config_t const  * main_config
Main server configuration.
char const  * name
Name of the daemon, usually 'radiusd'.
#define FR_SBUFF_OUT(_start, _len_or_end)
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const  *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
fr_pair_t * fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item))
Get the next item in a valuepair list after a specific entry.
ssize_t fr_pair_print_value_quoted(fr_sbuff_t *out, fr_pair_t const *vp, fr_token_t quote)
Print the value of an attribute to a string.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.