annotate include/freeDiameter/libfdcore.h @ 706:4ffbc9f1e922

Large UNTESTED commit with the following changes: * Improved DiameterIdentity handling (esp. interationalization issues), and improve efficiency of some string operations in peers, sessions, and dictionary modules (closes #7) * Cleanup in the session module to free only unreferenced sessions (#16) * Removed fd_cpu_flush_cache(), replaced by more robust alternatives. * Improved peer state machine algorithm to counter SCTP multistream race condition.
author Sebastien Decugis <sdecugis@nict.go.jp>
date Wed, 09 Feb 2011 15:26:58 +0900
parents f198d16fa7f4
children 571b3abaa5df
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) *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
648
ae29bf971f20 Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 646
diff changeset
5 * Copyright (c) 2011, 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
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
40 #include <freeDiameter/libfdproto.h>
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
41 #include <gnutls/gnutls.h>
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
42 #include <gnutls/x509.h>
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
43
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
44 /* GNUTLS version */
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
45 #ifndef GNUTLS_VERSION
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
46 #define GNUTLS_VERSION LIBGNUTLS_VERSION
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
47 #endif /* GNUTLS_VERSION */
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
48
214
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
49 /* GNUTLS calls debug level */
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
50 #ifndef GNUTLS_DBG_LEVEL
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
51 #define GNUTLS_DBG_LEVEL ANNOYING
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
52 #endif /* GNUTLS_DBG_LEVEL */
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
53
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
54 /* Check the return value of a GNUTLS function, log and propagate */
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
55 #define CHECK_GNUTLS_DO( __call__, __fallback__ ) { \
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
56 int __ret__; \
214
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
57 TRACE_DEBUG(GNUTLS_DBG_LEVEL, "GNUTLS call: " #__call__ ); \
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
58 __ret__ = (__call__); \
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
59 if (__ret__ < 0) { \
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
60 TRACE_DEBUG(INFO, "Error in '" #__call__ "':\t%s", gnutls_strerror(__ret__)); \
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
61 __fallback__; \
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
62 } \
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
63 }
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64
214
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
65 /* For GNUTLS routines that do not return a value */
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
66 #define GNUTLS_TRACE( __call__) { \
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
67 TRACE_DEBUG(GNUTLS_DBG_LEVEL, "GNUTLS call: " #__call__ ); \
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
68 (__call__); \
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
69 }
5a1b93f59f8f Added trace facility for GNUTLS calls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 162
diff changeset
70
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
71
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
72 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
73 /* INITIALIZATION */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
74 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
75
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
76
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
77 /* 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
78 int fd_core_initialize(void);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
79
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
80 /* Return a string describing the version of the library */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
81 const char *fd_core_version(void);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
82
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
83 /* Parse the freeDiameter.conf configuration file, load the extensions */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
84 int fd_core_parseconf(char * conffile);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
85
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
86 /* Start the server & client threads */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
87 int fd_core_start(void);
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 /* 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
90 int fd_core_waitstartcomplete(void);
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
91
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
92 /* Initialize shutdown of the framework */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
93 int fd_core_shutdown(void);
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 /* 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
96 int fd_core_wait_shutdown_complete(void);
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
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
99 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
100 /* CONFIG */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
101 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
102
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
103 /* 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
104 #define EYEC_CONFIG 0xC011F16
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
105 struct fd_config {
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
106 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
107
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
108 char *cnf_file; /* Configuration file to parse, default is DEFAULT_CONF_FILE */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
109
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
110 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
111 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
112 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
113 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
114
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
115 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
116 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
117
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
118 uint16_t cnf_port; /* the local port for legacy Diameter (default: 3868) in host byte order */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
119 uint16_t cnf_port_tls; /* the local port for Diameter/TLS (default: 3869) in host byte order */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
120 uint16_t cnf_sctp_str; /* default max number of streams for SCTP associations (def: 30) */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
121 struct fd_list cnf_endpoints; /* the local endpoints to bind the server to. list of struct fd_endpoint. default is empty (bind all) */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
122 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
123 uint16_t cnf_dispthr; /* Number of dispatch threads to create */
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
124 struct {
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
125 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
126 unsigned no_ip4 : 1; /* disable IP */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
127 unsigned no_ip6 : 1; /* disable IPv6 */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
128 unsigned no_tcp : 1; /* disable use of TCP */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
129 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
130 unsigned pr_tcp : 1; /* prefer TCP over SCTP */
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
131 unsigned tls_alg: 1; /* TLS algorithm for initiated cnx. 0: separate port. 1: inband-security (old) */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
132 } cnf_flags;
8
3e143f047f78 Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 7
diff changeset
133
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
134 struct {
18
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
135 /* Credentials parameters (backup) */
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
136 char * cert_file;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
137 char * key_file;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
138
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
139 char * ca_file;
142
dee0a871abcd Added number of CA certificates for debug
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 140
diff changeset
140 int ca_file_nr;
18
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
141 char * crl_file;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
142
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
143 char * prio_string;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
144 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
145 char * dh_file;
18
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
146
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
147 /* GNUTLS parameters */
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
148 gnutls_priority_t prio_cache;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
149 gnutls_dh_params_t dh_cache;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
150
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
151 /* GNUTLS server credential(s) */
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
152 gnutls_certificate_credentials_t credentials;
e7187583dcf8 Added CA helper script
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 17
diff changeset
153
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
154 } cnf_sec_data;
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
155
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
156 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
157 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
158 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
159 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
160 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
161
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
162
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
163
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
164 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
165 /* PEERS */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
166 /*============================================================*/
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
167
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
168 /* States of a peer */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
169 enum peer_state {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
170 /* Stable states */
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
171 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
172 STATE_OPEN, /* Connexion established */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
173
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
174 /* Peer state machine */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
175 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
176 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
177 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
178 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
179 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
180 /* 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
181 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
182 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
183 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
184 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
185
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
186 /* Failover state machine */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
187 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
188 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
189
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
190 /* 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
191 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
192 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
193
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
194 /* Error state */
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
195 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
196 #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
197 };
33
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
198 /* 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
199 #define DECLARE_STATE_STR() \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
200 const char *peer_state_str[] = { \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
201 "STATE_NEW" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
202 , "STATE_OPEN" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
203 , "STATE_CLOSED" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
204 , "STATE_CLOSING" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
205 , "STATE_WAITCNXACK" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
206 , "STATE_WAITCNXACK_ELEC" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
207 , "STATE_WAITCEA" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
208 , "STATE_OPEN_HANDSHAKE" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
209 , "STATE_SUSPECT" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
210 , "STATE_REOPEN" \
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
211 , "STATE_OPEN_NEW" \
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
212 , "STATE_CLOSING_GRACE" \
33
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
213 , "STATE_ZOMBIE" \
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
214 };
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
215 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
216 #define STATE_STR(state) \
16
013ce9851131 Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 14
diff changeset
217 (((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
218
640
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
219 /* Constants for the peer_info structure bellow */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
220 #define PI_P3_DEFAULT 0 /* Use any available protocol */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
221 #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
222 #define PI_P3_IPv6 2 /* resp, IPv6 */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
223
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
224 #define PI_P4_DEFAULT 0 /* Attempt any available protocol */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
225 #define PI_P4_TCP 1 /* Only use TCP */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
226 #define PI_P4_SCTP 2 /* Only use SCTP */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
227
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
228 #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
229 #define PI_ALGPREF_TCP 1 /* TCP is attempted first */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
230
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
231 #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
232 #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
233 #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
234 /* Set sec = 3 to authorize use of (Inband-Security-Id == NONE) with this peer, sec = 2 only authorizing TLS */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
235
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
236 #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
237 #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
238
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
239 #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
240 #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
241
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
242 /* 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
243 struct peer_info {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
244
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
245 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
246 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
247
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
248 struct {
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
249 struct {
640
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
250 unsigned pro3 :2; /* PI_P3_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
251 unsigned pro4 :2; /* PI_P4_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
252 unsigned alg :1; /* PI_ALGPREF_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
253 unsigned sec :2; /* PI_SEC_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
254 unsigned exp :1; /* PI_EXP_* */
237cf6339546 dbg_interactive almost complete
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 628
diff changeset
255 unsigned persist :1; /* PI_PRST_* */
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
256
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
257 } 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
258
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
259 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
260 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
261
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
262 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
263 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
264 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
265
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
266 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
267
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
268 } 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
269
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
270 struct {
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
271
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
272 /* enum peer_state pir_state; */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
273 /* Since 1.1.0, read the state with fd_peer_getstate(peer). */
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 34
diff changeset
274
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
275 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
276 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
277
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 43
diff changeset
286 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
287
37
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
288 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
289 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
290 /* 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
291 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
292 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
293
cc3c59fe98fe Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
294 } 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
295
13
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
296 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
297 };
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
298
454
f1484823cb4a Small hack which might spear some concurrency problems and is quite harmless
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 447
diff changeset
299
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
300 struct peer_hdr {
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
301 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
302 struct peer_info info; /* The public data */
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
303
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
304 /* 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
305 };
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
306
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
307 /* the global list of peers.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
308 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
309 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
310 extern struct fd_list fd_g_peers;
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
311 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
312
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
313 /*
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
314 * FUNCTION: fd_peer_add
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
315 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
316 * PARAMETERS:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
317 * 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
318 * 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
319 * 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
320 * 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
321 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
322 * DESCRIPTION:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
323 * 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
324 *
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
325 * 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
326 * 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
327 * 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
328 *
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
329 * 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
330 * 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
331 * 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
332 * 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
333 * 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
334 *
ef9ef3bf4752 Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 12
diff changeset
335 * 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
336 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
337 * RETURN VALUE:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
338 * 0 : The peer is added.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
339 * EINVAL : A parameter is invalid.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
340 * 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
341 * (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
342 * 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
343 */
12
418d2ce80dc8 Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 11
diff changeset
344 int fd_peer_add ( struct peer_info * info, 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
345
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
346 /*
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
347 * FUNCTION: fd_peer_getbyid
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
348 *
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
349 * PARAMETERS:
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
350 * 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
351 * diamidlen : length of the diamid
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
352 * igncase : perform an almost-case-insensitive search? (slower)
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
353 * peer : The peer is stored here if it exists.
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
354 *
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
355 * DESCRIPTION:
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
356 * Search a peer by its Diameter-Id.
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
357 *
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
358 * RETURN VALUE:
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
359 * 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
360 * !0 : An error occurred.
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
361 */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
362 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
363
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
364 /*
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
365 * FUNCTION: fd_peer_get_state
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
366 *
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
367 * PARAMETERS:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
368 * 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
369 *
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
370 * DESCRIPTION:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
371 * 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
372 *
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
373 * RETURN VALUE:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
374 * -1 : peer is invalid
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
375 * >=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
376 */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
377 int fd_peer_get_state(struct peer_hdr *peer);
86
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
378
e3e22d89e023 Started routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 85
diff changeset
379 /*
162
79768bf7d208 Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 142
diff changeset
380 * FUNCTION: fd_peer_validate_register
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
381 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
382 * PARAMETERS:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
383 * peer_validate : Callback as defined bellow.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
384 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
385 * DESCRIPTION:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
386 * 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
387 * 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
388 * 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
389 * 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
390 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
391 * RETURN VALUE:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
392 * 0 : The callback is added.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
393 * !0 : An error occurred.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
394 */
20
277ec00d793e Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 18
diff changeset
395 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
396 /*
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
397 * CALLBACK: peer_validate
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
398 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
399 * PARAMETERS:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
400 * 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
401 * 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
402 * 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
403 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
404 * DESCRIPTION:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
405 * 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
406 * 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
407 *
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
408 * 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
409 * 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
410 * 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
411 *
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
412 * 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
413 * 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
414 * 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
415 * 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
416 * 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
417 * 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
418 * peer is destroyed.
162
79768bf7d208 Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 142
diff changeset
419 * 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
420 * additional restrictions.
11
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
421 *
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
422 * RETURN VALUE:
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
423 * 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
424 * !0 : An error occurred.
6576ef5e01eb Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
425 */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
426
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
427
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
428
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
429 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
430 /* MESSAGES */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
431 /*============================================================*/
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
432
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
433 /*
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
434 * FUNCTION: fd_msg_send, fd_msg_send_timeout
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
435 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
436 * PARAMETERS:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
437 * pmsg : Location of the message to be sent on the network (set to NULL on function return to avoid double deletion).
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
438 * anscb : A callback to be called when answer is received, if msg is a request (optional for fd_msg_send)
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
439 * anscb_data : opaque data to be passed back to the anscb when it is called.
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
440 * timeout : (only for fd_msg_send_timeout) sets the absolute time until when to wait for an answer. Past this time,
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
441 * the anscb is called with the request as parameter and the answer will be discarded when received.
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
442 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
443 * DESCRIPTION:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
444 * 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
445 * For requests, the end-to-end id must be set (see fd_msg_get_eteid / MSGFL_ALLOC_ETEID).
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
446 * For answers, the message must be created with function fd_msg_new_answ.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
447 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
448 * 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
449 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
450 * 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
451 * - either having registered a callback in the dispatch module (see fd_disp_register)
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
452 * - or provide a callback as parameter here. If such callback is provided, it is called before the dispatch callbacks.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
453 * The prototype for this callback function is:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
454 * void anscb(void * data, struct msg ** answer)
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
455 * where:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
456 * data : opaque data that was registered along with the callback.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
457 * answer : location of the pointer to the answer.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
458 * 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
459 * 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
460 * 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
461 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
462 * 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
463 *
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
464 * fd_msg_send_timeout is similar to fd_msg_send, except that it takes an additional argument "timeout" and can be called
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
465 * only with requests as parameters, and an anscb callback.
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
466 * If the matching answer or error is received before the timeout date passes, everything occurs as with fd_msg_send. Otherwise,
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
467 * the request is removed from the queue (meaning the matching answer will be discarded upon reception) and passed to the answcb
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
468 * function. This function can easily distinguish between timeout case and answer case by checking if the message received is
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
469 * a request. Upon return, if the *msg parameter is not NULL, it is freed (not passed to other callbacks).
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
470 *
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
471 * RETURN VALUE:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
472 * 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
473 * 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
474 * ...
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
475 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
476 int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data );
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 640
diff changeset
477 int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, const struct timespec *timeout );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
478
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
479 /*
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
480 * FUNCTION: fd_msg_rescode_set
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
481 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
482 * PARAMETERS:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
483 * msg : A msg object -- it must be an answer.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
484 * 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
485 * 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
486 * 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
487 * 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
488 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
489 * DESCRIPTION:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
490 * This function adds a Result-Code AVP to a message, and optionally
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
491 * - sets the 'E' error flag in the header,
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
492 * - adds Error-Message, Error-Reporting-Host and Failed-AVP AVPs.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
493 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
494 * RETURN VALUE:
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
495 * 0 : Operation complete.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
496 * !0 : an error occurred.
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
497 */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
498 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
499
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
500 /* 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
501 int fd_msg_add_origin ( struct msg * msg, int osi );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
502
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
503 /* 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
504 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
505
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
506
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 33
diff changeset
507 /* Parse a message against our dictionary, and in case of error log and eventually build the error reply (on return and EBADMSG, *msg == NULL or *msg is the error message ready to send) */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 33
diff changeset
508 int fd_msg_parse_or_error( struct msg ** msg );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
509
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
510
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
511
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
512
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
513 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
514 /* DISPATCH */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
515 /*============================================================*/
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
516
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
517 /*
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
518 * FUNCTION: fd_disp_app_support
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
519 *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
520 * PARAMETERS:
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
521 * app : The dictionary object corresponding to the Application.
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
522 * 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
523 * auth : Support auth app part.
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
524 * acct : Support acct app part.
7
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
525 *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
526 * DESCRIPTION:
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
527 * 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
528 * 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
529 * 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
530 *
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
531 * RETURN VALUE:
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
532 * 0 : The application support is registered.
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
533 * EINVAL : A parameter is invalid.
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
534 */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
535 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
536
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
537 /* 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
538
e5af94b04946 Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
539
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
540 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
541 /* ROUTING */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
542 /*============================================================*/
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
543
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
544 /* 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
545 * and that can be called by extensions.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
546 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
547 * Three different type of messages must be distinguished:
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
548 * - 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
549 * - 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
550 * - Message is locally generated (OUT messages)
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
551 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
552 * 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
553 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
554 * (*) IN messages processing details:
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
555 * - 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
556 * - 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
557 * - 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
558 * - 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
559 * 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
560 * - 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
561 * - 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
562 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
563 * (*) FWD messages details:
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
564 * - 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
565 * - If the local peer does not relay message, an error DIAMETER_APPLICATION_UNSUPPORTED is returned.
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
566 * - All callbacks registered with fd_rt_fwd_register are called for the message (see bellow).
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
567 * - 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
568 * - Once all callbacks have been called, the message is queued in the global fd_g_outgoing queue.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
569 * - The remaining processing is the same as for OUT messages, as described bellow.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
570 *
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
571 * (*) OUT messages details:
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
572 * - 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
573 * - 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
574 * - 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
575 * - 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
576 * - 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
577 * - 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
578 * - Otherwise, call all callbacks registered by function fd_rt_out_register, with the list of peers and the message.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
579 * - Order the resulting list of peers by score (see bellow), and sent the message to the peer with highest (positive) score.
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
580 * - 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
581 * - 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
582 * - 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
583 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
584 * 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
585 */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
586
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
587 /********** Forwarding callbacks: for Proxy operations ***********/
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
588
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
589 /* Handle to registered callback */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
590 struct fd_rt_fwd_hdl;
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
591
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
592 /* Message direction for the callback */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
593 enum fd_rt_fwd_dir {
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
594 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
595 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
596 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
597 };
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
598
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
599 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
600 * FUNCTION: fd_rt_fwd_register
83
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
601 *
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
602 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
603 * rt_fwd_cb : The callback function to register (see prototype bellow).
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
604 * 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
605 * 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
606 * 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
607 * 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
608 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
609 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
610 * 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
611 * 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
612 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
613 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
614 * 0 : The callback is registered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
615 * EINVAL : A parameter is invalid.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
616 * 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
617 */
620
bc7328e600f0 Removed the OUTPUT specification for SWIG, too complex
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 618
diff changeset
618 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
619 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
620 * CALLBACK: rt_fwd_cb
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
621 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
622 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
623 * 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
624 * 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
625 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
626 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
627 * 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
628 * 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
629 * 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
630 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
631 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
632 * 0 : Operation complete.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
633 * !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
634 */
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
635
85
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
636 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
637 * FUNCTION: fd_rt_fwd_unregister
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
638 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
639 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
640 * 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
641 * 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
642 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
643 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
644 * 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
645 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
646 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
647 * 0 : The callback is unregistered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
648 * EINVAL : A parameter is invalid.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
649 */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
650 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
651
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
652
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
653 /********** 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
654
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
655 /* Handle to registered callback */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
656 struct fd_rt_out_hdl;
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
657
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
658 enum fd_rt_out_score {
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
659 FD_SCORE_NO_DELIVERY = -70, /* We should not send this message to this candidate */
124
cc42d8607114 Completed cleanups of queues when the daemon is stopping
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 105
diff changeset
660 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
661 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
662 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
663 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
664 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
665 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
666 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
667 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
668 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
669 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
670 FD_SCORE_REDIR_SESSION = 50, /* If there is a redirect rule with ALL_SESSION for these message and peer */
89
3f8b437bcb66 Added some default routing handlers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 87
diff changeset
671 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
672 };
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
673
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
674 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
675 * FUNCTION: fd_rt_out_register
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
676 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
677 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
678 * rt_out_cb : The callback function to register (see prototype bellow).
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
679 * 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
680 * 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
681 * 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
682 * 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
683 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
684 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
685 * 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
686 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
687 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
688 * 0 : The callback is registered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
689 * EINVAL : A parameter is invalid.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
690 * 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
691 */
620
bc7328e600f0 Removed the OUTPUT specification for SWIG, too complex
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 618
diff changeset
692 int fd_rt_out_register ( int (*rt_out_cb)(void * cbdata, struct msg * msg, 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
693 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
694 * CALLBACK: rt_out_cb
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
695 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
696 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
697 * cbdata : pointer to some data that was registered with the callback.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
698 * msg : The message that must be sent.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
699 * 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
700 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
701 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
702 * 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
703 * 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
704 * 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
705 * 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
706 * (for different messages)
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
707 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
708 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
709 * 0 : Operation complete.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
710 * !0 : An error occurred.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
711 */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
712
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
713 /*
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
714 * FUNCTION: fd_rt_out_unregister
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
715 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
716 * PARAMETERS:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
717 * 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
718 * 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
719 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
720 * DESCRIPTION:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
721 * 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
722 *
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
723 * RETURN VALUE:
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
724 * 0 : The callback is unregistered.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
725 * EINVAL : A parameter is invalid.
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
726 */
e5fcd672caff Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 83
diff changeset
727 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
728
c662d3eb6ff6 Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 82
diff changeset
729
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
730 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
731 /* EVENTS */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
732 /*============================================================*/
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
733
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
734 struct fd_event {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
735 int code; /* codespace depends on the queue */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
736 size_t size;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
737 void *data;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
738 };
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
739
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
740 /* 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
741 enum {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
742 FDEV_TERMINATE = 1000 /* request to terminate */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
743 ,FDEV_DUMP_DICT /* Dump the content of the dictionary */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
744 ,FDEV_DUMP_EXT /* Dump state of extensions */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
745 ,FDEV_DUMP_SERV /* Dump the server socket status */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
746 ,FDEV_DUMP_QUEUES /* Dump the message queues */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
747 ,FDEV_DUMP_CONFIG /* Dump the configuration */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
748 ,FDEV_DUMP_PEERS /* Dump the list of peers */
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
749 ,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
750 };
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
751
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
752 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
753 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
754 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
755 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
756 const char * fd_ev_str(int event);
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
757
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
758 /* for extensions */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
759 int fd_event_trig_regcb(int trigger_val, const char * module, void (*cb)(void));
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
760 void fd_event_trig_dump();
628
e1c6f45f5fcd Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 621
diff changeset
761
e1c6f45f5fcd Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 621
diff changeset
762
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
763 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
764 /* ENDPOINTS */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
765 /*============================================================*/
24
bd83ce9328ed Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 23
diff changeset
766
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
767 struct fd_endpoint {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
768 struct fd_list chain; /* link in cnf_endpoints list */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
769
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
770 union {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
771 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
772 sSA4 sin;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
773 sSA6 sin6;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
774 sSA sa;
621
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
775 }
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
776 #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
777 s
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
778 #endif /* SWIG */
04dbea46c7a2 Cleanup many SWIG definitions from main .h files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 620
diff changeset
779 ;
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
780
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
781 #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
782 #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
783 #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
784 #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
785 #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
786 #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
787 uint32_t flags; /* Additional information about the endpoint */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
788
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
789 /* 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
790 };
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
791
24
bd83ce9328ed Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 23
diff changeset
792 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
793 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
794 int fd_ep_filter_family( struct fd_list * list, int af );
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 336
diff changeset
795 int fd_ep_filter_list( struct fd_list * list, struct fd_list * exclude_list );
24
bd83ce9328ed Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 23
diff changeset
796 int fd_ep_clearflags( struct fd_list * list, uint32_t flags );
33
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
797 void fd_ep_dump_one( char * prefix, struct fd_endpoint * ep, char * suffix );
e6fcdf12b9a0 Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 25
diff changeset
798 void fd_ep_dump( 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
799
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
800
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
801 /*============================================================*/
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
802 /* APPLICATIONS IDs */
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
803 /*============================================================*/
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
804
82
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
805 struct fd_app {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
806 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
807 struct {
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
808 unsigned auth : 1;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
809 unsigned acct : 1;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
810 } flags;
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
811 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
812 application_id_t appid; /* The identifier of the application */
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
813 };
b6344f1d521a Some cleanups
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
814
43
2db15632a63d Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 42
diff changeset
815 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
816 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
817 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
818 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
819
658
f198d16fa7f4 Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 648
diff changeset
820 #endif /* _LIBFDCORE_H */
"Welcome to our mercurial repository"