From 780c8b8e4822bc0db4746ec21bb1c3b21bf1c98d Mon Sep 17 00:00:00 2001 From: "Olle E. Johansson" Date: Mon, 2 Jan 2017 21:07:38 +0100 Subject: [PATCH] acc Remove radius support code (now in separate module - acc_radius.so) --- src/modules/acc/acc.c | 180 +----------------------------------- src/modules/acc/acc.h | 5 - src/modules/acc/acc_extra.c | 16 ---- src/modules/acc/acc_extra.h | 5 - src/modules/acc/acc_logic.c | 46 +-------- src/modules/acc/acc_logic.h | 4 - src/modules/acc/acc_mod.c | 68 -------------- src/modules/acc/acc_mod.h | 6 -- 8 files changed, 6 insertions(+), 324 deletions(-) diff --git a/src/modules/acc/acc.c b/src/modules/acc/acc.c index 1819f769690..a7ba8c0d751 100644 --- a/src/modules/acc/acc.c +++ b/src/modules/acc/acc.c @@ -47,10 +47,6 @@ #include "acc_logic.h" #include "acc_api.h" -#ifdef RAD_ACC -#include "../misc_radius/radius.h" -#endif - #ifdef DIAM_ACC #include "diam_dict.h" #include "diam_message.h" @@ -62,10 +58,6 @@ extern struct acc_extra *leg_info; extern struct acc_enviroment acc_env; extern char *acc_time_format; -#ifdef RAD_ACC -extern struct acc_extra *rad_extra; -#endif - #ifdef DIAM_ACC extern char *diameter_client_host; extern int diameter_client_port; @@ -530,7 +522,7 @@ int acc_db_request( struct sip_msg *rq) /************ RADIUS & DIAMETER helper functions **************/ -#if defined(RAD_ACC) || defined (DIAM_ACC) +#if defined (DIAM_ACC) #ifndef UINT4 #define UINT4 uint32_t #endif @@ -551,176 +543,6 @@ inline static UINT4 phrase2code(str *phrase) #endif -/******************************************** - * RADIUS ACCOUNTING - ********************************************/ -#ifdef RAD_ACC -enum { RA_ACCT_STATUS_TYPE=0, RA_SERVICE_TYPE, RA_SIP_RESPONSE_CODE, - RA_SIP_METHOD, RA_TIME_STAMP, RA_STATIC_MAX}; -enum {RV_STATUS_START=0, RV_STATUS_STOP, RV_STATUS_ALIVE, RV_STATUS_FAILED, - RV_SIP_SESSION, RV_STATIC_MAX}; -static struct attr - rd_attrs[RA_STATIC_MAX+ACC_CORE_LEN-2+MAX_ACC_EXTRA+MAX_ACC_LEG]; -static struct val rd_vals[RV_STATIC_MAX]; - -int init_acc_rad(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; -} - - -static inline UINT4 rad_status( struct sip_msg *req, int code ) -{ - str tag; - unsigned int in_dialog_req = 0; - - tag = get_to(req)->tag_value; - if(tag.s!=0 && tag.len!=0) - in_dialog_req = 1; - - if (req->REQ_METHOD==METHOD_INVITE && in_dialog_req == 0 - && code>=200 && code<300) - return rd_vals[RV_STATUS_START].v; - if ((req->REQ_METHOD==METHOD_BYE || req->REQ_METHOD==METHOD_CANCEL)) - return rd_vals[RV_STATUS_STOP].v; - if (in_dialog_req != 0) - return rd_vals[RV_STATUS_ALIVE].v; - return rd_vals[RV_STATUS_FAILED].v; - } - -#define ADD_RAD_AVPAIR(_attr,_val,_len) \ - do { \ - if (!rc_avpair_add(rh, &send, rd_attrs[_attr].v, _val, _len, 0)) { \ - LM_ERR("failed to add %s, %d\n", rd_attrs[_attr].n, _attr); \ - goto error; \ - } \ - }while(0) - -int acc_rad_request( struct sip_msg *req ) -{ - int attr_cnt; - VALUE_PAIR *send; - UINT4 av_type; - int offset; - int i; - int m; - int o; - - send=NULL; - - attr_cnt = core2strar( req, val_arr, int_arr, type_arr ); - /* not interested in the last 2 values */ - attr_cnt -= 2; - - av_type = rad_status( req, acc_env.code); /* RADIUS status */ - ADD_RAD_AVPAIR( RA_ACCT_STATUS_TYPE, &av_type, -1); - - av_type = rd_vals[RV_SIP_SESSION].v; /* session*/ - ADD_RAD_AVPAIR( RA_SERVICE_TYPE, &av_type, -1); - - av_type = (UINT4)acc_env.code; /* status=integer */ - ADD_RAD_AVPAIR( RA_SIP_RESPONSE_CODE, &av_type, -1); - - av_type = req->REQ_METHOD; /* method */ - ADD_RAD_AVPAIR( RA_SIP_METHOD, &av_type, -1); - - /* unix time */ - av_type = (UINT4)acc_env.ts; - ADD_RAD_AVPAIR( RA_TIME_STAMP, &av_type, -1); - - /* add extra also */ - o = extra2strar(rad_extra, req, val_arr+attr_cnt, - int_arr+attr_cnt, type_arr+attr_cnt); - attr_cnt += o; - m = attr_cnt; - - /* add the values for the vector - start from 1 instead of - * 0 to skip the first value which is the METHOD as string */ - offset = RA_STATIC_MAX-1; - for( i=1; inext) { - attrs[offset+i].n = extra->name.s; - } - return i; -} -#endif - - /*! \brief converts the name of the extra from str to integer * and stores it over str.len ; str.s is freed and made zero */ diff --git a/src/modules/acc/acc_extra.h b/src/modules/acc/acc_extra.h index 777d63b5723..767c9c630f1 100644 --- a/src/modules/acc/acc_extra.h +++ b/src/modules/acc/acc_extra.h @@ -56,11 +56,6 @@ int legs2strar( struct acc_extra *legs, struct sip_msg *rq, str *val_arr, int extra2int( struct acc_extra *extra, int *attrs ); -#ifdef RAD_ACC -#include "../misc_radius/radius.h" -int extra2attrs( struct acc_extra *extra, struct attr *attrs, int offset); -#endif - static inline void free_strar_mem( char* type_arr, str* alloc_arr, int dim_arr, int dim_ext){ int i = 0; for ( i = 0; i < dim_arr; i ++ ) { diff --git a/src/modules/acc/acc_logic.c b/src/modules/acc/acc_logic.c index bd2fd8e73c4..b512d83307c 100644 --- a/src/modules/acc/acc_logic.c +++ b/src/modules/acc/acc_logic.c @@ -67,14 +67,6 @@ struct acc_enviroment acc_env; #define is_db_mc_on(_rq) (0) #endif -#ifdef RAD_ACC - #define is_rad_acc_on(_rq) is_acc_flag_set(_rq,radius_flag) - #define is_rad_mc_on(_rq) is_acc_flag_set(_rq,radius_missed_flag) -#else - #define is_rad_acc_on(_rq) (0) - #define is_rad_mc_on(_rq) (0) -#endif - #ifdef DIAM_ACC #define is_diam_acc_on(_rq) is_acc_flag_set(_rq,diameter_flag) @@ -86,11 +78,11 @@ struct acc_enviroment acc_env; #define is_acc_on(_rq) \ ( (is_log_acc_on(_rq)) || (is_db_acc_on(_rq)) \ - || (is_rad_acc_on(_rq)) || (is_diam_acc_on(_rq)) ) + || (is_diam_acc_on(_rq)) ) #define is_mc_on(_rq) \ ( (is_log_mc_on(_rq)) || (is_db_mc_on(_rq)) \ - || (is_rad_mc_on(_rq)) || (is_diam_mc_on(_rq)) ) + || (is_diam_mc_on(_rq)) ) #define skip_cancel(_rq) \ (((_rq)->REQ_METHOD==METHOD_CANCEL) && report_cancels==0) @@ -279,22 +271,6 @@ int w_acc_db_request(struct sip_msg *rq, char *comment, char *table) } #endif - -#ifdef RAD_ACC -int w_acc_rad_request(struct sip_msg *rq, char *comment, char *foo) -{ - struct acc_param *param = (struct acc_param*)comment; - if (acc_preparse_req(rq)<0) - return -1; - if(acc_get_param_value(rq, param)<0) - return -1; - env_set_to( rq->to ); - env_set_comment(param); - return acc_rad_request(rq); -} -#endif - - #ifdef DIAM_ACC int w_acc_diam_request(struct sip_msg *rq, char *comment, char *foo) { @@ -445,12 +421,7 @@ static inline void on_missed(struct cell *t, struct sip_msg *req, flags_to_reset |= db_missed_flag; } #endif -#ifdef RAD_ACC - if (is_rad_mc_on(req)) { - acc_rad_request( req ); - flags_to_reset |= radius_missed_flag; - } -#endif + /* DIAMETER */ #ifdef DIAM_ACC if (is_diam_mc_on(req)) { @@ -539,10 +510,7 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req, } } #endif -#ifdef RAD_ACC - if (is_rad_acc_on(preq)) - acc_rad_request(preq); -#endif + /* DIAMETER */ #ifdef DIAM_ACC if (is_diam_acc_on(preq)) @@ -596,11 +564,7 @@ static inline void acc_onack( struct cell* t, struct sip_msg *req, acc_db_request( ack ); } #endif -#ifdef RAD_ACC - if (is_rad_acc_on(req)) { - acc_rad_request(ack); - } -#endif + /* DIAMETER */ #ifdef DIAM_ACC if (is_diam_acc_on(req)) { diff --git a/src/modules/acc/acc_logic.h b/src/modules/acc/acc_logic.h index 79bacd8d61e..4101ca8f0ba 100644 --- a/src/modules/acc/acc_logic.h +++ b/src/modules/acc/acc_logic.h @@ -45,10 +45,6 @@ int w_acc_log_request(struct sip_msg *rq, char *comment, char *foo); int w_acc_db_request(struct sip_msg *rq, char *comment, char *table); #endif -#ifdef RAD_ACC -int w_acc_rad_request(struct sip_msg *rq, char *comment, char *foo); -#endif - #ifdef DIAM_ACC int w_acc_diam_request(struct sip_msg *rq, char *comment, char *foo); #endif diff --git a/src/modules/acc/acc_mod.c b/src/modules/acc/acc_mod.c index bc423ee54e7..a60fb3e7467 100644 --- a/src/modules/acc/acc_mod.c +++ b/src/modules/acc/acc_mod.c @@ -53,10 +53,6 @@ #include "acc_logic.h" #include "acc_cdr.h" -#ifdef RAD_ACC -#include "../misc_radius/radius.h" -#endif - #ifdef DIAM_ACC #include "diam_dict.h" #include "diam_tcp.h" @@ -136,23 +132,6 @@ str acc_cdrs_table = str_init(""); /*@}*/ -/* ----- RADIUS acc variables ----------- */ -/*! \name AccRadiusVariables Radius Variables */ -/*@{*/ - -#ifdef RAD_ACC -static char *radius_config = 0; -int radius_flag = -1; -int radius_missed_flag = -1; -static int service_type = -1; -void *rh; -/* rad extra variables */ -static char *rad_extra_str = 0; -struct acc_extra *rad_extra = 0; -#endif -/*@}*/ - - /* ----- DIAMETER acc variables ----------- */ /*! \name AccDiamaterVariables Radius Variables */ @@ -216,11 +195,6 @@ static cmd_export_t cmds[] = { acc_fixup, free_acc_fixup, ANY_ROUTE}, #endif -#ifdef RAD_ACC - {"acc_rad_request", (cmd_function)w_acc_rad_request, 1, - acc_fixup, free_acc_fixup, - ANY_ROUTE}, -#endif #ifdef DIAM_ACC {"acc_diam_request",(cmd_function)w_acc_diam_request,1, acc_fixup, free_acc_fixup, @@ -259,13 +233,6 @@ static param_export_t params[] = { {"cdr_end_id", PARAM_STR, &cdr_end_str }, {"cdr_duration_id", PARAM_STR, &cdr_duration_str }, {"cdr_expired_dlg_enable", INT_PARAM, &cdr_expired_dlg_enable }, -#ifdef RAD_ACC - {"radius_config", PARAM_STRING, &radius_config }, - {"radius_flag", INT_PARAM, &radius_flag }, - {"radius_missed_flag", INT_PARAM, &radius_missed_flag }, - {"service_type", INT_PARAM, &service_type }, - {"radius_extra", PARAM_STRING, &rad_extra_str }, -#endif /* DIAMETER specific */ #ifdef DIAM_ACC {"diameter_flag", INT_PARAM, &diameter_flag }, @@ -618,37 +585,6 @@ static int mod_init( void ) } #endif - /* ------------ RADIUS INIT SECTION ----------- */ - -#ifdef RAD_ACC - if (radius_config && radius_config[0]) { - /* parse the extra string, if any */ - if (rad_extra_str && (rad_extra=parse_acc_extra(rad_extra_str))==0 ) { - LM_ERR("failed to parse rad_extra param\n"); - return -1; - } - - /* fix the flags */ - if ((radius_flag != -1) && !flag_in_range(radius_flag)) { - LM_ERR("radius_flag set to invalid value\n"); - return -1; - } - - if ((radius_missed_flag != -1) && !flag_in_range(radius_missed_flag)) { - LM_ERR("radius_missed_flag set to invalid value\n"); - return -1; - } - - if (init_acc_rad( radius_config, service_type)!=0 ) { - LM_ERR("failed to init radius\n"); - return -1; - } - } else { - radius_config = 0; - radius_flag = -1; - radius_missed_flag = -1; - } -#endif /* ------------ DIAMETER INIT SECTION ----------- */ @@ -732,10 +668,6 @@ static void destroy(void) if (db_extra) destroy_extras( db_extra); #endif -#ifdef RAD_ACC - if (rad_extra) - destroy_extras( rad_extra); -#endif #ifdef DIAM_ACC close_tcp_connection(sockfd); if (dia_extra) diff --git a/src/modules/acc/acc_mod.h b/src/modules/acc/acc_mod.h index 52ee5457272..05690315c4c 100644 --- a/src/modules/acc/acc_mod.h +++ b/src/modules/acc/acc_mod.h @@ -53,12 +53,6 @@ extern int cdr_start_on_confirmed; extern int cdr_log_facility; extern int cdr_expired_dlg_enable; -#ifdef RAD_ACC -extern int radius_flag; -extern int radius_missed_flag; -extern void *rh; -#endif - #ifdef DIAM_ACC #include "diam_tcp.h" extern rd_buf_t *rb;