Navigation


Changeset 961:d95cd3ca9e8d in freeDiameter for libfdcore


Ignore:
Timestamp:
Mar 7, 2013, 4:09:54 AM (11 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Parents:
960:f39fa6cd86e0 (diff), 933:04f590da5821 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

merge latest 1.1 branch (one commit post 1.1.6)

Location:
libfdcore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/cnxctx.c

    r928 r961  
    229229       
    230230        if (TRACE_BOOL(INFO)) {
    231                 fd_log_debug("%s : accepted new client [", fd_cnx_getid(serv));
    232                 sSA_DUMP_NODE( &ss, NI_NUMERICHOST );
    233                 fd_log_debug("].\n");
     231                char buf[1024];
     232                sSA_DUMP_NODE( buf, sizeof(buf), &ss, NI_NUMERICHOST );
     233                fd_log_debug("%s : accepted new client [%s].\n", fd_cnx_getid(serv), buf);
    234234        }
    235235       
     
    312312       
    313313        if (TRACE_BOOL(INFO)) {
    314                 fd_log_debug("Connection established to server '");
    315                 sSA_DUMP_NODE_SERV( sa, NI_NUMERICSERV);
    316                 fd_log_debug("' (TCP:%d).\n", sock);
     314                char buf[1024];
     315                sSA_DUMP_NODE_SERV( buf, sizeof(buf), sa, NI_NUMERICSERV);
     316                fd_log_debug("Connection established to server '%s' (TCP:%d).\n", buf, sock);
    317317        }
    318318       
     
    404404       
    405405        if (TRACE_BOOL(INFO)) {
    406                 fd_log_debug("Connection established to server '");
    407                 sSA_DUMP_NODE_SERV( &primary, NI_NUMERICSERV);
    408                 fd_log_debug("' (SCTP:%d, %d/%d streams).\n", sock, cnx->cc_sctp_para.str_in, cnx->cc_sctp_para.str_out);
     406                char buf[1024];
     407                sSA_DUMP_NODE_SERV( buf, sizeof(buf), &primary, NI_NUMERICSERV);
     408                fd_log_debug("Connection established to server '%s' (SCTP:%d, %d/%d streams).\n", buf, sock, cnx->cc_sctp_para.str_in, cnx->cc_sctp_para.str_out);
    409409        }
    410410       
  • libfdcore/cnxctx.c

    r946 r961  
    33* Author: Sebastien Decugis <sdecugis@freediameter.net>                                                  *
    44*                                                                                                        *
    5 * Copyright (c) 2012, WIDE Project and NICT                                                              *
     5* Copyright (c) 2013, WIDE Project and NICT                                                              *
    66* All rights reserved.                                                                                   *
    77*                                                                                                        *
     
    561561                        continue;
    562562               
     563                if (cur->ifa_addr == NULL) /* may happen with ppp interfaces */
     564                        continue;
     565               
    563566                if (fd_g_config->cnf_flags.no_ip4 && (cur->ifa_addr->sa_family == AF_INET))
    564567                        continue;
  • libfdcore/core.c

    r928 r961  
    226226
    227227/* Parse the freeDiameter.conf configuration file, load the extensions */
    228 int fd_core_parseconf(char * conffile)
     228int fd_core_parseconf(const char * conffile)
    229229{
    230230        TRACE_ENTRY("%p", conffile);
  • libfdcore/core.c

    r947 r961  
    33* Author: Sebastien Decugis <sdecugis@freediameter.net>                                                  *
    44*                                                                                                        *
    5 * Copyright (c) 2012, WIDE Project and NICT                                                              *
     5* Copyright (c) 2013, WIDE Project and NICT                                                              *
    66* All rights reserved.                                                                                   *
    77*                                                                                                        *
  • libfdcore/fdd.l

    r950 r961  
    33* Author: Sebastien Decugis <sdecugis@freediameter.net>                                                  *
    44*                                                                                                        *
    5 * Copyright (c) 2011, WIDE Project and NICT                                                              *
     5* Copyright (c) 2013, WIDE Project and NICT                                                              *
    66* All rights reserved.                                                                                   *
    77*                                                                                                        *
     
    6767/* %option noinput ? */
    6868#define YY_NO_INPUT
     69
     70/* Additional for files inclusion */
     71#include <glob.h>
     72#include <string.h>
     73
     74#define MAX_NESTED_CONF_FILES   5
     75
     76struct nested_conffiles_t {
     77        YY_BUFFER_STATE parent_level_state;
     78        glob_t filelist;
     79        int current_file;
     80} nested_conffiles[MAX_NESTED_CONF_FILES];
     81
     82int current_nested_level = 0;
     83
     84int globerrfct(const char *epath, int eerrno)
     85{
     86        TRACE_DEBUG_ERROR("Failed to scan %s: %s\n", epath, strerror(eerrno));
     87        return 1;
     88}
     89
    6990%}
    7091
     
    7394%option nounput
    7495
     96%x in_include
     97
    7598/* Quoted string. Multilines do not match. */
    7699qstring         \"[^\"\n]*\"
    77100
    78101%%
    79 
    80102<*>\n                   {
    81103                                /* Update the line count */
     
    87109<*>([[:space:]]{-}[\n])+        ; /* Eat all spaces, not new lines */
    88110<*>#.*$                 ; /* Eat all comments */
     111
     112
     113include         BEGIN(in_include);
     114        /* Following an "include" keyword */
     115<in_include>{
     116{qstring}       { /* Name of the file to include. This is directly sent to glob. */
     117                        int globerror=0;
     118                        char * buf = strdup(yytext+1);
     119                        if (buf[yyleng-2] != '"')
     120                        {
     121                                TRACE_DEBUG_ERROR("Unterminated string: %s\n", yytext);
     122                                return LEX_ERROR;
     123                        }
     124                        buf[yyleng-2] = '\0';
     125
     126                        if (current_nested_level >= MAX_NESTED_CONF_FILES)
     127                        {
     128                                TRACE_DEBUG_ERROR("Too many recursion levels in configuration files includes\n");
     129                                return LEX_ERROR;
     130                        }
     131
     132                        /* glob the include */
     133                        globerror = glob(buf, GLOB_ERR, globerrfct, &nested_conffiles[current_nested_level].filelist);
     134
     135                        if (globerror == GLOB_NOSPACE)
     136                        {
     137                                TRACE_DEBUG_ERROR("Not enough memory to parse include directive.\n");
     138                                return LEX_ERROR;
     139                        }
     140                        if (globerror == GLOB_ABORTED)
     141                        {
     142                                TRACE_DEBUG_ERROR("An error was encountered in include directive.\n");
     143                                return LEX_ERROR;
     144                        }
     145                        if (globerror == GLOB_NOMATCH)
     146                        {
     147                                globfree(&nested_conffiles[current_nested_level].filelist);
     148                                goto nomatch;
     149                        }
     150                        if (globerror)
     151                        {
     152                                TRACE_DEBUG_ERROR("Unexpected error in glob (%d).\n", globerror);
     153                                return LEX_ERROR;
     154                        }
     155
     156                        /* We have a list of files to include. */
     157
     158                        /* save the current buffer for returning when this include has been parsed */
     159                        nested_conffiles[current_nested_level].parent_level_state = YY_CURRENT_BUFFER;
     160
     161                        /* Start with the first match */
     162                        nested_conffiles[current_nested_level].current_file = 0;
     163
     164                        yyin = fopen( nested_conffiles[current_nested_level].filelist.gl_pathv[0], "r" );
     165
     166                        if ( ! yyin )
     167                        {
     168                                TRACE_DEBUG_ERROR("Error in %s: %s", nested_conffiles[current_nested_level].filelist.gl_pathv[0], strerror(errno));
     169                                return LEX_ERROR;
     170                        }
     171
     172                        yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ));
     173
     174                        /* In case of recursive includes */
     175                        current_nested_level++;
     176
     177nomatch:
     178                        BEGIN(INITIAL);
     179                }
     180}
     181
     182<<EOF>> {
     183                        if (current_nested_level == 0)
     184                        {
     185                              /* We are at the end of parsing */
     186                              yyterminate();
     187                        }
     188
     189                        /* Otherwise we are doing an include statement */
     190                        --current_nested_level;
     191                        yy_delete_buffer(YY_CURRENT_BUFFER);
     192
     193                        /* Go to next file, if any */
     194                        nested_conffiles[current_nested_level].current_file++;
     195                        if ( nested_conffiles[current_nested_level].filelist.gl_pathv[nested_conffiles[current_nested_level].current_file] == NULL )
     196                        {
     197                                /* We have finished with this list of includes */
     198                                globfree(&nested_conffiles[current_nested_level].filelist);
     199                                yy_switch_to_buffer(nested_conffiles[current_nested_level].parent_level_state);
     200                        }
     201                        else
     202                        {
     203                                /* Proceed to next included file */
     204                                yyin = fopen( nested_conffiles[current_nested_level].filelist.gl_pathv[nested_conffiles[current_nested_level].current_file], "r" );
     205
     206                                if ( ! yyin )
     207                                {
     208                                        TRACE_DEBUG_ERROR("Error in %s: %s", nested_conffiles[current_nested_level].filelist.gl_pathv[nested_conffiles[current_nested_level].current_file], strerror(errno));
     209                                        return LEX_ERROR;
     210                                }
     211
     212                                yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ));
     213
     214                                /* In case of recursive includes */
     215                                current_nested_level++;
     216                        }
     217
     218}
    89219
    90220{qstring}               {
  • libfdcore/fdd.y

    r950 r961  
    33* Author: Sebastien Decugis <sdecugis@freediameter.net>                                                  *
    44*                                                                                                        *
    5 * Copyright (c) 2012, WIDE Project and NICT                                                              *
     5* Copyright (c) 2013, WIDE Project and NICT                                                              *
    66* All rights reserved.                                                                                   *
    77*                                                                                                        *
  • libfdcore/peers.c

    r933 r961  
    9191
    9292/* Add a new peer entry */
    93 int fd_peer_add ( struct peer_info * info, char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data )
     93int fd_peer_add ( struct peer_info * info, const char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data )
    9494{
    9595        struct fd_peer *p = NULL;
  • libfdcore/peers.c

    r950 r961  
    33* Author: Sebastien Decugis <sdecugis@freediameter.net>                                                  *
    44*                                                                                                        *
    5 * Copyright (c) 2012, WIDE Project and NICT                                                              *
     5* Copyright (c) 2013, WIDE Project and NICT                                                              *
    66* All rights reserved.                                                                                   *
    77*                                                                                                        *
     
    515515                peer->p_flags.pf_delete = 1;
    516516               
     517#ifndef DISABLE_PEER_EXPIRY
    517518                /* Set this peer to expire on inactivity */
    518519                peer->p_hdr.info.config.pic_flags.exp   = PI_EXP_INACTIVE;
    519520                peer->p_hdr.info.config.pic_lft         = 3600; /* 1 hour without any message
    520521                -- RFC3539 states that this must not be inferior to BRINGDOWN_INTERVAL = 5 minutes */
     522               
    521523                CHECK_FCT_DO( ret = fd_p_expi_update( peer ), goto out );
    522 
     524#endif /* DISABLE_PEER_EXPIRY */
    523525               
    524526                /* Insert the new peer in the list (the PSM will take care of setting the expiry after validation) */
  • libfdcore/sctp.c

    r928 r961  
    909909        }
    910910        if (TRACE_BOOL(SCTP_LEVEL)) {
     911                char buf[1024];
     912                sSA_DUMP_NODE_SERV(buf, sizeof(buf), &status.sstat_primary.spinfo_address, NI_NUMERICHOST | NI_NUMERICSERV );
    911913                fd_log_debug( "SCTP_STATUS : sstat_state                  : %i\n" , status.sstat_state);
    912914                fd_log_debug( "              sstat_rwnd                   : %u\n" , status.sstat_rwnd);
     
    916918                fd_log_debug( "              sstat_outstrms               : %hu\n", status.sstat_outstrms);
    917919                fd_log_debug( "              sstat_fragmentation_point    : %u\n" , status.sstat_fragmentation_point);
    918                 fd_log_debug( "              sstat_primary.spinfo_address : ");
    919                 sSA_DUMP_NODE_SERV(&status.sstat_primary.spinfo_address, NI_NUMERICHOST | NI_NUMERICSERV );
    920                 fd_log_debug( "\n" );
     920                fd_log_debug( "              sstat_primary.spinfo_address : %s\n" , buf);
    921921                fd_log_debug( "              sstat_primary.spinfo_state   : %d\n" , status.sstat_primary.spinfo_state);
    922922                fd_log_debug( "              sstat_primary.spinfo_cwnd    : %u\n" , status.sstat_primary.spinfo_cwnd);
  • libfdcore/sctp.c

    r950 r961  
    33* Author: Sebastien Decugis <sdecugis@freediameter.net>                                                  *
    44*                                                                                                        *
    5 * Copyright (c) 2012, WIDE Project and NICT                                                              *
     5* Copyright (c) 2013, WIDE Project and NICT                                                              *
    66* All rights reserved.                                                                                   *
    77*                                                                                                        *
Note: See TracChangeset for help on using the changeset viewer.