Mercurial > hg > freeDiameter
annotate libfdcore/p_dw.c @ 1562:6219359a36a9 default tip
Merge latest changes from proposed branch
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Mon, 21 Jun 2021 19:08:18 +0800 |
parents | 8f9684264fe0 |
children |
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 * * |
1127
1af09cc156d6
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
5 * Copyright (c) 2013, 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 */ |
1119
79dd22145f52
Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents:
974
diff
changeset
|
53 LOG_F("Ignored an Origin-State-Id AVP with unset value in DWR/DWA"); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
54 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
|
55 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
56 |
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
|
57 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
|
58 /* 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
|
59 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
|
60 } |
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 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
62 if (peer->p_hdr.info.runtime.pir_orstate != hdr->avp_value->u32) { |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
745
diff
changeset
|
63 TRACE_DEBUG(INFO, "Received a new Origin-State-Id from peer '%s'! (%x -> %x); resetting the connection.", |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
64 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
|
65 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
|
66 hdr->avp_value->u32 ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
67 return EINVAL; |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
68 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
69 } |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
70 return 0; |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
71 } |
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 /* Create and send a DWR */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
74 static int send_DWR(struct fd_peer * peer) |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
75 { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
76 struct msg * msg = NULL; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
77 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
78 /* Create a new DWR instance */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
79 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
|
80 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
81 /* 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
|
82 CHECK_FCT( fd_msg_add_origin ( msg, 1 ) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
83 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
84 /* Now send this message */ |
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:
1186
diff
changeset
|
85 CHECK_FCT( fd_out_send(&msg, NULL, peer, 0) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
86 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
87 /* And mark the pending DW */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
88 peer->p_flags.pf_dw_pending = 1; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
89 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
90 return 0; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
91 } |
36 | 92 |
93 /* Handle an incoming message */ | |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
94 int fd_p_dw_handle(struct msg ** msg, int req, struct fd_peer * peer) |
36 | 95 { |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
96 int reset_tmr = 0; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
97 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
98 TRACE_ENTRY("%p %d %p", msg, req, peer); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
99 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
100 /* 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
|
101 CHECK_FCT( check_state_id(*msg, peer) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
102 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
103 if (req) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
104 /* 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
|
105 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
|
106 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
|
107 CHECK_FCT( fd_msg_add_origin ( *msg, 1 ) ); |
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:
1186
diff
changeset
|
108 CHECK_FCT( fd_out_send( msg, peer->p_cnxctx, peer, 0) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
109 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
110 } else { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
111 /* Discard the DWA */ |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
112 CHECK_FCT_DO( fd_msg_free(*msg), /* continue */ ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
113 *msg = NULL; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
114 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
115 /* And clear the pending DW flag */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
116 peer->p_flags.pf_dw_pending = 0; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
117 } |
36 | 118 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
119 /* Now update timeout */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
120 if (req) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
121 /* 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
|
122 reset_tmr = !peer->p_flags.pf_dw_pending; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
123 } else { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
124 /* Reset the timer */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
125 reset_tmr = 1; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
126 } |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
127 if (reset_tmr) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
128 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
|
129 } |
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 /* 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
|
132 if (fd_peer_getstate(peer) == STATE_REOPEN) { |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
133 peer->p_flags.pf_reopen_cnt += 1; |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
134 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
135 if (peer->p_flags.pf_reopen_cnt) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
136 /* Send a new DWR */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
137 CHECK_FCT( send_DWR(peer) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
138 } else { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
139 /* Move to OPEN state */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
140 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
|
141 } |
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 return 0; |
36 | 145 } |
146 | |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
147 /* Handle a timeout in the PSM (OPEN or REOPEN state only) */ |
36 | 148 int fd_p_dw_timeout(struct fd_peer * peer) |
149 { | |
74 | 150 TRACE_ENTRY("%p", peer); |
151 | |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
152 if (peer->p_flags.pf_dw_pending) { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
153 /* 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
|
154 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
|
155 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
|
156 } else { |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
157 /* The timeout has expired, send a DWR */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
158 CHECK_FCT( send_DWR(peer) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
159 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
|
160 } |
36 | 161 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
162 return 0; |
36 | 163 } |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
164 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
165 /* 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
|
166 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
|
167 { |
74 | 168 TRACE_ENTRY("%p", peer); |
169 | |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
170 peer->p_flags.pf_reopen_cnt = 1; |
74 | 171 peer->p_flags.pf_cnx_pb = 0; |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
172 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
|
173 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
174 return 0; |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
175 } |
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 |