Changeset 120:d7acdc46134d in freeDiameter
- Timestamp:
- Dec 9, 2009, 5:36:38 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
- 15 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/CMakeLists.txt
r118 r120 57 57 58 58 #### 59 # Debug / development extensions59 # Debug / test extensions 60 60 61 61 OPTION(BUILD_SAMPLE "Build sample.fdx? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF) … … 64 64 ENDIF (BUILD_SAMPLE) 65 65 66 OPTION(BUILD_ MONITOR "Buildmonitor.fdx? (display periodical debug information on the console)" OFF)67 IF (BUILD_ MONITOR)66 OPTION(BUILD_DBG_MONITOR "Build dbg_monitor.fdx? (display periodical debug information on the console)" OFF) 67 IF (BUILD_DBG_MONITOR) 68 68 SUBDIRS(dbg_monitor) 69 ENDIF (BUILD_ MONITOR)69 ENDIF (BUILD_DBG_MONITOR) 70 70 71 OPTION(BUILD_ RT_ANY "Build rt_any? (Routing extension randomly sending message to any peer available, for testing purpose only)" OFF)72 IF (BUILD_ RT_ANY)73 SUBDIRS( rt_any)74 ENDIF (BUILD_ RT_ANY)71 OPTION(BUILD_DBG_RT "Build dbg_rt.fdx? (Routing extension for debugging the routing module)" OFF) 72 IF (BUILD_DBG_RT) 73 SUBDIRS(dbg_rt) 74 ENDIF (BUILD_DBG_RT) 75 75 76 OPTION(BUILD_ RT_DEBUG "Build rt_debug? (Routing extension for debugging the routing module)" OFF)77 IF (BUILD_ RT_DEBUG)78 SUBDIRS( rt_debug)79 ENDIF (BUILD_ RT_DEBUG)76 OPTION(BUILD_TEST_APP "Build test_app.fdx? (Testing application to send dummy message to another peer, for testing purpose only)" OFF) 77 IF (BUILD_TEST_APP) 78 SUBDIRS(test_app) 79 ENDIF (BUILD_TEST_APP) 80 80 81 OPTION(BUILD_ APP_TEST "Build app_test? (Testing application to send dummy message to another peer, for testing purpose only)" OFF)82 IF (BUILD_ APP_TEST)83 SUBDIRS( app_test)84 ENDIF (BUILD_ APP_TEST)81 OPTION(BUILD_TEST_RT_ANY "Build test_rt_any.fdx? (Routing extension randomly sending message to any peer available, for testing purpose only)" OFF) 82 IF (BUILD_TEST_RT_ANY) 83 SUBDIRS(test_rt_any) 84 ENDIF (BUILD_TEST_RT_ANY) -
extensions/dbg_monitor/CMakeLists.txt
r10 r120 1 1 # Monitoring extension 2 2 PROJECT("Monitor extension" C) 3 FD_ADD_EXTENSION(dbg_monitor monitor.c)3 FD_ADD_EXTENSION(dbg_monitor dbg_monitor.c) -
extensions/dbg_monitor/dbg_monitor.c
r97 r120 48 48 static int monitor_main(char * conffile); 49 49 50 EXTENSION_ENTRY(" monitor", monitor_main);50 EXTENSION_ENTRY("dbg_monitor", monitor_main); 51 51 52 52 /* Function called on receipt of SIGUSR1 */ 53 53 static void got_sig(int signal) 54 54 { 55 fd_log_debug("[dbg_monitor] Dumping extra information\n"); 55 56 CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_DICT, 0, NULL), /* continue */); 56 57 CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_CONFIG, 0, NULL), /* continue */); … … 80 81 sleep(3600); /* 1 hour */ 81 82 #endif /* DEBUG */ 82 TRACE_DEBUG(NONE, "Monitor information");83 fd_log_debug("[dbg_monitor] Dumping current information\n"); 83 84 CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_QUEUES, 0, NULL), /* continue */); 84 85 CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_SERV, 0, NULL), /* continue */); -
extensions/dbg_rt/CMakeLists.txt
r117 r120 3 3 4 4 # Compile as a module 5 FD_ADD_EXTENSION( rt_debug rt_debug.c)5 FD_ADD_EXTENSION(dbg_rt dbg_rt.c) -
extensions/dbg_rt/dbg_rt.c
r117 r120 44 44 45 45 /* Proxying debug callback */ 46 static int rtdebug_fwd_cb(void * cbdata, struct msg ** msg)46 static int dbgrt_fwd_cb(void * cbdata, struct msg ** msg) 47 47 { 48 48 TRACE_ENTRY("%p %p", cbdata, msg); 49 49 50 fd_log_debug("[ rt_debug] FWD routing message: %p\n", msg ? *msg : NULL);50 fd_log_debug("[dbg_rt] FWD routing message: %p\n", msg ? *msg : NULL); 51 51 if (msg) 52 52 fd_msg_dump_walk(INFO, *msg); … … 56 56 57 57 /* Path selection debug callback */ 58 static int rtdebug_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates)58 static int dbgrt_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates) 59 59 { 60 60 struct fd_list * li; … … 62 62 TRACE_ENTRY("%p %p %p", cbdata, msg, candidates); 63 63 64 fd_log_debug("[ rt_debug] OUT routing message: %p\n", msg);64 fd_log_debug("[dbg_rt] OUT routing message: %p\n", msg); 65 65 fd_msg_dump_walk(INFO, msg); 66 fd_log_debug("[ rt_debug] Current list of candidates (%p)\n", msg);66 fd_log_debug("[dbg_rt] Current list of candidates (%p)\n", msg); 67 67 68 68 for (li = candidates->next; li != candidates; li = li->next) { 69 69 struct rtd_candidate *c = (struct rtd_candidate *) li; 70 fd_log_debug("[ rt_debug] - %d\t%s\n", c->score, c->diamid);70 fd_log_debug("[dbg_rt] - %d\t%s\n", c->score, c->diamid); 71 71 } 72 72 … … 75 75 76 76 /* Register the callbacks to the daemon */ 77 static int rtdebug_main(char * conffile)77 static int dbgrt_main(char * conffile) 78 78 { 79 79 TRACE_ENTRY("%p", conffile); 80 80 81 CHECK_FCT( fd_rt_fwd_register ( rtdebug_fwd_cb, NULL, RT_FWD_ALL, &fwd_hdl ) );82 CHECK_FCT( fd_rt_out_register ( rtdebug_out_cb, NULL, -1 /* so that it is called late */, &out_hdl ) );81 CHECK_FCT( fd_rt_fwd_register ( dbgrt_fwd_cb, NULL, RT_FWD_ALL, &fwd_hdl ) ); 82 CHECK_FCT( fd_rt_out_register ( dbgrt_out_cb, NULL, -1 /* so that it is called late */, &out_hdl ) ); 83 83 84 84 return 0; … … 98 98 99 99 /* Define the entry point function */ 100 EXTENSION_ENTRY(" rt_debug", rtdebug_main);100 EXTENSION_ENTRY("dbg_rt", dbgrt_main); -
extensions/test_app/CMakeLists.txt
r93 r120 3 3 4 4 # Parser files 5 BISON_FILE( atst_conf.y)6 FLEX_FILE( atst_conf.l)7 SET_SOURCE_FILES_PROPERTIES(lex. atst_conf.c atst_conf.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}")5 BISON_FILE(ta_conf.y) 6 FLEX_FILE(ta_conf.l) 7 SET_SOURCE_FILES_PROPERTIES(lex.ta_conf.c ta_conf.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}") 8 8 9 9 # List of source files 10 10 SET( APP_TEST_SRC 11 app_test.c12 app_test.h13 lex. atst_conf.c14 atst_conf.tab.c15 atst_conf.tab.h16 atst_sig.c17 atst_dict.c18 atst_serv.c19 atst_cli.c11 test_app.h 12 test_app.c 13 lex.ta_conf.c 14 ta_conf.tab.c 15 ta_conf.tab.h 16 ta_sig.c 17 ta_dict.c 18 ta_cli.c 19 ta_serv.c 20 20 ) 21 21 22 22 # Compile as a module 23 FD_ADD_EXTENSION( app_test${APP_TEST_SRC})23 FD_ADD_EXTENSION(test_app ${APP_TEST_SRC}) -
extensions/test_app/ta_cli.c
r99 r120 40 40 */ 41 41 42 #include " app_test.h"42 #include "test_app.h" 43 43 44 44 #include <stdio.h> 45 45 46 static struct session_handler * atst_cli_reg = NULL;47 48 struct atst_mess_info {46 static struct session_handler * ta_cli_reg = NULL; 47 48 struct ta_mess_info { 49 49 int32_t randval; /* a random value to store in Test-AVP */ 50 50 struct timespec ts; /* Time of sending the message */ … … 52 52 53 53 /* Cb called when an answer is received */ 54 static void atst_cb_ans(void * data, struct msg ** msg)55 { 56 struct atst_mess_info * mi = NULL;54 static void ta_cb_ans(void * data, struct msg ** msg) 55 { 56 struct ta_mess_info * mi = NULL; 57 57 struct timespec ts; 58 58 struct session * sess; … … 68 68 ASSERT( new == 0 ); 69 69 70 CHECK_FCT_DO( fd_sess_state_retrieve( atst_cli_reg, sess, &mi ), return );70 CHECK_FCT_DO( fd_sess_state_retrieve( ta_cli_reg, sess, &mi ), return ); 71 71 TRACE_DEBUG( INFO, "%p %p", mi, data); 72 72 ASSERT( (void *)mi == data ); … … 77 77 78 78 /* Value of Test-AVP */ 79 CHECK_FCT_DO( fd_msg_search_avp ( *msg, atst_avp, &avp), return );79 CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_avp, &avp), return ); 80 80 if (avp) { 81 81 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return ); … … 86 86 87 87 /* Value of Result Code */ 88 CHECK_FCT_DO( fd_msg_search_avp ( *msg, atst_res_code, &avp), return );88 CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_res_code, &avp), return ); 89 89 if (avp) { 90 90 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return ); … … 95 95 96 96 /* Value of Origin-Host */ 97 CHECK_FCT_DO( fd_msg_search_avp ( *msg, atst_origin_host, &avp), return );97 CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_host, &avp), return ); 98 98 if (avp) { 99 99 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return ); … … 104 104 105 105 /* Value of Origin-Realm */ 106 CHECK_FCT_DO( fd_msg_search_avp ( *msg, atst_origin_realm, &avp), return );106 CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_realm, &avp), return ); 107 107 if (avp) { 108 108 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return ); … … 136 136 137 137 /* Create a test message */ 138 static void atst_cli_test_message(void)138 static void ta_cli_test_message(void) 139 139 { 140 140 struct msg * req = NULL; 141 141 struct avp * avp; 142 142 union avp_value val; 143 struct atst_mess_info * mi = NULL, *svg;143 struct ta_mess_info * mi = NULL, *svg; 144 144 struct session *sess = NULL; 145 145 … … 147 147 148 148 /* Create the request from template */ 149 CHECK_FCT_DO( fd_msg_new( atst_cmd_r, MSGFL_ALLOC_ETEID, &req ), goto out );149 CHECK_FCT_DO( fd_msg_new( ta_cmd_r, MSGFL_ALLOC_ETEID, &req ), goto out ); 150 150 151 151 /* Create a new session */ … … 153 153 154 154 /* Create the random value to store with the session */ 155 mi = malloc(sizeof(struct atst_mess_info));155 mi = malloc(sizeof(struct ta_mess_info)); 156 156 if (mi == NULL) { 157 157 fd_log_debug("malloc failed: %s", strerror(errno)); … … 167 167 char * sid; 168 168 CHECK_FCT_DO( fd_sess_getsid ( sess, &sid ), goto out ); 169 CHECK_FCT_DO( fd_msg_avp_new ( atst_sess_id, 0, &avp ), goto out );169 CHECK_FCT_DO( fd_msg_avp_new ( ta_sess_id, 0, &avp ), goto out ); 170 170 val.os.data = sid; 171 171 val.os.len = strlen(sid); … … 177 177 /* Set the Destination-Realm AVP */ 178 178 { 179 CHECK_FCT_DO( fd_msg_avp_new ( atst_dest_realm, 0, &avp ), goto out );180 val.os.data = (unsigned char *)( atst_conf->dest_realm);181 val.os.len = strlen( atst_conf->dest_realm);179 CHECK_FCT_DO( fd_msg_avp_new ( ta_dest_realm, 0, &avp ), goto out ); 180 val.os.data = (unsigned char *)(ta_conf->dest_realm); 181 val.os.len = strlen(ta_conf->dest_realm); 182 182 CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); 183 183 CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); … … 185 185 186 186 /* Set the Destination-Host AVP if needed*/ 187 if ( atst_conf->dest_host) {188 CHECK_FCT_DO( fd_msg_avp_new ( atst_dest_host, 0, &avp ), goto out );189 val.os.data = (unsigned char *)( atst_conf->dest_host);190 val.os.len = strlen( atst_conf->dest_host);187 if (ta_conf->dest_host) { 188 CHECK_FCT_DO( fd_msg_avp_new ( ta_dest_host, 0, &avp ), goto out ); 189 val.os.data = (unsigned char *)(ta_conf->dest_host); 190 val.os.len = strlen(ta_conf->dest_host); 191 191 CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); 192 192 CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); … … 199 199 /* Set the Test-AVP AVP */ 200 200 { 201 CHECK_FCT_DO( fd_msg_avp_new ( atst_avp, 0, &avp ), goto out );201 CHECK_FCT_DO( fd_msg_avp_new ( ta_avp, 0, &avp ), goto out ); 202 202 val.i32 = mi->randval; 203 203 CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); … … 211 211 212 212 /* Store this value in the session */ 213 CHECK_FCT_DO( fd_sess_state_store ( atst_cli_reg, sess, &mi ), goto out );213 CHECK_FCT_DO( fd_sess_state_store ( ta_cli_reg, sess, &mi ), goto out ); 214 214 215 215 /* Log sending the message */ 216 fprintf(stderr, "SEND %x to '%s' (%s)\n", svg->randval, atst_conf->dest_realm, atst_conf->dest_host?:"-" );216 fprintf(stderr, "SEND %x to '%s' (%s)\n", svg->randval, ta_conf->dest_realm, ta_conf->dest_host?:"-" ); 217 217 fflush(stderr); 218 218 219 219 /* Send the request */ 220 CHECK_FCT_DO( fd_msg_send( &req, atst_cb_ans, svg ), goto out );220 CHECK_FCT_DO( fd_msg_send( &req, ta_cb_ans, svg ), goto out ); 221 221 222 222 out: … … 225 225 } 226 226 227 int atst_cli_init(void)228 { 229 CHECK_FCT( fd_sess_handler_create(& atst_cli_reg, free) );230 231 CHECK_FCT( atst_sig_init(atst_cli_test_message) );227 int ta_cli_init(void) 228 { 229 CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, free) ); 230 231 CHECK_FCT( ta_sig_init(ta_cli_test_message) ); 232 232 233 233 return 0; 234 234 } 235 235 236 void atst_cli_fini(void)237 { 238 (void) fd_sess_handler_destroy(& atst_cli_reg);239 240 atst_sig_fini();236 void ta_cli_fini(void) 237 { 238 (void) fd_sess_handler_destroy(&ta_cli_reg); 239 240 ta_sig_fini(); 241 241 242 242 return; -
extensions/test_app/ta_conf.l
r93 r120 41 41 42 42 %{ 43 #include " app_test.h"43 #include "test_app.h" 44 44 /* Include yacc tokens definitions */ 45 #include " atst_conf.tab.h"45 #include "ta_conf.tab.h" 46 46 47 47 /* Update the column information */ -
extensions/test_app/ta_conf.y
r93 r120 50 50 51 51 %{ 52 #include " app_test.h"53 #include " atst_conf.tab.h" /* bison is not smart enough to define the YYLTYPE before including this code, so... */52 #include "test_app.h" 53 #include "ta_conf.tab.h" /* bison is not smart enough to define the YYLTYPE before including this code, so... */ 54 54 55 55 #include <string.h> … … 60 60 61 61 /* Parse the configuration file */ 62 int atst_conf_handle(char * conffile)62 int ta_conf_handle(char * conffile) 63 63 { 64 extern FILE * atst_confin;64 extern FILE * ta_confin; 65 65 int ret; 66 66 … … 69 69 TRACE_DEBUG (FULL, "Parsing configuration file: %s...", conffile); 70 70 71 atst_confin = fopen(conffile, "r");72 if ( atst_confin == NULL) {71 ta_confin = fopen(conffile, "r"); 72 if (ta_confin == NULL) { 73 73 ret = errno; 74 74 fd_log_debug("Unable to open extension configuration file %s for reading: %s\n", conffile, strerror(ret)); … … 79 79 ret = yyparse(conffile); 80 80 81 fclose( atst_confin);81 fclose(ta_confin); 82 82 83 83 if (ret != 0) { … … 90 90 91 91 /* The Lex parser prototype */ 92 int atst_conflex(YYSTYPE *lvalp, YYLTYPE *llocp);92 int ta_conflex(YYSTYPE *lvalp, YYLTYPE *llocp); 93 93 94 94 /* Function to report the errors */ … … 152 152 vendor: VENDOR_ID '=' INTEGER ';' 153 153 { 154 atst_conf->vendor_id = $3;154 ta_conf->vendor_id = $3; 155 155 } 156 156 ; … … 158 158 appli: APPLI_ID '=' INTEGER ';' 159 159 { 160 atst_conf->appli_id = $3;160 ta_conf->appli_id = $3; 161 161 } 162 162 ; … … 164 164 cmd: CMD_ID '=' INTEGER ';' 165 165 { 166 atst_conf->cmd_id = $3;166 ta_conf->cmd_id = $3; 167 167 } 168 168 ; … … 170 170 avp: AVP_ID '=' INTEGER ';' 171 171 { 172 atst_conf->avp_id = $3;172 ta_conf->avp_id = $3; 173 173 } 174 174 ; … … 176 176 mode: MODE '=' INTEGER ';' 177 177 { 178 atst_conf->mode = $3;178 ta_conf->mode = $3; 179 179 } 180 180 ; … … 182 182 dstrealm: DEST_REALM '=' QSTRING ';' 183 183 { 184 free( atst_conf->dest_realm);185 atst_conf->dest_realm = $3;184 free(ta_conf->dest_realm); 185 ta_conf->dest_realm = $3; 186 186 } 187 187 ; … … 189 189 dsthost: DEST_HOST '=' QSTRING ';' 190 190 { 191 free( atst_conf->dest_host);192 atst_conf->dest_host = $3;191 free(ta_conf->dest_host); 192 ta_conf->dest_host = $3; 193 193 } 194 194 ; … … 196 196 signal: SIGNAL '=' INTEGER ';' 197 197 { 198 atst_conf->signal = $3;199 } 200 ; 198 ta_conf->signal = $3; 199 } 200 ; -
extensions/test_app/ta_dict.c
r93 r120 36 36 /* Install the dictionary objects */ 37 37 38 #include " app_test.h"38 #include "test_app.h" 39 39 40 struct dict_object * atst_vendor = NULL;41 struct dict_object * atst_appli = NULL;42 struct dict_object * atst_cmd_r = NULL;43 struct dict_object * atst_cmd_a = NULL;44 struct dict_object * atst_avp = NULL;40 struct dict_object * ta_vendor = NULL; 41 struct dict_object * ta_appli = NULL; 42 struct dict_object * ta_cmd_r = NULL; 43 struct dict_object * ta_cmd_a = NULL; 44 struct dict_object * ta_avp = NULL; 45 45 46 struct dict_object * atst_sess_id = NULL;47 struct dict_object * atst_origin_host = NULL;48 struct dict_object * atst_origin_realm = NULL;49 struct dict_object * atst_dest_host = NULL;50 struct dict_object * atst_dest_realm = NULL;51 struct dict_object * atst_res_code = NULL;46 struct dict_object * ta_sess_id = NULL; 47 struct dict_object * ta_origin_host = NULL; 48 struct dict_object * ta_origin_realm = NULL; 49 struct dict_object * ta_dest_host = NULL; 50 struct dict_object * ta_dest_realm = NULL; 51 struct dict_object * ta_res_code = NULL; 52 52 53 int atst_dict_init(void)53 int ta_dict_init(void) 54 54 { 55 55 TRACE_DEBUG(FULL, "Initializing the dictionary for test"); … … 58 58 { 59 59 struct dict_vendor_data data; 60 data.vendor_id = atst_conf->vendor_id;60 data.vendor_id = ta_conf->vendor_id; 61 61 data.vendor_name = "app_test vendor"; 62 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_VENDOR, &data, NULL, & atst_vendor));62 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_VENDOR, &data, NULL, &ta_vendor)); 63 63 } 64 64 … … 66 66 { 67 67 struct dict_application_data data; 68 data.application_id = atst_conf->appli_id;68 data.application_id = ta_conf->appli_id; 69 69 data.application_name = "app_test application"; 70 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_APPLICATION, &data, atst_vendor, &atst_appli));70 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_APPLICATION, &data, ta_vendor, &ta_appli)); 71 71 } 72 72 … … 74 74 { 75 75 struct dict_cmd_data data; 76 data.cmd_code = atst_conf->cmd_id;76 data.cmd_code = ta_conf->cmd_id; 77 77 data.cmd_name = "Test-Request"; 78 78 data.cmd_flag_mask = CMD_FLAG_PROXIABLE | CMD_FLAG_REQUEST; 79 79 data.cmd_flag_val = CMD_FLAG_PROXIABLE | CMD_FLAG_REQUEST; 80 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_COMMAND, &data, atst_appli, &atst_cmd_r));80 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_COMMAND, &data, ta_appli, &ta_cmd_r)); 81 81 data.cmd_name = "Test-Answer"; 82 82 data.cmd_flag_val = CMD_FLAG_PROXIABLE; 83 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_COMMAND, &data, atst_appli, &atst_cmd_a));83 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_COMMAND, &data, ta_appli, &ta_cmd_a)); 84 84 } 85 85 … … 87 87 { 88 88 struct dict_avp_data data; 89 data.avp_code = atst_conf->avp_id;90 data.avp_vendor = atst_conf->vendor_id;89 data.avp_code = ta_conf->avp_id; 90 data.avp_vendor = ta_conf->vendor_id; 91 91 data.avp_name = "Test-AVP"; 92 92 data.avp_flag_mask = AVP_FLAG_VENDOR; 93 93 data.avp_flag_val = AVP_FLAG_VENDOR; 94 94 data.avp_basetype = AVP_TYPE_INTEGER32; 95 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_AVP, &data, NULL, & atst_avp));95 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_AVP, &data, NULL, &ta_avp)); 96 96 } 97 97 98 98 /* Now resolve some other useful AVPs */ 99 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", & atst_sess_id, ENOENT) );100 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", & atst_origin_host, ENOENT) );101 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Realm", & atst_origin_realm, ENOENT) );102 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", & atst_dest_host, ENOENT) );103 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", & atst_dest_realm, ENOENT) );104 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", & atst_res_code, ENOENT) );99 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &ta_sess_id, ENOENT) ); 100 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &ta_origin_host, ENOENT) ); 101 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Realm", &ta_origin_realm, ENOENT) ); 102 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", &ta_dest_host, ENOENT) ); 103 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &ta_dest_realm, ENOENT) ); 104 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &ta_res_code, ENOENT) ); 105 105 106 106 /* Create the rules for Test-Request and Test-Answer */ … … 111 111 112 112 /* Session-Id is in first position */ 113 data.rule_avp = atst_sess_id;113 data.rule_avp = ta_sess_id; 114 114 data.rule_position = RULE_FIXED_HEAD; 115 115 data.rule_order = 1; 116 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_r, NULL));117 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_a, NULL));116 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_r, NULL)); 117 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_a, NULL)); 118 118 119 119 data.rule_position = RULE_REQUIRED; 120 120 /* Test-AVP is mandatory */ 121 data.rule_avp = atst_avp;122 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_r, NULL));123 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_a, NULL));121 data.rule_avp = ta_avp; 122 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_r, NULL)); 123 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_a, NULL)); 124 124 125 125 /* idem for Origin Host and Realm */ 126 data.rule_avp = atst_origin_host;127 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_r, NULL));128 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_a, NULL));126 data.rule_avp = ta_origin_host; 127 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_r, NULL)); 128 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_a, NULL)); 129 129 130 data.rule_avp = atst_origin_realm;131 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_r, NULL));132 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_a, NULL));130 data.rule_avp = ta_origin_realm; 131 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_r, NULL)); 132 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_a, NULL)); 133 133 134 134 /* And Result-Code is mandatory for answers only */ 135 data.rule_avp = atst_res_code;136 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_a, NULL));135 data.rule_avp = ta_res_code; 136 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_a, NULL)); 137 137 138 138 /* And Destination-Realm for requests only */ 139 data.rule_avp = atst_dest_realm;140 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_r, NULL));139 data.rule_avp = ta_dest_realm; 140 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_r, NULL)); 141 141 142 142 /* And Destination-Host optional for requests only */ 143 143 data.rule_position = RULE_OPTIONAL; 144 144 data.rule_min = 0; 145 data.rule_avp = atst_dest_host;146 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, atst_cmd_r, NULL));145 data.rule_avp = ta_dest_host; 146 CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &data, ta_cmd_r, NULL)); 147 147 148 148 } -
extensions/test_app/ta_serv.c
r112 r120 36 36 /* Install the dispatch callbacks */ 37 37 38 #include " app_test.h"38 #include "test_app.h" 39 39 40 static struct disp_hdl * atst_hdl_fb = NULL; /* handler for fallback cb */41 static struct disp_hdl * atst_hdl_tr = NULL; /* handler for Test-Request req cb */40 static struct disp_hdl * ta_hdl_fb = NULL; /* handler for fallback cb */ 41 static struct disp_hdl * ta_hdl_tr = NULL; /* handler for Test-Request req cb */ 42 42 43 43 /* Default callback for the application. */ 44 static int atst_fb_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act)44 static int ta_fb_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act) 45 45 { 46 46 /* This CB should never be called */ … … 53 53 54 54 /* Callback for incoming Test-Request messages */ 55 static int atst_tr_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act)55 static int ta_tr_cb( struct msg ** msg, struct avp * avp, struct session * sess, enum disp_action * act) 56 56 { 57 57 struct msg *ans, *qry; … … 73 73 struct avp_hdr * hdr = NULL; 74 74 75 CHECK_FCT( fd_msg_search_avp ( qry, atst_avp, &src) );75 CHECK_FCT( fd_msg_search_avp ( qry, ta_avp, &src) ); 76 76 CHECK_FCT( fd_msg_avp_hdr( src, &hdr ) ); 77 77 78 CHECK_FCT( fd_msg_avp_new ( atst_avp, 0, &avp ) );78 CHECK_FCT( fd_msg_avp_new ( ta_avp, 0, &avp ) ); 79 79 CHECK_FCT( fd_msg_avp_setvalue( avp, hdr->avp_value ) ); 80 80 CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, avp ) ); … … 90 90 } 91 91 92 int atst_serv_init(void)92 int ta_serv_init(void) 93 93 { 94 94 struct disp_when data; … … 97 97 98 98 memset(&data, 0, sizeof(data)); 99 data.app = atst_appli;100 data.command = atst_cmd_r;99 data.app = ta_appli; 100 data.command = ta_cmd_r; 101 101 102 102 /* fallback CB if command != Test-Request received */ 103 CHECK_FCT( fd_disp_register( atst_fb_cb, DISP_HOW_APPID, &data, &atst_hdl_fb ) );103 CHECK_FCT( fd_disp_register( ta_fb_cb, DISP_HOW_APPID, &data, &ta_hdl_fb ) ); 104 104 105 105 /* Now specific handler for Test-Request */ 106 CHECK_FCT( fd_disp_register( atst_tr_cb, DISP_HOW_CC, &data, &atst_hdl_tr ) );106 CHECK_FCT( fd_disp_register( ta_tr_cb, DISP_HOW_CC, &data, &ta_hdl_tr ) ); 107 107 108 108 return 0; 109 109 } 110 110 111 void atst_serv_fini(void)111 void ta_serv_fini(void) 112 112 { 113 if ( atst_hdl_fb) {114 (void) fd_disp_unregister(& atst_hdl_fb);113 if (ta_hdl_fb) { 114 (void) fd_disp_unregister(&ta_hdl_fb); 115 115 } 116 if ( atst_hdl_tr) {117 (void) fd_disp_unregister(& atst_hdl_tr);116 if (ta_hdl_tr) { 117 (void) fd_disp_unregister(&ta_hdl_tr); 118 118 } 119 119 -
extensions/test_app/ta_sig.c
r98 r120 36 36 /* Install the signal handler */ 37 37 38 #include " app_test.h"38 #include "test_app.h" 39 39 40 40 static pthread_t th = (pthread_t) NULL; 41 41 42 static void * atst_sig_th(void * arg)42 static void * ta_sig_th(void * arg) 43 43 { 44 44 int sig; … … 50 50 51 51 sigemptyset(&ss); 52 sigaddset(&ss, atst_conf->signal);52 sigaddset(&ss, ta_conf->signal); 53 53 54 54 while (1) { … … 69 69 } 70 70 71 int atst_sig_init(void (*cb)(void))71 int ta_sig_init(void (*cb)(void)) 72 72 { 73 return pthread_create( &th, NULL, atst_sig_th, (void *)cb );73 return pthread_create( &th, NULL, ta_sig_th, (void *)cb ); 74 74 } 75 75 76 void atst_sig_fini(void)76 void ta_sig_fini(void) 77 77 { 78 78 void * th_ret = NULL; -
extensions/test_app/test_app.c
r108 r120 38 38 */ 39 39 40 #include " app_test.h"40 #include "test_app.h" 41 41 #include <signal.h> 42 42 43 43 /* Initialize the configuration */ 44 struct atst_conf * atst_conf = NULL;45 static struct atst_conf _conf;44 struct ta_conf * ta_conf = NULL; 45 static struct ta_conf _conf; 46 46 47 static int atst_conf_init(void)47 static int ta_conf_init(void) 48 48 { 49 atst_conf = &_conf;50 memset( atst_conf, 0, sizeof(struct atst_conf));49 ta_conf = &_conf; 50 memset(ta_conf, 0, sizeof(struct ta_conf)); 51 51 52 52 /* Set the default values */ 53 atst_conf->vendor_id = 999999; /* Dummy value */54 atst_conf->appli_id = 0xffffff; /* dummy value */55 atst_conf->cmd_id = 0xfffffe; /* Experimental */56 atst_conf->avp_id = 0xffffff; /* dummy value */57 atst_conf->mode = MODE_SERV | MODE_CLI;58 atst_conf->dest_realm = strdup(fd_g_config->cnf_diamrlm);59 atst_conf->dest_host = NULL;60 atst_conf->signal = APP_TEST_DEFAULT_SIGNAL;53 ta_conf->vendor_id = 999999; /* Dummy value */ 54 ta_conf->appli_id = 0xffffff; /* dummy value */ 55 ta_conf->cmd_id = 0xfffffe; /* Experimental */ 56 ta_conf->avp_id = 0xffffff; /* dummy value */ 57 ta_conf->mode = MODE_SERV | MODE_CLI; 58 ta_conf->dest_realm = strdup(fd_g_config->cnf_diamrlm); 59 ta_conf->dest_host = NULL; 60 ta_conf->signal = TEST_APP_DEFAULT_SIGNAL; 61 61 62 62 return 0; 63 63 } 64 64 65 static void atst_conf_dump(void)65 static void ta_conf_dump(void) 66 66 { 67 67 if (!TRACE_BOOL(INFO)) 68 68 return; 69 69 fd_log_debug( "------- app_test configuration dump: ---------\n"); 70 fd_log_debug( " Vendor Id .......... : %u\n", atst_conf->vendor_id);71 fd_log_debug( " Application Id ..... : %u\n", atst_conf->appli_id);72 fd_log_debug( " Command Id ......... : %u\n", atst_conf->cmd_id);73 fd_log_debug( " AVP Id ............. : %u\n", atst_conf->avp_id);74 fd_log_debug( " Mode ............... : %s%s\n", atst_conf->mode & MODE_SERV ? "Serv" : "", atst_conf->mode & MODE_CLI ? "Cli" : "" );75 fd_log_debug( " Destination Realm .. : %s\n", atst_conf->dest_realm ?: "- none -");76 fd_log_debug( " Destination Host ... : %s\n", atst_conf->dest_host ?: "- none -");77 fd_log_debug( " Signal ............. : %i\n", atst_conf->signal);70 fd_log_debug( " Vendor Id .......... : %u\n", ta_conf->vendor_id); 71 fd_log_debug( " Application Id ..... : %u\n", ta_conf->appli_id); 72 fd_log_debug( " Command Id ......... : %u\n", ta_conf->cmd_id); 73 fd_log_debug( " AVP Id ............. : %u\n", ta_conf->avp_id); 74 fd_log_debug( " Mode ............... : %s%s\n", ta_conf->mode & MODE_SERV ? "Serv" : "", ta_conf->mode & MODE_CLI ? "Cli" : "" ); 75 fd_log_debug( " Destination Realm .. : %s\n", ta_conf->dest_realm ?: "- none -"); 76 fd_log_debug( " Destination Host ... : %s\n", ta_conf->dest_host ?: "- none -"); 77 fd_log_debug( " Signal ............. : %i\n", ta_conf->signal); 78 78 fd_log_debug( "------- /app_test configuration dump ---------\n"); 79 79 } 80 80 81 81 /* entry point */ 82 static int atst_entry(char * conffile)82 static int ta_entry(char * conffile) 83 83 { 84 84 TRACE_ENTRY("%p", conffile); 85 85 86 86 /* Initialize configuration */ 87 CHECK_FCT( atst_conf_init() );87 CHECK_FCT( ta_conf_init() ); 88 88 89 89 /* Parse configuration file */ 90 90 if (conffile != NULL) { 91 CHECK_FCT( atst_conf_handle(conffile) );91 CHECK_FCT( ta_conf_handle(conffile) ); 92 92 } 93 93 94 TRACE_DEBUG(INFO, "Extension APP/Testinitialized with configuration: '%s'", conffile);95 atst_conf_dump();94 TRACE_DEBUG(INFO, "Extension Test_App initialized with configuration: '%s'", conffile); 95 ta_conf_dump(); 96 96 97 97 /* Install objects definitions for this test application */ 98 CHECK_FCT( atst_dict_init() );98 CHECK_FCT( ta_dict_init() ); 99 99 100 100 /* Install the handlers for incoming messages */ 101 if ( atst_conf->mode & MODE_SERV) {102 CHECK_FCT( atst_serv_init() );101 if (ta_conf->mode & MODE_SERV) { 102 CHECK_FCT( ta_serv_init() ); 103 103 } 104 104 105 105 /* Start the signal handler thread */ 106 if ( atst_conf->mode & MODE_CLI) {107 CHECK_FCT( atst_cli_init() );106 if (ta_conf->mode & MODE_CLI) { 107 CHECK_FCT( ta_cli_init() ); 108 108 } 109 109 110 110 /* Advertise the support for the test application in the peer */ 111 CHECK_FCT( fd_disp_app_support ( atst_appli, atst_vendor, 1, 0 ) );111 CHECK_FCT( fd_disp_app_support ( ta_appli, ta_vendor, 1, 0 ) ); 112 112 113 113 return 0; … … 117 117 void fd_ext_fini(void) 118 118 { 119 if ( atst_conf->mode & MODE_CLI)120 atst_cli_fini();121 if ( atst_conf->mode & MODE_SERV)122 atst_serv_fini();119 if (ta_conf->mode & MODE_CLI) 120 ta_cli_fini(); 121 if (ta_conf->mode & MODE_SERV) 122 ta_serv_fini(); 123 123 } 124 124 125 EXTENSION_ENTRY(" app_test", atst_entry);125 EXTENSION_ENTRY("test_app", ta_entry); -
extensions/test_app/test_app.h
r97 r120 43 43 #include <freeDiameter/extension.h> 44 44 45 #ifndef APP_TEST_DEFAULT_SIGNAL46 #define APP_TEST_DEFAULT_SIGNAL SIGUSR147 #endif /* APP_TEST_DEFAULT_SIGNAL */45 #ifndef TEST_APP_DEFAULT_SIGNAL 46 #define TEST_APP_DEFAULT_SIGNAL SIGUSR1 47 #endif /* TEST_APP_DEFAULT_SIGNAL */ 48 48 49 49 … … 53 53 54 54 /* The module configuration */ 55 struct atst_conf {55 struct ta_conf { 56 56 uint32_t vendor_id; /* default 999999 */ 57 57 uint32_t appli_id; /* default 123456 */ … … 61 61 char * dest_realm; /* default local realm */ 62 62 char * dest_host; /* default NULL */ 63 int signal; /* default APP_TEST_DEFAULT_SIGNAL */63 int signal; /* default TEST_APP_DEFAULT_SIGNAL */ 64 64 }; 65 extern struct atst_conf * atst_conf;65 extern struct ta_conf * ta_conf; 66 66 67 67 /* Parse the configuration file */ 68 int atst_conf_handle(char * conffile);68 int ta_conf_handle(char * conffile); 69 69 70 70 /* Start or stop the signal handler */ 71 int atst_sig_init(void (*cb)(void));72 void atst_sig_fini(void);71 int ta_sig_init(void (*cb)(void)); 72 void ta_sig_fini(void); 73 73 74 74 /* Handle incoming messages (server) */ 75 int atst_serv_init(void);76 void atst_serv_fini(void);75 int ta_serv_init(void); 76 void ta_serv_fini(void); 77 77 78 78 /* Create outgoing message (client) */ 79 int atst_cli_init(void);80 void atst_cli_fini(void);79 int ta_cli_init(void); 80 void ta_cli_fini(void); 81 81 82 82 /* Initialize dictionary definitions */ 83 int atst_dict_init(void);83 int ta_dict_init(void); 84 84 85 85 86 86 /* Some global variables for dictionary */ 87 extern struct dict_object * atst_vendor;88 extern struct dict_object * atst_appli;89 extern struct dict_object * atst_cmd_r;90 extern struct dict_object * atst_cmd_a;91 extern struct dict_object * atst_avp;87 extern struct dict_object * ta_vendor; 88 extern struct dict_object * ta_appli; 89 extern struct dict_object * ta_cmd_r; 90 extern struct dict_object * ta_cmd_a; 91 extern struct dict_object * ta_avp; 92 92 93 extern struct dict_object * atst_sess_id;94 extern struct dict_object * atst_origin_host;95 extern struct dict_object * atst_origin_realm;96 extern struct dict_object * atst_dest_host;97 extern struct dict_object * atst_dest_realm;98 extern struct dict_object * atst_res_code;93 extern struct dict_object * ta_sess_id; 94 extern struct dict_object * ta_origin_host; 95 extern struct dict_object * ta_origin_realm; 96 extern struct dict_object * ta_dest_host; 97 extern struct dict_object * ta_dest_realm; 98 extern struct dict_object * ta_res_code; -
extensions/test_rt_any/CMakeLists.txt
r118 r120 3 3 4 4 # Compile as a module 5 FD_ADD_EXTENSION( rt_anyrt_any.c)5 FD_ADD_EXTENSION(test_rt_any test_rt_any.c) -
extensions/test_rt_any/test_rt_any.c
r118 r120 41 41 42 42 /* The callback */ 43 static int rtany_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates)43 static int tra_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates) 44 44 { 45 45 struct fd_list * li; … … 58 58 59 59 /* Register the callbacks to the daemon */ 60 static int rtany_main(char * conffile)60 static int tra_main(char * conffile) 61 61 { 62 62 TRACE_ENTRY("%p", conffile); 63 CHECK_FCT( fd_rt_out_register ( rtany_out_cb, NULL, 0 /* we call it late so that it replaces previous scores */, &out_hdl ) );63 CHECK_FCT( fd_rt_out_register ( tra_out_cb, NULL, 0 /* we call it late so that it replaces previous scores */, &out_hdl ) ); 64 64 return 0; 65 65 } … … 74 74 75 75 /* Define the entry point function */ 76 EXTENSION_ENTRY(" rt_any", rtany_main);76 EXTENSION_ENTRY("test_rt_any", tra_main);
Note: See TracChangeset
for help on using the changeset viewer.