Mercurial > hg > freeDiameter
annotate libfdcore/messages.c @ 1554:566bb46cc73f
Updated copyright information
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Tue, 06 Oct 2020 21:34:53 +0800 |
parents | b09f1b4c9fad |
children |
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 * * |
1554
566bb46cc73f
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1425
diff
changeset
|
5 * Copyright (c) 2020, 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 */ |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
45 static struct dict_object * dict_avp_ER = NULL; /* Experimental-Result */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
46 static struct dict_object * dict_avp_VI = NULL; /* Vendor-Id */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
47 static struct dict_object * dict_avp_ERC = NULL; /* Experimental-Result-Code */ |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 /* Resolve the dictionary objects */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 int fd_msg_init(void) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 TRACE_ENTRY(""); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
58 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 /* 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
|
60 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
|
61 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
|
62 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
|
63 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-State-Id", &fd_dict_avp_OSI , ENOENT) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
64 |
10
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, "Result-Code", &dict_avp_RC , ENOENT) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 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
|
67 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
|
68 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Failed-AVP", &dict_avp_FAVP, ENOENT) ); |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
69 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Experimental-Result", &dict_avp_ER, ENOENT) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
70 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict_avp_VI, ENOENT) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
71 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Experimental-Result-Code", &dict_avp_ERC, ENOENT) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
72 |
78
a58f0757c06a
Added code for DPR/DPA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
66
diff
changeset
|
73 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Disconnect-Cause", &fd_dict_avp_DC , ENOENT) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
74 |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
75 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
|
76 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
|
77 CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Disconnect-Peer-Request", &fd_dict_cmd_DPR, ENOENT ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
78 |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
79 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
80 return 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
81 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
82 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
83 /* 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
|
84 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
|
85 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
86 union avp_value val; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
87 struct avp * avp_OH = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
88 struct avp * avp_OR = NULL; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
89 struct avp * avp_OSI = NULL; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
90 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
91 TRACE_ENTRY("%p", msg); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
92 CHECK_PARAMS( msg ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
93 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
94 /* Create the Origin-Host AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
95 CHECK_FCT( fd_msg_avp_new( dict_avp_OH, 0, &avp_OH ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
96 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
97 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
98 memset(&val, 0, sizeof(val)); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
99 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
|
100 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
|
101 CHECK_FCT( fd_msg_avp_setvalue( avp_OH, &val ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
102 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
103 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
104 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_OH ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
105 |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
106 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 /* Create the Origin-Realm AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
108 CHECK_FCT( fd_msg_avp_new( dict_avp_OR, 0, &avp_OR ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
109 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
110 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
111 memset(&val, 0, sizeof(val)); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
112 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
|
113 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
|
114 CHECK_FCT( fd_msg_avp_setvalue( avp_OR, &val ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
115 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
117 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_OR ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
118 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 if (osi) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
120 /* Create the Origin-State-Id AVP */ |
66
dcbd5b5ee55c
Added handling for DWR/DWA
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
121 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
|
122 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
123 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
124 memset(&val, 0, sizeof(val)); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
125 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
|
126 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
|
127 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
128 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
129 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
|
130 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
131 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
132 return 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
133 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
134 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
135 /* 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
|
136 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
|
137 { |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
138 union avp_value val; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
139 struct avp * avp = NULL; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
140 struct session * sess = NULL; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
141 os0_t sid; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
142 size_t sidlen; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
143 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
144 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
|
145 CHECK_PARAMS( msg ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
146 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
147 /* 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
|
148 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
|
149 CHECK_PARAMS( sess == NULL ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
150 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
151 /* Ok, now create the session */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
152 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
|
153 CHECK_FCT( fd_sess_getsid( sess, &sid, &sidlen) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
154 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
155 /* Create an AVP to hold it */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
156 CHECK_FCT( fd_msg_avp_new( dict_avp_SI, 0, &avp ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
157 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
158 /* Set its value */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
159 memset(&val, 0, sizeof(val)); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
160 val.os.data = sid; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
161 val.os.len = sidlen; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
162 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
163 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
164 /* Add it to the message */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
165 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_FIRST_CHILD, avp ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
166 |
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
|
167 /* 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
|
168 CHECK_FCT( fd_msg_sess_set( msg, sess) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
169 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
170 /* Done! */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
171 return 0; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
172 } |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
173 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
174 |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
175 /* Add Result-Code or Experimental-Result, and eventually Failed-AVP, Error-Message and Error-Reporting-Host AVPs */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
176 int fd_msg_add_result( struct msg * msg, vendor_id_t vendor, struct dict_object * restype, char * rescode, char * errormsg, struct avp * optavp, int type_id ) |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
177 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
178 union avp_value val; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
179 uint32_t rc_val = 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
180 int set_e_bit=0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
181 int std_err_msg=0; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
182 |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
183 TRACE_ENTRY("%p %d %p %s %p %p %d", msg, vendor, restype, rescode, errormsg, optavp, type_id); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
184 |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
185 CHECK_PARAMS( msg && restype && rescode ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
186 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
187 /* 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
|
188 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
189 struct dict_object * enum_obj = NULL; |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
190 |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
191 /* Search in the restype */ |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
192 struct dict_enumval_request req; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
193 memset(&req, 0, sizeof(struct dict_enumval_request)); |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
194 req.type_obj = restype; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
195 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
196 /* 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
|
197 req.search.enum_name = rescode; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
198 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &req, &enum_obj, ENOTSUP) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
199 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
200 /* finally retrieve its data */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
201 CHECK_FCT_DO( fd_dict_getval( enum_obj, &(req.search) ), return EINVAL ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
202 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
203 /* 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
|
204 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
|
205 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
206 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
207 if (type_id == 1) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
208 /* 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
|
209 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
|
210 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
211 |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
212 if (vendor == 0) { |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
213 /* Vendor 0; create the Result-Code AVP */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
214 struct avp * avp_RC = NULL; |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
215 CHECK_FCT( fd_msg_avp_new( dict_avp_RC, 0, &avp_RC ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
216 |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
217 /* Set its value */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
218 memset(&val, 0, sizeof(val)); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
219 val.u32 = rc_val; |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
220 CHECK_FCT( fd_msg_avp_setvalue( avp_RC, &val ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
221 |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
222 /* Add it to the message */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
223 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_RC ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
224 } else { |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
225 /* Vendor !0; create the Experimental-Result AVP */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
226 struct avp * avp_ER = NULL; |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
227 CHECK_FCT( fd_msg_avp_new( dict_avp_ER, 0, &avp_ER ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
228 |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
229 /* Create the Vendor-Id AVP and add to Experimental-Result */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
230 { |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
231 struct avp * avp_VI = NULL; |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
232 CHECK_FCT( fd_msg_avp_new( dict_avp_VI, 0, &avp_VI ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
233 |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
234 /* Set Vendor-Id value to vendor */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
235 memset(&val, 0, sizeof(val)); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
236 val.u32 = vendor; |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
237 CHECK_FCT( fd_msg_avp_setvalue( avp_VI, &val ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
238 |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
239 /* Add it to Experimental-Result */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
240 CHECK_FCT( fd_msg_avp_add( avp_ER, MSG_BRW_LAST_CHILD, avp_VI ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
241 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
242 |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
243 /* Create the Experimental-Result-Code AVP and add to Experimental-Result */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
244 { |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
245 struct avp * avp_ERC = NULL; |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
246 CHECK_FCT( fd_msg_avp_new( dict_avp_ERC, 0, &avp_ERC ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
247 |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
248 /* Set Experimental-Result-Code value to rc_val */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
249 memset(&val, 0, sizeof(val)); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
250 val.u32 = rc_val; |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
251 CHECK_FCT( fd_msg_avp_setvalue( avp_ERC, &val ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
252 |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
253 /* Add it to Experimental-Result */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
254 CHECK_FCT( fd_msg_avp_add( avp_ER, MSG_BRW_LAST_CHILD, avp_ERC ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
255 } |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
256 |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
257 /* Add it to the message */ |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
258 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp_ER ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
259 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
260 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
261 if (type_id == 2) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
262 /* Add the Error-Reporting-Host AVP */ |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
263 struct avp * avp_ERH = NULL; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
264 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
|
265 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
266 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
267 memset(&val, 0, sizeof(val)); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
272 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
273 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
|
274 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
275 |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
276 /* Now add the optavp in a Failed-AVP if provided */ |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
277 if (optavp) { |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
278 struct avp * avp_FAVP= NULL; |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
279 struct avp * optavp_cpy = NULL; |
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
280 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
|
281 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
|
282 int is_grouped = 0; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
283 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
284 /* Create the Failed-AVP AVP */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
285 CHECK_FCT( fd_msg_avp_new( dict_avp_FAVP, 0, &avp_FAVP ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
286 |
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
|
287 /* 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
|
288 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
|
289 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
|
290 CHECK_FCT( fd_dict_getval(opt_model, &dictdata) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
291 if (dictdata.avp_basetype == AVP_TYPE_GROUPED) |
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
|
292 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
|
293 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
294 |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
837
diff
changeset
|
295 /* 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
|
296 optavp_cpy = optavp; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
297 |
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
|
298 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
|
299 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
|
300 } 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
|
301 CHECK_FCT( fd_msg_avp_new( NULL, AVPFL_SET_BLANK_VALUE | AVPFL_SET_RAWDATA_FROM_AVP, &optavp_cpy) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
302 |
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
|
303 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
|
304 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
|
305 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
|
306 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
307 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
308 /* 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
|
309 CHECK_FCT( fd_msg_avp_add( avp_FAVP, MSG_BRW_LAST_CHILD, optavp_cpy ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
310 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
311 /* And add to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
312 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
|
313 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
314 |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
315 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
316 /* 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
|
317 switch (rc_val / 1000) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
318 case 1: /* Informational */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
319 case 2: /* Success */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
320 /* 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
|
321 break; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
322 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
323 case 3: /* Protocol Errors */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
324 set_e_bit = 1; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
325 std_err_msg = 1; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
326 break; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
327 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
328 case 4: /* Transcient Failure */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
329 case 5: /* Permanent Failure */ |
1323
10143e09abdf
Use error bit for errors NO_COMMON_SECURITY
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
330 if (rc_val == 5017) /* DIAMETER_NO_COMMON_SECURITY */ { |
10143e09abdf
Use error bit for errors NO_COMMON_SECURITY
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
331 set_e_bit = 1; |
10143e09abdf
Use error bit for errors NO_COMMON_SECURITY
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
332 } |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
333 default: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
334 std_err_msg = 1; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
335 break; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
336 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
337 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
338 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
339 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
340 struct msg_hdr * hdr = NULL; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
341 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
342 CHECK_FCT( fd_msg_hdr( msg, &hdr ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
343 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
344 if (set_e_bit) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
345 hdr->msg_flags |= CMD_FLAG_ERROR; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
346 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
|
347 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
|
348 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
349 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
350 if (std_err_msg || errormsg) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
351 /* Add the Error-Message AVP */ |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
352 struct avp * avp_EM = NULL; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
353 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
|
354 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
355 /* Set its value */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
356 memset(&val, 0, sizeof(val)); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
357 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
358 if (errormsg) { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
359 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
|
360 val.os.len = strlen(errormsg); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
361 } else { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
688
diff
changeset
|
362 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
|
363 val.os.len = strlen(rescode); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
364 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
365 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
|
366 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
367 /* Add it to the message */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
368 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
|
369 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
370 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
371 return 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
372 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
373 |
1425
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
374 int fd_msg_rescode_set( struct msg * msg, char * rescode, char * errormsg, struct avp * optavp, int type_id ) |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
375 { |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
376 struct dict_object * restype = NULL; |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
377 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, dict_avp_RC, &restype, ENOENT ) ); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
378 return fd_msg_add_result(msg, 0, restype, rescode, errormsg, optavp, type_id); |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
379 } |
b09f1b4c9fad
fd_msg_add_result: add function
Luke Mewburn <luke@mewburn.net>
parents:
1383
diff
changeset
|
380 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
381 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
|
382 { |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
383 struct msg_hdr *hdr; |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
384 DiamId_t diamid; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
385 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
386 /* Save the callback in the message, with the timeout */ |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
387 CHECK_FCT( fd_msg_anscb_associate( *pmsg, anscb, data, expirecb, timeout ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
388 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
389 /* 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
|
390 if ( (fd_msg_hdr(*pmsg, &hdr) == 0) |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
391 && (hdr->msg_flags & CMD_FLAG_REQUEST) |
1120
c473581adff2
Cleanup some traces
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1113
diff
changeset
|
392 && (fd_msg_source_get(*pmsg, &diamid, NULL) == 0) |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
393 && (diamid == NULL)) { |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
394 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
|
395 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
396 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
397 /* Post the message in the outgoing queue */ |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
398 CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
399 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
400 return 0; |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
401 } |
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
402 |
1228 | 403 /* 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
|
404 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
|
405 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
406 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
|
407 CHECK_PARAMS( pmsg ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
408 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
409 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
|
410 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
411 |
646
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
412 /* 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
|
413 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
|
414 { |
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
|
415 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
|
416 CHECK_PARAMS( pmsg && expirecb && timeout ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
417 |
1113
eb4ce68b6e5c
Added calls to remaining hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1103
diff
changeset
|
418 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
|
419 } |
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
420 |
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
116
diff
changeset
|
421 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
422 /* 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
|
423 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
|
424 { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
425 int ret = 0; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
426 struct msg * m; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
427 struct msg_hdr * hdr = NULL; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
428 struct fd_pei pei; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
429 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
430 TRACE_ENTRY("%p", msg); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
431 |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
432 CHECK_PARAMS(msg && *msg && error); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
433 m = *msg; |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
434 *error = NULL; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
435 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
436 /* Parse the message against our dictionary */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
437 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
|
438 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
|
439 && (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
|
440 return ret; /* 0 or another error */ |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
441 |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
442 /* Log */ |
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
443 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, m, NULL, pei.pei_message ?: pei.pei_errcode, fd_msg_pmdl_get(m)); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
444 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
445 CHECK_FCT( fd_msg_hdr(m, &hdr) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
446 |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
447 /* 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
|
448 if (hdr->msg_flags & CMD_FLAG_REQUEST) { |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
449 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
450 /* Create the error message */ |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
451 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, &m, pei.pei_protoerr ? MSGFL_ANSW_ERROR : 0 ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
452 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
453 /* Set the error code */ |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
454 CHECK_FCT( fd_msg_rescode_set(m, pei.pei_errcode, pei.pei_message, pei.pei_avp, 1 ) ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
455 |
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
|
456 /* 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
|
457 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
|
458 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
|
459 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
460 |
1103
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
461 *msg = NULL; |
d8591b1c56cd
Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1078
diff
changeset
|
462 *error = m; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
463 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
464 } else { |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
465 do { /* Rescue error messages */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
466 struct avp * avp; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
467 union avp_value * rc = NULL; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
468 |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
469 /* 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
|
470 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
|
471 while (avp) { |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
472 struct avp_hdr * ahdr; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
473 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &ahdr ), break ); |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
474 |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
475 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
|
476 /* Parse this AVP */ |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
477 if (fd_msg_parse_dict(avp, fd_g_config->cnf_dict, &pei) < 0) { |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
478 TRACE_DEBUG(INFO, "error parsing Result-Code AVP"); |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
479 rc = NULL; |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
480 break; |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
481 } |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
482 rc = ahdr->avp_value; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
483 if (rc == NULL) { |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
484 TRACE_DEBUG(INFO, "invalid Result-Code AVP"); |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
485 break; |
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
486 } |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
487 break; |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
488 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
489 |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
490 /* Go to next AVP */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
491 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
|
492 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
493 |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
494 if (rc) { |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
495 switch (rc->u32 / 1000) { |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
496 case 1: /* 1xxx : Informational */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
497 case 2: /* 2xxx : Sucess */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
498 /* 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
|
499 break; |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
500 |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
501 default: /* Other errors */ |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
502 /* 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
|
503 *error = m; |
116
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
504 } |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
505 } |
638647100330
Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
115
diff
changeset
|
506 } while (0); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
507 } |
1383
0d71c0b2eed4
Be loud, but don't exit on invalid mandatory AVP in Answer
Thomas Klausner <tk@giga.or.at>
parents:
1323
diff
changeset
|
508 |
115 | 509 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
|
510 } |