annotate freeDiameter/p_dp.c @ 454:f1484823cb4a

Small hack which might spear some concurrency problems and is quite harmless
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 29 Jul 2010 16:11:12 +0900
parents 26aafbbc1640
children
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) *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> *
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
258
5df55136361b Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 229
diff changeset
5 * Copyright (c) 2010, 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
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 #include "fD.h"
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
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
40 /* Handle a received message */
40
7e1deaa89540 Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 36
diff changeset
41 int fd_p_dp_handle(struct msg ** msg, int req, struct fd_peer * peer)
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
42 {
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
43 TRACE_ENTRY("%p %d %p", msg, req, peer);
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
44
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
45 if (req) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
46 /* We received a DPR, save the Disconnect-Cause and terminate the connection */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
47 struct avp * dc;
79
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
48 int delay = peer->p_hdr.info.config.pic_tctimer ?: fd_g_config->cnf_timer_tc;
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
49
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
50 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
51 if (dc) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
52 /* Check the value is consistent with the saved one */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
53 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
54 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
55 if (hdr->avp_value == NULL) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
56 /* This is a sanity check */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
57 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
58 fd_msg_dump_one(NONE, dc);
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
59 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
60 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
61
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
62 peer->p_hdr.info.runtime.pir_lastDC = hdr->avp_value->u32;
79
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
63
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
64 switch (hdr->avp_value->u32) {
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
65 case ACV_DC_REBOOTING:
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
66 default:
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
67 /* We use TcTimer to attempt reconnection */
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
68 break;
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
69 case ACV_DC_BUSY:
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
70 /* No need to hammer the overloaded peer */
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
71 delay *= 10;
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
72 break;
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
73 case ACV_DC_NOT_FRIEND:
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
74 /* He does not want to speak to us... let's retry a lot later maybe */
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
75 delay *= 200;
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
76 break;
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
77 }
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
78 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
79 if (TRACE_BOOL(INFO)) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
80 if (dc) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
81 struct dict_object * dictobj = NULL;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
82 struct dict_enumval_request er;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
83 memset(&er, 0, sizeof(er));
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
84 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
85 er.search.enum_value.u32 = peer->p_hdr.info.runtime.pir_lastDC;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
86 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
87 if (dictobj) {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
88 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
89 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
90 } else {
229
965f5971dc23 Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 129
diff changeset
91 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
92 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
93 } else {
229
965f5971dc23 Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 129
diff changeset
94 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
95 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
96 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
97
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
98 /* Now reply with a DPA */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
99 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
100 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
101
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
102 /* Move to CLOSING state to failover outgoing messages (and avoid failing the DPA...) */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
103 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
104
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
105 /* 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
106 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
107
79
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
108 /* Move to CLOSED state */
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
109 fd_psm_cleanup(peer, 0);
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
110
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
111 /* Reset the timer for next connection attempt -- we'll retry sooner or later depending on the disconnection cause */
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
112 fd_psm_next_timeout(peer, 1, delay);
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
113
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
114 } else {
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
115 /* We received a DPA */
454
f1484823cb4a Small hack which might spear some concurrency problems and is quite harmless
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
116 fd_cpu_flush_cache();
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
117 if (peer->p_hdr.info.runtime.pir_state != STATE_CLOSING) {
229
965f5971dc23 Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 129
diff changeset
118 TRACE_DEBUG(INFO, "Ignoring DPA received in state %s", STATE_STR(peer->p_hdr.info.runtime.pir_state));
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
119 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
120
79
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
121 /* 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 */
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
122 CHECK_FCT_DO( fd_msg_free( *msg ), /* continue */ );
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
123 *msg = NULL;
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
124
d273a2ce19c8 Fix problem in DPR handling
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
125 /* The calling function handles cleaning the PSM and terminating the peer since we return in CLOSING state */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
126 }
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
127
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
128 return 0;
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
129 }
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
130
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
131 /* Start disconnection of a peer: send DPR */
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
132 int fd_p_dp_initiate(struct fd_peer * peer, char * reason)
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
133 {
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
134 struct msg * msg = NULL;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
135 struct dict_object * dictobj = NULL;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
136 struct avp * avp = NULL;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
137 struct dict_enumval_request er;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
138 union avp_value val;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
139
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
140 TRACE_ENTRY("%p %p", peer, reason);
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
141
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
142 /* Create a new DWR instance */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
143 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
144
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
145 /* Add the Origin information */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
146 CHECK_FCT( fd_msg_add_origin ( msg, 0 ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
147
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
148 /* Add the Disconnect-Cause */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
149 CHECK_FCT( fd_msg_avp_new ( fd_dict_avp_DC, 0, &avp ) );
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
150
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
151 /* Search the value in the dictionary */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
152 memset(&er, 0, sizeof(er));
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
153 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
154 er.search.enum_name = reason ?: "REBOOTING";
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
155 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &er, &dictobj, ENOENT ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
156 CHECK_FCT( fd_dict_getval( dictobj, &er.search ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
157
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
158 /* Set the value in the AVP */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
159 val.u32 = er.search.enum_value.u32;
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
160 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) );
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
161 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
162
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
163 /* Save the value also in the peer */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
164 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
165
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
166 /* Update the peer state and timer */
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
167 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
168 fd_psm_next_timeout(peer, 0, DPR_TIMEOUT);
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
169
80
56f0b629e036 Fix race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 79
diff changeset
170 /* 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
171 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
172
78
a58f0757c06a Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 40
diff changeset
173 return 0;
36
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
174 }
"Welcome to our mercurial repository"