Updated API for 2.2
[freeradius.git] / src / modules / rlm_counter / rlm_counter.c
index 45c70f6..d5ed5d2 100644 (file)
@@ -145,7 +145,7 @@ static int counter_cmp(void *instance,
        /*
         *      Find the key attribute.
         */
-       key_vp = pairfind(request, data->key_attr);
+       key_vp = pairfind(request, data->key_attr, 0);
        if (key_vp == NULL) {
                return RLM_MODULE_NOOP;
        }
@@ -413,7 +413,7 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
        }
 
        memset(&flags, 0, sizeof(flags));
-       dict_addattr(data->counter_name, 0, PW_TYPE_INTEGER, -1, flags);
+       dict_addattr(data->counter_name, -1, 0, PW_TYPE_INTEGER, flags);
        dattr = dict_attrbyname(data->counter_name);
        if (dattr == NULL) {
                radlog(L_ERR, "rlm_counter: Failed to create counter attribute %s",
@@ -447,7 +447,7 @@ static int counter_instantiate(CONF_SECTION *conf, void **instance)
         * Find the attribute for the allowed protocol
         */
        if (data->service_type != NULL) {
-               if ((dval = dict_valbyname(PW_SERVICE_TYPE, data->service_type)) == NULL) {
+               if ((dval = dict_valbyname(PW_SERVICE_TYPE, 0, data->service_type)) == NULL) {
                        radlog(L_ERR, "rlm_counter: Failed to find attribute number for %s",
                                        data->service_type);
                        counter_detach(data);
@@ -572,7 +572,7 @@ static int counter_accounting(void *instance, REQUEST *request)
        int acctstatustype = 0;
        time_t diff;
 
-       if ((key_vp = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE)) != NULL)
+       if ((key_vp = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE, 0)) != NULL)
                acctstatustype = key_vp->vp_integer;
        else {
                DEBUG("rlm_counter: Could not find account status type in packet.");
@@ -582,7 +582,7 @@ static int counter_accounting(void *instance, REQUEST *request)
                DEBUG("rlm_counter: We only run on Accounting-Stop packets.");
                return RLM_MODULE_NOOP;
        }
-       uniqueid_vp = pairfind(request->packet->vps, PW_ACCT_UNIQUE_SESSION_ID);
+       uniqueid_vp = pairfind(request->packet->vps, PW_ACCT_UNIQUE_SESSION_ID, 0);
        if (uniqueid_vp != NULL)
                DEBUG("rlm_counter: Packet Unique ID = '%s'",uniqueid_vp->vp_strvalue);
 
@@ -606,7 +606,7 @@ static int counter_accounting(void *instance, REQUEST *request)
         * Check if we need to watch out for a specific service-type. If yes then check it
         */
        if (data->service_type != NULL) {
-               if ((proto_vp = pairfind(request->packet->vps, PW_SERVICE_TYPE)) == NULL){
+               if ((proto_vp = pairfind(request->packet->vps, PW_SERVICE_TYPE, 0)) == NULL){
                        DEBUG("rlm_counter: Could not find Service-Type attribute in the request. Returning NOOP.");
                        return RLM_MODULE_NOOP;
                }
@@ -619,7 +619,7 @@ static int counter_accounting(void *instance, REQUEST *request)
         * Check if request->timestamp - {Acct-Delay-Time} < last_reset
         * If yes reject the packet since it is very old
         */
-       key_vp = pairfind(request->packet->vps, PW_ACCT_DELAY_TIME);
+       key_vp = pairfind(request->packet->vps, PW_ACCT_DELAY_TIME, 0);
        if (key_vp != NULL){
                if (key_vp->vp_integer != 0 &&
                    (request->timestamp - key_vp->vp_integer) < data->last_reset){
@@ -634,7 +634,7 @@ static int counter_accounting(void *instance, REQUEST *request)
         *      Look for the key.  User-Name is special.  It means
         *      The REAL username, after stripping.
         */
-       key_vp = (data->key_attr == PW_USER_NAME) ? request->username : pairfind(request->packet->vps, data->key_attr);
+       key_vp = (data->key_attr == PW_USER_NAME) ? request->username : pairfind(request->packet->vps, data->key_attr, 0);
        if (key_vp == NULL){
                DEBUG("rlm_counter: Could not find the key-attribute in the request. Returning NOOP.");
                return RLM_MODULE_NOOP;
@@ -643,7 +643,7 @@ static int counter_accounting(void *instance, REQUEST *request)
        /*
         *      Look for the attribute to use as a counter.
         */
-       count_vp = pairfind(request->packet->vps, data->count_attr);
+       count_vp = pairfind(request->packet->vps, data->count_attr, 0);
        if (count_vp == NULL){
                DEBUG("rlm_counter: Could not find the count-attribute in the request.");
                return RLM_MODULE_NOOP;
@@ -774,7 +774,7 @@ static int counter_authorize(void *instance, REQUEST *request)
         *      The REAL username, after stripping.
         */
        DEBUG2("rlm_counter: Entering module authorize code");
-       key_vp = (data->key_attr == PW_USER_NAME) ? request->username : pairfind(request->packet->vps, data->key_attr);
+       key_vp = (data->key_attr == PW_USER_NAME) ? request->username : pairfind(request->packet->vps, data->key_attr, 0);
        if (key_vp == NULL) {
                DEBUG2("rlm_counter: Could not find Key value pair");
                return ret;
@@ -783,7 +783,7 @@ static int counter_authorize(void *instance, REQUEST *request)
        /*
         *      Look for the check item
         */
-       if ((check_vp= pairfind(request->config_items, data->check_attr)) == NULL) {
+       if ((check_vp= pairfind(request->config_items, data->check_attr, 0)) == NULL) {
                DEBUG2("rlm_counter: Could not find Check item value pair");
                return ret;
        }
@@ -848,21 +848,21 @@ static int counter_authorize(void *instance, REQUEST *request)
                                res += check_vp->vp_integer;
                        }
 
-                       if ((reply_item = pairfind(request->reply->vps, PW_SESSION_TIMEOUT)) != NULL) {
+                       if ((reply_item = pairfind(request->reply->vps, PW_SESSION_TIMEOUT, 0)) != NULL) {
                                if (reply_item->vp_integer > res)
                                        reply_item->vp_integer = res;
                        } else {
-                               reply_item = radius_paircreate(request, &request->reply->vps, PW_SESSION_TIMEOUT, PW_TYPE_INTEGER);
+                               reply_item = radius_paircreate(request, &request->reply->vps, PW_SESSION_TIMEOUT, 0, PW_TYPE_INTEGER);
                                reply_item->vp_integer = res;
                        }
                }
                else if (data->reply_attr) {
-                       if ((reply_item = pairfind(request->reply->vps, data->reply_attr)) != NULL) {
+                       if ((reply_item = pairfind(request->reply->vps, data->reply_attr, 0)) != NULL) {
                                if (reply_item->vp_integer > res)
                                        reply_item->vp_integer = res;
                        }
                        else {
-                               reply_item = radius_paircreate(request, &request->reply->vps, data->reply_attr, PW_TYPE_INTEGER);
+                               reply_item = radius_paircreate(request, &request->reply->vps, data->reply_attr, 0, PW_TYPE_INTEGER);
                                reply_item->vp_integer = res;
                        }
                }