Ejemplo n.º 1
0
Archivo: acc.c Proyecto: iamroger/voip
int init_acc_aaa(char* aaa_proto_url, int srv_type) 
{
	int n;
	str prot_url;

	memset(rd_attrs, 0, sizeof(rd_attrs));
	memset(rd_vals, 0, sizeof(rd_vals));

	rd_attrs[RA_ACCT_STATUS_TYPE].name  = "Acct-Status-Type";
	rd_attrs[RA_SERVICE_TYPE].name      = "Service-Type";
	rd_attrs[RA_SIP_RESPONSE_CODE].name	= "Sip-Response-Code";
	rd_attrs[RA_SIP_METHOD].name        = "Sip-Method";
	rd_attrs[RA_TIME_STAMP].name        = "Event-Timestamp";
	n = RA_STATIC_MAX;
	/* caution: keep these aligned to core acc output */
	rd_attrs[n++].name                  = "Sip-From-Tag";
	rd_attrs[n++].name                  = "Sip-To-Tag";
	rd_attrs[n++].name                  = "Acct-Session-Id";

	rd_vals[RV_STATUS_START].name        = "Start";
	rd_vals[RV_STATUS_STOP].name         = "Stop";
	rd_vals[RV_STATUS_ALIVE].name        = "Alive";
	rd_vals[RV_STATUS_FAILED].name       = "Failed";
	rd_vals[RV_SIP_SESSION].name         = "Sip-Session";

	/* add and count the extras as attributes */
	n += extra2attrs( aaa_extra, rd_attrs, n);
	n += extra2attrs( aaa_extra_bye, rd_attrs, n);
	/* add and count the legs as attributes */
	n += extra2attrs( leg_info, rd_attrs, n);

	if (dlg_api.get_dlg) {
		rd_attrs[n++].name = "Sip-Call-Duration";
		rd_attrs[n++].name = "Sip-Call-Setuptime";
	}

	prot_url.s = aaa_proto_url;
	prot_url.len = strlen(aaa_proto_url);

	if(aaa_prot_bind(&prot_url, &proto)) {
		LM_ERR("AAA protocol bind failure\n");
		return -1;
	}

	conn = proto.init_prot(&prot_url);
	if (!conn) {
		LM_ERR("AAA protocol initialization failure\n");
		return -1;
	}

	INIT_AV(proto, conn, rd_attrs, n, rd_vals, RV_STATIC_MAX, "acc", -1, -1);

	if (srv_type != -1)
		rd_vals[RV_SIP_SESSION].value = srv_type;


	LM_DBG("init_acc_aaa success!\n");
	return 0;
}
Ejemplo n.º 2
0
int init_acc_rad(acc_extra_t *leg_info, char *rad_cfg, int srv_type)
{
	int n;

	memset(rd_attrs, 0, sizeof(rd_attrs));
	memset(rd_vals, 0, sizeof(rd_vals));
	rd_attrs[RA_ACCT_STATUS_TYPE].n  = "Acct-Status-Type";
	rd_attrs[RA_SERVICE_TYPE].n      = "Service-Type";
	rd_attrs[RA_SIP_RESPONSE_CODE].n = "Sip-Response-Code";
	rd_attrs[RA_SIP_METHOD].n        = "Sip-Method";
	rd_attrs[RA_TIME_STAMP].n        = "Event-Timestamp";
	n = RA_STATIC_MAX;
	/* caution: keep these aligned to core acc output */
	rd_attrs[n++].n                  = "Sip-From-Tag";
	rd_attrs[n++].n                  = "Sip-To-Tag";
	rd_attrs[n++].n                  = "Acct-Session-Id";

	rd_vals[RV_STATUS_START].n        = "Start";
	rd_vals[RV_STATUS_STOP].n         = "Stop";
	rd_vals[RV_STATUS_ALIVE].n        = "Alive";
	rd_vals[RV_STATUS_FAILED].n       = "Failed";
	rd_vals[RV_SIP_SESSION].n         = "Sip-Session";

	/* add and count the extras as attributes */
	n += extra2attrs( rad_extra, rd_attrs, n);
	/* add and count the legs as attributes */
	n += extra2attrs( leg_info, rd_attrs, n);

	/* read config */
	if ((rh = rc_read_config(rad_cfg)) == NULL) {
		LM_ERR("failed to open radius config file: %s\n", rad_cfg );
		return -1;
	}
	/* read dictionary */
	if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary"))!=0) {
		LM_ERR("failed to read radius dictionary\n");
		return -1;
	}

	INIT_AV(rh, rd_attrs, n, rd_vals, RV_STATIC_MAX, "acc", -1, -1);

	if (srv_type != -1)
		rd_vals[RV_SIP_SESSION].v = srv_type;

	return 0;
}
Ejemplo n.º 3
0
/*
 * Module initialization function
 */
static int mod_init(void)
{
	DICT_VENDOR *vend;
	bind_auth_s_t bind_auth;
	int n;

	if ((rh = rc_read_config(radius_config)) == NULL) {
		LM_ERR("failed to open configuration file \n");
		return -1;
	}

	if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) {
		LM_ERR("failed to open dictionary file \n");
		return -2;
	}

	bind_auth = (bind_auth_s_t)find_export("bind_auth_s", 0, 0);
	if (!bind_auth) {
		LM_ERR("unable to find bind_auth function. Check if you load the auth module.\n");
		return -1;
	}

	if (bind_auth(&auth_api) < 0) {
		LM_ERR("cannot bind to auth module\n");
		return -4;
	}

	/* init the extra engine */
	init_extra_engine();

	/* parse extra attributes (if any) */
	if (auth_extra_str &&
	    (auth_extra=parse_extra_str(auth_extra_str)) == 0 ) {
	    LM_ERR("failed to parse auth_extra parameter\n");
	    return -1;
	}

	memset(attrs, 0, sizeof(attrs));
	attrs[A_SERVICE_TYPE].n			= "Service-Type";
	attrs[A_SIP_URI_USER].n			= "Sip-URI-User";
	attrs[A_DIGEST_RESPONSE].n		= "Digest-Response";
	attrs[A_DIGEST_ALGORITHM].n		= "Digest-Algorithm";
	attrs[A_DIGEST_BODY_DIGEST].n		= "Digest-Body-Digest";
	attrs[A_DIGEST_CNONCE].n		= "Digest-CNonce";
	attrs[A_DIGEST_NONCE_COUNT].n		= "Digest-Nonce-Count";
	attrs[A_DIGEST_QOP].n			= "Digest-QOP";
	attrs[A_DIGEST_METHOD].n		= "Digest-Method";
	attrs[A_DIGEST_URI].n			= "Digest-URI";
	attrs[A_DIGEST_NONCE].n			= "Digest-Nonce";
	attrs[A_DIGEST_REALM].n			= "Digest-Realm";
	attrs[A_DIGEST_USER_NAME].n		= "Digest-User-Name";
	attrs[A_USER_NAME].n			= "User-Name";
	attrs[A_SIP_AVP].n			= "SIP-AVP";
	vend = rc_dict_findvend(rh, "Cisco");
	if (vend == NULL) {
	    LM_DBG("no `Cisco' vendor in Radius dictionary\n");
	} else {
	    attrs[A_CISCO_AVPAIR].n		= "Cisco-AVPair";
	}
	n = A_MAX;
	n += extra2attrs(auth_extra, attrs, n);
	memset(vals, 0, sizeof(vals));
	vals[V_SIP_SESSION].n			= "Sip-Session";
	INIT_AV(rh, attrs, n, vals, V_MAX, "auth_radius", -5, -6);

	if (service_type != -1) {
		vals[V_SIP_SESSION].v = service_type;
	}

	return 0;
}
Ejemplo n.º 4
0
static int mod_init(void)
{
    int n;

    LM_INFO("initializing...\n");
    
    /* read config */
    if ((rh = rc_read_config(radius_config)) == NULL) {
	LM_ERR("failed to open radius config file: %s\n", radius_config);
	return -1;
    }

    /* read dictionary */
    if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) {
	LM_ERR("failed to read radius dictionary\n");
	return -1;
    }

    /* init the extra engine */
    init_extra_engine();

    /* parse extra attributes (if any) */
    if (caller_extra_str &&
	(caller_extra=parse_extra_str(caller_extra_str)) == 0 ) {
	LM_ERR("failed to parse caller_extra parameter\n");
	return -1;
    }
    if (callee_extra_str &&
	(callee_extra=parse_extra_str(callee_extra_str)) == 0 ) {
	LM_ERR("failed to parse callee_extra parameter\n");
	return -1;
    }
    if (group_extra_str &&
	(group_extra=parse_extra_str(group_extra_str)) == 0 ) {
	LM_ERR("failed to parse group_extra parameter\n");
	return -1;
    }
    if (uri_extra_str &&
	(uri_extra=parse_extra_str(uri_extra_str)) == 0 ) {
	LM_ERR("failed to parse uri_extra parameter\n");
	return -1;
    }

    SET_STATIC(caller_attrs);
    n += extra2attrs(caller_extra, caller_attrs, n);
    memset(caller_vals, 0, sizeof(caller_vals));
    caller_vals[RV_SIP_CALLER_AVPS].n     = "SIP-Caller-AVPs";
    INIT_AV(rh, caller_attrs, n, caller_vals, RV_STATIC_MAX, "misc_radius",
	    -1, -1);
    if (caller_service_type != -1) {
	caller_vals[RV_SIP_CALLER_AVPS].v = caller_service_type;
    }

    SET_STATIC(callee_attrs);
    n += extra2attrs(callee_extra, callee_attrs, n);
    memset(callee_vals, 0, sizeof(callee_vals));
    callee_vals[EV_SIP_CALLEE_AVPS].n     = "SIP-Callee-AVPs";
    INIT_AV(rh, callee_attrs, n, callee_vals, EV_STATIC_MAX, "misc_radius",
	    -1, -1);
    if (callee_service_type != -1) {
	callee_vals[EV_SIP_CALLEE_AVPS].v = callee_service_type;
    }

    SET_STATIC(group_attrs);
    n += extra2attrs(group_extra, group_attrs, n);
    memset(group_vals, 0, sizeof(group_vals));
    group_vals[GV_GROUP_CHECK].n     = "Group-Check";
    INIT_AV(rh, group_attrs, n, group_vals, RV_STATIC_MAX, "misc_radius",
	    -1, -1);
    if (group_service_type != -1) {
	group_vals[GV_GROUP_CHECK].v = group_service_type;
    }
    SET_STATIC(uri_attrs);
    n += extra2attrs(uri_extra, uri_attrs, n);
    memset(uri_vals, 0, sizeof(uri_vals));
    uri_vals[UV_CALL_CHECK].n     = "Call-Check";
    INIT_AV(rh, uri_attrs, n, uri_vals, UV_STATIC_MAX, "misc_radius",
	    -1, -1);
    if (uri_service_type != -1) {
	uri_vals[UV_CALL_CHECK].v = uri_service_type;
    }

    return 0;
}