Changeset 120:d7acdc46134d in freeDiameter for extensions/test_app/test_app.c
- Timestamp:
- Dec 9, 2009, 5:36:38 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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);
Note: See TracChangeset
for help on using the changeset viewer.