Navigation


Changes in / [950:51c15f98a965:949:ad5c976e0dc7] in freeDiameter


Ignore:
Files:
1 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • INSTALL.FreeBSD

    r921 r707  
    99
    1010Then the cmake command had to look like:
    11  cmake -DFLEX_EXECUTABLE:FILEPATH=/usr/local/bin/flex -DSCTP_USE_MAPPED_ADDRESSES:BOOL=ON ...
     11 cmake -DFLEX_EXECUTABLE:FILEPATH=/usr/local/bin/flex ...
    1212
    1313
     
    4646   
    47477) Run cmake for freeDiameter (add other flags as you see fit, see INSTALL for more details)
    48    # /usr/local/bin/cmake -DFLEX_EXECUTABLE:FILEPATH=/usr/local/bin/flex -DSCTP_USE_MAPPED_ADDRESSES:BOOL=ON ../freeDiameter
     48   # /usr/local/bin/cmake -DFLEX_EXECUTABLE:FILEPATH=/usr/local/bin/flex ../freeDiameter
    4949
    50508) Compile, optionnaly test
  • extensions/app_radgw/rgwx_auth.c

    r924 r740  
    458458                if (si_len) {
    459459                        /* We already have the Session-Id, just use it */
    460                         CHECK_FCT( fd_sess_fromsid_msg ( si, si_len, session, NULL) );
     460                        CHECK_FCT( fd_sess_fromsid ( si, si_len, session, NULL) );
    461461                } else {
    462462                        /* Create a new Session-Id string */
     
    496496                CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
    497497                CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) );
    498                 CHECK_FCT( fd_msg_sess_set( *diam_fw, *session) );
    499498        }
    500499       
  • extensions/app_radgw/rgwx_sip.c

    r924 r816  
    480480        CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
    481481        CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) );
    482         CHECK_FCT( fd_msg_sess_set( *diam_fw, *session) );
    483482       
    484483        /*
  • extensions/app_sip/registrationtermination.c

    r924 r706  
    148148        {
    149149                #define APP_SIP_SID_OPT  "app_sip"
    150                 CHECK_FCT( fd_msg_new_session( message, (os0_t)APP_SIP_SID_OPT, CONSTSTRLEN(APP_SIP_SID_OPT) ) );
     150                CHECK_FCT( fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, (os0_t)APP_SIP_SID_OPT, CONSTSTRLEN(APP_SIP_SID_OPT) ));
     151                os0_t sid;
     152                size_t sidlen;
     153                CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ));
     154                CHECK_FCT( fd_msg_avp_new ( sip_dict.Session_Id, 0, &avp ));
     155                value.os.data = sid;
     156                value.os.len  = sidlen;
     157                CHECK_FCT( fd_msg_avp_setvalue( avp, &value ));
     158                CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_FIRST_CHILD, avp ));
    151159        }
    152160       
  • extensions/test_app/ta_bench.c

    r924 r879  
    122122        union avp_value val;
    123123        struct ta_mess_info * mi = NULL;
     124        struct session *sess = NULL;
    124125       
    125126        TRACE_DEBUG(FULL, "Creating a new message for sending.");
     
    130131        /* Create a new session */
    131132        #define TEST_APP_SID_OPT  "app_testb"
    132         CHECK_FCT_DO( fd_msg_new_session( req, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
     133        CHECK_FCT_DO( fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
    133134       
    134135        /* Create the random value to store with the session */
     
    142143       
    143144        /* Now set all AVPs values */
     145       
     146        /* Session-Id */
     147        {
     148                os0_t sid;
     149                size_t sidlen;
     150                CHECK_FCT_DO( fd_sess_getsid ( sess, &sid, &sidlen ), goto out );
     151                CHECK_FCT_DO( fd_msg_avp_new ( ta_sess_id, 0, &avp ), goto out );
     152                val.os.data = sid;
     153                val.os.len  = sidlen;
     154                CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
     155                CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_FIRST_CHILD, avp ), goto out );
     156               
     157        }
    144158       
    145159        /* Set the Destination-Realm AVP */
  • extensions/test_app/ta_cli.c

    r924 r740  
    151151        /* Create a new session */
    152152        #define TEST_APP_SID_OPT  "app_test"
    153         CHECK_FCT_DO( fd_msg_new_session( req, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
    154         CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, req, &sess, NULL), goto out );
     153        CHECK_FCT_DO( fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
    155154       
    156155        /* Create the random value to store with the session */
     
    165164        /* Now set all AVPs values */
    166165       
     166        /* Session-Id */
     167        {
     168                os0_t sid;
     169                size_t sidlen;
     170                CHECK_FCT_DO( fd_sess_getsid ( sess, &sid, &sidlen ), goto out );
     171                CHECK_FCT_DO( fd_msg_avp_new ( ta_sess_id, 0, &avp ), goto out );
     172                val.os.data = sid;
     173                val.os.len  = sidlen;
     174                CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
     175                CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_FIRST_CHILD, avp ), goto out );
     176               
     177        }
     178       
    167179        /* Set the Destination-Realm AVP */
    168180        {
  • extensions/test_sip/locationinfo.c

    r924 r706  
    4242        struct msg * message=NULL;
    4343        struct avp *avp=NULL;
     44        struct session *sess=NULL;
    4445        union avp_value value;
    4546       
     
    6162        // Create a new session
    6263        {
    63                 CHECK_FCT( fd_msg_new_session( message, (os0_t)"appsip", CONSTSTRLEN("appsip") ) );
     64                CHECK_FCT( fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, (os0_t)"appsip", 6 ));
     65                os0_t sid;
     66                size_t sidlen;
     67                CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ));
     68                CHECK_FCT( fd_msg_avp_new ( sip_dict.Session_Id, 0, &avp ));
     69                value.os.data = sid;
     70                value.os.len  = sidlen;
     71                CHECK_FCT( fd_msg_avp_setvalue( avp, &value ));
     72                CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_FIRST_CHILD, avp ));
    6473        }
    6574       
  • extensions/test_sip/locationinfosl.c

    r924 r706  
    4242        struct msg * message=NULL;
    4343        struct avp *avp=NULL;
     44        struct session *sess=NULL;
    4445        union avp_value value;
    4546       
     
    6162        // Create a new session
    6263        {
    63                 CHECK_FCT( fd_msg_new_session( message, (os0_t)"appsip", CONSTSTRLEN("appsip") ) );
     64                CHECK_FCT( fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, (os0_t)"appsip", 6 ));
     65                os0_t sid;
     66                size_t sidlen;
     67                CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ));
     68                CHECK_FCT( fd_msg_avp_new ( sip_dict.Session_Id, 0, &avp ));
     69                value.os.data = sid;
     70                value.os.len  = sidlen;
     71                CHECK_FCT( fd_msg_avp_setvalue( avp, &value ));
     72                CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_FIRST_CHILD, avp ));
    6473        }
    6574       
  • extensions/test_sip/serverassignment.c

    r924 r706  
    4242        struct msg * message=NULL;
    4343        struct avp *avp=NULL;
     44        struct session *sess=NULL;
    4445        union avp_value value;
    4546       
     
    7071        // Create a new session
    7172        {
    72                 CHECK_FCT( fd_msg_new_session( message, (os0_t)"appsip", CONSTSTRLEN("appsip") ) );
     73                CHECK_FCT( fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, (os0_t)"appsip", 6 ));
     74                os0_t sid;
     75                size_t sidlen;
     76                CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ));
     77                CHECK_FCT( fd_msg_avp_new ( sip_dict.Session_Id, 0, &avp ));
     78                value.os.data = sid;
     79                value.os.len  = sidlen;
     80                CHECK_FCT( fd_msg_avp_setvalue( avp, &value ));
     81                CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_FIRST_CHILD, avp ));
    7382        }
    7483       
  • extensions/test_sip/userauthorization.c

    r924 r706  
    4242        struct msg * message=NULL;
    4343        struct avp *avp=NULL;
     44        struct session *sess=NULL;
    4445        union avp_value value;
    4546       
     
    6667        // Create a new session
    6768        {
    68                 CHECK_FCT( fd_msg_new_session( message, (os0_t)"appsip", CONSTSTRLEN("appsip") ) );
     69                CHECK_FCT( fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, (os0_t)"appsip", 6 ));
     70                os0_t sid;
     71                size_t sidlen;
     72                CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ));
     73                CHECK_FCT( fd_msg_avp_new ( sip_dict.Session_Id, 0, &avp ));
     74                value.os.data = sid;
     75                value.os.len  = sidlen;
     76                CHECK_FCT( fd_msg_avp_setvalue( avp, &value ));
     77                CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_FIRST_CHILD, avp ));
    6978        }
    7079       
  • include/freeDiameter/libfdproto.h

    r950 r946  
    11581158};
    11591159
    1160 /****
    1161  Callbacks defined in libfdproto/dictionary_functions.c file -- see that file for usage.
    1162  */
    1163 
    1164 /* Convert an Address type AVP into a struct sockaddr_storage */
    1165 int fd_dictfct_Address_encode(void * data, union avp_value * avp_value);
    1166 int fd_dictfct_Address_interpret(union avp_value * avp_value, void * interpreted);
    1167 char * fd_dictfct_Address_dump(union avp_value * avp_value);
    1168 
    1169 /* Display the content of an AVP of type UTF8String in the log file */
    1170 char * fd_dictfct_UTF8String_dump(union avp_value * avp_value);
    1171 
    1172 /* For Time AVPs, map with time_t value directly */
    1173 int fd_dictfct_Time_encode(void * data, union avp_value * avp_value);
    1174 int fd_dictfct_Time_interpret(union avp_value * avp_value, void * interpreted);
    1175 char * fd_dictfct_Time_dump(union avp_value * avp_value);
    1176 
    1177 
    1178 
    1179 /****/
    11801160
    11811161/***
     
    12081188 
    12091189*/
    1210 
     1190         
    12111191/*
    12121192 ***************************************************************************
     
    18101790 *
    18111791 * RETURN VALUE:
    1812  *  0           : The session is created, the initial msg refcount is 1.
    1813  *  EINVAL      : A parameter is invalid.
    1814  *  EALREADY    : A session with the same name already exists (returned in *session), the msg refcount is increased.
     1792 *  0           : The session is created.
     1793 *  EINVAL      : A parameter is invalid.
     1794 *  EALREADY    : A session with the same name already exists (returned in *session)
    18151795 *  ENOMEM      : Not enough memory to complete the operation
    18161796 */
     
    24992479int fd_msg_sess_get(struct dictionary * dict, struct msg * msg, struct session ** session, int * isnew);
    25002480
    2501 /* This one is used by the libfdcore, you should use fd_msg_new_session rather than fd_sess_new, when possible */
    2502 int fd_msg_sess_set(struct msg * msg, struct session * session);
    2503 
    2504 
    25052481/***************************************/
    25062482/*   Manage AVP values                 */
  • libfdcore/dict_base_proto.c

    r922 r838  
    4545struct dictionary * fd_g_dict = NULL;
    4646
     47/* The functions to encode and interpret the derived types defined in the base protocol */
     48
     49/* Address AVP <-> struct sockaddr_storage */
     50static int Address_encode(void * data, union avp_value * avp_value)
     51{
     52        sSS * ss = (sSS *) data;
     53        uint16_t AddressType = 0;
     54        size_t  size = 0;
     55        unsigned char * buf = NULL;
     56       
     57        TRACE_ENTRY("%p %p", data, avp_value);
     58        CHECK_PARAMS( data && avp_value  );
     59       
     60        switch (ss->ss_family) {
     61                case AF_INET:
     62                        {
     63                                /* We are encoding an IP address */
     64                                sSA4 * sin = (sSA4 *)ss;
     65                               
     66                                AddressType = 1;/* see http://www.iana.org/assignments/address-family-numbers/ */
     67                                size = 6;       /* 2 for AddressType + 4 for data */
     68                               
     69                                CHECK_MALLOC(  buf = malloc(size)  );
     70                               
     71                                /* may not work because of alignment: *(uint32_t *)(buf+2) = htonl(sin->sin_addr.s_addr); */
     72                                memcpy(buf + 2, &sin->sin_addr.s_addr, 4);
     73                        }
     74                        break;
     75                               
     76                case AF_INET6:
     77                        {
     78                                /* We are encoding an IPv6 address */
     79                                sSA6 * sin6 = (sSA6 *)ss;
     80                               
     81                                AddressType = 2;/* see http://www.iana.org/assignments/address-family-numbers/ */
     82                                size = 18;      /* 2 for AddressType + 16 for data */
     83                               
     84                                CHECK_MALLOC(  buf = malloc(size)  );
     85                               
     86                                /* The order is already good here */
     87                                memcpy(buf + 2, &sin6->sin6_addr.s6_addr, 16);
     88                        }
     89                        break;
     90                               
     91                default:
     92                        CHECK_PARAMS( AddressType = 0 );
     93        }
     94       
     95        *(uint16_t *)buf = htons(AddressType);
     96
     97        avp_value->os.len = size;
     98        avp_value->os.data = buf;
     99       
     100        return 0;
     101}
     102
     103static int Address_interpret(union avp_value * avp_value, void * interpreted)
     104{
     105        uint16_t AddressType = 0;
     106        unsigned char * buf;
     107       
     108        TRACE_ENTRY("%p %p", avp_value, interpreted);
     109       
     110        CHECK_PARAMS( avp_value && interpreted && (avp_value->os.len >= 2)  );
     111       
     112        AddressType = ntohs(*(uint16_t *)avp_value->os.data);
     113        buf = &avp_value->os.data[2];
     114       
     115        switch (AddressType) {
     116                case 1 /* IP */:
     117                        {
     118                                sSA4 * sin = (sSA4 *)interpreted;
     119                               
     120                                CHECK_PARAMS(  avp_value->os.len == 6  );
     121                               
     122                                sin->sin_family = AF_INET;
     123                                /* sin->sin_addr.s_addr = ntohl( * (uint32_t *) buf); -- may not work because of bad alignment */
     124                                memcpy(&sin->sin_addr.s_addr, buf, 4);
     125                        }
     126                        break;
     127                               
     128                case 2 /* IP6 */:
     129                        {
     130                                sSA6 * sin6 = (sSA6 *)interpreted;
     131                               
     132                                CHECK_PARAMS(  avp_value->os.len == 18  );
     133                               
     134                                sin6->sin6_family = AF_INET6;
     135                                memcpy(&sin6->sin6_addr.s6_addr, buf, 16);
     136                        }
     137                        break;
     138                               
     139                default:
     140                        CHECK_PARAMS( AddressType = 0 );
     141        }
     142       
     143        return 0;
     144}
     145
     146/* Dump the content of an Address AVP */
     147static char * Address_dump(union avp_value * avp_value)
     148{
     149        char * ret;
     150        #define STR_LEN 1024
     151        union {
     152                sSA     sa;
     153                sSS     ss;
     154                sSA4    sin;
     155                sSA6    sin6;
     156        } s;
     157        uint16_t fam;
     158       
     159        memset(&s, 0, sizeof(s));
     160       
     161        CHECK_MALLOC_DO( ret = malloc(STR_LEN), return NULL );
     162       
     163        /* The first two octets represent the address family, http://www.iana.org/assignments/address-family-numbers/ */
     164        if (avp_value->os.len < 2) {
     165                snprintf(ret, STR_LEN, "[invalid length: %zd]", avp_value->os.len);
     166                return ret;
     167        }
     168       
     169        /* Following octets are the address in network byte order already */
     170        fam = avp_value->os.data[0] << 8 | avp_value->os.data[1];
     171        switch (fam) {
     172                case 1:
     173                        /* IP */
     174                        s.sa.sa_family = AF_INET;
     175                        if (avp_value->os.len != 6) {
     176                                snprintf(ret, STR_LEN, "[invalid IP length: %zd]", avp_value->os.len);
     177                                return ret;
     178                        }
     179                        memcpy(&s.sin.sin_addr.s_addr, avp_value->os.data + 2, 4);
     180                        break;
     181                case 2:
     182                        /* IP6 */
     183                        s.sa.sa_family = AF_INET6;
     184                        if (avp_value->os.len != 18) {
     185                                snprintf(ret, STR_LEN, "[invalid IP6 length: %zd]", avp_value->os.len);
     186                                return ret;
     187                        }
     188                        memcpy(&s.sin6.sin6_addr.s6_addr, avp_value->os.data + 2, 16);
     189                        break;
     190                default:
     191                        snprintf(ret, STR_LEN, "[unsupported family: 0x%hx]", fam);
     192                        return ret;
     193        }
     194       
     195        {
     196                int rc = getnameinfo(&s.sa, sSAlen(&s.sa), ret, STR_LEN, NULL, 0, NI_NUMERICHOST);
     197                if (rc)
     198                        snprintf(ret, STR_LEN, "%s", (char *)gai_strerror(rc));
     199        }
     200       
     201        return ret;
     202}
     203
     204static char * UTF8String_dump(union avp_value * avp_value)
     205{
     206        return strndup((char *)avp_value->os.data, 42); /* avoid very long strings */
     207}
     208
     209
    47210
    48211
     
    132295                                the content and format of the remaining octets.
    133296                        */
    134                         struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "Address"               , fd_dictfct_Address_interpret  , fd_dictfct_Address_encode,    fd_dictfct_Address_dump };
     297                        struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "Address"               , Address_interpret     , Address_encode,       Address_dump    };
    135298                        CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
    136299                }
     
    151314                                This procedure MUST be supported by all DIAMETER nodes.
    152315                        */
    153                         struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "Time"                  , fd_dictfct_Time_interpret     , fd_dictfct_Time_encode,       fd_dictfct_Time_dump            };
     316                        struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "Time"                  , NULL                  , NULL          , NULL          };
    154317                        CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
    155318                }
     
    189352                                octets, not characters.
    190353                        */
    191                         struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "UTF8String"            , NULL                  , NULL  , fd_dictfct_UTF8String_dump    };
     354                        struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "UTF8String"            , NULL                  , NULL  , UTF8String_dump       };
    192355                        CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
    193356                }
     
    218381                                Domain Name (IDNs).
    219382                        */
    220                         struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "DiameterIdentity"      , NULL                  , NULL          , fd_dictfct_UTF8String_dump    };
     383                        struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "DiameterIdentity"      , NULL                  , NULL          , UTF8String_dump       };
    221384                        CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
    222385                }
     
    273436                                aaa://host.example.com:1813;transport=udp;protocol=radius
    274437                        */
    275                         struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "DiameterURI"           , NULL                  , NULL          , fd_dictfct_UTF8String_dump    };
     438                        struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "DiameterURI"           , NULL                  , NULL          , UTF8String_dump       };
    276439                        CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
    277440                }
     
    335498                                infrastructure.
    336499                        */
    337                         struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "IPFilterRule"          , NULL                  , NULL          , fd_dictfct_UTF8String_dump    };
     500                        struct dict_type_data data = { AVP_TYPE_OCTETSTRING,    "IPFilterRule"          , NULL                  , NULL          , UTF8String_dump       };
    338501                        CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
    339502                }
  • libfdcore/fdd.l

    r950 r944  
    5252        yylloc->first_column = yylloc->last_column + 1;                 \
    5353        yylloc->last_column = yylloc->first_column + yyleng - 1;        \
    54         TRACE_DEBUG_ERROR(                                              \
    55                 "(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n", \
     54        TRACE_DEBUG_ERROR("(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n",       \
    5655                yylloc->first_line, yylloc->first_column,               \
    5756                yylloc->last_line, yylloc->last_column,                 \
     
    146145<*>[[:alnum:]]+         |       /* This rule is only useful to print a complete token in error messages */
    147146        /* Unrecognized character */
    148 <*>.                    {
     147<*>.                    { 
    149148                                TRACE_DEBUG_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext);
    150149                                return LEX_ERROR;
  • libfdcore/fdd.y

    r950 r944  
    328328                                if (fd == NULL) {
    329329                                        int ret = errno;
    330                                         TRACE_DEBUG_ERROR("Unable to open extension file %s for reading: %s\n", fname, strerror(ret));
     330                                        TRACE_DEBUG(INFO, "Unable to open extension file %s for reading: %s\n", fname, strerror(ret));
    331331                                        yyerror (&yylloc, conf, "Error adding extension");
    332332                                        YYERROR;
     
    502502                                if (fd == NULL) {
    503503                                        int ret = errno;
    504                                         TRACE_DEBUG_ERROR("Unable to open certificate file %s for reading: %s\n", $3, strerror(ret));
     504                                        TRACE_DEBUG(INFO, "Unable to open certificate file %s for reading: %s\n", $3, strerror(ret));
    505505                                        yyerror (&yylloc, conf, "Error on file name");
    506506                                        YYERROR;
     
    510510                                if (fd == NULL) {
    511511                                        int ret = errno;
    512                                         TRACE_DEBUG_ERROR("Unable to open private key file %s for reading: %s\n", $5, strerror(ret));
     512                                        TRACE_DEBUG(INFO, "Unable to open private key file %s for reading: %s\n", $5, strerror(ret));
    513513                                        yyerror (&yylloc, conf, "Error on file name");
    514514                                        YYERROR;
     
    533533                                if (fd == NULL) {
    534534                                        int ret = errno;
    535                                         TRACE_DEBUG_ERROR("Unable to open CA file %s for reading: %s\n", $3, strerror(ret));
     535                                        TRACE_DEBUG(INFO, "Unable to open CA file %s for reading: %s\n", $3, strerror(ret));
    536536                                        yyerror (&yylloc, conf, "Error on file name");
    537537                                        YYERROR;
     
    573573                                if (fd == NULL) {
    574574                                        int ret = errno;
    575                                         TRACE_DEBUG_ERROR("Unable to open CRL file %s for reading: %s\n", $3, strerror(ret));
     575                                        TRACE_DEBUG(INFO, "Unable to open CRL file %s for reading: %s\n", $3, strerror(ret));
    576576                                        yyerror (&yylloc, conf, "Error on file name");
    577577                                        YYERROR;
     
    616616                                                        &err_pos),
    617617                                                { yyerror (&yylloc, conf, "Error setting Priority parameter.");
    618                                                   TRACE_DEBUG_ERROR("Error at position : %s\n", err_pos);
     618                                                  fprintf(stderr, "Error at position : %s\n", err_pos);
    619619                                                  YYERROR; } );
    620620                        }
     
    633633                                if (fd == NULL) {
    634634                                        int ret = errno;
    635                                         TRACE_DEBUG_ERROR("Unable to open DH file %s for reading: %s\n", $3, strerror(ret));
     635                                        TRACE_DEBUG(INFO, "Unable to open DH file %s for reading: %s\n", $3, strerror(ret));
    636636                                        yyerror (&yylloc, conf, "Error on file name");
    637637                                        YYERROR;
  • libfdcore/messages.c

    r924 r892  
    159159        CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_FIRST_CHILD, avp ) );
    160160       
    161         /* Save the session associated with the message */
    162         CHECK_FCT( fd_msg_sess_set( msg, sess) );
    163        
    164161        /* Done! */
    165162        return 0;
     
    287284                        hdr->msg_flags |= CMD_FLAG_ERROR;
    288285                else
    289                         hdr->msg_flags &= ~ CMD_FLAG_ERROR;
     286                        hdr->msg_flags &= ! CMD_FLAG_ERROR;
    290287        }
    291288       
  • libfdcore/peers.c

    r950 r947  
    549549        ev_data->validate = !found;
    550550       
    551         CHECK_FCT_DO( ret = fd_event_send(peer->p_events, FDEVP_CNX_INCOMING, sizeof(*ev_data), ev_data), goto out );
     551        CHECK_FCT_DO( ret = fd_event_send(peer->p_events, FDEVP_CNX_INCOMING, sizeof(ev_data), ev_data), goto out );
    552552       
    553553out:   
  • libfdcore/sctp.c

    r950 r946  
    654654                if (ep->sa.sa_family == AF_INET6)
    655655                #else /* SCTP_USE_MAPPED_ADDRESSES */
    656                 if (target_family == AF_INET6)
     656                if (target_family == AF_INET6) {
    657657                #endif /* SCTP_USE_MAPPED_ADDRESSES */
    658658                        sz = sizeof(sSA6);
     
    10871087        /* We will loop while all data is not received. */
    10881088incomplete:
    1089         while (datasize + sizeof(struct timespec) >= bufsz ) {
     1089        if (datasize == bufsz - sizeof(struct timespec)) {
    10901090                /* The buffer is full, enlarge it */
    10911091                bufsz += mempagesz;
  • libfdproto/CMakeLists.txt

    r922 r836  
    66        fdproto-internal.h
    77        dictionary.c
    8         dictionary_functions.c
    98        dispatch.c
    109        fifo.c
  • libfdproto/fdproto-internal.h

    r924 r909  
    7070int fd_sess_reclaim_msg ( struct session ** session );
    7171
    72 
    7372/* For dump routines into string buffers */
    7473#include <stdarg.h>
  • libfdproto/messages.c

    r924 r903  
    106106#define _A(_x) ((struct avp *)(_x))
    107107/* Check the type and eyecatcher */
    108 #define CHECK_AVP(_x) ((_x) && (_C(_x)->type == MSG_AVP) && (_A(_x)->avp_eyec == MSG_AVP_EYEC))
     108#define CHECK_AVP(_x) ((_C(_x)->type == MSG_AVP) && (_A(_x)->avp_eyec == MSG_AVP_EYEC))
    109109
    110110/* The following structure represents an instance of a message (command and children AVPs). */
     
    239239                if (new->avp_rawlen) {
    240240                        CHECK_MALLOC(  new->avp_rawdata = malloc(new->avp_rawlen)  );
    241                         memset(new->avp_rawdata, 0x00, new->avp_rawlen);
     241                        memset(new->avp_rawdata, 0xFF, new->avp_rawlen);
    242242                }
    243243        }
     
    12161216}
    12171217
    1218 /* Associate a session with a message, use only when the session was just created */
    1219 int fd_msg_sess_set(struct msg * msg, struct session * session)
    1220 {
    1221         TRACE_ENTRY("%p %p", msg, session);
    1222        
    1223         /* Check we received valid parameters */
    1224         CHECK_PARAMS( CHECK_MSG(msg) );
    1225         CHECK_PARAMS( session );
    1226         CHECK_PARAMS( msg->msg_sess == NULL );
    1227        
    1228         msg->msg_sess = session;
    1229         return 0;
    1230 }
    1231 
    12321218
    12331219/* Retrieve the session of the message */
     
    12751261       
    12761262        /* Resolve the session and we are done */
    1277         if (avp->avp_public.avp_value->os.len > 0) {
    1278                 CHECK_FCT( fd_sess_fromsid_msg ( avp->avp_public.avp_value->os.data, avp->avp_public.avp_value->os.len, &msg->msg_sess, new) );
    1279                 *session = msg->msg_sess;
    1280         } else {
    1281                 TRACE_DEBUG(FULL, "Session-Id AVP with 0-byte length found in message %p", msg);
    1282                 *session = NULL;
    1283         }
     1263        CHECK_FCT( fd_sess_fromsid_msg ( avp->avp_public.avp_value->os.data, avp->avp_public.avp_value->os.len, &msg->msg_sess, new) );
     1264        *session = msg->msg_sess;
    12841265       
    12851266        return 0;
     
    16671648                struct avp * avp;
    16681649               
    1669                 if (buflen - offset < AVPHDRSZ_NOVEND) {
     1650                if (buflen - offset <= AVPHDRSZ_NOVEND) {
    16701651                        TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes", buflen - offset);
    16711652                        return EBADMSG;
     
    16851666               
    16861667                if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) {
    1687                         if (buflen - offset < 4) {
     1668                        if (buflen - offset <= 4) {
    16881669                                TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes for vendor and data", buflen - offset);
    16891670                                free(avp);
     
    16951676               
    16961677                /* Check there is enough remaining data in the buffer */
    1697                 if ( (avp->avp_public.avp_len > GETAVPHDRSZ(avp->avp_public.avp_flags))
    1698                 && (buflen - offset < avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags))) {
     1678                if (buflen - offset < avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags)) {
    16991679                        TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes for data, and avp data size is %d",
    17001680                                        buflen - offset,
  • libfdproto/sessions.c

    r924 r788  
    360360
    361361
    362 /* Create a new session object with the default timeout value, and link it. The refcount is increased by 1, whether the session existed or not */
     362/* Create a new session object with the default timeout value, and link it */
    363363int fd_sess_new ( struct session ** session, DiamId_t diamid, size_t diamidlen, uint8_t * opt, size_t optlen )
    364364{
     
    461461       
    462462                fd_list_insert_before(li, &sess->chain_h); /* hash table */
    463                 sess->msg_cnt++;
    464463        } else {
    465464                free(sid);
    466                
    467                 CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) );
    468                 (*session)->msg_cnt++;
    469                 CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) );
    470                
    471465                /* it was found: was it previously destroyed? */
    472466                if ((*session)->is_destroyed == 0) {
     
    475469                } else {
    476470                        /* the session was marked destroyed, let's re-activate it. */
     471                        TODO("Re-creating a deleted session. Should investigate if this can lead to an issue... (need more feedback)");
    477472                        sess = *session;
    478                         sess->is_destroyed = 0;
    479473                       
    480474                        /* update the expiry time */
     
    507501
    508502out:
    509         ;
     503        ;       
    510504        pthread_cleanup_pop(0);
    511505        CHECK_POSIX( pthread_mutex_unlock( H_LOCK(hash) ) );
     
    518512}
    519513
    520 /* Find or create a session -- the msg refcount is increased */
    521 int fd_sess_fromsid_msg ( uint8_t * sid, size_t len, struct session ** session, int * new)
     514/* Find or create a session */
     515int fd_sess_fromsid ( uint8_t * sid, size_t len, struct session ** session, int * new)
    522516{
    523517        int ret;
     
    808802
    809803/* For the messages module */
    810 int fd_sess_fromsid ( uint8_t * sid, size_t len, struct session ** session, int * new)
     804int fd_sess_fromsid_msg ( uint8_t * sid, size_t len, struct session ** session, int * new)
    811805{
    812806        TRACE_ENTRY("%p %zd %p %p", sid, len, session, new);
     
    814808       
    815809        /* Get the session object */
    816         CHECK_FCT( fd_sess_fromsid_msg ( sid, len, session, new) );
    817        
    818         /* Decrease the refcount */
    819         CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) );
    820         (*session)->msg_cnt--; /* was increased in fd_sess_new */
    821         CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) );
    822                
     810        CHECK_FCT( fd_sess_fromsid ( sid, len, session, new) );
     811       
     812        /* Increase count */
     813        CHECK_FCT( fd_sess_ref_msg ( *session ) );
     814       
    823815        /* Done */
    824816        return 0;
     
    841833{
    842834        int reclaim;
    843         uint32_t hash;
    844835       
    845836        TRACE_ENTRY("%p", session);
    846837        CHECK_PARAMS( session && VALIDATE_SI(*session) );
    847838       
    848         /* Lock the hash line to avoid possibility that session is freed while we are reclaiming */
    849         hash = (*session)->hash;
    850         CHECK_POSIX( pthread_mutex_lock( H_LOCK(hash)) );
    851         pthread_cleanup_push( fd_cleanup_mutex, H_LOCK(hash) );
    852 
    853839        /* Update the msg refcount */
    854840        CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) );
     
    857843        CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) );
    858844       
    859         /* Ok, now unlock the hash line */
    860         pthread_cleanup_pop( 0 );
    861         CHECK_POSIX( pthread_mutex_unlock( H_LOCK(hash) ) );
    862        
    863         /* and reclaim if no message references the session anymore */
    864845        if (reclaim == 1) {
    865846                CHECK_FCT(fd_sess_reclaim ( session ));
Note: See TracChangeset for help on using the changeset viewer.