Mercurial > hg > freeDiameter
annotate libfdcore/p_dw.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 | 712c7bbf1016 |
children | 2091bf698fb1 |
rev | line source |
---|---|
36 | 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> * |
36 | 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 | 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:
454
diff
changeset
|
36 #include "fdcore-internal.h" |
36 | 37 |
38 /* This file contains code to handle Device Watchdog messages (DWR and DWA) */ | |
39 | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
40 /* Check the value of Origin-State-Id is consistent in a DWR or DWA -- we return an error otherwise */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
41 static int check_state_id(struct msg * msg, struct fd_peer * peer) |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
42 { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
43 struct avp * osi; |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
44 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
45 /* Check if the request contains the Origin-State-Id */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
46 CHECK_FCT( fd_msg_search_avp ( msg, fd_dict_avp_OSI, &osi ) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
47 if (osi) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
48 /* Check the value is consistent with the saved one */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
49 struct avp_hdr * hdr; |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
50 CHECK_FCT( fd_msg_avp_hdr( osi, &hdr ) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
51 if (hdr->avp_value == NULL) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
52 /* This is a sanity check */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
53 TRACE_DEBUG(NONE, "BUG: Unset value in Origin-State-Id in DWR / DWA"); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
54 fd_msg_dump_one(NONE, osi); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
55 ASSERT(0); /* To check if this really happens, and understand why... */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
56 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
57 |
745
712c7bbf1016
Fix for bug on Origin-State-Id reported in http://lists.freediameter.net/pipermail/help/2011-May/000156.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
58 if (! peer->p_hdr.info.runtime.pir_orstate) { |
712c7bbf1016
Fix for bug on Origin-State-Id reported in http://lists.freediameter.net/pipermail/help/2011-May/000156.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
59 /* It was not already received in CER/CEA, save it now */ |
712c7bbf1016
Fix for bug on Origin-State-Id reported in http://lists.freediameter.net/pipermail/help/2011-May/000156.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
60 peer->p_hdr.info.runtime.pir_orstate = hdr->avp_value->u32; |
712c7bbf1016
Fix for bug on Origin-State-Id reported in http://lists.freediameter.net/pipermail/help/2011-May/000156.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
61 } |
712c7bbf1016
Fix for bug on Origin-State-Id reported in http://lists.freediameter.net/pipermail/help/2011-May/000156.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
62 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
63 if (peer->p_hdr.info.runtime.pir_orstate != hdr->avp_value->u32) { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
64 TRACE_DEBUG(INFO, "Received a new Origin-State-Id from peer '%s'! (%x -> %x); resetting the connection.\n", |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
65 peer->p_hdr.info.pi_diamid, |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
66 peer->p_hdr.info.runtime.pir_orstate, |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
67 hdr->avp_value->u32 ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
68 return EINVAL; |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
69 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
70 } |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
71 return 0; |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
72 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
73 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
74 /* Create and send a DWR */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
75 static int send_DWR(struct fd_peer * peer) |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
76 { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
77 struct msg * msg = NULL; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
78 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
79 /* Create a new DWR instance */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
80 CHECK_FCT( fd_msg_new ( fd_dict_cmd_DWR, MSGFL_ALLOC_ETEID, &msg ) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
81 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
82 /* Add the content of the message (only the origin) */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
83 CHECK_FCT( fd_msg_add_origin ( msg, 1 ) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
84 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
85 /* Now send this message */ |
229
965f5971dc23
Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
74
diff
changeset
|
86 CHECK_FCT( fd_out_send(&msg, NULL, peer, FD_CNX_ORDERED) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
87 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
88 /* And mark the pending DW */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
89 peer->p_flags.pf_dw_pending = 1; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
90 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
91 return 0; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
92 } |
36 | 93 |
94 /* Handle an incoming message */ | |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
95 int fd_p_dw_handle(struct msg ** msg, int req, struct fd_peer * peer) |
36 | 96 { |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
97 int reset_tmr = 0; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
98 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
99 TRACE_ENTRY("%p %d %p", msg, req, peer); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
100 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
101 /* Check the value of OSI for information */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
102 CHECK_FCT( check_state_id(*msg, peer) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
103 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
104 if (req) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
105 /* If we receive a DWR, send back a DWA */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
106 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, 0 ) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
107 CHECK_FCT( fd_msg_rescode_set( *msg, "DIAMETER_SUCCESS", NULL, NULL, 0 ) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
108 CHECK_FCT( fd_msg_add_origin ( *msg, 1 ) ); |
229
965f5971dc23
Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
74
diff
changeset
|
109 CHECK_FCT( fd_out_send( msg, peer->p_cnxctx, peer, FD_CNX_ORDERED) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
110 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
111 } else { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
112 /* Discard the DWA */ |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
113 CHECK_FCT_DO( fd_msg_free(*msg), /* continue */ ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
114 *msg = NULL; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
115 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
116 /* And clear the pending DW flag */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
117 peer->p_flags.pf_dw_pending = 0; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
118 } |
36 | 119 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
120 /* Now update timeout */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
121 if (req) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
122 /* Update timeout only if we did not already send a DWR ourselves */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
123 reset_tmr = !peer->p_flags.pf_dw_pending; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
124 } else { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
125 /* Reset the timer */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
126 reset_tmr = 1; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
127 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
128 if (reset_tmr) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
129 fd_psm_next_timeout(peer, 1, peer->p_hdr.info.config.pic_twtimer ?: fd_g_config->cnf_timer_tw); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
130 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
131 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
132 /* If we are in REOPEN state, increment the counter */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
133 if (fd_peer_getstate(peer) == STATE_REOPEN) { |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
134 peer->p_flags.pf_reopen_cnt += 1; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
135 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
136 if (peer->p_flags.pf_reopen_cnt) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
137 /* Send a new DWR */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
138 CHECK_FCT( send_DWR(peer) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
139 } else { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
140 /* Move to OPEN state */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
141 CHECK_FCT( fd_psm_change_state(peer, STATE_OPEN) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
142 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
143 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
144 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
145 return 0; |
36 | 146 } |
147 | |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
148 /* Handle a timeout in the PSM (OPEN or REOPEN state only) */ |
36 | 149 int fd_p_dw_timeout(struct fd_peer * peer) |
150 { | |
74 | 151 TRACE_ENTRY("%p", peer); |
152 | |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
153 if (peer->p_flags.pf_dw_pending) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
154 /* We have sent a DWR and received no answer during TwTimer */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
155 CHECK_FCT( fd_psm_change_state(peer, STATE_SUSPECT) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
156 fd_psm_next_timeout(peer, 0, 2 * (peer->p_hdr.info.config.pic_twtimer ?: fd_g_config->cnf_timer_tw) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
157 } else { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
158 /* The timeout has expired, send a DWR */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
159 CHECK_FCT( send_DWR(peer) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
160 fd_psm_next_timeout(peer, 0, peer->p_hdr.info.config.pic_twtimer ?: fd_g_config->cnf_timer_tw ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
161 } |
36 | 162 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
163 return 0; |
36 | 164 } |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
165 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
166 /* Handle DW exchanges after the peer has come alive again */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
167 int fd_p_dw_reopen(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
|
168 { |
74 | 169 TRACE_ENTRY("%p", peer); |
170 | |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
171 peer->p_flags.pf_reopen_cnt = 1; |
74 | 172 peer->p_flags.pf_cnx_pb = 0; |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
173 CHECK_FCT( send_DWR(peer) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
174 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
175 return 0; |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
176 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
177 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
178 |