Changes in / [1307:7a2ab0087788:1306:0d15dad33f0b] in freeDiameter
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
.hgtags
r1293 r1282 69 69 f937feb727347445f8afb7759a97e34c76c0ba7b 1.2.0 70 70 ab6457399be2762b3e85bd173ba754ff758ef060 1.2.1-rc1 71 043b894b0511b6beb155576e9e2c509a21be8360 proposed_merged72 0000000000000000000000000000000000000000 proposed_merged73 13948c684c354d8c891ca5e2a5f1d76d1f176afe 1.2.1-rc2 -
contrib/debian/changelog
r1304 r1234 1 freediameter (1.2.1) UNRELEASED; urgency=low2 3 * New extension: rt_randomize (load-balancing on possible destinations)4 * New contrib: Gx extension.5 * rt_redirect.fdx and rt_load_balance.fdx improvement: use a hash table. Thanks Thomas.6 * New hook HOOK_MESSAGE_SENDING to give a last chance to edit messages before they are sent.7 This will be mostly used for enforcing interoperability constraints on non-compliant peers.8 * Simplified log output. Old output can be recovered with DEBUG_WITH_META build option.9 * Updated the internal counters for finer control on the load.10 * Fixes in message expiry mechanism.11 * Bug fixes in error messages generation.12 * Improvements on shutdown sequence handling.13 * Improvements to the dict_dcca_* extensions.14 * Improved default CMake configuration.15 * Fixes for a few newer operating systems compatibility.16 * Fixed default secure Diameter port number 5868 instead of5658 (errata of RFC 6733)17 18 -- Sebastien Decugis <sdecugis@freediameter.net> Sat, 30 Jan 2016 23:38:03 +080019 20 1 freediameter (1.2.0) UNRELEASED; urgency=low 21 2 -
doc/freediameter.conf.sample
r1304 r1246 32 32 # See TLS_old_method for more information about TLS flavours. 33 33 # Note: we use TLS/SCTP instead of DTLS/SCTP at the moment. This will change in future version of freeDiameter. 34 # Default: 5 868. Use 0 to disable.35 #SecPort = 5 868;34 # Default: 5658. Use 0 to disable. 35 #SecPort = 5658; 36 36 37 37 # Use RFC3588 method for TLS protection, where TLS is negociated after CER/CEA exchange is completed … … 238 238 # No_TCP; No_SCTP; No_IP; No_IPv6; Prefer_TCP; TLS_old_method; 239 239 # No_TLS; # assume transparent security instead of TLS. DTLS is not supported yet (will change in future versions). 240 # Port = 5 868; # The port to connect to240 # Port = 5658; # The port to connect to 241 241 # TcTimer = 30; 242 242 # TwTimer = 30; -
extensions/app_radgw/md5.c
r1291 r972 293 293 byteReverse((unsigned char *) ctx->buf, 4); 294 294 os_memcpy(digest, ctx->buf, 16); 295 os_memset(ctx, 0, sizeof( *ctx)); /* In case it's sensitive */295 os_memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ 296 296 } 297 297 -
extensions/app_sip/md5.c
r1291 r972 316 316 byteReverse((unsigned char *) ctx->buf, 4); 317 317 os_memcpy(digest, ctx->buf, 16); 318 os_memset(ctx, 0, sizeof( *ctx)); /* In case it's sensitive */318 os_memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ 319 319 } 320 320 -
extensions/dbg_msg_dumps/dbg_msg_dumps.c
r1307 r1306 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 105 105 } 106 106 break; 107 case HOOK_MESSAGE_PARSING_ERROR2:108 LOG_E("PARSING ERROR, returning:");109 LOG_SPLIT(FD_LOG_ERROR, " ", buf, NULL);110 break;111 107 case HOOK_MESSAGE_ROUTING_ERROR: 112 108 LOG_E("ROUTING ERROR '%s' for: ", (char *)other); … … 121 117 case HOOK_MESSAGE_RECEIVED: 122 118 LOG_N("RCV from '%s':", peer_name); 123 LOG_SPLIT(FD_LOG_NOTICE, " ", buf, NULL);124 break;125 case HOOK_MESSAGE_SENDING:126 LOG_N("SNDING to '%s':", peer_name);127 119 LOG_SPLIT(FD_LOG_NOTICE, " ", buf, NULL); 128 120 break; … … 202 194 } 203 195 break; 204 case HOOK_MESSAGE_PARSING_ERROR2:205 LOG_E("PARSING ERROR, returning: %s", buf);206 break;207 196 case HOOK_MESSAGE_ROUTING_ERROR: 208 197 LOG_E("ROUTING ERROR '%s' for: %s", (char *)other, buf); … … 215 204 case HOOK_MESSAGE_RECEIVED: 216 205 LOG_N("RCV from '%s': %s", peer_name, buf); 217 break;218 case HOOK_MESSAGE_SENDING:219 LOG_N("SNDING to '%s': %s", peer_name, buf);220 206 break; 221 207 case HOOK_MESSAGE_SENT: … … 287 273 } 288 274 break; 289 case HOOK_MESSAGE_PARSING_ERROR2:290 LOG_E("PARSING ERROR, returning: %s", buf);291 break;292 275 case HOOK_MESSAGE_ROUTING_ERROR: 293 276 LOG_E("ROUTING ERROR '%s' for: %s", (char *)other, buf); … … 300 283 case HOOK_MESSAGE_RECEIVED: 301 284 LOG_N("RCV from '%s': %s", peer_name, buf); 302 break;303 case HOOK_MESSAGE_SENDING:304 LOG_N("SNDING to '%s': %s", peer_name, buf);305 285 break; 306 286 case HOOK_MESSAGE_SENT: … … 361 341 } 362 342 363 mask_errors = HOOK_MASK( HOOK_MESSAGE_FAILOVER, HOOK_MESSAGE_PARSING_ERROR, HOOK_MESSAGE_ PARSING_ERROR2, HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED );364 mask_sndrcv = HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT ); /* We don t access SENDING hook here */343 mask_errors = HOOK_MASK( HOOK_MESSAGE_FAILOVER, HOOK_MESSAGE_PARSING_ERROR, HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED ); 344 mask_sndrcv = HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT ); 365 345 mask_routing= HOOK_MASK( HOOK_MESSAGE_LOCAL, HOOK_MESSAGE_ROUTING_FORWARD, HOOK_MESSAGE_ROUTING_LOCAL ); 366 346 mask_peers = HOOK_MASK( HOOK_PEER_CONNECT_FAILED, HOOK_PEER_CONNECT_SUCCESS ); -
extensions/test_app/ta_bench.c
r1294 r1206 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 37 37 38 38 #include "test_app.h" 39 40 #include <semaphore.h> 39 41 #include <stdio.h> 40 41 #ifndef __APPLE__ /* they deprecated the semaphore there... */42 #include <semaphore.h>43 44 #define my_sem_t sem_t45 #define my_sem_init sem_init46 #define my_sem_destroy sem_destroy47 #define my_sem_timedwait sem_timedwait48 #define my_sem_post sem_post49 50 #else // on APPLE51 #include <sched.h>52 #include <dispatch/dispatch.h>53 54 #define my_sem_t dispatch_semaphore_t55 56 static int my_sem_init(my_sem_t * s, int pshared, unsigned int value ) {57 *s = dispatch_semaphore_create(value);58 if (*s == NULL)59 return ENOMEM;60 return 0;61 }62 63 static int my_sem_destroy(my_sem_t *s) {64 dispatch_release(*s);65 *s = NULL;66 return 0;67 }68 69 static int my_sem_timedwait(my_sem_t * s, struct timespec *ts) {70 struct timespec tsn;71 int64_t nsec;72 dispatch_time_t when;73 74 CHECK_SYS( clock_gettime(CLOCK_REALTIME, &tsn) );75 76 nsec = (ts->tv_sec * 1000000000) + ts->tv_nsec77 - (tsn.tv_sec * 1000000000) - tsn.tv_nsec;78 79 when = dispatch_time ( DISPATCH_TIME_NOW, nsec );80 81 return dispatch_semaphore_wait ( *s, when ) ? ETIMEDOUT : 0;82 }83 84 static int my_sem_post(my_sem_t *s) {85 dispatch_semaphore_signal(*s);86 return 0;87 }88 89 #endif // APPLE90 91 92 42 93 43 struct ta_mess_info { … … 96 46 }; 97 47 98 static my_sem_t ta_sem; /* To handle the concurrency */48 static sem_t ta_sem; /* To handle the concurrency */ 99 49 100 50 /* Cb called when an answer is received */ … … 160 110 161 111 /* Post the semaphore */ 162 CHECK_SYS_DO( my_sem_post(&ta_sem), );112 CHECK_SYS_DO( sem_post(&ta_sem), ); 163 113 164 114 return; … … 264 214 do { 265 215 /* Do not create more that NB_CONCURRENT_MESSAGES in paralel */ 266 int ret = my_sem_timedwait(&ta_sem, &end_time);216 int ret = sem_timedwait(&ta_sem, &end_time); 267 217 if (ret == -1) { 268 218 ret = errno; … … 320 270 int ta_bench_init(void) 321 271 { 322 CHECK_SYS( my_sem_init( &ta_sem, 0, ta_conf->bench_concur) );272 CHECK_SYS( sem_init( &ta_sem, 0, ta_conf->bench_concur) ); 323 273 324 274 CHECK_FCT( fd_event_trig_regcb(ta_conf->signal, "test_app.bench", ta_bench_start ) ); … … 331 281 // CHECK_FCT_DO( fd_sig_unregister(ta_conf->signal), /* continue */ ); 332 282 333 CHECK_SYS_DO( my_sem_destroy(&ta_sem), );283 CHECK_SYS_DO( sem_destroy(&ta_sem), ); 334 284 335 285 return; -
extensions/test_app/ta_cli.c
r1305 r1214 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 71 71 72 72 CHECK_FCT_DO( fd_sess_state_retrieve( ta_cli_reg, sess, &mi ), return ); 73 TRACE_DEBUG( INFO, "%p %p", mi, data); 73 74 ASSERT( (void *)mi == data ); 74 75 } -
freeDiameterd/main.c
r1305 r1182 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 172 172 /* Loop on arguments */ 173 173 while (1) { 174 c = getopt_long (argc, argv, "hVc:dql: f:F:g:", long_options, &option_index);174 c = getopt_long (argc, argv, "hVc:dql:M:", long_options, &option_index); 175 175 if (c == -1) 176 176 break; /* Exit from the loop. */ … … 208 208 #ifdef DEBUG 209 209 fd_debug_one_function = optarg; 210 fd_g_debug_lvl = FD_LOG_DEBUG;211 210 #else /* DEBUG */ 212 211 fprintf(stderr, "Error: must compile with DEBUG support to use --dbg_func feature!\n"); … … 218 217 #ifdef DEBUG 219 218 fd_debug_one_file = basename(optarg); 220 fd_g_debug_lvl = FD_LOG_DEBUG;221 219 #else /* DEBUG */ 222 220 fprintf(stderr, "Error: must compile with DEBUG support to use --dbg_file feature!\n"); -
include/freeDiameter/CMakeLists.txt
r1295 r1289 16 16 OPTION(ERRORS_ON_TODO "(development) Generate compilation errors on TODO items ?" OFF) 17 17 18 # In DEBUG mode, each log c an contain pid, calling function and file for easy debug. Set to ON to displaythis information.19 OPTION(DEBUG_WITH _META "Showcalling location in logs?" OFF)18 # In DEBUG mode, each log contains pid, calling function and file for easy debug. Set to ON to strip this information. 19 OPTION(DEBUG_WITHOUT_META "Strip calling location in logs?" OFF) 20 20 21 21 # Create the absolute path for searching extensions … … 37 37 OPTION(WORKAROUND_ACCEPT_INVALID_VSAI "Do not reject a CER/CEA with a Vendor-Specific-Application-Id AVP containing both Auth- and Acct- application AVPs?" OFF) 38 38 39 MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DEBUG_WITH _META DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY WORKAROUND_ACCEPT_INVALID_VSAI)39 MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO DEBUG_WITHOUT_META DIAMID_IDNA_IGNORE DIAMID_IDNA_REJECT DISABLE_PEER_EXPIRY WORKAROUND_ACCEPT_INVALID_VSAI) 40 40 41 41 ######################## -
include/freeDiameter/freeDiameter-host.h.in
r1305 r1237 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 54 54 #cmakedefine DISABLE_SCTP 55 55 #cmakedefine DEBUG_SCTP 56 #cmakedefine DEBUG_WITH _META56 #cmakedefine DEBUG_WITHOUT_META 57 57 #cmakedefine SCTP_USE_MAPPED_ADDRESSES 58 58 #cmakedefine SCTP_CONNECTX_4_ARGS -
include/freeDiameter/libfdcore.h
r1305 r1220 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 6, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 128 128 129 129 uint16_t cnf_port; /* the local port for legacy Diameter (default: 3868) in host byte order */ 130 uint16_t cnf_port_tls; /* the local port for Diameter/TLS (default: 5 868) in host byte order */130 uint16_t cnf_port_tls; /* the local port for Diameter/TLS (default: 5658) in host byte order */ 131 131 uint16_t cnf_port_3436; /* Open an additional server port to listen to old TLS/SCTP clients (RFC3436, freeDiameter versions < 1.2.0) */ 132 132 uint16_t cnf_sctp_str; /* default max number of streams for SCTP associations (def: 30) */ … … 965 965 */ 966 966 967 HOOK_MESSAGE_SENDING,968 /* Hook called when a message is about to be sent to a peer. The message pointer cannot be modified here, but the content of the message969 could still be changed (for example add or remove some AVP. This is the last chance.970 - {msg} points to the message. Some objects may not have been dictionary resolved. If you971 try to call fd_msg_parse_dict, it will slow down the operation of the instance.972 - {peer} is the one the message is being sent to.973 - {other} is NULL.974 - {permsgdata} points to existing structure if any, or a new structure otherwise.975 */976 977 967 HOOK_MESSAGE_SENT, 978 968 /* Hook called when a message has been sent to a peer. The message might be freed as soon as the hook function returns, … … 1003 993 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered). 1004 994 */ 1005 995 1006 996 HOOK_MESSAGE_ROUTING_ERROR, 1007 997 /* Hook called when a message being processed by the routing thread meets an error such as no remaining available peer for sending, based on routing callbacks decisions (maybe after retries). … … 1059 1049 */ 1060 1050 1061 HOOK_MESSAGE_PARSING_ERROR2, 1062 /* Hook called after an error message has been generated due to a dictionary parsing error. 1063 - {msg} points to the error message that has been generated. 1064 - {peer} is NULL. You can still retrieve the source from the message itself. 1065 - {other} is NULL 1066 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered). 1067 Use this hook if you need to populate more data in the error being returned, from the error message. 1068 (e.g. some AVP need to be added to replies even if error case. 1069 */ 1070 #define HOOK_LAST HOOK_MESSAGE_PARSING_ERROR2 1051 #define HOOK_LAST HOOK_PEER_CONNECT_SUCCESS 1071 1052 }; 1072 1053 -
include/freeDiameter/libfdproto.h
r1304 r1281 110 110 111 111 #define DIAMETER_PORT 3868 112 #define DIAMETER_SECURE_PORT 5 868112 #define DIAMETER_SECURE_PORT 5658 113 113 114 114 … … 290 290 #endif /* __PRETTY_FUNCTION__ */ 291 291 292 /* A version of __FILE__ without the full path . This is specific to each C file being compiled*/292 /* A version of __FILE__ without the full path */ 293 293 static char * file_bname = NULL; 294 294 static char * file_bname_init(char * full) { file_bname = basename(full); return file_bname; } … … 298 298 299 299 /* In DEBUG mode, we add meta-information along each trace. This makes multi-threading problems easier to debug. */ 300 #if (defined(DEBUG) && defined(DEBUG_WITH_META))300 #if (defined(DEBUG) && !defined(DEBUG_WITHOUT_META)) 301 301 # define STD_TRACE_FMT_STRING "pid:%s in %s@%s:%d: " 302 302 # define STD_TRACE_FMT_ARGS , ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed"), __PRETTY_FUNCTION__, __STRIPPED_FILE__, __LINE__ 303 #else /* DEBUG && DEBUG_WITH_META */303 #else /* DEBUG && !DEBUG_WITHOUT_META */ 304 304 # define STD_TRACE_FMT_STRING "" 305 305 # define STD_TRACE_FMT_ARGS 306 #endif /* DEBUG && DEBUG_WITH_META */306 #endif /* DEBUG && !DEBUG_WITHOUT_META */ 307 307 308 308 /************************* … … 1259 1259 typedef int (*dict_avpdata_encode) (void * data, union avp_value * val); 1260 1260 1261 /*1262 * CALLBACK: dict_avpdata_check1263 *1264 * PARAMETERS:1265 * val : Pointer to the AVP value that was received and needs to be sanity checked.1266 * data : a parameter stored in the type structure (to enable more generic check functions)1267 * error_msg: upon erroneous value, a string describing the error can be returned here (it will be strcpy by caller). This description will be returned in the error message, if any.1268 *1269 * DESCRIPTION:1270 * This callback can be provided with a derived type in order to improve the operation of the1271 * fd_msg_parse_dict function. When this callback is present, the value of the AVP that has1272 * been parsed is passed to this function for finer granularity check. For example for some1273 * speccific AVP, the format of an OCTETSTRING value can be further checked, or the1274 * interger value can be verified.1275 *1276 * RETURN VALUE:1277 * 0 : The value is valid.1278 * !0 : An error occurred, the error code is returned. It is advised to return EINVAL on incorrect val1279 */1280 typedef int (*dict_avpdata_check) (void * data, union avp_value * val, char ** error_msg);1281 1282 1283 1261 1284 1262 /* Type to hold data associated to a derived AVP data type */ … … 1289 1267 dict_avpdata_encode type_encode; /* cb to convert formatted data into an AVP value (or NULL) */ 1290 1268 DECLARE_FD_DUMP_PROTOTYPE((*type_dump), union avp_value * val); /* cb called by fd_msg_dump_* for this type of data (if != NULL). Returned string must be freed. */ 1291 dict_avpdata_check type_check;1292 void * type_check_param;1293 1269 }; 1294 1270 … … 1317 1293 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_Time_dump, union avp_value * avp_value); 1318 1294 1319 1320 /* For string AVP, the following type_check function provides simple basic check for specific characters presence, e.g. use "@." for trivial email address check */1321 int fd_dictfct_CharInOS_check(void * data, union avp_value * val, char ** error_msg);1322 1295 1323 1296 -
libfdcore/hooks.c
r1307 r1306 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 345 345 } 346 346 347 case HOOK_MESSAGE_SENDING: {348 LOG_A("SENDING message to '%s'", peer ? peer->p_hdr.info.pi_diamid : "<unknown>");349 break;350 }351 352 347 case HOOK_MESSAGE_SENT: { 353 348 CHECK_MALLOC_DO(fd_msg_dump_summary(&hook_default_buf, &hook_default_len, NULL, msg, NULL, 0, 1), break); … … 383 378 } 384 379 385 case HOOK_MESSAGE_PARSING_ERROR2: {386 CHECK_MALLOC_DO(fd_msg_dump_treeview(&hook_default_buf, &hook_default_len, NULL, msg, NULL, 0, 1), break);387 388 LOG_E("Returning following message after parsing error:");389 LOG_SPLIT(FD_LOG_ERROR, " ", hook_default_buf, NULL);390 break;391 }392 393 380 case HOOK_MESSAGE_ROUTING_ERROR: { 394 381 CHECK_MALLOC_DO(fd_msg_dump_treeview(&hook_default_buf, &hook_default_len, NULL, msg, NULL, 0, 1), break); -
libfdcore/p_out.c
r1305 r1238 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 166 166 TRACE_ENTRY("%p %p %p", msg, cnx, peer); 167 167 CHECK_PARAMS( msg && *msg && (cnx || (peer && peer->p_cnxctx))); 168 169 fd_hook_call(HOOK_MESSAGE_SENDING, *msg, peer, NULL, fd_msg_pmdl_get(*msg));170 168 171 169 if (update_reqin_cnt && peer) { -
libfdcore/routing_dispatch.c
r1301 r1283 454 454 } else { 455 455 if (!msgptr) { 456 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR2, error, NULL, NULL, fd_msg_pmdl_get(error));457 456 /* error now contains the answer message to send back */ 458 457 CHECK_FCT( fd_fifo_post(fd_g_outgoing, &error) ); -
libfdproto/dictionary_functions.c
r1300 r1284 359 359 } 360 360 361 /* Check that a given AVP value contains all the characters from data in the same order */362 static char error_message[80];363 int fd_dictfct_CharInOS_check(void * data, union avp_value * val, char ** error_msg)364 {365 char * inChar = data;366 char * inData = (char *)val->os.data;367 int i = 0;368 CHECK_PARAMS(data);369 while (*inChar != '\0') {370 while (i < val->os.len) {371 if (*inChar == inData[i++]) {372 inChar++;373 break;374 }375 }376 if (i >= val->os.len)377 break;378 }379 if (*inChar == '\0')380 return 0;381 382 if (error_msg) {383 snprintf(error_message, sizeof(error_message), "Could not find '%c' in AVP", *inChar);384 *error_msg = error_message;385 }386 return EBADMSG;387 } -
libfdproto/log.c
r1305 r1243 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 96 96 /* add timestamp */ 97 97 printf("%s ", fd_log_time(NULL, buf, sizeof(buf), 98 #if (defined(DEBUG) && defined(DEBUG_WITH_META))98 #if (defined(DEBUG) && !defined(DEBUG_WITHOUT_META)) 99 99 1, 1 100 #else /* (defined(DEBUG) && defined(DEBUG_WITH_META)) */100 #else /* (defined(DEBUG) && !defined(DEBUG_WITHOUT_META)) */ 101 101 0, 0 102 #endif /* (defined(DEBUG) && defined(DEBUG_WITH_META)) */102 #endif /* (defined(DEBUG) && !defined(DEBUG_WITHOUT_META)) */ 103 103 )); 104 104 /* Use colors on stdout ? */ -
libfdproto/messages.c
r1305 r1248 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 232 232 struct dict_avp_data dictdata; 233 233 234 CHECK_FCT _DO( fd_dict_getval(model, &dictdata), { free(new); return __ret__; });234 CHECK_FCT( fd_dict_getval(model, &dictdata) ); 235 235 236 236 new->avp_model = model; … … 248 248 new->avp_rawlen = (*avp)->avp_public.avp_len - GETAVPHDRSZ( (*avp)->avp_public.avp_flags ); 249 249 if (new->avp_rawlen) { 250 CHECK_MALLOC _DO( new->avp_rawdata = malloc(new->avp_rawlen), { free(new); return __ret__; });250 CHECK_MALLOC( new->avp_rawdata = malloc(new->avp_rawlen) ); 251 251 memset(new->avp_rawdata, 0x00, new->avp_rawlen); 252 252 } … … 286 286 struct dict_object *dictappl; 287 287 288 CHECK_FCT _DO( fd_dict_getdict(model, &dict), { free(new); return __ret__; });289 CHECK_FCT _DO( fd_dict_getval(model, &dictdata), { free(new); return __ret__; });288 CHECK_FCT( fd_dict_getdict(model, &dict) ); 289 CHECK_FCT( fd_dict_getval(model, &dictdata) ); 290 290 291 291 new->msg_model = model; … … 294 294 295 295 /* Initialize application from the parent, if any */ 296 CHECK_FCT _DO( fd_dict_search( dict, DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl, 0), { free(new); return __ret__; });296 CHECK_FCT( fd_dict_search( dict, DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl, 0) ); 297 297 if (dictappl != NULL) { 298 298 struct dict_application_data appdata; 299 CHECK_FCT _DO( fd_dict_getval(dictappl, &appdata), { free(new); return __ret__; });299 CHECK_FCT( fd_dict_getval(dictappl, &appdata) ); 300 300 new->msg_public.msg_appl = appdata.application_id; 301 301 } … … 365 365 366 366 if (!sess_id_avp) { 367 CHECK_FCT _DO( fd_dict_search( dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &sess_id_avp, ENOENT), { free(ans); return __ret__; });368 } 369 CHECK_FCT _DO( fd_sess_getsid ( sess, &sid, &sidlen ), { free(ans); return __ret__; });370 CHECK_FCT _DO( fd_msg_avp_new ( sess_id_avp, 0, &avp ), { free(ans); return __ret__; });367 CHECK_FCT( fd_dict_search( dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &sess_id_avp, ENOENT) ); 368 } 369 CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ) ); 370 CHECK_FCT( fd_msg_avp_new ( sess_id_avp, 0, &avp ) ); 371 371 val.os.data = sid; 372 372 val.os.len = sidlen; 373 CHECK_FCT _DO( fd_msg_avp_setvalue( avp, &val ), { free(avp); free(ans); return __ret__; });374 CHECK_FCT _DO( fd_msg_avp_add( ans, MSG_BRW_FIRST_CHILD, avp ), { free(avp); free(ans); return __ret__; });373 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); 374 CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_FIRST_CHILD, avp ) ); 375 375 ans->msg_sess = sess; 376 CHECK_FCT _DO( fd_sess_ref_msg(sess), { free(ans); return __ret__; });376 CHECK_FCT( fd_sess_ref_msg(sess) ); 377 377 } 378 378 … … 383 383 struct fd_list avpcpylist = FD_LIST_INITIALIZER(avpcpylist); 384 384 385 CHECK_FCT _DO( fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL) , { free(ans); return __ret__; });385 CHECK_FCT( fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL) ); 386 386 while (avp) { 387 387 if ( (avp->avp_public.avp_code == AC_PROXY_INFO) … … 394 394 395 395 /* Create a buffer with the content of the AVP. This is easier than going through the list */ 396 CHECK_FCT _DO( fd_msg_update_length(avp), { free(ans); return __ret__; });397 CHECK_MALLOC _DO( buf = malloc(avp->avp_public.avp_len), { free(ans); return __ret__; });398 CHECK_FCT _DO( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp), { free(buf); free(ans); return __ret__; });396 CHECK_FCT( fd_msg_update_length(avp) ); 397 CHECK_MALLOC( buf = malloc(avp->avp_public.avp_len) ); 398 CHECK_FCT( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp) ); 399 399 400 400 /* Now we parse this buffer to create a copy AVP */ 401 CHECK_FCT _DO( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist), { free(buf); free(ans); return __ret__; });401 CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist) ); 402 402 403 403 /* Parse dictionary objects now to remove the dependency on the buffer */ 404 CHECK_FCT _DO( parsedict_do_chain(dict, &avpcpylist, 0, &pei), { /* leaking the avpcpylist -- this should never happen anyway */ free(buf); free(ans); return __ret__; });404 CHECK_FCT( parsedict_do_chain(dict, &avpcpylist, 0, &pei) ); 405 405 406 406 /* Done for this AVP */ … … 411 411 } 412 412 /* move to next AVP in the message, we can have several Proxy-Info instances */ 413 CHECK_FCT _DO( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL), { free(ans); return __ret__; });413 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) ); 414 414 } 415 415 } … … 2037 2037 { 2038 2038 struct dict_avp_data dictdata; 2039 struct dict_type_data derivedtypedata;2040 struct dict_object * avp_derived_type = NULL;2041 2039 uint8_t * source; 2042 2040 … … 2219 2217 break; 2220 2218 2221 }2222 2223 /* Is there a derived type check function ? */2224 CHECK_FCT ( fd_dict_search ( dict, DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &avp_derived_type, 0) );2225 if (avp_derived_type) {2226 CHECK_FCT( fd_dict_getval(avp_derived_type, &derivedtypedata) );2227 if (derivedtypedata.type_check != NULL) {2228 char * err;2229 int ret = (*derivedtypedata.type_check)( derivedtypedata.type_check_param, &avp->avp_storage, &err );2230 2231 if (ret != 0) {2232 TRACE_DEBUG(INFO, "The AVP failed to pass the dictionary validation");2233 if (error_info) {2234 error_info->pei_errcode = "DIAMETER_INVALID_AVP_VALUE";2235 error_info->pei_avp = avp;2236 strncpy(error_message, err, sizeof(error_message));2237 error_info->pei_message = error_message;2238 } else {2239 char * buf = NULL;2240 size_t buflen;2241 CHECK_MALLOC(fd_msg_dump_treeview(&buf, &buflen, NULL, avp, NULL, 0, 0));2242 LOG_E("Invalid AVP: %s", buf);2243 free(buf);2244 }2245 return ret; /* should we just return EBADMSG? */2246 }2247 }2248 2219 } 2249 2220 -
tests/testmesg.c
r1300 r1281 309 309 #endif 310 310 } 311 312 {313 struct dict_object * type = NULL;314 struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS test2", NULL, NULL, NULL, fd_dictfct_CharInOS_check, "@." };315 struct dict_avp_data avp_data = { 73575, 73565, "AVP Test - os2", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING };316 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) );317 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) );318 }319 320 311 #if 0 321 312 { … … 762 753 /* reset */ 763 754 CHECK( 0, fd_msg_free ( msg ) ); 764 }765 766 /* Test with a type verifier */767 {768 struct fd_pei error_info;769 CPYBUF();770 buf_cpy[103] = 0x67; /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */771 772 /* Check that we cannot support this message now */773 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );774 CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );775 776 /* reset */777 CHECK( 0, fd_msg_free ( msg ) );778 779 CPYBUF();780 buf_cpy[103] = 0x67; /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */781 782 /* Check error reporting works */783 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );784 CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, &error_info ) );785 786 #if 1787 fd_log_debug("Error reported: %s\n in AVP: %s", error_info.pei_message, fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, error_info.pei_avp, fd_g_config->cnf_dict, 0, 1));788 #endif789 790 /* reset */791 CHECK( 0, fd_msg_free ( msg ) );792 793 CPYBUF();794 buf_cpy[103] = 0x67; /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */795 buf_cpy[130] = '@';796 buf_cpy[140] = '.'; /* now we comply to the constraints */797 798 /* Check that we cannot support this message now */799 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );800 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );801 802 /* reset */803 CHECK( 0, fd_msg_free ( msg ) );804 805 806 755 } 807 756 … … 1450 1399 } 1451 1400 1401 1452 1402 /* That's all for the tests yet */ 1453 1403 PASSTEST();
Note: See TracChangeset
for help on using the changeset viewer.