Mercurial > hg > freeDiameter
annotate freeDiameter/p_ce.c @ 233:87ca7b66a90c
Make the CEA broadcast optional
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 04 Mar 2010 17:24:31 +0900 |
parents | 5b17534180f1 |
children | 5df55136361b |
rev | line source |
---|---|
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
5 * Copyright (c) 2009, WIDE Project and NICT * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
6486e97f56ae
Added test for modified message parsing
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 * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
6486e97f56ae
Added test for modified message parsing
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 * |
6486e97f56ae
Added test for modified message parsing
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 * |
6486e97f56ae
Added test for modified message parsing
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 * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
6486e97f56ae
Added test for modified message parsing
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 * |
6486e97f56ae
Added test for modified message parsing
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 * |
6486e97f56ae
Added test for modified message parsing
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 * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 #include "fD.h" |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
38 /* This file contains code to handle Capabilities Exchange messages (CER and CEA) and election process */ |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 |
233
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
40 /* Compilation option: |
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
41 USE_CEA_BROADCAST |
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
42 Define this to enable sending multiple copies of the CEA in case of SCTP connection. |
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
43 This avoids a race condition when sending an application message over a different stream |
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
44 than the CEA, it might be delivered first and thus ignored. |
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
45 */ |
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
46 |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
47 /* Save a connection as peer's principal */ |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
48 static int set_peer_cnx(struct fd_peer * peer, struct cnxctx **cnx) |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 { |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
50 CHECK_PARAMS( peer->p_cnxctx == NULL ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
51 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
52 /* Save the connection in peer */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
53 peer->p_cnxctx = *cnx; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
54 *cnx = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
55 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
56 /* Set the events to be sent to the PSM */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
57 CHECK_FCT( fd_cnx_recv_setaltfifo(peer->p_cnxctx, peer->p_events) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
58 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
59 /* Read the credentials if possible */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
60 if (fd_cnx_getTLS(peer->p_cnxctx)) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
61 CHECK_FCT( fd_cnx_getcred(peer->p_cnxctx, &peer->p_hdr.info.runtime.pir_cert_list, &peer->p_hdr.info.runtime.pir_cert_list_size) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
62 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
63 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
64 /* Read the endpoints, maybe used to reconnect to the peer later */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
65 CHECK_FCT( fd_cnx_getendpoints(peer->p_cnxctx, NULL, &peer->p_hdr.info.pi_endpoints) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
66 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
67 /* Read the protocol */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
68 peer->p_hdr.info.runtime.pir_proto = fd_cnx_getproto(peer->p_cnxctx); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
69 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
70 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
71 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
72 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
73 /* Delete the peer connection, and cleanup associated information */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
74 void fd_p_ce_clear_cnx(struct fd_peer * peer, struct cnxctx ** cnx_kept) |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
75 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
76 peer->p_hdr.info.runtime.pir_cert_list = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
77 peer->p_hdr.info.runtime.pir_cert_list_size = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
78 peer->p_hdr.info.runtime.pir_proto = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
79 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
80 if (peer->p_cnxctx) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
81 if (cnx_kept != NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
82 *cnx_kept = peer->p_cnxctx; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
83 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
84 fd_cnx_destroy(peer->p_cnxctx); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
85 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
86 peer->p_cnxctx = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
87 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
88 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
89 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
90 /* Election: compare the Diameter Ids, return true if the election is won */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
91 static __inline__ int election_result(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
|
92 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
93 int ret = (strcasecmp(peer->p_hdr.info.pi_diamid, fd_g_config->cnf_diamid) < 0); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
94 if (ret) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
95 TRACE_DEBUG(INFO, "Election WON against peer '%s'", peer->p_hdr.info.pi_diamid); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
96 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
97 TRACE_DEBUG(INFO, "Election LOST against peer '%s'", peer->p_hdr.info.pi_diamid); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
98 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
99 return ret; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
100 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
101 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
102 /* Add AVPs about local information in a CER or CEA */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
103 static int add_CE_info(struct msg *msg, struct cnxctx * cnx, int isi_tls, int isi_none) |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
104 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
105 struct dict_object * dictobj = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
106 struct avp * avp = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
107 union avp_value val; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
108 struct fd_list *li, local_ep = FD_LIST_INITIALIZER(local_ep); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
109 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
110 /* Add the Origin-* AVPs */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
111 CHECK_FCT( fd_msg_add_origin ( msg, 1 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
112 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
113 /* Find the model for Host-IP-Address AVP */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
114 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &dictobj, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
115 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
116 /* Get the list of endpoints */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
117 CHECK_FCT( fd_cnx_getendpoints(cnx, &local_ep, NULL) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
118 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
119 /* Add the AVP(s) -- not sure what is the purpose... We could probably only add the primary one ? */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
120 for (li = local_ep.next; li != &local_ep; li = li->next) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
121 struct fd_endpoint * ep = (struct fd_endpoint *)li; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
122 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
123 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
124 CHECK_FCT( fd_msg_avp_value_encode ( &ep->ss, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
125 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
126 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
127 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
128 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
129 /* Vendor-Id, Product-Name, and Firmware-Revision AVPs */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
130 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dictobj, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
131 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
132 val.u32 = MY_VENDOR_ID; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
133 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
134 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
135 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
136 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Product-Name", &dictobj, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
137 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
138 val.os.data = (unsigned char *)FD_PROJECT_NAME; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
139 val.os.len = strlen(FD_PROJECT_NAME); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
140 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
141 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
142 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
143 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Firmware-Revision", &dictobj, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
144 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
145 val.u32 = (uint32_t)(FD_PROJECT_VERSION_MAJOR * 10000 + FD_PROJECT_VERSION_MINOR * 100 + FD_PROJECT_VERSION_REV); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
146 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
147 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
148 |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
149 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
150 /* Add the Inband-Security-Id AVP if needed */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
151 if (isi_tls || isi_none) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
152 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Inband-Security-Id", &dictobj, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
153 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
154 if (isi_none) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
155 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
156 val.u32 = ACV_ISI_NO_INBAND_SECURITY; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
157 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
158 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
159 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
160 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
161 if (isi_tls) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
162 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
163 val.u32 = ACV_ISI_TLS; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
164 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
165 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
166 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
167 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
168 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
169 /* List of local applications */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
170 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
171 struct dict_object * dictobj_auth = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
172 struct dict_object * dictobj_acct = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
173 struct dict_object * dictobj_vid = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
174 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
175 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Vendor-Specific-Application-Id", &dictobj, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
176 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dictobj_vid, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
177 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dictobj_auth, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
178 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Application-Id", &dictobj_acct, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
179 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
180 for (li = fd_g_config->cnf_apps.next; li != &fd_g_config->cnf_apps; li = li->next) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
181 struct fd_app * a = (struct fd_app *)(li); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
182 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
183 if (a->flags.auth) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
184 CHECK_FCT( fd_msg_avp_new ( dictobj_auth, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
185 val.u32 = a->appid; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
186 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
187 if (a->vndid != 0) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
188 struct avp * avp2 = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
189 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp2 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
190 CHECK_FCT( fd_msg_avp_add( avp2, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
191 avp = avp2; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
192 CHECK_FCT( fd_msg_avp_new ( dictobj_vid, 0, &avp2 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
193 val.u32 = a->vndid; |
110
0e21b85edf85
Fix buggy CE info function for vendor-specific application id
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
105
diff
changeset
|
194 CHECK_FCT( fd_msg_avp_setvalue( avp2, &val ) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
195 CHECK_FCT( fd_msg_avp_add( avp, MSG_BRW_LAST_CHILD, avp2 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
196 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
197 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
198 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
199 if (a->flags.acct) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
200 CHECK_FCT( fd_msg_avp_new ( dictobj_acct, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
201 val.u32 = a->appid; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
202 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
203 if (a->vndid != 0) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
204 struct avp * avp2 = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
205 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp2 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
206 CHECK_FCT( fd_msg_avp_add( avp2, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
207 avp = avp2; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
208 CHECK_FCT( fd_msg_avp_new ( dictobj_vid, 0, &avp2 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
209 val.u32 = a->vndid; |
110
0e21b85edf85
Fix buggy CE info function for vendor-specific application id
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
105
diff
changeset
|
210 CHECK_FCT( fd_msg_avp_setvalue( avp2, &val ) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
211 CHECK_FCT( fd_msg_avp_add( avp, MSG_BRW_LAST_CHILD, avp2 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
212 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
213 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
214 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
215 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
216 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
217 /* do not forget the relay application */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
218 if (! fd_g_config->cnf_flags.no_fwd) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
219 CHECK_FCT( fd_msg_avp_new ( dictobj_auth, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
220 val.u32 = AI_RELAY; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
221 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
222 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
223 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
224 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
225 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
226 /* Add the list of supported vendors */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
227 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
228 uint32_t * array = fd_dict_get_vendorid_list(fd_g_config->cnf_dict); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
229 if (array) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
230 int i = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
231 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Supported-Vendor-Id", &dictobj, ENOENT ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
232 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
233 while (array[i] != 0) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
234 CHECK_FCT( fd_msg_avp_new ( dictobj, 0, &avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
235 val.u32 = array[i]; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
236 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
237 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
238 i++; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
239 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
240 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
241 free(array); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
242 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
243 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
244 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
245 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
246 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
247 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
248 /* Remove any information saved from a previous CER/CEA exchange */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
249 static void cleanup_remote_CE_info(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
|
250 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
251 free(peer->p_hdr.info.runtime.pir_realm); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
252 peer->p_hdr.info.runtime.pir_realm = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
253 peer->p_hdr.info.runtime.pir_vendorid = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
254 peer->p_hdr.info.runtime.pir_orstate = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
255 free(peer->p_hdr.info.runtime.pir_prodname); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
256 peer->p_hdr.info.runtime.pir_prodname = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
257 peer->p_hdr.info.runtime.pir_firmrev = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
258 peer->p_hdr.info.runtime.pir_relay = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
259 peer->p_hdr.info.runtime.pir_isi = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
260 while (!FD_IS_LIST_EMPTY(&peer->p_hdr.info.runtime.pir_apps)) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
261 struct fd_list * li = peer->p_hdr.info.runtime.pir_apps.next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
262 fd_list_unlink(li); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
263 free(li); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
264 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
265 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
266 fd_ep_clearflags( &peer->p_hdr.info.pi_endpoints, EP_FL_ADV /* Remove previously advertised endpoints */ ); |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
267 } |
36 | 268 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
269 /* Extract information sent by the remote peer and save it in our peer structure */ |
131
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
270 static int save_remote_CE_info(struct msg * msg, struct fd_peer * peer, char ** error_code, uint32_t *rc) |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
271 { |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
272 struct avp * avp = NULL; |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
273 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
274 cleanup_remote_CE_info(peer); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
275 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
276 CHECK_FCT( fd_msg_browse( msg, MSG_BRW_FIRST_CHILD, &avp, NULL) ); |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
277 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
278 /* Loop on all AVPs and save what we are interrested into */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
279 while (avp) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
280 struct avp_hdr * hdr; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
281 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
282 CHECK_FCT( fd_msg_avp_hdr( avp, &hdr ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
283 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
284 if (hdr->avp_flags & AVP_FLAG_VENDOR) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
285 /* Ignore all vendor-specific AVPs in CER/CEA because we don't support any currently */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
286 TRACE_DEBUG(FULL, "Ignored a vendor AVP in CER / CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
287 fd_msg_dump_one(FULL, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
288 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
289 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
290 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
291 switch (hdr->avp_code) { |
130
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
292 case AC_RESULT_CODE: /* Result-Code */ |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
293 if (hdr->avp_value == NULL) { |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
294 /* This is a sanity check */ |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
295 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
296 fd_msg_dump_one(NONE, avp); |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
297 ASSERT(0); /* To check if this really happens, and understand why... */ |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
298 goto next; |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
299 } |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
300 |
131
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
301 if (rc) |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
302 *rc = hdr->avp_value->u32; |
130
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
303 break; |
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
304 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
305 case AC_ORIGIN_HOST: /* Origin-Host */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
306 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
307 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
308 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
309 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
310 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
311 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
312 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
313 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
314 /* We check that the value matches what we know, otherwise disconnect the peer */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
315 if (strncasecmp(hdr->avp_value->os.data, peer->p_hdr.info.pi_diamid, hdr->avp_value->os.len)) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
316 TRACE_DEBUG(INFO, "Received a message with Origin-Host set to '%.*s' while expecting '%s'\n", |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
317 hdr->avp_value->os.len, hdr->avp_value->os.data, peer->p_hdr.info.pi_diamid); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
318 *error_code = "DIAMETER_UNKNOWN_PEER"; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
319 return EINVAL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
320 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
321 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
322 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
323 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
324 case AC_ORIGIN_REALM: /* Origin-Realm */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
325 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
326 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
327 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
328 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
329 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
330 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
331 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
332 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
333 /* In case of multiple AVPs */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
334 if (peer->p_hdr.info.runtime.pir_realm) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
335 TRACE_DEBUG(INFO, "Ignored multiple instances of the Origin-Realm AVP"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
336 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
337 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
338 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
339 /* Save the value -- we don't change the case to avoid risking breaking UTF-8 with poor tolower() impls. */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
340 CHECK_MALLOC( peer->p_hdr.info.runtime.pir_realm = calloc( hdr->avp_value->os.len + 1, 1 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
341 memcpy(peer->p_hdr.info.runtime.pir_realm, hdr->avp_value->os.data, hdr->avp_value->os.len); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
342 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
343 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
344 case AC_HOST_IP_ADDRESS: /* Host-IP-Address */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
345 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
346 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
347 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
348 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
349 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
350 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
351 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
352 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
353 sSS ss; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
354 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
355 /* Get the sockaddr value */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
356 memset(&ss, 0, sizeof(ss)); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
357 CHECK_FCT( fd_msg_avp_value_interpret( avp, &ss) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
358 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
359 /* Save this endpoint in the list as advertized */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
360 CHECK_FCT( fd_ep_add_merge( &peer->p_hdr.info.pi_endpoints, (sSA *)&ss, sizeof(sSS), EP_FL_ADV ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
361 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
362 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
363 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
364 case AC_VENDOR_ID: /* Vendor-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
365 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
366 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
367 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
368 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
369 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
370 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
371 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
372 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
373 /* In case of multiple AVPs */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
374 if (peer->p_hdr.info.runtime.pir_vendorid) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
375 TRACE_DEBUG(INFO, "Ignored multiple instances of the Vendor-Id AVP"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
376 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
377 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
378 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
379 peer->p_hdr.info.runtime.pir_vendorid = hdr->avp_value->u32; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
380 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
381 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
382 case AC_PRODUCT_NAME: /* Product-Name */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
383 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
384 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
385 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
386 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
387 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
388 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
389 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
390 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
391 /* In case of multiple AVPs */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
392 if (peer->p_hdr.info.runtime.pir_prodname) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
393 TRACE_DEBUG(INFO, "Ignored multiple instances of the Product-Name AVP"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
394 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
395 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
396 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
397 CHECK_MALLOC( peer->p_hdr.info.runtime.pir_prodname = calloc( hdr->avp_value->os.len + 1, 1 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
398 memcpy(peer->p_hdr.info.runtime.pir_prodname, hdr->avp_value->os.data, hdr->avp_value->os.len); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
399 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
400 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
401 case AC_ORIGIN_STATE_ID: /* Origin-State-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
402 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
403 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
404 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
405 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
406 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
407 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
408 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
409 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
410 /* In case of multiple AVPs */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
411 if (peer->p_hdr.info.runtime.pir_orstate) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
412 TRACE_DEBUG(INFO, "Ignored multiple instances of the Origin-State-Id AVP"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
413 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
414 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
415 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
416 peer->p_hdr.info.runtime.pir_orstate = hdr->avp_value->u32; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
417 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
418 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
419 case AC_SUPPORTED_VENDOR_ID: /* Supported-Vendor-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
420 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
421 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
422 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
423 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
424 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
425 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
426 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
427 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
428 TRACE_DEBUG(FULL, "'%s' supports a subset of vendor %d features.", peer->p_hdr.info.pi_diamid, hdr->avp_value->u32); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
429 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
430 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
431 case AC_VENDOR_SPECIFIC_APPLICATION_ID: /* Vendor-Specific-Application-Id (grouped)*/ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
432 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
433 struct avp * inavp = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
434 application_id_t aid = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
435 vendor_id_t vid = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
436 int auth = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
437 int acct = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
438 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
439 /* get the first child AVP */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
440 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_FIRST_CHILD, &inavp, NULL) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
441 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
442 while (inavp) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
443 struct avp_hdr * inhdr; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
444 CHECK_FCT( fd_msg_avp_hdr( inavp, &inhdr ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
445 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
446 if (inhdr->avp_flags & AVP_FLAG_VENDOR) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
447 TRACE_DEBUG(FULL, "Ignored a vendor AVP inside Vendor-Specific-Application-Id AVP"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
448 fd_msg_dump_one(FULL, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
449 goto innext; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
450 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
451 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
452 if (inhdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
453 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
454 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
455 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
456 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
457 goto innext; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
458 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
459 switch (inhdr->avp_code) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
460 case AC_VENDOR_ID: /* Vendor-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
461 vid = inhdr->avp_value->u32; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
462 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
463 case AC_AUTH_APPLICATION_ID: /* Auth-Application-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
464 aid = inhdr->avp_value->u32; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
465 auth += 1; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
466 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
467 case AC_ACCT_APPLICATION_ID: /* Acct-Application-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
468 aid = inhdr->avp_value->u32; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
469 acct += 1; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
470 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
471 /* ignore other AVPs */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
472 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
473 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
474 innext: |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
475 /* Go to next in AVP */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
476 CHECK_FCT( fd_msg_browse(inavp, MSG_BRW_NEXT, &inavp, NULL) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
477 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
478 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
479 if (auth + acct != 1) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
480 TRACE_DEBUG(FULL, "Invalid Vendor-Specific-Application-Id AVP received, ignored"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
481 fd_msg_dump_one(FULL, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
482 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
483 /* Add an entry in the list */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
484 CHECK_FCT( fd_app_merge(&peer->p_hdr.info.runtime.pir_apps, aid, vid, auth, acct) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
485 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
486 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
487 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
488 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
489 case AC_AUTH_APPLICATION_ID: /* Auth-Application-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
490 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
491 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
492 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
493 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
494 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
495 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
496 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
497 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
498 if (hdr->avp_value->u32 == AI_RELAY) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
499 peer->p_hdr.info.runtime.pir_relay = 1; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
500 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
501 CHECK_FCT( fd_app_merge(&peer->p_hdr.info.runtime.pir_apps, hdr->avp_value->u32, 0, 1, 0) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
502 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
503 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
504 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
505 case AC_ACCT_APPLICATION_ID: /* Acct-Application-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
506 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
507 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
508 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
509 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
510 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
511 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
512 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
513 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
514 if (hdr->avp_value->u32 == AI_RELAY) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
515 peer->p_hdr.info.runtime.pir_relay = 1; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
516 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
517 /* Not clear if the relay application can be inside this AVP... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
518 CHECK_FCT( fd_app_merge(&peer->p_hdr.info.runtime.pir_apps, hdr->avp_value->u32, 0, 0, 1) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
519 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
520 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
521 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
522 case AC_FIRMWARE_REVISION: /* Firmware-Revision */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
523 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
524 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
525 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
526 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
527 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
528 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
529 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
530 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
531 peer->p_hdr.info.runtime.pir_firmrev = hdr->avp_value->u32; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
532 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
533 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
534 case AC_INBAND_SECURITY_ID: /* Inband-Security-Id */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
535 if (hdr->avp_value == NULL) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
536 /* This is a sanity check */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
537 TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
538 fd_msg_dump_one(NONE, avp); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
539 ASSERT(0); /* To check if this really happens, and understand why... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
540 goto next; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
541 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
542 ASSERT( hdr->avp_value->u32 < 32 ); /* if false, we have to change the code bellow */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
543 peer->p_hdr.info.runtime.pir_isi |= (1 << hdr->avp_value->u32); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
544 break; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
545 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
546 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
547 next: |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
548 /* Go to next AVP */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
549 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
550 } |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
551 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
552 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
553 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
554 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
555 /* Create a CER message for sending */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
556 static int create_CER(struct fd_peer * peer, struct cnxctx * cnx, struct msg ** cer) |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
557 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
558 int isi_tls = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
559 int isi_none = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
560 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
561 /* Find CER dictionary object and create an instance */ |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
63
diff
changeset
|
562 CHECK_FCT( fd_msg_new ( fd_dict_cmd_CER, MSGFL_ALLOC_ETEID, cer ) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
563 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
564 /* Do we need Inband-Security-Id AVPs ? */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
565 if (!fd_cnx_getTLS(cnx)) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
566 isi_none = peer->p_hdr.info.config.pic_flags.sec & PI_SEC_NONE; /* we add it event if the peer does not use the old mechanism */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
567 isi_tls = peer->p_hdr.info.config.pic_flags.sec & PI_SEC_TLS_OLD; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
568 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
569 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
570 /* Add the information about the local peer */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
571 CHECK_FCT( add_CE_info(*cer, cnx, isi_tls, isi_none) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
572 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
573 /* Done! */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
574 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
575 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
576 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
577 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
578 /* Continue with the initiator side */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
579 static int to_waitcea(struct fd_peer * peer, struct cnxctx * cnx) |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
580 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
581 /* We sent a CER on the connection, set the event queue so that we receive the CEA */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
582 CHECK_FCT( set_peer_cnx(peer, &cnx) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
583 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
584 /* Change state and reset the timer */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
585 CHECK_FCT( fd_psm_change_state(peer, STATE_WAITCEA) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
586 fd_psm_next_timeout(peer, 0, CEA_TIMEOUT); |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
587 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
588 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
589 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
590 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
591 /* Reject an incoming connection attempt */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
592 static void receiver_reject(struct cnxctx * recv_cnx, struct msg ** cer, char * rescode, char * errormsg) |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
593 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
594 /* Create and send the CEA with appropriate error code */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
595 CHECK_FCT_DO( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, cer, MSGFL_ANSW_ERROR ), goto destroy ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
596 CHECK_FCT_DO( fd_msg_rescode_set(*cer, rescode, errormsg, NULL, 1 ), goto destroy ); |
229
965f5971dc23
Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
225
diff
changeset
|
597 CHECK_FCT_DO( fd_out_send(cer, recv_cnx, NULL, FD_CNX_ORDERED), goto destroy ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
598 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
599 /* And now destroy this connection */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
600 destroy: |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
601 fd_cnx_destroy(recv_cnx); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
602 if (*cer) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
603 fd_msg_free(*cer); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
604 *cer = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
605 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
606 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
607 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
608 /* We have established a new connection to the remote peer, send CER and eventually process the election */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
609 int fd_p_ce_handle_newcnx(struct fd_peer * peer, struct cnxctx * initiator) |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
610 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
611 struct msg * cer = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
612 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
613 /* Send CER on the new connection */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
614 CHECK_FCT( create_CER(peer, initiator, &cer) ); |
229
965f5971dc23
Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
225
diff
changeset
|
615 CHECK_FCT( fd_out_send(&cer, initiator, peer, FD_CNX_ORDERED) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
616 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
617 /* Are we doing an election ? */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
618 if (peer->p_hdr.info.runtime.pir_state == STATE_WAITCNXACK_ELEC) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
619 if (election_result(peer)) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
620 /* Close initiator connection */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
621 fd_cnx_destroy(initiator); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
622 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
623 /* Process with the receiver side */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
624 CHECK_FCT( fd_p_ce_process_receiver(peer) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
625 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
626 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
627 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
628 /* Answer an ELECTION LOST to the receiver side */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
629 receiver_reject(peer->p_receiver, &peer->p_cer, "ELECTION_LOST", NULL); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
630 peer->p_receiver = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
631 CHECK_FCT( to_waitcea(peer, initiator) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
632 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
633 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
634 /* No election (yet) */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
635 CHECK_FCT( to_waitcea(peer, initiator) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
636 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
637 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
638 return 0; |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
639 } |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
640 |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
641 /* We have received a Capabilities Exchange message on the peer connection */ |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
642 int fd_p_ce_msgrcv(struct msg ** msg, int req, struct fd_peer * peer) |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
643 { |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
644 char * ec; |
131
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
645 uint32_t rc = 0; |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
646 TRACE_ENTRY("%p %p", msg, peer); |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
647 CHECK_PARAMS( msg && *msg && CHECK_PEER(peer) ); |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
648 |
130
a16504d20ed1
Handle CEA with error result codes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
129
diff
changeset
|
649 /* The only valid situation where we are called is in WAITCEA and we receive a CEA (we may have won an election) */ |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
650 |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
651 /* Note : to implement Capabilities Update, we would need to change here */ |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
652 |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
653 /* If it is a CER, just reply an error */ |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
654 if (req) { |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
655 /* Create the error message */ |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
656 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, MSGFL_ANSW_ERROR ) ); |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
657 |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
658 /* Set the error code */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
659 CHECK_FCT( fd_msg_rescode_set(*msg, "DIAMETER_COMMAND_UNSUPPORTED", "No CER allowed in current state", NULL, 1 ) ); |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
660 |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
661 /* msg now contains an answer message to send back */ |
229
965f5971dc23
Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
225
diff
changeset
|
662 CHECK_FCT_DO( fd_out_send(msg, NULL, peer, FD_CNX_ORDERED), /* In case of error the message has already been dumped */ ); |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
663 } |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
664 |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
665 /* If the state is not WAITCEA, just discard the message */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
666 if (req || (peer->p_hdr.info.runtime.pir_state != STATE_WAITCEA)) { |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
667 if (*msg) { |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
668 fd_log_debug("Received CER/CEA message while in state '%s', discarded.\n", STATE_STR(peer->p_hdr.info.runtime.pir_state)); |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
669 fd_msg_dump_walk(NONE, *msg); |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
670 CHECK_FCT_DO( fd_msg_free(*msg), /* continue */); |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
671 *msg = NULL; |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
672 } |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
673 |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
674 return 0; |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
675 } |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
676 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
677 /* Save info from the CEA into the peer */ |
131
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
678 CHECK_FCT_DO( save_remote_CE_info(*msg, peer, &ec, &rc), goto cleanup ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
679 |
62 | 680 /* Dispose of the message, we don't need it anymore */ |
63
56dd4efdf6e8
Fix compilation error
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
62
diff
changeset
|
681 CHECK_FCT_DO( fd_msg_free(*msg), /* continue */ ); |
62 | 682 *msg = NULL; |
683 | |
131
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
684 /* Check the Result-Code */ |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
685 switch (rc) { |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
686 case ER_DIAMETER_SUCCESS: |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
687 /* No problem, we can continue */ |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
688 break; |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
689 |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
690 case ER_DIAMETER_TOO_BUSY: |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
691 /* Retry later */ |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
692 TRACE_DEBUG(INFO, "Peer %s replied a CEA with Result-Code AVP DIAMETER_TOO_BUSY, will retry later.", peer->p_hdr.info.pi_diamid); |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
693 fd_psm_cleanup(peer, 0); |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
694 fd_psm_next_timeout(peer, 0, 300); |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
695 return 0; |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
696 |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
697 case ER_ELECTION_LOST: |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
698 /* Ok, just wait for a little while for the CER to be processed on the other connection. */ |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
699 TRACE_DEBUG(FULL, "Peer %s replied a CEA with Result-Code AVP ELECTION_LOST, waiting for events.", peer->p_hdr.info.pi_diamid); |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
700 return 0; |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
701 |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
702 default: |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
703 /* In any other case, we abort all attempts to connect to this peer */ |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
704 TRACE_DEBUG(INFO, "Peer %s replied a CEA with Result-Code AVP %d, aborting connection attempts.", peer->p_hdr.info.pi_diamid, rc); |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
705 return EINVAL; |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
706 } |
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
707 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
708 /* Handshake if needed, start clear otherwise */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
709 if ( ! fd_cnx_getTLS(peer->p_cnxctx) ) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
710 int todo = peer->p_hdr.info.config.pic_flags.sec & peer->p_hdr.info.runtime.pir_isi ; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
711 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
712 if (todo == PI_SEC_NONE) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
713 /* Ok for clear connection */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
714 TRACE_DEBUG(INFO, "No TLS protection negotiated with peer '%s'.", peer->p_hdr.info.pi_diamid); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
715 CHECK_FCT( fd_cnx_start_clear(peer->p_cnxctx, 1) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
716 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
717 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
718 fd_psm_change_state(peer, STATE_OPEN_HANDSHAKE); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
719 CHECK_FCT_DO( fd_cnx_handshake(peer->p_cnxctx, GNUTLS_CLIENT, peer->p_hdr.info.config.pic_priority, NULL), |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
720 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
721 /* Handshake failed ... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
722 fd_log_debug("TLS Handshake failed with peer '%s', resetting the connection\n", peer->p_hdr.info.pi_diamid); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
723 goto cleanup; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
724 } ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
725 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
726 /* Retrieve the credentials */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
727 CHECK_FCT( fd_cnx_getcred(peer->p_cnxctx, &peer->p_hdr.info.runtime.pir_cert_list, &peer->p_hdr.info.runtime.pir_cert_list_size) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
728 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
729 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
730 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
731 /* Move to next state */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
732 if (peer->p_flags.pf_cnx_pb) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
733 fd_psm_change_state(peer, STATE_REOPEN ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
734 CHECK_FCT( fd_p_dw_reopen(peer) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
735 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
736 fd_psm_change_state(peer, STATE_OPEN ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
737 fd_psm_next_timeout(peer, 1, peer->p_hdr.info.config.pic_twtimer ?: fd_g_config->cnf_timer_tw); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
738 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
739 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
740 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
741 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
742 cleanup: |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
743 fd_p_ce_clear_cnx(peer, NULL); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
744 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
745 /* Send the error to the peer */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
746 CHECK_FCT( fd_event_send(peer->p_events, FDEVP_CNX_ERROR, 0, NULL) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
747 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
748 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
749 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
750 |
105
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
751 /* Handle the receiver side to go to OPEN state (any election is resolved) */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
752 int fd_p_ce_process_receiver(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
|
753 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
754 char * ec = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
755 struct msg * msg = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
756 int isi = 0; |
105
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
757 int fatal = 0; |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
758 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
759 TRACE_ENTRY("%p", peer); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
760 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
761 CHECK_FCT( set_peer_cnx(peer, &peer->p_receiver) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
762 msg = peer->p_cer; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
763 peer->p_cer = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
764 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
765 /* Parse the content of the received CER */ |
131
50d1dc19b221
Hopefully removed infinite loop
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
130
diff
changeset
|
766 CHECK_FCT_DO( save_remote_CE_info(msg, peer, &ec, NULL), goto error_abort ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
767 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
768 /* Validate the peer if needed */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
769 if (peer->p_flags.pf_responder) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
770 int res = fd_peer_validate( peer ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
771 if (res < 0) { |
160
3577f20319c1
Added trace for rejected peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
131
diff
changeset
|
772 TRACE_DEBUG(INFO, "Rejected CER from peer '%s', validation failed (returning DIAMETER_UNKNOWN_PEER).\n", peer->p_hdr.info.pi_diamid); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
773 ec = "DIAMETER_UNKNOWN_PEER"; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
774 goto error_abort; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
775 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
776 CHECK_FCT( res ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
777 } |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
778 |
87 | 779 /* Check if we have common applications */ |
105
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
780 if ( fd_g_config->cnf_flags.no_fwd && (! peer->p_hdr.info.runtime.pir_relay) ) { |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
781 int got_common; |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
782 CHECK_FCT( fd_app_check_common( &fd_g_config->cnf_apps, &peer->p_hdr.info.runtime.pir_apps, &got_common) ); |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
783 if (!got_common) { |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
784 TRACE_DEBUG(INFO, "No common application with peer '%s', sending DIAMETER_NO_COMMON_APPLICATION", peer->p_hdr.info.pi_diamid); |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
785 ec = "DIAMETER_NO_COMMON_APPLICATION"; |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
786 fatal = 1; |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
787 goto error_abort; |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
788 } |
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
789 } |
87 | 790 |
162
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
791 /* Do we agree on ISI ? */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
792 if ( ! fd_cnx_getTLS(peer->p_cnxctx) ) { |
162
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
793 /* In case of responder, the validate callback must have set the config.pic_flags.sec value already */ |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
794 if (!peer->p_hdr.info.config.pic_flags.sec) { |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
795 /* The peer did not send the Inband-Security-Id AVP, reject */ |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
796 TRACE_DEBUG(INFO, "No security mechanism advertised by peer '%s', sending DIAMETER_NO_COMMON_SECURITY", peer->p_hdr.info.pi_diamid); |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
797 ec = "DIAMETER_NO_COMMON_SECURITY"; |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
798 fatal = 1; |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
799 goto error_abort; |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
800 } |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
801 |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
802 /* Now, check if we agree on the value IPsec */ |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
803 if ((peer->p_hdr.info.config.pic_flags.sec & PI_SEC_NONE) && (peer->p_hdr.info.runtime.pir_isi & PI_SEC_NONE)) { |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
804 isi = PI_SEC_NONE; |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
805 } else if ((peer->p_hdr.info.config.pic_flags.sec & PI_SEC_TLS_OLD) && (peer->p_hdr.info.runtime.pir_isi & PI_SEC_TLS_OLD)) { |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
806 isi = PI_SEC_TLS_OLD; |
162
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
807 } |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
808 |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
809 /* If we did not find an agreement */ |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
810 if (!isi) { |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
811 TRACE_DEBUG(INFO, "No common security mechanism with '%s', sending DIAMETER_NO_COMMON_SECURITY", peer->p_hdr.info.pi_diamid); |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
812 ec = "DIAMETER_NO_COMMON_SECURITY"; |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
813 fatal = 1; |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
814 goto error_abort; |
79768bf7d208
Completed whitelist extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
160
diff
changeset
|
815 } |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
816 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
817 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
818 /* Reply a CEA */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
819 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, &msg, 0 ) ); |
56
299507847ef9
Fixed duplicate Origin-Host AVPs in CEA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
820 CHECK_FCT( fd_msg_rescode_set(msg, "DIAMETER_SUCCESS", NULL, NULL, 0 ) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
821 CHECK_FCT( add_CE_info(msg, peer->p_cnxctx, isi & PI_SEC_TLS_OLD, isi & PI_SEC_NONE) ); |
233
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
822 #ifdef USE_CEA_BROADCAST |
230
5b17534180f1
Avoid possible problem with previous commit in case of TLS handshake following CER/CEA exchange...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
229
diff
changeset
|
823 CHECK_FCT( fd_out_send(&msg, peer->p_cnxctx, peer, (isi & PI_SEC_TLS_OLD) ? FD_CNX_ORDERED : FD_CNX_BROADCAST) ); /* Broadcast in order to avoid further messages sent over a different stream be delivered first... */ |
233
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
824 #else /* USE_CEA_BROADCAST */ |
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
825 CHECK_FCT( fd_out_send(&msg, peer->p_cnxctx, peer, FD_CNX_ORDERED ) ); |
87ca7b66a90c
Make the CEA broadcast optional
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
230
diff
changeset
|
826 #endif /* USE_CEA_BROADCAST */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
827 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
828 /* Handshake if needed */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
829 if (isi & PI_SEC_TLS_OLD) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
830 fd_psm_change_state(peer, STATE_OPEN_HANDSHAKE); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
831 CHECK_FCT_DO( fd_cnx_handshake(peer->p_cnxctx, GNUTLS_SERVER, peer->p_hdr.info.config.pic_priority, NULL), |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
832 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
833 /* Handshake failed ... */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
834 fd_log_debug("TLS Handshake failed with peer '%s', resetting the connection\n", peer->p_hdr.info.pi_diamid); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
835 goto cleanup; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
836 } ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
837 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
838 /* Retrieve the credentials */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
839 CHECK_FCT( fd_cnx_getcred(peer->p_cnxctx, &peer->p_hdr.info.runtime.pir_cert_list, &peer->p_hdr.info.runtime.pir_cert_list_size) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
840 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
841 /* Call second validation callback if needed */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
842 if (peer->p_cb2) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
843 TRACE_DEBUG(FULL, "Calling second validation callback for %s", peer->p_hdr.info.pi_diamid); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
844 CHECK_FCT_DO( (*peer->p_cb2)( &peer->p_hdr.info ), |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
845 { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
846 TRACE_DEBUG(INFO, "Validation callback rejected the peer %s after handshake", peer->p_hdr.info.pi_diamid); |
78
a58f0757c06a
Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
847 CHECK_FCT( fd_psm_terminate( peer, "DO_NOT_WANT_TO_TALK_TO_YOU" ) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
848 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
849 } ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
850 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
851 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
852 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
853 if ( ! fd_cnx_getTLS(peer->p_cnxctx) ) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
854 TRACE_DEBUG(INFO, "No TLS protection negotiated with peer '%s'.", peer->p_hdr.info.pi_diamid); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
855 CHECK_FCT( fd_cnx_start_clear(peer->p_cnxctx, 1) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
856 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
857 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
858 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
859 /* Move to OPEN or REOPEN state */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
860 if (peer->p_flags.pf_cnx_pb) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
861 fd_psm_change_state(peer, STATE_REOPEN ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
862 CHECK_FCT( fd_p_dw_reopen(peer) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
863 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
864 fd_psm_change_state(peer, STATE_OPEN ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
865 fd_psm_next_timeout(peer, 1, peer->p_hdr.info.config.pic_twtimer ?: fd_g_config->cnf_timer_tw); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
866 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
867 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
868 return 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
869 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
870 error_abort: |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
871 if (ec) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
872 /* Create the error message */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
873 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, &msg, MSGFL_ANSW_ERROR ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
874 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
875 /* Set the error code */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
876 CHECK_FCT( fd_msg_rescode_set(msg, ec, NULL, NULL, 1 ) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
877 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
878 /* msg now contains an answer message to send back */ |
229
965f5971dc23
Broadcast CEA over all streams to avoid possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
225
diff
changeset
|
879 CHECK_FCT_DO( fd_out_send(&msg, peer->p_cnxctx, peer, FD_CNX_ORDERED), /* In case of error the message has already been dumped */ ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
880 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
881 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
882 cleanup: |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
883 if (msg) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
884 fd_msg_free(msg); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
885 } |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
886 fd_p_ce_clear_cnx(peer, NULL); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
887 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
888 /* Send the error to the peer */ |
105
0d9c9e004be0
Compute common applications after CER reception
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
87
diff
changeset
|
889 CHECK_FCT( fd_event_send(peer->p_events, fatal ? FDEVP_TERMINATE : FDEVP_CNX_ERROR, 0, NULL) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
890 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
891 return 0; |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
892 } |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
893 |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
894 /* We have received a CER on a new connection for this peer */ |
36 | 895 int fd_p_ce_handle_newCER(struct msg ** msg, struct fd_peer * peer, struct cnxctx ** cnx, int valid) |
896 { | |
37
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
897 switch (peer->p_hdr.info.runtime.pir_state) { |
36 | 898 case STATE_CLOSED: |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
899 peer->p_receiver = *cnx; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
900 *cnx = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
901 peer->p_cer = *msg; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
902 *msg = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
903 CHECK_FCT( fd_p_ce_process_receiver(peer) ); |
36 | 904 break; |
905 | |
906 case STATE_WAITCNXACK: | |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
907 /* Save the parameters in the peer, move to STATE_WAITCNXACK_ELEC */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
908 peer->p_receiver = *cnx; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
909 *cnx = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
910 peer->p_cer = *msg; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
911 *msg = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
912 CHECK_FCT( fd_psm_change_state(peer, STATE_WAITCNXACK_ELEC) ); |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
913 break; |
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
914 |
36 | 915 case STATE_WAITCEA: |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
916 if (election_result(peer)) { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
917 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
918 /* Close initiator connection (was already set as principal) */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
919 fd_p_ce_clear_cnx(peer, NULL); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
920 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
921 /* and go on with the receiver side */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
922 peer->p_receiver = *cnx; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
923 *cnx = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
924 peer->p_cer = *msg; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
925 *msg = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
926 CHECK_FCT( fd_p_ce_process_receiver(peer) ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
927 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
928 } else { |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
929 |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
930 /* Answer an ELECTION LOST to the receiver side and continue */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
931 receiver_reject(*cnx, msg, "ELECTION_LOST", "Please answer my CER instead, you won the election."); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
932 *cnx = NULL; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
933 } |
36 | 934 break; |
935 | |
936 default: | |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
937 receiver_reject(*cnx, msg, "DIAMETER_UNABLE_TO_COMPLY", "Invalid state to receive a new connection attempt"); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
938 *cnx = NULL; |
36 | 939 } |
940 | |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
941 return 0; |
40
7e1deaa89540
Some progress on the PSM
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
942 } |