Navigation


Changeset 10:c5c99c73c2bf in freeDiameter


Ignore:
Timestamp:
Sep 25, 2009, 4:12:08 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added some extensions and functions in the daemon

Files:
10 added
19 edited
2 moved

Legend:

Unmodified
Added
Removed
  • doc/freediameter.conf.sample

    r9 r10  
    129129TwTimer = 6;
    130130NoRelay;
    131 #LoadExtension = "extensions/sample.fdx";
    132 LoadExtension = "extensions/sample.fdx":"conf/sample.conf";
     131LoadExtension = "extensions/dbg_monitor.fdx";
     132LoadExtension = "extensions/dict_nasreq.fdx";
     133LoadExtension = "extensions/dict_eap.fdx";
  • extensions/CMakeLists.txt

    r9 r10  
    1818####
    1919# 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)
     20OPTION(BUILD_DICT_NASREQ "Build NASREQ (RFC4005) Dictionary definitions?" ON)
     21        IF (BUILD_DICT_NASREQ)
     22           SUBDIRS(dict_nasreq)
     23        ENDIF (BUILD_DICT_NASREQ)
    2424
    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)
     25OPTION(BUILD_DICT_EAP "Build Diameter EAP (RFC4072) Dictionary definitions?" ON)
     26        IF (BUILD_DICT_EAP)
     27           SUBDIRS(dict_eap)
     28        ENDIF (BUILD_DICT_EAP)
    2929
    3030
     
    5959# Debug / development extensions
    6060
    61 OPTION(BUILD_SAMPLE "Build sample? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF)
     61OPTION(BUILD_SAMPLE "Build sample.fdx? (Simple extension to demonstrate extension mechanism, for developpers only)" OFF)
    6262        IF (BUILD_SAMPLE)
    6363           SUBDIRS(_sample)
    6464        ENDIF (BUILD_SAMPLE)
     65
     66OPTION(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)
    6570
    6671# 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  
    33
    44# Compile as a module
    5 FD_ADD_EXTENSION(sample sample.c fini.c)
     5FD_ADD_EXTENSION(dbg_sample sample.c fini.c)
  • extensions/_sample/fini.c

    r9 r10  
    3434*********************************************************************************************************/
    3535
    36 /* Sample extension exit point */
    37 
    3836#include <freeDiameter/extension.h>
    3937
     38/* The function MUST be called this */
    4039void fd_ext_fini(void)
    4140{
    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!");
    4343        return ;
    4444}
  • extensions/_sample/sample.c

    r9 r10  
    4545static int sample_main(char * conffile)
    4646{
     47        /* The debug macro from main tree can be used the same way */
    4748        TRACE_ENTRY("%p", conffile);
    4849       
    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);
    5052       
     53        /* The configuration file name is received in the conffile var. It's up to extension to parse it */
    5154        if (conffile) {
    5255                fprintf(stdout, "I should parse my configuration file there: %s\n", conffile);
     
    5558        }
    5659       
    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'...");
    5962        {
    6063                struct dict_object * origin_host_avp = NULL;
     
    6467                struct dict_avp_data example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED };
    6568
    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));
    6871               
    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 ));
    7073               
    7174                rule_data.rule_avp = origin_host_avp;
    7275                rule_data.rule_min = 1;
    7376                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 ));
    7578               
    7679                rule_data.rule_avp = session_id_avp;
    7780                rule_data.rule_min = 1;
    7881                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);
    8085        }
    81         fd_log_debug("'Example-AVP' created without error\n");
     86        TRACE_DEBUG(INFO, "'Example-AVP' created without error\n");
    8287       
     88        /* The initialization function returns an error code with the standard POSIX meaning (ENOMEM, and so on) */
    8389        return 0;
    8490}
     91
     92/* See file fini.c for an example of destructor */
  • freeDiameter/CMakeLists.txt

    r8 r10  
    1111        fD.h
    1212        config.c
     13        dispatch.c
    1314        extensions.c
    1415        dict_base_proto.c
     16        messages.c
     17        queues.c
    1518        )
    1619
  • freeDiameter/config.c

    r8 r10  
    4343        TRACE_ENTRY();
    4444       
    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);
    5356        #ifdef DISABLE_SCTP
    54         fd_g_config->flags.no_sctp = 1;
     57        fd_g_config->cnf_flags.no_sctp = 1;
    5558        #endif /* DISABLE_SCTP */
    5659       
    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) );
    6464       
    6565        return 0;
     
    7373        fd_log_debug("-- Configuration :\n");
    7474        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)) {
    8284                fd_log_debug("  Local endpoints ........ : Default (use all available)\n");
    8385        } else {
    84                 struct fd_list * li = fd_g_config->loc_endpoints.next;
     86                struct fd_list * li = fd_g_config->cnf_endpoints.next;
    8587                fd_log_debug("  Local endpoints ........ : ");
    86                 while (li != &fd_g_config->loc_endpoints) {
     88                while (li != &fd_g_config->cnf_endpoints) {
    8789                        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("                             ");
    8991                        sSA_DUMP_NODE( &ep->ss, NI_NUMERICHOST );
    9092                        fd_log_debug("\n");
     
    9294                }
    9395        }
    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");
    98117        #ifdef DISABLE_SCTP
    99118        fd_log_debug("          - SCTP ......... : DISABLED (at compilation)\n");
    100119        #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");
    102121        #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);
    108125}
    109126
     
    113130        extern FILE * fddin;
    114131       
    115         TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->conf_file);
    116        
    117         fddin = fopen(fd_g_config->conf_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");
    118135        if (fddin == NULL) {
    119136                int ret = errno;
    120                 fprintf(stderr, "Unable to open configuration file %s for reading: %s\n", fd_g_config->conf_file, strerror(ret));
     137                fprintf(stderr, "Unable to open configuration file %s for reading: %s\n", fd_g_config->cnf_file, strerror(ret));
    121138                return ret;
    122139        }
     
    129146       
    130147        /* Resolve hostname if not provided */
    131         if (fd_g_config->diam_id == NULL) {
     148        if (fd_g_config->cnf_diamid == NULL) {
    132149#ifndef HOST_NAME_MAX
    133150#define HOST_NAME_MAX 1024
     
    152169                        return EINVAL;
    153170                }
    154                 CHECK_MALLOC( fd_g_config->diam_id = strdup(info->ai_canonname) );
     171                CHECK_MALLOC( fd_g_config->cnf_diamid = strdup(info->ai_canonname) );
    155172                freeaddrinfo(info);
    156173        }
    157174       
    158175        /* 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);
    160177       
    161178        /* Handle the realm part */
    162         if (fd_g_config->diam_realm == NULL) {
     179        if (fd_g_config->cnf_diamrlm == NULL) {
    163180                char * start = NULL;
    164181               
    165182                /* Check the diameter identity is a fqdn */
    166                 start = strchr(fd_g_config->diam_id, '.');
     183                start = strchr(fd_g_config->cnf_diamid, '.');
    167184                if ((start == NULL) || (start[1] == '\0')) {
    168185                        fprintf(stderr, "Unable to extract realm from the LocalIdentity '%s'.\n"
    169186                                        "Please fix your LocalIdentity setting or provide LocalRealm.\n",
    170                                         fd_g_config->diam_id);
     187                                        fd_g_config->cnf_diamid);
    171188                        return EINVAL;
    172189                }               
    173190               
    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);
    177194       
    178195        /* 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) {
    180197                fprintf(stderr, "IP and IPv6 cannot be disabled at the same time.\n");
    181198                return EINVAL;
    182199        }
    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) {
    184201                fprintf(stderr, "TCP and SCTP cannot be disabled at the same time.\n");
    185202                return EINVAL;
  • freeDiameter/extensions.c

    r9 r10  
    7979        TRACE_DEBUG (FULL, "Extension %s added to the list.", filename);
    8080        return 0;
     81}
     82
     83/* Dump the list */
     84void 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        }
    8195}
    8296
  • freeDiameter/fD.h

    r8 r10  
    4242#include <freeDiameter/freeDiameter.h>
    4343
    44 /* Events codespace for fd_g_config->g_fifo_main */
    45 enum {
    46         FM_TERMINATE = 1000     /* request to terminate */
    47 };
    48 
    4944/* Configuration */
    5045int fd_conf_init();
     
    5752int fd_ext_add( char * filename, char * conffile );
    5853int fd_ext_load();
     54void fd_ext_dump(void);
    5955int fd_ext_fini(void);
     56
     57/* Messages */
     58int fd_msg_init(void);
     59
     60/* Global message queues */
     61extern struct fifo * fd_g_incoming; /* all messages received from other peers, except local messages (CER, ...) */
     62extern struct fifo * fd_g_outgoing; /* messages to be sent to other peers on the network following routing procedure */
     63extern struct fifo * fd_g_local; /* messages to be handled to local extensions */
     64/* Message queues */
     65int fd_queues_init(void);
     66int fd_queues_fini(void);
    6067
    6168/* Create all the dictionary objects defined in the Diameter base RFC. */
  • freeDiameter/fdd.y

    r8 r10  
    6363{
    6464        if (ploc->first_line != ploc->last_line)
    65                 fprintf(stderr, "%s:%d.%d-%d.%d : %s\n", conf->conf_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);
    6666        else if (ploc->first_column != ploc->last_column)
    67                 fprintf(stderr, "%s:%d.%d-%d : %s\n", conf->conf_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);
    6868        else
    69                 fprintf(stderr, "%s:%d.%d : %s\n", conf->conf_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);
    7070}
    7171
     
    111111                        | conffile localidentity
    112112                        | conffile localrealm
     113                        | conffile tctimer
     114                        | conffile twtimer
    113115                        | conffile localport
    114116                        | conffile localsecport
     117                        | conffile sctpstreams
     118                        | conffile listenon
     119                        | conffile norelay
    115120                        | conffile noip
    116121                        | conffile noip6
     
    119124                        | conffile prefertcp
    120125                        | conffile oldtls
    121                         | conffile sctpstreams
    122                         | conffile listenon
    123                         | conffile tctimer
    124                         | conffile twtimer
    125                         | conffile norelay
    126126                        | conffile loadext
    127127                        ;
     
    129129localidentity:          LOCALIDENTITY '=' QSTRING ';'
    130130                        {
    131                                 conf->diam_id = $3;
     131                                conf->cnf_diamid = $3;
    132132                        }
    133133                        ;
     
    135135localrealm:             LOCALREALM '=' QSTRING ';'
    136136                        {
    137                                 conf->diam_realm = $3;
     137                                conf->cnf_diamrlm = $3;
     138                        }
     139                        ;
     140
     141tctimer:                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
     149twtimer:                TWTIMER '=' INTEGER ';'
     150                        {
     151                                CHECK_PARAMS_DO( ($3 > 5),
     152                                        { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } );
     153                                conf->cnf_timer_tw = (unsigned int)$3;
    138154                        }
    139155                        ;
     
    143159                                CHECK_PARAMS_DO( ($3 > 0) && ($3 < 1<<16),
    144160                                        { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } );
    145                                 conf->loc_port = (uint16_t)$3;
     161                                conf->cnf_port = (uint16_t)$3;
    146162                        }
    147163                        ;
     
    151167                                CHECK_PARAMS_DO( ($3 > 0) && ($3 < 1<<16),
    152168                                        { 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;
    190170                        }
    191171                        ;
     
    195175                                CHECK_PARAMS_DO( ($3 > 0) && ($3 < 1<<16),
    196176                                        { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } );
    197                                 conf->loc_sctp_str = (uint16_t)$3;
     177                                conf->cnf_sctp_str = (uint16_t)$3;
    198178                        }
    199179                        ;
     
    218198                                free($3);
    219199                                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);
    237201                        }
    238202                        ;
     
    240204norelay:                NORELAY ';'
    241205                        {
    242                                 conf->flags.no_fwd = 1;
     206                                conf->cnf_flags.no_fwd = 1;
     207                        }
     208                        ;
     209
     210noip:                   NOIP ';'
     211                        {
     212                                conf->cnf_flags.no_ip4 = 1;
     213                        }
     214                        ;
     215
     216noip6:                  NOIP6 ';'
     217                        {
     218                                conf->cnf_flags.no_ip6 = 1;
     219                        }
     220                        ;
     221
     222notcp:                  NOTCP ';'
     223                        {
     224                                conf->cnf_flags.no_tcp = 1;
     225                        }
     226                        ;
     227
     228nosctp:                 NOSCTP ';'
     229                        {
     230                                conf->cnf_flags.no_sctp = 1;
     231                        }
     232                        ;
     233
     234prefertcp:              PREFERTCP ';'
     235                        {
     236                                conf->cnf_flags.pr_tcp = 1;
     237                        }
     238                        ;
     239
     240oldtls:                 OLDTLS ';'
     241                        {
     242                                conf->cnf_flags.tls_alg = 1;
    243243                        }
    244244                        ;
  • freeDiameter/main.c

    r9 r10  
    3939#include <getopt.h>
    4040
     41/* forward declarations */
     42static void * sig_hdl(void * arg);
     43static int main_cmdline(int argc, char *argv[]);
     44
     45/* The static configuration structure */
     46static struct fd_config conf;
     47struct fd_config * fd_g_config = &conf;
     48
     49/* freeDiameter starting point */
     50int 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       
     127end:
     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}
    41136
    42137/* Display package version */
     
    122217                        case 'c':       /* Read configuration from this file instead of the default location..  */
    123218                                CHECK_PARAMS( optarg );
    124                                 fd_g_config->conf_file = optarg;
     219                                fd_g_config->cnf_file = optarg;
    125220                                break;
    126221
     
    159254#endif /* HAVE_SIGNALENT_H */
    160255
    161 
    162256/* signal handler */
    163257static void * sig_hdl(void * arg)
     
    176270       
    177271        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) );
    179273        return NULL;
    180274}
    181275       
    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  
    1515        testdict
    1616        testmesg
    17         testqueues
     17        testfifo
    1818        testsess
    1919        testdisp
  • freeDiameter/tests/testdict.c

    r8 r10  
    6767               
    6868                /* 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 ) );
    7171               
    7272                /* 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 ) );
    7474                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 ) );
    7676                CHECK( obj1, obj2);
    7777               
    7878                /* 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 ) );
    8080               
    8181                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 ) );
    8787               
    8888                /* Check the get_* functions */
     
    9494               
    9595                /* 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 ) );
    9898               
    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 ) );
    100100                CHECK( obj1, obj3);
    101101               
     
    112112                struct dict_avp_data example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED };
    113113
    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 ) );
    116116               
    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 ) );
    118118               
    119119                rule_data.rule_avp = origin_host_avp;
    120120                rule_data.rule_min = 1;
    121121                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 ) );
    123123               
    124124                rule_data.rule_avp = session_id_avp;
    125125                rule_data.rule_min = 1;
    126126                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 ) );
    128128               
    129129                CHECK( 0, fd_dict_iterate_rules ( example_avp_avp, &nbr, iter_test) );
  • freeDiameter/tests/testdisp.c

    r8 r10  
    128128                struct dict_enumval_data enu2_data = { "ENU test 2", { .u32 = 2 }};
    129129               
    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 ) );
    139139        }
    140140       
     
    669669        }                       
    670670       
     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       
    671699        /* That's all for the tests yet */
    672700        PASSTEST();
  • freeDiameter/tests/testfifo.c

    r8 r10  
    128128                struct dict_object * dwr_model = NULL;
    129129
    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 ) );
    133133                CHECK( 0, fd_msg_new ( acr_model, 0, &msg1 ) );
    134134                CHECK( 0, fd_msg_new ( cer_model, 0, &msg2 ) );
     
    215215               
    216216                /* 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 ) );
    218218                for (i = 0; i < NBR_MSG * NBR_THREADS * 2; i++) {
    219219                        CHECK( 0, fd_msg_new ( dwr_model, 0, &msgs[i] ) );
  • freeDiameter/tests/testmesg.c

    r8 r10  
    5151
    5252                /* 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 ) );
    5454
    5555                /* Create the instance, using the templates */
     
    7171
    7272                /* 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 ) );
    7474
    7575                /* Create the instance, using the templates */
     
    133133
    134134                /* 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 ) );
    136136
    137137                /* Create the instance, using the templates */
     
    161161
    162162                /* 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 ) );
    164164
    165165                /* Create the instance, using the templates */
     
    173173                {
    174174                        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 ) );
    176176                }
    177177               
    178178                {
    179179                        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 ) );
    181181                }
    182182               
    183183                {
    184184                        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 ) );
    186186                }
    187187               
     
    190190                        struct dict_type_data type_data = { AVP_TYPE_INTEGER64, "Int64 test" };
    191191                        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 ) );
    194194                }
    195195               
     
    202202                        struct dict_avp_data     avp_data = { 73569, 73565, "AVP Test - enumi32", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_INTEGER32 };
    203203                       
    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 ) );
    209209                }
    210210                       
     
    213213                        struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS test" };
    214214                        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 ) );
    217217                }
    218218               
     
    225225                        struct dict_avp_data     avp_data = { 73571, 73565, "AVP Test - enumos", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING };
    226226                       
    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 ) );
    232232                }
    233233               
     
    236236                        struct dict_avp_data avp_data = { 73572, 73565, "AVP Test - grouped", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED };
    237237                       
    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 ) );
    239239                       
    240240                        /* Macro to search AVP and create a rule */             
     
    243243                                struct dict_avp_request _req = { (_vendor), 0, (_avpname) };                    \
    244244                                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));\
    246246                                _data.rule_avp = _avp;                                                          \
    247247                                _data.rule_position = (_pos);                                                   \
     
    249249                                _data.rule_min = (_min);                                                        \
    250250                                _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 ) ); \
    252252                        }
    253253                       
     
    261261                        struct dict_cmd_data  cmd_data = { 73573, "Test-Command-Request", CMD_FLAG_REQUEST, CMD_FLAG_REQUEST };
    262262                       
    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 ) );
    265265                        ADD_RULE(command, 0,     "AVP Test - no vendor - f32",  RULE_FIXED_HEAD, -1,  1,  1);
    266266                        ADD_RULE(command, 73565, "AVP Test - i64",              RULE_REQUIRED,   -1, -1,  0);
     
    275275                        struct dict_avp_data  avp_data = { 73574, 73565, "AVP Test - rules", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED };
    276276                       
    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 ) );
    278278                       
    279279                        ADD_RULE(gavp,     0, "AVP Test - no vendor - f32", RULE_FIXED_HEAD,   0, 1, 1);
     
    303303                union avp_value      value;
    304304               
    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 ) );
    306306               
    307307                /* Check an error is trigged if the AVP has no value set */
    308308                {
    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 ) );
    310310                       
    311311                        CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) );
     
    329329                                struct dict_object * _avp = NULL;                                               \
    330330                                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));\
    332332                                CHECK( 0, fd_msg_avp_new ( _avp, 0, &_avpi ) );                                 \
    333333                                CHECK( 0, fd_msg_avp_add ( (_parent), (_position), _avpi ) );                   \
     
    378378                               
    379379                                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 ) );
    381381                                memset(&request, 0, sizeof(request));
    382382                                request.type_obj = type_model;
    383383                                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 ) );
    385385                                CHECK( 0, fd_dict_getval ( value_model, &request.search ) );
    386386                                CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) );
     
    399399                               
    400400                                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 ) );
    402402                                memset(&request, 0, sizeof(request));
    403403                                request.type_obj = type_model;
    404404                                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 ) );
    406406                                CHECK( 0, fd_dict_getval ( value_model, &request.search ) );
    407407                                CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) );
     
    458458                               
    459459                                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 ) );
    461461                                memset(&request, 0, sizeof(request));
    462462                                request.type_obj = type_model;
    463463                                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 ) );
    465465                                CHECK( 0, fd_dict_getval ( value_model, &request.search ) );
    466466                                CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) );
     
    483483                               
    484484                                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 ) );
    486486                                memset(&request, 0, sizeof(request));
    487487                                request.type_obj = type_model;
    488488                                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 ) );
    490490                                CHECK( 0, fd_dict_getval ( value_model, &request.search ) );
    491491                                CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) );
     
    654654                       
    655655                        /* 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 ) );
    657657                       
    658658                        CPYBUF();
     
    680680                                buf_cpy[5] = 0x11;
    681681                                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 ) );
    683683                               
    684684                                /* reset */
     
    695695                                /* Check that we cannot support this message now */
    696696                                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 ) );
    698698                               
    699699                                /* reset */
     
    709709                                /* Check that we can support this message now */
    710710                                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 ) );
    712712                               
    713713                                #if 0
     
    720720                       
    721721                        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 ) );
    723723                        #if 0
    724724                        fd_msg_dump_walk(0, msg);
     
    730730                        struct dict_object * rule;
    731731                       
    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 ) );
    733733                       
    734734                        /* Use the "AVP Test - rules" AVP to test the rules */
     
    749749                               
    750750                                /* 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 ) );
    752752                               
    753753                                /* The first avp is optional in fixed position, so remove it and check the message is still OK */
    754754                                CHECK( 0, fd_msg_browse ( tavp, MSG_BRW_FIRST_CHILD, &childavp, NULL) );
    755755                                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 ) );
    757757                                ADD_AVP( tavp, MSG_BRW_FIRST_CHILD, childavp,     0, "AVP Test - no vendor - f32" );
    758758                               
     
    761761                                #define CHECK_CONFLICT( _msg, _ruleavp, _avpvendor )            {                               \
    762762                                        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 ) );                   \
    764764                                        if ((_ruleavp) == NULL) {                                                               \
    765765                                                CHECK( NULL, _rule);                                                            \
     
    768768                                                struct dict_object *    _avp;                                                   \
    769769                                                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));      \
    771771                                                CHECK( 0, fd_dict_getval( _rule, &_ruledata ) );                                \
    772772                                                CHECK( _avp, _ruledata.rule_avp );                                              \
     
    824824                                       
    825825                                        /* 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 ) );
    827827                                       
    828828                                        /* Now break the rule */
     
    865865               
    866866                /* 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 ) );
    868868
    869869                /* 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 ) );
    871871
    872872                /* Create the msg instance */
     
    945945                /* Ok, now let's recreate the message */
    946946                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 ) );
    948948               
    949949                /* Get the pointers to the first and last AVP */
     
    972972                {
    973973                        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 ) );
    975975                }
    976976                {
    977977                        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 ) );
    979979                }
    980980                {
    981981                        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 ) );
    983983                }
    984984                {
    985985                        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 ) );
    987987                }
    988988                {
    989989                        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 ) );
    991991                }
    992992                {
    993993                        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 ) );
    995995                }
    996996                {
    997997                        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 ) );
    999999                }
    10001000               
     
    10101010                        struct msg_hdr     * msgdata = NULL;
    10111011
    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 ) );
    10131013
    10141014                        /* Create a message */
     
    11751175                       
    11761176                        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 ) );
    11781178                        #if 0
    11791179                        fd_msg_dump_walk(0, msg);
  • freeDiameter/tests/tests.h

    r8 r10  
    104104        fd_log_threadname(basename(__FILE__));                  \
    105105        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) );       \
    107107        parse_cmdline(argc, argv);                              \
    108108}
  • include/freeDiameter/freeDiameter.h

    r8 r10  
    4343/* Structure to hold the configuration of the freeDiameter daemon */
    4444struct 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. */
    5763        struct {
     64                unsigned no_fwd : 1;    /* the peer does not relay messages (0xffffff app id) */
    5865                unsigned no_ip4 : 1;    /* disable IP */
    5966                unsigned no_ip6 : 1;    /* disable IPv6 */
     
    6269                unsigned pr_tcp : 1;    /* prefer TCP over SCTP */
    6370                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};
     77extern struct fd_config *fd_g_config; /* The pointer to access the global configuration, initalized in main */
    7978
    8079/* Endpoints */
    8180struct fd_endpoint {
    82         struct fd_list  chain;  /* link in loc_endpoints list */
     81        struct fd_list  chain;  /* link in cnf_endpoints list */
    8382        sSS             ss;     /* the socket information. */
    8483};
     84
     85/* Applications */
     86struct 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       
    8597
    8698/* Events */
     
    90102};
    91103
    92 /* send an event */
    93104static __inline__ int fd_event_send(struct fifo *queue, int code, void * data)
    94105{
     
    100111        return 0;
    101112}
    102 /* receive an event */
    103113static __inline__ int fd_event_get(struct fifo *queue, int *code, void ** data)
    104114{
     
    112122        return 0;
    113123}
     124
     125/* Events codespace for fd_g_config->cnf_main_ev */
     126enum {
     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 */
     142enum 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};
     162extern char *peer_state_str[];
     163
     164/* Information about a remote peer, used both for query and for creating a new entry */
     165struct 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
    114216
    115217/***************************************/
     
    158260 * PARAMETERS:
    159261 *  msg         : A msg object -- it must be an answer.
    160  *  dict        : dictionary to use for AVP definitions
    161262 *  rescode     : The name of the returned error code (ex: "DIAMETER_INVALID_AVP")
    162263 *  errormsg    : (optional) human-readable error message to put in Error-Message AVP
     
    173274 *  !0          : an error occurred.
    174275 */
    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 */
     276int 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 */
     279int fd_msg_add_origin ( struct msg * msg, int osi );
    179280
    180281
     
    184285/***************************************/
    185286
    186 enum {
    187         DISP_APP_AUTH   = 1,
    188         DISP_APP_ACCT   = 2
    189 };
    190287/*
    191288 * FUNCTION:    fd_disp_app_support
     
    194291 *  app         : The dictionary object corresponding to the Application.
    195292 *  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.
    197295 *
    198296 * DESCRIPTION:
     
    205303 *  EINVAL      : A parameter is invalid.
    206304 */
    207 int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int flags );
     305int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int auth, int acct );
    208306
    209307/* 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  
    171171                char __buf[25];                                                                                                 \
    172172                char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    173                 fd_log_debug("\t | th:%-30s\t%s\tin %s@%s:%d\n"                                                                 \
     173                fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
    174174                          "\t%s|%*s" format "\n",                                                                               \
    175175                                        __thn, fd_log_time(__buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,      \
     
    24562456        fd_fifo_timedget_int((queue), (void *)(item), (abstime))
    24572457
     2458/* Dump a fifo list and optionally its inner elements -- beware of deadlocks! */
     2459void fd_fifo_dump(int level, char * name, struct fifo * queue, void (*dump_item)(int level, void * item));
     2460
    24582461#endif /* _LIBFREEDIAMETER_H */
  • libfreeDiameter/CMakeLists.txt

    r8 r10  
    77        dictionary.c
    88        dispatch.c
     9        fifo.c
    910        init.c
    1011        lists.c
    1112        log.c
    1213        messages.c
    13         queues.c
    1414        sessions.c
    1515        )
  • libfreeDiameter/fifo.c

    r8 r10  
    100100}
    101101
     102/* Dump the content of a queue */
     103void 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
    102138/* Delete a queue. It must be unused. */
    103139int fd_fifo_del ( struct fifo  ** queue )
Note: See TracChangeset for help on using the changeset viewer.