Changeset 8:3e143f047f78 in freeDiameter
- Timestamp:
- Sep 18, 2009, 6:54:07 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 10 added
- 2 deleted
- 15 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
CMakeLists.txt
r1 r8 3 3 # Name of the project, and language 4 4 PROJECT("freeDiameter" C) 5 6 # Informations to display in daemon's help 7 SET(FD_PROJECT_NAME freeDiameter) 8 SET(FD_PROJECT_BINARY freeDiameterd) 9 SET(FD_PROJECT_VERSION_MAJOR 0) 10 SET(FD_PROJECT_VERSION_MINOR 1) 11 SET(FD_PROJECT_VERSION_REV 0) 12 SET(FD_PROJECT_COPYRIGHT "Copyright (c) 2008-2009, WIDE Project (www.wide.ad.jp) and NICT (www.nict.go.jp)") 5 13 6 14 # Some subfolders may have tests … … 16 24 ADD_DEFINITIONS(-D_GNU_SOURCE) 17 25 18 # Location for the include files19 INCLUDE_DIRECTORIES(include)20 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)21 SUBDIRS(include/freeDiameter)22 23 26 # some subfolders use yacc and lex parsers 24 27 SET(BISON_GENERATE_DEFINES TRUE) … … 33 36 # how to do the check with cmake??? 34 37 38 # Location for the include files 39 INCLUDE_DIRECTORIES(include) 40 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include) 41 SUBDIRS(include/freeDiameter) 42 35 43 # Location for the source code 36 44 SUBDIRS(libfreeDiameter) -
cmake/Modules/FindSCTP.cmake
r0 r8 6 6 # SCTP_LIBRARIES - link these to use SCTP 7 7 8 include(LibFindMacros) 9 10 # Use pkg-config to get hints about paths (Note: not yet supported?) 11 # libfind_pkg_check_modules(SCTP_PKGCONF sctp) 8 if (SCTP_INCLUDE_DIRS) 9 set(SCTP_FIND_QUIETLY TRUE) 10 endif (SCTP_INCLUDE_DIRS) 12 11 13 12 # Include dir 14 13 find_path(SCTP_INCLUDE_DIR 15 14 NAMES netinet/sctp.h 16 PATHS ${SCTP_PKGCONF_INCLUDE_DIRS}17 15 ) 18 16 19 # Finally the library itself17 # Library 20 18 find_library(SCTP_LIBRARY 21 19 NAMES sctp 22 PATHS ${SCTP_PKGCONF_LIBRARY_DIRS}23 20 ) 24 21 25 22 # Set the include dir variables and the libraries and let libfind_process do the rest. 26 23 # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 27 set(SCTP_PROCESS_INCLUDES SCTP_INCLUDE_DIR) 28 set(SCTP_PROCESS_LIBS SCTP_LIBRARY) 29 libfind_process(SCTP) 24 #set(SCTP_PROCESS_INCLUDES SCTP_INCLUDE_DIR) 25 #set(SCTP_PROCESS_LIBS SCTP_LIBRARY) 26 #libfind_process(SCTP) 27 28 29 # handle the QUIETLY and REQUIRED arguments and set SCTP_FOUND to TRUE if 30 # all listed variables are TRUE 31 INCLUDE(FindPackageHandleStandardArgs) 32 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SCTP DEFAULT_MSG SCTP_LIBRARY SCTP_INCLUDE_DIR) 33 34 # If we successfully found the sctp library then add the library to the 35 # SCTP_LIBRARIES cmake variable otherwise set SCTP_LIBRARIES to nothing. 36 IF(SCTP_FOUND) 37 SET( SCTP_LIBRARIES ${SCTP_LIBRARY} ) 38 ELSE(SCTP_FOUND) 39 SET( SCTP_LIBRARIES ) 40 ENDIF(SCTP_FOUND) 41 42 43 # Lastly make it so that the SCTP_LIBRARY and SCTP_INCLUDE_DIR variables 44 # only show up under the advanced options in the gui cmake applications. 45 MARK_AS_ADVANCED( SCTP_LIBRARY SCTP_INCLUDE_DIR ) 46 -
freeDiameter/CMakeLists.txt
r2 r8 2 2 Project("freeDiameterd" C) 3 3 4 SET(PROJECT_VERSION 0.1) 5 SET(PROJECT_COPYRIGHT "Copyright (c) 2008-2009, WIDE Project (www.wide.ad.jp) and NICT (www.nict.go.jp)") 4 # Configuration parser 5 BISON_FILE(fdd.y) 6 FLEX_FILE(fdd.l) 7 SET_SOURCE_FILES_PROPERTIES(lex.fdd.c fdd.tab.c PROPERTIES COMPILE_FLAGS "-I ${CMAKE_CURRENT_SOURCE_DIR}") 6 8 7 9 # List of source files 8 10 SET(FD_COMMON_SRC 9 11 fD.h 12 config.c 13 extensions.c 10 14 dict_base_proto.c 11 15 ) 12 16 17 SET(FD_COMMON_GEN_SRC 18 lex.fdd.c 19 fdd.tab.c 20 fdd.tab.h 21 ) 22 23 13 24 # Building the executable 14 ADD_EXECUTABLE(freeDiameterd ${FD_COMMON_SRC} main.c)25 ADD_EXECUTABLE(freeDiameterd ${FD_COMMON_SRC} ${FD_COMMON_GEN_SRC} main.c) 15 26 16 27 # The link command … … 20 31 # Save the list of files, if needed 21 32 SET(FD_COMMON_SRC ${FD_COMMON_SRC} PARENT_SCOPE) 33 SET(FD_COMMON_GEN_SRC ${FD_COMMON_GEN_SRC} PARENT_SCOPE) 22 34 23 35 # The unary tests directory -
freeDiameter/fD.h
r1 r8 42 42 #include <freeDiameter/freeDiameter.h> 43 43 44 /* Events codespace for fd_g_config->g_fifo_main */ 45 enum { 46 FM_TERMINATE = 1000 /* request to terminate */ 47 }; 48 49 /* Configuration */ 50 int fd_conf_init(); 51 void fd_conf_dump(); 52 int fd_conf_parse(); 53 int fddparse(struct fd_config * conf); /* yacc generated */ 54 55 /* Extensions */ 56 int fd_ext_init(); 57 int fd_ext_add( char * filename, char * conffile ); 58 int fd_ext_load(); 59 int fd_ext_fini(void); 60 44 61 /* Create all the dictionary objects defined in the Diameter base RFC. */ 45 62 int fd_dict_base_protocol(struct dictionary * dict); 46 63 47 48 64 #endif /* _FD_H */ -
freeDiameter/main.c
r3 r8 36 36 #include "fD.h" 37 37 38 #include <signal.h> 39 #include <getopt.h> 40 41 42 /* Display package version */ 43 static void main_version_core(void) 44 { 45 printf("%s, version %d.%d.%d" 46 #ifdef HG_VERSION 47 " (r%s" 48 # ifdef PACKAGE_HG_REVISION 49 "/%s" 50 # endif /* PACKAGE_HG_VERSION */ 51 ")" 52 #endif /* HG_VERSION */ 53 "\n", 54 FD_PROJECT_NAME, FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR, FD_PROJECT_VERSION_REV 55 #ifdef HG_VERSION 56 , HG_VERSION 57 # ifdef PACKAGE_HG_REVISION 58 , PACKAGE_HG_REVISION 59 # endif /* PACKAGE_HG_VERSION */ 60 #endif /* HG_VERSION */ 61 ); 62 } 63 64 /* Display package version and general info */ 65 static void main_version(void) 66 { 67 main_version_core(); 68 printf( "%s\n", FD_PROJECT_COPYRIGHT); 69 printf( "\nSee " FD_PROJECT_NAME " homepage at http://aaa.koganei.wide.ad.jp/\n" 70 " for information, updates and bug reports on this software.\n"); 71 } 72 73 /* Print command-line options */ 74 static void main_help( void ) 75 { 76 main_version_core(); 77 printf( " This daemon is an implementation of the Diameter protocol\n" 78 " used for Authentication, Authorization, and Accounting (AAA).\n"); 79 printf("\nUsage: " FD_PROJECT_BINARY " [OPTIONS]...\n"); 80 printf( " -h, --help Print help and exit\n" 81 " -V, --version Print version and exit\n" 82 " -c, --config=filename Read configuration from this file instead of the \n" 83 " default location (%s).\n", DEFAULT_CONF_FILE); 84 printf( "\nDebug:\n" 85 " These options are mostly useful for developers\n" 86 " -d, --debug Increase verbosity of debug messages\n" 87 " -q, --quiet Decrease verbosity then remove debug messages\n"); 88 } 89 90 /* Parse the command-line */ 91 static int main_cmdline(int argc, char *argv[]) 92 { 93 int c; 94 int option_index = 0; 95 96 struct option long_options[] = { 97 { "help", 0, NULL, 'h' }, 98 { "version", 0, NULL, 'V' }, 99 { "config", 1, NULL, 'c' }, 100 { "debug", 0, NULL, 'd' }, 101 { "quiet", 0, NULL, 'q' }, 102 { NULL, 0, NULL, 0 } 103 }; 104 105 TRACE_ENTRY("%d %p", argc, argv); 106 107 /* Loop on arguments */ 108 while (1) { 109 c = getopt_long (argc, argv, "hVc:dq", long_options, &option_index); 110 if (c == -1) 111 break; /* Exit from the loop. */ 112 113 switch (c) { 114 case 'h': /* Print help and exit. */ 115 main_help(); 116 exit(0); 117 118 case 'V': /* Print version and exit. */ 119 main_version(); 120 exit(0); 121 122 case 'c': /* Read configuration from this file instead of the default location.. */ 123 CHECK_PARAMS( optarg ); 124 fd_g_config->conf_file = optarg; 125 break; 126 127 case 'd': /* Increase verbosity of debug messages. */ 128 fd_g_debug_lvl++; 129 break; 130 131 case 'q': /* Decrease verbosity then remove debug messages. */ 132 fd_g_debug_lvl--; 133 break; 134 135 case '?': /* Invalid option. */ 136 /* `getopt_long' already printed an error message. */ 137 TRACE_DEBUG(INFO, "getopt_long found an invalid character\n"); 138 return EINVAL; 139 140 default: /* bug: option not considered. */ 141 TRACE_DEBUG(INFO, "A command-line option is missing in parser: %c\n", c); 142 ASSERT(0); 143 return EINVAL; 144 } 145 } 146 147 return 0; 148 149 } 150 151 #ifdef HAVE_SIGNALENT_H 152 const char *const signalstr[] = { 153 # include "signalent.h" 154 }; 155 const int nsignalstr = sizeof signalstr / sizeof signalstr[0]; 156 # define SIGNALSTR(sig) (((sig) < nsignalstr) ? signalstr[(sig)] : "unknown") 157 #else /* HAVE_SIGNALENT_H */ 158 # define SIGNALSTR(sig) ("") 159 #endif /* HAVE_SIGNALENT_H */ 160 161 162 /* signal handler */ 163 static void * sig_hdl(void * arg) 164 { 165 sigset_t sig_main; 166 int sig = 0; 167 168 TRACE_ENTRY(); 169 fd_log_threadname("Main signal handler"); 170 171 sigemptyset(&sig_main); 172 sigaddset(&sig_main, SIGINT); 173 sigaddset(&sig_main, SIGTERM); 174 175 CHECK_SYS_DO( sigwait(&sig_main, &sig), TRACE_DEBUG(INFO, "Error in sigwait function") ); 176 177 TRACE_DEBUG(INFO, "Received signal %s (%d), exiting", SIGNALSTR(sig), sig); 178 CHECK_FCT_DO( fd_event_send(fd_g_config->g_fifo_main, FM_TERMINATE, NULL), exit(2) ); 179 return NULL; 180 } 181 182 /* The static configuration structure */ 183 static struct fd_config conf; 184 struct fd_config * fd_g_config = &conf; 185 38 186 /* Entry point */ 39 187 int main(int argc, char * argv[]) 40 188 { 189 int ret; 190 pthread_t sig_th; 191 sigset_t sig_all; 192 193 memset(fd_g_config, 0, sizeof(struct fd_config)); 194 sigfillset(&sig_all); 195 CHECK_POSIX( pthread_sigmask(SIG_BLOCK, &sig_all, NULL) ); 196 41 197 /* Initialize the library */ 42 198 CHECK_FCT( fd_lib_init() ); … … 44 200 /* Name this thread */ 45 201 fd_log_threadname("Main"); 46 47 /* Initialize the dictionary */ 48 CHECK_FCT( fd_dict_init(&fd_g_dict) ); 202 203 /* Initialize the config */ 204 CHECK_FCT( fd_conf_init() ); 205 206 /* Parse the command-line */ 207 CHECK_FCT( main_cmdline(argc, argv) ); 208 209 /* Allow SIGINT and SIGTERM from this point */ 210 CHECK_POSIX( pthread_create(&sig_th, NULL, sig_hdl, NULL) ); 49 211 50 212 /* Add definitions of the base protocol */ 51 CHECK_FCT( fd_dict_base_protocol(fd_g_dict) ); 52 53 TRACE_DEBUG(INFO, "freeDiameter daemon initialized."); 54 55 return 0; 56 } 213 CHECK_FCT( fd_dict_base_protocol(fd_g_config->g_dict) ); 214 215 /* Initialize other modules */ 216 CHECK_FCT( fd_ext_init() ); 217 218 /* Parse the configuration file */ 219 CHECK_FCT( fd_conf_parse() ); 220 221 /* Load the dynamic extensions */ 222 CHECK_FCT( fd_ext_load() ); 223 224 /* Start the peer state machines */ 225 226 227 /* Now, just wait for events */ 228 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized."); 229 fd_conf_dump(); 230 while (1) { 231 int code; 232 CHECK_FCT_DO( fd_event_get(fd_g_config->g_fifo_main, &code, NULL), break ); 233 switch (code) { 234 case FM_TERMINATE: 235 ret = 0; 236 goto end; 237 238 default: 239 TRACE_DEBUG(INFO, "Unexpected event in the daemon (%d), terminating.\n", code); 240 ret = -1; 241 goto end; 242 } 243 } 244 245 end: 246 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon is stopping..."); 247 248 /* cleanups */ 249 CHECK_FCT( fd_thr_term(&sig_th) ); 250 251 return ret; 252 } -
freeDiameter/tests/CMakeLists.txt
r7 r8 15 15 testdict 16 16 testmesg 17 test mq17 testqueues 18 18 testsess 19 19 testdisp … … 29 29 INCLUDE_DIRECTORIES( "../../libfreeDiameter" ) 30 30 31 BISON_FILE(../fdd.y) 32 FLEX_FILE(../fdd.l) 33 31 34 SET(TEST_COMMON_SRC "") 32 35 … … 35 38 ENDFOREACH(SRC_FILE) 36 39 37 #FOREACH( SRC_FILE ${FD_COMMON_GEN_SRC})38 #SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "${CMAKE_CURRENT_BINARY_DIR}/../${SRC_FILE}")39 #ENDFOREACH(SRC_FILE)40 FOREACH( SRC_FILE ${FD_COMMON_GEN_SRC}) 41 SET(TEST_COMMON_SRC ${TEST_COMMON_SRC} "${CMAKE_CURRENT_BINARY_DIR}/../${SRC_FILE}") 42 ENDFOREACH(SRC_FILE) 40 43 41 44 FOREACH( SRC_FILE ${LFD_SRC}) -
freeDiameter/tests/testdict.c
r1 r8 67 67 68 68 /* Create two vendors */ 69 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_VENDOR, &vendor1_data , NULL, &obj1 ) );70 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_VENDOR, &vendor2_data , NULL, NULL ) );69 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_VENDOR, &vendor1_data , NULL, &obj1 ) ); 70 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_VENDOR, &vendor2_data , NULL, NULL ) ); 71 71 72 72 /* Check we always retrieve the correct vendor object */ 73 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) );73 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) ); 74 74 CHECK( obj1, obj2); 75 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 1", &obj2, ENOENT ) );75 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 1", &obj2, ENOENT ) ); 76 76 CHECK( obj1, obj2); 77 77 78 78 /* Check the error conditions */ 79 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) );79 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) ); 80 80 81 81 vendor_id = 735673; /* Not defined */ 82 CHECK( ENOENT, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) );83 CHECK( ENOENT, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", NULL, ENOENT ) );84 CHECK( ENOENT, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) );85 CHECK( ENOENT, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOENT ) );86 CHECK( ENOTSUP, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOTSUP ) );82 CHECK( ENOENT, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) ); 83 CHECK( ENOENT, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", NULL, ENOENT ) ); 84 CHECK( ENOENT, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) ); 85 CHECK( ENOENT, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOENT ) ); 86 CHECK( ENOTSUP, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOTSUP ) ); 87 87 88 88 /* Check the get_* functions */ … … 94 94 95 95 /* Create the application with vendor1 as parent */ 96 CHECK( EINVAL, fd_dict_new ( fd_g_ dict, DICT_APPLICATION, &app1_data , (struct dict_object *)"bad object", &obj2 ) );97 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_APPLICATION, &app1_data , obj1, &obj2 ) );96 CHECK( EINVAL, fd_dict_new ( fd_g_config->g_dict, DICT_APPLICATION, &app1_data , (struct dict_object *)"bad object", &obj2 ) ); 97 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_APPLICATION, &app1_data , obj1, &obj2 ) ); 98 98 99 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_VENDOR, VENDOR_OF_APPLICATION, obj2, &obj3, ENOENT ) );99 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_VENDOR, VENDOR_OF_APPLICATION, obj2, &obj3, ENOENT ) ); 100 100 CHECK( obj1, obj3); 101 101 … … 112 112 struct dict_avp_data example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED }; 113 113 114 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT ) );115 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT ) );114 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT ) ); 115 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT ) ); 116 116 117 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ) );117 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ) ); 118 118 119 119 rule_data.rule_avp = origin_host_avp; 120 120 rule_data.rule_min = 1; 121 121 rule_data.rule_max = 1; 122 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) );122 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) ); 123 123 124 124 rule_data.rule_avp = session_id_avp; 125 125 rule_data.rule_min = 1; 126 126 rule_data.rule_max = -1; 127 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) );127 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) ); 128 128 129 129 CHECK( 0, fd_dict_iterate_rules ( example_avp_avp, &nbr, iter_test) ); -
freeDiameter/tests/testdisp.c
r7 r8 128 128 struct dict_enumval_data enu2_data = { "ENU test 2", { .u32 = 2 }}; 129 129 130 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_APPLICATION, &app1_data, NULL, &app1 ) );131 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_APPLICATION, &app2_data, NULL, &app2 ) );132 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_COMMAND, &cmd1_data, NULL, &cmd1 ) );133 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_COMMAND, &cmd2_data, NULL, &cmd2 ) );134 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_TYPE, &type_data, NULL, &enutype ) );135 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp1_data, NULL, &avp1 ) );136 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp2_data, enutype, &avp2 ) );137 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_ENUMVAL, &enu1_data, enutype, &enu1 ) );138 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_ENUMVAL, &enu2_data, enutype, &enu2 ) );130 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_APPLICATION, &app1_data, NULL, &app1 ) ); 131 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_APPLICATION, &app2_data, NULL, &app2 ) ); 132 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_COMMAND, &cmd1_data, NULL, &cmd1 ) ); 133 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_COMMAND, &cmd2_data, NULL, &cmd2 ) ); 134 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_TYPE, &type_data, NULL, &enutype ) ); 135 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp1_data, NULL, &avp1 ) ); 136 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp2_data, enutype, &avp2 ) ); 137 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_ENUMVAL, &enu1_data, enutype, &enu1 ) ); 138 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_ENUMVAL, &enu2_data, enutype, &enu2 ) ); 139 139 } 140 140 -
freeDiameter/tests/testmesg.c
r2 r8 51 51 52 52 /* Now find the ACR dictionary object */ 53 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );53 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) ); 54 54 55 55 /* Create the instance, using the templates */ … … 71 71 72 72 /* Now find the ACR dictionary object */ 73 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_model, ENOENT ) );73 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_model, ENOENT ) ); 74 74 75 75 /* Create the instance, using the templates */ … … 133 133 134 134 /* Now find the dictionary object */ 135 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_AVP, AVP_BY_NAME, "Route-Record", &rr_model, ENOENT ) );135 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "Route-Record", &rr_model, ENOENT ) ); 136 136 137 137 /* Create the instance, using the templates */ … … 161 161 162 162 /* Now find the ACR dictionary object */ 163 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );163 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) ); 164 164 165 165 /* Create the instance, using the templates */ … … 173 173 { 174 174 struct dict_vendor_data vendor_data = { 73565, "Vendor test" }; 175 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_VENDOR, &vendor_data , NULL, &vendor ) );175 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_VENDOR, &vendor_data , NULL, &vendor ) ); 176 176 } 177 177 178 178 { 179 179 struct dict_application_data app_data = { 73566, "Application test" }; 180 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_APPLICATION, &app_data , vendor, NULL ) );180 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_APPLICATION, &app_data , vendor, NULL ) ); 181 181 } 182 182 183 183 { 184 184 struct dict_avp_data avp_data = { 73567, 0, "AVP Test - no vendor - f32", 0, 0, AVP_TYPE_FLOAT32 }; 185 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, NULL ) );185 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 186 186 } 187 187 … … 190 190 struct dict_type_data type_data = { AVP_TYPE_INTEGER64, "Int64 test" }; 191 191 struct dict_avp_data avp_data = { 73568, 73565, "AVP Test - i64", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_INTEGER64 }; 192 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_TYPE, &type_data , NULL, &type ) );193 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , type, NULL ) );192 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_TYPE, &type_data , NULL, &type ) ); 193 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , type, NULL ) ); 194 194 } 195 195 … … 202 202 struct dict_avp_data avp_data = { 73569, 73565, "AVP Test - enumi32", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_INTEGER32 }; 203 203 204 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_TYPE, &type_data , NULL, &type ) );205 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , type, NULL ) );206 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_ENUMVAL, &val1 , type, NULL ) );207 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_ENUMVAL, &val2 , type, NULL ) );208 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_ENUMVAL, &val3 , type, NULL ) );204 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_TYPE, &type_data , NULL, &type ) ); 205 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , type, NULL ) ); 206 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_ENUMVAL, &val1 , type, NULL ) ); 207 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_ENUMVAL, &val2 , type, NULL ) ); 208 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_ENUMVAL, &val3 , type, NULL ) ); 209 209 } 210 210 … … 213 213 struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS test" }; 214 214 struct dict_avp_data avp_data = { 73570, 73565, "AVP Test - os", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING }; 215 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_TYPE, &type_data , NULL, &type ) );216 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , type, NULL ) );215 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_TYPE, &type_data , NULL, &type ) ); 216 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , type, NULL ) ); 217 217 } 218 218 … … 225 225 struct dict_avp_data avp_data = { 73571, 73565, "AVP Test - enumos", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING }; 226 226 227 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_TYPE, &type_data , NULL, &type ) );228 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , type, NULL ) );229 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_ENUMVAL, &val1 , type, NULL ) );230 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_ENUMVAL, &val2 , type, NULL ) );231 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_ENUMVAL, &val3 , type, NULL ) );227 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_TYPE, &type_data , NULL, &type ) ); 228 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , type, NULL ) ); 229 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_ENUMVAL, &val1 , type, NULL ) ); 230 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_ENUMVAL, &val2 , type, NULL ) ); 231 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_ENUMVAL, &val3 , type, NULL ) ); 232 232 } 233 233 … … 236 236 struct dict_avp_data avp_data = { 73572, 73565, "AVP Test - grouped", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED }; 237 237 238 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, &gavp ) );238 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, &gavp ) ); 239 239 240 240 /* Macro to search AVP and create a rule */ … … 243 243 struct dict_avp_request _req = { (_vendor), 0, (_avpname) }; \ 244 244 struct dict_rule_data _data; \ 245 CHECK( 0, fd_dict_search( fd_g_ dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\245 CHECK( 0, fd_dict_search( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\ 246 246 _data.rule_avp = _avp; \ 247 247 _data.rule_position = (_pos); \ … … 249 249 _data.rule_min = (_min); \ 250 250 _data.rule_max = (_max); \ 251 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_RULE, &_data , (_parent), NULL ) ); \251 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_RULE, &_data , (_parent), NULL ) ); \ 252 252 } 253 253 … … 261 261 struct dict_cmd_data cmd_data = { 73573, "Test-Command-Request", CMD_FLAG_REQUEST, CMD_FLAG_REQUEST }; 262 262 263 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) );264 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_COMMAND, &cmd_data , application, &command ) );263 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) ); 264 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_COMMAND, &cmd_data , application, &command ) ); 265 265 ADD_RULE(command, 0, "AVP Test - no vendor - f32", RULE_FIXED_HEAD, -1, 1, 1); 266 266 ADD_RULE(command, 73565, "AVP Test - i64", RULE_REQUIRED, -1, -1, 0); … … 275 275 struct dict_avp_data avp_data = { 73574, 73565, "AVP Test - rules", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED }; 276 276 277 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, &gavp ) );277 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, &gavp ) ); 278 278 279 279 ADD_RULE(gavp, 0, "AVP Test - no vendor - f32", RULE_FIXED_HEAD, 0, 1, 1); … … 303 303 union avp_value value; 304 304 305 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );305 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) ); 306 306 307 307 /* Check an error is trigged if the AVP has no value set */ 308 308 { 309 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) );309 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) ); 310 310 311 311 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) ); … … 329 329 struct dict_object * _avp = NULL; \ 330 330 struct dict_avp_request _req = { (_avpvendor), 0, (_avpname) }; \ 331 CHECK( 0, fd_dict_search( fd_g_ dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\331 CHECK( 0, fd_dict_search( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\ 332 332 CHECK( 0, fd_msg_avp_new ( _avp, 0, &_avpi ) ); \ 333 333 CHECK( 0, fd_msg_avp_add ( (_parent), (_position), _avpi ) ); \ … … 378 378 379 379 CHECK( 0, fd_msg_model ( avpi, &avp_model ) ); 380 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );380 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) ); 381 381 memset(&request, 0, sizeof(request)); 382 382 request.type_obj = type_model; 383 383 request.search.enum_name = "i32 const test (val 2)"; 384 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );384 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) ); 385 385 CHECK( 0, fd_dict_getval ( value_model, &request.search ) ); 386 386 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) ); … … 399 399 400 400 CHECK( 0, fd_msg_model ( avpi, &avp_model ) ); 401 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );401 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) ); 402 402 memset(&request, 0, sizeof(request)); 403 403 request.type_obj = type_model; 404 404 request.search.enum_name = "i32 const test (val -5)"; 405 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );405 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) ); 406 406 CHECK( 0, fd_dict_getval ( value_model, &request.search ) ); 407 407 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) ); … … 458 458 459 459 CHECK( 0, fd_msg_model ( avpi, &avp_model ) ); 460 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );460 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) ); 461 461 memset(&request, 0, sizeof(request)); 462 462 request.type_obj = type_model; 463 463 request.search.enum_name = "os const test (waaad)"; 464 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );464 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) ); 465 465 CHECK( 0, fd_dict_getval ( value_model, &request.search ) ); 466 466 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) ); … … 483 483 484 484 CHECK( 0, fd_msg_model ( avpi, &avp_model ) ); 485 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );485 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) ); 486 486 memset(&request, 0, sizeof(request)); 487 487 request.type_obj = type_model; 488 488 request.search.enum_name = "os const test (waa)"; 489 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );489 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) ); 490 490 CHECK( 0, fd_dict_getval ( value_model, &request.search ) ); 491 491 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) ); … … 654 654 655 655 /* Now find the ACR dictionary object */ 656 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) );656 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) ); 657 657 658 658 CPYBUF(); … … 680 680 buf_cpy[5] = 0x11; 681 681 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) ); 682 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_ dict ) );682 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_config->g_dict ) ); 683 683 684 684 /* reset */ … … 695 695 /* Check that we cannot support this message now */ 696 696 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) ); 697 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_ dict ) );697 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_config->g_dict ) ); 698 698 699 699 /* reset */ … … 709 709 /* Check that we can support this message now */ 710 710 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) ); 711 CHECK( 0, fd_msg_parse_dict( msg, fd_g_ dict ) );711 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->g_dict ) ); 712 712 713 713 #if 0 … … 720 720 721 721 CHECK( 0, fd_msg_parse_buffer( &buf, 344, &msg) ); 722 CHECK( 0, fd_msg_parse_dict( msg, fd_g_ dict ) );722 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->g_dict ) ); 723 723 #if 0 724 724 fd_msg_dump_walk(0, msg); … … 730 730 struct dict_object * rule; 731 731 732 CHECK( 0, fd_msg_parse_rules( msg, fd_g_ dict, &rule ) );732 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->g_dict, &rule ) ); 733 733 734 734 /* Use the "AVP Test - rules" AVP to test the rules */ … … 749 749 750 750 /* Check the message is still conform */ 751 CHECK( 0, fd_msg_parse_rules( msg, fd_g_ dict, &rule ) );751 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->g_dict, &rule ) ); 752 752 753 753 /* The first avp is optional in fixed position, so remove it and check the message is still OK */ 754 754 CHECK( 0, fd_msg_browse ( tavp, MSG_BRW_FIRST_CHILD, &childavp, NULL) ); 755 755 CHECK( 0, fd_msg_free ( childavp ) ); 756 CHECK( 0, fd_msg_parse_rules( msg, fd_g_ dict, &rule ) );756 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->g_dict, &rule ) ); 757 757 ADD_AVP( tavp, MSG_BRW_FIRST_CHILD, childavp, 0, "AVP Test - no vendor - f32" ); 758 758 … … 761 761 #define CHECK_CONFLICT( _msg, _ruleavp, _avpvendor ) { \ 762 762 struct dict_object * _rule; \ 763 CHECK( EBADMSG, fd_msg_parse_rules( _msg, fd_g_ dict, &_rule ) ); \763 CHECK( EBADMSG, fd_msg_parse_rules( _msg, fd_g_config->g_dict, &_rule ) ); \ 764 764 if ((_ruleavp) == NULL) { \ 765 765 CHECK( NULL, _rule); \ … … 768 768 struct dict_object * _avp; \ 769 769 struct dict_avp_request _req = { (_avpvendor), 0, (_ruleavp) }; \ 770 CHECK( 0, fd_dict_search( fd_g_ dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT)); \770 CHECK( 0, fd_dict_search( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT)); \ 771 771 CHECK( 0, fd_dict_getval( _rule, &_ruledata ) ); \ 772 772 CHECK( _avp, _ruledata.rule_avp ); \ … … 824 824 825 825 /* The message is still conform */ 826 CHECK( 0, fd_msg_parse_rules( msg, fd_g_ dict, &rule ) );826 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->g_dict, &rule ) ); 827 827 828 828 /* Now break the rule */ … … 865 865 866 866 /* Find the CER dictionary object */ 867 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) );867 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) ); 868 868 869 869 /* Now find the Host-IP-Address dictionary object */ 870 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &hia_model, ENOENT ) );870 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &hia_model, ENOENT ) ); 871 871 872 872 /* Create the msg instance */ … … 945 945 /* Ok, now let's recreate the message */ 946 946 CHECK( 0, fd_msg_parse_buffer( &buf, 64, &cer) ); 947 CHECK( 0, fd_msg_parse_dict( cer, fd_g_ dict ) );947 CHECK( 0, fd_msg_parse_dict( cer, fd_g_config->g_dict ) ); 948 948 949 949 /* Get the pointers to the first and last AVP */ … … 972 972 { 973 973 struct dict_avp_data avp_data = { 91001, 0, "AVP Test 2 - os", 0, 0, AVP_TYPE_OCTETSTRING }; 974 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, NULL ) );974 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 975 975 } 976 976 { 977 977 struct dict_avp_data avp_data = { 91002, 0, "AVP Test 2 - i32", 0, 0, AVP_TYPE_INTEGER32 }; 978 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, NULL ) );978 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 979 979 } 980 980 { 981 981 struct dict_avp_data avp_data = { 91003, 0, "AVP Test 2 - i64", 0, 0, AVP_TYPE_INTEGER64 }; 982 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, NULL ) );982 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 983 983 } 984 984 { 985 985 struct dict_avp_data avp_data = { 91004, 0, "AVP Test 2 - u32", 0, 0, AVP_TYPE_UNSIGNED32 }; 986 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, NULL ) );986 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 987 987 } 988 988 { 989 989 struct dict_avp_data avp_data = { 91005, 0, "AVP Test 2 - u64", 0, 0, AVP_TYPE_UNSIGNED64 }; 990 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, NULL ) );990 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 991 991 } 992 992 { 993 993 struct dict_avp_data avp_data = { 91006, 0, "AVP Test 2 - f32", 0, 0, AVP_TYPE_FLOAT32 }; 994 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, NULL ) );994 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 995 995 } 996 996 { 997 997 struct dict_avp_data avp_data = { 91007, 0, "AVP Test 2 - f64", 0, 0, AVP_TYPE_FLOAT64 }; 998 CHECK( 0, fd_dict_new ( fd_g_ dict, DICT_AVP, &avp_data , NULL, NULL ) );998 CHECK( 0, fd_dict_new ( fd_g_config->g_dict, DICT_AVP, &avp_data , NULL, NULL ) ); 999 999 } 1000 1000 … … 1010 1010 struct msg_hdr * msgdata = NULL; 1011 1011 1012 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );1012 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) ); 1013 1013 1014 1014 /* Create a message */ … … 1175 1175 1176 1176 CHECK( 0, fd_msg_parse_buffer( &buf, 148, &msg) ); 1177 CHECK( 0, fd_msg_parse_dict( msg, fd_g_ dict ) );1177 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->g_dict ) ); 1178 1178 #if 0 1179 1179 fd_msg_dump_walk(0, msg); -
freeDiameter/tests/testqueues.c
r1 r8 38 38 /* Structure for testing threshold function */ 39 39 static struct thrh_test { 40 struct mqueue *queue; /* pointer to the queue */40 struct fifo * queue; /* pointer to the queue */ 41 41 int h_calls; /* number of calls of h_cb */ 42 42 int l_calls; /* number of calls of l_cb */ … … 44 44 45 45 /* Callbacks for threasholds test */ 46 void thrh_cb_h(struct mqueue*queue, void **data)46 void thrh_cb_h(struct fifo *queue, void **data) 47 47 { 48 48 if (thrh_td.h_calls == thrh_td.l_calls) { … … 57 57 thrh_td.h_calls ++; 58 58 } 59 void thrh_cb_l(struct mqueue*queue, void **data)59 void thrh_cb_l(struct fifo *queue, void **data) 60 60 { 61 61 CHECK( 1, data ? 1 : 0 ); … … 76 76 /* Structure that is passed to the test function */ 77 77 struct test_data { 78 struct mqueue* queue; /* pointer to the queue */78 struct fifo * queue; /* pointer to the queue */ 79 79 pthread_barrier_t * bar; /* if not NULL, barrier to synchronize before getting messages */ 80 80 struct timespec * ts; /* if not NULL, use a timedget instead of a get */ … … 100 100 for (i=0; i< td->nbr; i++) { 101 101 if (td->ts != NULL) { 102 CHECK( 0, fd_ mq_timedget(td->queue, &msg, td->ts) );102 CHECK( 0, fd_fifo_timedget(td->queue, &msg, td->ts) ); 103 103 } else { 104 CHECK( 0, fd_ mq_get(td->queue, &msg) );104 CHECK( 0, fd_fifo_get(td->queue, &msg) ); 105 105 } 106 106 } … … 128 128 struct dict_object * dwr_model = NULL; 129 129 130 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );131 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) );132 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) );130 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) ); 131 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) ); 132 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) ); 133 133 CHECK( 0, fd_msg_new ( acr_model, 0, &msg1 ) ); 134 134 CHECK( 0, fd_msg_new ( cer_model, 0, &msg2 ) ); … … 138 138 /* Basic operation */ 139 139 { 140 struct mqueue* queue = NULL;140 struct fifo * queue = NULL; 141 141 int count; 142 142 struct msg * msg = NULL; 143 143 144 144 /* Create the queue */ 145 CHECK( 0, fd_ mq_new(&queue) );145 CHECK( 0, fd_fifo_new(&queue) ); 146 146 147 147 /* Check the count is 0 */ 148 CHECK( 0, fd_ mq_length(queue, &count) );148 CHECK( 0, fd_fifo_length(queue, &count) ); 149 149 CHECK( 0, count); 150 150 151 151 /* Now enqueue */ 152 152 msg = msg1; 153 CHECK( 0, fd_ mq_post(queue, &msg) );153 CHECK( 0, fd_fifo_post(queue, &msg) ); 154 154 msg = msg2; 155 CHECK( 0, fd_ mq_post(queue, &msg) );155 CHECK( 0, fd_fifo_post(queue, &msg) ); 156 156 msg = msg3; 157 CHECK( 0, fd_ mq_post(queue, &msg) );157 CHECK( 0, fd_fifo_post(queue, &msg) ); 158 158 159 159 /* Check the count is 3 */ 160 CHECK( 0, fd_ mq_length(queue, &count) );160 CHECK( 0, fd_fifo_length(queue, &count) ); 161 161 CHECK( 3, count); 162 162 163 /* Retrieve the first message using fd_ mq_get */164 CHECK( 0, fd_ mq_get(queue, &msg) );163 /* Retrieve the first message using fd_fifo_get */ 164 CHECK( 0, fd_fifo_get(queue, &msg) ); 165 165 CHECK( msg1, msg); 166 CHECK( 0, fd_ mq_length(queue, &count) );166 CHECK( 0, fd_fifo_length(queue, &count) ); 167 167 CHECK( 2, count); 168 168 169 /* Retrieve the second message using fd_ mq_timedget */169 /* Retrieve the second message using fd_fifo_timedget */ 170 170 CHECK(0, clock_gettime(CLOCK_REALTIME, &ts)); 171 171 ts.tv_sec += 1; /* Set the timeout to 1 second */ 172 CHECK( 0, fd_ mq_timedget(queue, &msg, &ts) );172 CHECK( 0, fd_fifo_timedget(queue, &msg, &ts) ); 173 173 CHECK( msg2, msg); 174 CHECK( 0, fd_ mq_length(queue, &count) );174 CHECK( 0, fd_fifo_length(queue, &count) ); 175 175 CHECK( 1, count); 176 176 177 177 /* Retrieve the third message using meq_tryget */ 178 CHECK( 0, fd_ mq_tryget(queue, &msg) );178 CHECK( 0, fd_fifo_tryget(queue, &msg) ); 179 179 CHECK( msg3, msg); 180 CHECK( 0, fd_ mq_length(queue, &count) );180 CHECK( 0, fd_fifo_length(queue, &count) ); 181 181 CHECK( 0, count); 182 182 183 183 /* Check that another meq_tryget does not block */ 184 CHECK( EWOULDBLOCK, fd_ mq_tryget(queue, &msg) );185 CHECK( 0, fd_ mq_length(queue, &count) );184 CHECK( EWOULDBLOCK, fd_fifo_tryget(queue, &msg) ); 185 CHECK( 0, fd_fifo_length(queue, &count) ); 186 186 CHECK( 0, count); 187 187 188 188 /* We're done for basic tests */ 189 CHECK( 0, fd_ mq_del(&queue) );189 CHECK( 0, fd_fifo_del(&queue) ); 190 190 } 191 191 … … 194 194 #define NBR_MSG 200 195 195 #define NBR_THREADS 60 196 struct mqueue*queue = NULL;196 struct fifo *queue = NULL; 197 197 pthread_barrier_t bar; 198 198 struct test_data td_1; … … 205 205 206 206 /* Create the queue */ 207 CHECK( 0, fd_ mq_new(&queue) );207 CHECK( 0, fd_fifo_new(&queue) ); 208 208 209 209 /* Create the barrier */ … … 215 215 216 216 /* Create the messages */ 217 CHECK( 0, fd_dict_search ( fd_g_ dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) );217 CHECK( 0, fd_dict_search ( fd_g_config->g_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) ); 218 218 for (i = 0; i < NBR_MSG * NBR_THREADS * 2; i++) { 219 219 CHECK( 0, fd_msg_new ( dwr_model, 0, &msgs[i] ) ); … … 248 248 for (i=0; i < NBR_MSG * NBR_THREADS * 2; i++) { 249 249 msg = msgs[i]; 250 CHECK( 0, fd_ mq_post(queue, &msg) );250 CHECK( 0, fd_fifo_post(queue, &msg) ); 251 251 } 252 252 … … 257 257 258 258 /* Check the count of the queue is back to 0 */ 259 CHECK( 0, fd_ mq_length(queue, &count) );259 CHECK( 0, fd_fifo_length(queue, &count) ); 260 260 CHECK( 0, count); 261 261 262 262 /* Destroy this queue and the messages */ 263 CHECK( 0, fd_ mq_del(&queue) );263 CHECK( 0, fd_fifo_del(&queue) ); 264 264 for (i=0; i < NBR_MSG * NBR_THREADS * 2; i++) { 265 265 CHECK( 0, fd_msg_free( msgs[i] ) ); … … 269 269 /* Test thread cancelation */ 270 270 { 271 struct mqueue*queue = NULL;271 struct fifo *queue = NULL; 272 272 pthread_barrier_t bar; 273 273 struct test_data td; … … 275 275 276 276 /* Create the queue */ 277 CHECK( 0, fd_ mq_new(&queue) );277 CHECK( 0, fd_fifo_new(&queue) ); 278 278 279 279 /* Create the barrier */ … … 332 332 333 333 /* Destroy the queue */ 334 CHECK( 0, fd_ mq_del(&queue) );334 CHECK( 0, fd_fifo_del(&queue) ); 335 335 } 336 336 337 337 /* Test the threashold function */ 338 338 { 339 struct mqueue* queue = NULL;339 struct fifo * queue = NULL; 340 340 int i; 341 341 struct msg * msg = NULL; 342 342 343 343 /* Create the queue */ 344 CHECK( 0, fd_ mq_new(&queue) );344 CHECK( 0, fd_fifo_new(&queue) ); 345 345 346 346 /* Prepare the test data */ … … 349 349 350 350 /* Set the thresholds for the queue */ 351 CHECK( 0, fd_ mq_setthrhd ( queue, NULL, 6, thrh_cb_h, 4, thrh_cb_l ) );351 CHECK( 0, fd_fifo_setthrhd ( queue, NULL, 6, thrh_cb_h, 4, thrh_cb_l ) ); 352 352 353 353 /* Post 5 messages, no cb must be called. */ 354 354 for (i=0; i<5; i++) { 355 355 msg = msg1; 356 CHECK( 0, fd_ mq_post(queue, &msg) );356 CHECK( 0, fd_fifo_post(queue, &msg) ); 357 357 } /* 5 msg in queue */ 358 358 CHECK( 0, thrh_td.h_calls ); … … 361 361 /* Get all these messages, and check again */ 362 362 for (i=0; i<5; i++) { 363 CHECK( 0, fd_ mq_get(queue, &msg) );363 CHECK( 0, fd_fifo_get(queue, &msg) ); 364 364 } /* 0 msg in queue */ 365 365 CHECK( 0, thrh_td.h_calls ); … … 369 369 for (i=0; i<6; i++) { 370 370 msg = msg1; 371 CHECK( 0, fd_ mq_post(queue, &msg) );371 CHECK( 0, fd_fifo_post(queue, &msg) ); 372 372 } /* 6 msg in queue */ 373 373 CHECK( 1, thrh_td.h_calls ); … … 376 376 /* Remove 2 messages, to reach the low threshold */ 377 377 for (i=0; i<2; i++) { 378 CHECK( 0, fd_ mq_get(queue, &msg) );378 CHECK( 0, fd_fifo_get(queue, &msg) ); 379 379 } /* 4 msg in queue */ 380 380 CHECK( 1, thrh_td.h_calls ); … … 384 384 for (i=0; i<2; i++) { 385 385 msg = msg1; 386 CHECK( 0, fd_ mq_post(queue, &msg) );386 CHECK( 0, fd_fifo_post(queue, &msg) ); 387 387 } /* 6 msg in queue */ 388 388 CHECK( 2, thrh_td.h_calls ); … … 392 392 for (i=0; i<6; i++) { 393 393 msg = msg1; 394 CHECK( 0, fd_ mq_post(queue, &msg) );394 CHECK( 0, fd_fifo_post(queue, &msg) ); 395 395 } /* 12 msg in queue */ 396 396 CHECK( 3, thrh_td.h_calls ); … … 398 398 for (i=0; i<5; i++) { 399 399 msg = msg1; 400 CHECK( 0, fd_ mq_post(queue, &msg) );400 CHECK( 0, fd_fifo_post(queue, &msg) ); 401 401 } /* 17 msg in queue */ 402 402 CHECK( 3, thrh_td.h_calls ); … … 405 405 /* Now the queue goes back to 0 messages */ 406 406 for (i=0; i<17; i++) { 407 CHECK( 0, fd_ mq_get(queue, &msg) );407 CHECK( 0, fd_fifo_get(queue, &msg) ); 408 408 } /* 0 msg in queue */ 409 409 CHECK( 3, thrh_td.h_calls ); … … 411 411 412 412 /* We're done for this test */ 413 CHECK( 0, fd_ mq_del(&queue) );413 CHECK( 0, fd_fifo_del(&queue) ); 414 414 } 415 415 -
freeDiameter/tests/tests.h
r3 r8 75 75 76 76 static int test_verbo = 0; 77 static struct fd_config conf; 78 struct fd_config * fd_g_config = &conf; 77 79 78 80 /* Define the standard check routines */ … … 97 99 98 100 /* Minimum inits */ 99 #define INIT_FD() { \ 100 CHECK( 0, fd_lib_init() ); \ 101 fd_log_threadname(basename(__FILE__)); \ 102 CHECK( 0, fd_dict_init(&fd_g_dict) ); \ 103 CHECK( 0, fd_dict_base_protocol(fd_g_dict) ); \ 104 parse_cmdline(argc, argv); \ 101 #define INIT_FD() { \ 102 memset(fd_g_config, 0, sizeof(struct fd_config)); \ 103 CHECK( 0, fd_lib_init() ); \ 104 fd_log_threadname(basename(__FILE__)); \ 105 CHECK( 0, fd_conf_init() ); \ 106 CHECK( 0, fd_dict_base_protocol(fd_g_config->g_dict) ); \ 107 parse_cmdline(argc, argv); \ 105 108 } 106 109 -
include/freeDiameter/CMakeLists.txt
r1 r8 72 72 CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H) 73 73 74 # signalent.h ? -- found in strace distrib; just for nice signal names... 75 CHECK_INCLUDE_FILES (signalent.h HAVE_SIGNALENT_H) 76 74 77 # The default configuration file name 75 78 IF (NOT DEFAULT_CONF_FILE) -
include/freeDiameter/freeDiameter-host.h.in
r1 r8 40 40 #cmakedefine HAVE_NTOHLL 41 41 #cmakedefine HAVE_MALLOC_H 42 #cmakedefine HAVE_SIGNALENT_H 42 43 43 44 #cmakedefine HOST_BIG_ENDIAN @HOST_BIG_ENDIAN@ … … 45 46 #cmakedefine DISABLE_SCTP 46 47 47 #cmakedefine PROJECT_NAME "@PROJECT_NAME@" 48 #cmakedefine CMAKE_PROJECT_NAME "@CMAKE_PROJECT_NAME@" 49 #cmakedefine PROJECT_VERSION "@PROJECT_VERSION@" 50 #cmakedefine PROJECT_COPYRIGHT "@PROJECT_COPYRIGHT@" 48 #cmakedefine FD_PROJECT_BINARY "@FD_PROJECT_BINARY@" 49 #cmakedefine FD_PROJECT_NAME "@FD_PROJECT_NAME@" 50 #cmakedefine FD_PROJECT_VERSION_MAJOR @FD_PROJECT_VERSION_MAJOR@ 51 #ifndef FD_PROJECT_VERSION_MAJOR 52 # define FD_PROJECT_VERSION_MAJOR 0 53 #endif /*FD_PROJECT_VERSION_MAJOR*/ 54 #cmakedefine FD_PROJECT_VERSION_MINOR @FD_PROJECT_VERSION_MINOR@ 55 #ifndef FD_PROJECT_VERSION_MINOR 56 # define FD_PROJECT_VERSION_MINOR 0 57 #endif /*FD_PROJECT_VERSION_MINOR*/ 58 #cmakedefine FD_PROJECT_VERSION_REV @FD_PROJECT_VERSION_REV@ 59 #ifndef FD_PROJECT_VERSION_REV 60 # define FD_PROJECT_VERSION_REV 0 61 #endif /*FD_PROJECT_VERSION_REV*/ 62 /* HG_VERSION */ 63 /* PACKAGE_HG_REVISION */ 64 #cmakedefine FD_PROJECT_COPYRIGHT "@FD_PROJECT_COPYRIGHT@" 51 65 52 66 #cmakedefine DEFAULT_CONF_FILE "@DEFAULT_CONF_FILE@" 53 67 68 54 69 #endif /* FD_IS_CONFIG */ -
include/freeDiameter/freeDiameter.h
r7 r8 41 41 42 42 43 /* The global dictionary */ 44 extern struct dictionary * fd_g_dict; 45 43 /* Structure to hold the configuration of the freeDiameter daemon */ 44 struct fd_config { 45 int eyec; /* Eye catcher: EYEC_CONFIG */ 46 char *conf_file; /* Configuration file to parse, default is DEFAULT_CONF_FILE */ 47 48 char *diam_id; /* Diameter Identity of the local peer (FQDN -- UTF-8) */ 49 size_t diam_id_len; /* length of the previous string */ 50 char *diam_realm; /* Diameter realm of the local peer, default to realm part of diam_id */ 51 size_t diam_realm_len;/* length of the previous string */ 52 53 uint16_t loc_port; /* the local port for legacy Diameter (default: 3868) in host byte order */ 54 uint16_t loc_port_tls; /* the local port for Diameter/TLS (default: 3869) in host byte order */ 55 uint16_t loc_sctp_str; /* default max number of streams for SCTP associations (def: 30) */ 56 struct fd_list loc_endpoints; /* the local endpoints to bind the server to. list of struct fd_endpoint. default is empty (bind all) */ 57 struct { 58 unsigned no_ip4 : 1; /* disable IP */ 59 unsigned no_ip6 : 1; /* disable IPv6 */ 60 unsigned no_tcp : 1; /* disable use of TCP */ 61 unsigned no_sctp: 1; /* disable the use of SCTP */ 62 unsigned pr_tcp : 1; /* prefer TCP over SCTP */ 63 unsigned tls_alg: 1; /* TLS algorithm for initiated cnx. 0: separate port. 1: inband-security (old) */ 64 unsigned no_fwd : 1; /* the peer does not relay messages (0xffffff app id) */ 65 } flags; 66 67 unsigned int timer_tc; /* The value in seconds of the default Tc timer */ 68 unsigned int timer_tw; /* The value in seconds of the default Tw timer */ 69 70 uint32_t or_state_id; /* The value to use in Origin-State-Id, default to random value */ 71 struct dictionary *g_dict; /* pointer to the global dictionary */ 72 struct fifo *g_fifo_main; /* FIFO queue of events in the daemon main (struct fd_event items) */ 73 }; 74 75 #define EYEC_CONFIG 0xC011F16 76 77 /* The pointer to access the global configuration, initalized in main */ 78 extern struct fd_config *fd_g_config; 79 80 /* Endpoints */ 81 struct fd_endpoint { 82 struct fd_list chain; /* link in loc_endpoints list */ 83 sSS ss; /* the socket information. */ 84 }; 85 86 /* Events */ 87 struct fd_event { 88 int code; /* codespace depends on the queue */ 89 void *data; 90 }; 91 92 /* send an event */ 93 static __inline__ int fd_event_send(struct fifo *queue, int code, void * data) 94 { 95 struct fd_event * ev; 96 CHECK_MALLOC( ev = malloc(sizeof(struct fd_event)) ); 97 ev->code = code; 98 ev->data = data; 99 CHECK_FCT( fd_fifo_post(queue, &ev) ); 100 return 0; 101 } 102 /* receive an event */ 103 static __inline__ int fd_event_get(struct fifo *queue, int *code, void ** data) 104 { 105 struct fd_event * ev; 106 CHECK_FCT( fd_fifo_get(queue, &ev) ); 107 if (code) 108 *code = ev->code; 109 if (data) 110 *data = ev->data; 111 free(ev); 112 return 0; 113 } 46 114 47 115 /***************************************/ -
include/freeDiameter/libfreeDiameter.h
r7 r8 37 37 * 38 38 * This library is meant to be used by both the freeDiameter daemon and its extensions. 39 *40 39 * It provides the tools to manipulate Diameter messages and related data. 41 *42 40 * This file should always be included as #include <freeDiameter/libfreeDiameter.h> 41 * 42 * The file contains the following parts: 43 * DEBUG 44 * MACROS 45 * THREADS 46 * LISTS 47 * DICTIONARY 48 * SESSIONS 49 * MESSAGES 50 * DISPATCH 51 * QUEUES 43 52 */ 44 53 … … 297 306 #define sSA6 struct sockaddr_in6 298 307 299 /* Dump one sockaddr */300 #define sSA_DUMP ( level, text, sa) { \308 /* Dump one sockaddr Node information */ 309 #define sSA_DUMP_NODE( sa, flag ) { \ 301 310 sSA * __sa = (sSA *)(sa); \ 302 char *__str, __addrbuf[INET6_ADDRSTRLEN];\311 char __addrbuf[INET6_ADDRSTRLEN]; \ 303 312 if (__sa) { \ 304 313 int __rc = getnameinfo(__sa, \ … … 308 317 NULL, \ 309 318 0, \ 310 0); \319 flag); \ 311 320 if (__rc) \ 312 __str = (char *)gai_strerror(__rc);\321 fd_log_debug((char *)gai_strerror(__rc)); \ 313 322 else \ 314 __str = &__addrbuf[0];\323 fd_log_debug(&__addrbuf[0]); \ 315 324 } else { \ 316 __str = "(NULL / ANY)";\325 fd_log_debug("(NULL / ANY)"); \ 317 326 } \ 318 TRACE_DEBUG(level, text "%s", __str); \319 327 } 328 /* if needed, add sSA_DUMP_SERVICE */ 320 329 321 330 /* The sockaddr length of a sSS structure */ … … 2275 2284 2276 2285 /*============================================================*/ 2277 /* MESSAGE QUEUES*/2286 /* QUEUES */ 2278 2287 /*============================================================*/ 2279 2288 2280 /* Management of queues of messages */2281 2282 /* A messagequeue is an opaque object */2283 struct mqueue;2284 2285 /* 2286 * FUNCTION: fd_ mq_new2287 * 2288 * PARAMETERS: 2289 * queue : Upon success, a pointer to the new messagequeue is saved here.2290 * 2291 * DESCRIPTION: 2292 * Create a new empty messagequeue.2289 /* Management of FIFO queues of elements */ 2290 2291 /* A queue is an opaque object */ 2292 struct fifo; 2293 2294 /* 2295 * FUNCTION: fd_fifo_new 2296 * 2297 * PARAMETERS: 2298 * queue : Upon success, a pointer to the new queue is saved here. 2299 * 2300 * DESCRIPTION: 2301 * Create a new empty queue. 2293 2302 * 2294 2303 * RETURN VALUE : 2295 * 0 : The messagequeue has been initialized successfully.2304 * 0 : The queue has been initialized successfully. 2296 2305 * EINVAL : The parameter is invalid. 2297 2306 * ENOMEM : Not enough memory to complete the creation. 2298 2307 */ 2299 int fd_ mq_new ( struct mqueue** queue );2300 2301 /* 2302 * FUNCTION: fd_ mq_del2303 * 2304 * PARAMETERS: 2305 * queue : Pointer to an empty messagequeue to delete.2306 * 2307 * DESCRIPTION: 2308 * Destroys a message queue. This is only possible if no thread is waiting for a message,2308 int fd_fifo_new ( struct fifo ** queue ); 2309 2310 /* 2311 * FUNCTION: fd_fifo_del 2312 * 2313 * PARAMETERS: 2314 * queue : Pointer to an empty queue to delete. 2315 * 2316 * DESCRIPTION: 2317 * Destroys a queue. This is only possible if no thread is waiting for an element, 2309 2318 * and the queue is empty. 2310 2319 * 2311 2320 * RETURN VALUE: 2312 * 0 : The messagequeue has been destroyed successfully.2321 * 0 : The queue has been destroyed successfully. 2313 2322 * EINVAL : The parameter is invalid. 2314 2323 */ 2315 int fd_ mq_del ( struct mqueue** queue );2316 2317 /* 2318 * FUNCTION: fd_ mq_length2319 * 2320 * PARAMETERS: 2321 * queue : The queue from which to retrieve the length.2322 * length : Upon success, the current number of messages in the queue is stored here.2323 * 2324 * DESCRIPTION: 2325 * Retrieve the number of messages pendingin a queue.2324 int fd_fifo_del ( struct fifo ** queue ); 2325 2326 /* 2327 * FUNCTION: fd_fifo_length 2328 * 2329 * PARAMETERS: 2330 * queue : The queue from which to retrieve the number of elements. 2331 * length : Upon success, the current number of elements in the queue is stored here. 2332 * 2333 * DESCRIPTION: 2334 * Retrieve the number of elements in a queue. 2326 2335 * 2327 2336 * RETURN VALUE: … … 2329 2338 * EINVAL : A parameter is invalid. 2330 2339 */ 2331 int fd_ mq_length ( struct mqueue* queue, int * length );2332 int fd_ mq_length_noerr ( struct mqueue * queue ); /* alternate with no error checking*/2333 2334 /* 2335 * FUNCTION: fd_ mq_setthrhd2340 int fd_fifo_length ( struct fifo * queue, int * length ); 2341 int fd_fifo_length_noerr ( struct fifo * queue ); /* no error checking version */ 2342 2343 /* 2344 * FUNCTION: fd_fifo_setthrhd 2336 2345 * 2337 2346 * PARAMETERS: … … 2345 2354 * DESCRIPTION: 2346 2355 * This function allows to adjust the number of producer / consumer threads of a queue. 2347 * If the consumer are slower than the producers, the number of messages in the queue increase.2356 * If the consumer are slower than the producers, the number of elements in the queue increase. 2348 2357 * By setting a "high" value, we allow a callback to be called when this number is too high. 2349 2358 * The typical use would be to create an additional consumer thread in this callback. 2350 2359 * If the queue continues to grow, the callback will be called again when the length is 2 * high, then 3*high, ... N * high 2351 * (the callback itself mayimplement a limit on the number of consumers that can be created)2360 * (the callback itself should implement a limit on the number of consumers that can be created) 2352 2361 * When the queue starts to decrease, and the number of elements go under ((N - 1) * high + low, the l_cb callback is called 2353 * and would typially stop one of the consumer threads. If the queue continue to reduce, l_cb is again called at (N-2)*high + low,2362 * and would typially stop one of the consumer threads. If the queue continues to reduce, l_cb is again called at (N-2)*high + low, 2354 2363 * and so on. 2355 2364 * … … 2357 2366 * l_cb when the length of the queue is becoming < low. 2358 2367 * 2359 * Note that the callbacks are called synchronously, during fd_ mq_post or fd_mq_get. Their operation should be quick.2368 * Note that the callbacks are called synchronously, during fd_fifo_post or fd_fifo_get. Their operation should be quick. 2360 2369 * 2361 2370 * RETURN VALUE: … … 2363 2372 * EINVAL : A parameter is invalid. 2364 2373 */ 2365 int fd_ mq_setthrhd ( struct mqueue * queue, void * data, uint16_t high, void (*h_cb)(struct mqueue *, void **), uint16_t low, void (*l_cb)(struct mqueue*, void **) );2366 2367 /* 2368 * FUNCTION: fd_ mq_post2369 * 2370 * PARAMETERS: 2371 * queue : The queue in which the messagemust be posted.2372 * msg : The messagethat is put in the queue.2373 * 2374 * DESCRIPTION: 2375 * A message is added in a queue. Messages are retrieved from the queue (in FIFO order)2376 * with the fd_ mq_get, fd_mq_tryget, or fd_mq_timedget functions.2377 * 2378 * RETURN VALUE: 2379 * 0 : The messageis queued.2374 int fd_fifo_setthrhd ( struct fifo * queue, void * data, uint16_t high, void (*h_cb)(struct fifo *, void **), uint16_t low, void (*l_cb)(struct fifo *, void **) ); 2375 2376 /* 2377 * FUNCTION: fd_fifo_post 2378 * 2379 * PARAMETERS: 2380 * queue : The queue in which the element must be posted. 2381 * item : The element that is put in the queue. 2382 * 2383 * DESCRIPTION: 2384 * An element is added in a queue. Elements are retrieved from the queue in FIFO order 2385 * with the fd_fifo_get, fd_fifo_tryget, or fd_fifo_timedget functions. 2386 * 2387 * RETURN VALUE: 2388 * 0 : The element is queued. 2380 2389 * EINVAL : A parameter is invalid. 2381 2390 * ENOMEM : Not enough memory to complete the operation. 2382 2391 */ 2383 int fd_mq_post ( struct mqueue * queue, struct msg ** msg ); 2384 2385 /* 2386 * FUNCTION: fd_mq_get 2387 * 2388 * PARAMETERS: 2389 * queue : The queue from which the message must be retrieved. 2390 * msg : On return, the first message of the queue is stored here. 2391 * 2392 * DESCRIPTION: 2393 * This function retrieves a message from a queue. If the queue is empty, the function will block the 2394 * thread until a new message is posted to the queue, or until the thread is canceled (in which case the 2392 int fd_fifo_post_int ( struct fifo * queue, void ** item ); 2393 #define fd_fifo_post(queue, item) \ 2394 fd_fifo_post_int((queue), (void *)(item)) 2395 2396 /* 2397 * FUNCTION: fd_fifo_get 2398 * 2399 * PARAMETERS: 2400 * queue : The queue from which the first element must be retrieved. 2401 * item : On return, the first element of the queue is stored here. 2402 * 2403 * DESCRIPTION: 2404 * This function retrieves the first element from a queue. If the queue is empty, the function will block the 2405 * thread until a new element is posted to the queue, or until the thread is canceled (in which case the 2395 2406 * function does not return). 2396 2407 * 2397 2408 * RETURN VALUE: 2398 * 0 : A new message has been retrieved. 2399 * EINVAL : A parameter is invalid. 2400 */ 2401 int fd_mq_get ( struct mqueue * queue, struct msg ** msg ); 2402 2403 /* 2404 * FUNCTION: fd_mq_tryget 2405 * 2406 * PARAMETERS: 2407 * queue : The queue from which the message must be retrieved. 2409 * 0 : A new element has been retrieved. 2410 * EINVAL : A parameter is invalid. 2411 */ 2412 int fd_fifo_get_int ( struct fifo * queue, void ** item ); 2413 #define fd_fifo_get(queue, item) \ 2414 fd_fifo_get_int((queue), (void *)(item)) 2415 2416 /* 2417 * FUNCTION: fd_fifo_tryget 2418 * 2419 * PARAMETERS: 2420 * queue : The queue from which the element must be retrieved. 2408 2421 * msg : On return, the message is stored here. 2409 2422 * 2410 2423 * DESCRIPTION: 2411 * This function is similar to fd_ mq_get, except that it will not block if2424 * This function is similar to fd_fifo_get, except that it will not block if 2412 2425 * the queue is empty, but return EWOULDBLOCK instead. 2413 2426 * 2414 2427 * RETURN VALUE: 2415 * 0 : A new messagehas been retrieved.2428 * 0 : A new element has been retrieved. 2416 2429 * EINVAL : A parameter is invalid. 2417 2430 * EWOULDBLOCK : The queue was empty. 2418 2431 */ 2419 int fd_mq_tryget ( struct mqueue * queue, struct msg ** msg ); 2420 2421 /* 2422 * FUNCTION: fd_mq_timedget 2423 * 2424 * PARAMETERS: 2425 * queue : The queue from which the message must be retrieved. 2426 * msg : On return, the message is stored here. 2427 * abstime : the absolute time until which we allow waiting for a message. 2428 * 2429 * DESCRIPTION: 2430 * This function is similar to fd_mq_get, except that it will block if the queue is empty 2432 int fd_fifo_tryget_int ( struct fifo * queue, void ** item ); 2433 #define fd_fifo_tryget(queue, item) \ 2434 fd_fifo_tryget_int((queue), (void *)(item)) 2435 2436 /* 2437 * FUNCTION: fd_fifo_timedget 2438 * 2439 * PARAMETERS: 2440 * queue : The queue from which the element must be retrieved. 2441 * item : On return, the element is stored here. 2442 * abstime : the absolute time until which we allow waiting for an item. 2443 * 2444 * DESCRIPTION: 2445 * This function is similar to fd_fifo_get, except that it will block if the queue is empty 2431 2446 * only until the absolute time abstime (see pthread_cond_timedwait for + info). 2432 2447 * If the queue is still empty when the time expires, the function returns ETIMEDOUT 2433 2448 * 2434 2449 * RETURN VALUE: 2435 * 0 : A new message has been retrieved. 2436 * EINVAL : A parameter is invalid. 2437 * ETIMEDOUT : The time out has passed and no message has been received. 2438 */ 2439 int fd_mq_timedget ( struct mqueue * queue, struct msg ** msg, const struct timespec *abstime ); 2450 * 0 : A new item has been retrieved. 2451 * EINVAL : A parameter is invalid. 2452 * ETIMEDOUT : The time out has passed and no item has been received. 2453 */ 2454 int fd_fifo_timedget_int ( struct fifo * queue, void ** item, const struct timespec *abstime ); 2455 #define fd_fifo_timedget(queue, item, abstime) \ 2456 fd_fifo_timedget_int((queue), (void *)(item), (abstime)) 2440 2457 2441 2458 #endif /* _LIBFREEDIAMETER_H */ -
libfreeDiameter/CMakeLists.txt
r7 r8 1 1 # Name of the subproject 2 2 Project("libfreeDiameter" C) 3 4 SET(PROJECT_COPYRIGHT "Copyright (c) 2008-2009, WIDE Project (www.wide.ad.jp) and NICT (www.nict.go.jp)")5 3 6 4 # List of source files for the library … … 13 11 log.c 14 12 messages.c 15 mqueues.c13 queues.c 16 14 sessions.c 17 15 ) -
libfreeDiameter/queues.c
r1 r8 34 34 *********************************************************************************************************/ 35 35 36 /* Messagesqueues module.36 /* FIFO queues module. 37 37 * 38 38 * The threads that call these functions must be in the cancellation state PTHREAD_CANCEL_ENABLE and type PTHREAD_CANCEL_DEFERRED. … … 42 42 * -> shutdown any process that can add into the queue first. 43 43 * -> pthread_cancel any thread that could be waiting on the queue. 44 * -> consume any message that is in the queue, using meq_tryget.45 * -> then destroy the queue using meq_del.44 * -> consume any element that is in the queue, using fd_qu_tryget_int. 45 * -> then destroy the queue using fd_mq_del. 46 46 */ 47 47 48 48 #include "libfD.h" 49 49 50 /* Definition of a messagequeue object */51 struct mqueue{52 int eyec; /* An eye catcher, also used to check a queue is valid. MQ_EYEC */50 /* Definition of a FIFO queue object */ 51 struct fifo { 52 int eyec; /* An eye catcher, also used to check a queue is valid. FIFO_EYEC */ 53 53 54 54 pthread_mutex_t mtx; /* Mutex protecting this queue */ 55 55 pthread_cond_t cond; /* condition variable of the list */ 56 56 57 struct fd_list list; /* sentinel for the list of messages */57 struct fd_list list; /* sentinel for the list of elements */ 58 58 int count; /* number of objects in the list */ 59 int thrs; /* number of threads waiting for a new message(when count is 0) */59 int thrs; /* number of threads waiting for a new element (when count is 0) */ 60 60 61 61 uint16_t high; /* High level threshold (see libfreeDiameter.h for details) */ 62 62 uint16_t low; /* Low level threshhold */ 63 63 void *data; /* Opaque pointer for threshold callbacks */ 64 void (*h_cb)(struct mqueue*, void **); /* The callbacks */65 void (*l_cb)(struct mqueue*, void **);64 void (*h_cb)(struct fifo *, void **); /* The callbacks */ 65 void (*l_cb)(struct fifo *, void **); 66 66 int highest;/* The highest count value for which h_cb has been called */ 67 67 }; 68 68 69 69 /* The eye catcher value */ 70 #define MQ_EYEC 0xe7ec113070 #define FIFO_EYEC 0xe7ec1130 71 71 72 72 /* Macro to check a pointer */ 73 #define CHECK_ QUEUE( _queue ) (( (_queue) != NULL) && ( (_queue)->eyec == MQ_EYEC) )74 75 76 /* Create a new messagequeue */77 int fd_ mq_new ( struct mqueue** queue )78 { 79 struct mqueue* new;73 #define CHECK_FIFO( _queue ) (( (_queue) != NULL) && ( (_queue)->eyec == FIFO_EYEC) ) 74 75 76 /* Create a new queue */ 77 int fd_fifo_new ( struct fifo ** queue ) 78 { 79 struct fifo * new; 80 80 81 81 TRACE_ENTRY( "%p", queue ); … … 84 84 85 85 /* Create a new object */ 86 CHECK_MALLOC( new = malloc (sizeof (struct mqueue) ) );86 CHECK_MALLOC( new = malloc (sizeof (struct fifo) ) ); 87 87 88 88 /* Initialize the content */ 89 memset(new, 0, sizeof(struct mqueue));90 91 new->eyec = MQ_EYEC;89 memset(new, 0, sizeof(struct fifo)); 90 91 new->eyec = FIFO_EYEC; 92 92 CHECK_POSIX( pthread_mutex_init(&new->mtx, NULL) ); 93 93 CHECK_POSIX( pthread_cond_init(&new->cond, NULL) ); … … 100 100 } 101 101 102 /* Delete a messagequeue. It must be unused. */103 int fd_ mq_del ( struct mqueue** queue )104 { 105 struct mqueue* q;102 /* Delete a queue. It must be unused. */ 103 int fd_fifo_del ( struct fifo ** queue ) 104 { 105 struct fifo * q; 106 106 107 107 TRACE_ENTRY( "%p", queue ); 108 108 109 CHECK_PARAMS( queue && CHECK_ QUEUE( *queue ) );109 CHECK_PARAMS( queue && CHECK_FIFO( *queue ) ); 110 110 111 111 q = *queue; … … 139 139 140 140 /* Get the length of the queue */ 141 int fd_ mq_length ( struct mqueue* queue, int * length )141 int fd_fifo_length ( struct fifo * queue, int * length ) 142 142 { 143 143 TRACE_ENTRY( "%p %p", queue, length ); 144 144 145 145 /* Check the parameters */ 146 CHECK_PARAMS( CHECK_ QUEUE( queue ) && length );146 CHECK_PARAMS( CHECK_FIFO( queue ) && length ); 147 147 148 148 /* lock the queue */ … … 160 160 161 161 /* alternate version with no error checking */ 162 int fd_ mq_length_noerr ( struct mqueue* queue )163 { 164 if ( !CHECK_ QUEUE( queue ) )162 int fd_fifo_length_noerr ( struct fifo * queue ) 163 { 164 if ( !CHECK_FIFO( queue ) ) 165 165 return 0; 166 166 … … 169 169 170 170 /* Set the thresholds of the queue */ 171 int fd_ mq_setthrhd ( struct mqueue * queue, void * data, uint16_t high, void (*h_cb)(struct mqueue *, void **), uint16_t low, void (*l_cb)(struct mqueue*, void **) )171 int fd_fifo_setthrhd ( struct fifo * queue, void * data, uint16_t high, void (*h_cb)(struct fifo *, void **), uint16_t low, void (*l_cb)(struct fifo *, void **) ) 172 172 { 173 173 TRACE_ENTRY( "%p %p %hu %p %hu %p", queue, data, high, h_cb, low, l_cb ); 174 174 175 175 /* Check the parameters */ 176 CHECK_PARAMS( CHECK_ QUEUE( queue ) && (high > low) && (queue->data == NULL) );176 CHECK_PARAMS( CHECK_FIFO( queue ) && (high > low) && (queue->data == NULL) ); 177 177 178 178 /* lock the queue */ … … 193 193 } 194 194 195 /* Post a new messagein the queue */196 int fd_ mq_post ( struct mqueue * queue, struct msg ** msg)195 /* Post a new item in the queue */ 196 int fd_fifo_post_int ( struct fifo * queue, void ** item ) 197 197 { 198 198 struct fd_list * new; 199 199 int call_cb = 0; 200 200 201 TRACE_ENTRY( "%p %p", queue, msg);202 203 /* Check the parameters */ 204 CHECK_PARAMS( CHECK_ QUEUE( queue ) && msg && *msg);201 TRACE_ENTRY( "%p %p", queue, item ); 202 203 /* Check the parameters */ 204 CHECK_PARAMS( CHECK_FIFO( queue ) && item && *item ); 205 205 206 206 /* Create a new list item */ 207 207 CHECK_MALLOC( new = malloc (sizeof (struct fd_list)) ); 208 208 209 fd_list_init(new, * msg);210 * msg= NULL;211 212 /* lock the queue */ 213 CHECK_POSIX( pthread_mutex_lock( &queue->mtx ) ); 214 215 /* Add the new messageat the end */209 fd_list_init(new, *item); 210 *item = NULL; 211 212 /* lock the queue */ 213 CHECK_POSIX( pthread_mutex_lock( &queue->mtx ) ); 214 215 /* Add the new item at the end */ 216 216 fd_list_insert_before( &queue->list, new); 217 217 queue->count++; … … 237 237 } 238 238 239 /* Pop the first messagefrom the queue */240 static struct msg * mq_pop(struct mqueue* queue)241 { 242 struct msg* ret = NULL;239 /* Pop the first item from the queue */ 240 static void * mq_pop(struct fifo * queue) 241 { 242 void * ret = NULL; 243 243 struct fd_list * li; 244 244 … … 247 247 fd_list_unlink(li = queue->list.next); 248 248 queue->count--; 249 ret = (struct msg *)(li->o);249 ret = li->o; 250 250 free(li); 251 251 … … 254 254 255 255 /* Check if the low watermark callback must be called. */ 256 static int test_l_cb(struct mqueue* queue)256 static __inline__ int test_l_cb(struct fifo * queue) 257 257 { 258 258 if ((queue->high == 0) || (queue->low == 0) || (queue->l_cb == 0)) … … 267 267 } 268 268 269 /* Try poping a message*/270 int fd_ mq_tryget ( struct mqueue * queue, struct msg ** msg)269 /* Try poping an item */ 270 int fd_fifo_tryget_int ( struct fifo * queue, void ** item ) 271 271 { 272 272 int wouldblock = 0; 273 273 int call_cb = 0; 274 274 275 TRACE_ENTRY( "%p %p", queue, msg);276 277 /* Check the parameters */ 278 CHECK_PARAMS( CHECK_ QUEUE( queue ) && msg);275 TRACE_ENTRY( "%p %p", queue, item ); 276 277 /* Check the parameters */ 278 CHECK_PARAMS( CHECK_FIFO( queue ) && item ); 279 279 280 280 /* lock the queue */ … … 283 283 /* Check queue status */ 284 284 if (queue->count > 0) { 285 /* There are messages in the queue, so pick the first one */286 * msg= mq_pop(queue);285 /* There are elements in the queue, so pick the first one */ 286 *item = mq_pop(queue); 287 287 call_cb = test_l_cb(queue); 288 288 } else { 289 289 wouldblock = 1; 290 * msg= NULL;290 *item = NULL; 291 291 } 292 292 … … 303 303 304 304 /* This handler is called when a thread is blocked on a queue, and cancelled */ 305 static void mq_cleanup(void * queue)306 { 307 struct mqueue * q = (struct mqueue*)queue;305 static void fifo_cleanup(void * queue) 306 { 307 struct fifo * q = (struct fifo *)queue; 308 308 TRACE_ENTRY( "%p", queue ); 309 309 310 310 /* Check the parameter */ 311 if ( ! CHECK_ QUEUE( q )) {311 if ( ! CHECK_FIFO( q )) { 312 312 TRACE_DEBUG(INFO, "Invalid queue, skipping handler"); 313 313 return; … … 324 324 } 325 325 326 /* The internal function for meq_timedget and meq_get */327 static int mq_tget ( struct mqueue * queue, struct msg ** msg, int istimed, const struct timespec *abstime)326 /* The internal function for fd_fifo_timedget and fd_fifo_get */ 327 static int fifo_tget ( struct fifo * queue, void ** item, int istimed, const struct timespec *abstime) 328 328 { 329 329 int timedout = 0; … … 331 331 332 332 /* Check the parameters */ 333 CHECK_PARAMS( CHECK_ QUEUE( queue ) && msg&& (abstime || !istimed) );334 335 /* Initialize the msgvalue */336 * msg= NULL;333 CHECK_PARAMS( CHECK_FIFO( queue ) && item && (abstime || !istimed) ); 334 335 /* Initialize the return value */ 336 *item = NULL; 337 337 338 338 /* lock the queue */ … … 342 342 /* Check queue status */ 343 343 if (queue->count > 0) { 344 /* There are messages in the queue, so pick the first one */345 * msg= mq_pop(queue);344 /* There are items in the queue, so pick the first one */ 345 *item = mq_pop(queue); 346 346 call_cb = test_l_cb(queue); 347 347 } else { 348 348 int ret = 0; 349 /* We have to wait for a new message*/349 /* We have to wait for a new item */ 350 350 queue->thrs++ ; 351 pthread_cleanup_push( mq_cleanup, queue);351 pthread_cleanup_push( fifo_cleanup, queue); 352 352 if (istimed) { 353 353 ret = pthread_cond_timedwait( &queue->cond, &queue->mtx, abstime ); … … 379 379 } 380 380 381 /* Get the next available message, block until there is one */382 int fd_ mq_get ( struct mqueue * queue, struct msg ** msg)383 { 384 TRACE_ENTRY( "%p %p", queue, msg);385 return mq_tget(queue, msg, 0, NULL);386 } 387 388 /* Get the next available message, block until there is one, or the timeout expires */389 int fd_ mq_timedget ( struct mqueue * queue, struct msg ** msg, const struct timespec *abstime )390 { 391 TRACE_ENTRY( "%p %p %p", queue, msg, abstime );392 return mq_tget(queue, msg, 1, abstime);393 } 394 381 /* Get the next available item, block until there is one */ 382 int fd_fifo_get_int ( struct fifo * queue, void ** item ) 383 { 384 TRACE_ENTRY( "%p %p", queue, item ); 385 return fifo_tget(queue, item, 0, NULL); 386 } 387 388 /* Get the next available item, block until there is one, or the timeout expires */ 389 int fd_fifo_timedget_int ( struct fifo * queue, void ** item, const struct timespec *abstime ) 390 { 391 TRACE_ENTRY( "%p %p %p", queue, item, abstime ); 392 return fifo_tget(queue, item, 1, abstime); 393 } 394
Note: See TracChangeset
for help on using the changeset viewer.