annotate libfdcore/messages.c @ 740:4a9f08d6b6ba

Updated my mail address
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 24 Mar 2011 15:00:18 +0900
parents 4ffbc9f1e922
children 89c5849b0832
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 * *
648
ae29bf971f20 Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 646
diff changeset
5 * Copyright (c) 2011, 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
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
161 /* Done! */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
162 return 0;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
163 }
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
164
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
165
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166 /* 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
167 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
168 {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169 union avp_value val;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
170 struct avp * avp_RC = NULL;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
171 struct avp * avp_EM = NULL;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
172 struct avp * avp_ERH = NULL;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173 struct avp * avp_FAVP= NULL;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
174 uint32_t rc_val = 0;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
175 int set_e_bit=0;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
176 int std_err_msg=0;
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 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
179
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
180 CHECK_PARAMS( msg && rescode );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
181
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
182 /* 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
183 {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
184 struct dict_object * enum_obj = NULL;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
185 struct dict_enumval_request req;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
186 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
187
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
188 /* 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
189 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
190
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
191 /* 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
192 req.search.enum_name = rescode;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
193 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
194
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
195 /* finally retrieve its data */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
196 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
197
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
198 /* 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
199 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
200 }
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
201
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
202 if (type_id == 1) {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
203 /* 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
204 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
205 }
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
206
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
207 /* Create the Result-Code AVP */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
208 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
209
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
210 /* Set its value */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
211 memset(&val, 0, sizeof(val));
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
212 val.u32 = rc_val;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
213 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
214
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
215 /* Add it to the message */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
216 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
217
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
218 if (type_id == 2) {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
219 /* Add the Error-Reporting-Host AVP */
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 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
222
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
223 /* Set its value */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
224 memset(&val, 0, sizeof(val));
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
225 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
226 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
227 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
228
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
229 /* Add it to the message */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
230 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
231
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
232 }
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
233
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
234 /* 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
235 if (optavp) {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
236 /* Create the Failed-AVP AVP */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
237 CHECK_FCT( fd_msg_avp_new( dict_avp_FAVP, 0, &avp_FAVP ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
238
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
239 /* Add the passed AVP inside it */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
240 CHECK_FCT( fd_msg_avp_add( avp_FAVP, MSG_BRW_LAST_CHILD, optavp ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
241
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
242 /* And add to the message */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
243 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
244 }
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
245
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
246
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
247 /* 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
248 switch (rc_val / 1000) {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
249 case 1: /* Informational */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
250 case 2: /* Success */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
251 /* 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
252 break;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
253
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
254 case 3: /* Protocol Errors */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
255 set_e_bit = 1;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
256 std_err_msg = 1;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
257 break;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
258
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
259 case 4: /* Transcient Failure */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
260 case 5: /* Permanent Failure */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
261 default:
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
262 std_err_msg = 1;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
263 break;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
264
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
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
267 {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
268 struct msg_hdr * hdr = NULL;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
269
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
270 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
271
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
272 if (set_e_bit)
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
273 hdr->msg_flags |= CMD_FLAG_ERROR;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
274 else
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
275 hdr->msg_flags &= ! CMD_FLAG_ERROR;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
276 }
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
277
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
278 if (std_err_msg || errormsg) {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
279 /* Add the Error-Message AVP */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
280
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
281 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
282
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
283 /* Set its value */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
284 memset(&val, 0, sizeof(val));
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
285
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
286 if (errormsg) {
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
287 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
288 val.os.len = strlen(errormsg);
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
289 } else {
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
290 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
291 val.os.len = strlen(rescode);
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
292 }
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
293 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
294
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
295 /* Add it to the message */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
296 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
297 }
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 return 0;
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
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
302 /* Send a message and optionaly register a callback for an answer */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
303 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
304 {
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
305 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
306 CHECK_PARAMS( pmsg );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
307
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
308 /* Save the callback in the message */
103
215eeeeb0bd3 Fix invalid call
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
309 if (anscb) {
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
310 CHECK_FCT( fd_msg_anscb_associate( *pmsg, anscb, data, NULL /* we should maybe use a safeguard here like 1 hour or so? */ ) );
103
215eeeeb0bd3 Fix invalid call
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 78
diff changeset
311 }
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
312
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
313 /* Post the message in the outgoing queue */
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
314 CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
315
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
316 return 0;
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
317 }
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
318
646
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
319 /* The variation of the same function with a timeout callback */
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
320 int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, const struct timespec *timeout )
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
321 {
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
322 TRACE_ENTRY("%p %p %p", pmsg, anscb, data, timeout);
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
323 CHECK_PARAMS( pmsg && anscb && timeout );
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
324
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
325 /* Save the callback in the message, with the timeout */
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
326 CHECK_FCT( fd_msg_anscb_associate( *pmsg, anscb, data, timeout ) );
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
327
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
328 /* Post the message in the outgoing queue */
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
329 CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) );
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
330
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
331 return 0;
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
332 }
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
333
cfc8da9264f4 Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 116
diff changeset
334
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
335 /* Parse a message against our dictionary, and in case of error log and eventually build the error reply -- returns the parsing status */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
336 int fd_msg_parse_or_error( struct msg ** msg )
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
337 {
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
338 int ret = 0;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
339 struct msg * m;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
340 struct msg_hdr * hdr = NULL;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
341 struct fd_pei pei;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
342
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
343 TRACE_ENTRY("%p", msg);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
344
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
345 CHECK_PARAMS(msg && *msg);
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
346 m = *msg;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
347
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
348 /* Parse the message against our dictionary */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
349 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
350 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
351 && (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
352 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
353
688
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
354 TRACE_DEBUG(INFO, "A message does not comply to the dictionary and/or rules (%s)", pei.pei_errcode);
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
355 fd_msg_dump_walk(FULL, m);
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
356
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
357 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
358
116
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
359 /* 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
360 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
361
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
362 /* Create the error message */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
363 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, pei.pei_protoerr ? MSGFL_ANSW_ERROR : 0 ) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
364
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
365 /* Set the error code */
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
366 CHECK_FCT( fd_msg_rescode_set(*msg, pei.pei_errcode, pei.pei_message, pei.pei_avp, 1 ) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
367
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
368 } else {
116
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
369 do { /* Rescue error messages */
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
370 struct avp * avp;
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
371 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
372
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
373 /* 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
374 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
375 while (avp) {
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
376 struct avp_hdr * ahdr;
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
377 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
378
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
379 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
380 /* Parse this AVP */
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
381 ASSERT( ahdr->avp_value );
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
382 rc = ahdr->avp_value;
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
383 break;
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
384 }
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
385
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
386 /* Go to next AVP */
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
387 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
388 }
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
389
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
390 if (rc) {
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
391 switch (rc->u32 / 1000) {
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
392 case 1: /* 1xxx : Informational */
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
393 case 2: /* 2xxx : Sucess */
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
394 /* 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
395 break;
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
396
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
397 default: /* Other errors */
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
398 /* We let the application decide what to do with the message, we rescue it */
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
399 return 0;
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
400 }
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
401 }
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
402 } while (0);
638647100330 Changed function to accept invalid ABNF in error messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 115
diff changeset
403
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
404 /* Just discard */
688
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 658
diff changeset
405 fd_msg_log( FD_MSG_LOG_DROPPED, m, "Answer not compliant to dictionary's ABNF (%s)", pei.pei_errcode );
34
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
406 CHECK_FCT( fd_msg_free( m ) );
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
407 *msg = NULL;
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
408 }
0e2b57789361 Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
409
115
926e6b016778 Fix return value
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 114
diff changeset
410 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
411 }
"Welcome to our mercurial repository"