Example #1
0
/*
 *	Write accounting information to this modules database.
 */
static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
{
	VALUE_PAIR	*pair;
	int 		acctstatustype=0;

	if ((pair = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE, 0, TAG_ANY)) != NULL) {
		acctstatustype = pair->vp_integer;
	} else {
		ERROR("Invalid Accounting Packet");
		return RLM_MODULE_INVALID;
	}

	switch (acctstatustype) {

	case PW_STATUS_START:

		if (((rlm_perl_t *)instance)->func_start_accounting) {
			return do_perl(instance, request,
				       ((rlm_perl_t *)instance)->func_start_accounting);
		} else {
			return do_perl(instance, request,
				       ((rlm_perl_t *)instance)->func_accounting);
		}
		break;

	case PW_STATUS_STOP:

		if (((rlm_perl_t *)instance)->func_stop_accounting) {
			return do_perl(instance, request,
				       ((rlm_perl_t *)instance)->func_stop_accounting);
		} else {
			return do_perl(instance, request,
				       ((rlm_perl_t *)instance)->func_accounting);
		}
		break;
	default:
		return do_perl(instance, request,
			       ((rlm_perl_t *)instance)->func_accounting);

	}
}
Example #2
0
/*
 *	Write accounting information to this modules database.
 */
static rlm_rcode_t CC_HINT(nonnull) mod_accounting(void *instance, UNUSED void *thread, REQUEST *request)
{
	VALUE_PAIR	*pair;
	int 		acct_status_type = 0;

	pair = fr_pair_find_by_da(request->packet->vps, attr_acct_status_type, TAG_ANY);
	if (pair != NULL) {
		acct_status_type = pair->vp_uint32;
	} else {
		REDEBUG("Invalid Accounting Packet");
		return RLM_MODULE_INVALID;
	}

	switch (acct_status_type) {
	case FR_STATUS_START:
		if (((rlm_perl_t const *)instance)->func_start_accounting) {
			return do_perl(instance, request,
				       ((rlm_perl_t const *)instance)->func_start_accounting);
		} else {
			return do_perl(instance, request,
				       ((rlm_perl_t const *)instance)->func_accounting);
		}

	case FR_STATUS_STOP:
		if (((rlm_perl_t const *)instance)->func_stop_accounting) {
			return do_perl(instance, request,
				       ((rlm_perl_t const *)instance)->func_stop_accounting);
		} else {
			return do_perl(instance, request,
				       ((rlm_perl_t const *)instance)->func_accounting);
		}

	default:
		return do_perl(instance, request,
			       ((rlm_perl_t const *)instance)->func_accounting);
	}
}
Example #3
0
/*
 *	Write accounting information to this modules database.
 */
static rlm_rcode_t CC_HINT(nonnull) mod_accounting(void *instance, REQUEST *request)
{
	VALUE_PAIR	*pair;
	int 		acctstatustype=0;

	if ((pair = fr_pair_find_by_num(request->packet->vps, 0, PW_ACCT_STATUS_TYPE, TAG_ANY)) != NULL) {
		acctstatustype = pair->vp_integer;
	} else {
		RDEBUG("Invalid Accounting Packet");
		return RLM_MODULE_INVALID;
	}

	switch (acctstatustype) {
	case PW_STATUS_START:
		if (((rlm_perl_t *)instance)->func_start_accounting) {
			return do_perl(instance, request,
				       ((rlm_perl_t *)instance)->func_start_accounting);
		} else {
			return do_perl(instance, request,
				       ((rlm_perl_t *)instance)->func_accounting);
		}

	case PW_STATUS_STOP:
		if (((rlm_perl_t *)instance)->func_stop_accounting) {
			return do_perl(instance, request,
				       ((rlm_perl_t *)instance)->func_stop_accounting);
		} else {
			return do_perl(instance, request,
				       ((rlm_perl_t *)instance)->func_accounting);
		}

	default:
		return do_perl(instance, request,
			       ((rlm_perl_t *)instance)->func_accounting);
	}
}