annotate include/freeDiameter/libfdcore.h @ 1540:407e0a889c7e

SCTP ConnectPeer: sctp_bindx() to local endpoints When connecting to an SCTP peer using sctp_connectx() with local addresses configured with ListenOn, bind to the ListenOn addresses using sctp_bindx() so that the SCTP INIT only contains the configured local addresses, matching what is advertised in the CER, and disable SCTP_AUTO_ASCONF. If no local addresses are configured with ListenOn, the previous behaviour of sctp_connectx() and enable SCTP_AUTO_ASCONF is used.
author Luke Mewburn <luke@mewburn.net>
date Fri, 01 May 2020 18:20:33 +1000
parents b09f1b4c9fad
children 566bb46cc73f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 717
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
1305
84a3c9c4b834 Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1304
diff changeset
5 * Copyright (c) 2016, WIDE Project and NICT *
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
36 #ifndef _LIBFDCORE_H
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
37 #define _LIBFDCORE_H
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39
904
b839a1b1c1da Make freeDiameter headers more C++ friendly -- thank you Thomas
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
40 #ifdef __cplusplus
b839a1b1c1da Make freeDiameter headers more C++ friendly -- thank you Thomas
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
41 extern "C" {
b839a1b1c1da Make freeDiameter headers more C++ friendly -- thank you Thomas
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
42 #endif
b839a1b1c1da Make freeDiameter headers more C++ friendly -- thank you Thomas
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
43
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
44 #include <freeDiameter/libfdproto.h>
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
45 #include <gnutls/gnutls.h>
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
46 #include <gnutls/x509.h>
1396
188c82b6690b Add ProcessingPeersPattern and ProcessingPeersMinimum parameters.
Thomas Klausner <tk@giga.or.at>
parents: 1329
diff changeset
47 #include <regex.h>
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
48
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
49 /* GNUTLS version */
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
50 #ifndef GNUTLS_VERSION
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
51 #define GNUTLS_VERSION LIBGNUTLS_VERSION
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
52 #endif /* GNUTLS_VERSION */
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
53
214
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
54 /* GNUTLS calls debug level */
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
55 #ifndef GNUTLS_DBG_LEVEL
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
56 #define GNUTLS_DBG_LEVEL ANNOYING
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
57 #endif /* GNUTLS_DBG_LEVEL */
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
58
805
fb5e0fd923ff Updated verification of the local certificate following GnuTLS 3.x guideline
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
59
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
60 /* Check the return value of a GNUTLS function, log and propagate */
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
61 #define CHECK_GNUTLS_GEN( faillevel, __call__, __fallback__ ) { \
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
62 CHECK_PRELUDE(__call__); \
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
63 if (__ret__ < 0) { \
1159
05f74dc19c49 Include source rev number in version information when available
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1155
diff changeset
64 LOG(faillevel, "TLS ERROR: in '%s' :\t%s", #__call__ , gnutls_strerror(__ret__)); \
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
65 __fallback__; \
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
66 } \
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
67 }
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
68
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
69 /* we use this macro to help debugging gnutls usage issues -- just change the content to display what you need */
214
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
70 #define GNUTLS_TRACE( __call__) { \
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
71 TRACE_CALL("Check: %s", #__call__ ); \
214
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
72 (__call__); \
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
73 }
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
74
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
75
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
76 #ifndef EXCLUDE_DEPRECATED
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
77 /* Macro for transition, replace with CHECK_GNUTLS_GEN */
1159
05f74dc19c49 Include source rev number in version information when available
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1155
diff changeset
78 #define CHECK_GNUTLS_DO( __call__, __fallback__ ) \
05f74dc19c49 Include source rev number in version information when available
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1155
diff changeset
79 CHECK_GNUTLS_GEN( FD_LOG_ERROR, __call__, __fallback__ )
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
80
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
81 #endif /* EXCLUDE_DEPRECATED */
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
82
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
83
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
84 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
85 /* INITIALIZATION */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
86 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
87
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
88
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
89 /* Initialize the libfdcore internals. This also initializes libfdproto */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
90 int fd_core_initialize(void);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
91
1159
05f74dc19c49 Include source rev number in version information when available
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1155
diff changeset
92 /* A string describing the version of the library */
05f74dc19c49 Include source rev number in version information when available
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1155
diff changeset
93 extern const char fd_core_version[];
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
94
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
95 /* Parse the freeDiameter.conf configuration file, load the extensions */
947
cce5d4bace82 Make config file parameter const and convert another fprintf to TRACE_DEBUG_ERROR.
Thomas Klausner <tk@giga.or.at>
parents: 904
diff changeset
96 int fd_core_parseconf(const char * conffile);
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
97
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
98 /* Start the server & client threads */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
99 int fd_core_start(void);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
100
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
101 /* Block until the framework has completed its initialization -- useful for extensions */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
102 int fd_core_waitstartcomplete(void);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
103
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
104 /* Initialize shutdown of the framework */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
105 int fd_core_shutdown(void);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
106
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
107 /* Wait for the shutdown to be complete -- this should always be called after fd_core_shutdown */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
108 int fd_core_wait_shutdown_complete(void);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
109
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
110
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
111 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
112 /* CONFIG */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
113 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
114
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
115 /* Structure to hold the configuration of the freeDiameter daemon */
640
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
116 #define EYEC_CONFIG 0xC011F16
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
117 struct fd_config {
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
118 int cnf_eyec; /* Eye catcher: EYEC_CONFIG */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
119
947
cce5d4bace82 Make config file parameter const and convert another fprintf to TRACE_DEBUG_ERROR.
Thomas Klausner <tk@giga.or.at>
parents: 904
diff changeset
120 const char *cnf_file; /* Configuration file to parse, default is DEFAULT_CONF_FILE */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
121
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
122 DiamId_t cnf_diamid; /* Diameter Identity of the local peer (FQDN -- ASCII) */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
123 size_t cnf_diamid_len;/* cached length of the previous string */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
124 DiamId_t cnf_diamrlm; /* Diameter realm of the local peer, default to realm part of cnf_diamid */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
125 size_t cnf_diamrlm_len;/* length of the previous string */
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
126
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
127 unsigned int cnf_timer_tc; /* The value in seconds of the default Tc timer */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
128 unsigned int cnf_timer_tw; /* The value in seconds of the default Tw timer */
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
129
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
130 uint16_t cnf_port; /* the local port for legacy Diameter (default: 3868) in host byte order */
1304
5a505af0bba0 Fix default secure port
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1301
diff changeset
131 uint16_t cnf_port_tls; /* the local port for Diameter/TLS (default: 5868) in host byte order */
1180
773498f59520 Preparing for future DTLS/SCTP support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1169
diff changeset
132 uint16_t cnf_port_3436; /* Open an additional server port to listen to old TLS/SCTP clients (RFC3436, freeDiameter versions < 1.2.0) */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
133 uint16_t cnf_sctp_str; /* default max number of streams for SCTP associations (def: 30) */
1122
d4371b7aa0ff New CMake option: ADDRESS_AVP_INCLUDE_PORT. Turn off for standard Host-IP-Address AVPs
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1120
diff changeset
134 struct fd_list cnf_endpoints; /* the local endpoints to bind the server to. list of struct fd_endpoint. default is empty (bind all). After servers are started, this is the actual list of endpoints including port information. */
1189
50bf33dc8fe0 Limit number of incoming connections under processing to configurable value
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1186
diff changeset
135 int cnf_thr_srv; /* Number of threads per servers handling the connection state machines */
1396
188c82b6690b Add ProcessingPeersPattern and ProcessingPeersMinimum parameters.
Thomas Klausner <tk@giga.or.at>
parents: 1329
diff changeset
136 int cnf_processing_peers_minimum; /* Number of processing peers that must be connected before other peers may connect */
188c82b6690b Add ProcessingPeersPattern and ProcessingPeersMinimum parameters.
Thomas Klausner <tk@giga.or.at>
parents: 1329
diff changeset
137 regex_t cnf_processing_peers_pattern_regex; /* Regex pattern for identifying processing peers */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
138 struct fd_list cnf_apps; /* Applications locally supported (except relay, see flags). Use fd_disp_app_support to add one. list of struct fd_app. */
253
ad6c0118fb50 Configurable number of server threads
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 214
diff changeset
139 uint16_t cnf_dispthr; /* Number of dispatch threads to create */
1397
239ba25870d8 Allow parametrizing the number of threads for routing in/out.
Thomas Klausner <tk@giga.or.at>
parents: 1396
diff changeset
140 uint16_t cnf_rtinthr; /* Number of routing in threads to create */
239ba25870d8 Allow parametrizing the number of threads for routing in/out.
Thomas Klausner <tk@giga.or.at>
parents: 1396
diff changeset
141 uint16_t cnf_rtoutthr; /* Number of routing out threads to create */
1326
afe0ecdb0692 Add config option if Route-Record AVPs should be added in Answers.
Thomas Klausner <tk@giga.or.at>
parents: 1305
diff changeset
142 uint16_t cnf_rr_in_answers; /* include Route-Record AVP in answers */
1397
239ba25870d8 Allow parametrizing the number of threads for routing in/out.
Thomas Klausner <tk@giga.or.at>
parents: 1396
diff changeset
143 int cnf_qin_limit; /* limit for incoming queue*/
239ba25870d8 Allow parametrizing the number of threads for routing in/out.
Thomas Klausner <tk@giga.or.at>
parents: 1396
diff changeset
144 int cnf_qout_limit; /* limit for outgoing queue */
239ba25870d8 Allow parametrizing the number of threads for routing in/out.
Thomas Klausner <tk@giga.or.at>
parents: 1396
diff changeset
145 int cnf_qlocal_limit; /* limit for local queue */
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
146 struct {
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
147 unsigned no_fwd : 1; /* the peer does not relay messages (0xffffff app id) */
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
148 unsigned no_ip4 : 1; /* disable IP */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
149 unsigned no_ip6 : 1; /* disable IPv6 */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
150 unsigned no_tcp : 1; /* disable use of TCP */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
151 unsigned no_sctp: 1; /* disable the use of SCTP */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
152 unsigned pr_tcp : 1; /* prefer TCP over SCTP */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
153 unsigned tls_alg: 1; /* TLS algorithm for initiated cnx. 0: separate port. 1: inband-security (old) */
1540
407e0a889c7e SCTP ConnectPeer: sctp_bindx() to local endpoints
Luke Mewburn <luke@mewburn.net>
parents: 1425
diff changeset
154 unsigned no_bind: 1; /* disable client bind to cnf_endpoints if non configured (bind all) */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
155 } cnf_flags;
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
156
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
157 struct {
1155
d00b5914351e Allow running freeDiameter without TLS credentials if the following conditions are verified:
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1136
diff changeset
158 int tls_disabled;
d00b5914351e Allow running freeDiameter without TLS credentials if the following conditions are verified:
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1136
diff changeset
159
18
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
160 /* Credentials parameters (backup) */
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
161 char * cert_file;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
162 char * key_file;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
163
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
164 char * ca_file;
142
dee0a871abcd Added number of CA certificates for debug
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 140
diff changeset
165 int ca_file_nr;
18
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
166 char * crl_file;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
167
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
168 char * prio_string;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
169 unsigned int dh_bits;
578
7c9a00bfd115 Allow TLS Diffie-Hellmann parameters to be loaded from a file (ticket #17)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 542
diff changeset
170 char * dh_file;
18
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
171
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
172 /* GNUTLS parameters */
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
173 gnutls_priority_t prio_cache;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
174 gnutls_dh_params_t dh_cache;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
175
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
176 /* GNUTLS server credential(s) */
805
fb5e0fd923ff Updated verification of the local certificate following GnuTLS 3.x guideline
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
177 gnutls_certificate_credentials_t credentials; /* contains local cert + trust anchors */
fb5e0fd923ff Updated verification of the local certificate following GnuTLS 3.x guideline
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
178 #ifdef GNUTLS_VERSION_300
fb5e0fd923ff Updated verification of the local certificate following GnuTLS 3.x guideline
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
179 gnutls_x509_trust_list_t trustlist; /* the logic to check local certificate has changed */
fb5e0fd923ff Updated verification of the local certificate following GnuTLS 3.x guideline
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
180 #endif /* GNUTLS_VERSION_300 */
18
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
181
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
182 } cnf_sec_data;
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
183
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
184 uint32_t cnf_orstateid; /* The value to use in Origin-State-Id, default to random value */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
185 struct dictionary *cnf_dict; /* pointer to the global dictionary */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
186 struct fifo *cnf_main_ev; /* events for the daemon's main (struct fd_event items) */
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
187 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
188 extern struct fd_config *fd_g_config; /* The pointer to access the global configuration, initalized in main */
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
189
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
190
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
191
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
192 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
193 /* PEERS */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
194 /*============================================================*/
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
195
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
196 /* States of a peer */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
197 enum peer_state {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
198 /* Stable states */
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
199 STATE_NEW = 0, /* The peer has been just been created, PSM thread not started yet */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
200 STATE_OPEN, /* Connexion established */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
201
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
202 /* Peer state machine */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
203 STATE_CLOSED, /* No connection established, will re-attempt after TcTimer. */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
204 STATE_CLOSING, /* the connection is being shutdown (DPR/DPA in progress) */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
205 STATE_WAITCNXACK, /* Attempting to establish transport-level connection */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
206 STATE_WAITCNXACK_ELEC, /* Received a CER from this same peer on an incoming connection (other peer object), while we were waiting for cnx ack */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
207 STATE_WAITCEA, /* Connection established, CER sent, waiting for CEA */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
208 /* STATE_WAITRETURNS_ELEC, */ /* This state is not stable and therefore deprecated:
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
209 We have sent a CER on our initiated connection, and received a CER from the remote peer on another connection. Election.
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
210 If we win the election, we must disconnect the initiated connection and send a CEA on the other => we go to OPEN state.
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
211 If we lose, we disconnect the other connection (receiver) and fallback to WAITCEA state. */
42
f4d94bc65e1f Some minor updates
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 38
diff changeset
212 STATE_OPEN_HANDSHAKE, /* TLS Handshake and validation are in progress in open state -- we use it only for debug purpose, it is never displayed */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
213
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
214 /* Failover state machine */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
215 STATE_SUSPECT, /* A DWR was sent and not answered within TwTime. Failover in progress. */
14
14cf6daf716d Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 13
diff changeset
216 STATE_REOPEN, /* Connection has been re-established, waiting for 3 DWR/DWA exchanges before putting back to service */
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
217
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
218 /* Ordering issues with multistream & state machine. -- see top of p_psm.c for explanation */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
219 STATE_OPEN_NEW, /* after CEA is sent, until a new message is received. Force ordering in this state */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
220 STATE_CLOSING_GRACE, /* after DPA is sent or received, give a short delay for messages in the pipe to be received. */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
221
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
222 /* Error state */
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
223 STATE_ZOMBIE /* The PSM thread is not running anymore; it must be re-started or peer should be deleted. */
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
224 #define STATE_MAX STATE_ZOMBIE
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
225 };
33
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
226 /* The following macro is called in freeDiameter/p_psm.c */
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
227 #define DECLARE_STATE_STR() \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
228 const char *peer_state_str[] = { \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
229 "STATE_NEW" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
230 , "STATE_OPEN" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
231 , "STATE_CLOSED" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
232 , "STATE_CLOSING" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
233 , "STATE_WAITCNXACK" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
234 , "STATE_WAITCNXACK_ELEC" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
235 , "STATE_WAITCEA" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
236 , "STATE_OPEN_HANDSHAKE" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
237 , "STATE_SUSPECT" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
238 , "STATE_REOPEN" \
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
239 , "STATE_OPEN_NEW" \
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
240 , "STATE_CLOSING_GRACE" \
33
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
241 , "STATE_ZOMBIE" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
242 };
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
243 extern const char *peer_state_str[];
12
418d2ce80dc8 Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 11
diff changeset
244 #define STATE_STR(state) \
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
245 (((unsigned)(state)) <= STATE_MAX ? peer_state_str[((unsigned)(state)) ] : "<Invalid>")
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
246
972
ce3cacbbccc9 Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 968
diff changeset
247 /* Constants for the peer_info structure below */
640
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
248 #define PI_P3_DEFAULT 0 /* Use any available protocol */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
249 #define PI_P3_IP 1 /* Use only IP to connect to this peer */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
250 #define PI_P3_IPv6 2 /* resp, IPv6 */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
251
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
252 #define PI_P4_DEFAULT 0 /* Attempt any available protocol */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
253 #define PI_P4_TCP 1 /* Only use TCP */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
254 #define PI_P4_SCTP 2 /* Only use SCTP */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
255
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
256 #define PI_ALGPREF_SCTP 0 /* SCTP is attempted first (default) */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
257 #define PI_ALGPREF_TCP 1 /* TCP is attempted first */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
258
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
259 #define PI_SEC_DEFAULT 0 /* New TLS security (handshake after connection, protecting also CER/CEA) */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
260 #define PI_SEC_NONE 1 /* Transparent security with this peer (IPsec) */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
261 #define PI_SEC_TLS_OLD 2 /* Old TLS security (use Inband-Security-Id AVP during CER/CEA) */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
262 /* Set sec = 3 to authorize use of (Inband-Security-Id == NONE) with this peer, sec = 2 only authorizing TLS */
1180
773498f59520 Preparing for future DTLS/SCTP support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1169
diff changeset
263
773498f59520 Preparing for future DTLS/SCTP support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1169
diff changeset
264 #define PI_SCTPSEC_DEF 0 /* Use DTLS over SCTP to connect to this peer (default) */
773498f59520 Preparing for future DTLS/SCTP support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1169
diff changeset
265 #define PI_SCTPSEC_3436 1 /* Use TLS over SCTP to connect to this peer (RFC3436) */
640
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
266
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
267 #define PI_EXP_NONE 0 /* the peer entry does not expire */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
268 #define PI_EXP_INACTIVE 1 /* the peer entry expires (i.e. is deleted) after pi_lft seconds without activity */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
269
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
270 #define PI_PRST_NONE 0 /* the peer entry is deleted after disconnection / error */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
271 #define PI_PRST_ALWAYS 1 /* the peer entry is persistant (will be kept as ZOMBIE in case of error) */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
272
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
273 /* Information about a remote peer */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
274 struct peer_info {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
275
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
276 DiamId_t pi_diamid; /* (supposedly) UTF-8, \0 terminated. The Diameter Identity of the remote peer. */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
277 size_t pi_diamidlen; /* cached length of pi_diamid */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
278
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
279 struct {
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
280 struct {
640
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
281 unsigned pro3 :2; /* PI_P3_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
282 unsigned pro4 :2; /* PI_P4_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
283 unsigned alg :1; /* PI_ALGPREF_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
284 unsigned sec :2; /* PI_SEC_* */
1180
773498f59520 Preparing for future DTLS/SCTP support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1169
diff changeset
285 unsigned sctpsec :1; /* PI_SCTPSEC_* */
640
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
286 unsigned exp :1; /* PI_EXP_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
287 unsigned persist :1; /* PI_PRST_* */
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
288
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
289 } pic_flags; /* Flags influencing the connection to the remote peer */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
290
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
291 DiamId_t pic_realm; /* If configured, the daemon will check the received realm in CER/CEA matches this. */
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
292 uint16_t pic_port; /* port to connect to. 0: default. */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
293
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
294 uint32_t pic_lft; /* lifetime of this peer when inactive (see pic_flags.exp definition) */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
295 int pic_tctimer; /* use this value for TcTimer instead of global, if != 0 */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
296 int pic_twtimer; /* use this value for TwTimer instead of global, if != 0 */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
297
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
298 char * pic_priority; /* Priority string for GnuTLS if we don't use the default */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
299
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
300 } config; /* Configured data (static for this peer entry) */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
301
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
302 struct {
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
303
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
304 /* enum peer_state pir_state; */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
305 /* Since 1.1.0, read the state with fd_peer_getstate(peer). */
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
306
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
307 DiamId_t pir_realm; /* The received realm in CER/CEA. */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
308 size_t pir_realmlen; /* length of the realm */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
309
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
310 uint32_t pir_vendorid; /* Content of the Vendor-Id AVP, or 0 by default */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
311 uint32_t pir_orstate; /* Origin-State-Id value */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
312 os0_t pir_prodname; /* copy of Product-Name AVP (\0 terminated) */
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
313 uint32_t pir_firmrev; /* Content of the Firmware-Revision AVP */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
314 int pir_relay; /* The remote peer advertized the relay application */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
315 struct fd_list pir_apps; /* applications advertised by the remote peer, except relay (pi_flags.relay) */
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
316 int pir_isi; /* Inband-Security-Id advertised (PI_SEC_* bits) */
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
317
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 43
diff changeset
318 uint32_t pir_lastDC; /* The last Disconnect-Cause value received */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 43
diff changeset
319
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
320 int pir_proto; /* The L4 protocol currently used with the peer (IPPROTO_TCP or IPPROTO_SCTP) */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
321 const gnutls_datum_t *pir_cert_list; /* The (valid) credentials that the peer has presented, or NULL if TLS is not used */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
322 /* This is inspired from http://www.gnu.org/software/gnutls/manual/gnutls.html#ex_003ax509_002dinfo
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
323 see there for example of using this data */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
324 unsigned int pir_cert_list_size; /* Number of certificates in the list */
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
325
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
326 } runtime; /* Data populated after connection, may change between 2 connections -- not used by fd_peer_add */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
327
13
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
328 struct fd_list pi_endpoints; /* Endpoint(s) of the remote peer (configured, discovered, or advertized). list of struct fd_endpoint. DNS resolved if empty. */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
329 };
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
330
454
f1484823cb4a Small hack which might spear some concurrency problems and is quite harmless
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 447
diff changeset
331
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
332 struct peer_hdr {
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
333 struct fd_list chain; /* Link into the list of all the peers, ordered by their Diameter Id (fd_os_cmp) */
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
334 struct peer_info info; /* The public data */
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
335
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
336 /* This header is followed by more data in the private peer structure definition */
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
337 };
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
338
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
339 /* the global list of peers.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
340 Since we are not expecting so many connections, we don't use a hash, but it might be changed.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
341 The list items are peer_hdr structures (actually, fd_peer, but the cast is OK) */
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
342 extern struct fd_list fd_g_peers;
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
343 extern pthread_rwlock_t fd_g_peers_rw; /* protect the list */
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
344
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
345 /*
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
346 * FUNCTION: fd_peer_add
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
347 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
348 * PARAMETERS:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
349 * info : Information to create the peer.
12
418d2ce80dc8 Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 11
diff changeset
350 * orig_dbg : A string indicating the origin of the peer information, for debug (ex: conf, redirect, ...)
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
351 * cb : optional, a callback to call (once) when the peer connection is established or failed
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
352 * cb_data : opaque data to pass to the callback.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
353 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
354 * DESCRIPTION:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
355 * Add a peer to the list of peers to which the daemon must maintain a connexion.
13
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
356 *
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
357 * The content of info parameter is copied, except for the list of endpoints if
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
358 * not empty, which is simply moved into the created object. It means that the list
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
359 * items must have been malloc'd, so that they can be freed.
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
360 *
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
361 * If cb is not null, the callback is called when the connection is in OPEN state or
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
362 * when an error has occurred. The callback should use the pi_state information to
13
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
363 * determine which one it is. If the first parameter of the called callback is NULL, it
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
364 * means that the peer is being destroyed before attempt success / failure.
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
365 * cb is called to allow freeing cb_data in * this case.
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
366 *
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
367 * The orig_dbg string is only useful for easing debug, and can be left to NULL.
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
368 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
369 * RETURN VALUE:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
370 * 0 : The peer is added.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
371 * EINVAL : A parameter is invalid.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
372 * EEXIST : A peer with the same Diameter-Id is already in the list.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
373 * (other standard errors may be returned, too, with their standard meaning. Example:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
374 * ENOMEM : Memory allocation for the new object element failed.)
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
375 */
947
cce5d4bace82 Make config file parameter const and convert another fprintf to TRACE_DEBUG_ERROR.
Thomas Klausner <tk@giga.or.at>
parents: 904
diff changeset
376 int fd_peer_add ( struct peer_info * info, const char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data );
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
377
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
378 /*
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
379 * FUNCTION: fd_peer_getbyid
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
380 *
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
381 * PARAMETERS:
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
382 * diamid : an UTF8 string describing the diameter Id of the peer to seek
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
383 * diamidlen : length of the diamid
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
384 * igncase : perform an almost-case-insensitive search? (slower)
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
385 * peer : The peer is stored here if it exists.
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
386 *
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
387 * DESCRIPTION:
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
388 * Search a peer by its Diameter-Id.
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
389 *
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
390 * RETURN VALUE:
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
391 * 0 : *peer has been updated (to NULL if the peer is not found).
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
392 * !0 : An error occurred.
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
393 */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
394 int fd_peer_getbyid( DiamId_t diamid, size_t diamidlen, int igncase, struct peer_hdr ** peer );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
395
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
396 /*
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
397 * FUNCTION: fd_peer_get_state
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
398 *
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
399 * PARAMETERS:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
400 * peer : The peer which state to read
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
401 *
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
402 * DESCRIPTION:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
403 * Returns the current state of the peer.
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
404 *
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
405 * RETURN VALUE:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
406 * -1 : peer is invalid
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
407 * >=0 : the state of the peer at the time of reading.
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
408 */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
409 int fd_peer_get_state(struct peer_hdr *peer);
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
410
939
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
411 /*
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
412 * FUNCTION: fd_peer_cnx_proto_info
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
413 *
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
414 * PARAMETERS:
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
415 * peer : The peer which information to be read
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
416 * buf : Where to store the protocol information
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
417 * len : available space in bug
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
418 *
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
419 * DESCRIPTION:
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
420 * Creates a string describing the current connection to this peer, e.g.: "TCP,TLS,soc#3".
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
421 *
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
422 * RETURN VALUE:
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
423 * 0 : buffer was written
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
424 * >=0 : error code.
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
425 */
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
426 int fd_peer_cnx_proto_info(struct peer_hdr *peer, char * buf, size_t len);
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
427
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1180
diff changeset
428 /*
939
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
429 * FUNCTION: fd_peer_get_load_pending
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
430 *
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
431 * PARAMETERS:
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
432 * peer : The peer which load to read
1010
357c2f892d24 Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1008
diff changeset
433 * to_receive : (out) number of requests sent to this peer without matching answer yet.
357c2f892d24 Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1008
diff changeset
434 * to_send : (out) number of requests received from this peer and not yet answered.
939
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
435 *
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
436 * DESCRIPTION:
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
437 * Returns the current number of requests sent to this peer
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
438 * that have not been answered yet. This is an empirical indication
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
439 * of the workload of this peer.
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
440 *
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
441 * RETURN VALUE:
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
442 * 0 : The load parameter has been updated. (it should have a positive value always)
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
443 * !0 : An error occurred
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
444 */
1010
357c2f892d24 Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1008
diff changeset
445 int fd_peer_get_load_pending(struct peer_hdr *peer, long * to_receive, long * to_send);
939
1bc052ef961f Add a function to access this counter
Sebastien Decugis <sdecugis@freediameter.net>
parents: 904
diff changeset
446
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
447 /*
162
79768bf7d208 Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 142
diff changeset
448 * FUNCTION: fd_peer_validate_register
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
449 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
450 * PARAMETERS:
972
ce3cacbbccc9 Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 968
diff changeset
451 * peer_validate : Callback as defined below.
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
452 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
453 * DESCRIPTION:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
454 * Add a callback to authorize / reject incoming peer connections.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
455 * All registered callbacks are called until a callback sets auth = -1 or auth = 1.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
456 * If no callback returns a clear decision, the default behavior is applied (reject unknown connections)
33
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
457 * The callbacks are called in FILO order of their registration.
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
458 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
459 * RETURN VALUE:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
460 * 0 : The callback is added.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
461 * !0 : An error occurred.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
462 */
20
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
463 int fd_peer_validate_register ( int (*peer_validate)(struct peer_info * /* info */, int * /* auth */, int (**cb2)(struct peer_info *)) );
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
464 /*
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
465 * CALLBACK: peer_validate
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
466 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
467 * PARAMETERS:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
468 * info : Structure containing information about the peer attempting the connection.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
469 * auth : Store there the result if the peer is accepted (1), rejected (-1), or unknown (0).
20
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
470 * cb2 : If != NULL and in case of PI_SEC_TLS_OLD, another callback to call after handshake (if auth = 1).
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
471 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
472 * DESCRIPTION:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
473 * This callback is called when a new connection is being established from an unknown peer,
20
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
474 * after the CER is received. An extension must register such callback with peer_validate_register.
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
475 *
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
476 * The callback can learn if the peer has sent Inband-Security-Id AVPs in runtime.pir_isi fields.
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
477 * It can also learn if a handshake has already been performed in runtime.pir_cert_list field.
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
478 * The callback must set the value of config.pic_flags.sec appropriately to allow a connection without TLS.
20
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
479 *
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
480 * If the old TLS mechanism is used,
20
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
481 * the extension may also need to check the credentials provided during the TLS
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
482 * exchange (remote certificate). For this purpose, it may set the address of a new callback
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
483 * to be called once the handshake is completed. This new callback receives the information
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
484 * structure as parameter (with pir_cert_list set) and returns 0 if the credentials are correct,
20
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
485 * or an error code otherwise. If the error code is received, the connection is closed and the
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
486 * peer is destroyed.
162
79768bf7d208 Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 142
diff changeset
487 * Note that freeDiameter already achieves some usual checks. The callback may be used to enforce
79768bf7d208 Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 142
diff changeset
488 * additional restrictions.
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
489 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
490 * RETURN VALUE:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
491 * 0 : The authorization decision has been written in the location pointed by auth.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
492 * !0 : An error occurred.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
493 */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
494
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
495
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
496
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
497 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
498 /* MESSAGES */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
499 /*============================================================*/
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
500
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
501 /*
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
502 * FUNCTION: fd_msg_send, fd_msg_send_timeout
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
503 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
504 * PARAMETERS:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
505 * pmsg : Location of the message to be sent on the network (set to NULL on function return to avoid double deletion).
1014
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
506 * anscb : A callback to be called when corresponding answer is received, when sending a request (not used with answers)
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
507 * anscb_data : opaque data to be passed back to the anscb (or expirecb) when it is called.
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
508 * expirecb : (only for fd_msg_send_timeout) If the request did not get an answer before timeout, this callback is called.
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
509 * timeout : (only for fd_msg_send_timeout) sets the absolute time until when to wait for an answer. Past this time,
1014
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
510 * the expirecb is called with the request and the answer will be discarded if received later.
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
511 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
512 * DESCRIPTION:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
513 * Sends a message on the network. (actually simply queues it in a global queue, to be picked by a daemon's thread)
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
514 * For requests, the end-to-end id must be set (see fd_msg_get_eteid / MSGFL_ALLOC_ETEID).
1014
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
515 * For answers, the message must be created with function fd_msg_new_answer_from_req.
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
516 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
517 * The routing module will handle sending to the correct peer, usually based on the Destination-Realm / Destination-Host AVP.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
518 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
519 * If the msg is a request, there are two ways of receiving the answer:
93
3910804c84db Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 89
diff changeset
520 * - either having registered a callback in the dispatch module (see fd_disp_register)
1014
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
521 * - or provide a anscb callback here. If such callback is provided, it is called before the dispatch callbacks.
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
522 * The prototype for this anscb callback function is:
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
523 * void anscb(void * data, struct msg ** answer)
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
524 * where:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
525 * data : opaque data that was registered along with the callback.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
526 * answer : location of the pointer to the answer.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
527 * note1: on function return, if *answer is not NULL, the message is passed to the dispatch module for regular callbacks.
336
5d1a22bb1cfe Removed some references to waaad
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
528 * otherwise, the callback must take care of freeing the message (fd_msg_free).
5d1a22bb1cfe Removed some references to waaad
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
529 * note2: the opaque data is not freed by the daemon in any case, extensions should ensure clean handling in fd_ext_fini.
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
530 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
531 * If no callback is registered to handle an answer, the message is discarded and an error is logged.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
532 *
1014
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
533 * fd_msg_send_timeout is similar to fd_msg_send, except that it takes two additional arguments "expirecb" and "timeout".
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
534 * If the message parameter is an answer, there is no difference with fd_msg_send.
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
535 * Otherwise, if the corresponding answer (or error) is received before the timeout date elapses, everything occurs as with fd_msg_send.
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
536 * Otherwise, the request is removed from the queue (meaning the matching answer will be discarded upon reception) and passed to the expirecb
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
537 * function. Upon return, if the *msg parameter is not NULL, it is freed (not passed to other callbacks).
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
538 * expirecb is called in a dedicated thread.
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
539 *
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
540 * The prototype for the expirecb callback function is:
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
541 * void expirecb(void * data, struct peer_hdr * sentto, struct msg ** request)
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
542 * where:
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
543 * data : opaque data that was registered along with the callback.
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
544 * sentto : pointer to the peer to which the message was sent and no answer received within timeout.
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
545 * request: location of the pointer to the request that was not answered.
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
546 *
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
547 * RETURN VALUE:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
548 * 0 : The message has been queued for sending (sending may fail asynchronously).
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
549 * EINVAL : A parameter is invalid (ex: anscb provided but message is not a request).
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
550 * ...
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
551 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
552 int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data );
1014
908ffbb81f60 Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1010
diff changeset
553 int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
554
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
555 /*
1425
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
556 * FUNCTION: fd_msg_add_result
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
557 *
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
558 * PARAMETERS:
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
559 * msg : A msg object -- it must be an answer.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
560 * vendor : Vendor. If 0, add Result-Code else add Experimental-Result.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
561 * restype : DICT_TYPE containing rescode (ex: from TYPE_BY_NAME "Enumerated(Result-Code)").
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
562 * rescode : The name of the returned error code (ex: "DIAMETER_INVALID_AVP").
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
563 * errormsg : (optional) human-readable error message to put in Error-Message AVP.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
564 * optavp : (optional) If provided, the content will be put inside a Failed-AVP.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
565 * type_id : 0 => nothing; 1 => adds Origin-Host and Origin-Realm with local info. 2=> adds Error-Reporting-Host.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
566 *
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
567 * DESCRIPTION:
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
568 * This function adds a Result-Code AVP (if vendor is 0) or Experimental-Result AVP (vendor is not 0)
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
569 * to a message, and optionally
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
570 * - sets the 'E' error flag in the header,
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
571 * - adds Error-Message, Error-Reporting-Host and Failed-AVP AVPs.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
572 *
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
573 * RETURN VALUE:
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
574 * 0 : Operation complete.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
575 * !0 : an error occurred.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
576 */
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
577 int fd_msg_add_result( struct msg * msg, vendor_id_t vendor, struct dict_object * restype, char * rescode, char * errormsg, struct avp * optavp, int type_id );
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
578
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
579 /*
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
580 * FUNCTION: fd_msg_rescode_set
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
581 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
582 * PARAMETERS:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
583 * msg : A msg object -- it must be an answer.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
584 * rescode : The name of the returned error code (ex: "DIAMETER_INVALID_AVP")
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
585 * errormsg : (optional) human-readable error message to put in Error-Message AVP
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
586 * optavp : (optional) If provided, the content will be put inside a Failed-AVP
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
587 * type_id : 0 => nothing; 1 => adds Origin-Host and Origin-Realm with local info. 2=> adds Error-Reporting-Host.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
588 *
1425
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
589 * DESCRIPTION:
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
590 * This function adds a Result-Code AVP to a message, and optionally
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
591 * - sets the 'E' error flag in the header,
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
592 * - adds Error-Message, Error-Reporting-Host and Failed-AVP AVPs.
1425
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
593 * Uses fd_msg_add_result with vendor 0 and restype for Enumerated(Result-Code).
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
594 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
595 * RETURN VALUE:
1425
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
596 * 0 : Operation complete.
b09f1b4c9fad fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents: 1397
diff changeset
597 * !0 : an error occurred.
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
598 */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
599 int fd_msg_rescode_set( struct msg * msg, char * rescode, char * errormsg, struct avp * optavp, int type_id );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
600
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
601 /* Add Origin-Host, Origin-Realm, (if osi) Origin-State-Id AVPS at the end of the message */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
602 int fd_msg_add_origin ( struct msg * msg, int osi );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
603
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
604 /* Generate a new Session-Id and add it at the beginning of the message (opt is added at the end of the sid if provided) */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
605 int fd_msg_new_session( struct msg * msg, os0_t opt, size_t optlen );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
606
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
607
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
608 /* Parse a message against our dictionary,
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
609 return 0 in case of success.
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
610 log parsing error & return error code in case of failure in parsing.
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
611 In addition, if the error code is EBADMSG (the message does not follow our dictionary)
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
612 if *msg was a request, *msg is NULL and *error contains the error message ready to send back on return
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
613 if *msg was an answer, *msg is untouched and *error==*msg if *msg was an error message, *error is null otherwise */
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
614 int fd_msg_parse_or_error( struct msg ** msg, struct msg **error );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
615
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
616
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
617
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
618
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
619 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
620 /* DISPATCH */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
621 /*============================================================*/
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
622
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
623 /*
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
624 * FUNCTION: fd_disp_app_support
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
625 *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
626 * PARAMETERS:
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
627 * app : The dictionary object corresponding to the Application.
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
628 * vendor : (Optional) the dictionary object of a Vendor to claim support in Vendor-Specific-Application-Id
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
629 * auth : Support auth app part.
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
630 * acct : Support acct app part.
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
631 *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
632 * DESCRIPTION:
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
633 * Registers an application to be advertized in CER/CEA exchanges.
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
634 * Messages with an application-id matching a registered value are passed to the dispatch module,
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
635 * while other messages are simply relayed or an error is returned (if local node does not relay)
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
636 *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
637 * RETURN VALUE:
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
638 * 0 : The application support is registered.
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
639 * EINVAL : A parameter is invalid.
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
640 */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
641 int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int auth, int acct );
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
642
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
643 /* Note: if we want to support capabilities updates, we'll have to add possibility to remove an app as well... */
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
644
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
645
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
646 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
647 /* ROUTING */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
648 /*============================================================*/
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
649
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
650 /* This file contains the definitions of types and functions involved in the routing decisions in freeDiameter,
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
651 * and that can be called by extensions.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
652 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
653 * Three different type of messages must be distinguished:
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
654 * - Messages received, and the peer is final recipient (IN messages)
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
655 * - Messages received, and the peer is not final recipient (FWD messages)
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
656 * - Message is locally generated (OUT messages)
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
657 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
658 * There are three global message queues (in queues.c) and also peers-specific queues (in struct fd_peer).
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
659 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
660 * (*) IN messages processing details:
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
661 * - the message is received from the remote peer, a FDEVP_CNX_MSG_RECV event is generated for the peer.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
662 * - the PSM thread parses the buffer, does some verifications, handles non routable messages (fd_msg_is_routable)
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
663 * - routable messages are queued in the fd_g_incoming global queue.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
664 * - a thread (routing-in) picks the message and takes the decision if it is handled locally or forwarded,
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
665 * based on local capabilities (registered by extensions with fd_disp_app_support).
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
666 * - If the message is handled locally, it is queued in fd_g_local.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
667 * - Another thread (dispatch.c) will handle this message and pass it to registered callbacks (see fd_disp_register in libfreeDiameter.h).
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
668 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
669 * (*) FWD messages details:
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
670 * - The process is the same as for IN messages, until the routing-in threads makes its decision that the message is not handled locally.
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
671 * - If the local peer does not relay message, an error DIAMETER_APPLICATION_UNSUPPORTED is returned.
972
ce3cacbbccc9 Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 968
diff changeset
672 * - All callbacks registered with fd_rt_fwd_register are called for the message (see below).
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
673 * - these callbacks will typically do proxying work. Note that adding the route-record is handled by the daemon.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
674 * - Once all callbacks have been called, the message is queued in the global fd_g_outgoing queue.
972
ce3cacbbccc9 Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 968
diff changeset
675 * - The remaining processing is the same as for OUT messages, as described below.
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
676 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
677 * (*) OUT messages details:
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
678 * - The message are picked from fd_g_outgoing (they are queued there as result of forwarding process or call to fd_msg_send.)
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
679 * - The (routing-out) thread builds a list of possible destinations for the message, as follow:
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
680 * - create a list of all known peers in the "OPEN" state.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
681 * - remove from that list all peers that are in a Route-Record AVP of the message, to avoid routing loops.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
682 * - remove also all peers that have previously replied an error message for this message.
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
683 * - If the list is empty, create an error UNABLE_TO_DELIVER (note: should we trig dynamic discovery here???) and reply.
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
684 * - Otherwise, call all callbacks registered by function fd_rt_out_register, with the list of peers and the message.
972
ce3cacbbccc9 Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 968
diff changeset
685 * - Order the resulting list of peers by score (see below), and sent the message to the peer with highest (positive) score.
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
686 * - in case the peer is no longer in the "OPEN" state, send the message to the second peer in the list.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
687 * - if no peer is in OPEN state anymore, restart the process of creating the list.
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
688 * - Once a peer has been selected, the message is queued into that peer's outgoing queue.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
689 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
690 * The following functions allow an extension to register or remove a callback as described above.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
691 */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
692
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
693 /********** Forwarding callbacks: for Proxy operations ***********/
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
694
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
695 /* Handle to registered callback */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
696 struct fd_rt_fwd_hdl;
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
697
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
698 /* Message direction for the callback */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
699 enum fd_rt_fwd_dir {
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
700 RT_FWD_REQ = 1, /* The callback will be called on forwarded requests only */
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
701 RT_FWD_ALL = 2, /* The callback will be called on all forwarded messages (requests and answers )*/
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
702 RT_FWD_ANS = 3 /* The callback will be called on answers and errors only */
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
703 };
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
704
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
705 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
706 * FUNCTION: fd_rt_fwd_register
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
707 *
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
708 * PARAMETERS:
972
ce3cacbbccc9 Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 968
diff changeset
709 * rt_fwd_cb : The callback function to register (see prototype below).
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
710 * cbdata : Pointer to pass to the callback when it is called. The data is opaque to the daemon.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
711 * dir : One of the RT_FWD_* directions defined above.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
712 * handler : On success, a handler to the registered callback is stored here.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
713 * This handler will be used to unregister the cb.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
714 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
715 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
716 * Register a new callback for forwarded messages. See explanations above.
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
717 * Note that there is no guaranteed order for the callbacks calls.
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
718 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
719 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
720 * 0 : The callback is registered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
721 * EINVAL : A parameter is invalid.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
722 * ENOMEM : Not enough memory to complete the operation
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
723 */
620
bc7328e600f0 Removed the OUTPUT specification for SWIG, too complex
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 618
diff changeset
724 int fd_rt_fwd_register ( int (*rt_fwd_cb)(void * cbdata, struct msg ** msg), void * cbdata, enum fd_rt_fwd_dir dir, struct fd_rt_fwd_hdl ** handler );
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
725 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
726 * CALLBACK: rt_fwd_cb
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
727 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
728 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
729 * data : pointer to some data that was passed when the callback was registered (optional).
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
730 * msg : The message that is being forwarded.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
731 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
732 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
733 * This callback is called when a message is forwarded to another peer. It may for example add a Proxy-Info AVP.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
734 * The callback may also choose to handle the message in a more complex form. In that case, it must set *msg = NULL
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
735 * and handle it differently. In such case, the forwarding thread will stop processing this message.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
736 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
737 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
738 * 0 : Operation complete.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
739 * !0 : An error occurred -- will result in daemon's termination.
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
740 */
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
741
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
742 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
743 * FUNCTION: fd_rt_fwd_unregister
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
744 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
745 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
746 * handler : The handler of the callback that must be unregistered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
747 * cbdata : Will receive the data registered with the callback, that can be freed if needed.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
748 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
749 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
750 * Removes a callback from the list of registered callbacks.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
751 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
752 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
753 * 0 : The callback is unregistered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
754 * EINVAL : A parameter is invalid.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
755 */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
756 int fd_rt_fwd_unregister ( struct fd_rt_fwd_hdl * handler, void ** cbdata );
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
757
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
758
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
759 /********** Out callbacks: for next hop routing decision operations ***********/
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
760
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
761 /* Handle to registered callback */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
762 struct fd_rt_out_hdl;
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
763
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
764 enum fd_rt_out_score {
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
765 FD_SCORE_NO_DELIVERY = -70, /* We should not send this message to this candidate */
717
571b3abaa5df Support for Diameter Redirects through rt_redirect.fdx extension (EXPERIMENTAL)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 706
diff changeset
766 FD_SCORE_SENT_REDIRECT = -60, /* If this peer previously sent a Redirect indication that applies to this message */
124
cc42d8607114 Completed cleanups of queues when the daemon is stopping
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 105
diff changeset
767 FD_SCORE_INI = -2, /* All candidates are initialized with this value */
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
768 FD_SCORE_LOAD_BALANCE = 1, /* Use this to differentiate between several peers with the same score */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
769 FD_SCORE_DEFAULT = 5, /* The peer is a default route for all messages */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
770 FD_SCORE_DEFAULT_REALM = 10, /* The peer is a default route for this realm */
89
3f8b437bcb66 Added some default routing handlers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 87
diff changeset
771 FD_SCORE_REALM = 15, /* The peer belongs to Destination-Realm of the message */
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
772 FD_SCORE_REDIR_HOST = 25, /* If there is a redirect rule with ALL_HOST for these message and peer */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
773 FD_SCORE_REDIR_APP = 30, /* If there is a redirect rule with ALL_APPLICATION for these message and peer */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
774 FD_SCORE_REDIR_REALM = 35, /* If there is a redirect rule with ALL_REALM for these message and peer */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
775 FD_SCORE_REDIR_REALM_APP = 40, /* If there is a redirect rule with REALM_AND_APPLICATION for these message and peer */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
776 FD_SCORE_REDIR_USER = 45, /* If there is a redirect rule with ALL_USER for these message and peer */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
777 FD_SCORE_REDIR_SESSION = 50, /* If there is a redirect rule with ALL_SESSION for these message and peer */
717
571b3abaa5df Support for Diameter Redirects through rt_redirect.fdx extension (EXPERIMENTAL)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 706
diff changeset
778 FD_SCORE_REDIR_ONCE = 55, /* If there is a redirect rule with DONT_CACHE for these message and peer */
89
3f8b437bcb66 Added some default routing handlers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 87
diff changeset
779 FD_SCORE_FINALDEST = 100 /* If the peer is the final recipient of the message (i.e. matching Destination-Host), it receives a big score. */
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
780 };
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
781
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
782 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
783 * FUNCTION: fd_rt_out_register
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
784 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
785 * PARAMETERS:
972
ce3cacbbccc9 Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 968
diff changeset
786 * rt_out_cb : The callback function to register (see prototype below).
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
787 * cbdata : Pointer to pass to the callback when it is called. The data is opaque to the daemon.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
788 * priority : Order for calling this callback. The callbacks are called in reverse priority order (higher priority = called sooner).
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
789 * handler : On success, a handler to the registered callback is stored here.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
790 * This handler will be used to unregister the cb.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
791 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
792 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
793 * Register a new callback to handle OUT routing decisions. See explanations above.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
794 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
795 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
796 * 0 : The callback is registered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
797 * EINVAL : A parameter is invalid.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
798 * ENOMEM : Not enough memory to complete the operation
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
799 */
1216
581bbd48524a Change prototype of rt_out callbacks to allow disposal of messages
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1194
diff changeset
800 int fd_rt_out_register ( int (*rt_out_cb)(void * cbdata, struct msg ** pmsg, struct fd_list * candidates), void * cbdata, int priority, struct fd_rt_out_hdl ** handler );
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
801 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
802 * CALLBACK: rt_out_cb
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
803 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
804 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
805 * cbdata : pointer to some data that was registered with the callback.
1216
581bbd48524a Change prototype of rt_out callbacks to allow disposal of messages
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1194
diff changeset
806 * pmsg : pointer to the message that must be sent. upon return if *msg is NULL, the processing stops and the message is not sent.
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
807 * list : The list of peers to which the message may be sent to, as returned by fd_rtd_candidate_extract
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
808 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
809 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
810 * This callback must attribute a score (preferably from FD_SCORE_*) to each candidate peer in the list.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
811 * Once all registered callbacks have been called, the message is sent to the candidate with the highest score.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
812 * Note that each callback must *add* its locally-attributed score to the candidate current "score" parameter, not replace it!
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
813 * Note also that this callback must be re-entrant since it may be called by several threads at the same time
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
814 * (for different messages)
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
815 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
816 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
817 * 0 : Operation complete.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
818 * !0 : An error occurred.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
819 */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
820
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
821 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
822 * FUNCTION: fd_rt_out_unregister
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
823 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
824 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
825 * handler : The handler of the callback that must be unregistered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
826 * cbdata : Will receive the data registered with the callback, that can be freed if needed.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
827 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
828 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
829 * Removes a callback from the list of registered callbacks.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
830 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
831 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
832 * 0 : The callback is unregistered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
833 * EINVAL : A parameter is invalid.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
834 */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
835 int fd_rt_out_unregister ( struct fd_rt_out_hdl * handler, void ** cbdata );
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
836
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
837
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
838 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
839 /* EVENTS */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
840 /*============================================================*/
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
841
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
842 struct fd_event {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
843 int code; /* codespace depends on the queue */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
844 size_t size;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
845 void *data;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
846 };
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
847
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
848 /* Daemon's codespace: 1000->1999 (1500->1999 defined in fdcore-internal.h) */
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
849 enum {
1190
6a1042d8075b Replace FDEV_TERMINATE events with calls to fd_core_shutdown to handle the core state properly
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1189
diff changeset
850 FDEV_TERMINATE_INT= 1000 /* request to terminate. DO NOT USE. Use fd_core_shutdown() instead. */
6a1042d8075b Replace FDEV_TERMINATE events with calls to fd_core_shutdown to handle the core state properly
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1189
diff changeset
851 ,FDEV_TRIGGER /* Trigger available for extensions. size is sizeof(int), data is int * */
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
852 };
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
853
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
854 int fd_event_send(struct fifo *queue, int code, size_t datasz, void * data);
620
bc7328e600f0 Removed the OUTPUT specification for SWIG, too complex
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 618
diff changeset
855 int fd_event_get(struct fifo *queue, int * code, size_t * datasz, void ** data);
bc7328e600f0 Removed the OUTPUT specification for SWIG, too complex
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 618
diff changeset
856 int fd_event_timedget(struct fifo *queue, struct timespec * timeout, int timeoutcode, int * code, size_t * datasz, void ** data);
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
857 void fd_event_destroy(struct fifo **queue, void (*free_cb)(void * data));
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
858 const char * fd_ev_str(int event);
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
859
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
860 /* for extensions */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
861 int fd_event_trig_regcb(int trigger_val, const char * module, void (*cb)(void));
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
862
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1085
diff changeset
863 #ifndef SWIG
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
864 DECLARE_FD_DUMP_PROTOTYPE(fd_event_trig_dump);
628
e1c6f45f5fcd Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 621
diff changeset
865
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
866 /* The "old" FD_EV_DUMP_* events are replaced with direct calls to the following dump functions */
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
867 DECLARE_FD_DUMP_PROTOTYPE(fd_conf_dump);
1220
cec3e9b579e1 Cleanup parameter that has become useless
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1216
diff changeset
868
cec3e9b579e1 Cleanup parameter that has become useless
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1216
diff changeset
869 DECLARE_FD_DUMP_PROTOTYPE(fd_ext_dump);
1169
11724ff78638 Some cleanups in dbg_interactive extension
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1164
diff changeset
870 #else /* SWIG */
11724ff78638 Some cleanups in dbg_interactive extension
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1164
diff changeset
871 DECLARE_FD_DUMP_PROTOTYPE_simple(fd_event_trig_dump);
11724ff78638 Some cleanups in dbg_interactive extension
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1164
diff changeset
872 DECLARE_FD_DUMP_PROTOTYPE_simple(fd_conf_dump);
1220
cec3e9b579e1 Cleanup parameter that has become useless
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1216
diff changeset
873 DECLARE_FD_DUMP_PROTOTYPE_simple(fd_ext_dump);
1169
11724ff78638 Some cleanups in dbg_interactive extension
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1164
diff changeset
874 #endif /* SWIG */
1113
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
875 DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump, int details);
1085
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
876 DECLARE_FD_DUMP_PROTOTYPE(fd_peer_dump_list, int details);
7d7266115a34 Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1077
diff changeset
877 DECLARE_FD_DUMP_PROTOTYPE(fd_peer_dump, struct peer_hdr * p, int details);
628
e1c6f45f5fcd Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 621
diff changeset
878
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
879 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
880 /* ENDPOINTS */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
881 /*============================================================*/
24
bd83ce9328ed Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 23
diff changeset
882
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
883 struct fd_endpoint {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
884 struct fd_list chain; /* link in cnf_endpoints list */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
885
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
886 union {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
887 sSS ss; /* the socket information. List is always ordered by ss value (memcmp) -- see fd_ep_add_merge */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
888 sSA4 sin;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
889 sSA6 sin6;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
890 sSA sa;
621
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
891 }
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
892 #ifdef SWIG /* nested anonymous unions are not supported yet */
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
893 s
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
894 #endif /* SWIG */
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
895 ;
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
896
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
897 #define EP_FL_CONF (1 << 0) /* This endpoint is statically configured in a configuration file */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
898 #define EP_FL_DISC (1 << 1) /* This endpoint was resolved from the Diameter Identity or other DNS query */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
899 #define EP_FL_ADV (1 << 2) /* This endpoint was advertized in Diameter CER/CEA exchange */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
900 #define EP_FL_LL (1 << 3) /* Lower layer mechanism provided this endpoint */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
901 #define EP_FL_PRIMARY (1 << 4) /* This endpoint is primary in a multihomed SCTP association */
140
34e47f4addf8 Fix broken test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 124
diff changeset
902 #define EP_ACCEPTALL (1 << 15) /* This flag allows bypassing the address filter in fd_ep_add_merge. */
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
903 uint32_t flags; /* Additional information about the endpoint */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
904
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
905 /* To add: a validity timestamp for DNS records ? How do we retrieve this lifetime from DNS ? */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
906 };
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
907
24
bd83ce9328ed Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 23
diff changeset
908 int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, uint32_t flags );
bd83ce9328ed Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 23
diff changeset
909 int fd_ep_filter( struct fd_list * list, uint32_t flags );
38
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 37
diff changeset
910 int fd_ep_filter_family( struct fd_list * list, int af );
24
bd83ce9328ed Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 23
diff changeset
911 int fd_ep_clearflags( struct fd_list * list, uint32_t flags );
1113
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
912 DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump_one, int preamble, struct fd_endpoint * ep );
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
913 DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump, int preamble, int indent, struct fd_list * eps );
24
bd83ce9328ed Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 23
diff changeset
914
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
915
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
916 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
917 /* APPLICATIONS IDs */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
918 /*============================================================*/
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
919
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
920 struct fd_app {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
921 struct fd_list chain; /* link in cnf_apps list. List ordered by appid. */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
922 struct {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
923 unsigned auth : 1;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
924 unsigned acct : 1;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
925 } flags;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
926 vendor_id_t vndid; /* if not 0, Vendor-Specific-App-Id AVP will be used */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
927 application_id_t appid; /* The identifier of the application */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
928 };
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
929
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
930 int fd_app_merge(struct fd_list * list, application_id_t aid, vendor_id_t vid, int auth, int acct);
87
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 86
diff changeset
931 int fd_app_check(struct fd_list * list, application_id_t aid, struct fd_app **detail);
620
bc7328e600f0 Removed the OUTPUT specification for SWIG, too complex
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 618
diff changeset
932 int fd_app_check_common(struct fd_list * list1, struct fd_list * list2, int * common_found);
447
097bae83b07a Forgot to cleanup the configuration on exit, spotted by valgrind
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
933 int fd_app_empty(struct fd_list * list);
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
934
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
935
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
936
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
937 /*============================================================*/
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
938 /* MONITORING */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
939 /*============================================================*/
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
940
1077
b36c81e52e9a Add empty code for hooks so that dbg_interactive extension can load
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1071
diff changeset
941 /* These functions allow an extension to collect state information about the
b36c81e52e9a Add empty code for hooks so that dbg_interactive extension can load
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1071
diff changeset
942 * framework, as well as being hooked at some key checkpoints in the processing
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
943 * for logging or statistics purpose.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
944 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
945
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
946
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
947 /* CALLBACK: fd_hook_cb
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
948 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
949 * PARAMETERS:
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
950 * type : The type of hook that triggered this call, in case same cb is registered for several hooks.
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
951 * msg : If relevant, the pointer to the message triggering the call. NULL otherwise.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
952 * peer : If relevant, the pointer to the peer associated with the call. NULL otherwise.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
953 * other : For some callbacks, the remaining information is passed in this parameter. See each hook detail.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
954 * permsgdata : Structure associated with a given message, across several hooks.
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
955 * A different structure is associated with requests and corresponding answers.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
956 * See fd_hook_data_hdl below for details.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
957 * If no fd_hook_data_hdl is registered with this callback, this parameter is always NULL
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
958 * regdata : Data pointer stored at registration, opaque for the framework.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
959 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
960 * DESCRIPTION:
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
961 * When such callback is registered with fd_hook_register function, it will be called on matching events with
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
962 * the parameters as described in the list of fd_hook_type below. One can use this mechanism for e.g.:
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
963 * - log completely the messages for safety / backup
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
964 * - create statistics information on the throughput
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
965 * - ...
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
966 *
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
967 * IMPORTANT: the callback MUST NOT change the memory pointed by the different parameters (peer, message, ...)
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
968 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
969 * RETURN VALUE:
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
970 * none.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
971 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
972
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
973 /* The available hooks in the framework */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
974 enum fd_hook_type {
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
975
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
976 HOOK_DATA_RECEIVED = 0,
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
977 /* Hook called as soon as a message has been received from the network, after TLS & boundary processing.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
978 - {msg} is NULL.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
979 - {peer} is NULL.
1102
1d7b3ebda27f Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1101
diff changeset
980 - {other} is a pointer to a struct fd_cnx_rcvdata containing the received buffer.
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
981 - {permsgdata} points to either a new empty structure allocated for this message (cf. fd_hook_data_hdl), or NULL if no hdl is registered.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
982 */
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
983
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
984 HOOK_MESSAGE_RECEIVED,
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
985 /* Hook called when a message has been received and the structure has been parsed successfully (list of AVPs).
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
986 - {msg} points to the parsed message. At this time, the objects have not been dictionary resolved. If you
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
987 try to call fd_msg_parse_dict, it will slow down the operation of a relay agent.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
988 - {peer} is set if the message is received from a peer's connection, and NULL if the message is from a new client
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
989 connected and not yet identified
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
990 - {other} is NULL, or a char * identifying the connection when {peer} is null.
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
991 - {permsgdata} points to either a new empty structure allocated for this message or the one passed to HOOK_DATA_RECEIVED if used.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
992 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
993
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
994 HOOK_MESSAGE_LOCAL,
1113
eb4ce68b6e5c Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
995 /* Hook called when a request message has been created locally by an extension and is being sent.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
996 - {msg} points to the message.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
997 - {peer} is NULL
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
998 - {other} is NULL
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
999 - {permsgdata} points to a new empty structure allocated for this request (cf. fd_hook_data_hdl)
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1000 */
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1001
1299
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1002 HOOK_MESSAGE_SENDING,
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1003 /* Hook called when a message is about to be sent to a peer. The message pointer cannot be modified here, but the content of the message
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1004 could still be changed (for example add or remove some AVP. This is the last chance.
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1005 - {msg} points to the message. Some objects may not have been dictionary resolved. If you
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1006 try to call fd_msg_parse_dict, it will slow down the operation of the instance.
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1007 - {peer} is the one the message is being sent to.
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1008 - {other} is NULL.
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1009 - {permsgdata} points to existing structure if any, or a new structure otherwise.
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1010 */
035f489b845b Added a new hook HOOK_MESSAGE_SENDING
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1220
diff changeset
1011
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1012 HOOK_MESSAGE_SENT,
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1013 /* Hook called when a message has been sent to a peer. The message might be freed as soon as the hook function returns,
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1014 so it is not safe to store the pointer for asynchronous processing.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1015 - {msg} points to the sent message. Again, the objects may not have been dictionary resolved. If you
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1016 try to call fd_msg_parse_dict, it will slow down the operation of a relay agent.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1017 - {peer} is set if the message is sent to a peer's connection, and NULL if the message is sent to a new client
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1018 connected and not yet identified, or being rejected
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1019 - {other} is NULL.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1020 - {permsgdata} points to existing structure if any, or a new structure otherwise.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1021 */
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1022
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1023 HOOK_MESSAGE_FAILOVER,
1099
6ce5c99a40af Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 1088
diff changeset
1024 /* Hook called when a message that was sent to a peer is being requeued, because e.g. the connection was torn down.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1025 In that case the message will go again through the routing process.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1026 - {msg} points to the corresponding request message (the answer is discarded). Again, the objects may not have been dictionary resolved. If you
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1027 try to call fd_msg_parse_dict, it might slow down the operation of a relay agent, although this hook is not on the normal execution path.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1028 - {peer} is the peer this message was previously sent to.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1029 - {other} is NULL.
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1030 - {permsgdata} points to existing structure if any, or a new structure otherwise.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1031 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1032
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1033 HOOK_MESSAGE_PARSING_ERROR,
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1034 /* Hook called when a message being processed cannot be parsed successfully.
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1035 - {msg} points to the message if buffer was parsed successfully, or NULL otherwise. You should not call fd_msg_parse_dict on this in any case.
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1036 - {peer} is NULL or the peer that received the message. If NULL and the message is not NULL, you can still retrieve the source from the message itself.
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1037 - {other} is a char * pointer to the error message (human-readable) if {msg} is not NULL, a pointer to struct fd_cnx_rcvdata containing the received buffer otherwise.
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1038 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1039 */
1301
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1040
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1041 HOOK_MESSAGE_ROUTING_ERROR,
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1042 /* Hook called when a message being processed by the routing thread meets an error such as no remaining available peer for sending, based on routing callbacks decisions (maybe after retries).
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1043 - {msg} points to the message. Again, the objects may not have been dictionary resolved. If you
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1044 try to call fd_msg_parse_dict, it might slow down the operation of a relay agent, although this hook is not on the normal execution path.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1045 - {peer} is NULL.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1046 - {other} is a char * pointer to the error message (human-readable).
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1047 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1048 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1049
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1050 HOOK_MESSAGE_ROUTING_FORWARD,
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1051 /* Hook called when a received message is deemed to be not handled locally by the routing_dispatch process.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1052 The decision of knowing which peer it will be sent to is not made yet (or if an error will be returned).
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1053 The hook is trigged before the callbacks registered with fd_rt_fwd_register are called.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1054 - {msg} points to the message. Again, the objects may not have been dictionary resolved.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1055 If you try to call fd_msg_parse_dict, it will slow down the operation of a relay agent.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1056 - {peer} is NULL.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1057 - {other} is NULL.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1058 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1059 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1060
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1061 HOOK_MESSAGE_ROUTING_LOCAL,
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1062 /* Hook called when a received message is handled locally by the routing_dispatch process (i.e., not forwarded).
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1063 The hook is trigged before the callbacks registered with fd_disp_register are called.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1064 - {msg} points to the message. Here, the message has been already parsed completely & successfully.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1065 - {peer} is NULL.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1066 - {other} is NULL.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1067 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1068 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1069
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1070 HOOK_MESSAGE_DROPPED,
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1071 /* Hook called when a message is being discarded by the framework because of some error condition (normal or abnormal).
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1072 It is probably a good idea to log this for analysis / backup.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1073 - {msg} points to the message, which will be freed as soon as the hook returns.
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1074 - {peer} may be NULL or a peer related to the event.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1075 - {other} is a char * pointer to the error message (human-readable).
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1076 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1077 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1078
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1079 HOOK_PEER_CONNECT_FAILED,
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1080 /* Hook called when a connection attempt to/from a remote peer has failed. This hook is also called when the peer was in OPEN state and the connection is broken.
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1081 - {msg} may be NULL (lower layer error, e.g. connection timeout) or points to a message showing the error (either invalid incoming message, or the CEA message sent or received with an error code).
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1082 - {peer} may be NULL for incoming requests from unknown peers being rejected, otherwise it points to the peer structure associated with the attempt.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1083 - {other} is a char * pointer to the error message (human-readable).
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1084 - {permsgdata} is always NULL for this hook.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1085 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1086
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1087 HOOK_PEER_CONNECT_SUCCESS,
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1088 /* Hook called when a connection attempt to/from a remote peer has succeeded (the peer moves to OPEN_HANDSHAKE or OPEN state).
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1089 In case of deprecated TLS handshake after the CER/CEA exchange, this hook can still be followed by HOOK_PEER_CONNECT_FAILED if TLS handshake fails.
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1090 - {msg} points to the CEA message sent or received (with a success code) -- in case it is sent, you can always get access to the matching CER.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1091 - {peer} points to the peer structure.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1092 - {other} is NULL.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1093 - {permsgdata} is always NULL for this hook.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1094 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1095
1301
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1096 HOOK_MESSAGE_PARSING_ERROR2,
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1097 /* Hook called after an error message has been generated due to a dictionary parsing error.
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1098 - {msg} points to the error message that has been generated.
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1099 - {peer} is NULL. You can still retrieve the source from the message itself.
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1100 - {other} is NULL
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1101 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1102 Use this hook if you need to populate more data in the error being returned, from the error message.
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1103 (e.g. some AVP need to be added to replies even if error case.
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1104 */
50fb308e84f7 Added a new hook to allow extensions act on the error messages being returned in case of parsing error (e.g. if some mandatory AVP are expected in error messages)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1299
diff changeset
1105 #define HOOK_LAST HOOK_MESSAGE_PARSING_ERROR2
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1106 };
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1107
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1108
1099
6ce5c99a40af Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 1088
diff changeset
1109 /* Type of the {permsgdata} pointer. It is up to each extension to define its own structure. This is opaque for the framework. */
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1110 struct fd_hook_permsgdata;
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1111
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1112 /* A handle that will be associated with the extension, and with the permsgdata structures. */
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1113 struct fd_hook_data_hdl;
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1114
1102
1d7b3ebda27f Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1101
diff changeset
1115 /* The following structure is what is passed to the HOOK_DATA_RECEIVED hook */
1d7b3ebda27f Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1101
diff changeset
1116 struct fd_cnx_rcvdata {
1d7b3ebda27f Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1101
diff changeset
1117 size_t length;
1d7b3ebda27f Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1101
diff changeset
1118 uint8_t * buffer; /* internal note: the buffer is padded with a struct fd_msg_pmdl, not accounted for in length */
1d7b3ebda27f Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1101
diff changeset
1119 };
1d7b3ebda27f Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1101
diff changeset
1120
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1121 /* Function to register a new fd_hook_data_hdl. Should be called by your extension init function.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1122 * The arguments are the functions called to initialize a new fd_hook_permsgdata and to free this structure when the corresponding message is being freed.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1123 */
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1124 /*
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1125 * FUNCTION: fd_hook_data_register
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1126 *
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1127 * PARAMETERS:
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1128 * permsgdata_size : the size of the fd_hook_permsgdata structure.
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1129 * permsgdata_init_cb : function called to initialize a new fd_hook_permsgdata structure, when a hook will be called for a message that does not have such structure yet.
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1130 * The memory is already allocated and blanked, so you can pass NULL if no further handling is required.
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1131 * permsgdata_fini_cb : function called when a message is being disposed. It should free the resources associated with the fd_hook_permsgdata.
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1132 * You can pass NULL if no special handling is required. The memory of the permsgdata structure itself will be freed by the framework.
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1133 * new_handle : On success, a handler to the registered callback is stored here.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1134 * This handler will be used to unregister the cb.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1135 *
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1136 * DESCRIPTION:
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1137 * Register a new fd_hook_data_hdl. This handle is used during hooks registration (see below) in order to associate data with the messages, to allow keeping tracking of the message easily.
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1138 * Note that these handlers are statically allocated and cannot be unregistered. FD_HOOK_HANDLE_LIMIT handlers can be registered at maximum (recompile libfdproto if you change this value)
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1139 *
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1140 * RETURN VALUE:
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1141 * 0 : The callback is registered.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1142 * EINVAL : A parameter is invalid.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1143 * ENOSPC : Too many handles already registered. You may need to increase the limit in the code.
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1144 */
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1145 int fd_hook_data_register(
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1146 size_t permsgdata_size,
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1147 void (*permsgdata_init_cb) (struct fd_hook_permsgdata *),
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1148 void (*permsgdata_fini_cb) (struct fd_hook_permsgdata *),
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1149 struct fd_hook_data_hdl **new_handle
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1150 );
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1151
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1152 /* A handler associated with a registered hook callback (for cleanup) */
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1153 struct fd_hook_hdl;
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1154
1128
7c5449ddc434 New macro HOOK_MASK to ease call of the fd_hook_register function
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1155 /* Helper for building a mask of hooks for registration */
7c5449ddc434 New macro HOOK_MASK to ease call of the fd_hook_register function
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1156 #define HOOK_MASK(hooklist...) fd_hook_mask_helper(0, ## hooklist, -1)
7c5449ddc434 New macro HOOK_MASK to ease call of the fd_hook_register function
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1157
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1158 /*
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1159 * FUNCTION: fd_hook_register
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1160 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1161 * PARAMETERS:
1128
7c5449ddc434 New macro HOOK_MASK to ease call of the fd_hook_register function
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1162 * type_mask : A bitmask of fd_hook_type bits for which this cb is registered, e.g. HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT )
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1163 * fd_hook_cb : The callback function to register (see prototype above).
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1164 * regdata : Pointer to pass to the callback when it is called. The data is opaque to the daemon.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1165 * data_hdl : If permsgdata is requested for the hooks, a handler registered with fd_hook_data_register. NULL otherwise.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1166 * handler : On success, a handler to the registered callback is stored here.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1167 * This handler can be used to unregister the cb.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1168 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1169 * DESCRIPTION:
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1170 * Register a new hook in the framework. See explanations above.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1171 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1172 * RETURN VALUE:
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1173 * 0 : The callback is registered.
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1174 * EEXIST : Another callback is already registered for this type of hook (HOOK_DATA_RECEIVED).
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1175 * EINVAL : A parameter is invalid.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1176 * ENOMEM : Not enough memory to complete the operation
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1177 */
1098
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1178 int fd_hook_register ( uint32_t type_mask,
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1179 void (*fd_hook_cb)(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata),
f38d77f9cfd3 Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
1180 void *regdata,
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1181 struct fd_hook_data_hdl *data_hdl,
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1182 struct fd_hook_hdl ** handler );
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1183
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1184 /* Remove a hook registration */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1185 int fd_hook_unregister( struct fd_hook_hdl * handler );
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1186
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1187
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1188 /* Use the following function to retrieve any pmd structure associated with a request matching the current answer. Returns NULL in case of error / no such structure */
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1189 struct fd_hook_permsgdata * fd_hook_get_request_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * answer);
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1190
1329
175f2eb883a0 Add function to retrieve pmd structure associated with a request.
Thomas Klausner <tk@giga.or.at>
parents: 1326
diff changeset
1191 /* Use the following function to retrieve any pmd structure associated with a request. Returns NULL in case of error */
175f2eb883a0 Add function to retrieve pmd structure associated with a request.
Thomas Klausner <tk@giga.or.at>
parents: 1326
diff changeset
1192 struct fd_hook_permsgdata * fd_hook_get_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * msg);
175f2eb883a0 Add function to retrieve pmd structure associated with a request.
Thomas Klausner <tk@giga.or.at>
parents: 1326
diff changeset
1193
175f2eb883a0 Add function to retrieve pmd structure associated with a request.
Thomas Klausner <tk@giga.or.at>
parents: 1326
diff changeset
1194
1128
7c5449ddc434 New macro HOOK_MASK to ease call of the fd_hook_register function
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1195 /* The following is used by HOOK_MASK macro */
7c5449ddc434 New macro HOOK_MASK to ease call of the fd_hook_register function
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1196 uint32_t fd_hook_mask_helper(int dummy, ...);
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1102
diff changeset
1197
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1198 /*============================================================*/
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1199
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1200 /*
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1201 * The following allows an extension to retrieve stat information on the different fifo queues involved in the freeDiameter framework.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1202 * There are three global queues, plus per-peer queues.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1203 * This information can be used to build SNMP-like data for example, or quickly get a status of the framework to find the loaded path of execution / bottlenecks.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1204 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1205 enum fd_stat_type {
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1206 /* For the following, no peer is associated with the stat */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1207 STAT_G_LOCAL= 1, /* Get statistics for the global queue of messages processed by local extensions */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1208 STAT_G_INCOMING, /* Get statistics for the global queue of received messages to be processed by routing_in thread */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1209 STAT_G_OUTGOING, /* Get statistics for the global queue of messages to be processed by routing_out thread */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1210
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1211 /* For the following, the peer must be provided */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1212 STAT_P_PSM, /* Peer state machine queue (events to be processed for this peer, including received messages) */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1213 STAT_P_TOSEND, /* Queue of messages for sending to this peer */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1214 };
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1215
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1216 /*
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1217 * FUNCTION: fd_stat_getstats
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1218 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1219 * PARAMETERS:
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1220 * stat : Which queue is being queried
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1221 * peer : (depending on the stat parameter) which peer is being queried
1071
6ca6cadf209c Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1069
diff changeset
1222 * current_count : (out) The number of items in the queue currently
6ca6cadf209c Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1069
diff changeset
1223 * limit_count : (out) The max number of items the queue accepts before becoming blocking -- 0 means no max.
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1224 * highest_count : (out) The highest count the queue has reached since startup
1067
23989d6c8390 Add total count in the statistics of the queues, thanks for the feedback :)
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1063
diff changeset
1225 * total_count : (out) Total number of items that this queue has processed (always growing, use deltas for monitoring)
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1226 * total : (out) Cumulated time all items spent in this queue, including blocking time (always growing, use deltas for monitoring)
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1227 * blocking : (out) Cumulated time threads trying to post new items were blocked (queue full).
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1228 * last : (out) For the last element retrieved from the queue, how long it took between posting (including blocking) and poping
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1229 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1230 * DESCRIPTION:
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1231 * Get statistics information about a given queue.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1232 * Any of the (out) parameters can be NULL if not requested.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1233 *
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1234 * RETURN VALUE:
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1235 * 0 : The callback is registered.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1236 * EINVAL : A parameter is invalid.
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1237 */
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1238 int fd_stat_getstats(enum fd_stat_type stat, struct peer_hdr * peer,
1071
6ca6cadf209c Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1069
diff changeset
1239 int * current_count, int * limit_count, int * highest_count, long long * total_count,
1063
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1240 struct timespec * total, struct timespec * blocking, struct timespec * last);
7a7f63f6f135 Commit prototype of new functions for discussion. These will replace the fd_log_msg feature as well as several internal dumping routines. The dbg_monitoring will be totally rewritten. Comments welcome...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1014
diff changeset
1241
1069
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1242 /*============================================================*/
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1243 /* EOF */
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1244 /*============================================================*/
544fa1be79a9 Update the new API prototype to make it easier for extension to track messages between hooks, for e.g. timing computations
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1067
diff changeset
1245
904
b839a1b1c1da Make freeDiameter headers more C++ friendly -- thank you Thomas
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
1246 #ifdef __cplusplus
b839a1b1c1da Make freeDiameter headers more C++ friendly -- thank you Thomas
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
1247 }
b839a1b1c1da Make freeDiameter headers more C++ friendly -- thank you Thomas
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
1248 #endif
b839a1b1c1da Make freeDiameter headers more C++ friendly -- thank you Thomas
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
1249
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
1250 #endif /* _LIBFDCORE_H */
"Welcome to our mercurial repository"