Mercurial > hg > freeDiameter
annotate libfdcore/fdcore-internal.h @ 1240:0420ccc4671a
Add a counter for the sent requests for which we did not wait for an answer. It might be relevant this value contributes to the load estimate of the remote peer, but it is not very reliable
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Thu, 10 Oct 2013 16:30:55 +0200 |
parents | 8f9684264fe0 |
children | 239ba25870d8 |
rev | line source |
---|---|
0 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
740
4a9f08d6b6ba
Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
0 | 4 * * |
928
5053f1abcf5d
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
909
diff
changeset
|
5 * Copyright (c) 2013, WIDE Project and NICT * |
0 | 6 * All rights reserved. * |
7 * * | |
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * | |
9 * permitted provided that the following conditions are met: * | |
10 * * | |
11 * * Redistributions of source code must retain the above * | |
12 * copyright notice, this list of conditions and the * | |
13 * following disclaimer. * | |
14 * * | |
15 * * Redistributions in binary form must reproduce the above * | |
16 * copyright notice, this list of conditions and the * | |
17 * following disclaimer in the documentation and/or other * | |
18 * materials provided with the distribution. * | |
19 * * | |
20 * * Neither the name of the WIDE Project or NICT nor the * | |
21 * names of its contributors may be used to endorse or * | |
22 * promote products derived from this software without * | |
23 * specific prior written permission of WIDE Project and * | |
24 * NICT. * | |
25 * * | |
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * | |
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | |
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | |
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | |
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | |
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | |
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | |
34 *********************************************************************************************************/ | |
35 | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
36 /* This file contains the definitions for internal use in the freeDiameter core library */ |
0 | 37 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
38 #ifndef _FDCORE_INTERNAL_H |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
39 #define _FDCORE_INTERNAL_H |
0 | 40 |
1
bafb831ba688
Fix names to proper case for freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
41 #include <freeDiameter/freeDiameter-host.h> |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
42 #include <freeDiameter/libfdcore.h> |
304
ad3c46016584
Added install directives for cmake; also allow default directory to seek for extensions and configuration files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
285
diff
changeset
|
43 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
44 #ifdef DISABLE_SCTP |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
45 #undef IPPROTO_SCTP |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
46 #define IPPROTO_SCTP (2 = 4) /* some compilation error to spot the references */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
47 #endif /* DISABLE_SCTP */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
48 |
815
958d3efb45b5
Add test for AI_ADDRCONFIG for platforms where it does not exist
Sebastien Decugis <sdecugis@freediameter.net>
parents:
808
diff
changeset
|
49 #ifndef HAVE_AI_ADDRCONFIG |
958d3efb45b5
Add test for AI_ADDRCONFIG for platforms where it does not exist
Sebastien Decugis <sdecugis@freediameter.net>
parents:
808
diff
changeset
|
50 #define AI_ADDRCONFIG 0 /* ignore this flag at the moment */ |
958d3efb45b5
Add test for AI_ADDRCONFIG for platforms where it does not exist
Sebastien Decugis <sdecugis@freediameter.net>
parents:
808
diff
changeset
|
51 #endif /* HAVE_AI_ADDRCONFIG */ |
958d3efb45b5
Add test for AI_ADDRCONFIG for platforms where it does not exist
Sebastien Decugis <sdecugis@freediameter.net>
parents:
808
diff
changeset
|
52 |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
53 /* Timeout for establishing a connection */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
54 #ifndef CNX_TIMEOUT |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
55 #define CNX_TIMEOUT 10 /* in seconds */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
56 #endif /* CNX_TIMEOUT */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
57 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
58 /* Timeout for receiving a CER after incoming connection is established */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
59 #ifndef INCNX_TIMEOUT |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
60 #define INCNX_TIMEOUT 20 /* in seconds */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
61 #endif /* INCNX_TIMEOUT */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
62 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
63 /* Timeout for receiving a CEA after CER is sent */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
64 #ifndef CEA_TIMEOUT |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
65 #define CEA_TIMEOUT 10 /* in seconds */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
66 #endif /* CEA_TIMEOUT */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
67 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
68 /* The timeout value to wait for answer to a DPR */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
69 #ifndef DPR_TIMEOUT |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
70 #define DPR_TIMEOUT 15 /* in seconds */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
71 #endif /* DPR_TIMEOUT */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
72 |
1015 | 73 /* Delay where the connection is maintained opened to allow exchanging remaining pending answers after DPR/DPA */ |
1010
357c2f892d24
Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
938
diff
changeset
|
74 #ifndef GRACE_TIMEOUT |
357c2f892d24
Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
938
diff
changeset
|
75 #define GRACE_TIMEOUT 1 /* in seconds */ |
357c2f892d24
Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
938
diff
changeset
|
76 #endif /* GRACE_TIMEOUT */ |
357c2f892d24
Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
938
diff
changeset
|
77 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
78 /* The Vendor-Id to advertise in CER/CEA */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
79 #ifndef MY_VENDOR_ID |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
80 #define MY_VENDOR_ID 0 /* Reserved value to tell it must be ignored */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
81 #endif /* MY_VENDOR_ID */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
82 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
83 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
84 |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
85 /* Configuration */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
86 int fd_conf_init(); |
447
097bae83b07a
Forgot to cleanup the configuration on exit, spotted by valgrind
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
403
diff
changeset
|
87 int fd_conf_deinit(); |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
88 int fd_conf_parse(); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
89 int fddparse(struct fd_config * conf); /* yacc generated */ |
805
fb5e0fd923ff
Updated verification of the local certificate following GnuTLS 3.x guideline
Sebastien Decugis <sdecugis@freediameter.net>
parents:
740
diff
changeset
|
90 int fd_conf_stream_to_gnutls_datum(FILE * pemfile, gnutls_datum_t *out); |
fb5e0fd923ff
Updated verification of the local certificate following GnuTLS 3.x guideline
Sebastien Decugis <sdecugis@freediameter.net>
parents:
740
diff
changeset
|
91 |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
92 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
93 /* Extensions */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
94 int fd_ext_add( char * filename, char * conffile ); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
95 int fd_ext_load(); |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
96 int fd_ext_term(void); |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
97 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
98 /* Messages */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
99 int fd_msg_init(void); |
909
047f99b09632
Clean some externs for picky linkers (by Thomas)
Sebastien Decugis <sdecugis@freediameter.net>
parents:
894
diff
changeset
|
100 extern struct dict_object * fd_dict_avp_OSI; /* Origin-State-Id */ |
047f99b09632
Clean some externs for picky linkers (by Thomas)
Sebastien Decugis <sdecugis@freediameter.net>
parents:
894
diff
changeset
|
101 extern struct dict_object * fd_dict_cmd_CER; /* Capabilities-Exchange-Request */ |
047f99b09632
Clean some externs for picky linkers (by Thomas)
Sebastien Decugis <sdecugis@freediameter.net>
parents:
894
diff
changeset
|
102 extern struct dict_object * fd_dict_cmd_DWR; /* Device-Watchdog-Request */ |
047f99b09632
Clean some externs for picky linkers (by Thomas)
Sebastien Decugis <sdecugis@freediameter.net>
parents:
894
diff
changeset
|
103 extern struct dict_object * fd_dict_avp_DC; /* Disconnect-Cause */ |
047f99b09632
Clean some externs for picky linkers (by Thomas)
Sebastien Decugis <sdecugis@freediameter.net>
parents:
894
diff
changeset
|
104 extern struct dict_object * fd_dict_cmd_DPR; /* Disconnect-Peer-Request */ |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
105 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
106 /* Global message queues */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
107 extern struct fifo * fd_g_incoming; /* all messages received from other peers, except local messages (CER, ...) */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
108 extern struct fifo * fd_g_outgoing; /* messages to be sent to other peers on the network following routing procedure */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
109 extern struct fifo * fd_g_local; /* messages to be handled to local extensions */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
110 /* Message queues */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
111 int fd_queues_init(void); |
124
cc42d8607114
Completed cleanups of queues when the daemon is stopping
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
123
diff
changeset
|
112 int fd_queues_fini(struct fifo ** queue); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
113 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
114 /* Trigged events */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
115 int fd_event_trig_call_cb(int trigger_val); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
116 int fd_event_trig_fini(void); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
117 |
0 | 118 /* Create all the dictionary objects defined in the Diameter base RFC. */ |
119 int fd_dict_base_protocol(struct dictionary * dict); | |
120 | |
82 | 121 /* Routing */ |
123
960fa8048805
Merged routing and dispatch files for similarities
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
122
diff
changeset
|
122 int fd_rtdisp_init(void); |
960fa8048805
Merged routing and dispatch files for similarities
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
122
diff
changeset
|
123 int fd_rtdisp_cleanstop(void); |
960fa8048805
Merged routing and dispatch files for similarities
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
122
diff
changeset
|
124 int fd_rtdisp_fini(void); |
960fa8048805
Merged routing and dispatch files for similarities
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
122
diff
changeset
|
125 int fd_rtdisp_cleanup(void); |
82 | 126 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
127 /* Sentinel for the sent requests list */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
128 struct sr_list { |
649
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
447
diff
changeset
|
129 struct fd_list srs; /* requests ordered by hop-by-hop id */ |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
447
diff
changeset
|
130 struct fd_list exp; /* requests that have a timeout set, ordered by timeout */ |
1010
357c2f892d24
Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
938
diff
changeset
|
131 long cnt; /* number of requests in the srs list */ |
1240
0420ccc4671a
Add a counter for the sent requests for which we did not wait for an answer. It might be relevant this value contributes to the load estimate of the remote peer, but it is not very reliable
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1238
diff
changeset
|
132 long cnt_lost; /* number of requests that have not been answered in time. |
0420ccc4671a
Add a counter for the sent requests for which we did not wait for an answer. It might be relevant this value contributes to the load estimate of the remote peer, but it is not very reliable
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1238
diff
changeset
|
133 It is decremented when an unexpected answer is received, so this may not be accurate. */ |
649
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
447
diff
changeset
|
134 pthread_mutex_t mtx; /* mutex to protect these lists */ |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
447
diff
changeset
|
135 pthread_cond_t cnd; /* cond var used by the thread that handles timeouts */ |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1010
diff
changeset
|
136 pthread_t thr; /* the thread that handles timeouts (expirecb called in separate forked threads) */ |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
137 }; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
138 |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
139 /* Peers */ |
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
140 struct fd_peer { /* The "real" definition of the peer structure */ |
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
141 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
142 /* The public data */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
143 struct peer_hdr p_hdr; |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
144 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
145 /* Eye catcher, EYEC_PEER */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
146 int p_eyec; |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
147 #define EYEC_PEER 0x373C9336 |
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
148 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
149 /* Origin of this peer object, for debug */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
150 char *p_dbgorig; |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
151 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
152 /* State of the peer, and its lock */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
153 enum peer_state p_state; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
154 pthread_mutex_t p_state_mtx; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
155 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
156 /* Chaining in peers sublists */ |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
157 struct fd_list p_actives; /* list of peers in the STATE_OPEN state -- used by routing */ |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
158 struct fd_list p_expiry; /* list of expiring peers, ordered by their timeout value */ |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
159 struct timespec p_exp_timer; /* Timestamp where the peer will expire; updated each time activity is seen on the peer (except DW) */ |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
160 |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
161 /* Some flags influencing the peer state machine */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
162 struct { |
37
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
163 unsigned pf_responder : 1; /* The peer has been created to handle incoming connection */ |
154
4356de61174d
Small tweaks in the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
124
diff
changeset
|
164 unsigned pf_delete : 1; /* Destroy the peer when the connection is terminated */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
165 unsigned pf_localterm : 1; /* If the latest DPR/DPA was initiated from this side */ |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
166 |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
167 unsigned pf_dw_pending : 1; /* A DWR message was sent and not answered yet */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
168 |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
169 unsigned pf_cnx_pb : 1; /* The peer was disconnected because of watchdogs; must exchange 3 watchdogs before putting back to normal */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
170 unsigned pf_reopen_cnt : 2; /* remaining DW to be exchanged after re-established connection */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
171 |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
172 } p_flags; |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
173 |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
174 /* The events queue, peer state machine thread, timer for states timeouts */ |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
175 struct fifo *p_events; /* The mutex of this FIFO list protects also the state and timer information */ |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
176 pthread_t p_psm; |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
177 struct timespec p_psm_timer; |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
178 |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
179 /* Outgoing message queue, and thread managing sending the messages */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
180 struct fifo *p_tosend; |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
181 pthread_t p_outthr; |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
182 |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
183 /* The next hop-by-hop id value for the link, only read & modified by p_outthr */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
184 uint32_t p_hbh; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
185 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
186 /* Sent requests (for fallback), list of struct sentreq ordered by hbh */ |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
187 struct sr_list p_sr; |
1207
043b894b0511
Cleanups in failover situation to avoid deadlocks and corrupt messages ids. Tested OK now.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1186
diff
changeset
|
188 struct fifo *p_tofailover; |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
189 |
1010
357c2f892d24
Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
938
diff
changeset
|
190 /* Pending received requests not yet answered (count only) */ |
357c2f892d24
Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
938
diff
changeset
|
191 long p_reqin_count; /* We use p_state_mtx to protect this value */ |
357c2f892d24
Implement a new counter on pending answers to send back to a peer.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
938
diff
changeset
|
192 |
37
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
193 /* Data for transitional states before the peer is in OPEN state */ |
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
194 struct { |
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
195 struct cnxctx * p_receiver; /* Only used in case of election */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
196 struct msg * p_cer; /* Only used in case of election */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
197 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
198 pthread_t p_ini_thr; /* Initiator thread for establishing a connection */ |
38
68c1890f7049
Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
199 struct fd_list p_connparams; /* The list of connection attempts, see p_cnx.c */ |
37
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
200 }; |
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
201 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
202 /* connection context: socket and related information */ |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
203 struct cnxctx *p_cnxctx; |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
204 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
205 /* Callback for peer validation after the handshake */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
206 int (*p_cb2)(struct peer_info *); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
207 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
208 /* Callback on initial connection success / failure after the peer was added */ |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
209 void (*p_cb)(struct peer_info *, void *); |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
210 void *p_cb_data; |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
211 |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
212 }; |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
213 #define CHECK_PEER( _p ) \ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
214 (((_p) != NULL) && (((struct fd_peer *)(_p))->p_eyec == EYEC_PEER)) |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
215 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
216 #define fd_peer_getstate(peer) fd_peer_get_state((struct peer_hdr *)(peer)) |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
217 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
218 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
219 /* Events codespace for struct fd_peer->p_events */ |
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
220 enum { |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
221 /* request to terminate this peer : disconnect, requeue all messages */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1016
diff
changeset
|
222 FDEVP_TERMINATE = 1500 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
223 |
1102
1d7b3ebda27f
Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1098
diff
changeset
|
224 /* A connection object has received a message. (data contains the buffer + padding + struct fd_msg_pmdl) */ |
22
0b3b46da2c12
Progress on server code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
225 ,FDEVP_CNX_MSG_RECV |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
226 |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
227 /* A connection object has encountered an error (disconnected). */ |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
228 ,FDEVP_CNX_ERROR |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
229 |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
230 /* Endpoints of a connection have been changed (multihomed SCTP). */ |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
231 ,FDEVP_CNX_EP_CHANGE |
22
0b3b46da2c12
Progress on server code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
232 |
228 | 233 /* The connection is being shutdown (SCTP notification). */ |
234 ,FDEVP_CNX_SHUTDOWN | |
235 | |
37
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
236 /* A new connection (with a CER) has been received */ |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
237 ,FDEVP_CNX_INCOMING |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
238 |
37
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
239 /* A new connection has been established to the remote peer (event data is the cnxctx object) */ |
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
240 ,FDEVP_CNX_ESTABLISHED |
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
241 |
70
65b32c93f21e
Do not wait for timeout when all connections attempts have failed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
242 /* A connection attempt (initiator side) has failed */ |
65b32c93f21e
Do not wait for timeout when all connections attempts have failed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
243 ,FDEVP_CNX_FAILED |
65b32c93f21e
Do not wait for timeout when all connections attempts have failed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
244 |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
245 /* The PSM state is expired */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
246 ,FDEVP_PSM_TIMEOUT |
22
0b3b46da2c12
Progress on server code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
247 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
248 }; |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
249 #define CHECK_PEVENT( _e ) \ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1016
diff
changeset
|
250 (((int)(_e) >= FDEVP_TERMINATE) && ((int)(_e) <= FDEVP_PSM_TIMEOUT)) |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
251 /* The following macro is actually called in p_psm.c -- another solution would be to declare it static inline */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
252 #define DECLARE_PEV_STR() \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
253 const char * fd_pev_str(int event) \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
254 { \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
255 switch (event) { \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
256 case_str(FDEVP_TERMINATE); \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
257 case_str(FDEVP_CNX_MSG_RECV); \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
258 case_str(FDEVP_CNX_ERROR); \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
259 case_str(FDEVP_CNX_EP_CHANGE); \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
260 case_str(FDEVP_CNX_INCOMING); \ |
37
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
261 case_str(FDEVP_CNX_ESTABLISHED); \ |
70
65b32c93f21e
Do not wait for timeout when all connections attempts have failed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
262 case_str(FDEVP_CNX_FAILED); \ |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
263 case_str(FDEVP_PSM_TIMEOUT); \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
264 } \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
265 TRACE_DEBUG(FULL, "Unknown event : %d", event); \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
266 return "Unknown event"; \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
267 } |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
268 const char * fd_pev_str(int event); |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
269 |
229
965f5971dc23
Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
228
diff
changeset
|
270 /* The data structure for FDEVP_CNX_INCOMING event */ |
29
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
271 struct cnx_incoming { |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
272 struct msg * cer; /* the CER message received on this connection */ |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
273 struct cnxctx * cnx; /* The connection context */ |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
274 int validate; /* The peer is new, it must be validated (by an extension) or error CEA to be sent */ |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
275 }; |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
276 |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
277 /* Functions */ |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
278 int fd_peer_fini(); |
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
279 int fd_peer_alloc(struct fd_peer ** ptr); |
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
280 int fd_peer_free(struct fd_peer ** ptr); |
29
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
281 int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx ); |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
282 /* fd_peer_add declared in freeDiameter.h */ |
29
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
283 int fd_peer_validate( struct fd_peer * peer ); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
284 void fd_peer_failover_msg(struct fd_peer * peer); |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
285 |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
286 /* Peer expiry */ |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
287 int fd_p_expi_init(void); |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
288 int fd_p_expi_fini(void); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
289 int fd_p_expi_update(struct fd_peer * peer ); |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
290 |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
291 /* Peer state machine */ |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
292 int fd_psm_start(); |
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
293 int fd_psm_begin(struct fd_peer * peer ); |
78
a58f0757c06a
Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
70
diff
changeset
|
294 int fd_psm_terminate(struct fd_peer * peer, char * reason ); |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
295 void fd_psm_abord(struct fd_peer * peer ); |
36 | 296 void fd_psm_next_timeout(struct fd_peer * peer, int add_random, int delay); |
297 int fd_psm_change_state(struct fd_peer * peer, int new_state); | |
38
68c1890f7049
Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
298 void fd_psm_cleanup(struct fd_peer * peer, int terminate); |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
299 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
300 /* Peer out */ |
1238
8f9684264fe0
Change management of the p_reqin_count counter to be updated only on routable messages. This should limit the errors in the counter value resulting from rejected or discarded link-local messages.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1207
diff
changeset
|
301 int fd_out_send(struct msg ** msg, struct cnxctx * cnx, struct fd_peer * peer, int update_reqin_cnt); |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
302 int fd_out_start(struct fd_peer * peer); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
303 int fd_out_stop(struct fd_peer * peer); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
304 |
38
68c1890f7049
Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
305 /* Initiating connections */ |
68c1890f7049
Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
306 int fd_p_cnx_init(struct fd_peer * peer); |
68c1890f7049
Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
307 void fd_p_cnx_abort(struct fd_peer * peer, int cleanup_all); |
68c1890f7049
Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
308 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
309 /* Peer sent requests cache */ |
165
4679ff581d6a
Fix invalid restore of the hop-by-hop id on forwarded answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
154
diff
changeset
|
310 int fd_p_sr_store(struct sr_list * srlist, struct msg **req, uint32_t *hbhloc, uint32_t hbh_restore); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
311 int fd_p_sr_fetch(struct sr_list * srlist, uint32_t hbh, struct msg **req); |
649
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
447
diff
changeset
|
312 int fd_p_sr_start(struct sr_list * srlist); |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
447
diff
changeset
|
313 int fd_p_sr_stop(struct sr_list * srlist); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
314 void fd_p_sr_failover(struct sr_list * srlist); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
33
diff
changeset
|
315 |
36 | 316 /* Local Link messages (CER/CEA, DWR/DWA, DPR/DPA) */ |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
38
diff
changeset
|
317 int fd_p_ce_msgrcv(struct msg ** msg, int req, struct fd_peer * peer); |
36 | 318 int fd_p_ce_handle_newCER(struct msg ** msg, struct fd_peer * peer, struct cnxctx ** cnx, int valid); |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
38
diff
changeset
|
319 int fd_p_ce_handle_newcnx(struct fd_peer * peer, struct cnxctx * initiator); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
320 int fd_p_ce_process_receiver(struct fd_peer * peer); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
321 void fd_p_ce_clear_cnx(struct fd_peer * peer, struct cnxctx ** cnx_kept); |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
38
diff
changeset
|
322 int fd_p_dw_handle(struct msg ** msg, int req, struct fd_peer * peer); |
36 | 323 int fd_p_dw_timeout(struct fd_peer * peer); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
324 int fd_p_dw_reopen(struct fd_peer * peer); |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
38
diff
changeset
|
325 int fd_p_dp_handle(struct msg ** msg, int req, struct fd_peer * peer); |
78
a58f0757c06a
Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
70
diff
changeset
|
326 int fd_p_dp_initiate(struct fd_peer * peer, char * reason); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
327 int fd_p_dp_newdelay(struct fd_peer * peer); |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
328 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
329 /* Active peers -- routing process should only ever take the read lock, the write lock is managed by PSMs */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
330 extern struct fd_list fd_g_activ_peers; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
331 extern pthread_rwlock_t fd_g_activ_peers_rw; /* protect the list */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
332 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
31
diff
changeset
|
333 |
20
277ec00d793e
Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
16
diff
changeset
|
334 /* Server sockets */ |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
335 int fd_servers_start(); |
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
336 int fd_servers_stop(); |
20
277ec00d793e
Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
16
diff
changeset
|
337 |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
338 /* Connection contexts -- there are also definitions in cnxctx.h for the relevant files */ |
22
0b3b46da2c12
Progress on server code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
339 struct cnxctx * fd_cnx_serv_tcp(uint16_t port, int family, struct fd_endpoint * ep); |
0b3b46da2c12
Progress on server code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
340 struct cnxctx * fd_cnx_serv_sctp(uint16_t port, struct fd_list * ep_list); |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
341 int fd_cnx_serv_listen(struct cnxctx * conn); |
22
0b3b46da2c12
Progress on server code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
342 struct cnxctx * fd_cnx_serv_accept(struct cnxctx * serv); |
24
bd83ce9328ed
Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
23
diff
changeset
|
343 struct cnxctx * fd_cnx_cli_connect_tcp(sSA * sa, socklen_t addrlen); |
bd83ce9328ed
Cleanups and completed sctp code (not finished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
23
diff
changeset
|
344 struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list); |
29
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
345 int fd_cnx_start_clear(struct cnxctx * conn, int loop); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
346 void fd_cnx_sethostname(struct cnxctx * conn, DiamId_t hn); |
1186
56c36d1007b4
Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1181
diff
changeset
|
347 int fd_cnx_proto_info(struct cnxctx * conn, char * buf, size_t len); |
1181
22de21feec64
Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1102
diff
changeset
|
348 #define ALGO_HANDSHAKE_DEFAULT 0 /* TLS for TCP, DTLS for SCTP */ |
22de21feec64
Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1102
diff
changeset
|
349 #define ALGO_HANDSHAKE_3436 1 /* For TLS for SCTP also */ |
22de21feec64
Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1102
diff
changeset
|
350 int fd_cnx_handshake(struct cnxctx * conn, int mode, int algo, char * priority, void * alt_creds); |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
351 char * fd_cnx_getid(struct cnxctx * conn); |
29
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
352 int fd_cnx_getproto(struct cnxctx * conn); |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
353 int fd_cnx_getTLS(struct cnxctx * conn); |
1186
56c36d1007b4
Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1181
diff
changeset
|
354 int fd_cnx_is_unordered_delivery_supported(struct cnxctx * conn); |
56c36d1007b4
Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1181
diff
changeset
|
355 int fd_cnx_unordered_delivery(struct cnxctx * conn, int is_allowed); |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
356 int fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size); |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
378
diff
changeset
|
357 int fd_cnx_get_local_eps(struct fd_list * list); |
378
41e3c2a3721c
Replaced old mechanism to discover local addresses by a call to getifaddrs, lot cleaner!
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
304
diff
changeset
|
358 int fd_cnx_getremoteeps(struct cnxctx * conn, struct fd_list * eps); |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
359 char * fd_cnx_getremoteid(struct cnxctx * conn); |
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
360 int fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len); |
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
361 int fd_cnx_recv_setaltfifo(struct cnxctx * conn, struct fifo * alt_fifo); /* send FDEVP_CNX_MSG_RECV event to the fifo list */ |
1186
56c36d1007b4
Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1181
diff
changeset
|
362 int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len); |
28
3628f7d2ba88
some new functions backbones
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
363 void fd_cnx_destroy(struct cnxctx * conn); |
807
09f8f0c4f4a4
Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents:
805
diff
changeset
|
364 #ifdef GNUTLS_VERSION_300 |
09f8f0c4f4a4
Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents:
805
diff
changeset
|
365 int fd_tls_verify_credentials_2(gnutls_session_t session); |
09f8f0c4f4a4
Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents:
805
diff
changeset
|
366 #endif /* GNUTLS_VERSION_300 */ |
20
277ec00d793e
Backup before typhoon... Progress on server side
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
16
diff
changeset
|
367 |
1098
f38d77f9cfd3
Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
368 /* Internal calls of the hook mechanism */ |
f38d77f9cfd3
Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
369 void fd_hook_call(enum fd_hook_type type, struct msg * msg, struct fd_peer * peer, void * other, struct fd_msg_pmdl * pmdl); |
f38d77f9cfd3
Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
370 void fd_hook_associate(struct msg * msg, struct fd_msg_pmdl * pmdl); |
f38d77f9cfd3
Initial implementation of the hook mechanism
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
371 int fd_hooks_init(void); |
1102
1d7b3ebda27f
Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1098
diff
changeset
|
372 size_t fd_msg_pmdl_sizewithoverhead(size_t datalen); |
1d7b3ebda27f
Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1098
diff
changeset
|
373 struct fd_msg_pmdl * fd_msg_pmdl_get_inbuf(uint8_t * buf, size_t datalen); |
1d7b3ebda27f
Implemented the calls to HOOK_DATA_RECEIVED hook
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1098
diff
changeset
|
374 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
649
diff
changeset
|
375 #endif /* _FDCORE_INTERNAL_H */ |