Changeset 658:f198d16fa7f4 in freeDiameter for libfdcore
- Timestamp:
- Jan 14, 2011, 3:15:23 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdcore
- Files:
-
- 1 added
- 1 copied
- 27 moved
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/CMakeLists.txt
r592 r658 1 1 # The subproject name 2 Project("freeDiameter d" C)2 Project("freeDiameter core library" C) 3 3 4 4 # Configuration parser … … 8 8 9 9 # List of source files 10 SET(FD _COMMON_SRC11 f D.h10 SET(FDCORE_SRC 11 fdcore-internal.h 12 12 apps.c 13 13 cnxctx.h 14 14 config.c 15 core.c 15 16 cnxctx.c 16 17 endpoints.c … … 35 36 36 37 IF(NOT DISABLE_SCTP) 37 SET(FD _COMMON_SRC ${FD_COMMON_SRC} sctp.c sctps.c)38 SET(FDCORE_SRC ${FDCORE_SRC} sctp.c sctps.c) 38 39 ENDIF(NOT DISABLE_SCTP) 39 40 40 SET(FD _COMMON_GEN_SRC41 SET(FDCORE_GEN_SRC 41 42 lex.fdd.c 42 43 fdd.tab.c … … 45 46 46 47 # Save the list of files for the tests 47 SET(FD_COMMON_SRC ${FD_COMMON_SRC} PARENT_SCOPE) 48 SET(FD_COMMON_GEN_SRC ${FD_COMMON_GEN_SRC} PARENT_SCOPE) 49 50 51 # Require GNU TLS for building the daemon 52 FIND_PACKAGE(GnuTLS REQUIRED) 53 INCLUDE_DIRECTORIES(${GNUTLS_INCLUDE_DIR}) 54 SET(FD_LIBS ${FD_LIBS} ${GNUTLS_LIBRARIES}) 55 find_path(GCRYPT_INCLUDE_DIR NAMES gcrypt.h) 56 If ( NOT GCRYPT_INCLUDE_DIR ) 57 MESSAGE(SEND_ERROR "Unable to find gcrypt.h, please install libgcrypt-dev or equivalent") 58 Endif ( NOT GCRYPT_INCLUDE_DIR ) 59 MARK_AS_ADVANCED(GCRYPT_INCLUDE_DIR) 60 INCLUDE_DIRECTORIES(${GCRYPT_INCLUDE_DIR}) 61 62 # Also we need libgcrypt to... display its version :( 63 find_library(GCRYPT_LIBRARY 64 NAMES gcrypt 65 ) 66 If ( NOT GCRYPT_LIBRARY ) 67 MESSAGE(SEND_ERROR "Unable to find libgcrypt, please install libgcrypt or equivalent") 68 Endif ( NOT GCRYPT_LIBRARY ) 69 SET(FD_LIBS ${FD_LIBS} ${GCRYPT_LIBRARY}) 70 48 SET(FDCORE_SRC ${FDCORE_SRC} PARENT_SCOPE) 49 SET(FDCORE_GEN_SRC ${FDCORE_GEN_SRC} PARENT_SCOPE) 71 50 72 51 73 52 # Build the executable 74 ADD_ EXECUTABLE(freeDiameterd ${FD_COMMON_SRC} ${FD_COMMON_GEN_SRC} main.c)53 ADD_LIBRARY(libfdcore SHARED ${FDCORE_SRC} ${FDCORE_GEN_SRC}) 75 54 76 # The version 77 SET_TARGET_PROPERTIES(freeDiameterd PROPERTIES 55 # Avoid the liblib name, and set the version 56 SET_TARGET_PROPERTIES(libfdcore PROPERTIES 57 OUTPUT_NAME "fdcore" 58 SOVERSION ${FD_PROJECT_VERSION_API} 78 59 VERSION ${FD_PROJECT_VERSION_MAJOR}.${FD_PROJECT_VERSION_MINOR}.${FD_PROJECT_VERSION_REV}) 79 60 80 # The li nk command81 LINK_DIRECTORIES(${CURRENT_BINARY_DIR}/../libf reeDiameter)82 TARGET_LINK_LIBRARIES( freeDiameterd libfreeDiameter ${FD_LIBS})61 # The library itself needs other libraries 62 LINK_DIRECTORIES(${CURRENT_BINARY_DIR}/../libfdproto) 63 TARGET_LINK_LIBRARIES(libfdcore libfdproto ${LFDCORE_LIBS}) 83 64 84 # The unary tests directory85 IF ( BUILD_TESTING )86 SUBDIRS(tests)87 ENDIF ( BUILD_TESTING )88 65 89 66 #### 90 67 ## INSTALL section ## 91 68 92 INSTALL(TARGETS freeDiameterd93 RUNTIME DESTINATION ${INSTALL_DAEMON_SUFFIX}94 COMPONENT freeDiameter- daemon)69 INSTALL(TARGETS libfdcore 70 LIBRARY DESTINATION ${INSTALL_LIBRARY_SUFFIX} 71 COMPONENT freeDiameter-common) -
libfdcore/apps.c
r648 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* Merge information into a list of apps */ -
libfdcore/cnxctx.c
r591 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 #include "cnxctx.h" 38 38 -
libfdcore/config.c
r578 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 #include <sys/stat.h> 38 38 … … 46 46 #endif /* GNUTLS_DEFAULT_DHBITS */ 47 47 48 /* Initialize the fd_g_config structure to default values */48 /* Initialize the fd_g_config structure to default values -- it should already have been initialized to all-0 */ 49 49 int fd_conf_init() 50 50 { -
libfdcore/dict_base_proto.c
r336 r658 37 37 */ 38 38 39 #include "f D.h"39 #include "fdcore-internal.h" 40 40 41 41 #include <netinet/in.h> -
libfdcore/endpoints.c
r640 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 -
libfdcore/events.c
r82 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "fD.h" 36 #include "fdcore-internal.h" 37 38 /* Events are a subset of fifo queues, with a known type */ 37 39 38 40 int fd_event_send(struct fifo *queue, int code, size_t datasz, void * data) … … 110 112 case_str(FDEV_DUMP_CONFIG); 111 113 case_str(FDEV_DUMP_PEERS); 114 case_str(FDEV_TRIGGER); 112 115 113 116 default: … … 117 120 } 118 121 122 /**********************************************************************/ 123 /* Trigged events */ 124 /* This allows extensions to register for / send triggers to other extensions */ 125 /* It is used for example for users interactions (through signals or ...) */ 126 127 /* Because the number of triggers is not expected to grow, we use a simple ordered chained list */ 128 static pthread_rwlock_t trig_rwl = PTHREAD_RWLOCK_INITIALIZER; 129 static struct fd_list trig_list = FD_LIST_INITIALIZER(trig_list); /* The list of triggers ordered by trigger value */ 130 struct trig_item { 131 struct fd_list chain; 132 int trig_value; 133 const char * trig_module; 134 void (*cb)(void); 135 }; 136 137 /* Add a new entry in the trigger list */ 138 int fd_event_trig_regcb(int trigger_val, const char * module, void (*cb)(void)) 139 { 140 struct trig_item * ti; 141 struct fd_list * li; 142 143 TRACE_ENTRY("%d %p %p", trigger_val, module, cb); 144 CHECK_PARAMS( trigger_val && cb ); 145 146 /* Create a new trig_item */ 147 CHECK_MALLOC( ti = malloc(sizeof(struct trig_item)) ); 148 memset(ti, 0, sizeof(struct trig_item)); 149 fd_list_init(&ti->chain, ti); 150 ti->trig_value = trigger_val; 151 ti->trig_module = module; 152 ti->cb = cb; 153 154 /* Now insert in the list */ 155 CHECK_POSIX( pthread_rwlock_wrlock(&trig_rwl) ); 156 157 for (li = trig_list.next; li != &trig_list; li = li->next) { 158 struct trig_item *t = li->o; 159 if (t->trig_value >= trigger_val) 160 break; 161 } 162 163 fd_list_insert_before(li, &ti->chain); 164 165 CHECK_POSIX( pthread_rwlock_unlock(&trig_rwl) ); 166 167 return 0; 168 } 169 170 void fd_event_trig_dump() 171 { 172 struct fd_list * li; 173 if (!TRACE_BOOL(FULL)) 174 return; 175 176 CHECK_POSIX_DO( pthread_rwlock_rdlock(&trig_rwl), ); 177 178 for (li = trig_list.next; li != &trig_list; li = li->next) { 179 struct trig_item *t = li->o; 180 fd_log_debug(" Trigger %d, module '%s': %p\n", t->trig_value, t->trig_module, t->cb); 181 } 182 183 CHECK_POSIX_DO( pthread_rwlock_unlock(&trig_rwl), ); 184 } 185 186 static void *call_cb_detached(void * arg) 187 { 188 void (*cb)(void) = arg; 189 fd_log_threadname("Trig'd callback thread"); 190 TRACE_ENTRY("%p", arg); 191 (*cb)(); 192 TRACE_DEBUG(ANNOYING, "Callback %p completed", cb); 193 } 194 195 int fd_event_trig_call_cb(int trigger_val) 196 { 197 struct fd_list * li; 198 pthread_attr_t detached; 199 pthread_t th; 200 201 CHECK_POSIX( pthread_attr_init(&detached) ); 202 CHECK_POSIX( pthread_attr_setdetachstate(&detached, PTHREAD_CREATE_DETACHED) ); 203 204 CHECK_POSIX( pthread_rwlock_rdlock(&trig_rwl) ); 205 206 for (li = trig_list.next; li != &trig_list; li = li->next) { 207 struct trig_item *t = li->o; 208 if (t->trig_value == trigger_val) { 209 TRACE_DEBUG(FULL, "Trigger %d: Calling %p in %s", t->trig_value, t->cb, t->trig_module); 210 CHECK_POSIX_DO( pthread_create( &th, &detached, call_cb_detached, t->cb ), break ); 211 } 212 if (t->trig_value > trigger_val) 213 break; 214 } 215 216 CHECK_POSIX( pthread_rwlock_unlock(&trig_rwl) ); 217 218 return 0; 219 } 220 221 int fd_event_trig_fini(void) { 222 223 TRACE_ENTRY(""); 224 225 CHECK_POSIX( pthread_rwlock_wrlock(&trig_rwl) ); 226 227 while (!FD_IS_LIST_EMPTY(&trig_list)) { 228 struct fd_list * li = trig_list.next; 229 fd_list_unlink(li); 230 free(li); 231 } 232 233 CHECK_POSIX( pthread_rwlock_unlock(&trig_rwl) ); 234 235 return 0; 236 } -
libfdcore/extensions.c
r287 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 #include <dlfcn.h> /* We may use libtool's <ltdl.h> later for better portability.... */ -
libfdcore/fdcore-internal.h
r649 r658 34 34 *********************************************************************************************************/ 35 35 36 /* This file contains the definitions for internal use in the freeDiameter daemon*/37 38 #ifndef _FD _H39 #define _FD _H36 /* This file contains the definitions for internal use in the freeDiameter core library */ 37 38 #ifndef _FDCORE_INTERNAL_H 39 #define _FDCORE_INTERNAL_H 40 40 41 41 #include <freeDiameter/freeDiameter-host.h> 42 #include <freeDiameter/freeDiameter.h> 43 44 #ifndef FD_DEFAULT_CONF_FILENAME 45 #define FD_DEFAULT_CONF_FILENAME "freeDiameter.conf" 46 #endif /* FD_DEFAULT_CONF_FILENAME */ 42 #include <freeDiameter/libfdcore.h> 47 43 48 44 #ifdef DISABLE_SCTP … … 106 102 int fd_queues_init(void); 107 103 int fd_queues_fini(struct fifo ** queue); 104 105 /* Trigged events */ 106 int fd_event_trig_call_cb(int trigger_val); 107 int fd_event_trig_fini(void); 108 108 109 109 /* Create all the dictionary objects defined in the Diameter base RFC. */ … … 345 345 #define FD_CNX_BROADCAST (1 << 1) /* The message is sent over all stream pairs, in case of SCTP. No effect on TCP */ 346 346 347 #endif /* _FD _H */347 #endif /* _FDCORE_INTERNAL_H */ -
libfdcore/fdd.l
r578 r658 43 43 %{ 44 44 /* Include the daemon's header files */ 45 #include "f D.h"45 #include "fdcore-internal.h" 46 46 /* Include yacc tokens definitions */ 47 47 #include "fdd.tab.h" -
libfdcore/fdd.y
r578 r658 53 53 54 54 %{ 55 #include "f D.h"55 #include "fdcore-internal.h" 56 56 #include "fdd.tab.h" /* bug : bison does not define the YYLTYPE before including this bloc, so... */ 57 57 -
libfdcore/messages.c
r648 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 static struct dict_object * dict_avp_OH = NULL; /* Origin-Host */ -
libfdcore/p_ce.c
r454 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* This file contains code to handle Capabilities Exchange messages (CER and CEA) and election process */ -
libfdcore/p_cnx.c
r379 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* This file contains code used by a peer state machine to initiate a connection to remote peer */ -
libfdcore/p_dp.c
r454 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* This file contains code to handle Disconnect Peer messages (DPR and DPA) */ -
libfdcore/p_dw.c
r454 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* This file contains code to handle Device Watchdog messages (DWR and DWA) */ -
libfdcore/p_expiry.c
r648 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* Delay for garbage collection of expired peers, in seconds */ -
libfdcore/p_out.c
r455 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* Alloc a new hbh for requests, bufferize the message and send on the connection, save in sentreq if provided */ -
libfdcore/p_psm.c
r454 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* The actual declaration of peer_state_str */ -
libfdcore/p_sr.c
r650 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 #ifndef SR_DEBUG_LVL -
libfdcore/peers.c
r649 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* Global list of peers */ -
libfdcore/queues.c
r124 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* The global message queues */ -
libfdcore/routing_dispatch.c
r649 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /********************************************************************************/ -
libfdcore/sctp.c
r590 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 #include "cnxctx.h" 38 38 -
libfdcore/sctps.c
r543 r658 37 37 /* See http://aaa.koganei.wide.ad.jp/blogs/index.php/waaad/2008/08/18/tls-over-sctp for history */ 38 38 39 #include "f D.h"39 #include "fdcore-internal.h" 40 40 #include "cnxctx.h" 41 41 -
libfdcore/server.c
r590 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 38 38 /* Server (listening) part of the daemon */ -
libfdcore/tcp.c
r378 r658 34 34 *********************************************************************************************************/ 35 35 36 #include "f D.h"36 #include "fdcore-internal.h" 37 37 #include "cnxctx.h" 38 38
Note: See TracChangeset
for help on using the changeset viewer.