Mercurial > hg > freeDiameter
annotate libfdcore/messages.c @ 1281:ab6457399be2 1.2.1-rc1
Updated copyright information
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sat, 03 Jan 2015 02:23:28 +0800 |
parents | 25fad6714991 |
children | 10143e09abdf |
rev | line source |
---|---|
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
740
4a9f08d6b6ba
Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
1281
ab6457399be2
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1268
diff
changeset
|
5 * Copyright (c) 2015, WIDE Project and NICT * |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
c5c99c73c2bf
Added some extensions and functions in the daemon
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 * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
c5c99c73c2bf
Added some extensions and functions in the daemon
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 * |
c5c99c73c2bf
Added some extensions and functions in the daemon
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 * |
c5c99c73c2bf
Added some extensions and functions in the daemon
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 * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
c5c99c73c2bf
Added some extensions and functions in the daemon
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 * |
c5c99c73c2bf
Added some extensions and functions in the daemon
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 * |
c5c99c73c2bf
Added some extensions and functions in the daemon
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 * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
36 #include "fdcore-internal.h" |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
38 static struct dict_object * dict_avp_SI = NULL; /* Session-Id */ |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 static struct dict_object * dict_avp_OH = NULL; /* Origin-Host */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 static struct dict_object * dict_avp_OR = NULL; /* Origin-Realm */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 static struct dict_object * dict_avp_EM = NULL; /* Error-Message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 static struct dict_object * dict_avp_ERH = NULL; /* Error-Reporting-Host */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 static struct dict_object * dict_avp_FAVP= NULL; /* Failed-AVP */ |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
44 static struct dict_object * dict_avp_RC = NULL; /* Result-Code */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
45 struct dict_object * fd_dict_avp_OSI = NULL; /* Origin-State-Id */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
46 struct dict_object * fd_dict_cmd_CER = NULL; /* Capabilities-Exchange-Request */ |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
47 struct dict_object * fd_dict_cmd_DWR = NULL; /* Device-Watchdog-Request */ |
78
a58f0757c06a
Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
48 struct dict_object * fd_dict_avp_DC = NULL; /* Disconnect-Cause */ |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
49 struct dict_object * fd_dict_cmd_DPR = NULL; /* Disconnect-Peer-Request */ |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 /* Resolve the dictionary objects */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 int fd_msg_init(void) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 TRACE_ENTRY(""); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 /* Initialize the dictionary objects that we may use frequently */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
57 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &dict_avp_SI , ENOENT) ); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
58 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &dict_avp_OH , ENOENT) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Realm", &dict_avp_OR , ENOENT) ); |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
60 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-State-Id", &fd_dict_avp_OSI , ENOENT) ); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
61 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
62 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &dict_avp_RC , ENOENT) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Error-Message", &dict_avp_EM , ENOENT) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Error-Reporting-Host", &dict_avp_ERH , ENOENT) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Failed-AVP", &dict_avp_FAVP, ENOENT) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 |
78
a58f0757c06a
Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
67 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Disconnect-Cause", &fd_dict_avp_DC , ENOENT) ); |
a58f0757c06a
Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
68 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
69 CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &fd_dict_cmd_CER, ENOENT ) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
70 CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &fd_dict_cmd_DWR, ENOENT ) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
71 CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Disconnect-Peer-Request", &fd_dict_cmd_DPR, ENOENT ) ); |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
72 |
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
73 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
74 return 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
75 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
76 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
77 /* Add Origin-Host, Origin-Realm, Origin-State-Id AVPS at the end of the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
78 int fd_msg_add_origin ( struct msg * msg, int osi ) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
79 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
80 union avp_value val; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
81 struct avp * avp_OH = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
82 struct avp * avp_OR = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
83 struct avp * avp_OSI = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
84 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
85 TRACE_ENTRY("%p", msg); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
86 CHECK_PARAMS( msg ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
87 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
88 /* Create the Origin-Host AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
89 CHECK_FCT( fd_msg_avp_new( dict_avp_OH, 0, &avp_OH ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
90 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
91 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
92 memset(&val, 0, sizeof(val)); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
93 val.os.data = (os0_t)fd_g_config->cnf_diamid; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
94 val.os.len = fd_g_config->cnf_diamid_len; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
95 CHECK_FCT( fd_msg_avp_setvalue( avp_OH, &val ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
96 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
97 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
98 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_OH ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
99 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
100 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
101 /* Create the Origin-Realm AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
102 CHECK_FCT( fd_msg_avp_new( dict_avp_OR, 0, &avp_OR ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
103 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
104 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
105 memset(&val, 0, sizeof(val)); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
106 val.os.data = (os0_t)fd_g_config->cnf_diamrlm; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 val.os.len = fd_g_config->cnf_diamrlm_len; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
108 CHECK_FCT( fd_msg_avp_setvalue( avp_OR, &val ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
109 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
110 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
111 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_OR ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
112 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
113 if (osi) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
114 /* Create the Origin-State-Id AVP */ |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
115 CHECK_FCT( fd_msg_avp_new( fd_dict_avp_OSI, 0, &avp_OSI ) ); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
117 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
118 memset(&val, 0, sizeof(val)); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 val.u32 = fd_g_config->cnf_orstateid; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
120 CHECK_FCT( fd_msg_avp_setvalue( avp_OSI, &val ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
121 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
122 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
123 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_OSI ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
124 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
125 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
126 return 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
127 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
128 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
129 /* Create a new Session-Id and add at the beginning of the message. */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
130 int fd_msg_new_session( struct msg * msg, os0_t opt, size_t optlen ) |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
131 { |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
132 union avp_value val; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
133 struct avp * avp = NULL; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
134 struct session * sess = NULL; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
135 os0_t sid; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
136 size_t sidlen; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
137 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
138 TRACE_ENTRY("%p %p %zd", msg, opt, optlen); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
139 CHECK_PARAMS( msg ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
140 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
141 /* Check there is not already a session in the message */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
142 CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, msg, &sess, NULL) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
143 CHECK_PARAMS( sess == NULL ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
144 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
145 /* Ok, now create the session */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
146 CHECK_FCT( fd_sess_new ( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, opt, optlen ) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
147 CHECK_FCT( fd_sess_getsid( sess, &sid, &sidlen) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
148 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
149 /* Create an AVP to hold it */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
150 CHECK_FCT( fd_msg_avp_new( dict_avp_SI, 0, &avp ) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
151 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
152 /* Set its value */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
153 memset(&val, 0, sizeof(val)); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
154 val.os.data = sid; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
155 val.os.len = sidlen; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
156 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
157 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
158 /* Add it to the message */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
159 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_FIRST_CHILD, avp ) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
160 |
924
877592751fee
Fix (tentative) for invalid handling of sessions fast creation/destruction as pointed by Yusuke Okura -- http://lists.freediameter.net/pipermail/help/2013-February/000584.html and http://lists.freediameter.net/pipermail/help/2013-February/000589.html -- Thank you very much
Sebastien Decugis <sdecugis@freediameter.net>
parents:
912
diff
changeset
|
161 /* Save the session associated with the message */ |
877592751fee
Fix (tentative) for invalid handling of sessions fast creation/destruction as pointed by Yusuke Okura -- http://lists.freediameter.net/pipermail/help/2013-February/000584.html and http://lists.freediameter.net/pipermail/help/2013-February/000589.html -- Thank you very much
Sebastien Decugis <sdecugis@freediameter.net>
parents:
912
diff
changeset
|
162 CHECK_FCT( fd_msg_sess_set( msg, sess) ); |
877592751fee
Fix (tentative) for invalid handling of sessions fast creation/destruction as pointed by Yusuke Okura -- http://lists.freediameter.net/pipermail/help/2013-February/000584.html and http://lists.freediameter.net/pipermail/help/2013-February/000589.html -- Thank you very much
Sebastien Decugis <sdecugis@freediameter.net>
parents:
912
diff
changeset
|
163 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
164 /* Done! */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
165 return 0; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
166 } |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
167 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
168 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
169 /* Add Result-Code and eventually Failed-AVP, Error-Message and Error-Reporting-Host AVPs */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
170 int fd_msg_rescode_set( struct msg * msg, char * rescode, char * errormsg, struct avp * optavp, int type_id ) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
171 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
172 union avp_value val; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
173 struct avp * avp_RC = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
174 struct avp * avp_EM = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
175 struct avp * avp_ERH = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
176 struct avp * avp_FAVP= NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
177 uint32_t rc_val = 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
178 int set_e_bit=0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
179 int std_err_msg=0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
180 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
181 TRACE_ENTRY("%p %s %p %p %d", msg, rescode, errormsg, optavp, type_id); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
182 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
183 CHECK_PARAMS( msg && rescode ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
184 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
185 /* Find the enum value corresponding to the rescode string, this will give the class of error */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
186 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
187 struct dict_object * enum_obj = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
188 struct dict_enumval_request req; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
189 memset(&req, 0, sizeof(struct dict_enumval_request)); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
190 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
191 /* First, get the enumerated type of the Result-Code AVP (this is fast, no need to cache the object) */ |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
192 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, dict_avp_RC, &(req.type_obj), ENOENT ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
193 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
194 /* Now search for the value given as parameter */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
195 req.search.enum_name = rescode; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
196 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &req, &enum_obj, ENOTSUP) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
197 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
198 /* finally retrieve its data */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
199 CHECK_FCT_DO( fd_dict_getval( enum_obj, &(req.search) ), return EINVAL ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
200 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
201 /* copy the found value, we're done */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
202 rc_val = req.search.enum_value.u32; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
203 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
204 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
205 if (type_id == 1) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
206 /* Add the Origin-Host and Origin-Realm AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
207 CHECK_FCT( fd_msg_add_origin ( msg, 0 ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
208 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
209 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
210 /* Create the Result-Code AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
211 CHECK_FCT( fd_msg_avp_new( dict_avp_RC, 0, &avp_RC ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
212 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
213 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
214 memset(&val, 0, sizeof(val)); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
215 val.u32 = rc_val; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
216 CHECK_FCT( fd_msg_avp_setvalue( avp_RC, &val ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
217 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
218 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
219 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_RC ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
220 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
221 if (type_id == 2) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
222 /* Add the Error-Reporting-Host AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
223 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
224 CHECK_FCT( fd_msg_avp_new( dict_avp_ERH, 0, &avp_ERH ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
225 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
226 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
227 memset(&val, 0, sizeof(val)); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
228 val.os.data = (uint8_t *)fd_g_config->cnf_diamid; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
229 val.os.len = fd_g_config->cnf_diamid_len; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
230 CHECK_FCT( fd_msg_avp_setvalue( avp_ERH, &val ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
231 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
232 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
233 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_ERH ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
234 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
235 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
236 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
237 /* Now add the optavp in a FailedAVP if provided */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
238 if (optavp) { |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
239 struct avp * optavp_cpy = NULL; |
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
240 struct avp_hdr *opt_hdr, *optcpy_hdr; |
1250
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
241 struct dict_object * opt_model = NULL; |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
242 int is_grouped = 0; |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
243 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
244 /* Create the Failed-AVP AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
245 CHECK_FCT( fd_msg_avp_new( dict_avp_FAVP, 0, &avp_FAVP ) ); |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
246 |
1250
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
247 /* Was this AVP a grouped one? Best effort only here */ |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
248 if (!fd_msg_model ( optavp, &opt_model ) && (opt_model != NULL)) { |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
249 struct dict_avp_data dictdata; |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
250 CHECK_FCT( fd_dict_getval(opt_model, &dictdata) ); |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
251 if (dictdata.avp_basetype == AVP_TYPE_GROUPED) |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
252 is_grouped = 1; |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
253 } |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
254 |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
255 /* Create a new AVP with a copy of the data of the invalid or missing AVP */ |
892
b2e8f1a3ef76
Allow the content of the Failed-AVP to be parseable to bufferize the message. The content is only padded currently
Sebastien Decugis <sdecugis@freediameter.net>
parents:
891
diff
changeset
|
256 optavp_cpy = optavp; |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
257 |
1250
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
258 if (is_grouped) { |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
259 CHECK_FCT( fd_msg_avp_new( opt_model, 0, &optavp_cpy) ); |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
260 } else { |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
261 CHECK_FCT( fd_msg_avp_new( NULL, AVPFL_SET_BLANK_VALUE | AVPFL_SET_RAWDATA_FROM_AVP, &optavp_cpy) ); |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
262 |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
263 CHECK_FCT( fd_msg_avp_hdr(optavp, &opt_hdr) ); |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
264 CHECK_FCT( fd_msg_avp_hdr(optavp_cpy, &optcpy_hdr) ); |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
265 memcpy(optcpy_hdr, opt_hdr, sizeof(struct avp_hdr)); |
446683efbb1f
Attempt fix for Failed-AVP created with a Grouped AVP, in that case we want an empty AVP by default, not a blank AVP of the same length
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1230
diff
changeset
|
266 } |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
267 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
268 /* Add the passed AVP inside it */ |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
269 CHECK_FCT( fd_msg_avp_add( avp_FAVP, MSG_BRW_LAST_CHILD, optavp_cpy ) ); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
270 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
271 /* And add to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
272 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_FAVP ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
273 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
274 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
275 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
276 /* Deal with the 'E' bit and the error message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
277 switch (rc_val / 1000) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
278 case 1: /* Informational */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
279 case 2: /* Success */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
280 /* Nothing special here: no E bit, no error message unless one is specified */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
281 break; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
282 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
283 case 3: /* Protocol Errors */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
284 set_e_bit = 1; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
285 std_err_msg = 1; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
286 break; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
287 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
288 case 4: /* Transcient Failure */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
289 case 5: /* Permanent Failure */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
290 default: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
291 std_err_msg = 1; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
292 break; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
293 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
294 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
295 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
296 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
297 struct msg_hdr * hdr = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
298 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
299 CHECK_FCT( fd_msg_hdr( msg, &hdr ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
300 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
301 if (set_e_bit) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
302 hdr->msg_flags |= CMD_FLAG_ERROR; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
303 else |
912
0a46772fad5d
Fix handling the CMD_FLAG_ERROR bit -- http://lists.freediameter.net/pipermail/help/2013-January/000575.html
Sebastien Decugis <sdecugis@freediameter.net>
parents:
892
diff
changeset
|
304 hdr->msg_flags &= ~ CMD_FLAG_ERROR; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
305 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
306 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
307 if (std_err_msg || errormsg) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
308 /* Add the Error-Message AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
309 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
310 CHECK_FCT( fd_msg_avp_new( dict_avp_EM, 0, &avp_EM ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
311 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
312 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
313 memset(&val, 0, sizeof(val)); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
314 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
315 if (errormsg) { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
316 val.os.data = (uint8_t *)errormsg; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
317 val.os.len = strlen(errormsg); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
318 } else { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
319 val.os.data = (uint8_t *)rescode; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
320 val.os.len = strlen(rescode); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
321 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
322 CHECK_FCT( fd_msg_avp_setvalue( avp_EM, &val ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
323 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
324 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
325 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_EM ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
326 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
327 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
328 return 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
329 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
330 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
331 static int fd_msg_send_int( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout ) |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
332 { |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
333 struct msg_hdr *hdr; |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
334 DiamId_t diamid; |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
335 |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
336 /* Save the callback in the message, with the timeout */ |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
337 CHECK_FCT( fd_msg_anscb_associate( *pmsg, anscb, data, expirecb, timeout ) ); |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
338 |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
339 /* If this is a new request, call the HOOK_MESSAGE_LOCAL hook */ |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
340 if ( (fd_msg_hdr(*pmsg, &hdr) == 0) |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
341 && (hdr->msg_flags & CMD_FLAG_REQUEST) |
1120
c473581adff2
Cleanup some traces
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1113
diff
changeset
|
342 && (fd_msg_source_get(*pmsg, &diamid, NULL) == 0) |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
343 && (diamid == NULL)) { |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
344 fd_hook_call(HOOK_MESSAGE_LOCAL, *pmsg, NULL, NULL, fd_msg_pmdl_get(*pmsg)); |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
345 } |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
346 |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
347 /* Post the message in the outgoing queue */ |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
348 CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) ); |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
349 |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
350 return 0; |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
351 } |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
352 |
1228 | 353 /* Send a message and optionally register a callback for an answer */ |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
354 int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data ) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
355 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
356 TRACE_ENTRY("%p %p %p", pmsg, anscb, data); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
357 CHECK_PARAMS( pmsg ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
358 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
359 return fd_msg_send_int(pmsg, anscb, data, NULL, NULL); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
360 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
361 |
646
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
362 /* The variation of the same function with a timeout callback */ |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
363 int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout ) |
646
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
364 { |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
365 TRACE_ENTRY("%p %p %p %p %p", pmsg, anscb, data, expirecb, timeout); |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
366 CHECK_PARAMS( pmsg && expirecb && timeout ); |
646
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
367 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
368 return fd_msg_send_int(pmsg, anscb, data, expirecb, timeout); |
646
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
369 } |
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
370 |
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
371 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
372 /* Parse a message against our dictionary, and in case of error log and eventually build the error reply -- returns the parsing status */ |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
373 int fd_msg_parse_or_error( struct msg ** msg, struct msg **error) |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
374 { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
375 int ret = 0; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
376 struct msg * m; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
377 struct msg_hdr * hdr = NULL; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
378 struct fd_pei pei; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
379 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
380 TRACE_ENTRY("%p", msg); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
381 |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
382 CHECK_PARAMS(msg && *msg && error); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
383 m = *msg; |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
384 *error = NULL; |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
385 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
386 /* Parse the message against our dictionary */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
387 ret = fd_msg_parse_rules ( m, fd_g_config->cnf_dict, &pei); |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
103
diff
changeset
|
388 if ((ret != EBADMSG) /* Parsing grouped AVP failed / Conflicting rule found */ |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
103
diff
changeset
|
389 && (ret != ENOTSUP)) /* Command is not supported / Mandatory AVP is not supported */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
390 return ret; /* 0 or another error */ |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
391 |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
392 /* Log */ |
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
393 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, m, NULL, pei.pei_message ?: pei.pei_errcode, fd_msg_pmdl_get(m)); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
394 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
395 CHECK_FCT( fd_msg_hdr(m, &hdr) ); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
396 |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
397 /* Now create an answer error if the message is a query */ |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
398 if (hdr->msg_flags & CMD_FLAG_REQUEST) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
399 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
400 /* Create the error message */ |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
401 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, &m, pei.pei_protoerr ? MSGFL_ANSW_ERROR : 0 ) ); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
402 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
403 /* Set the error code */ |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
404 CHECK_FCT( fd_msg_rescode_set(m, pei.pei_errcode, pei.pei_message, pei.pei_avp, 1 ) ); |
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
405 |
1230
e72c9dad62ac
Fix issue with generating Failed-AVP when the error is DIAMETER_MISSING_AVP. Also fix a memory leak in that case
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1228
diff
changeset
|
406 /* free the pei AVP to avoid memory leak */ |
e72c9dad62ac
Fix issue with generating Failed-AVP when the error is DIAMETER_MISSING_AVP. Also fix a memory leak in that case
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1228
diff
changeset
|
407 if (pei.pei_avp_free) { |
e72c9dad62ac
Fix issue with generating Failed-AVP when the error is DIAMETER_MISSING_AVP. Also fix a memory leak in that case
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1228
diff
changeset
|
408 fd_msg_free(pei.pei_avp); |
e72c9dad62ac
Fix issue with generating Failed-AVP when the error is DIAMETER_MISSING_AVP. Also fix a memory leak in that case
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1228
diff
changeset
|
409 } |
e72c9dad62ac
Fix issue with generating Failed-AVP when the error is DIAMETER_MISSING_AVP. Also fix a memory leak in that case
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1228
diff
changeset
|
410 |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
411 *msg = NULL; |
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
412 *error = m; |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
413 |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
414 } else { |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
415 do { /* Rescue error messages */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
416 struct avp * avp; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
417 union avp_value * rc = NULL; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
418 |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
419 /* Search the Result-Code AVP */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
420 CHECK_FCT_DO( fd_msg_browse(*msg, MSG_BRW_FIRST_CHILD, &avp, NULL), break ); |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
421 while (avp) { |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
422 struct avp_hdr * ahdr; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
423 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &ahdr ), break ); |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
424 |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
425 if ((ahdr->avp_code == AC_RESULT_CODE) && (! (ahdr->avp_flags & AVP_FLAG_VENDOR)) ) { |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
426 /* Parse this AVP */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
427 ASSERT( ahdr->avp_value ); |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
428 rc = ahdr->avp_value; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
429 break; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
430 } |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
431 |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
432 /* Go to next AVP */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
433 CHECK_FCT_DO( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL), break ); |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
434 } |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
435 |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
436 if (rc) { |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
437 switch (rc->u32 / 1000) { |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
438 case 1: /* 1xxx : Informational */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
439 case 2: /* 2xxx : Sucess */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
440 /* In these cases, we want the message to validate the ABNF, so we will discard the bad message */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
441 break; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
442 |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
443 default: /* Other errors */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
444 /* We let the application decide what to do with the message, we rescue it */ |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
445 *error = m; |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
446 } |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
447 } |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
448 } while (0); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
449 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
450 |
115 | 451 return EBADMSG; /* We convert ENOTSUP to EBADMSG as well */ |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
452 } |