Mercurial > hg > freeDiameter
comparison include/freeDiameter/libfreeDiameter.h @ 618:1dbc4c5397d6
Attempting to improve python wrapper usability (work in progress)
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 03 Dec 2010 18:29:51 +0900 |
parents | 2d15fd8ef5ba |
children | bc7328e600f0 |
comparison
equal
deleted
inserted
replaced
617:c16583e80ffe | 618:1dbc4c5397d6 |
---|---|
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | 27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | 28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | 29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | 30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | 32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY S_OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | 33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
34 *********************************************************************************************************/ | 34 *********************************************************************************************************/ |
35 | 35 |
36 /* This file contains the definitions of functions and types used by the libfreeDiameter library. | 36 /* This file contains the definitions of functions and types used by the libfreeDiameter library. |
37 * | 37 * |
75 | 75 |
76 #ifdef DEBUG | 76 #ifdef DEBUG |
77 #include <libgen.h> /* for basename if --dbg_file is specified */ | 77 #include <libgen.h> /* for basename if --dbg_file is specified */ |
78 #endif /* DEBUG */ | 78 #endif /* DEBUG */ |
79 | 79 |
80 #ifdef SWIG | |
81 #define S_INOUT(_p_) INOUT | |
82 #define S_OUT(_p_) OUTPUT | |
83 #else /* SWIG */ | |
84 #define S_INOUT(_p_) _p_ | |
85 #define S_OUT(_p_) _p_ | |
86 #endif /* SWIG */ | |
80 | 87 |
81 /*============================================================*/ | 88 /*============================================================*/ |
82 /* INIT */ | 89 /* INIT */ |
83 /*============================================================*/ | 90 /*============================================================*/ |
91 #ifndef SWIG /* This section is not included in wrapper */ | |
92 | |
84 | 93 |
85 /* This function must be called first, before any call to another library function */ | 94 /* This function must be called first, before any call to another library function */ |
86 /* If the parameter is not 0, the support for signals (fd_sig_register) is enabled, otherwise it is disabled */ | 95 /* If the parameter is not 0, the support for signals (fd_sig_register) is enabled, otherwise it is disabled */ |
87 /* The function must be called while the application is single-threaded to enable support for signals */ | 96 /* The function must be called while the application is single-threaded to enable support for signals */ |
88 int fd_lib_init(int support_signals); | 97 int fd_lib_init(int support_signals); |
89 | 98 |
90 /* Call this one when the application terminates, to destroy internal threads */ | 99 /* Call this one when the application terminates, to destroy internal threads */ |
91 void fd_lib_fini(void); | 100 void fd_lib_fini(void); |
92 | 101 |
93 | 102 |
94 | 103 #endif /* !SWIG */ |
95 | |
96 /*============================================================*/ | 104 /*============================================================*/ |
97 /* DEBUG */ | 105 /* DEBUG */ |
98 /*============================================================*/ | 106 /*============================================================*/ |
107 | |
99 | 108 |
100 /* | 109 /* |
101 * FUNCTION: fd_log_debug | 110 * FUNCTION: fd_log_debug |
102 * | 111 * |
103 * PARAMETERS: | 112 * PARAMETERS: |
114 * | 123 * |
115 * RETURN VALUE: | 124 * RETURN VALUE: |
116 * None. | 125 * None. |
117 */ | 126 */ |
118 void fd_log_debug ( char * format, ... ); | 127 void fd_log_debug ( char * format, ... ); |
128 #ifndef SWIG | |
119 extern pthread_mutex_t fd_log_lock; | 129 extern pthread_mutex_t fd_log_lock; |
130 #endif /* !SWIG */ | |
120 extern char * fd_debug_one_function; | 131 extern char * fd_debug_one_function; |
121 extern char * fd_debug_one_file; | 132 extern char * fd_debug_one_file; |
122 | 133 |
123 /* | 134 /* |
124 * FUNCTION: fd_log_threadname | 135 * FUNCTION: fd_log_threadname |
133 * in the address space of the current process. | 144 * in the address space of the current process. |
134 * | 145 * |
135 * RETURN VALUE: | 146 * RETURN VALUE: |
136 * None. | 147 * None. |
137 */ | 148 */ |
149 #ifndef SWIG | |
138 void fd_log_threadname ( char * name ); | 150 void fd_log_threadname ( char * name ); |
139 extern pthread_key_t fd_log_thname; | 151 extern pthread_key_t fd_log_thname; |
152 #endif /* !SWIG */ | |
140 | 153 |
141 /* | 154 /* |
142 * FUNCTION: fd_log_time | 155 * FUNCTION: fd_log_time |
143 * | 156 * |
144 * PARAMETERS: | 157 * PARAMETERS: |
157 | 170 |
158 /*============================================================*/ | 171 /*============================================================*/ |
159 /* DEBUG MACROS */ | 172 /* DEBUG MACROS */ |
160 /*============================================================*/ | 173 /*============================================================*/ |
161 | 174 |
175 #ifndef SWIG | |
162 #ifndef ASSERT | 176 #ifndef ASSERT |
163 #define ASSERT(x) assert(x) | 177 #define ASSERT(x) assert(x) |
164 #endif /* ASSERT */ | 178 #endif /* ASSERT */ |
179 #endif /* !SWIG */ | |
165 | 180 |
166 /* levels definitions */ | 181 /* levels definitions */ |
167 #define NONE 0 /* Display no debug message */ | 182 #define NONE 0 /* Display no debug message */ |
168 #define INFO 1 /* Display errors only */ | 183 #define INFO 1 /* Display errors only */ |
169 #define FULL 2 /* Display additional information to follow code execution */ | 184 #define FULL 2 /* Display additional information to follow code execution */ |
170 #define ANNOYING 4 /* Very verbose, for example in loops */ | 185 #define ANNOYING 4 /* Very verbose, for example in loops */ |
171 #define FCTS 6 /* Display entry parameters of most functions */ | 186 #define FCTS 6 /* Display entry parameters of most functions */ |
172 #define CALL 9 /* Display calls to most functions (with CHECK macros) */ | 187 #define CALL 9 /* Display calls to most functions (with CHECK macros) */ |
173 | 188 |
174 /* Default level is INFO */ | 189 /* Default level is INFO */ |
190 #ifndef SWIG | |
175 #ifndef TRACE_LEVEL | 191 #ifndef TRACE_LEVEL |
176 #define TRACE_LEVEL INFO | 192 #define TRACE_LEVEL INFO |
177 #endif /* TRACE_LEVEL */ | 193 #endif /* TRACE_LEVEL */ |
194 #endif /* !SWIG */ | |
178 | 195 |
179 /* The level of the file being compiled. */ | 196 /* The level of the file being compiled. */ |
197 #ifndef SWIG | |
180 static int local_debug_level = TRACE_LEVEL; | 198 static int local_debug_level = TRACE_LEVEL; |
199 #endif /* !SWIG */ | |
181 | 200 |
182 /* A global level, changed by configuration or cmd line for example. default is 0. */ | 201 /* A global level, changed by configuration or cmd line for example. default is 0. */ |
183 extern int fd_g_debug_lvl; | 202 extern int fd_g_debug_lvl; |
184 | 203 |
185 /* Some portability code to get nice function name in __PRETTY_FUNCTION__ */ | 204 /* Some portability code to get nice function name in __PRETTY_FUNCTION__ */ |
205 #ifndef SWIG | |
186 #if __STDC_VERSION__ < 199901L | 206 #if __STDC_VERSION__ < 199901L |
187 # if __GNUC__ >= 2 | 207 # if __GNUC__ >= 2 |
188 # define __func__ __FUNCTION__ | 208 # define __func__ __FUNCTION__ |
189 # else /* __GNUC__ >= 2 */ | 209 # else /* __GNUC__ >= 2 */ |
190 # define __func__ "<unknown>" | 210 # define __func__ "<unknown>" |
191 # endif /* __GNUC__ >= 2 */ | 211 # endif /* __GNUC__ >= 2 */ |
192 #endif /* __STDC_VERSION__ < 199901L */ | 212 #endif /* __STDC_VERSION__ < 199901L */ |
193 #ifndef __PRETTY_FUNCTION__ | 213 #ifndef __PRETTY_FUNCTION__ |
194 #define __PRETTY_FUNCTION__ __func__ | 214 #define __PRETTY_FUNCTION__ __func__ |
195 #endif /* __PRETTY_FUNCTION__ */ | 215 #endif /* __PRETTY_FUNCTION__ */ |
216 #endif /* !SWIG */ | |
196 | 217 |
197 /* A version of __FILE__ without the full path */ | 218 /* A version of __FILE__ without the full path */ |
219 #ifndef SWIG | |
198 static char * file_bname = NULL; | 220 static char * file_bname = NULL; |
199 #define __STRIPPED_FILE__ (file_bname ?: (file_bname = basename(__FILE__))) | 221 #define __STRIPPED_FILE__ (file_bname ?: (file_bname = basename(__FILE__))) |
222 #endif /* !SWIG */ | |
200 | 223 |
201 | 224 |
202 /* Boolean for tracing at a certain level */ | 225 /* Boolean for tracing at a certain level */ |
226 #ifndef SWIG | |
203 #ifdef DEBUG | 227 #ifdef DEBUG |
204 #define TRACE_BOOL(_level_) ( ((_level_) <= local_debug_level + fd_g_debug_lvl) \ | 228 #define TRACE_BOOL(_level_) ( ((_level_) <= local_debug_level + fd_g_debug_lvl) \ |
205 || (fd_debug_one_function && !strcmp(fd_debug_one_function, __PRETTY_FUNCTION__)) \ | 229 || (fd_debug_one_function && !strcmp(fd_debug_one_function, __PRETTY_FUNCTION__)) \ |
206 || (fd_debug_one_file && !strcmp(fd_debug_one_file, __STRIPPED_FILE__) ) ) | 230 || (fd_debug_one_file && !strcmp(fd_debug_one_file, __STRIPPED_FILE__) ) ) |
207 #else /* DEBUG */ | 231 #else /* DEBUG */ |
208 #define TRACE_BOOL(_level_) ((_level_) <= local_debug_level + fd_g_debug_lvl) | 232 #define TRACE_BOOL(_level_) ((_level_) <= local_debug_level + fd_g_debug_lvl) |
209 #endif /* DEBUG */ | 233 #endif /* DEBUG */ |
234 #endif /* !SWIG */ | |
210 | 235 |
211 | 236 |
212 /************* | 237 /************* |
213 The general debug macro, each call results in two lines of debug messages (change the macro for more compact output) | 238 The general debug macro, each call results in two lines of debug messages (change the macro for more compact output) |
214 *************/ | 239 *************/ |
240 #ifndef SWIG | |
215 #ifdef DEBUG | 241 #ifdef DEBUG |
216 /* In DEBUG mode, we add (a lot of) meta-information along each trace. This makes multi-threading problems easier to debug. */ | 242 /* In DEBUG mode, we add (a lot of) meta-information along each trace. This makes multi-threading problems easier to debug. */ |
217 #define TRACE_DEBUG(level,format,args... ) { \ | 243 #define TRACE_DEBUG(level,format,args... ) { \ |
218 if ( TRACE_BOOL(level) ) { \ | 244 if ( TRACE_BOOL(level) ) { \ |
219 char __buf[25]; \ | 245 char __buf[25]; \ |
239 fd_log_debug(format "\n", ## args); \ | 265 fd_log_debug(format "\n", ## args); \ |
240 } \ | 266 } \ |
241 } \ | 267 } \ |
242 } | 268 } |
243 #endif /* DEBUG */ | 269 #endif /* DEBUG */ |
270 #endif /* !SWIG */ | |
244 | 271 |
245 /************* | 272 /************* |
246 Derivatives from this macro | 273 Derivatives from this macro |
247 ************/ | 274 ************/ |
275 #ifndef SWIG | |
248 /* Helper for function entry -- for very detailed trace of the execution */ | 276 /* Helper for function entry -- for very detailed trace of the execution */ |
249 #define TRACE_ENTRY(_format,_args... ) \ | 277 #define TRACE_ENTRY(_format,_args... ) \ |
250 TRACE_DEBUG(FCTS, "[enter] %s(" _format ") {" #_args "}", __PRETTY_FUNCTION__, ##_args ); | 278 TRACE_DEBUG(FCTS, "[enter] %s(" _format ") {" #_args "}", __PRETTY_FUNCTION__, ##_args ); |
251 | 279 |
252 /* Helper for debugging by adding traces -- for debuging a specific location of the code */ | 280 /* Helper for debugging by adding traces -- for debuging a specific location of the code */ |
374 #define TRACE_DEBUG_ERROR(format,args... ) { \ | 402 #define TRACE_DEBUG_ERROR(format,args... ) { \ |
375 fd_log_debug(format "\n", ## args); \ | 403 fd_log_debug(format "\n", ## args); \ |
376 } | 404 } |
377 #endif /* STRIP_DEBUG_CODE */ | 405 #endif /* STRIP_DEBUG_CODE */ |
378 | 406 |
407 #endif /* !SWIG */ | |
379 | 408 |
380 /*============================================================*/ | 409 /*============================================================*/ |
381 /* ERROR CHECKING MACRO */ | 410 /* ERROR CHECKING MACRO */ |
382 /*============================================================*/ | 411 /*============================================================*/ |
383 | 412 |
384 /* Macros to check a return value and branch out in case of error. | 413 /* Macros to check a return value and branch out in case of error. |
385 * These macro should be used only when errors are improbable, not for expected errors. | 414 * These macro should be used only when errors are improbable, not for expected errors. |
386 */ | 415 */ |
416 #ifndef SWIG | |
387 | 417 |
388 /* Check the return value of a system function and execute fallback in case of error */ | 418 /* Check the return value of a system function and execute fallback in case of error */ |
389 #define CHECK_SYS_DO( __call__, __fallback__ ) { \ | 419 #define CHECK_SYS_DO( __call__, __fallback__ ) { \ |
390 int __ret__; \ | 420 int __ret__; \ |
391 TRACE_DEBUG_ALL( "Check SYS: " #__call__ ); \ | 421 TRACE_DEBUG_ALL( "Check SYS: " #__call__ ); \ |
475 #define CHECK_FCT( __call__ ) { \ | 505 #define CHECK_FCT( __call__ ) { \ |
476 int __v__; \ | 506 int __v__; \ |
477 CHECK_FCT_DO( __v__ = (__call__), return __v__ ); \ | 507 CHECK_FCT_DO( __v__ = (__call__), return __v__ ); \ |
478 } | 508 } |
479 | 509 |
510 #endif /* !SWIG */ | |
511 | |
480 | 512 |
481 /*============================================================*/ | 513 /*============================================================*/ |
482 /* OTHER MACROS */ | 514 /* OTHER MACROS */ |
483 /*============================================================*/ | 515 /*============================================================*/ |
516 | |
517 #ifndef SWIG | |
484 | 518 |
485 /* helper macros (pre-processor hacks to allow macro arguments) */ | 519 /* helper macros (pre-processor hacks to allow macro arguments) */ |
486 #define __str( arg ) #arg | 520 #define __str( arg ) #arg |
487 #define _stringize( arg ) __str( arg ) | 521 #define _stringize( arg ) __str( arg ) |
488 #define __agr( arg1, arg2 ) arg1 ## arg2 | 522 #define __agr( arg1, arg2 ) arg1 ## arg2 |
562 /* This gives a good size for buffered reads */ | 596 /* This gives a good size for buffered reads */ |
563 #ifndef BUFSIZ | 597 #ifndef BUFSIZ |
564 #define BUFSIZ 96 | 598 #define BUFSIZ 96 |
565 #endif /* BUFSIZ */ | 599 #endif /* BUFSIZ */ |
566 | 600 |
601 #endif /* !SWIG */ | |
567 | 602 |
568 | 603 |
569 /*============================================================*/ | 604 /*============================================================*/ |
570 /* THREADS */ | 605 /* THREADS */ |
571 /*============================================================*/ | 606 /*============================================================*/ |
572 #ifndef SWIG | 607 #ifndef SWIG |
573 | 608 |
574 /* Terminate a thread */ | 609 /* Terminate a thread */ |
575 static __inline__ int fd_thr_term(pthread_t * th) | 610 static __inline__ int fd_thr_term(pthread_t * th) |
576 { | 611 { |
577 void * th_ret = NULL; | 612 void * th_ret = NULL; |
630 if (sockptr && (*(int *)sockptr > 0)) { | 665 if (sockptr && (*(int *)sockptr > 0)) { |
631 CHECK_SYS_DO( close(*(int *)sockptr), /* ignore */ ); | 666 CHECK_SYS_DO( close(*(int *)sockptr), /* ignore */ ); |
632 *(int *)sockptr = -1; | 667 *(int *)sockptr = -1; |
633 } | 668 } |
634 } | 669 } |
635 | 670 #endif /* !SWIG */ |
636 #endif /* SWIG */ | |
637 | 671 |
638 /*============================================================*/ | 672 /*============================================================*/ |
639 /* SIGNALS */ | 673 /* SIGNALS */ |
640 /*============================================================*/ | 674 /*============================================================*/ |
641 | 675 |
642 /* Register a new callback to be called on reception of a given signal (it receives the signal as parameter) */ | 676 /* Register a new callback to be called on reception of a given signal (it receives the signal as parameter) */ |
643 /* EALREADY will be returned if there is already a callback registered on this signal */ | 677 /* EALREADY will be returned if there is already a callback registered on this signal */ |
644 /* NOTE: the signal handler will be called from a new detached thread */ | 678 /* NOTE: the signal handler will be called from a new detached thread */ |
679 #ifndef SWIG | |
645 int fd_sig_register(int signal, char * modname, void (*callback)(int signal)); | 680 int fd_sig_register(int signal, char * modname, void (*callback)(int signal)); |
681 #endif /* !SWIG */ | |
646 | 682 |
647 /* Remove the handler for a given signal */ | 683 /* Remove the handler for a given signal */ |
648 int fd_sig_unregister(int signal); | 684 int fd_sig_unregister(int signal); |
649 | 685 |
650 /* Dump list of handlers */ | 686 /* Dump list of handlers */ |
669 /* Initialize a list element */ | 705 /* Initialize a list element */ |
670 #define FD_LIST_INITIALIZER( _list_name ) \ | 706 #define FD_LIST_INITIALIZER( _list_name ) \ |
671 { .next = & _list_name, .prev = & _list_name, .head = & _list_name, .o = NULL } | 707 { .next = & _list_name, .prev = & _list_name, .head = & _list_name, .o = NULL } |
672 #define FD_LIST_INITIALIZER_O( _list_name, _obj ) \ | 708 #define FD_LIST_INITIALIZER_O( _list_name, _obj ) \ |
673 { .next = & _list_name, .prev = & _list_name, .head = & _list_name, .o = _obj } | 709 { .next = & _list_name, .prev = & _list_name, .head = & _list_name, .o = _obj } |
674 void fd_list_init ( struct fd_list * list, void *obj ); | 710 #ifdef SWIG |
711 %apply struct fd_list * OUTPUT { struct fd_list * list }; | |
712 void fd_list_init ( struct fd_list * list, void * obj ); | |
713 %clear struct fd_list * list; | |
714 #else | |
715 void fd_list_init ( struct fd_list * list, void * obj ); | |
716 #endif | |
675 | 717 |
676 /* Return boolean, true if the list is empty */ | 718 /* Return boolean, true if the list is empty */ |
677 #define FD_IS_LIST_EMPTY( _list ) ((((struct fd_list *)(_list))->head == (_list)) && (((struct fd_list *)(_list))->next == (_list))) | 719 #define FD_IS_LIST_EMPTY( _list ) ((((struct fd_list *)(_list))->head == (_list)) && (((struct fd_list *)(_list))->next == (_list))) |
678 | 720 |
679 /* Insert an item in a list at known position */ | 721 /* Insert an item in a list at known position */ |
701 | 743 |
702 | 744 |
703 /*============================================================*/ | 745 /*============================================================*/ |
704 /* DICTIONARY */ | 746 /* DICTIONARY */ |
705 /*============================================================*/ | 747 /*============================================================*/ |
748 | |
706 /* Structure that contains the complete dictionary definitions */ | 749 /* Structure that contains the complete dictionary definitions */ |
707 struct dictionary; | 750 struct dictionary; |
708 | 751 |
709 /* Structure that contains a dictionary object */ | 752 /* Structure that contains a dictionary object */ |
710 struct dict_object; | 753 struct dict_object; |
747 * EEXIST : This object is already defined in the dictionary (with conflicting data). | 790 * EEXIST : This object is already defined in the dictionary (with conflicting data). |
748 * If "ref" is not NULL, it points to the existing element on return. | 791 * If "ref" is not NULL, it points to the existing element on return. |
749 * (other standard errors may be returned, too, with their standard meaning. Example: | 792 * (other standard errors may be returned, too, with their standard meaning. Example: |
750 * ENOMEM : Memory allocation for the new object element failed.) | 793 * ENOMEM : Memory allocation for the new object element failed.) |
751 */ | 794 */ |
752 int fd_dict_new ( struct dictionary * dict, enum dict_object_type type, void * data, struct dict_object * parent, struct dict_object **ref ); | 795 int fd_dict_new ( struct dictionary * dict, enum dict_object_type type, void * data, struct dict_object * parent, struct dict_object ** S_OUT(ref) ); |
753 | 796 |
754 /* | 797 /* |
755 * FUNCTION: fd_dict_search | 798 * FUNCTION: fd_dict_search |
756 * | 799 * |
757 * PARAMETERS: | 800 * PARAMETERS: |
772 * RETURN VALUE: | 815 * RETURN VALUE: |
773 * 0 : The object has been found in the dictionary, or *result is NULL. | 816 * 0 : The object has been found in the dictionary, or *result is NULL. |
774 * EINVAL : A parameter is invalid. | 817 * EINVAL : A parameter is invalid. |
775 * ENOENT : No matching object has been found, and result was NULL. | 818 * ENOENT : No matching object has been found, and result was NULL. |
776 */ | 819 */ |
777 int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, void * what, struct dict_object **result, int retval ); | 820 int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, void * what, struct dict_object ** S_OUT(result), int retval ); |
778 | 821 |
779 /* Special case: get the generic error command object */ | 822 /* Special case: get the generic error command object */ |
780 int fd_dict_get_error_cmd(struct dictionary * dict, struct dict_object **obj); | 823 int fd_dict_get_error_cmd(struct dictionary * dict, struct dict_object ** S_OUT(obj)); |
781 | 824 |
782 /* | 825 /* |
783 * FUNCTION: fd_dict_getval | 826 * FUNCTION: fd_dict_getval |
784 * | 827 * |
785 * PARAMETERS: | 828 * PARAMETERS: |
793 * | 836 * |
794 * RETURN VALUE: | 837 * RETURN VALUE: |
795 * 0 : The content of the object has been retrieved. | 838 * 0 : The content of the object has been retrieved. |
796 * EINVAL : A parameter is invalid. | 839 * EINVAL : A parameter is invalid. |
797 */ | 840 */ |
798 int fd_dict_getval ( struct dict_object * object, void * val); | 841 int fd_dict_getval ( struct dict_object * object, void * S_INOUT(val)); |
799 int fd_dict_gettype ( struct dict_object * object, enum dict_object_type * type); | 842 int fd_dict_gettype ( struct dict_object * object, enum dict_object_type * S_OUT(type)); |
800 int fd_dict_getdict ( struct dict_object * object, struct dictionary ** dict); | 843 int fd_dict_getdict ( struct dict_object * object, struct dictionary ** S_OUT(dict)); |
801 | 844 |
802 /* Debug functions */ | 845 /* Debug functions */ |
803 void fd_dict_dump_object(struct dict_object * obj); | 846 void fd_dict_dump_object(struct dict_object * obj); |
804 void fd_dict_dump(struct dictionary * dict); | 847 void fd_dict_dump(struct dictionary * dict); |
805 | 848 |
1550 | 1593 |
1551 /* The state information that a module associate with a session -- each module defines its own data format */ | 1594 /* The state information that a module associate with a session -- each module defines its own data format */ |
1552 typedef void session_state; | 1595 typedef void session_state; |
1553 | 1596 |
1554 /* The following function must be called to activate the session expiry mechanism */ | 1597 /* The following function must be called to activate the session expiry mechanism */ |
1598 #ifndef SWIG | |
1555 int fd_sess_start(void); | 1599 int fd_sess_start(void); |
1600 #endif /* !SWIG */ | |
1556 | 1601 |
1557 /* | 1602 /* |
1558 * FUNCTION: fd_sess_handler_create | 1603 * FUNCTION: fd_sess_handler_create |
1559 * | 1604 * |
1560 * PARAMETERS: | 1605 * PARAMETERS: |
1569 * RETURN VALUE: | 1614 * RETURN VALUE: |
1570 * 0 : The new handler has been created. | 1615 * 0 : The new handler has been created. |
1571 * EINVAL : A parameter is invalid. | 1616 * EINVAL : A parameter is invalid. |
1572 * ENOMEM : Not enough memory to complete the operation | 1617 * ENOMEM : Not enough memory to complete the operation |
1573 */ | 1618 */ |
1574 int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(session_state * state, char * sid) ); | 1619 int fd_sess_handler_create_internal ( struct session_handler ** S_OUT(handler), void (*cleanup)(session_state * state, char * sid) ); |
1575 /* Macro to avoid casting everywhere */ | 1620 /* Macro to avoid casting everywhere */ |
1576 #define fd_sess_handler_create( _handler, _cleanup ) \ | 1621 #define fd_sess_handler_create( _handler, _cleanup ) \ |
1577 fd_sess_handler_create_internal( (_handler), (void (*)(session_state *, char *))(_cleanup) ) | 1622 fd_sess_handler_create_internal( (_handler), (void (*)(session_state *, char *))(_cleanup) ) |
1578 | 1623 |
1579 | 1624 |
1617 * 0 : The session is created. | 1662 * 0 : The session is created. |
1618 * EINVAL : A parameter is invalid. | 1663 * EINVAL : A parameter is invalid. |
1619 * EALREADY : A session with the same name already exists (returned in *session) | 1664 * EALREADY : A session with the same name already exists (returned in *session) |
1620 * ENOMEM : Not enough memory to complete the operation | 1665 * ENOMEM : Not enough memory to complete the operation |
1621 */ | 1666 */ |
1622 int fd_sess_new ( struct session ** session, char * diamId, char * opt, size_t optlen ); | 1667 int fd_sess_new ( struct session ** S_OUT(session), char * diamId, char * opt, size_t optlen ); |
1623 | 1668 |
1624 /* | 1669 /* |
1625 * FUNCTION: fd_sess_fromsid | 1670 * FUNCTION: fd_sess_fromsid |
1626 * | 1671 * |
1627 * PARAMETERS: | 1672 * PARAMETERS: |
1637 * RETURN VALUE: | 1682 * RETURN VALUE: |
1638 * 0 : The session parameter has been updated. | 1683 * 0 : The session parameter has been updated. |
1639 * EINVAL : A parameter is invalid. | 1684 * EINVAL : A parameter is invalid. |
1640 * ENOMEM : Not enough memory to complete the operation | 1685 * ENOMEM : Not enough memory to complete the operation |
1641 */ | 1686 */ |
1642 int fd_sess_fromsid ( char * sid, size_t len, struct session ** session, int * new); | 1687 int fd_sess_fromsid ( char * sid, size_t len, struct session ** S_OUT(session), int * S_OUT(new)); |
1643 | 1688 |
1644 /* | 1689 /* |
1645 * FUNCTION: fd_sess_getsid | 1690 * FUNCTION: fd_sess_getsid |
1646 * | 1691 * |
1647 * PARAMETERS: | 1692 * PARAMETERS: |
1656 * | 1701 * |
1657 * RETURN VALUE: | 1702 * RETURN VALUE: |
1658 * 0 : The sid parameter has been updated. | 1703 * 0 : The sid parameter has been updated. |
1659 * EINVAL : A parameter is invalid. | 1704 * EINVAL : A parameter is invalid. |
1660 */ | 1705 */ |
1661 int fd_sess_getsid ( struct session * session, char ** sid ); | 1706 int fd_sess_getsid ( struct session * session, char ** S_OUT(sid) ); |
1662 | 1707 |
1663 /* | 1708 /* |
1664 * FUNCTION: fd_sess_settimeout | 1709 * FUNCTION: fd_sess_settimeout |
1665 * | 1710 * |
1666 * PARAMETERS: | 1711 * PARAMETERS: |
1757 * | 1802 * |
1758 * RETURN VALUE: | 1803 * RETURN VALUE: |
1759 * 0 : *state is updated (NULL or points to the state if it was found). | 1804 * 0 : *state is updated (NULL or points to the state if it was found). |
1760 * EINVAL : A parameter is invalid. | 1805 * EINVAL : A parameter is invalid. |
1761 */ | 1806 */ |
1762 int fd_sess_state_retrieve_internal ( struct session_handler * handler, struct session * session, session_state ** state ); | 1807 int fd_sess_state_retrieve_internal ( struct session_handler * handler, struct session * session, session_state ** S_OUT(state) ); |
1763 #define fd_sess_state_retrieve( _handler, _session, _state ) \ | 1808 #define fd_sess_state_retrieve( _handler, _session, _state ) \ |
1764 fd_sess_state_retrieve_internal( (_handler), (_session), (void *)(_state) ) | 1809 fd_sess_state_retrieve_internal( (_handler), (_session), (void *)(_state) ) |
1765 | 1810 |
1766 | 1811 |
1767 /* For debug */ | 1812 /* For debug */ |
1768 void fd_sess_dump(int level, struct session * session); | 1813 void fd_sess_dump(int level, struct session * session); |
1769 void fd_sess_dump_hdl(int level, struct session_handler * handler); | 1814 void fd_sess_dump_hdl(int level, struct session_handler * handler); |
1770 | 1815 |
1771 | |
1772 /*============================================================*/ | 1816 /*============================================================*/ |
1773 /* ROUTING */ | 1817 /* ROUTING */ |
1774 /*============================================================*/ | 1818 /*============================================================*/ |
1775 | 1819 |
1776 /* The following functions are helpers for the routing module. | 1820 /* The following functions are helpers for the routing module. |
1778 | 1822 |
1779 /* Structure that contains the routing data for a message */ | 1823 /* Structure that contains the routing data for a message */ |
1780 struct rt_data; | 1824 struct rt_data; |
1781 | 1825 |
1782 /* Following functions are helpers to create the routing data of a message */ | 1826 /* Following functions are helpers to create the routing data of a message */ |
1783 int fd_rtd_init(struct rt_data ** rtd); | 1827 int fd_rtd_init(struct rt_data ** S_OUT(rtd)); |
1784 void fd_rtd_free(struct rt_data ** rtd); | 1828 void fd_rtd_free(struct rt_data ** rtd); |
1785 | 1829 |
1786 /* Add a peer to the candidates list */ | 1830 /* Add a peer to the candidates list */ |
1787 int fd_rtd_candidate_add(struct rt_data * rtd, char * peerid, char * realm); | 1831 int fd_rtd_candidate_add(struct rt_data * rtd, char * peerid, char * realm); |
1788 | 1832 |
1789 /* Remove a peer from the candidates (if it is found) */ | 1833 /* Remove a peer from the candidates (if it is found) */ |
1790 void fd_rtd_candidate_del(struct rt_data * rtd, char * peerid, size_t sz /* if !0, peerid does not need to be \0 terminated */); | 1834 void fd_rtd_candidate_del(struct rt_data * rtd, char * peerid, size_t sz /* if !0, peerid does not need to be \0 terminated */); |
1791 | 1835 |
1792 /* Extract the list of valid candidates, and initialize their scores to 0 */ | 1836 /* Extract the list of valid candidates, and initialize their scores to 0 */ |
1793 void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** candidates, int ini_score); | 1837 void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** S_OUT(candidates), int ini_score); |
1794 | 1838 |
1795 /* If a peer returned a protocol error for this message, save it so that we don't try to send it there again */ | 1839 /* If a peer returned a protocol error for this message, save it so that we don't try to send it there again */ |
1796 int fd_rtd_error_add(struct rt_data * rtd, char * sentto, uint8_t * origin, size_t originsz, uint32_t rcode); | 1840 int fd_rtd_error_add(struct rt_data * rtd, char * sentto, uint8_t * origin, size_t originsz, uint32_t rcode); |
1797 | 1841 |
1798 /* The extracted list items have the following structure: */ | 1842 /* The extracted list items have the following structure: */ |
1902 * 0 : The AVP is created. | 1946 * 0 : The AVP is created. |
1903 * EINVAL : A parameter is invalid. | 1947 * EINVAL : A parameter is invalid. |
1904 * (other standard errors may be returned, too, with their standard meaning. Example: | 1948 * (other standard errors may be returned, too, with their standard meaning. Example: |
1905 * ENOMEM : Memory allocation for the new avp failed.) | 1949 * ENOMEM : Memory allocation for the new avp failed.) |
1906 */ | 1950 */ |
1907 int fd_msg_avp_new ( struct dict_object * model, int flags, struct avp ** avp ); | 1951 int fd_msg_avp_new ( struct dict_object * model, int flags, struct avp ** S_OUT(avp) ); |
1908 | 1952 |
1909 /* | 1953 /* |
1910 * FUNCTION: fd_msg_new | 1954 * FUNCTION: fd_msg_new |
1911 * | 1955 * |
1912 * PARAMETERS: | 1956 * PARAMETERS: |
1921 * 0 : The message is created. | 1965 * 0 : The message is created. |
1922 * EINVAL : A parameter is invalid. | 1966 * EINVAL : A parameter is invalid. |
1923 * (other standard errors may be returned, too, with their standard meaning. Example: | 1967 * (other standard errors may be returned, too, with their standard meaning. Example: |
1924 * ENOMEM : Memory allocation for the new message failed.) | 1968 * ENOMEM : Memory allocation for the new message failed.) |
1925 */ | 1969 */ |
1926 int fd_msg_new ( struct dict_object * model, int flags, struct msg ** msg ); | 1970 int fd_msg_new ( struct dict_object * model, int flags, struct msg ** S_OUT(msg) ); |
1927 | 1971 |
1928 /* | 1972 /* |
1929 * FUNCTION: msg_new_answer_from_req | 1973 * FUNCTION: msg_new_answer_from_req |
1930 * | 1974 * |
1931 * PARAMETERS: | 1975 * PARAMETERS: |
1942 * | 1986 * |
1943 * RETURN VALUE: | 1987 * RETURN VALUE: |
1944 * 0 : Operation complete. | 1988 * 0 : Operation complete. |
1945 * !0 : an error occurred. | 1989 * !0 : an error occurred. |
1946 */ | 1990 */ |
1947 int fd_msg_new_answer_from_req ( struct dictionary * dict, struct msg ** msg, int flag ); | 1991 int fd_msg_new_answer_from_req ( struct dictionary * dict, struct msg ** S_INOUT(msg), int flag ); |
1948 | 1992 |
1949 /* | 1993 /* |
1950 * FUNCTION: fd_msg_browse | 1994 * FUNCTION: fd_msg_browse |
1951 * | 1995 * |
1952 * PARAMETERS: | 1996 * PARAMETERS: |
1966 * RETURN VALUE: | 2010 * RETURN VALUE: |
1967 * 0 : found has been updated (if non NULL). | 2011 * 0 : found has been updated (if non NULL). |
1968 * EINVAL : A parameter is invalid. | 2012 * EINVAL : A parameter is invalid. |
1969 * ENOENT : No element has been found where requested, and "found" was NULL (otherwise, *found is set to NULL and 0 is returned). | 2013 * ENOENT : No element has been found where requested, and "found" was NULL (otherwise, *found is set to NULL and 0 is returned). |
1970 */ | 2014 */ |
1971 int fd_msg_browse_internal ( msg_or_avp * reference, enum msg_brw_dir dir, msg_or_avp ** found, int * depth ); | 2015 int fd_msg_browse_internal ( msg_or_avp * reference, enum msg_brw_dir dir, msg_or_avp ** S_OUT(found), int * S_INOUT(depth) ); |
1972 /* Macro to avoid having to cast the third parameter everywhere */ | 2016 /* Macro to avoid having to cast the third parameter everywhere */ |
1973 #define fd_msg_browse( ref, dir, found, depth ) \ | 2017 #define fd_msg_browse( ref, dir, found, depth ) \ |
1974 fd_msg_browse_internal( (ref), (dir), (void *)(found), (depth) ) | 2018 fd_msg_browse_internal( (ref), (dir), (void *)(found), (depth) ) |
1975 | 2019 |
1976 | 2020 |
2010 * RETURN VALUE: | 2054 * RETURN VALUE: |
2011 * 0 : The AVP has been found. | 2055 * 0 : The AVP has been found. |
2012 * EINVAL : A parameter is invalid. | 2056 * EINVAL : A parameter is invalid. |
2013 * ENOENT : No AVP has been found, and "avp" was NULL (otherwise, *avp is set to NULL and 0 returned). | 2057 * ENOENT : No AVP has been found, and "avp" was NULL (otherwise, *avp is set to NULL and 0 returned). |
2014 */ | 2058 */ |
2015 int fd_msg_search_avp ( struct msg * msg, struct dict_object * what, struct avp ** avp ); | 2059 int fd_msg_search_avp ( struct msg * msg, struct dict_object * what, struct avp ** S_OUT(avp) ); |
2016 | 2060 |
2017 /* | 2061 /* |
2018 * FUNCTION: fd_msg_free | 2062 * FUNCTION: fd_msg_free |
2019 * | 2063 * |
2020 * PARAMETERS: | 2064 * PARAMETERS: |
2067 * | 2111 * |
2068 * RETURN VALUE: | 2112 * RETURN VALUE: |
2069 * 0 : The model has been set. | 2113 * 0 : The model has been set. |
2070 * EINVAL : A parameter is invalid. | 2114 * EINVAL : A parameter is invalid. |
2071 */ | 2115 */ |
2072 int fd_msg_model ( msg_or_avp * reference, struct dict_object ** model ); | 2116 int fd_msg_model ( msg_or_avp * reference, struct dict_object ** S_OUT(model) ); |
2073 | 2117 |
2074 /* | 2118 /* |
2075 * FUNCTION: fd_msg_hdr | 2119 * FUNCTION: fd_msg_hdr |
2076 * | 2120 * |
2077 * PARAMETERS: | 2121 * PARAMETERS: |
2083 * | 2127 * |
2084 * RETURN VALUE: | 2128 * RETURN VALUE: |
2085 * 0 : The location has been written. | 2129 * 0 : The location has been written. |
2086 * EINVAL : A parameter is invalid. | 2130 * EINVAL : A parameter is invalid. |
2087 */ | 2131 */ |
2088 int fd_msg_hdr ( struct msg *msg, struct msg_hdr **pdata ); | 2132 int fd_msg_hdr ( struct msg *msg, struct msg_hdr ** S_OUT(pdata) ); |
2089 | 2133 |
2090 /* | 2134 /* |
2091 * FUNCTION: fd_msg_avp_hdr | 2135 * FUNCTION: fd_msg_avp_hdr |
2092 * | 2136 * |
2093 * PARAMETERS: | 2137 * PARAMETERS: |
2099 * | 2143 * |
2100 * RETURN VALUE: | 2144 * RETURN VALUE: |
2101 * 0 : The location has been written. | 2145 * 0 : The location has been written. |
2102 * EINVAL : A parameter is invalid. | 2146 * EINVAL : A parameter is invalid. |
2103 */ | 2147 */ |
2104 int fd_msg_avp_hdr ( struct avp *avp, struct avp_hdr **pdata ); | 2148 int fd_msg_avp_hdr ( struct avp *avp, struct avp_hdr ** S_OUT(pdata) ); |
2105 | 2149 |
2106 /* | 2150 /* |
2107 * FUNCTION: fd_msg_answ_associate, fd_msg_answ_getq, fd_msg_answ_detach | 2151 * FUNCTION: fd_msg_answ_associate, fd_msg_answ_getq, fd_msg_answ_detach |
2108 * | 2152 * |
2109 * PARAMETERS: | 2153 * PARAMETERS: |
2120 * RETURN VALUE: | 2164 * RETURN VALUE: |
2121 * 0 : ok | 2165 * 0 : ok |
2122 * EINVAL: a parameter is invalid | 2166 * EINVAL: a parameter is invalid |
2123 */ | 2167 */ |
2124 int fd_msg_answ_associate( struct msg * answer, struct msg * query ); | 2168 int fd_msg_answ_associate( struct msg * answer, struct msg * query ); |
2125 int fd_msg_answ_getq ( struct msg * answer, struct msg ** query ); | 2169 int fd_msg_answ_getq ( struct msg * answer, struct msg ** S_OUT(query) ); |
2126 int fd_msg_answ_detach ( struct msg * answer ); | 2170 int fd_msg_answ_detach ( struct msg * answer ); |
2127 | 2171 |
2128 /* | 2172 /* |
2129 * FUNCTION: fd_msg_anscb_associate, fd_msg_anscb_get | 2173 * FUNCTION: fd_msg_anscb_associate, fd_msg_anscb_get |
2130 * | 2174 * |
2139 * | 2183 * |
2140 * RETURN VALUE: | 2184 * RETURN VALUE: |
2141 * 0 : ok | 2185 * 0 : ok |
2142 * EINVAL: a parameter is invalid | 2186 * EINVAL: a parameter is invalid |
2143 */ | 2187 */ |
2188 #ifndef SWIG | |
2144 int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data ); | 2189 int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data ); |
2145 int fd_msg_anscb_get ( struct msg * msg, void (**anscb)(void *, struct msg **), void ** data ); | 2190 int fd_msg_anscb_get ( struct msg * msg, void (**anscb)(void *, struct msg **), void ** data ); |
2191 #endif /* !SWIG */ | |
2146 | 2192 |
2147 /* | 2193 /* |
2148 * FUNCTION: fd_msg_rt_associate, fd_msg_rt_get | 2194 * FUNCTION: fd_msg_rt_associate, fd_msg_rt_get |
2149 * | 2195 * |
2150 * PARAMETERS: | 2196 * PARAMETERS: |
2157 * | 2203 * |
2158 * RETURN VALUE: | 2204 * RETURN VALUE: |
2159 * 0 : ok | 2205 * 0 : ok |
2160 * EINVAL: a parameter is invalid | 2206 * EINVAL: a parameter is invalid |
2161 */ | 2207 */ |
2208 #ifndef SWIG | |
2162 int fd_msg_rt_associate( struct msg * msg, struct rt_data ** rtd ); | 2209 int fd_msg_rt_associate( struct msg * msg, struct rt_data ** rtd ); |
2163 int fd_msg_rt_get ( struct msg * msg, struct rt_data ** rtd ); | 2210 #endif /* !SWIG */ |
2211 int fd_msg_rt_get ( struct msg * msg, struct rt_data ** S_OUT(rtd) ); | |
2164 | 2212 |
2165 /* | 2213 /* |
2166 * FUNCTION: fd_msg_is_routable | 2214 * FUNCTION: fd_msg_is_routable |
2167 * | 2215 * |
2168 * PARAMETERS: | 2216 * PARAMETERS: |
2195 * | 2243 * |
2196 * RETURN VALUE: | 2244 * RETURN VALUE: |
2197 * 0 : Operation complete. | 2245 * 0 : Operation complete. |
2198 * !0 : an error occurred. | 2246 * !0 : an error occurred. |
2199 */ | 2247 */ |
2248 #ifndef SWIG | |
2200 int fd_msg_source_set( struct msg * msg, char * diamid, int add_rr, struct dictionary * dict ); | 2249 int fd_msg_source_set( struct msg * msg, char * diamid, int add_rr, struct dictionary * dict ); |
2201 int fd_msg_source_get( struct msg * msg, char ** diamid ); | 2250 #endif /* !SWIG */ |
2251 int fd_msg_source_get( struct msg * msg, char ** S_OUT(diamid) ); | |
2202 | 2252 |
2203 /* | 2253 /* |
2204 * FUNCTION: fd_msg_eteid_get | 2254 * FUNCTION: fd_msg_eteid_get |
2205 * | 2255 * |
2206 * PARAMETERS: | 2256 * PARAMETERS: |
2231 * | 2281 * |
2232 * RETURN VALUE: | 2282 * RETURN VALUE: |
2233 * 0 : success | 2283 * 0 : success |
2234 * !0 : standard error code. | 2284 * !0 : standard error code. |
2235 */ | 2285 */ |
2236 int fd_msg_sess_get(struct dictionary * dict, struct msg * msg, struct session ** session, int * new); | 2286 int fd_msg_sess_get(struct dictionary * dict, struct msg * msg, struct session ** S_OUT(session), int * S_OUT(new)); |
2237 | 2287 |
2238 /***************************************/ | 2288 /***************************************/ |
2239 /* Manage AVP values */ | 2289 /* Manage AVP values */ |
2240 /***************************************/ | 2290 /***************************************/ |
2241 | 2291 |
2271 * RETURN VALUE: | 2321 * RETURN VALUE: |
2272 * 0 : The avp_value has been set. | 2322 * 0 : The avp_value has been set. |
2273 * EINVAL : A parameter is invalid. | 2323 * EINVAL : A parameter is invalid. |
2274 * ENOTSUP : There is no appropriate callback registered with this AVP's type. | 2324 * ENOTSUP : There is no appropriate callback registered with this AVP's type. |
2275 */ | 2325 */ |
2326 #ifndef SWIG | |
2276 int fd_msg_avp_value_encode ( void *data, struct avp *avp ); | 2327 int fd_msg_avp_value_encode ( void *data, struct avp *avp ); |
2277 | 2328 #endif /* !SWIG */ |
2278 /* | 2329 /* |
2279 * FUNCTION: fd_msg_avp_value_interpret | 2330 * FUNCTION: fd_msg_avp_value_interpret |
2280 * | 2331 * |
2281 * PARAMETERS: | 2332 * PARAMETERS: |
2282 * avp : Pointer to a valid avp object with a non-NULL avp_value value. | 2333 * avp : Pointer to a valid avp object with a non-NULL avp_value value. |
2290 * RETURN VALUE: | 2341 * RETURN VALUE: |
2291 * 0 : The avp_value has been set. | 2342 * 0 : The avp_value has been set. |
2292 * EINVAL : A parameter is invalid. | 2343 * EINVAL : A parameter is invalid. |
2293 * ENOTSUP : There is no appropriate callback registered with this AVP's type. | 2344 * ENOTSUP : There is no appropriate callback registered with this AVP's type. |
2294 */ | 2345 */ |
2346 #ifndef SWIG | |
2295 int fd_msg_avp_value_interpret ( struct avp *avp, void *data ); | 2347 int fd_msg_avp_value_interpret ( struct avp *avp, void *data ); |
2348 #endif /* !SWIG */ | |
2296 | 2349 |
2297 | 2350 |
2298 /***************************************/ | 2351 /***************************************/ |
2299 /* Message parsing functions */ | 2352 /* Message parsing functions */ |
2300 /***************************************/ | 2353 /***************************************/ |
2314 * RETURN VALUE: | 2367 * RETURN VALUE: |
2315 * 0 : The location has been written. | 2368 * 0 : The location has been written. |
2316 * EINVAL : The buffer does not contain a valid Diameter message. | 2369 * EINVAL : The buffer does not contain a valid Diameter message. |
2317 * ENOMEM : Unable to allocate enough memory to create the buffer object. | 2370 * ENOMEM : Unable to allocate enough memory to create the buffer object. |
2318 */ | 2371 */ |
2319 int fd_msg_bufferize ( struct msg * msg, unsigned char ** buffer, size_t * len ); | 2372 int fd_msg_bufferize ( struct msg * msg, unsigned char ** S_OUT(buffer), size_t * S_OUT(len) ); |
2320 | 2373 |
2321 /* | 2374 /* |
2322 * FUNCTION: fd_msg_parse_buffer | 2375 * FUNCTION: fd_msg_parse_buffer |
2323 * | 2376 * |
2324 * PARAMETERS: | 2377 * PARAMETERS: |
2336 * 0 : The location has been written. | 2389 * 0 : The location has been written. |
2337 * ENOMEM : Unable to allocate enough memory to create the msg object. | 2390 * ENOMEM : Unable to allocate enough memory to create the msg object. |
2338 * EBADMSG : The buffer does not contain a valid Diameter message (or is truncated). | 2391 * EBADMSG : The buffer does not contain a valid Diameter message (or is truncated). |
2339 * EINVAL : A parameter is invalid. | 2392 * EINVAL : A parameter is invalid. |
2340 */ | 2393 */ |
2341 int fd_msg_parse_buffer ( unsigned char ** buffer, size_t buflen, struct msg ** msg ); | 2394 int fd_msg_parse_buffer ( unsigned char ** buffer, size_t buflen, struct msg ** S_OUT(msg) ); |
2342 | 2395 |
2343 /* Parsing Error Information structure */ | 2396 /* Parsing Error Information structure */ |
2344 struct fd_pei { | 2397 struct fd_pei { |
2345 char * pei_errcode; /* name of the error code to use */ | 2398 char * pei_errcode; /* name of the error code to use */ |
2346 struct avp * pei_avp; /* pointer to invalid or missing AVP (to be freed) */ | 2399 struct avp * pei_avp; /* pointer to invalid or missing AVP (to be freed) */ |
2370 * 0 : The message has been fully parsed as described. | 2423 * 0 : The message has been fully parsed as described. |
2371 * EINVAL : The msg parameter is invalid for this operation. | 2424 * EINVAL : The msg parameter is invalid for this operation. |
2372 * ENOMEM : Unable to allocate enough memory to complete the operation. | 2425 * ENOMEM : Unable to allocate enough memory to complete the operation. |
2373 * ENOTSUP : No dictionary definition for the command or one of the mandatory AVP was found. | 2426 * ENOTSUP : No dictionary definition for the command or one of the mandatory AVP was found. |
2374 */ | 2427 */ |
2375 int fd_msg_parse_dict ( msg_or_avp * object, struct dictionary * dict, struct fd_pei *error_info ); | 2428 int fd_msg_parse_dict ( msg_or_avp * object, struct dictionary * dict, struct fd_pei * S_OUT(error_info) ); |
2376 | 2429 |
2377 /* | 2430 /* |
2378 * FUNCTION: fd_msg_parse_rules | 2431 * FUNCTION: fd_msg_parse_rules |
2379 * | 2432 * |
2380 * PARAMETERS: | 2433 * PARAMETERS: |
2389 * 0 : The message has been fully parsed and complies to the defined rules. | 2442 * 0 : The message has been fully parsed and complies to the defined rules. |
2390 * EBADMSG : A conflict was detected, or a mandatory AVP is unknown in the dictionary. | 2443 * EBADMSG : A conflict was detected, or a mandatory AVP is unknown in the dictionary. |
2391 * EINVAL : The msg or avp object is invalid for this operation. | 2444 * EINVAL : The msg or avp object is invalid for this operation. |
2392 * ENOMEM : Unable to allocate enough memory to complete the operation. | 2445 * ENOMEM : Unable to allocate enough memory to complete the operation. |
2393 */ | 2446 */ |
2394 int fd_msg_parse_rules ( msg_or_avp * object, struct dictionary * dict, struct fd_pei *error_info); | 2447 int fd_msg_parse_rules ( msg_or_avp * object, struct dictionary * dict, struct fd_pei * S_OUT(error_info)); |
2395 | 2448 |
2396 | 2449 |
2397 | 2450 |
2398 /* | 2451 /* |
2399 * FUNCTION: fd_msg_update_length | 2452 * FUNCTION: fd_msg_update_length |
2568 * 0 : The callback is registered. | 2621 * 0 : The callback is registered. |
2569 * EINVAL : A parameter is invalid. | 2622 * EINVAL : A parameter is invalid. |
2570 * ENOMEM : Not enough memory to complete the operation | 2623 * ENOMEM : Not enough memory to complete the operation |
2571 */ | 2624 */ |
2572 int fd_disp_register ( int (*cb)( struct msg **, struct avp *, struct session *, enum disp_action *), | 2625 int fd_disp_register ( int (*cb)( struct msg **, struct avp *, struct session *, enum disp_action *), |
2573 enum disp_how how, struct disp_when * when, struct disp_hdl ** handle ); | 2626 enum disp_how how, struct disp_when * when, struct disp_hdl ** S_OUT(handle) ); |
2574 | 2627 |
2575 /* | 2628 /* |
2576 * FUNCTION: fd_disp_unregister | 2629 * FUNCTION: fd_disp_unregister |
2577 * | 2630 * |
2578 * PARAMETERS: | 2631 * PARAMETERS: |
2634 * RETURN VALUE : | 2687 * RETURN VALUE : |
2635 * 0 : The queue has been initialized successfully. | 2688 * 0 : The queue has been initialized successfully. |
2636 * EINVAL : The parameter is invalid. | 2689 * EINVAL : The parameter is invalid. |
2637 * ENOMEM : Not enough memory to complete the creation. | 2690 * ENOMEM : Not enough memory to complete the creation. |
2638 */ | 2691 */ |
2639 int fd_fifo_new ( struct fifo ** queue ); | 2692 int fd_fifo_new ( struct fifo ** S_OUT(queue) ); |
2640 | 2693 |
2641 /* | 2694 /* |
2642 * FUNCTION: fd_fifo_del | 2695 * FUNCTION: fd_fifo_del |
2643 * | 2696 * |
2644 * PARAMETERS: | 2697 * PARAMETERS: |
2755 * | 2808 * |
2756 * RETURN VALUE: | 2809 * RETURN VALUE: |
2757 * 0 : A new element has been retrieved. | 2810 * 0 : A new element has been retrieved. |
2758 * EINVAL : A parameter is invalid. | 2811 * EINVAL : A parameter is invalid. |
2759 */ | 2812 */ |
2760 int fd_fifo_get_int ( struct fifo * queue, void ** item ); | 2813 int fd_fifo_get_int ( struct fifo * queue, void ** S_OUT(item) ); |
2761 #define fd_fifo_get(queue, item) \ | 2814 #define fd_fifo_get(queue, item) \ |
2762 fd_fifo_get_int((queue), (void *)(item)) | 2815 fd_fifo_get_int((queue), (void *)(item)) |
2763 | 2816 |
2764 /* | 2817 /* |
2765 * FUNCTION: fd_fifo_tryget | 2818 * FUNCTION: fd_fifo_tryget |
2775 * RETURN VALUE: | 2828 * RETURN VALUE: |
2776 * 0 : A new element has been retrieved. | 2829 * 0 : A new element has been retrieved. |
2777 * EINVAL : A parameter is invalid. | 2830 * EINVAL : A parameter is invalid. |
2778 * EWOULDBLOCK : The queue was empty. | 2831 * EWOULDBLOCK : The queue was empty. |
2779 */ | 2832 */ |
2780 int fd_fifo_tryget_int ( struct fifo * queue, void ** item ); | 2833 int fd_fifo_tryget_int ( struct fifo * queue, void ** S_OUT(item) ); |
2781 #define fd_fifo_tryget(queue, item) \ | 2834 #define fd_fifo_tryget(queue, item) \ |
2782 fd_fifo_tryget_int((queue), (void *)(item)) | 2835 fd_fifo_tryget_int((queue), (void *)(item)) |
2783 | 2836 |
2784 /* | 2837 /* |
2785 * FUNCTION: fd_fifo_timedget | 2838 * FUNCTION: fd_fifo_timedget |
2797 * RETURN VALUE: | 2850 * RETURN VALUE: |
2798 * 0 : A new item has been retrieved. | 2851 * 0 : A new item has been retrieved. |
2799 * EINVAL : A parameter is invalid. | 2852 * EINVAL : A parameter is invalid. |
2800 * ETIMEDOUT : The time out has passed and no item has been received. | 2853 * ETIMEDOUT : The time out has passed and no item has been received. |
2801 */ | 2854 */ |
2802 int fd_fifo_timedget_int ( struct fifo * queue, void ** item, const struct timespec *abstime ); | 2855 int fd_fifo_timedget_int ( struct fifo * queue, void ** S_OUT(item), const struct timespec *abstime ); |
2803 #define fd_fifo_timedget(queue, item, abstime) \ | 2856 #define fd_fifo_timedget(queue, item, abstime) \ |
2804 fd_fifo_timedget_int((queue), (void *)(item), (abstime)) | 2857 fd_fifo_timedget_int((queue), (void *)(item), (abstime)) |
2805 | 2858 |
2806 /* Dump a fifo list and optionally its inner elements -- beware of deadlocks! */ | 2859 /* Dump a fifo list and optionally its inner elements -- beware of deadlocks! */ |
2807 void fd_fifo_dump(int level, char * name, struct fifo * queue, void (*dump_item)(int level, void * item)); | 2860 void fd_fifo_dump(int level, char * name, struct fifo * queue, void (*dump_item)(int level, void * item)); |