annotate libfdcore/p_dp.c @ 882:ae96ae28f3dd 1.1.5

Limit python version to avoid using python3 (not compatible)
author Sebastien Decugis <sdecugis@freediameter.net>
date Sat, 03 Nov 2012 18:45:41 +0100
parents 4a9f08d6b6ba
children 2091bf698fb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 706
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
662
2e94ef0515d7 Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
5 * Copyright (c) 2011, WIDE Project and NICT *
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
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 *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
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 *
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 *
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 *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
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 *
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 *
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 *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
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: 454
diff changeset
36 #include "fdcore-internal.h"
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 /* This file contains code to handle Disconnect Peer messages (DPR and DPA) */
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
40 /* Delay to use before next reconnect attempt */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
41 int fd_p_dp_newdelay(struct fd_peer * peer)
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
42 {
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
43 int delay = peer->p_hdr.info.config.pic_tctimer ?: fd_g_config->cnf_timer_tc;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
44
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
45 switch (peer->p_hdr.info.runtime.pir_lastDC) {
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
46 case ACV_DC_REBOOTING:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
47 default:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
48 /* We use TcTimer to attempt reconnection */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
49 break;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
50 case ACV_DC_BUSY:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
51 /* No need to hammer the overloaded peer */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
52 delay *= 10;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
53 break;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
54 case ACV_DC_NOT_FRIEND:
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
55 /* He does not want to speak to us... let's retry a *lot* later maybe */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
56 delay *= 200;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
57 break;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
58 }
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
59 return delay;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
60 }
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
61
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 /* Handle a received message */
40
7e1deaa89540 Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
63 int fd_p_dp_handle(struct msg ** msg, int req, struct fd_peer * peer)
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64 {
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
65 TRACE_ENTRY("%p %d %p", msg, req, peer);
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
67 if (req) {
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
68 /* We received a DPR, save the Disconnect-Cause and go to CLOSING_GRACE or terminate the connection */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
69 struct avp * dc;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
70
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
71 CHECK_FCT( fd_msg_search_avp ( *msg, fd_dict_avp_DC, &dc ));
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
72 if (dc) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
73 struct avp_hdr * hdr;
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
74 CHECK_FCT( fd_msg_avp_hdr( dc, &hdr ) );
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
75 if (hdr->avp_value == NULL) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
76 /* This is a sanity check */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
77 TRACE_DEBUG(NONE, "BUG: Unset value in Disconnect-Cause in DPR");
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
78 fd_msg_dump_one(NONE, dc);
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
79 ASSERT(0); /* To check if this really happens, and understand why... */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
80 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
81
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
82 /* save the cause */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
83 peer->p_hdr.info.runtime.pir_lastDC = hdr->avp_value->u32;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
84 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
85 if (TRACE_BOOL(INFO)) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
86 if (dc) {
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
87 struct dict_object * dictobj;
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
88 struct dict_enumval_request er;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
89 memset(&er, 0, sizeof(er));
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
90
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
91 /* prepare the request */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
92 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, fd_dict_avp_DC, &er.type_obj, ENOENT ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
93 er.search.enum_value.u32 = peer->p_hdr.info.runtime.pir_lastDC;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
94
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
95 /* Search the enum value */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
96 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &er, &dictobj, 0 ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
97 if (dictobj) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
98 CHECK_FCT( fd_dict_getval( dictobj, &er.search ) );
229
965f5971dc23 Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 129
diff changeset
99 TRACE_DEBUG(INFO, "Peer '%s' sent a DPR with cause: %s\n", peer->p_hdr.info.pi_diamid, er.search.enum_name);
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
100 } else {
229
965f5971dc23 Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 129
diff changeset
101 TRACE_DEBUG(INFO, "Peer '%s' sent a DPR with unknown cause: %u\n", peer->p_hdr.info.pi_diamid, peer->p_hdr.info.runtime.pir_lastDC);
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
102 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
103 } else {
229
965f5971dc23 Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 129
diff changeset
104 TRACE_DEBUG(INFO, "Peer '%s' sent a DPR without Disconnect-Cause AVP\n", peer->p_hdr.info.pi_diamid);
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
105 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
106 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
107
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
108 /* Now reply with a DPA */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
109 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, 0 ) );
112
6a294d977878 Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 80
diff changeset
110 CHECK_FCT( fd_msg_rescode_set( *msg, "DIAMETER_SUCCESS", NULL, NULL, 1 ) );
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
111
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
112 /* Move to CLOSING state to failover outgoing messages (and avoid failing over the DPA...) */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
113 CHECK_FCT( fd_psm_change_state(peer, STATE_CLOSING) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
114
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
115 /* Now send the DPA */
229
965f5971dc23 Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 129
diff changeset
116 CHECK_FCT( fd_out_send( msg, NULL, peer, FD_CNX_ORDERED) );
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
117
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
118 if (fd_cnx_isMultichan(peer->p_cnxctx)) {
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
119 /* There is a possibililty that messages are still in the pipe coming here, so let's grace for 1 second */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
120 CHECK_FCT( fd_psm_change_state(peer, STATE_CLOSING_GRACE) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
121 fd_psm_next_timeout(peer, 0, 1);
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
122
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
123 } else {
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
124 /* Move to CLOSED state */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
125 fd_psm_cleanup(peer, 0);
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
126
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
127 /* Reset the timer for next connection attempt -- we'll retry sooner or later depending on the disconnection cause */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
128 fd_psm_next_timeout(peer, 1, fd_p_dp_newdelay(peer));
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
129 }
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
130 } else {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
131 /* We received a DPA */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
132 int curstate = fd_peer_getstate(peer);
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
133 if (curstate != STATE_CLOSING) {
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
134 TRACE_DEBUG(INFO, "Ignoring DPA received in state %s", STATE_STR(curstate));
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
135 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
136
79
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
137 /* In theory, we should control the Result-Code AVP. But since we will not go back to OPEN state here anyway, let's skip it */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
138
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
139 /* TODO("Control Result-Code in the DPA") */
79
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
140 CHECK_FCT_DO( fd_msg_free( *msg ), /* continue */ );
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
141 *msg = NULL;
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
142
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
143 if (fd_cnx_isMultichan(peer->p_cnxctx)) {
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
144 CHECK_FCT( fd_psm_change_state(peer, STATE_CLOSING_GRACE) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
145 fd_psm_next_timeout(peer, 0, 1);
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
146 peer->p_flags.pf_localterm = 1;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
147 }
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
148 /* otherwise, return in CLOSING state, the psm will handle it */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
149 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
150
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
151 return 0;
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152 }
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 /* Start disconnection of a peer: send DPR */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
155 int fd_p_dp_initiate(struct fd_peer * peer, char * reason)
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156 {
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
157 struct msg * msg = NULL;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
158 struct dict_object * dictobj = NULL;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
159 struct avp * avp = NULL;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
160 struct dict_enumval_request er;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
161 union avp_value val;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
162
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
163 TRACE_ENTRY("%p %p", peer, reason);
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
164
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
165 /* Create a new DWR instance */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
166 CHECK_FCT( fd_msg_new ( fd_dict_cmd_DPR, MSGFL_ALLOC_ETEID, &msg ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
167
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
168 /* Add the Origin information */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
169 CHECK_FCT( fd_msg_add_origin ( msg, 0 ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
170
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
171 /* Add the Disconnect-Cause */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
172 CHECK_FCT( fd_msg_avp_new ( fd_dict_avp_DC, 0, &avp ) );
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
174 /* Search the value in the dictionary */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
175 memset(&er, 0, sizeof(er));
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
176 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, fd_dict_avp_DC, &er.type_obj, ENOENT ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
177 er.search.enum_name = reason ?: "REBOOTING";
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
178 CHECK_FCT_DO( fd_dict_search( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &er, &dictobj, ENOENT ), { ASSERT(0); /* internal error: unknown reason */ } );
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
179 CHECK_FCT( fd_dict_getval( dictobj, &er.search ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
180
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
181 /* Set the value in the AVP */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
182 val.u32 = er.search.enum_value.u32;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
183 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
184 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
185
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
186 /* Save the value also in the peer */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
187 peer->p_hdr.info.runtime.pir_lastDC = val.u32;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
188
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
189 /* Update the peer state and timer */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
190 CHECK_FCT( fd_psm_change_state(peer, STATE_CLOSING) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
191 fd_psm_next_timeout(peer, 0, DPR_TIMEOUT);
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
192
80
56f0b629e036 Fix race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 79
diff changeset
193 /* Now send the DPR message */
229
965f5971dc23 Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 129
diff changeset
194 CHECK_FCT_DO( fd_out_send(&msg, NULL, peer, FD_CNX_ORDERED), /* ignore since we are on timeout anyway */ );
80
56f0b629e036 Fix race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 79
diff changeset
195
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
196 return 0;
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
197 }
"Welcome to our mercurial repository"