Mercurial > hg > freeDiameter
annotate freeDiameter/p_psm.c @ 33:e6fcdf12b9a0
Added a lot of TODOs :)
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 29 Oct 2009 18:05:45 +0900 |
parents | 5ba91682f0bc |
children | 0e2b57789361 |
rev | line source |
---|---|
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
5 * Copyright (c) 2009, WIDE Project and NICT * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
ef9ef3bf4752
Progress on peer state machine
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 * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
ef9ef3bf4752
Progress on peer state machine
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 * |
ef9ef3bf4752
Progress on peer state machine
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 * |
ef9ef3bf4752
Progress on peer state machine
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 * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
ef9ef3bf4752
Progress on peer state machine
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 * |
ef9ef3bf4752
Progress on peer state machine
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 * |
ef9ef3bf4752
Progress on peer state machine
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 * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 #include "fD.h" |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
38 /* The actual declaration of peer_state_str */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
39 DECLARE_STATE_STR(); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
40 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
41 /* Helper for next macro */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
42 #define case_str( _val ) \ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
43 case _val : return #_val |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
44 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
45 DECLARE_PEV_STR(); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
46 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
47 /************************************************************************/ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
48 /* Delayed startup */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
49 /************************************************************************/ |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 static int started = 0; |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 static pthread_mutex_t started_mtx = PTHREAD_MUTEX_INITIALIZER; |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 static pthread_cond_t started_cnd = PTHREAD_COND_INITIALIZER; |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 /* Wait for start signal */ |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 static int fd_psm_waitstart() |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 { |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 TRACE_ENTRY(""); |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
58 CHECK_POSIX( pthread_mutex_lock(&started_mtx) ); |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 awake: |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 if (! started) { |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
61 pthread_cleanup_push( fd_cleanup_mutex, &started_mtx ); |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
62 CHECK_POSIX( pthread_cond_wait(&started_cnd, &started_mtx) ); |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 pthread_cleanup_pop( 0 ); |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 goto awake; |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 } |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 CHECK_POSIX( pthread_mutex_unlock(&started_mtx) ); |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
67 return 0; |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
68 } |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
70 /* Allow the state machines to start */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
71 int fd_psm_start() |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
72 { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
73 TRACE_ENTRY(""); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
74 CHECK_POSIX( pthread_mutex_lock(&started_mtx) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
75 started = 1; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
76 CHECK_POSIX( pthread_cond_broadcast(&started_cnd) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
77 CHECK_POSIX( pthread_mutex_unlock(&started_mtx) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
78 return 0; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
79 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
80 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
81 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
82 /************************************************************************/ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
83 /* Manage the list of active peers */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
84 /************************************************************************/ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
85 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
86 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
87 /* Enter/leave OPEN state */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
88 static int enter_open_state(struct fd_peer * peer) |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
89 { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
90 CHECK_POSIX( pthread_rwlock_wrlock(&fd_g_activ_peers_rw) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
91 TODO(" insert in fd_g_activ_peers "); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
92 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
93 CHECK_POSIX( pthread_rwlock_unlock(&fd_g_activ_peers_rw) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
94 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
95 /* Start the thread to handle outgoing messages */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
96 CHECK_FCT( fd_out_start(peer) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
97 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
98 return ENOTSUP; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
99 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
100 static int leave_open_state(struct fd_peer * peer) |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
101 { |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
102 TODO("Remove from active list"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
103 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
104 /* Stop the "out" thread */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
105 CHECK_FCT( fd_out_stop(peer) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
106 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
107 TODO("Failover pending messages: requeue in global structures"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
108 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
109 return ENOTSUP; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
110 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
111 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
112 /************************************************************************/ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
113 /* Helpers for state changes */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
114 /************************************************************************/ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
115 /* Change state */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
116 static int change_state(struct fd_peer * peer, int new_state) |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
117 { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
118 int old; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
119 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
120 TRACE_ENTRY("%p %d(%s)", peer, new_state, STATE_STR(new_state)); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
121 CHECK_PARAMS( CHECK_PEER(peer) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
122 old = peer->p_hdr.info.pi_state; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
123 if (old == new_state) |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
124 return 0; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
125 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
126 TRACE_DEBUG(FULL, "'%s'\t-> '%s'\t'%s'", |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
127 STATE_STR(old), |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
128 STATE_STR(new_state), |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
129 peer->p_hdr.info.pi_diamid); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
130 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
131 if (old == STATE_OPEN) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
132 CHECK_FCT( leave_open_state(peer) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
133 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
134 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
135 peer->p_hdr.info.pi_state = new_state; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
136 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
137 if (new_state == STATE_OPEN) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
138 CHECK_FCT( enter_open_state(peer) ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
139 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
140 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
141 return 0; |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
142 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
143 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
144 /* Set timeout timer of next event */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
145 static void psm_next_timeout(struct fd_peer * peer, int add_random, int delay) |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
146 { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
147 /* Initialize the timer */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
148 CHECK_POSIX_DO( clock_gettime( CLOCK_REALTIME, &peer->p_psm_timer ), ASSERT(0) ); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
149 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
150 if (add_random) { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
151 if (delay > 2) |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
152 delay -= 2; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
153 else |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
154 delay = 0; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
155 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
156 /* Add a random value between 0 and 4sec */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
157 peer->p_psm_timer.tv_sec += random() % 4; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
158 peer->p_psm_timer.tv_nsec+= random() % 1000000000L; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
159 if (peer->p_psm_timer.tv_nsec > 1000000000L) { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
160 peer->p_psm_timer.tv_nsec -= 1000000000L; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
161 peer->p_psm_timer.tv_sec ++; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
162 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
163 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
164 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
165 peer->p_psm_timer.tv_sec += delay; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
166 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
167 #if 0 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
168 /* temporary for debug */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
169 peer->p_psm_timer.tv_sec += 10; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
170 #endif |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
171 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
172 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
173 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
174 /************************************************************************/ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
175 /* The PSM thread */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
176 /************************************************************************/ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
177 /* Cancelation cleanup : set ZOMBIE state in the peer */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
178 void cleanup_state(void * arg) |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
179 { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
180 struct fd_peer * peer = (struct fd_peer *)arg; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
181 CHECK_PARAMS_DO( CHECK_PEER(peer), return ); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
182 peer->p_hdr.info.pi_state = STATE_ZOMBIE; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
183 return; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
184 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
185 |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
186 /* The state machine thread (controler) */ |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
187 static void * p_psm_th( void * arg ) |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
188 { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
189 struct fd_peer * peer = (struct fd_peer *)arg; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
190 int created_started = started; |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
191 int event; |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
22
diff
changeset
|
192 size_t ev_sz; |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
193 void * ev_data; |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
194 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
195 CHECK_PARAMS_DO( CHECK_PEER(peer), ASSERT(0) ); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
196 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
197 pthread_cleanup_push( cleanup_state, arg ); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
198 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
199 /* Set the thread name */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
200 { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
201 char buf[48]; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
202 sprintf(buf, "PSM/%.*s", sizeof(buf) - 5, peer->p_hdr.info.pi_diamid); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
203 fd_log_threadname ( buf ); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
204 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
205 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
206 /* The state machine starts in CLOSED state */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
207 peer->p_hdr.info.pi_state = STATE_CLOSED; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
208 |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
209 /* Wait that the PSM are authorized to start in the daemon */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
210 CHECK_FCT_DO( fd_psm_waitstart(), goto psm_end ); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
211 |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
212 /* Initialize the timer */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
213 if (peer->p_flags.pf_responder) { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
214 psm_next_timeout(peer, 0, INCNX_TIMEOUT); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
215 } else { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
216 psm_next_timeout(peer, created_started ? 0 : 1, 0); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
217 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
218 |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
219 psm_loop: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
220 /* Get next event */ |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
22
diff
changeset
|
221 CHECK_FCT_DO( fd_event_timedget(peer->p_events, &peer->p_psm_timer, FDEVP_PSM_TIMEOUT, &event, &ev_sz, &ev_data), goto psm_end ); |
27
b3a1773e9f46
again, correct was actually %zd
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
26
diff
changeset
|
222 TRACE_DEBUG(FULL, "'%s'\t<-- '%s'\t(%p,%zd)\t'%s'", |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
223 STATE_STR(peer->p_hdr.info.pi_state), |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
22
diff
changeset
|
224 fd_pev_str(event), ev_data, ev_sz, |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
225 peer->p_hdr.info.pi_diamid); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
226 |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
227 /* Now, the action depends on the current state and the incoming event */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
228 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
229 /* The following states are impossible */ |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
230 ASSERT( peer->p_hdr.info.pi_state != STATE_NEW ); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
231 ASSERT( peer->p_hdr.info.pi_state != STATE_ZOMBIE ); |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
232 ASSERT( peer->p_hdr.info.pi_state != STATE_OPEN_HANDSHAKE ); /* because it exists only between two loops */ |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
233 |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
234 /* Purge invalid events */ |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
235 if (!CHECK_PEVENT(event)) { |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
236 TRACE_DEBUG(INFO, "Invalid event received in PSM '%s' : %d", peer->p_hdr.info.pi_diamid, event); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
237 goto psm_loop; |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
238 } |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
239 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
240 /* Call the extension callback if needed */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
241 if (peer->p_cb) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
242 /* Check if we must call it */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
243 /* */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
244 /* OK */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
245 TODO("Call CB"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
246 TODO("Clear CB"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
247 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
248 |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
249 /* Handle the (easy) debug event now */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
250 if (event == FDEVP_DUMP_ALL) { |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
251 fd_peer_dump(peer, ANNOYING); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
252 goto psm_loop; |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
253 } |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
254 |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
255 /* Requests to terminate the peer object */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
256 if (event == FDEVP_TERMINATE) { |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
257 switch (peer->p_hdr.info.pi_state) { |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
258 case STATE_CLOSING: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
259 case STATE_WAITCNXACK: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
260 case STATE_WAITCNXACK_ELEC: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
261 case STATE_WAITCEA: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
262 case STATE_SUSPECT: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
263 /* In these cases, we just cleanup the peer object and terminate now */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
264 TODO("Cleanup the PSM: terminate connection object, ..."); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
265 case STATE_CLOSED: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
266 /* Then we just terminate the PSM */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
267 goto psm_end; |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
268 |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
269 case STATE_OPEN: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
270 case STATE_REOPEN: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
271 /* We cannot just close the conenction, we have to send a DPR first */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
272 TODO("Send DPR, mark the peer as CLOSING"); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
273 goto psm_loop; |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
274 } |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
275 } |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
276 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
277 /* A message was received */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
278 if (event == FDEVP_CNX_MSG_RECV) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
279 TODO("Parse the buffer into a message"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
280 /* parse_and_get_local_ccode */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
281 TODO("Check if it is a local message (CER, DWR, ...)"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
282 TODO("If not, check we are in OPEN state"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
283 TODO("Update expiry timer if needed"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
284 TODO("Handle the message"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
285 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
286 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
287 /* The connection object is broken */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
288 if (event == FDEVP_CNX_ERROR) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
289 TODO("Destroy the connection object"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
290 TODO("Mark the error in the peer (pf_cnx_pb)"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
291 TODO("Move to closed state, Requeue all messages to a different connection (failover)"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
292 TODO("If pi_flags.exp, terminate the peer"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
293 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
294 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
295 /* The connection notified a change in endpoints */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
296 if (event == FDEVP_CNX_EP_CHANGE) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
297 /* Cleanup the remote LL and primary addresses */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
298 CHECK_FCT_DO( fd_ep_filter( &peer->p_hdr.info.pi_endpoints, EP_FL_CONF | EP_FL_DISC | EP_FL_ADV ), /* ignore the error */); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
299 CHECK_FCT_DO( fd_ep_clearflags( &peer->p_hdr.info.pi_endpoints, EP_FL_PRIMARY ), /* ignore the error */); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
300 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
301 /* Get the new ones */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
302 CHECK_FCT_DO( fd_cnx_getendpoints(peer->p_cnxctx, NULL, &peer->p_hdr.info.pi_endpoints), /* ignore the error */); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
303 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
304 if (TRACE_BOOL(ANNOYING)) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
305 fd_log_debug("New remote endpoint(s):\n"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
306 fd_ep_dump(6, &peer->p_hdr.info.pi_endpoints); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
307 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
308 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
309 /* Done */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
310 goto psm_loop; |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
311 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
312 |
29
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
313 /* A new connection was established and CER containing this peer id was received */ |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
314 if (event == FDEVP_CNX_INCOMING) { |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
315 struct cnx_incoming * params = ev_data; |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
316 ASSERT(params); |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
317 |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
318 switch (peer->p_hdr.info.pi_state) { |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
319 case STATE_CLOSED: |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
320 TODO("Handle the CER, validate the peer if needed (and set expiry), set the alt_fifo in the connection, reply a CEA, eventually handshake, move to OPEN or REOPEN state"); |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
321 break; |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
322 |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
323 case STATE_WAITCNXACK: |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
324 case STATE_WAITCEA: |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
325 TODO("Election"); |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
326 break; |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
327 |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
328 default: |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
329 TODO("Reply with error CEA"); |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
330 TODO("Close the connection"); |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
331 /* reject_incoming_connection */ |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
332 |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
333 } |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
334 |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
335 free(ev_data); |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
336 goto psm_loop; |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
337 } |
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
338 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
339 /* The timeout for the current state has been reached */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
340 if (event == FDEVP_PSM_TIMEOUT) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
341 switch (peer->p_hdr.info.pi_state) { |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
342 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
343 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
344 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
345 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
346 |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
347 /* Default action : the handling has not yet been implemented. [for debug only] */ |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
348 TODO("Missing handler in PSM : '%s'\t<-- '%s'", STATE_STR(peer->p_hdr.info.pi_state), fd_pev_str(event)); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
349 if (event == FDEVP_PSM_TIMEOUT) { |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
350 /* We have not handled timeout in this state, let's postpone next alert */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
351 psm_next_timeout(peer, 0, 60); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
352 } |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
353 |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
354 goto psm_loop; |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
355 |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
356 psm_end: |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
357 pthread_cleanup_pop(1); /* set STATE_ZOMBIE */ |
22
0b3b46da2c12
Progress on server code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
20
diff
changeset
|
358 peer->p_psm = (pthread_t)NULL; |
29
5ba91682f0bc
Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
28
diff
changeset
|
359 pthread_detach(pthread_self()); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
360 return NULL; |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
361 } |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
362 |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
363 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
364 /************************************************************************/ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
365 /* Functions to control the PSM */ |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
366 /************************************************************************/ |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
367 /* Create the PSM thread of one peer structure */ |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
368 int fd_psm_begin(struct fd_peer * peer ) |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
369 { |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
370 TRACE_ENTRY("%p", peer); |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
371 |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
372 /* Check the peer and state are OK */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
373 CHECK_PARAMS( CHECK_PEER(peer) && (peer->p_hdr.info.pi_state == STATE_NEW) ); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
374 |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
375 /* Create the PSM controler thread */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
376 CHECK_POSIX( pthread_create( &peer->p_psm, NULL, p_psm_th, peer ) ); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
377 |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
378 /* We're done */ |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
379 return 0; |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
380 } |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
381 |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
382 /* End the PSM (clean ending) */ |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
383 int fd_psm_terminate(struct fd_peer * peer ) |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
384 { |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
385 TRACE_ENTRY("%p", peer); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
386 CHECK_PARAMS( CHECK_PEER(peer) ); |
22
0b3b46da2c12
Progress on server code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
20
diff
changeset
|
387 |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
388 if (peer->p_hdr.info.pi_state != STATE_ZOMBIE) { |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
22
diff
changeset
|
389 CHECK_FCT( fd_event_send(peer->p_events, FDEVP_TERMINATE, 0, NULL) ); |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
390 } else { |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
391 TRACE_DEBUG(FULL, "Peer '%s' was already terminated", peer->p_hdr.info.pi_diamid); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
392 } |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
393 return 0; |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
394 } |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
395 |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
396 /* End the PSM & cleanup the peer structure */ |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
397 void fd_psm_abord(struct fd_peer * peer ) |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
398 { |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
399 TRACE_ENTRY("%p", peer); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
400 TODO("Cancel PSM thread"); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
401 TODO("Cancel OUT thread"); |
16
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
402 TODO("Cleanup the peer connection object"); |
013ce9851131
Started including TLS code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
403 TODO("Cleanup the message queues (requeue)"); |
33
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
404 TODO("Call p_cb with NULL parameter if needed"); |
e6fcdf12b9a0
Added a lot of TODOs :)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
405 |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
406 return; |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
407 } |
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
408 |