Changeset 10:c5c99c73c2bf in freeDiameter for extensions/_sample/sample.c
- Timestamp:
- Sep 25, 2009, 4:12:08 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/_sample/sample.c
r9 r10 45 45 static int sample_main(char * conffile) 46 46 { 47 /* The debug macro from main tree can be used the same way */ 47 48 TRACE_ENTRY("%p", conffile); 48 49 49 fprintf(stdout, "I am extension " __FILE__ " running on host %s\n", fd_g_config->diam_id); 50 /* This is how we access daemon's global vars */ 51 fprintf(stdout, "I am extension " __FILE__ " running on host %s.", fd_g_config->cnf_diamid); 50 52 53 /* The configuration file name is received in the conffile var. It's up to extension to parse it */ 51 54 if (conffile) { 52 55 fprintf(stdout, "I should parse my configuration file there: %s\n", conffile); … … 55 58 } 56 59 57 /* Use the dictionary for test*/58 fd_log_debug("Let's create that 'Example-AVP'...\n");60 /* Functions from the libfreediameter can also be used as demonstrated here: */ 61 TRACE_DEBUG(INFO, "Let's create that 'Example-AVP'..."); 59 62 { 60 63 struct dict_object * origin_host_avp = NULL; … … 64 67 struct dict_avp_data example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED }; 65 68 66 CHECK_FCT( fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT));67 CHECK_FCT( fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT));69 CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT)); 70 CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT)); 68 71 69 CHECK_FCT( fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ));72 CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp )); 70 73 71 74 rule_data.rule_avp = origin_host_avp; 72 75 rule_data.rule_min = 1; 73 76 rule_data.rule_max = 1; 74 CHECK_FCT( fd_dict_new ( fd_g_config-> g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));77 CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL )); 75 78 76 79 rule_data.rule_avp = session_id_avp; 77 80 rule_data.rule_min = 1; 78 81 rule_data.rule_max = -1; 79 CHECK_FCT( fd_dict_new ( fd_g_config->g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL )); 82 CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL )); 83 84 fd_dict_dump_object(example_avp_avp); 80 85 } 81 fd_log_debug("'Example-AVP' created without error\n");86 TRACE_DEBUG(INFO, "'Example-AVP' created without error\n"); 82 87 88 /* The initialization function returns an error code with the standard POSIX meaning (ENOMEM, and so on) */ 83 89 return 0; 84 90 } 91 92 /* See file fini.c for an example of destructor */
Note: See TracChangeset
for help on using the changeset viewer.