Changeset 10:c5c99c73c2bf in freeDiameter
- Timestamp:
- Sep 25, 2009, 4:12:08 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 10 added
- 19 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
doc/freediameter.conf.sample
r9 r10 129 129 TwTimer = 6; 130 130 NoRelay; 131 #LoadExtension = "extensions/sample.fdx"; 132 LoadExtension = "extensions/sample.fdx":"conf/sample.conf"; 131 LoadExtension = "extensions/dbg_monitor.fdx"; 132 LoadExtension = "extensions/dict_nasreq.fdx"; 133 LoadExtension = "extensions/dict_eap.fdx"; -
extensions/CMakeLists.txt
r9 r10 18 18 #### 19 19 # Diameter applications dictionary 20 #OPTION(BUILD_DICT_NASREQ "Build NASREQ (RFC4005) Dictionary definitions?" ON)21 #IF (BUILD_DICT_NASREQ)22 #SUBDIRS(dict_nasreq)23 #ENDIF (BUILD_DICT_NASREQ)20 OPTION(BUILD_DICT_NASREQ "Build NASREQ (RFC4005) Dictionary definitions?" ON) 21 IF (BUILD_DICT_NASREQ) 22 SUBDIRS(dict_nasreq) 23 ENDIF (BUILD_DICT_NASREQ) 24 24 25 #OPTION(BUILD_DICT_EAP "Build Diameter EAP (RFC4072) Dictionary definitions?" ON)26 #IF (BUILD_DICT_EAP)27 #SUBDIRS(dict_eap)28 #ENDIF (BUILD_DICT_EAP)25 OPTION(BUILD_DICT_EAP "Build Diameter EAP (RFC4072) Dictionary definitions?" ON) 26 IF (BUILD_DICT_EAP) 27 SUBDIRS(dict_eap) 28 ENDIF (BUILD_DICT_EAP) 29 29 30 30 … … 59 59 # Debug / development extensions 60 60 61 OPTION(BUILD_SAMPLE "Build sample ? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF)61 OPTION(BUILD_SAMPLE "Build sample.fdx? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF) 62 62 IF (BUILD_SAMPLE) 63 63 SUBDIRS(_sample) 64 64 ENDIF (BUILD_SAMPLE) 65 66 OPTION(BUILD_MONITOR "Build monitor.fdx? (display periodical debug information on the console)" OFF) 67 IF (BUILD_MONITOR) 68 SUBDIRS(dbg_monitor) 69 ENDIF (BUILD_MONITOR) 65 70 66 71 # OPTION(BUILD_RT_ANY "Build rt_any? (Routing extension sending message to any peer available, for testing purpose only)" OFF) -
extensions/_sample/CMakeLists.txt
r9 r10 3 3 4 4 # Compile as a module 5 FD_ADD_EXTENSION( sample sample.c fini.c)5 FD_ADD_EXTENSION(dbg_sample sample.c fini.c) -
extensions/_sample/fini.c
r9 r10 34 34 *********************************************************************************************************/ 35 35 36 /* Sample extension exit point */37 38 36 #include <freeDiameter/extension.h> 39 37 38 /* The function MUST be called this */ 40 39 void fd_ext_fini(void) 41 40 { 42 fd_log_debug("Extension is terminated... Bye!\n"); 41 /* This code is executed when the daemon is exiting; cleanup management should be placed here */ 42 TRACE_DEBUG(INFO, "Extension is terminated... Bye!"); 43 43 return ; 44 44 } -
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 */ -
freeDiameter/CMakeLists.txt
r8 r10 11 11 fD.h 12 12 config.c 13 dispatch.c 13 14 extensions.c 14 15 dict_base_proto.c 16 messages.c 17 queues.c 15 18 ) 16 19 -
freeDiameter/config.c
r8 r10 43 43 TRACE_ENTRY(); 44 44 45 fd_g_config->eyec = EYEC_CONFIG; 46 fd_g_config->conf_file = DEFAULT_CONF_FILE; 47 48 fd_g_config->loc_port = 3868; 49 fd_g_config->loc_port_tls = 3869; 50 fd_g_config->loc_sctp_str = 30; 51 fd_list_init(&fd_g_config->loc_endpoints, NULL); 52 45 fd_g_config->cnf_eyec = EYEC_CONFIG; 46 fd_g_config->cnf_file = DEFAULT_CONF_FILE; 47 48 fd_g_config->cnf_timer_tc = 30; 49 fd_g_config->cnf_timer_tw = 30; 50 51 fd_g_config->cnf_port = 3868; 52 fd_g_config->cnf_port_tls = 3869; 53 fd_g_config->cnf_sctp_str = 30; 54 fd_list_init(&fd_g_config->cnf_endpoints, NULL); 55 fd_list_init(&fd_g_config->cnf_apps, NULL); 53 56 #ifdef DISABLE_SCTP 54 fd_g_config-> flags.no_sctp = 1;57 fd_g_config->cnf_flags.no_sctp = 1; 55 58 #endif /* DISABLE_SCTP */ 56 59 57 fd_g_config->timer_tc = 30; 58 fd_g_config->timer_tw = 30; 59 60 fd_g_config->or_state_id = (uint32_t) time(NULL); 61 62 CHECK_FCT( fd_dict_init(&fd_g_config->g_dict) ); 63 CHECK_FCT( fd_fifo_new(&fd_g_config->g_fifo_main) ); 60 fd_g_config->cnf_orstateid = (uint32_t) time(NULL); 61 62 CHECK_FCT( fd_dict_init(&fd_g_config->cnf_dict) ); 63 CHECK_FCT( fd_fifo_new(&fd_g_config->cnf_main_ev) ); 64 64 65 65 return 0; … … 73 73 fd_log_debug("-- Configuration :\n"); 74 74 fd_log_debug(" Debug trace level ...... : %+d\n", fd_g_debug_lvl); 75 fd_log_debug(" Configuration file ..... : %s\n", fd_g_config->conf_file); 76 fd_log_debug(" Diameter Identity ...... : %s (l:%Zi)\n", fd_g_config->diam_id, fd_g_config->diam_id_len); 77 fd_log_debug(" Diameter Realm ......... : %s (l:%Zi)\n", fd_g_config->diam_realm, fd_g_config->diam_realm_len); 78 fd_log_debug(" Local port ............. : %hu\n", fd_g_config->loc_port); 79 fd_log_debug(" Local secure port ...... : %hu\n", fd_g_config->loc_port_tls); 80 fd_log_debug(" Number of SCTP streams . : %hu\n", fd_g_config->loc_sctp_str); 81 if (FD_IS_LIST_EMPTY(&fd_g_config->loc_endpoints)) { 75 fd_log_debug(" Configuration file ..... : %s\n", fd_g_config->cnf_file); 76 fd_log_debug(" Diameter Identity ...... : %s (l:%Zi)\n", fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len); 77 fd_log_debug(" Diameter Realm ......... : %s (l:%Zi)\n", fd_g_config->cnf_diamrlm, fd_g_config->cnf_diamrlm_len); 78 fd_log_debug(" Tc Timer ............... : %u\n", fd_g_config->cnf_timer_tc); 79 fd_log_debug(" Tw Timer ............... : %u\n", fd_g_config->cnf_timer_tw); 80 fd_log_debug(" Local port ............. : %hu\n", fd_g_config->cnf_port); 81 fd_log_debug(" Local secure port ...... : %hu\n", fd_g_config->cnf_port_tls); 82 fd_log_debug(" Number of SCTP streams . : %hu\n", fd_g_config->cnf_sctp_str); 83 if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints)) { 82 84 fd_log_debug(" Local endpoints ........ : Default (use all available)\n"); 83 85 } else { 84 struct fd_list * li = fd_g_config-> loc_endpoints.next;86 struct fd_list * li = fd_g_config->cnf_endpoints.next; 85 87 fd_log_debug(" Local endpoints ........ : "); 86 while (li != &fd_g_config-> loc_endpoints) {88 while (li != &fd_g_config->cnf_endpoints) { 87 89 struct fd_endpoint * ep = (struct fd_endpoint *)li; 88 if (li != fd_g_config-> loc_endpoints.next) fd_log_debug(" ");90 if (li != fd_g_config->cnf_endpoints.next) fd_log_debug(" "); 89 91 sSA_DUMP_NODE( &ep->ss, NI_NUMERICHOST ); 90 92 fd_log_debug("\n"); … … 92 94 } 93 95 } 94 fd_log_debug(" Flags : - IP ........... : %s\n", fd_g_config->flags.no_ip4 ? "DISABLED" : "Enabled"); 95 fd_log_debug(" - IPv6 ......... : %s\n", fd_g_config->flags.no_ip6 ? "DISABLED" : "Enabled"); 96 fd_log_debug(" - Relay app .... : %s\n", fd_g_config->flags.no_fwd ? "DISABLED" : "Enabled"); 97 fd_log_debug(" - TCP .......... : %s\n", fd_g_config->flags.no_tcp ? "DISABLED" : "Enabled"); 96 if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_apps)) { 97 fd_log_debug(" Local applications ..... : (none)\n"); 98 } else { 99 struct fd_list * li = fd_g_config->cnf_apps.next; 100 fd_log_debug(" Local applications ..... : "); 101 while (li != &fd_g_config->cnf_apps) { 102 struct fd_app * app = (struct fd_app *)li; 103 if (li != fd_g_config->cnf_apps.next) fd_log_debug(" "); 104 fd_log_debug("App: %u\t%s%s%s\tVnd: %u\n", 105 app->appid, 106 app->flags.auth ? "Au" : "--", 107 app->flags.acct ? "Ac" : "--", 108 app->flags.common ? "C" : "-", 109 app->vndid); 110 li = li->next; 111 } 112 } 113 fd_log_debug(" Flags : - IP ........... : %s\n", fd_g_config->cnf_flags.no_ip4 ? "DISABLED" : "Enabled"); 114 fd_log_debug(" - IPv6 ......... : %s\n", fd_g_config->cnf_flags.no_ip6 ? "DISABLED" : "Enabled"); 115 fd_log_debug(" - Relay app .... : %s\n", fd_g_config->cnf_flags.no_fwd ? "DISABLED" : "Enabled"); 116 fd_log_debug(" - TCP .......... : %s\n", fd_g_config->cnf_flags.no_tcp ? "DISABLED" : "Enabled"); 98 117 #ifdef DISABLE_SCTP 99 118 fd_log_debug(" - SCTP ......... : DISABLED (at compilation)\n"); 100 119 #else /* DISABLE_SCTP */ 101 fd_log_debug(" - SCTP ......... : %s\n", fd_g_config-> flags.no_sctp ? "DISABLED" : "Enabled");120 fd_log_debug(" - SCTP ......... : %s\n", fd_g_config->cnf_flags.no_sctp ? "DISABLED" : "Enabled"); 102 121 #endif /* DISABLE_SCTP */ 103 fd_log_debug(" - Pref. proto .. : %s\n", fd_g_config->flags.pr_tcp ? "TCP" : "SCTP"); 104 fd_log_debug(" - TLS method ... : %s\n", fd_g_config->flags.tls_alg ? "INBAND" : "Separate port"); 105 fd_log_debug(" Tc Timer ............... : %u\n", fd_g_config->timer_tc); 106 fd_log_debug(" Tw Timer ............... : %u\n", fd_g_config->timer_tw); 107 fd_log_debug(" Origin-State-Id ........ : %u\n", fd_g_config->or_state_id); 122 fd_log_debug(" - Pref. proto .. : %s\n", fd_g_config->cnf_flags.pr_tcp ? "TCP" : "SCTP"); 123 fd_log_debug(" - TLS method ... : %s\n", fd_g_config->cnf_flags.tls_alg ? "INBAND" : "Separate port"); 124 fd_log_debug(" Origin-State-Id ........ : %u\n", fd_g_config->cnf_orstateid); 108 125 } 109 126 … … 113 130 extern FILE * fddin; 114 131 115 TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->c onf_file);116 117 fddin = fopen(fd_g_config->c onf_file, "r");132 TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->cnf_file); 133 134 fddin = fopen(fd_g_config->cnf_file, "r"); 118 135 if (fddin == NULL) { 119 136 int ret = errno; 120 fprintf(stderr, "Unable to open configuration file %s for reading: %s\n", fd_g_config->c onf_file, strerror(ret));137 fprintf(stderr, "Unable to open configuration file %s for reading: %s\n", fd_g_config->cnf_file, strerror(ret)); 121 138 return ret; 122 139 } … … 129 146 130 147 /* Resolve hostname if not provided */ 131 if (fd_g_config-> diam_id == NULL) {148 if (fd_g_config->cnf_diamid == NULL) { 132 149 #ifndef HOST_NAME_MAX 133 150 #define HOST_NAME_MAX 1024 … … 152 169 return EINVAL; 153 170 } 154 CHECK_MALLOC( fd_g_config-> diam_id = strdup(info->ai_canonname) );171 CHECK_MALLOC( fd_g_config->cnf_diamid = strdup(info->ai_canonname) ); 155 172 freeaddrinfo(info); 156 173 } 157 174 158 175 /* cache the length of the diameter id for the session module */ 159 fd_g_config-> diam_id_len = strlen(fd_g_config->diam_id);176 fd_g_config->cnf_diamid_len = strlen(fd_g_config->cnf_diamid); 160 177 161 178 /* Handle the realm part */ 162 if (fd_g_config-> diam_realm == NULL) {179 if (fd_g_config->cnf_diamrlm == NULL) { 163 180 char * start = NULL; 164 181 165 182 /* Check the diameter identity is a fqdn */ 166 start = strchr(fd_g_config-> diam_id, '.');183 start = strchr(fd_g_config->cnf_diamid, '.'); 167 184 if ((start == NULL) || (start[1] == '\0')) { 168 185 fprintf(stderr, "Unable to extract realm from the LocalIdentity '%s'.\n" 169 186 "Please fix your LocalIdentity setting or provide LocalRealm.\n", 170 fd_g_config-> diam_id);187 fd_g_config->cnf_diamid); 171 188 return EINVAL; 172 189 } 173 190 174 CHECK_MALLOC( fd_g_config-> diam_realm = strdup( start + 1 ) );175 } 176 fd_g_config-> diam_realm_len = strlen(fd_g_config->diam_realm);191 CHECK_MALLOC( fd_g_config->cnf_diamrlm = strdup( start + 1 ) ); 192 } 193 fd_g_config->cnf_diamrlm_len = strlen(fd_g_config->cnf_diamrlm); 177 194 178 195 /* Validate some flags */ 179 if (fd_g_config-> flags.no_ip4 && fd_g_config->flags.no_ip6) {196 if (fd_g_config->cnf_flags.no_ip4 && fd_g_config->cnf_flags.no_ip6) { 180 197 fprintf(stderr, "IP and IPv6 cannot be disabled at the same time.\n"); 181 198 return EINVAL; 182 199 } 183 if (fd_g_config-> flags.no_tcp && fd_g_config->flags.no_sctp) {200 if (fd_g_config->cnf_flags.no_tcp && fd_g_config->cnf_flags.no_sctp) { 184 201 fprintf(stderr, "TCP and SCTP cannot be disabled at the same time.\n"); 185 202 return EINVAL; -
freeDiameter/extensions.c
r9 r10 79 79 TRACE_DEBUG (FULL, "Extension %s added to the list.", filename); 80 80 return 0; 81 } 82 83 /* Dump the list */ 84 void fd_ext_dump(void) 85 { 86 struct fd_list * li; 87 88 fd_log_debug("Dumping extensions list :\n"); 89 90 for (li = ext_list.next; li != &ext_list; li = li->next) 91 { 92 struct fd_ext_info * ext = (struct fd_ext_info *)li; 93 fd_log_debug(" - '%s'[%s] is %sloaded\n", ext->filename, ext->conffile?:"no conf", ext->handler ? "" : "not "); 94 } 81 95 } 82 96 -
freeDiameter/fD.h
r8 r10 42 42 #include <freeDiameter/freeDiameter.h> 43 43 44 /* Events codespace for fd_g_config->g_fifo_main */45 enum {46 FM_TERMINATE = 1000 /* request to terminate */47 };48 49 44 /* Configuration */ 50 45 int fd_conf_init(); … … 57 52 int fd_ext_add( char * filename, char * conffile ); 58 53 int fd_ext_load(); 54 void fd_ext_dump(void); 59 55 int fd_ext_fini(void); 56 57 /* Messages */ 58 int fd_msg_init(void); 59 60 /* Global message queues */ 61 extern struct fifo * fd_g_incoming; /* all messages received from other peers, except local messages (CER, ...) */ 62 extern struct fifo * fd_g_outgoing; /* messages to be sent to other peers on the network following routing procedure */ 63 extern struct fifo * fd_g_local; /* messages to be handled to local extensions */ 64 /* Message queues */ 65 int fd_queues_init(void); 66 int fd_queues_fini(void); 60 67 61 68 /* Create all the dictionary objects defined in the Diameter base RFC. */ -
freeDiameter/fdd.y
r8 r10 63 63 { 64 64 if (ploc->first_line != ploc->last_line) 65 fprintf(stderr, "%s:%d.%d-%d.%d : %s\n", conf->c onf_file, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s);65 fprintf(stderr, "%s:%d.%d-%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s); 66 66 else if (ploc->first_column != ploc->last_column) 67 fprintf(stderr, "%s:%d.%d-%d : %s\n", conf->c onf_file, ploc->first_line, ploc->first_column, ploc->last_column, s);67 fprintf(stderr, "%s:%d.%d-%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, ploc->last_column, s); 68 68 else 69 fprintf(stderr, "%s:%d.%d : %s\n", conf->c onf_file, ploc->first_line, ploc->first_column, s);69 fprintf(stderr, "%s:%d.%d : %s\n", conf->cnf_file, ploc->first_line, ploc->first_column, s); 70 70 } 71 71 … … 111 111 | conffile localidentity 112 112 | conffile localrealm 113 | conffile tctimer 114 | conffile twtimer 113 115 | conffile localport 114 116 | conffile localsecport 117 | conffile sctpstreams 118 | conffile listenon 119 | conffile norelay 115 120 | conffile noip 116 121 | conffile noip6 … … 119 124 | conffile prefertcp 120 125 | conffile oldtls 121 | conffile sctpstreams122 | conffile listenon123 | conffile tctimer124 | conffile twtimer125 | conffile norelay126 126 | conffile loadext 127 127 ; … … 129 129 localidentity: LOCALIDENTITY '=' QSTRING ';' 130 130 { 131 conf-> diam_id = $3;131 conf->cnf_diamid = $3; 132 132 } 133 133 ; … … 135 135 localrealm: LOCALREALM '=' QSTRING ';' 136 136 { 137 conf->diam_realm = $3; 137 conf->cnf_diamrlm = $3; 138 } 139 ; 140 141 tctimer: TCTIMER '=' INTEGER ';' 142 { 143 CHECK_PARAMS_DO( ($3 > 0), 144 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 145 conf->cnf_timer_tc = (unsigned int)$3; 146 } 147 ; 148 149 twtimer: TWTIMER '=' INTEGER ';' 150 { 151 CHECK_PARAMS_DO( ($3 > 5), 152 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 153 conf->cnf_timer_tw = (unsigned int)$3; 138 154 } 139 155 ; … … 143 159 CHECK_PARAMS_DO( ($3 > 0) && ($3 < 1<<16), 144 160 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 145 conf-> loc_port = (uint16_t)$3;161 conf->cnf_port = (uint16_t)$3; 146 162 } 147 163 ; … … 151 167 CHECK_PARAMS_DO( ($3 > 0) && ($3 < 1<<16), 152 168 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 153 conf->loc_port_tls = (uint16_t)$3; 154 } 155 ; 156 157 noip: NOIP ';' 158 { 159 conf->flags.no_ip4 = 1; 160 } 161 ; 162 163 noip6: NOIP6 ';' 164 { 165 conf->flags.no_ip6 = 1; 166 } 167 ; 168 169 notcp: NOTCP ';' 170 { 171 conf->flags.no_tcp = 1; 172 } 173 ; 174 175 nosctp: NOSCTP ';' 176 { 177 conf->flags.no_sctp = 1; 178 } 179 ; 180 181 prefertcp: PREFERTCP ';' 182 { 183 conf->flags.pr_tcp = 1; 184 } 185 ; 186 187 oldtls: OLDTLS ';' 188 { 189 conf->flags.tls_alg = 1; 169 conf->cnf_port_tls = (uint16_t)$3; 190 170 } 191 171 ; … … 195 175 CHECK_PARAMS_DO( ($3 > 0) && ($3 < 1<<16), 196 176 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 197 conf-> loc_sctp_str = (uint16_t)$3;177 conf->cnf_sctp_str = (uint16_t)$3; 198 178 } 199 179 ; … … 218 198 free($3); 219 199 freeaddrinfo(ai); 220 fd_list_insert_before(&conf->loc_endpoints, &ep->chain); 221 } 222 ; 223 224 tctimer: TCTIMER '=' INTEGER ';' 225 { 226 CHECK_PARAMS_DO( ($3 > 0), 227 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 228 conf->timer_tc = (unsigned int)$3; 229 } 230 ; 231 232 twtimer: TWTIMER '=' INTEGER ';' 233 { 234 CHECK_PARAMS_DO( ($3 > 5), 235 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 236 conf->timer_tw = (unsigned int)$3; 200 fd_list_insert_before(&conf->cnf_endpoints, &ep->chain); 237 201 } 238 202 ; … … 240 204 norelay: NORELAY ';' 241 205 { 242 conf->flags.no_fwd = 1; 206 conf->cnf_flags.no_fwd = 1; 207 } 208 ; 209 210 noip: NOIP ';' 211 { 212 conf->cnf_flags.no_ip4 = 1; 213 } 214 ; 215 216 noip6: NOIP6 ';' 217 { 218 conf->cnf_flags.no_ip6 = 1; 219 } 220 ; 221 222 notcp: NOTCP ';' 223 { 224 conf->cnf_flags.no_tcp = 1; 225 } 226 ; 227 228 nosctp: NOSCTP ';' 229 { 230 conf->cnf_flags.no_sctp = 1; 231 } 232 ; 233 234 prefertcp: PREFERTCP ';' 235 { 236 conf->cnf_flags.pr_tcp = 1; 237 } 238 ; 239 240 oldtls: OLDTLS ';' 241 { 242 conf->cnf_flags.tls_alg = 1; 243 243 } 244 244 ; -
freeDiameter/main.c
r9 r10 39 39 #include <getopt.h> 40 40 41 /* forward declarations */ 42 static void * sig_hdl(void * arg); 43 static int main_cmdline(int argc, char *argv[]); 44 45 /* The static configuration structure */ 46 static struct fd_config conf; 47 struct fd_config * fd_g_config = &conf; 48 49 /* freeDiameter starting point */ 50 int main(int argc, char * argv[]) 51 { 52 int ret; 53 pthread_t sig_th; 54 sigset_t sig_all; 55 56 memset(fd_g_config, 0, sizeof(struct fd_config)); 57 sigfillset(&sig_all); 58 CHECK_POSIX( pthread_sigmask(SIG_BLOCK, &sig_all, NULL) ); 59 60 /* Initialize the library */ 61 CHECK_FCT( fd_lib_init() ); 62 63 /* Name this thread */ 64 fd_log_threadname("Main"); 65 66 /* Initialize the config */ 67 CHECK_FCT( fd_conf_init() ); 68 69 /* Parse the command-line */ 70 CHECK_FCT( main_cmdline(argc, argv) ); 71 72 /* Allow SIGINT and SIGTERM from this point */ 73 CHECK_POSIX( pthread_create(&sig_th, NULL, sig_hdl, NULL) ); 74 75 /* Add definitions of the base protocol */ 76 CHECK_FCT( fd_dict_base_protocol(fd_g_config->cnf_dict) ); 77 78 /* Initialize other modules */ 79 CHECK_FCT( fd_ext_init() ); 80 CHECK_FCT( fd_queues_init() ); 81 CHECK_FCT( fd_msg_init() ); 82 83 /* Parse the configuration file */ 84 CHECK_FCT( fd_conf_parse() ); 85 86 /* Load the dynamic extensions */ 87 CHECK_FCT( fd_ext_load() ); 88 89 /* Start the peer state machines */ 90 91 92 /* Now, just wait for events */ 93 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized."); 94 fd_conf_dump(); 95 while (1) { 96 int code; 97 CHECK_FCT_DO( fd_event_get(fd_g_config->cnf_main_ev, &code, NULL), break ); 98 switch (code) { 99 case FDEV_DUMP_DICT: 100 fd_dict_dump(fd_g_config->cnf_dict); 101 break; 102 103 case FDEV_DUMP_EXT: 104 fd_ext_dump(); 105 break; 106 107 case FDEV_DUMP_QUEUES: 108 fd_fifo_dump(0, "Incoming messages", fd_g_incoming, fd_msg_dump_walk); 109 fd_fifo_dump(0, "Outgoing messages", fd_g_outgoing, fd_msg_dump_walk); 110 fd_fifo_dump(0, "Local messages", fd_g_local, fd_msg_dump_walk); 111 break; 112 113 case FDEV_DUMP_CONFIG: 114 fd_conf_dump(); 115 break; 116 117 118 case FDEV_TERMINATE: 119 ret = 0; 120 goto end; 121 122 default: 123 TRACE_DEBUG(INFO, "Unexpected event in the daemon (%d), ignored.\n", code); 124 } 125 } 126 127 end: 128 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon is stopping..."); 129 130 /* cleanups */ 131 CHECK_FCT_DO( fd_ext_fini(), /* continue */ ); 132 CHECK_FCT_DO( fd_thr_term(&sig_th), /* continue */ ); 133 134 return ret; 135 } 41 136 42 137 /* Display package version */ … … 122 217 case 'c': /* Read configuration from this file instead of the default location.. */ 123 218 CHECK_PARAMS( optarg ); 124 fd_g_config->c onf_file = optarg;219 fd_g_config->cnf_file = optarg; 125 220 break; 126 221 … … 159 254 #endif /* HAVE_SIGNALENT_H */ 160 255 161 162 256 /* signal handler */ 163 257 static void * sig_hdl(void * arg) … … 176 270 177 271 TRACE_DEBUG(INFO, "Received signal %s (%d), exiting", SIGNALSTR(sig), sig); 178 CHECK_FCT_DO( fd_event_send(fd_g_config-> g_fifo_main, FM_TERMINATE, NULL), exit(2) );272 CHECK_FCT_DO( fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, NULL), exit(2) ); 179 273 return NULL; 180 274 } 181 275 182 /* The static configuration structure */183 static struct fd_config conf;184 struct fd_config * fd_g_config = &conf;185 186 /* Entry point */187 int main(int argc, char * argv[])188 {189 int ret;190 pthread_t sig_th;191 sigset_t sig_all;192 193 memset(fd_g_config, 0, sizeof(struct fd_config));194 sigfillset(&sig_all);195 CHECK_POSIX( pthread_sigmask(SIG_BLOCK, &sig_all, NULL) );196 197 /* Initialize the library */198 CHECK_FCT( fd_lib_init() );199 200 /* Name this thread */201 fd_log_threadname("Main");202 203 /* Initialize the config */204 CHECK_FCT( fd_conf_init() );205 206 /* Parse the command-line */207 CHECK_FCT( main_cmdline(argc, argv) );208 209 /* Allow SIGINT and SIGTERM from this point */210 CHECK_POSIX( pthread_create(&sig_th, NULL, sig_hdl, NULL) );211 212 /* Add definitions of the base protocol */213 CHECK_FCT( fd_dict_base_protocol(fd_g_config->g_dict) );214 215 /* Initialize other modules */216 CHECK_FCT( fd_ext_init() );217 218 /* Parse the configuration file */219 CHECK_FCT( fd_conf_parse() );220 221 /* Load the dynamic extensions */222 CHECK_FCT( fd_ext_load() );223 224 /* Start the peer state machines */225 226 227 /* Now, just wait for events */228 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized.");229 fd_conf_dump();230 while (1) {231 int code;232 CHECK_FCT_DO( fd_event_get(fd_g_config->g_fifo_main, &code, NULL), break );233 switch (code) {234 case FM_TERMINATE:235 ret = 0;236 goto end;237 238 default:239 TRACE_DEBUG(INFO, "Unexpected event in the daemon (%d), terminating.\n", code);240 ret = -1;241 goto end;242 }243 }244 245 end:246 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon is stopping...");247 248 /* cleanups */249 CHECK_FCT_DO( fd_ext_fini(), /* continue */ );250 CHECK_FCT_DO( fd_thr_term(&sig_th), /* continue */ );251 252 return ret;253 } -
freeDiameter/tests/CMakeLists.txt
r8 r10 15 15 testdict 16 16 testmesg 17 test queues17 testfifo 18 18 testsess 19 19 testdisp -
freeDiameter/tests/testdict.c
r8 r10 67 67 68 68 /* Create two vendors */ 69 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_VENDOR, &vendor1_data , NULL, &obj1 ) );70 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_VENDOR, &vendor2_data , NULL, NULL ) );69 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_VENDOR, &vendor1_data , NULL, &obj1 ) ); 70 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_VENDOR, &vendor2_data , NULL, NULL ) ); 71 71 72 72 /* Check we always retrieve the correct vendor object */ 73 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) );73 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) ); 74 74 CHECK( obj1, obj2); 75 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 1", &obj2, ENOENT ) );75 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 1", &obj2, ENOENT ) ); 76 76 CHECK( obj1, obj2); 77 77 78 78 /* Check the error conditions */ 79 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) );79 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) ); 80 80 81 81 vendor_id = 735673; /* Not defined */ 82 CHECK( ENOENT, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) );83 CHECK( ENOENT, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", NULL, ENOENT ) );84 CHECK( ENOENT, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) );85 CHECK( ENOENT, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOENT ) );86 CHECK( ENOTSUP, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOTSUP ) );82 CHECK( ENOENT, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) ); 83 CHECK( ENOENT, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", NULL, ENOENT ) ); 84 CHECK( ENOENT, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) ); 85 CHECK( ENOENT, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOENT ) ); 86 CHECK( ENOTSUP, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOTSUP ) ); 87 87 88 88 /* Check the get_* functions */ … … 94 94 95 95 /* Create the application with vendor1 as parent */ 96 CHECK( EINVAL, fd_dict_new ( fd_g_config-> g_dict, DICT_APPLICATION, &app1_data , (struct dict_object *)"bad object", &obj2 ) );97 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_APPLICATION, &app1_data , obj1, &obj2 ) );96 CHECK( EINVAL, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app1_data , (struct dict_object *)"bad object", &obj2 ) ); 97 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app1_data , obj1, &obj2 ) ); 98 98 99 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_VENDOR, VENDOR_OF_APPLICATION, obj2, &obj3, ENOENT ) );99 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_OF_APPLICATION, obj2, &obj3, ENOENT ) ); 100 100 CHECK( obj1, obj3); 101 101 … … 112 112 struct dict_avp_data example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED }; 113 113 114 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT ) );115 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT ) );114 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT ) ); 115 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT ) ); 116 116 117 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ) );117 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ) ); 118 118 119 119 rule_data.rule_avp = origin_host_avp; 120 120 rule_data.rule_min = 1; 121 121 rule_data.rule_max = 1; 122 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) );122 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) ); 123 123 124 124 rule_data.rule_avp = session_id_avp; 125 125 rule_data.rule_min = 1; 126 126 rule_data.rule_max = -1; 127 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) );127 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) ); 128 128 129 129 CHECK( 0, fd_dict_iterate_rules ( example_avp_avp, &nbr, iter_test) ); -
freeDiameter/tests/testdisp.c
r8 r10 128 128 struct dict_enumval_data enu2_data = { "ENU test 2", { .u32 = 2 }}; 129 129 130 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_APPLICATION, &app1_data, NULL, &app1 ) );131 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_APPLICATION, &app2_data, NULL, &app2 ) );132 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_COMMAND, &cmd1_data, NULL, &cmd1 ) );133 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_COMMAND, &cmd2_data, NULL, &cmd2 ) );134 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_TYPE, &type_data, NULL, &enutype ) );135 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp1_data, NULL, &avp1 ) );136 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp2_data, enutype, &avp2 ) );137 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_ENUMVAL, &enu1_data, enutype, &enu1 ) );138 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_ENUMVAL, &enu2_data, enutype, &enu2 ) );130 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app1_data, NULL, &app1 ) ); 131 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app2_data, NULL, &app2 ) ); 132 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd1_data, NULL, &cmd1 ) ); 133 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd2_data, NULL, &cmd2 ) ); 134 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data, NULL, &enutype ) ); 135 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp1_data, NULL, &avp1 ) ); 136 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp2_data, enutype, &avp2 ) ); 137 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &enu1_data, enutype, &enu1 ) ); 138 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &enu2_data, enutype, &enu2 ) ); 139 139 } 140 140 … … 669 669 } 670 670 671 /* Test application support advertisement */ 672 { 673 struct dict_object * vnd; 674 struct dict_vendor_data vnd_data = { 1, "Vendor test" }; 675 struct fd_app * app; 676 677 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_VENDOR, &vnd_data, NULL, &vnd ) ); 678 679 CHECK( EINVAL, fd_disp_app_support ( vnd, NULL, 1, 0 ) ); 680 CHECK( EINVAL, fd_disp_app_support ( app1, NULL, 0, 0 ) ); 681 CHECK( 0, fd_disp_app_support ( app1, NULL, 1, 0 ) ); 682 CHECK( 0, fd_disp_app_support ( app1, NULL, 0, 1 ) ); 683 CHECK( 0, fd_disp_app_support ( app2, vnd, 1, 0 ) ); 684 685 app = (struct fd_app *)(fd_g_config->cnf_apps.next); 686 CHECK( 1, app->appid ); 687 CHECK( 1, app->flags.auth ); 688 CHECK( 1, app->flags.acct ); 689 app = (struct fd_app *)(fd_g_config->cnf_apps.prev); 690 CHECK( 2, app->appid ); 691 CHECK( 1, app->flags.auth ); 692 CHECK( 0, app->flags.acct ); 693 694 #if 0 695 fd_conf_dump(); 696 #endif 697 } 698 671 699 /* That's all for the tests yet */ 672 700 PASSTEST(); -
freeDiameter/tests/testfifo.c
r8 r10 128 128 struct dict_object * dwr_model = NULL; 129 129 130 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );131 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) );132 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) );130 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) ); 131 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) ); 132 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) ); 133 133 CHECK( 0, fd_msg_new ( acr_model, 0, &msg1 ) ); 134 134 CHECK( 0, fd_msg_new ( cer_model, 0, &msg2 ) ); … … 215 215 216 216 /* Create the messages */ 217 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) );217 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) ); 218 218 for (i = 0; i < NBR_MSG * NBR_THREADS * 2; i++) { 219 219 CHECK( 0, fd_msg_new ( dwr_model, 0, &msgs[i] ) ); -
freeDiameter/tests/testmesg.c
r8 r10 51 51 52 52 /* Now find the ACR dictionary object */ 53 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );53 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) ); 54 54 55 55 /* Create the instance, using the templates */ … … 71 71 72 72 /* Now find the ACR dictionary object */ 73 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_model, ENOENT ) );73 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_model, ENOENT ) ); 74 74 75 75 /* Create the instance, using the templates */ … … 133 133 134 134 /* Now find the dictionary object */ 135 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "Route-Record", &rr_model, ENOENT ) );135 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Route-Record", &rr_model, ENOENT ) ); 136 136 137 137 /* Create the instance, using the templates */ … … 161 161 162 162 /* Now find the ACR dictionary object */ 163 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );163 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) ); 164 164 165 165 /* Create the instance, using the templates */ … … 173 173 { 174 174 struct dict_vendor_data vendor_data = { 73565, "Vendor test" }; 175 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_VENDOR, &vendor_data , NULL, &vendor ) );175 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_VENDOR, &vendor_data , NULL, &vendor ) ); 176 176 } 177 177 178 178 { 179 179 struct dict_application_data app_data = { 73566, "Application test" }; 180 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_APPLICATION, &app_data , vendor, NULL ) );180 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app_data , vendor, NULL ) ); 181 181 } 182 182 183 183 { 184 184 struct dict_avp_data avp_data = { 73567, 0, "AVP Test - no vendor - f32", 0, 0, AVP_TYPE_FLOAT32 }; 185 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, NULL ) );185 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 186 186 } 187 187 … … 190 190 struct dict_type_data type_data = { AVP_TYPE_INTEGER64, "Int64 test" }; 191 191 struct dict_avp_data avp_data = { 73568, 73565, "AVP Test - i64", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_INTEGER64 }; 192 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_TYPE, &type_data , NULL, &type ) );193 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , type, NULL ) );192 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) ); 193 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) ); 194 194 } 195 195 … … 202 202 struct dict_avp_data avp_data = { 73569, 73565, "AVP Test - enumi32", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_INTEGER32 }; 203 203 204 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_TYPE, &type_data , NULL, &type ) );205 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , type, NULL ) );206 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_ENUMVAL, &val1 , type, NULL ) );207 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_ENUMVAL, &val2 , type, NULL ) );208 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_ENUMVAL, &val3 , type, NULL ) );204 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) ); 205 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) ); 206 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val1 , type, NULL ) ); 207 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val2 , type, NULL ) ); 208 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val3 , type, NULL ) ); 209 209 } 210 210 … … 213 213 struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS test" }; 214 214 struct dict_avp_data avp_data = { 73570, 73565, "AVP Test - os", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING }; 215 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_TYPE, &type_data , NULL, &type ) );216 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , type, NULL ) );215 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) ); 216 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) ); 217 217 } 218 218 … … 225 225 struct dict_avp_data avp_data = { 73571, 73565, "AVP Test - enumos", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING }; 226 226 227 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_TYPE, &type_data , NULL, &type ) );228 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , type, NULL ) );229 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_ENUMVAL, &val1 , type, NULL ) );230 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_ENUMVAL, &val2 , type, NULL ) );231 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_ENUMVAL, &val3 , type, NULL ) );227 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) ); 228 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) ); 229 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val1 , type, NULL ) ); 230 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val2 , type, NULL ) ); 231 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val3 , type, NULL ) ); 232 232 } 233 233 … … 236 236 struct dict_avp_data avp_data = { 73572, 73565, "AVP Test - grouped", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED }; 237 237 238 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, &gavp ) );238 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, &gavp ) ); 239 239 240 240 /* Macro to search AVP and create a rule */ … … 243 243 struct dict_avp_request _req = { (_vendor), 0, (_avpname) }; \ 244 244 struct dict_rule_data _data; \ 245 CHECK( 0, fd_dict_search( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\245 CHECK( 0, fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\ 246 246 _data.rule_avp = _avp; \ 247 247 _data.rule_position = (_pos); \ … … 249 249 _data.rule_min = (_min); \ 250 250 _data.rule_max = (_max); \ 251 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_RULE, &_data , (_parent), NULL ) ); \251 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &_data , (_parent), NULL ) ); \ 252 252 } 253 253 … … 261 261 struct dict_cmd_data cmd_data = { 73573, "Test-Command-Request", CMD_FLAG_REQUEST, CMD_FLAG_REQUEST }; 262 262 263 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) );264 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_COMMAND, &cmd_data , application, &command ) );263 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) ); 264 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd_data , application, &command ) ); 265 265 ADD_RULE(command, 0, "AVP Test - no vendor - f32", RULE_FIXED_HEAD, -1, 1, 1); 266 266 ADD_RULE(command, 73565, "AVP Test - i64", RULE_REQUIRED, -1, -1, 0); … … 275 275 struct dict_avp_data avp_data = { 73574, 73565, "AVP Test - rules", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED }; 276 276 277 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, &gavp ) );277 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, &gavp ) ); 278 278 279 279 ADD_RULE(gavp, 0, "AVP Test - no vendor - f32", RULE_FIXED_HEAD, 0, 1, 1); … … 303 303 union avp_value value; 304 304 305 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );305 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) ); 306 306 307 307 /* Check an error is trigged if the AVP has no value set */ 308 308 { 309 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) );309 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) ); 310 310 311 311 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) ); … … 329 329 struct dict_object * _avp = NULL; \ 330 330 struct dict_avp_request _req = { (_avpvendor), 0, (_avpname) }; \ 331 CHECK( 0, fd_dict_search( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\331 CHECK( 0, fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\ 332 332 CHECK( 0, fd_msg_avp_new ( _avp, 0, &_avpi ) ); \ 333 333 CHECK( 0, fd_msg_avp_add ( (_parent), (_position), _avpi ) ); \ … … 378 378 379 379 CHECK( 0, fd_msg_model ( avpi, &avp_model ) ); 380 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );380 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) ); 381 381 memset(&request, 0, sizeof(request)); 382 382 request.type_obj = type_model; 383 383 request.search.enum_name = "i32 const test (val 2)"; 384 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );384 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) ); 385 385 CHECK( 0, fd_dict_getval ( value_model, &request.search ) ); 386 386 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) ); … … 399 399 400 400 CHECK( 0, fd_msg_model ( avpi, &avp_model ) ); 401 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );401 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) ); 402 402 memset(&request, 0, sizeof(request)); 403 403 request.type_obj = type_model; 404 404 request.search.enum_name = "i32 const test (val -5)"; 405 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );405 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) ); 406 406 CHECK( 0, fd_dict_getval ( value_model, &request.search ) ); 407 407 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) ); … … 458 458 459 459 CHECK( 0, fd_msg_model ( avpi, &avp_model ) ); 460 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );460 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) ); 461 461 memset(&request, 0, sizeof(request)); 462 462 request.type_obj = type_model; 463 463 request.search.enum_name = "os const test (waaad)"; 464 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );464 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) ); 465 465 CHECK( 0, fd_dict_getval ( value_model, &request.search ) ); 466 466 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) ); … … 483 483 484 484 CHECK( 0, fd_msg_model ( avpi, &avp_model ) ); 485 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );485 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) ); 486 486 memset(&request, 0, sizeof(request)); 487 487 request.type_obj = type_model; 488 488 request.search.enum_name = "os const test (waa)"; 489 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );489 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) ); 490 490 CHECK( 0, fd_dict_getval ( value_model, &request.search ) ); 491 491 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) ); … … 654 654 655 655 /* Now find the ACR dictionary object */ 656 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) );656 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) ); 657 657 658 658 CPYBUF(); … … 680 680 buf_cpy[5] = 0x11; 681 681 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) ); 682 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_config-> g_dict ) );682 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_config->cnf_dict ) ); 683 683 684 684 /* reset */ … … 695 695 /* Check that we cannot support this message now */ 696 696 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) ); 697 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_config-> g_dict ) );697 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_config->cnf_dict ) ); 698 698 699 699 /* reset */ … … 709 709 /* Check that we can support this message now */ 710 710 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) ); 711 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config-> g_dict ) );711 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict ) ); 712 712 713 713 #if 0 … … 720 720 721 721 CHECK( 0, fd_msg_parse_buffer( &buf, 344, &msg) ); 722 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config-> g_dict ) );722 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict ) ); 723 723 #if 0 724 724 fd_msg_dump_walk(0, msg); … … 730 730 struct dict_object * rule; 731 731 732 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config-> g_dict, &rule ) );732 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &rule ) ); 733 733 734 734 /* Use the "AVP Test - rules" AVP to test the rules */ … … 749 749 750 750 /* Check the message is still conform */ 751 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config-> g_dict, &rule ) );751 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &rule ) ); 752 752 753 753 /* The first avp is optional in fixed position, so remove it and check the message is still OK */ 754 754 CHECK( 0, fd_msg_browse ( tavp, MSG_BRW_FIRST_CHILD, &childavp, NULL) ); 755 755 CHECK( 0, fd_msg_free ( childavp ) ); 756 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config-> g_dict, &rule ) );756 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &rule ) ); 757 757 ADD_AVP( tavp, MSG_BRW_FIRST_CHILD, childavp, 0, "AVP Test - no vendor - f32" ); 758 758 … … 761 761 #define CHECK_CONFLICT( _msg, _ruleavp, _avpvendor ) { \ 762 762 struct dict_object * _rule; \ 763 CHECK( EBADMSG, fd_msg_parse_rules( _msg, fd_g_config-> g_dict, &_rule ) ); \763 CHECK( EBADMSG, fd_msg_parse_rules( _msg, fd_g_config->cnf_dict, &_rule ) ); \ 764 764 if ((_ruleavp) == NULL) { \ 765 765 CHECK( NULL, _rule); \ … … 768 768 struct dict_object * _avp; \ 769 769 struct dict_avp_request _req = { (_avpvendor), 0, (_ruleavp) }; \ 770 CHECK( 0, fd_dict_search( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT)); \770 CHECK( 0, fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT)); \ 771 771 CHECK( 0, fd_dict_getval( _rule, &_ruledata ) ); \ 772 772 CHECK( _avp, _ruledata.rule_avp ); \ … … 824 824 825 825 /* The message is still conform */ 826 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config-> g_dict, &rule ) );826 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &rule ) ); 827 827 828 828 /* Now break the rule */ … … 865 865 866 866 /* Find the CER dictionary object */ 867 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) );867 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) ); 868 868 869 869 /* Now find the Host-IP-Address dictionary object */ 870 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &hia_model, ENOENT ) );870 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &hia_model, ENOENT ) ); 871 871 872 872 /* Create the msg instance */ … … 945 945 /* Ok, now let's recreate the message */ 946 946 CHECK( 0, fd_msg_parse_buffer( &buf, 64, &cer) ); 947 CHECK( 0, fd_msg_parse_dict( cer, fd_g_config-> g_dict ) );947 CHECK( 0, fd_msg_parse_dict( cer, fd_g_config->cnf_dict ) ); 948 948 949 949 /* Get the pointers to the first and last AVP */ … … 972 972 { 973 973 struct dict_avp_data avp_data = { 91001, 0, "AVP Test 2 - os", 0, 0, AVP_TYPE_OCTETSTRING }; 974 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, NULL ) );974 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 975 975 } 976 976 { 977 977 struct dict_avp_data avp_data = { 91002, 0, "AVP Test 2 - i32", 0, 0, AVP_TYPE_INTEGER32 }; 978 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, NULL ) );978 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 979 979 } 980 980 { 981 981 struct dict_avp_data avp_data = { 91003, 0, "AVP Test 2 - i64", 0, 0, AVP_TYPE_INTEGER64 }; 982 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, NULL ) );982 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 983 983 } 984 984 { 985 985 struct dict_avp_data avp_data = { 91004, 0, "AVP Test 2 - u32", 0, 0, AVP_TYPE_UNSIGNED32 }; 986 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, NULL ) );986 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 987 987 } 988 988 { 989 989 struct dict_avp_data avp_data = { 91005, 0, "AVP Test 2 - u64", 0, 0, AVP_TYPE_UNSIGNED64 }; 990 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, NULL ) );990 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 991 991 } 992 992 { 993 993 struct dict_avp_data avp_data = { 91006, 0, "AVP Test 2 - f32", 0, 0, AVP_TYPE_FLOAT32 }; 994 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, NULL ) );994 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 995 995 } 996 996 { 997 997 struct dict_avp_data avp_data = { 91007, 0, "AVP Test 2 - f64", 0, 0, AVP_TYPE_FLOAT64 }; 998 CHECK( 0, fd_dict_new ( fd_g_config-> g_dict, DICT_AVP, &avp_data , NULL, NULL ) );998 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 999 999 } 1000 1000 … … 1010 1010 struct msg_hdr * msgdata = NULL; 1011 1011 1012 CHECK( 0, fd_dict_search ( fd_g_config-> g_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );1012 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) ); 1013 1013 1014 1014 /* Create a message */ … … 1175 1175 1176 1176 CHECK( 0, fd_msg_parse_buffer( &buf, 148, &msg) ); 1177 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config-> g_dict ) );1177 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict ) ); 1178 1178 #if 0 1179 1179 fd_msg_dump_walk(0, msg); -
freeDiameter/tests/tests.h
r8 r10 104 104 fd_log_threadname(basename(__FILE__)); \ 105 105 CHECK( 0, fd_conf_init() ); \ 106 CHECK( 0, fd_dict_base_protocol(fd_g_config-> g_dict) ); \106 CHECK( 0, fd_dict_base_protocol(fd_g_config->cnf_dict) ); \ 107 107 parse_cmdline(argc, argv); \ 108 108 } -
include/freeDiameter/freeDiameter.h
r8 r10 43 43 /* Structure to hold the configuration of the freeDiameter daemon */ 44 44 struct fd_config { 45 int eyec; /* Eye catcher: EYEC_CONFIG */ 46 char *conf_file; /* Configuration file to parse, default is DEFAULT_CONF_FILE */ 47 48 char *diam_id; /* Diameter Identity of the local peer (FQDN -- UTF-8) */ 49 size_t diam_id_len; /* length of the previous string */ 50 char *diam_realm; /* Diameter realm of the local peer, default to realm part of diam_id */ 51 size_t diam_realm_len;/* length of the previous string */ 52 53 uint16_t loc_port; /* the local port for legacy Diameter (default: 3868) in host byte order */ 54 uint16_t loc_port_tls; /* the local port for Diameter/TLS (default: 3869) in host byte order */ 55 uint16_t loc_sctp_str; /* default max number of streams for SCTP associations (def: 30) */ 56 struct fd_list loc_endpoints; /* the local endpoints to bind the server to. list of struct fd_endpoint. default is empty (bind all) */ 45 int cnf_eyec; /* Eye catcher: EYEC_CONFIG */ 46 #define EYEC_CONFIG 0xC011F16 47 48 char *cnf_file; /* Configuration file to parse, default is DEFAULT_CONF_FILE */ 49 50 char *cnf_diamid; /* Diameter Identity of the local peer (FQDN -- UTF-8) */ 51 size_t cnf_diamid_len; /* length of the previous string */ 52 char *cnf_diamrlm; /* Diameter realm of the local peer, default to realm part of diam_id */ 53 size_t cnf_diamrlm_len;/* length of the previous string */ 54 55 unsigned int cnf_timer_tc; /* The value in seconds of the default Tc timer */ 56 unsigned int cnf_timer_tw; /* The value in seconds of the default Tw timer */ 57 58 uint16_t cnf_port; /* the local port for legacy Diameter (default: 3868) in host byte order */ 59 uint16_t cnf_port_tls; /* the local port for Diameter/TLS (default: 3869) in host byte order */ 60 uint16_t cnf_sctp_str; /* default max number of streams for SCTP associations (def: 30) */ 61 struct fd_list cnf_endpoints; /* the local endpoints to bind the server to. list of struct fd_endpoint. default is empty (bind all) */ 62 struct fd_list cnf_apps; /* Applications locally supported (except relay, see flags). Use fd_disp_app_support to add one. list of struct fd_app. */ 57 63 struct { 64 unsigned no_fwd : 1; /* the peer does not relay messages (0xffffff app id) */ 58 65 unsigned no_ip4 : 1; /* disable IP */ 59 66 unsigned no_ip6 : 1; /* disable IPv6 */ … … 62 69 unsigned pr_tcp : 1; /* prefer TCP over SCTP */ 63 70 unsigned tls_alg: 1; /* TLS algorithm for initiated cnx. 0: separate port. 1: inband-security (old) */ 64 unsigned no_fwd : 1; /* the peer does not relay messages (0xffffff app id) */ 65 } flags; 66 67 unsigned int timer_tc; /* The value in seconds of the default Tc timer */ 68 unsigned int timer_tw; /* The value in seconds of the default Tw timer */ 69 70 uint32_t or_state_id; /* The value to use in Origin-State-Id, default to random value */ 71 struct dictionary *g_dict; /* pointer to the global dictionary */ 72 struct fifo *g_fifo_main; /* FIFO queue of events in the daemon main (struct fd_event items) */ 73 }; 74 75 #define EYEC_CONFIG 0xC011F16 76 77 /* The pointer to access the global configuration, initalized in main */ 78 extern struct fd_config *fd_g_config; 71 } cnf_flags; 72 73 uint32_t cnf_orstateid; /* The value to use in Origin-State-Id, default to random value */ 74 struct dictionary *cnf_dict; /* pointer to the global dictionary */ 75 struct fifo *cnf_main_ev; /* events for the daemon's main (struct fd_event items) */ 76 }; 77 extern struct fd_config *fd_g_config; /* The pointer to access the global configuration, initalized in main */ 79 78 80 79 /* Endpoints */ 81 80 struct fd_endpoint { 82 struct fd_list chain; /* link in loc_endpoints list */81 struct fd_list chain; /* link in cnf_endpoints list */ 83 82 sSS ss; /* the socket information. */ 84 83 }; 84 85 /* Applications */ 86 struct fd_app { 87 struct fd_list chain; /* link in cnf_apps list. List ordered by appid. */ 88 struct { 89 unsigned auth : 1; 90 unsigned acct : 1; 91 unsigned common : 1; 92 } flags; 93 vendor_id_t vndid; /* if not 0, Vendor-Specific-App-Id AVP will be used */ 94 application_id_t appid; /* The identifier of the application */ 95 }; 96 85 97 86 98 /* Events */ … … 90 102 }; 91 103 92 /* send an event */93 104 static __inline__ int fd_event_send(struct fifo *queue, int code, void * data) 94 105 { … … 100 111 return 0; 101 112 } 102 /* receive an event */103 113 static __inline__ int fd_event_get(struct fifo *queue, int *code, void ** data) 104 114 { … … 112 122 return 0; 113 123 } 124 125 /* Events codespace for fd_g_config->cnf_main_ev */ 126 enum { 127 FDEV_TERMINATE = 1000, /* request to terminate */ 128 FDEV_DUMP_DICT, /* Dump the content of the dictionary */ 129 FDEV_DUMP_EXT, /* Dump state of extensions */ 130 FDEV_DUMP_QUEUES, /* Dump the message queues */ 131 FDEV_DUMP_CONFIG, /* Dump the configuration */ 132 FDEV_DUMP_PEERS /* Dump the list of peers */ 133 }; 134 135 136 137 /***************************************/ 138 /* Peers information */ 139 /***************************************/ 140 141 /* States of a peer */ 142 enum peer_state { 143 /* Stable states */ 144 STATE_DISABLED = 1, /* No connexion must be attempted / only this state means that the peer PSM thread is not running */ 145 STATE_OPEN, /* Connexion established */ 146 147 /* Peer state machine */ 148 STATE_CLOSED, /* No connection established, will re-attempt after TcTimer. */ 149 STATE_CLOSING, /* the connection is being shutdown (DPR/DPA in progress) */ 150 STATE_WAITCNXACK, /* Attempting to establish transport-level connection */ 151 STATE_WAITCNXACK_ELEC, /* Received a CER from this same peer on an incoming connection (other peer object), while we were waiting for cnx ack */ 152 STATE_WAITCEA, /* Connection established, CER sent, waiting for CEA */ 153 /* STATE_WAITRETURNS_ELEC, */ /* This state is not stable and therefore deprecated: 154 We have sent a CER on our initiated connection, and received a CER from the remote peer on another connection. Election. 155 If we win the election, we must disconnect the initiated connection and send a CEA on the other => we go to OPEN state. 156 If we lose, we disconnect the other connection (receiver) and fallback to WAITCEA state. */ 157 158 /* Failover state machine */ 159 STATE_SUSPECT, /* A DWR was sent and not answered within TwTime. Failover in progress. */ 160 STATE_REOPEN /* Connection has been re-established, waiting for 3 DWR/DWA exchanges before putting back to service */ 161 }; 162 extern char *peer_state_str[]; 163 164 /* Information about a remote peer, used both for query and for creating a new entry */ 165 struct peer_info { 166 167 /* This information is always there */ 168 char * pi_diamid; /* UTF-8, \0 terminated. The Diameter Identity of the remote peer */ 169 char * pi_realm; /* idem, its realm. */ 170 171 /* Flags */ 172 struct { 173 #define PI_PROT_DEFAULT 0 /* Use the default algorithm configured for the host */ 174 #define PI_PROT_TCP 1 175 #define PI_PROT_SCTP 2 176 unsigned proto :2; 177 178 #define PI_SEC_DEFAULT 0 /* The default behavior configured for the host */ 179 #define PI_SEC_NONE 1 /* Transparent security with this peer (IPsec) */ 180 #define PI_SEC_TLS_NEW 2 /* New TLS security (dedicated port protecting also CER/CEA) */ 181 #define PI_SEC_TLS_OLD 3 /* Old TLS security (inband on default port) */ 182 unsigned sec :2; 183 184 #define PI_EXP_DEFAULT 0 185 #define PI_EXP_NONE 1 /* the peer entry does not expire */ 186 #define PI_EXP_INACTIVE 2 /* the peer entry expires after pi_lft seconds without activity */ 187 #define PI_EXP_LIFETIME 3 /* the peer SA information is destroyed after lft seconds (example: DNS timeout) */ 188 unsigned exp :2; 189 190 /* Following flags are read-only and received from remote peer */ 191 #define PI_INB_NONE 1 /* Remote peer advertised inband-sec-id 0 (None) */ 192 #define PI_INB_TLS 2 /* Remote peer advertised inband-sec-id 1 (TLS) */ 193 unsigned inband :2; /* This is only meaningful with pi_flags.sec == 3 */ 194 195 unsigned relay :1; /* The remote peer advertized the relay application */ 196 } pi_flags; 197 198 /* Additional parameters */ 199 uint32_t pi_lft; /* lifetime of entry without activity (except watchdogs) (see pi_flags.exp definition) */ 200 uint16_t pi_streams; /* number of streams for SCTP. 0 = default */ 201 uint16_t pi_port; /* port to connect to. 0: default. */ 202 int pi_tctimer; /* use this value for TcTimer instead of global, if != 0 */ 203 int pi_twtimer; /* use this value for TwTimer instead of global, if != 0 */ 204 205 struct fd_list pi_endpoints; /* Endpoint(s) of the remote peer (discovered or advertized). list of struct fd_endpoint. DNS resolved if empty. */ 206 207 /* The remaining information is read-only, not used for peer creation */ 208 enum peer_state pi_state; 209 uint32_t pi_vendorid; /* Content of the Vendor-Id AVP, or 0 by default */ 210 uint32_t pi_orstate; /* Origin-State-Id value */ 211 char * pi_prodname; /* copy of UTF-8 Product-Name AVP (\0 terminated) */ 212 uint32_t pi_firmrev; /* Content of the Firmware-Revision AVP */ 213 struct fd_list pi_apps; /* applications advertised by the remote peer, except relay (pi_flags.relay) */ 214 }; 215 114 216 115 217 /***************************************/ … … 158 260 * PARAMETERS: 159 261 * msg : A msg object -- it must be an answer. 160 * dict : dictionary to use for AVP definitions161 262 * rescode : The name of the returned error code (ex: "DIAMETER_INVALID_AVP") 162 263 * errormsg : (optional) human-readable error message to put in Error-Message AVP … … 173 274 * !0 : an error occurred. 174 275 */ 175 int fd_msg_rescode_set( struct msg * msg, struct dictionary * dict,char * rescode, char * errormsg, struct avp * optavp, int type_id );176 177 /* The following functions are used to achieve frequent operations on the messages*/178 int fd_msg_add_origin ( struct msg * msg, struct dictionary * dict, int osi ); /* Add Origin-Host, Origin-Realm, (if osi) Origin-State-Id AVPS at the end of the message */276 int fd_msg_rescode_set( struct msg * msg, char * rescode, char * errormsg, struct avp * optavp, int type_id ); 277 278 /* Add Origin-Host, Origin-Realm, (if osi) Origin-State-Id AVPS at the end of the message */ 279 int fd_msg_add_origin ( struct msg * msg, int osi ); 179 280 180 281 … … 184 285 /***************************************/ 185 286 186 enum {187 DISP_APP_AUTH = 1,188 DISP_APP_ACCT = 2189 };190 287 /* 191 288 * FUNCTION: fd_disp_app_support … … 194 291 * app : The dictionary object corresponding to the Application. 195 292 * vendor : (Optional) the dictionary object of a Vendor to claim support in Vendor-Specific-Application-Id 196 * flags : Combination of DISP_APP_* flags. 293 * auth : Support auth app part. 294 * acct : Support acct app part. 197 295 * 198 296 * DESCRIPTION: … … 205 303 * EINVAL : A parameter is invalid. 206 304 */ 207 int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int flags);305 int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int auth, int acct ); 208 306 209 307 /* Note: if we want to support capabilities updates, we'll have to add possibility to remove an app as well... */ -
include/freeDiameter/libfreeDiameter.h
r8 r10 171 171 char __buf[25]; \ 172 172 char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed"); \ 173 fd_log_debug("\t | t h:%-30s\t%s\tin %s@%s:%d\n"\173 fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n" \ 174 174 "\t%s|%*s" format "\n", \ 175 175 __thn, fd_log_time(__buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__, \ … … 2456 2456 fd_fifo_timedget_int((queue), (void *)(item), (abstime)) 2457 2457 2458 /* Dump a fifo list and optionally its inner elements -- beware of deadlocks! */ 2459 void fd_fifo_dump(int level, char * name, struct fifo * queue, void (*dump_item)(int level, void * item)); 2460 2458 2461 #endif /* _LIBFREEDIAMETER_H */ -
libfreeDiameter/CMakeLists.txt
r8 r10 7 7 dictionary.c 8 8 dispatch.c 9 fifo.c 9 10 init.c 10 11 lists.c 11 12 log.c 12 13 messages.c 13 queues.c14 14 sessions.c 15 15 ) -
libfreeDiameter/fifo.c
r8 r10 100 100 } 101 101 102 /* Dump the content of a queue */ 103 void fd_fifo_dump(int level, char * name, struct fifo * queue, void (*dump_item)(int level, void * item)) 104 { 105 TRACE_ENTRY("%i %p %p %p", level, name, queue, dump_item); 106 107 if (!TRACE_BOOL(level)) 108 return; 109 110 fd_log_debug("Dumping queue '%s' (%p):\n", name ?: "?", queue); 111 if (!CHECK_FIFO( queue )) { 112 fd_log_debug(" Queue invalid!\n"); 113 if (queue) 114 fd_log_debug(" (%x != %x)\n", queue->eyec, FIFO_EYEC); 115 return; 116 } 117 118 CHECK_POSIX_DO( pthread_mutex_lock( &queue->mtx ), /* continue */ ); 119 fd_log_debug(" %d elements in queue\n", queue->count); 120 fd_log_debug(" %d threads waiting\n", queue->thrs); 121 fd_log_debug(" thresholds: %d / %d, cb: %p / %p (%p), highest: %d\n", 122 queue->high, queue->low, 123 queue->h_cb, queue->l_cb, queue->data, 124 queue->highest); 125 126 if (dump_item) { 127 struct fd_list * li; 128 int i = 0; 129 for (li = queue->list.next; li != &queue->list; li = li->next) { 130 fd_log_debug(" [%i] item %p in fifo %p:\n", i++, li->o, queue); 131 (*dump_item)(level, li->o); 132 } 133 } 134 CHECK_POSIX_DO( pthread_mutex_unlock( &queue->mtx ), /* continue */ ); 135 136 } 137 102 138 /* Delete a queue. It must be unused. */ 103 139 int fd_fifo_del ( struct fifo ** queue )
Note: See TracChangeset
for help on using the changeset viewer.