Changes in / [950:51c15f98a965:949:ad5c976e0dc7] in freeDiameter
- Files:
-
- 1 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
INSTALL.FreeBSD
r921 r707 9 9 10 10 Then 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 ... 12 12 13 13 … … 46 46 47 47 7) 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../freeDiameter48 # /usr/local/bin/cmake -DFLEX_EXECUTABLE:FILEPATH=/usr/local/bin/flex ../freeDiameter 49 49 50 50 8) Compile, optionnaly test -
extensions/app_radgw/rgwx_auth.c
r924 r740 458 458 if (si_len) { 459 459 /* 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) ); 461 461 } else { 462 462 /* Create a new Session-Id string */ … … 496 496 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 497 497 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) ); 498 CHECK_FCT( fd_msg_sess_set( *diam_fw, *session) );499 498 } 500 499 -
extensions/app_radgw/rgwx_sip.c
r924 r816 480 480 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 481 481 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) ); 482 CHECK_FCT( fd_msg_sess_set( *diam_fw, *session) );483 482 484 483 /* -
extensions/app_sip/registrationtermination.c
r924 r706 148 148 { 149 149 #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 )); 151 159 } 152 160 -
extensions/test_app/ta_bench.c
r924 r879 122 122 union avp_value val; 123 123 struct ta_mess_info * mi = NULL; 124 struct session *sess = NULL; 124 125 125 126 TRACE_DEBUG(FULL, "Creating a new message for sending."); … … 130 131 /* Create a new session */ 131 132 #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 ); 133 134 134 135 /* Create the random value to store with the session */ … … 142 143 143 144 /* 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 } 144 158 145 159 /* Set the Destination-Realm AVP */ -
extensions/test_app/ta_cli.c
r924 r740 151 151 /* Create a new session */ 152 152 #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 ); 155 154 156 155 /* Create the random value to store with the session */ … … 165 164 /* Now set all AVPs values */ 166 165 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 167 179 /* Set the Destination-Realm AVP */ 168 180 { -
extensions/test_sip/locationinfo.c
r924 r706 42 42 struct msg * message=NULL; 43 43 struct avp *avp=NULL; 44 struct session *sess=NULL; 44 45 union avp_value value; 45 46 … … 61 62 // Create a new session 62 63 { 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 )); 64 73 } 65 74 -
extensions/test_sip/locationinfosl.c
r924 r706 42 42 struct msg * message=NULL; 43 43 struct avp *avp=NULL; 44 struct session *sess=NULL; 44 45 union avp_value value; 45 46 … … 61 62 // Create a new session 62 63 { 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 )); 64 73 } 65 74 -
extensions/test_sip/serverassignment.c
r924 r706 42 42 struct msg * message=NULL; 43 43 struct avp *avp=NULL; 44 struct session *sess=NULL; 44 45 union avp_value value; 45 46 … … 70 71 // Create a new session 71 72 { 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 )); 73 82 } 74 83 -
extensions/test_sip/userauthorization.c
r924 r706 42 42 struct msg * message=NULL; 43 43 struct avp *avp=NULL; 44 struct session *sess=NULL; 44 45 union avp_value value; 45 46 … … 66 67 // Create a new session 67 68 { 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 )); 69 78 } 70 79 -
include/freeDiameter/libfdproto.h
r950 r946 1158 1158 }; 1159 1159 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 /****/1180 1160 1181 1161 /*** … … 1208 1188 1209 1189 */ 1210 1190 1211 1191 /* 1212 1192 *************************************************************************** … … 1810 1790 * 1811 1791 * 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) 1815 1795 * ENOMEM : Not enough memory to complete the operation 1816 1796 */ … … 2499 2479 int fd_msg_sess_get(struct dictionary * dict, struct msg * msg, struct session ** session, int * isnew); 2500 2480 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 2505 2481 /***************************************/ 2506 2482 /* Manage AVP values */ -
libfdcore/dict_base_proto.c
r922 r838 45 45 struct dictionary * fd_g_dict = NULL; 46 46 47 /* The functions to encode and interpret the derived types defined in the base protocol */ 48 49 /* Address AVP <-> struct sockaddr_storage */ 50 static 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 103 static 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 */ 147 static 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 204 static 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 47 210 48 211 … … 132 295 the content and format of the remaining octets. 133 296 */ 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 }; 135 298 CHECK_dict_new( DICT_TYPE, &data , NULL, NULL); 136 299 } … … 151 314 This procedure MUST be supported by all DIAMETER nodes. 152 315 */ 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 }; 154 317 CHECK_dict_new( DICT_TYPE, &data , NULL, NULL); 155 318 } … … 189 352 octets, not characters. 190 353 */ 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 }; 192 355 CHECK_dict_new( DICT_TYPE, &data , NULL, NULL); 193 356 } … … 218 381 Domain Name (IDNs). 219 382 */ 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 }; 221 384 CHECK_dict_new( DICT_TYPE, &data , NULL, NULL); 222 385 } … … 273 436 aaa://host.example.com:1813;transport=udp;protocol=radius 274 437 */ 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 }; 276 439 CHECK_dict_new( DICT_TYPE, &data , NULL, NULL); 277 440 } … … 335 498 infrastructure. 336 499 */ 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 }; 338 501 CHECK_dict_new( DICT_TYPE, &data , NULL, NULL); 339 502 } -
libfdcore/fdd.l
r950 r944 52 52 yylloc->first_column = yylloc->last_column + 1; \ 53 53 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", \ 56 55 yylloc->first_line, yylloc->first_column, \ 57 56 yylloc->last_line, yylloc->last_column, \ … … 146 145 <*>[[:alnum:]]+ | /* This rule is only useful to print a complete token in error messages */ 147 146 /* Unrecognized character */ 148 <*>. { 147 <*>. { 149 148 TRACE_DEBUG_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext); 150 149 return LEX_ERROR; -
libfdcore/fdd.y
r950 r944 328 328 if (fd == NULL) { 329 329 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)); 331 331 yyerror (&yylloc, conf, "Error adding extension"); 332 332 YYERROR; … … 502 502 if (fd == NULL) { 503 503 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)); 505 505 yyerror (&yylloc, conf, "Error on file name"); 506 506 YYERROR; … … 510 510 if (fd == NULL) { 511 511 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)); 513 513 yyerror (&yylloc, conf, "Error on file name"); 514 514 YYERROR; … … 533 533 if (fd == NULL) { 534 534 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)); 536 536 yyerror (&yylloc, conf, "Error on file name"); 537 537 YYERROR; … … 573 573 if (fd == NULL) { 574 574 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)); 576 576 yyerror (&yylloc, conf, "Error on file name"); 577 577 YYERROR; … … 616 616 &err_pos), 617 617 { 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); 619 619 YYERROR; } ); 620 620 } … … 633 633 if (fd == NULL) { 634 634 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)); 636 636 yyerror (&yylloc, conf, "Error on file name"); 637 637 YYERROR; -
libfdcore/messages.c
r924 r892 159 159 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_FIRST_CHILD, avp ) ); 160 160 161 /* Save the session associated with the message */162 CHECK_FCT( fd_msg_sess_set( msg, sess) );163 164 161 /* Done! */ 165 162 return 0; … … 287 284 hdr->msg_flags |= CMD_FLAG_ERROR; 288 285 else 289 hdr->msg_flags &= ~CMD_FLAG_ERROR;286 hdr->msg_flags &= ! CMD_FLAG_ERROR; 290 287 } 291 288 -
libfdcore/peers.c
r950 r947 549 549 ev_data->validate = !found; 550 550 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 ); 552 552 553 553 out: -
libfdcore/sctp.c
r950 r946 654 654 if (ep->sa.sa_family == AF_INET6) 655 655 #else /* SCTP_USE_MAPPED_ADDRESSES */ 656 if (target_family == AF_INET6) 656 if (target_family == AF_INET6) { 657 657 #endif /* SCTP_USE_MAPPED_ADDRESSES */ 658 658 sz = sizeof(sSA6); … … 1087 1087 /* We will loop while all data is not received. */ 1088 1088 incomplete: 1089 while (datasize + sizeof(struct timespec) >= bufsz) {1089 if (datasize == bufsz - sizeof(struct timespec)) { 1090 1090 /* The buffer is full, enlarge it */ 1091 1091 bufsz += mempagesz; -
libfdproto/CMakeLists.txt
r922 r836 6 6 fdproto-internal.h 7 7 dictionary.c 8 dictionary_functions.c9 8 dispatch.c 10 9 fifo.c -
libfdproto/fdproto-internal.h
r924 r909 70 70 int fd_sess_reclaim_msg ( struct session ** session ); 71 71 72 73 72 /* For dump routines into string buffers */ 74 73 #include <stdarg.h> -
libfdproto/messages.c
r924 r903 106 106 #define _A(_x) ((struct avp *)(_x)) 107 107 /* 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)) 109 109 110 110 /* The following structure represents an instance of a message (command and children AVPs). */ … … 239 239 if (new->avp_rawlen) { 240 240 CHECK_MALLOC( new->avp_rawdata = malloc(new->avp_rawlen) ); 241 memset(new->avp_rawdata, 0x 00, new->avp_rawlen);241 memset(new->avp_rawdata, 0xFF, new->avp_rawlen); 242 242 } 243 243 } … … 1216 1216 } 1217 1217 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 1232 1218 1233 1219 /* Retrieve the session of the message */ … … 1275 1261 1276 1262 /* 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; 1284 1265 1285 1266 return 0; … … 1667 1648 struct avp * avp; 1668 1649 1669 if (buflen - offset < AVPHDRSZ_NOVEND) {1650 if (buflen - offset <= AVPHDRSZ_NOVEND) { 1670 1651 TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes", buflen - offset); 1671 1652 return EBADMSG; … … 1685 1666 1686 1667 if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) { 1687 if (buflen - offset < 4) {1668 if (buflen - offset <= 4) { 1688 1669 TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes for vendor and data", buflen - offset); 1689 1670 free(avp); … … 1695 1676 1696 1677 /* 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)) { 1699 1679 TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes for data, and avp data size is %d", 1700 1680 buflen - offset, -
libfdproto/sessions.c
r924 r788 360 360 361 361 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 */ 363 363 int fd_sess_new ( struct session ** session, DiamId_t diamid, size_t diamidlen, uint8_t * opt, size_t optlen ) 364 364 { … … 461 461 462 462 fd_list_insert_before(li, &sess->chain_h); /* hash table */ 463 sess->msg_cnt++;464 463 } else { 465 464 free(sid); 466 467 CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) );468 (*session)->msg_cnt++;469 CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) );470 471 465 /* it was found: was it previously destroyed? */ 472 466 if ((*session)->is_destroyed == 0) { … … 475 469 } else { 476 470 /* 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)"); 477 472 sess = *session; 478 sess->is_destroyed = 0;479 473 480 474 /* update the expiry time */ … … 507 501 508 502 out: 509 ; 503 ; 510 504 pthread_cleanup_pop(0); 511 505 CHECK_POSIX( pthread_mutex_unlock( H_LOCK(hash) ) ); … … 518 512 } 519 513 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 */ 515 int fd_sess_fromsid ( uint8_t * sid, size_t len, struct session ** session, int * new) 522 516 { 523 517 int ret; … … 808 802 809 803 /* For the messages module */ 810 int fd_sess_fromsid ( uint8_t * sid, size_t len, struct session ** session, int * new)804 int fd_sess_fromsid_msg ( uint8_t * sid, size_t len, struct session ** session, int * new) 811 805 { 812 806 TRACE_ENTRY("%p %zd %p %p", sid, len, session, new); … … 814 808 815 809 /* 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 823 815 /* Done */ 824 816 return 0; … … 841 833 { 842 834 int reclaim; 843 uint32_t hash;844 835 845 836 TRACE_ENTRY("%p", session); 846 837 CHECK_PARAMS( session && VALIDATE_SI(*session) ); 847 838 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 853 839 /* Update the msg refcount */ 854 840 CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) ); … … 857 843 CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) ); 858 844 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 */864 845 if (reclaim == 1) { 865 846 CHECK_FCT(fd_sess_reclaim ( session ));
Note: See TracChangeset
for help on using the changeset viewer.