Changeset 8:3e143f047f78 in freeDiameter for include
- Timestamp:
- Sep 18, 2009, 6:54:07 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- include/freeDiameter
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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 */
Note: See TracChangeset
for help on using the changeset viewer.