Mercurial > hg > freeDiameter
annotate libfdproto/messages.c @ 1092:e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Mon, 06 May 2013 11:30:34 +0800 |
parents | 7d7266115a34 |
children | 44f3e48dfe27 |
rev | line source |
---|---|
0 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
740
4a9f08d6b6ba
Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
730
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
0 | 4 * * |
928
5053f1abcf5d
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
924
diff
changeset
|
5 * Copyright (c) 2013, WIDE Project and NICT * |
0 | 6 * All rights reserved. * |
7 * * | |
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * | |
9 * permitted provided that the following conditions are met: * | |
10 * * | |
11 * * Redistributions of source code must retain the above * | |
12 * copyright notice, this list of conditions and the * | |
13 * following disclaimer. * | |
14 * * | |
15 * * Redistributions in binary form must reproduce the above * | |
16 * copyright notice, this list of conditions and the * | |
17 * following disclaimer in the documentation and/or other * | |
18 * materials provided with the distribution. * | |
19 * * | |
20 * * Neither the name of the WIDE Project or NICT nor the * | |
21 * names of its contributors may be used to endorse or * | |
22 * promote products derived from this software without * | |
23 * specific prior written permission of WIDE Project and * | |
24 * NICT. * | |
25 * * | |
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * | |
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | |
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | |
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | |
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | |
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | |
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | |
34 *********************************************************************************************************/ | |
35 | |
36 /* Messages module. | |
37 * | |
38 * This module allows to manipulate the msg and avp structures that represents a Diameter message in memory. | |
39 */ | |
40 | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
656
diff
changeset
|
41 #include "fdproto-internal.h" |
0 | 42 |
43 #include <sys/param.h> | |
44 | |
45 /* Type of object */ | |
46 enum msg_objtype { | |
47 MSG_MSG = 1, | |
48 MSG_AVP | |
49 }; | |
50 | |
51 /* Chaining of elements as a free hierarchy */ | |
52 struct msg_avp_chain { | |
53 struct fd_list chaining; /* Chaining information at this level. */ | |
54 struct fd_list children; /* sentinel for the children of this object */ | |
55 enum msg_objtype type; /* Type of this object, _MSG_MSG or _MSG_AVP */ | |
56 }; | |
57 | |
58 /* Return the chain information from an AVP or MSG. Since it's the first field, we just cast */ | |
59 #define _C(_x) ((struct msg_avp_chain *)(_x)) | |
60 | |
61 /* Some details about chaining: | |
62 * | |
63 * A message is made of a header ( msg ) and 0 or more AVPs ( avp ). | |
64 * The structure is a kind of tree, where some AVPs (grouped AVPs) can contain other AVPs. | |
871 | 65 * Example: |
0 | 66 * msg |
67 * |-avp | |
68 * |-gavp | |
69 * | |-avp | |
70 * | |-avp | |
71 * | \-avp | |
72 * |-avp | |
73 * \-avp | |
74 * | |
75 * Each item (msg or avp) structure begins with a msg_avp_chain structure. | |
76 * The element at the top of the hierarchy (msg in our example) has all the fields of its "chaining" equal to the same value. | |
77 * | |
78 * All elements at the same level are linked by their "chaining" list. | |
79 * The "children" list is the sentinel for the lists of children of this element. | |
80 */ | |
81 | |
82 /* The following definitions are used to recognize objects in memory. */ | |
83 #define MSG_MSG_EYEC (0x11355463) | |
84 #define MSG_AVP_EYEC (0x11355467) | |
85 | |
86 /* The following structure represents an AVP instance. */ | |
87 struct avp { | |
88 struct msg_avp_chain avp_chain; /* Chaining information of this AVP */ | |
89 int avp_eyec; /* Must be equal to MSG_AVP_EYEC */ | |
90 struct dict_object *avp_model; /* If not NULL, pointer to the dictionary object of this avp */ | |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
91 struct { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
92 avp_code_t mnf_code; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
93 vendor_id_t mnf_vendor; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
94 } avp_model_not_found; /* When model resolution has failed, store a copy of the data here to avoid searching again */ |
0 | 95 struct avp_hdr avp_public; /* AVP data that can be managed by other modules */ |
96 | |
97 uint8_t *avp_source; /* If the message was parsed from a buffer, pointer to the AVP data start in the buffer. */ | |
98 uint8_t *avp_rawdata; /* when the data can not be interpreted, the raw data is copied here. The header is not part of it. */ | |
99 size_t avp_rawlen; /* The length of the raw buffer. */ | |
100 union avp_value avp_storage; /* To avoid many alloc/free, store the integer values here and set avp_public.avp_data to &storage */ | |
101 int avp_mustfreeos; /* 1 if an octetstring is malloc'd in avp_storage and must be freed. */ | |
102 }; | |
103 | |
104 /* Macro to compute the AVP header size */ | |
105 #define AVPHDRSZ_NOVEND 8 | |
106 #define AVPHDRSZ_VENDOR 12 | |
107 #define GETAVPHDRSZ( _flag ) ((_flag & AVP_FLAG_VENDOR) ? AVPHDRSZ_VENDOR : AVPHDRSZ_NOVEND) | |
108 | |
109 /* Macro to cast a msg_avp_t */ | |
110 #define _A(_x) ((struct avp *)(_x)) | |
111 /* Check the type and eyecatcher */ | |
915
9bd18fa4e601
Fix macro to avoid infinite loop in some situations
Sebastien Decugis <sdecugis@freediameter.net>
parents:
903
diff
changeset
|
112 #define CHECK_AVP(_x) ((_x) && (_C(_x)->type == MSG_AVP) && (_A(_x)->avp_eyec == MSG_AVP_EYEC)) |
0 | 113 |
114 /* The following structure represents an instance of a message (command and children AVPs). */ | |
115 struct msg { | |
116 struct msg_avp_chain msg_chain; /* List of the AVPs in the message */ | |
117 int msg_eyec; /* Must be equal to MSG_MSG_EYEC */ | |
118 struct dict_object *msg_model; /* If not NULL, pointer to the dictionary object of this message */ | |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
119 struct { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
120 command_code_t mnf_code; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
121 uint8_t mnf_flags; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
122 } msg_model_not_found; /* When model resolution has failed, store a copy of the data here to avoid searching again */ |
0 | 123 struct msg_hdr msg_public; /* Message data that can be managed by extensions. */ |
124 | |
125 uint8_t *msg_rawbuffer; /* data buffer that was received, saved during fd_msg_parse_buffer and freed in fd_msg_parse_dict */ | |
126 int msg_routable; /* Is this a routable message? (0: undef, 1: routable, 2: non routable) */ | |
127 struct msg *msg_query; /* the associated query if the message is a received answer */ | |
637
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
128 int msg_associated; /* and the counter part information in the query, to avoid double free */ |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
129 struct rt_data *msg_rtdata; /* Routing list for the query */ |
85
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
130 struct session *msg_sess; /* Cached message session if any */ |
0 | 131 struct { |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
132 void (*anscb)(void *, struct msg **); |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
133 void (*expirecb)(void *, DiamId_t, size_t, struct msg **); |
0 | 134 void * data; |
646
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
638
diff
changeset
|
135 struct timespec timeout; |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
136 } msg_cb; /* Callback to be called when an answer is received, or timeout expires, if not NULL */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
137 DiamId_t msg_src_id; /* Diameter Id of the peer this message was received from. This string is malloc'd and must be freed */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
138 size_t msg_src_id_len; /* cached length of this string */ |
894
43fb27a9037f
Intrumented socket reception to store the timestamp along the received buffer
Sebastien Decugis <sdecugis@freediameter.net>
parents:
893
diff
changeset
|
139 |
0 | 140 }; |
141 | |
142 /* Macro to compute the message header size */ | |
143 #define GETMSGHDRSZ() 20 | |
144 | |
145 /* Macro to cast a msg_avp_t */ | |
146 #define _M(_x) ((struct msg *)(_x)) | |
147 /* Check the type and eyecatcher */ | |
704
289632905e19
Added new sanity check
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
148 #define CHECK_MSG(_x) ((_x) && (_C(_x)->type == MSG_MSG) && (_M(_x)->msg_eyec == MSG_MSG_EYEC)) |
0 | 149 |
150 #define VALIDATE_OBJ(_x) ( (CHECK_MSG(_x)) || (CHECK_AVP(_x)) ) | |
151 | |
152 | |
153 /* Macro to validate a MSGFL_ value */ | |
638
9448cba86673
Improved usability of dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
637
diff
changeset
|
154 #define CHECK_AVPFL(_fl) ( ((_fl) & (- (AVPFL_MAX << 1) )) == 0 ) |
0 | 155 #define CHECK_MSGFL(_fl) ( ((_fl) & (- (MSGFL_MAX << 1) )) == 0 ) |
156 | |
157 | |
158 /* initial sizes of AVP from their types, in bytes. */ | |
159 static int avp_value_sizes[] = { | |
160 0, /* AVP_TYPE_GROUPED: size is dynamic */ | |
161 0, /* AVP_TYPE_OCTETSTRING: size is dynamic */ | |
162 4, /* AVP_TYPE_INTEGER32: size is 32 bits */ | |
163 8, /* AVP_TYPE_INTEGER64: size is 64 bits */ | |
164 4, /* AVP_TYPE_UNSIGNED32: size is 32 bits */ | |
165 8, /* AVP_TYPE_UNSIGNED64: size is 64 bits */ | |
166 4, /* AVP_TYPE_FLOAT32: size is 32 bits */ | |
167 8 /* AVP_TYPE_FLOAT64: size is 64 bits */ | |
168 }; | |
169 #define CHECK_BASETYPE( _type ) ( ((_type) <= AVP_TYPE_MAX) && ((_type) >= 0) ) | |
170 #define GETINITIALSIZE( _type, _vend ) (avp_value_sizes[ CHECK_BASETYPE(_type) ? (_type) : 0] + GETAVPHDRSZ(_vend)) | |
171 | |
172 /* Forward declaration */ | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
173 static int parsedict_do_msg(struct dictionary * dict, struct msg * msg, int only_hdr, struct fd_pei *error_info); |
0 | 174 |
175 /***************************************************************************************************************/ | |
176 /* Creating objects */ | |
177 | |
178 /* Initialize a msg_avp_chain structure */ | |
179 static void init_chain(struct msg_avp_chain * chain, int type) | |
180 { | |
181 fd_list_init( &chain->chaining, (void *)chain); | |
182 fd_list_init( &chain->children, (void *)chain); | |
183 chain->type = type; | |
184 } | |
185 | |
186 /* Initialize a new AVP object */ | |
187 static void init_avp ( struct avp * avp ) | |
188 { | |
189 TRACE_ENTRY("%p", avp); | |
190 | |
191 memset(avp, 0, sizeof(struct avp)); | |
192 init_chain( &avp->avp_chain, MSG_AVP); | |
193 avp->avp_eyec = MSG_AVP_EYEC; | |
194 } | |
195 | |
196 /* Initialize a new MSG object */ | |
197 static void init_msg ( struct msg * msg ) | |
198 { | |
199 TRACE_ENTRY("%p", msg); | |
200 | |
201 memset(msg, 0, sizeof(struct msg)); | |
202 init_chain( &msg->msg_chain, MSG_MSG); | |
203 msg->msg_eyec = MSG_MSG_EYEC; | |
204 } | |
205 | |
206 | |
207 /* Create a new AVP instance */ | |
208 int fd_msg_avp_new ( struct dict_object * model, int flags, struct avp ** avp ) | |
209 { | |
210 struct avp *new = NULL; | |
211 | |
212 TRACE_ENTRY("%p %x %p", model, flags, avp); | |
213 | |
214 /* Check the parameters */ | |
638
9448cba86673
Improved usability of dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
637
diff
changeset
|
215 CHECK_PARAMS( avp && CHECK_AVPFL(flags) ); |
0 | 216 |
217 if (model) { | |
218 enum dict_object_type dicttype; | |
219 CHECK_PARAMS( (fd_dict_gettype(model, &dicttype) == 0) && (dicttype == DICT_AVP) ); | |
220 } | |
221 | |
222 /* Create a new object */ | |
223 CHECK_MALLOC( new = malloc (sizeof(struct avp)) ); | |
224 | |
225 /* Initialize the fields */ | |
226 init_avp(new); | |
227 | |
228 if (model) { | |
229 struct dict_avp_data dictdata; | |
230 | |
231 CHECK_FCT( fd_dict_getval(model, &dictdata) ); | |
232 | |
233 new->avp_model = model; | |
234 new->avp_public.avp_code = dictdata.avp_code; | |
235 new->avp_public.avp_flags = dictdata.avp_flag_val; | |
236 new->avp_public.avp_len = GETINITIALSIZE(dictdata.avp_basetype, dictdata.avp_flag_val ); | |
237 new->avp_public.avp_vendor = dictdata.avp_vendor; | |
238 } | |
239 | |
638
9448cba86673
Improved usability of dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
637
diff
changeset
|
240 if (flags & AVPFL_SET_BLANK_VALUE) { |
9448cba86673
Improved usability of dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
637
diff
changeset
|
241 new->avp_public.avp_value = &new->avp_storage; |
9448cba86673
Improved usability of dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
637
diff
changeset
|
242 } |
9448cba86673
Improved usability of dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
637
diff
changeset
|
243 |
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
|
244 if (flags & AVPFL_SET_RAWDATA_FROM_AVP) { |
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
|
245 new->avp_rawlen = (*avp)->avp_public.avp_len - GETAVPHDRSZ( (*avp)->avp_public.avp_flags ); |
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
|
246 if (new->avp_rawlen) { |
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
|
247 CHECK_MALLOC( new->avp_rawdata = malloc(new->avp_rawlen) ); |
916
058e95c3a336
Initialize dummy AVP for Failed-AVP content with 0s instead of FFs
Sebastien Decugis <sdecugis@freediameter.net>
parents:
915
diff
changeset
|
248 memset(new->avp_rawdata, 0x00, new->avp_rawlen); |
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
|
249 } |
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
|
250 } |
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
|
251 |
0 | 252 /* The new object is ready, return */ |
253 *avp = new; | |
254 return 0; | |
255 } | |
256 | |
257 /* Create a new message instance */ | |
258 int fd_msg_new ( struct dict_object * model, int flags, struct msg ** msg ) | |
259 { | |
260 struct msg * new = NULL; | |
261 | |
262 TRACE_ENTRY("%p %x %p", model, flags, msg); | |
263 | |
264 /* Check the parameters */ | |
265 CHECK_PARAMS( msg && CHECK_MSGFL(flags) ); | |
266 | |
267 if (model) { | |
268 enum dict_object_type dicttype; | |
269 CHECK_PARAMS( (fd_dict_gettype(model, &dicttype) == 0) && (dicttype == DICT_COMMAND) ); | |
270 } | |
271 | |
272 /* Create a new object */ | |
273 CHECK_MALLOC( new = malloc (sizeof(struct msg)) ); | |
274 | |
275 /* Initialize the fields */ | |
276 init_msg(new); | |
277 new->msg_public.msg_version = DIAMETER_VERSION; | |
278 new->msg_public.msg_length = GETMSGHDRSZ(); /* This will be updated later */ | |
279 | |
280 if (model) { | |
281 struct dictionary *dict; | |
282 struct dict_cmd_data dictdata; | |
283 struct dict_object *dictappl; | |
284 | |
285 CHECK_FCT( fd_dict_getdict(model, &dict) ); | |
286 CHECK_FCT( fd_dict_getval(model, &dictdata) ); | |
287 | |
288 new->msg_model = model; | |
289 new->msg_public.msg_flags = dictdata.cmd_flag_val; | |
290 new->msg_public.msg_code = dictdata.cmd_code; | |
291 | |
292 /* Initialize application from the parent, if any */ | |
293 CHECK_FCT( fd_dict_search( dict, DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl, 0) ); | |
294 if (dictappl != NULL) { | |
295 struct dict_application_data appdata; | |
296 CHECK_FCT( fd_dict_getval(dictappl, &appdata) ); | |
297 new->msg_public.msg_appl = appdata.application_id; | |
298 } | |
299 } | |
300 | |
301 if (flags & MSGFL_ALLOC_ETEID) { | |
302 new->msg_public.msg_eteid = fd_msg_eteid_get(); | |
303 } | |
304 | |
305 /* The new object is ready, return */ | |
306 *msg = new; | |
307 return 0; | |
308 } | |
309 | |
992
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
310 static int bufferize_avp(unsigned char * buffer, size_t buflen, size_t * offset, struct avp * avp); |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
311 static int parsebuf_list(unsigned char * buf, size_t buflen, struct fd_list * head); |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
312 static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info); |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
313 |
992
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
314 |
0 | 315 /* Create answer from a request */ |
316 int fd_msg_new_answer_from_req ( struct dictionary * dict, struct msg ** msg, int flags ) | |
317 { | |
318 struct dict_object * model = NULL; | |
319 struct msg *qry, *ans; | |
112
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
320 struct session * sess = NULL; |
0 | 321 |
322 TRACE_ENTRY("%p %x", msg, flags); | |
323 | |
324 /* Check the parameters */ | |
325 CHECK_PARAMS( msg ); | |
326 qry = *msg; | |
327 CHECK_PARAMS( CHECK_MSG(qry) && (qry->msg_public.msg_flags & CMD_FLAG_REQUEST) ); | |
328 | |
112
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
329 if (! (flags & MSGFL_ANSW_NOSID)) { |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
330 /* Get the session of the message */ |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
331 CHECK_FCT_DO( fd_msg_sess_get(dict, qry, &sess, NULL), /* ignore an error */ ); |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
332 } |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
333 |
0 | 334 /* Find the model for the answer */ |
335 if (flags & MSGFL_ANSW_ERROR) { | |
336 /* The model is the generic error format */ | |
337 CHECK_FCT( fd_dict_get_error_cmd(dict, &model) ); | |
338 } else { | |
339 /* The model is the answer corresponding to the query. It supposes that these are defined in the dictionary */ | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
340 CHECK_FCT_DO( parsedict_do_msg( dict, qry, 1, NULL), /* continue */ ); |
0 | 341 if (qry->msg_model) { |
342 CHECK_FCT( fd_dict_search ( dict, DICT_COMMAND, CMD_ANSWER, qry->msg_model, &model, EINVAL ) ); | |
343 } | |
344 } | |
345 | |
346 /* Create the answer */ | |
347 CHECK_FCT( fd_msg_new( model, flags, &ans ) ); | |
348 | |
349 /* Set informations in the answer as in the query */ | |
350 ans->msg_public.msg_code = qry->msg_public.msg_code; /* useful for MSGFL_ANSW_ERROR */ | |
351 ans->msg_public.msg_appl = qry->msg_public.msg_appl; | |
352 ans->msg_public.msg_eteid = qry->msg_public.msg_eteid; | |
353 ans->msg_public.msg_hbhid = qry->msg_public.msg_hbhid; | |
354 | |
112
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
355 /* Add the Session-Id AVP if session is known */ |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
356 if (sess && dict) { |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
357 static struct dict_object * sess_id_avp = NULL; |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
358 os0_t sid; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
359 size_t sidlen; |
112
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
360 struct avp * avp; |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
361 union avp_value val; |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
362 |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
363 if (!sess_id_avp) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
364 CHECK_FCT( fd_dict_search( dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &sess_id_avp, ENOENT) ); |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
365 } |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
366 CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ) ); |
112
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
367 CHECK_FCT( fd_msg_avp_new ( sess_id_avp, 0, &avp ) ); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
368 val.os.data = sid; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
369 val.os.len = sidlen; |
112
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
370 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
371 CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_FIRST_CHILD, avp ) ); |
291
2d3a799ad29c
Cache the session pointer in answers when it was present in queries
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
280
diff
changeset
|
372 ans->msg_sess = sess; |
2d3a799ad29c
Cache the session pointer in answers when it was present in queries
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
280
diff
changeset
|
373 CHECK_FCT( fd_sess_ref_msg(sess) ); |
112
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
374 } |
6a294d977878
Default to add Session-Id in answers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
100
diff
changeset
|
375 |
992
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
376 /* Add all Proxy-Info AVPs from the query if any */ |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
377 if (! (flags & MSGFL_ANSW_NOPROXYINFO)) { |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
378 struct avp * avp; |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
379 struct fd_pei pei; |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
380 struct fd_list avpcpylist = FD_LIST_INITIALIZER(avpcpylist); |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
381 |
992
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
382 CHECK_FCT( fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL) ); |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
383 while (avp) { |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
384 if ( (avp->avp_public.avp_code == AC_PROXY_INFO) |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
385 && (avp->avp_public.avp_vendor == 0) ) { |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
386 /* We found a Proxy-Info, need to duplicate it in the answer */ |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
387 |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
388 /* In order to avoid dealing with all different possibilities of states, we just create a buffer then parse it */ |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
389 unsigned char * buf = NULL; |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
390 size_t offset = 0; |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
391 |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
392 /* Create a buffer with the content of the AVP. This is easier than going through the list */ |
992
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
393 CHECK_FCT( fd_msg_update_length(avp) ); |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
394 CHECK_MALLOC( buf = malloc(avp->avp_public.avp_len) ); |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
395 CHECK_FCT( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp) ); |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
396 |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
397 /* Now we parse this buffer to create a copy AVP */ |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
398 CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist) ); |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
399 |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
400 /* Parse dictionary objects now to remove the dependency on the buffer */ |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
401 CHECK_FCT( parsedict_do_chain(dict, &avpcpylist, 0, &pei) ); |
992
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
402 |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
403 /* Done for this AVP */ |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
404 free(buf); |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
405 |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
406 /* We move this AVP now so that we do not parse again in next loop */ |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
407 fd_list_move_end(&ans->msg_chain.children, &avpcpylist); |
992
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
408 } |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
409 /* move to next AVP in the message, we can have several Proxy-Info instances */ |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
410 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) ); |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
411 } |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
412 } |
80584f0e851a
Copy by default the Proxy-Info AVP included in requests into the answers. Use MSGFL_ANSW_NOPROXYINFO to ignore. This code has not been tested yet.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
413 |
0 | 414 /* associate with query */ |
415 ans->msg_query = qry; | |
637
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
416 qry->msg_associated = 1; |
0 | 417 |
418 /* Done */ | |
419 *msg = ans; | |
420 return 0; | |
421 } | |
422 | |
423 /***************************************************************************************************************/ | |
424 | |
425 /* Explore a message */ | |
426 int fd_msg_browse_internal ( msg_or_avp * reference, enum msg_brw_dir dir, msg_or_avp ** found, int * depth ) | |
427 { | |
428 struct msg_avp_chain *result = NULL; | |
429 int diff = 0; | |
430 struct fd_list *li = NULL; | |
431 | |
432 TRACE_ENTRY("%p %d %p %p", reference, dir, found, depth); | |
433 | |
434 /* Initialize the "found" result if any */ | |
435 if (found) | |
436 *found = NULL; | |
437 | |
438 /* Check the parameters */ | |
439 CHECK_PARAMS( VALIDATE_OBJ(reference) ); | |
440 | |
441 TRACE_DEBUG(FCTS, "chaining(%p): nxt:%p prv:%p hea:%p top:%p", | |
442 &_C(reference)->chaining, | |
443 _C(reference)->chaining.next, | |
444 _C(reference)->chaining.prev, | |
445 _C(reference)->chaining.head, | |
446 _C(reference)->chaining.o); | |
447 TRACE_DEBUG(FCTS, "children(%p): nxt:%p prv:%p hea:%p top:%p", | |
448 &_C(reference)->children, | |
449 _C(reference)->children.next, | |
450 _C(reference)->children.prev, | |
451 _C(reference)->children.head, | |
452 _C(reference)->children.o); | |
453 | |
454 /* Now search */ | |
455 switch (dir) { | |
456 case MSG_BRW_NEXT: | |
457 /* Check the reference is an AVP */ | |
458 CHECK_PARAMS( _C(reference)->type == MSG_AVP ); | |
459 | |
460 li = &_C(reference)->chaining; | |
461 | |
462 /* Check if the next element is not the sentinel ( ==> the parent) */ | |
463 if (li->next != li->head) | |
464 result = _C(li->next->o); | |
465 break; | |
466 | |
467 case MSG_BRW_PREV: | |
468 /* Check the reference is an AVP */ | |
469 CHECK_PARAMS( _C(reference)->type == MSG_AVP ); | |
470 | |
471 li = &_C(reference)->chaining; | |
472 | |
473 /* Check if the prev element is not the sentinel ( ==> the parent) */ | |
474 if (li->prev != li->head) | |
475 result = _C(li->prev->o); | |
476 break; | |
477 | |
478 case MSG_BRW_FIRST_CHILD: | |
479 li = &_C(reference)->children; | |
480 if (! FD_IS_LIST_EMPTY(li)) { | |
481 result = _C(li->next->o); | |
482 diff = 1; | |
483 } | |
484 break; | |
485 | |
486 case MSG_BRW_LAST_CHILD: | |
487 li = &_C(reference)->children; | |
488 if (! FD_IS_LIST_EMPTY(li)) { | |
489 result = _C(li->prev->o); | |
490 diff = 1; | |
491 } | |
492 break; | |
493 | |
494 case MSG_BRW_PARENT: | |
495 /* If the object is not chained, it has no parent */ | |
496 li = &_C(reference)->chaining; | |
497 if (li != li->head) { | |
498 /* The sentinel is the parent's children list */ | |
499 result = _C(li->head->o); | |
500 diff = -1; | |
501 } | |
502 break; | |
503 | |
504 case MSG_BRW_WALK: | |
505 /* First, try to find a child */ | |
506 li = &_C(reference)->children; | |
507 if ( ! FD_IS_LIST_EMPTY(li) ) { | |
508 result = _C(li->next->o); | |
509 diff = 1; | |
510 break; | |
511 } | |
512 | |
513 /* Then try to find a "next" at this level or one of the parent's */ | |
514 li = &_C(reference)->chaining; | |
515 do { | |
516 /* If this element has a "next" element, return it */ | |
517 if (li->next != li->head) { | |
518 result = _C(li->next->o); | |
519 break; | |
520 } | |
521 /* otherwise, check if we have a parent */ | |
522 if (li == li->head) { | |
523 /* no parent */ | |
524 break; | |
525 } | |
526 /* Go to the parent's chaining information and loop */ | |
527 diff -= 1; | |
528 li = &_C(li->head->o)->chaining; | |
529 } while (1); | |
530 break; | |
531 | |
532 default: | |
533 /* Other directions are invalid */ | |
534 CHECK_PARAMS( dir = 0 ); | |
535 } | |
536 | |
537 /* Save the found object, if any */ | |
538 if (found && result) | |
539 *found = (void *)result; | |
540 | |
541 /* Modify the depth according to the walk direction */ | |
542 if (depth && diff) | |
543 (*depth) += diff; | |
544 | |
545 /* Return ENOENT if found was NULL */ | |
546 if ((!found) && (!result)) | |
547 return ENOENT; | |
548 else | |
549 return 0; | |
550 } | |
551 | |
552 /* Add an AVP into a tree */ | |
553 int fd_msg_avp_add ( msg_or_avp * reference, enum msg_brw_dir dir, struct avp *avp) | |
554 { | |
555 TRACE_ENTRY("%p %d %p", reference, dir, avp); | |
556 | |
557 /* Check the parameters */ | |
558 CHECK_PARAMS( VALIDATE_OBJ(reference) && CHECK_AVP(avp) && FD_IS_LIST_EMPTY(&avp->avp_chain.chaining) ); | |
559 | |
560 /* Now insert */ | |
561 switch (dir) { | |
562 case MSG_BRW_NEXT: | |
563 /* Check the reference is an AVP -- we do not chain AVPs at same level as msgs. */ | |
564 CHECK_PARAMS( _C(reference)->type == MSG_AVP ); | |
565 | |
566 /* Insert the new avp after the reference */ | |
567 fd_list_insert_after( &_A(reference)->avp_chain.chaining, &avp->avp_chain.chaining ); | |
568 break; | |
569 | |
570 case MSG_BRW_PREV: | |
571 /* Check the reference is an AVP */ | |
572 CHECK_PARAMS( _C(reference)->type == MSG_AVP ); | |
573 | |
574 /* Insert the new avp before the reference */ | |
575 fd_list_insert_before( &_A(reference)->avp_chain.chaining, &avp->avp_chain.chaining ); | |
576 break; | |
577 | |
578 case MSG_BRW_FIRST_CHILD: | |
579 /* Insert the new avp after the children sentinel */ | |
580 fd_list_insert_after( &_C(reference)->children, &avp->avp_chain.chaining ); | |
581 break; | |
582 | |
583 case MSG_BRW_LAST_CHILD: | |
584 /* Insert the new avp before the children sentinel */ | |
585 fd_list_insert_before( &_C(reference)->children, &avp->avp_chain.chaining ); | |
586 break; | |
587 | |
588 default: | |
589 /* Other directions are invalid */ | |
590 CHECK_PARAMS( dir = 0 ); | |
591 } | |
592 | |
593 return 0; | |
594 } | |
595 | |
596 /* Search a given AVP model in a message */ | |
597 int fd_msg_search_avp ( struct msg * msg, struct dict_object * what, struct avp ** avp ) | |
598 { | |
599 struct avp * nextavp; | |
600 struct dict_avp_data dictdata; | |
601 enum dict_object_type dicttype; | |
602 | |
603 TRACE_ENTRY("%p %p %p", msg, what, avp); | |
604 | |
605 CHECK_PARAMS( CHECK_MSG(msg) && what ); | |
606 | |
607 CHECK_PARAMS( (fd_dict_gettype(what, &dicttype) == 0) && (dicttype == DICT_AVP) ); | |
608 CHECK_FCT( fd_dict_getval(what, &dictdata) ); | |
609 | |
610 /* Loop on all top AVPs */ | |
611 CHECK_FCT( fd_msg_browse(msg, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL) ); | |
612 while (nextavp) { | |
613 | |
614 if ( (nextavp->avp_public.avp_code == dictdata.avp_code) | |
615 && (nextavp->avp_public.avp_vendor == dictdata.avp_vendor) ) /* always 0 if no V flag */ | |
616 break; | |
617 | |
618 /* Otherwise move to next AVP in the message */ | |
619 CHECK_FCT( fd_msg_browse(nextavp, MSG_BRW_NEXT, (void *)&nextavp, NULL) ); | |
620 } | |
621 | |
622 if (avp) | |
623 *avp = nextavp; | |
624 | |
625 if (avp && nextavp) { | |
626 struct dictionary * dict; | |
627 CHECK_FCT( fd_dict_getdict( what, &dict) ); | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
628 CHECK_FCT_DO( fd_msg_parse_dict( nextavp, dict, NULL ), /* nothing */ ); |
0 | 629 } |
630 | |
631 if (avp || nextavp) | |
632 return 0; | |
633 else | |
634 return ENOENT; | |
635 } | |
636 | |
637 | |
638 /***************************************************************************************************************/ | |
639 /* Deleting objects */ | |
640 | |
641 /* Destroy and free an AVP or message */ | |
642 static int destroy_obj (struct msg_avp_chain * obj ) | |
643 { | |
644 TRACE_ENTRY("%p", obj); | |
645 | |
646 /* Check the parameter is a valid object */ | |
647 CHECK_PARAMS( VALIDATE_OBJ(obj) && FD_IS_LIST_EMPTY( &obj->children ) ); | |
648 | |
649 /* Unlink this object if needed */ | |
650 fd_list_unlink( &obj->chaining ); | |
651 | |
652 /* Free the octetstring if needed */ | |
653 if ((obj->type == MSG_AVP) && (_A(obj)->avp_mustfreeos == 1)) { | |
654 free(_A(obj)->avp_storage.os.data); | |
655 } | |
656 /* Free the rawdata if needed */ | |
657 if ((obj->type == MSG_AVP) && (_A(obj)->avp_rawdata != NULL)) { | |
658 free(_A(obj)->avp_rawdata); | |
659 } | |
660 if ((obj->type == MSG_MSG) && (_M(obj)->msg_rawbuffer != NULL)) { | |
661 free(_M(obj)->msg_rawbuffer); | |
662 } | |
663 | |
664 if ((obj->type == MSG_MSG) && (_M(obj)->msg_src_id != NULL)) { | |
665 free(_M(obj)->msg_src_id); | |
666 } | |
667 | |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
668 if ((obj->type == MSG_MSG) && (_M(obj)->msg_rtdata != NULL)) { |
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
669 fd_rtd_free(&_M(obj)->msg_rtdata); |
0 | 670 } |
671 | |
85
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
672 if ((obj->type == MSG_MSG) && (_M(obj)->msg_sess != NULL)) { |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
673 CHECK_FCT_DO( fd_sess_reclaim_msg ( &_M(obj)->msg_sess ), /* continue */); |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
674 } |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
675 |
0 | 676 /* free the object */ |
677 free(obj); | |
678 | |
679 return 0; | |
680 } | |
681 | |
682 /* Destroy an object and all its children */ | |
683 static void destroy_tree(struct msg_avp_chain * obj) | |
684 { | |
685 struct fd_list *rem; | |
686 | |
687 TRACE_ENTRY("%p", obj); | |
688 | |
689 /* Destroy any subtree */ | |
690 while ( (rem = obj->children.next) != &obj->children) | |
691 destroy_tree(_C(rem->o)); | |
692 | |
693 /* Then unlink and destroy the object */ | |
694 CHECK_FCT_DO( destroy_obj(obj), /* nothing */ ); | |
695 } | |
696 | |
697 /* Free an object and its tree */ | |
698 int fd_msg_free ( msg_or_avp * object ) | |
699 { | |
700 TRACE_ENTRY("%p", object); | |
701 | |
702 if (CHECK_MSG(object)) { | |
703 if (_M(object)->msg_query) { | |
637
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
704 _M(_M(object)->msg_query)->msg_associated = 0; |
0 | 705 CHECK_FCT( fd_msg_free( _M(object)->msg_query ) ); |
706 _M(object)->msg_query = NULL; | |
637
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
707 } else { |
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
708 if (_M(object)->msg_associated) { |
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
709 TRACE_DEBUG(INFO, "Not freeing query %p referenced in an answer (will be freed along the answer).", object); |
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
710 return 0; |
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
711 } |
0 | 712 } |
713 } | |
714 | |
715 destroy_tree(_C(object)); | |
716 return 0; | |
717 } | |
718 | |
719 | |
720 /***************************************************************************************************************/ | |
721 /* Debug functions: dumping */ | |
722 | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
723 #warning "todo" |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
724 DECLARE_FD_DUMP_PROTOTYPE( fd_msg_dump_summary, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
725 { |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
726 return NULL; |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
727 } |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
728 /* one-line dump with all the contents of the message */ |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
729 DECLARE_FD_DUMP_PROTOTYPE( fd_msg_dump_full, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
730 { |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
731 return NULL; |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
732 } |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
733 /* multi-line human-readable dump similar to wireshark output */ |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
734 DECLARE_FD_DUMP_PROTOTYPE( fd_msg_dump_treeview, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
735 { |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
736 return NULL; |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
737 } |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
738 |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
739 #ifndef OLD_CODE_TO_BE_REPLACED |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
740 void fd_msg_dump_walk ( int level, msg_or_avp *obj ) |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
741 { |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
742 LOG_D("fd_msg_dump_walk %d, %p is deprecated", level, obj); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
743 } |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
744 void fd_msg_dump_one ( int level, msg_or_avp * obj ) |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
745 { |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
746 LOG_D("fd_msg_dump_one %d, %p is deprecated", level, obj); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
747 } |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
748 #else /* OLD_CODE_TO_BE_REPLACED */ |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
749 |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
750 |
0 | 751 /* indent inside an object */ |
752 #define INOBJHDR "%*s " | |
753 #define INOBJHDRVAL indent<0 ? 1 : indent, indent<0 ? "-" : "|" | |
754 | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
755 /* Write some debug data in a buffer */ |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
756 |
0 | 757 /* Dump a msg_t object */ |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
758 static int obj_dump_msg (struct msg * msg, int indent, char **outstr, size_t *offset, size_t *outlen ) |
0 | 759 { |
760 int ret = 0; | |
761 | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
762 CHECK_FCT( dump_add_str(outstr, offset, outlen, "%*sMSG: %p|", INOBJHDRVAL, msg) ); |
0 | 763 |
764 if (!CHECK_MSG(msg)) { | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
765 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "INVALID!", INOBJHDRVAL) ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
766 return 0; |
0 | 767 } |
768 | |
769 if (!msg->msg_model) { | |
770 | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
771 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model)|", INOBJHDRVAL) ); |
0 | 772 |
773 } else { | |
774 | |
775 enum dict_object_type dicttype; | |
776 struct dict_cmd_data dictdata; | |
777 ret = fd_dict_gettype(msg->msg_model, &dicttype); | |
778 if (ret || (dicttype != DICT_COMMAND)) { | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
779 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(invalid model: %d %d)|", INOBJHDRVAL, ret, dicttype) ); |
0 | 780 goto public; |
781 } | |
782 ret = fd_dict_getval(msg->msg_model, &dictdata); | |
783 if (ret != 0) { | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
784 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(error getting model data: %s)|", INOBJHDRVAL, strerror(ret)) ); |
0 | 785 goto public; |
786 } | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
787 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "model : v/m:" DUMP_CMDFL_str "/" DUMP_CMDFL_str ", %u \"%s\"|", INOBJHDRVAL, |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
788 DUMP_CMDFL_val(dictdata.cmd_flag_val), DUMP_CMDFL_val(dictdata.cmd_flag_mask), dictdata.cmd_code, dictdata.cmd_name) ); |
0 | 789 } |
790 public: | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
791 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "public: V:%d L:%d fl:" DUMP_CMDFL_str " CC:%u A:%d hi:%x ei:%x|", INOBJHDRVAL, |
0 | 792 msg->msg_public.msg_version, |
793 msg->msg_public.msg_length, | |
794 DUMP_CMDFL_val(msg->msg_public.msg_flags), | |
795 msg->msg_public.msg_code, | |
796 msg->msg_public.msg_appl, | |
797 msg->msg_public.msg_hbhid, | |
798 msg->msg_public.msg_eteid | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
799 ) ); |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
800 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "intern: rwb:%p rt:%d cb:%p,%p(%p) qry:%p asso:%d sess:%p src:%s(%zd)|", |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
801 INOBJHDRVAL, msg->msg_rawbuffer, msg->msg_routable, msg->msg_cb.anscb, msg->msg_cb.expirecb, msg->msg_cb.data, msg->msg_query, msg->msg_associated, msg->msg_sess, msg->msg_src_id?:"(nil)", msg->msg_src_id_len) ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
802 return 0; |
0 | 803 } |
804 | |
805 /* Dump an avp object */ | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
806 static int obj_dump_avp ( struct avp * avp, int indent, char **outstr, size_t *offset, size_t *outlen ) |
0 | 807 { |
808 int ret = 0; | |
809 | |
810 if (!CHECK_AVP(avp)) { | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
811 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "INVALID!", INOBJHDRVAL) ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
812 return 0; |
0 | 813 } |
814 | |
815 if (!avp->avp_model) { | |
816 | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
817 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model resolved)|", INOBJHDRVAL) ); |
0 | 818 |
819 } else { | |
820 | |
821 enum dict_object_type dicttype; | |
822 struct dict_avp_data dictdata; | |
823 ret = fd_dict_gettype(avp->avp_model, &dicttype); | |
824 if (ret || (dicttype != DICT_AVP)) { | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
825 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(invalid model: %d %d)|", INOBJHDRVAL, ret, dicttype) ); |
0 | 826 goto public; |
827 } | |
828 ret = fd_dict_getval(avp->avp_model, &dictdata); | |
829 if (ret != 0) { | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
830 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(error getting model data: %s)|", INOBJHDRVAL, strerror(ret)) ); |
0 | 831 goto public; |
832 } | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
833 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "model : v/m:" DUMP_AVPFL_str "/" DUMP_AVPFL_str ", %12s, %u \"%s\"|", INOBJHDRVAL, |
0 | 834 DUMP_AVPFL_val(dictdata.avp_flag_val), |
835 DUMP_AVPFL_val(dictdata.avp_flag_mask), | |
836 type_base_name[dictdata.avp_basetype], | |
837 dictdata.avp_code, | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
838 dictdata.avp_name ) ); |
0 | 839 } |
840 public: | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
841 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "public: C:%u fl:" DUMP_AVPFL_str " L:%d V:%u data:@%p|", INOBJHDRVAL, |
0 | 842 avp->avp_public.avp_code, |
843 DUMP_AVPFL_val(avp->avp_public.avp_flags), | |
844 avp->avp_public.avp_len, | |
845 avp->avp_public.avp_vendor, | |
846 avp->avp_public.avp_value | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
847 ) ); |
0 | 848 /* Dump the value if set */ |
849 if (avp->avp_public.avp_value) { | |
850 if (!avp->avp_model) { | |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
851 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(data set but no model: ERROR)|", INOBJHDRVAL) ); |
0 | 852 } else { |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
853 CHECK_FCT( fd_dict_dump_avp_value(avp->avp_public.avp_value, avp->avp_model, indent, outstr, offset, outlen, 1) ); |
0 | 854 } |
855 } | |
400
bb8a4fa301b3
Fix compilation warning
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
387
diff
changeset
|
856 |
1005 | 857 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "intern: src:%p mf:%d raw:%p(%d)|", INOBJHDRVAL, avp->avp_source, avp->avp_mustfreeos, avp->avp_rawdata, avp->avp_rawlen) ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
858 return 0; |
0 | 859 } |
860 | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
861 /* Dump a single object content into out string, realloc if needed */ |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
862 static int msg_dump_intern ( int level, msg_or_avp * obj, int indent, char **outstr, size_t *offset, size_t *outlen ) |
0 | 863 { |
864 /* Log only if we are at least at level */ | |
865 if ( ! TRACE_BOOL(level) ) | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
866 return 0; |
0 | 867 |
868 /* Check the object */ | |
869 if (!VALIDATE_OBJ(obj)) { | |
979 | 870 CHECK_FCT( dump_add_str(outstr, offset, outlen, ">>> invalid object (%p)!.", obj) ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
871 return 0; |
0 | 872 } |
873 | |
874 /* Dump the object */ | |
875 switch (_C(obj)->type) { | |
876 case MSG_AVP: | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
877 CHECK_FCT( obj_dump_avp ( _A(obj), indent, outstr, offset, outlen )); |
0 | 878 break; |
879 | |
880 case MSG_MSG: | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
881 CHECK_FCT( obj_dump_msg ( _M(obj), indent, outstr, offset, outlen ) ); |
0 | 882 break; |
883 | |
884 default: | |
885 ASSERT(0); | |
886 } | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
887 return 0; |
0 | 888 } |
889 | |
687
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
890 /* Dump a message to a specified file stream */ |
688
8c3dc8584dab
Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
891 void fd_msg_dump_fstr ( struct msg * msg, FILE * fstr ) |
687
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
892 { |
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
893 msg_or_avp * ref = msg; |
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
894 int indent = 2; |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
895 char *outstr; |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
896 size_t offset, outlen; |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
897 CHECK_FCT_DO( dump_init_str(&outstr, &offset, &outlen), { fd_log_debug_fstr(fstr, "Error initializing string for dumping %p", msg); return; } ); |
687
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
898 do { |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
899 CHECK_FCT_DO( msg_dump_intern ( NONE, ref, indent, &outstr, &offset, &outlen ), |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
900 fd_log_debug_fstr(fstr, "Error while dumping %p", ref) ); |
687
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
901 |
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
902 /* Now find the next object */ |
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
903 CHECK_FCT_DO( fd_msg_browse ( ref, MSG_BRW_WALK, &ref, &indent ), break ); |
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
904 |
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
905 /* dump next object */ |
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
906 } while (ref); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
907 |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
908 /* now really output this in one shot, so it is not interrupted */ |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
909 fd_log_debug_fstr(fstr, "%s", outstr); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
910 |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
911 free(outstr); |
687
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
912 } |
710 | 913 void fd_msg_dump_fstr_one ( struct msg * msg, FILE * fstr ) /* just the header */ |
914 { | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
915 char *outstr; |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
916 size_t offset, outlen; |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
917 CHECK_FCT_DO( dump_init_str(&outstr, &offset, &outlen), { fd_log_debug_fstr(fstr, "Error initializing string for dumping %p", msg); return; } ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
918 CHECK_FCT_DO( msg_dump_intern ( NONE, msg, 2, &outstr, &offset, &outlen ), |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
919 fd_log_debug_fstr(fstr, "Error while dumping %p", msg) ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
920 /* now really output this in one shot, so it is not interrupted */ |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
921 fd_log_debug_fstr(fstr, "%s", outstr); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
922 |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
923 free(outstr); |
710 | 924 } |
687
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
925 |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
926 /* Completely dump a msg_t object */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
927 static int full_obj_dump_msg (struct msg * msg, struct dictionary *dict, char **outstr, size_t *offset, size_t *outlen) |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
928 { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
929 int ret = 0; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
930 int success = 0; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
931 struct dict_cmd_data dictdata; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
932 char buf[20]; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
933 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
934 if (!CHECK_MSG(msg)) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
935 CHECK_FCT( dump_add_str(outstr, offset, outlen, "INVALID MESSAGE") ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
936 return 0; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
937 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
938 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
939 if (!msg->msg_model) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
940 fd_msg_parse_dict(msg, dict, NULL); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
941 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
942 if (!msg->msg_model) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
943 CHECK_FCT( dump_add_str(outstr, offset, outlen, "(no model) ") ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
944 } else { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
945 enum dict_object_type dicttype; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
946 ret = fd_dict_gettype(msg->msg_model, &dicttype); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
947 if (ret || (dicttype != DICT_COMMAND)) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
948 CHECK_FCT( dump_add_str(outstr, offset, outlen, "(invalid model: %d %d) ", ret, dicttype) ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
949 } else { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
950 ret = fd_dict_getval(msg->msg_model, &dictdata); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
951 if (ret != 0) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
952 CHECK_FCT( dump_add_str(outstr, offset, outlen, "(error getting model data: %s) ", strerror(ret)) ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
953 } else { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
954 success = 1; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
955 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
956 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
957 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
958 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
959 if (msg->msg_public.msg_appl) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
960 snprintf(buf, sizeof(buf), "%u/", msg->msg_public.msg_appl); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
961 } else { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
962 buf[0] = '\0'; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
963 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
964 CHECK_FCT( dump_add_str(outstr, offset, outlen, "%s(%s%u)[" DUMP_CMDFL_str "], Length=%u, Hop-By-Hop-Id=0x%08x, End-to-End=0x%08x", |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
965 success ? dictdata.cmd_name : "unknown", buf, msg->msg_public.msg_code, DUMP_CMDFL_val(msg->msg_public.msg_flags), |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
966 msg->msg_public.msg_length, msg->msg_public.msg_hbhid, msg->msg_public.msg_eteid)); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
967 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
968 return 0; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
969 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
970 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
971 /* Dump an avp object completely */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
972 static int full_obj_dump_avp ( struct avp * avp, char **outstr, size_t *offset, size_t *outlen, int first ) |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
973 { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
974 int success = 0; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
975 struct dict_avp_data dictdata; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
976 char buf[20]; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
977 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
978 CHECK_FCT( dump_add_str(outstr, offset, outlen, first ? ((*outstr)[*offset-1] == '=' ? "{ " : ", { ") : ", ") ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
979 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
980 if (!CHECK_AVP(avp)) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
981 CHECK_FCT( dump_add_str(outstr, offset, outlen, "INVALID AVP") ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
982 return 0; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
983 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
984 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
985 if (avp->avp_model) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
986 enum dict_object_type dicttype; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
987 int ret; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
988 ret = fd_dict_gettype(avp->avp_model, &dicttype); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
989 if (ret || (dicttype != DICT_AVP)) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
990 CHECK_FCT( dump_add_str(outstr, offset, outlen, "(invalid model: %d %d) ", ret, dicttype) ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
991 } else { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
992 ret = fd_dict_getval(avp->avp_model, &dictdata); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
993 if (ret != 0) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
994 CHECK_FCT( dump_add_str(outstr, offset, outlen, "(error getting model data: %s) ", strerror(ret)) ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
995 } else { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
996 success = 1; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
997 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
998 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
999 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1000 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1001 if (avp->avp_public.avp_vendor) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1002 snprintf(buf, sizeof(buf), "%u/", avp->avp_public.avp_vendor); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1003 } else { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1004 buf[0] = '\0'; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1005 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1006 /* \todo add full vendorname? */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1007 CHECK_FCT(dump_add_str(outstr, offset, outlen, "%s(%s%u)[" DUMP_AVPFL_str "]=", success ? dictdata.avp_name : "unknown", buf, avp->avp_public.avp_code, DUMP_AVPFL_val(avp->avp_public.avp_flags))); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1008 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1009 /* Dump the value if set */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1010 if (avp->avp_public.avp_value) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1011 if (!avp->avp_model) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1012 CHECK_FCT( dump_add_str(outstr, offset, outlen, "(unknown data type)") ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1013 } else { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1014 CHECK_FCT( fd_dict_dump_avp_value(avp->avp_public.avp_value, avp->avp_model, 1, outstr, offset, outlen, 0) ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1015 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1016 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1017 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1018 return 0; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1019 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1020 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1021 /* Dump full message */ |
1078
74bba7975864
Cleanup the timing data and fd_msg_log feature that will be replaced by the new hooks mechanism. Kept the calls to fd_msg_log in comments to find the locations easily. WORK IN PROGRESS.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1062
diff
changeset
|
1022 // TODO: need align with new prototype & behavior |
74bba7975864
Cleanup the timing data and fd_msg_log feature that will be replaced by the new hooks mechanism. Kept the calls to fd_msg_log in comments to find the locations easily. WORK IN PROGRESS.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1062
diff
changeset
|
1023 void fd_msg_dump_full_TODO ( int level, struct dictionary *dict, const char *prefix, msg_or_avp *obj ) |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1024 { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1025 msg_or_avp * ref = obj; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1026 char *outstr; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1027 int indent = 1; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1028 int first = 1; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1029 int previous; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1030 size_t offset, outlen; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1031 CHECK_FCT_DO( dump_init_str(&outstr, &offset, &outlen), |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1032 { fd_log_error("Error initializing string for dumping %p", obj); return; } ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1033 CHECK_FCT_DO( dump_add_str(&outstr, &offset, &outlen, "%s: ", prefix), |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1034 { fd_log_error("Error while dumping %p", ref); return; }); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1035 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1036 do { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1037 /* Check the object */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1038 if (!VALIDATE_OBJ(ref)) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1039 CHECK_FCT_DO( dump_add_str(&outstr, &offset, &outlen, ">>> invalid object (%p)", ref), |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1040 { fd_log_error("Error in error handling dumping %p", ref); break; }); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1041 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1042 /* Dump the object */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1043 switch (_C(ref)->type) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1044 case MSG_AVP: |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1045 CHECK_FCT_DO( full_obj_dump_avp ( _A(ref), &outstr, &offset, &outlen, first ), |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1046 { fd_log_error("Error in error handling dumping %p", ref); }); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1047 break; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1048 case MSG_MSG: |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1049 CHECK_FCT_DO( full_obj_dump_msg ( _M(obj), dict, &outstr, &offset, &outlen ), |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1050 { fd_log_error("Error in error handling dumping %p", ref); }); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1051 break; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1052 default: |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1053 ASSERT(0); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1054 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1055 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1056 first = 0; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1057 previous = indent; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1058 /* Now find the next object */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1059 CHECK_FCT_DO( fd_msg_browse ( ref, MSG_BRW_WALK, &ref, &indent ), break ); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1060 if (previous < indent) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1061 first = 1; |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1062 } else while (previous-- > indent) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1063 CHECK_FCT_DO( dump_add_str(&outstr, &offset, &outlen, " }"), |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1064 { fd_log_error("Error while dumping %p", ref); return; }); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1065 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1066 /* dump next object */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1067 } while (ref); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1068 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1069 fd_log(level, "%s", outstr); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1070 free(outstr); |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1071 } |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1027
diff
changeset
|
1072 |
0 | 1073 /* Dump a message content -- for debug mostly */ |
1074 void fd_msg_dump_walk ( int level, msg_or_avp *obj ) | |
1075 { | |
1076 msg_or_avp * ref = obj; | |
1077 int indent = 1; | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1078 char *outstr; |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1079 size_t offset, outlen; |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1080 CHECK_FCT_DO( dump_init_str(&outstr, &offset, &outlen), |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
1081 { fd_log_debug_fstr(fd_g_debug_fstr, "Error initializing string for dumping %p", obj); return; } ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1082 |
0 | 1083 do { |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1084 CHECK_FCT_DO( msg_dump_intern ( level, ref, indent, &outstr, &offset, &outlen ), |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
1085 fd_log_debug_fstr(fd_g_debug_fstr, "Error while dumping %p", ref) ); |
0 | 1086 |
1087 /* Now find the next object */ | |
1088 CHECK_FCT_DO( fd_msg_browse ( ref, MSG_BRW_WALK, &ref, &indent ), break ); | |
1089 | |
1090 /* dump next object */ | |
1091 } while (ref); | |
1092 | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1093 /* now really output this in one shot, so it is not interrupted */ |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1094 TRACE_DEBUG(level, "------ Dumping object %p (w)-------", obj); |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
1095 TRACE_DEBUG(level, "%s", outstr); |
0 | 1096 TRACE_DEBUG(level, "------ /end of object %p -------", obj); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1097 |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1098 free(outstr); |
0 | 1099 } |
1100 | |
1101 /* Dump a single object content -- for debug mostly */ | |
1102 void fd_msg_dump_one ( int level, msg_or_avp * obj ) | |
1103 { | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1104 char *outstr; |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1105 size_t offset, outlen; |
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1106 CHECK_FCT_DO( dump_init_str(&outstr, &offset, &outlen), |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
1107 { fd_log_debug_fstr(fd_g_debug_fstr, "Error initializing string for dumping %p", obj); return; } ); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1108 CHECK_FCT_DO( msg_dump_intern ( level, obj, 1, &outstr, &offset, &outlen ), |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
961
diff
changeset
|
1109 fd_log_debug_fstr(fd_g_debug_fstr, "Error while dumping %p", obj) ); |
0 | 1110 TRACE_DEBUG(level, "------ Dumping object %p (s)-------", obj); |
951
f97fa305467f
Log messages into the same logfile where the error is reported.
Thomas Klausner <tk@giga.or.at>
parents:
924
diff
changeset
|
1111 TRACE_DEBUG(level, "%s", outstr); |
0 | 1112 TRACE_DEBUG(level, "------ /end of object %p -------", obj); |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
1113 free(outstr); |
0 | 1114 } |
1115 | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1084
diff
changeset
|
1116 #endif /* OLD_CODE_TO_BE_REPLACED */ |
0 | 1117 /***************************************************************************************************************/ |
1118 /* Simple meta-data management */ | |
1119 | |
1120 /* Retrieve the model of an object */ | |
1121 int fd_msg_model ( msg_or_avp * reference, struct dict_object ** model ) | |
1122 { | |
1123 TRACE_ENTRY("%p %p", reference, model); | |
1124 | |
1125 /* Check the parameters */ | |
1126 CHECK_PARAMS( model && VALIDATE_OBJ(reference) ); | |
1127 | |
1128 /* copy the model reference */ | |
1129 switch (_C(reference)->type) { | |
1130 case MSG_AVP: | |
1131 *model = _A(reference)->avp_model; | |
1132 break; | |
1133 | |
1134 case MSG_MSG: | |
1135 *model = _M(reference)->msg_model; | |
1136 break; | |
1137 | |
1138 default: | |
1139 CHECK_PARAMS(0); | |
1140 } | |
1141 | |
1142 return 0; | |
1143 } | |
1144 | |
1145 /* Retrieve the address of the msg_public field of a message */ | |
1146 int fd_msg_hdr ( struct msg *msg, struct msg_hdr **pdata ) | |
1147 { | |
1148 TRACE_ENTRY("%p %p", msg, pdata); | |
1149 CHECK_PARAMS( CHECK_MSG(msg) && pdata ); | |
1150 | |
1151 *pdata = &msg->msg_public; | |
1152 return 0; | |
1153 } | |
1154 | |
1155 /* Retrieve the address of the avp_public field of an avp */ | |
1156 int fd_msg_avp_hdr ( struct avp *avp, struct avp_hdr **pdata ) | |
1157 { | |
1158 TRACE_ENTRY("%p %p", avp, pdata); | |
1159 CHECK_PARAMS( CHECK_AVP(avp) && pdata ); | |
1160 | |
1161 *pdata = &avp->avp_public; | |
1162 return 0; | |
1163 } | |
1164 | |
1165 /* Associate answers and queries */ | |
1166 int fd_msg_answ_associate( struct msg * answer, struct msg * query ) | |
1167 { | |
1168 TRACE_ENTRY( "%p %p", answer, query ); | |
1169 | |
1170 CHECK_PARAMS( CHECK_MSG(answer) && CHECK_MSG(query) && (answer->msg_query == NULL ) ); | |
1171 | |
1172 answer->msg_query = query; | |
637
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
1173 query->msg_associated = 1; |
0 | 1174 |
1175 return 0; | |
1176 } | |
1177 | |
1178 int fd_msg_answ_getq( struct msg * answer, struct msg ** query ) | |
1179 { | |
1180 TRACE_ENTRY( "%p %p", answer, query ); | |
1181 | |
1182 CHECK_PARAMS( CHECK_MSG(answer) && query ); | |
1183 | |
1184 *query = answer->msg_query; | |
1185 | |
1186 return 0; | |
1187 } | |
1188 | |
1189 int fd_msg_answ_detach( struct msg * answer ) | |
1190 { | |
1191 TRACE_ENTRY( "%p", answer ); | |
1192 | |
1193 CHECK_PARAMS( CHECK_MSG(answer) ); | |
1194 | |
637
22e8fac3b2d6
Split interface file in modules
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
400
diff
changeset
|
1195 answer->msg_query->msg_associated = 0; |
0 | 1196 answer->msg_query = NULL; |
1197 | |
1198 return 0; | |
1199 } | |
1200 | |
1201 /* Associate / get answer callbacks */ | |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1202 int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout ) |
0 | 1203 { |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1204 TRACE_ENTRY("%p %p %p %p", msg, anscb, expirecb, data); |
0 | 1205 |
1206 /* Check the parameters */ | |
824
89c5849b0832
Allow retransmission of messages on timeout
Sebastien Decugis <sdecugis@freediameter.net>
parents:
808
diff
changeset
|
1207 CHECK_PARAMS( CHECK_MSG(msg) ); |
893
8187364e39ea
Fix answers sending
Sebastien Decugis <sdecugis@freediameter.net>
parents:
892
diff
changeset
|
1208 |
8187364e39ea
Fix answers sending
Sebastien Decugis <sdecugis@freediameter.net>
parents:
892
diff
changeset
|
1209 if (! (msg->msg_public.msg_flags & CMD_FLAG_REQUEST )) |
1009
e22434c66126
Be more restrictive on fd_msg_send() called with answer messages, the function now rejects the parameters if an answer callback is provided
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1005
diff
changeset
|
1210 return anscb ? EINVAL : 0; /* we associate with requests only */ |
893
8187364e39ea
Fix answers sending
Sebastien Decugis <sdecugis@freediameter.net>
parents:
892
diff
changeset
|
1211 |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1212 CHECK_PARAMS( (anscb == NULL) || (msg->msg_cb.anscb == NULL) ); /* We are not overwritting a cb */ |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1213 CHECK_PARAMS( (expirecb == NULL) || (msg->msg_cb.expirecb == NULL) ); /* We are not overwritting a cb */ |
0 | 1214 |
1215 /* Associate callback and data with the message, if any */ | |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1216 msg->msg_cb.anscb = anscb; |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1217 msg->msg_cb.expirecb = expirecb; |
0 | 1218 msg->msg_cb.data = data; |
646
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
638
diff
changeset
|
1219 if (timeout) { |
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
638
diff
changeset
|
1220 memcpy(&msg->msg_cb.timeout, timeout, sizeof(struct timespec)); |
cfc8da9264f4
Prepared first part of the changes for #10
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
638
diff
changeset
|
1221 } |
0 | 1222 |
1223 return 0; | |
1224 } | |
1225 | |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1226 int fd_msg_anscb_get( struct msg * msg, void (**anscb)(void *, struct msg **), void (**expirecb)(void *, DiamId_t, size_t, struct msg **), void ** data ) |
0 | 1227 { |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1228 TRACE_ENTRY("%p %p %p %p", msg, anscb, expirecb, data); |
0 | 1229 |
1230 /* Check the parameters */ | |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1231 CHECK_PARAMS( CHECK_MSG(msg) ); |
0 | 1232 |
1233 /* Copy the result */ | |
1014
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1234 if (anscb) |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1235 *anscb = msg->msg_cb.anscb; |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1236 if (data) |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1237 *data = msg->msg_cb.data; |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1238 if (expirecb) |
908ffbb81f60
Added a second callback in fd_msg_send_timeout to handle more easily the timeout situation
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1009
diff
changeset
|
1239 *expirecb = msg->msg_cb.expirecb; |
0 | 1240 |
1241 return 0; | |
649
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1242 } |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1243 |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1244 struct timespec *fd_msg_anscb_gettimeout( struct msg * msg ) |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1245 { |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1246 TRACE_ENTRY("%p", msg); |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1247 |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1248 /* Check the parameters */ |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1249 CHECK_PARAMS_DO( CHECK_MSG(msg), return NULL ); |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1250 |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1251 if (!msg->msg_cb.timeout.tv_sec) { |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1252 return NULL; |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1253 } |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1254 |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1255 return &msg->msg_cb.timeout; |
5e5d8152c229
Implemented fd_msg_send_timeout to close #10. Not tested yet.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
648
diff
changeset
|
1256 } |
0 | 1257 |
1258 /* Associate routing lists */ | |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1259 int fd_msg_rt_associate( struct msg * msg, struct rt_data ** rtd ) |
0 | 1260 { |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1261 TRACE_ENTRY( "%p %p", msg, rtd ); |
0 | 1262 |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1263 CHECK_PARAMS( CHECK_MSG(msg) && rtd ); |
0 | 1264 |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1265 msg->msg_rtdata = *rtd; |
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1266 *rtd = NULL; |
0 | 1267 |
1268 return 0; | |
1269 } | |
1270 | |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1271 int fd_msg_rt_get( struct msg * msg, struct rt_data ** rtd ) |
0 | 1272 { |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1273 TRACE_ENTRY( "%p %p", msg, rtd ); |
0 | 1274 |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1275 CHECK_PARAMS( CHECK_MSG(msg) && rtd ); |
0 | 1276 |
83
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1277 *rtd = msg->msg_rtdata; |
c662d3eb6ff6
Started support for routing module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
37
diff
changeset
|
1278 msg->msg_rtdata = NULL; |
0 | 1279 |
1280 return 0; | |
1281 } | |
1282 | |
1283 /* Find if a message is routable */ | |
1284 int fd_msg_is_routable ( struct msg * msg ) | |
1285 { | |
1286 TRACE_ENTRY("%p", msg); | |
1287 | |
1288 CHECK_PARAMS_DO( CHECK_MSG(msg), return 0 /* pretend the message is not routable */ ); | |
1289 | |
1290 if ( ! msg->msg_routable ) { | |
37
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
1291 /* To define if a message is routable, we rely on the "PXY" flag (for application 0). */ |
cc3c59fe98fe
Lot of cleanups in peer structure management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
1292 msg->msg_routable = ((msg->msg_public.msg_appl != 0) || (msg->msg_public.msg_flags & CMD_FLAG_PROXIABLE)) ? 1 : 2; |
0 | 1293 |
1294 /* Note : the 'real' criteria according to the Diameter I-D is that the message is | |
1295 routable if and only if the "Destination-Realm" AVP is required by the command ABNF. | |
1296 We could make a test for this here, but it's more computational work and our test | |
1297 seems accurate (until proven otherwise...) */ | |
1298 } | |
1299 | |
1300 return (msg->msg_routable == 1) ? 1 : 0; | |
1301 } | |
1302 | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1303 /* cache the dictionary model for next function to avoid re-searching at every incoming message */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1304 static struct dict_object *cached_avp_rr_model = NULL; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1305 static struct dictionary *cached_avp_rr_dict = NULL; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1306 static pthread_mutex_t cached_avp_rr_lock = PTHREAD_MUTEX_INITIALIZER; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1307 |
0 | 1308 /* Associate source peer */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1309 int fd_msg_source_set( struct msg * msg, DiamId_t diamid, size_t diamidlen, int add_rr, struct dictionary * dict ) |
0 | 1310 { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1311 TRACE_ENTRY( "%p %p %zd %d %p", msg, diamid, diamidlen, add_rr, dict); |
0 | 1312 |
1313 /* Check we received a valid message */ | |
656 | 1314 CHECK_PARAMS( CHECK_MSG(msg) && ( (! add_rr) || dict ) ); |
0 | 1315 |
1316 /* Cleanup any previous source */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1317 free(msg->msg_src_id); msg->msg_src_id = NULL; msg->msg_src_id_len = 0; |
0 | 1318 |
1319 /* If the request is to cleanup the source, we are done */ | |
1320 if (diamid == NULL) { | |
1321 return 0; | |
1322 } | |
1323 | |
1324 /* Otherwise save the new informations */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1325 CHECK_MALLOC( msg->msg_src_id = os0dup(diamid, diamidlen) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1326 msg->msg_src_id_len = diamidlen; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1327 |
0 | 1328 |
1329 if (add_rr) { | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1330 struct dict_object *avp_rr_model = NULL; |
0 | 1331 avp_code_t code = AC_ROUTE_RECORD; |
1332 struct avp *avp; | |
1333 union avp_value val; | |
1334 | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1335 /* Lock the cached values */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1336 CHECK_POSIX( pthread_mutex_lock(&cached_avp_rr_lock) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1337 if (cached_avp_rr_dict == dict) { |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1338 avp_rr_model = cached_avp_rr_model; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1339 } |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1340 CHECK_POSIX( pthread_mutex_unlock(&cached_avp_rr_lock) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1341 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1342 /* If it was not cached */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1343 if (!avp_rr_model) { |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1344 /* Find the model for Route-Record in the dictionary */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1345 CHECK_FCT( fd_dict_search ( dict, DICT_AVP, AVP_BY_CODE, &code, &avp_rr_model, ENOENT) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1346 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1347 /* Now cache this result */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1348 CHECK_POSIX( pthread_mutex_lock(&cached_avp_rr_lock) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1349 cached_avp_rr_dict = dict; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1350 cached_avp_rr_model = avp_rr_model; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1351 CHECK_POSIX( pthread_mutex_unlock(&cached_avp_rr_lock) ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1352 } |
0 | 1353 |
1354 /* Create the AVP with this model */ | |
1355 CHECK_FCT( fd_msg_avp_new ( avp_rr_model, 0, &avp ) ); | |
1356 | |
1357 /* Set the AVP value with the diameter id */ | |
1358 memset(&val, 0, sizeof(val)); | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1359 val.os.data = (uint8_t *)diamid; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1360 val.os.len = diamidlen; |
0 | 1361 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); |
1362 | |
1363 /* Add the AVP in the message */ | |
1364 CHECK_FCT( fd_msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) ); | |
1365 } | |
1366 | |
1367 /* done */ | |
1368 return 0; | |
1369 } | |
1370 | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1371 int fd_msg_source_get( struct msg * msg, DiamId_t* diamid, size_t * diamidlen ) |
0 | 1372 { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1373 TRACE_ENTRY( "%p %p %p", msg, diamid, diamidlen); |
0 | 1374 |
1375 /* Check we received valid parameters */ | |
1376 CHECK_PARAMS( CHECK_MSG(msg) ); | |
1377 CHECK_PARAMS( diamid ); | |
1378 | |
1379 /* Copy the informations */ | |
1380 *diamid = msg->msg_src_id; | |
1381 | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1382 if (diamidlen) |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1383 *diamidlen = msg->msg_src_id_len; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
1384 |
0 | 1385 /* done */ |
1386 return 0; | |
1387 } | |
1388 | |
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:
920
diff
changeset
|
1389 /* Associate a session with a message, use only when the session was just created */ |
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:
920
diff
changeset
|
1390 int fd_msg_sess_set(struct msg * msg, struct session * session) |
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:
920
diff
changeset
|
1391 { |
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:
920
diff
changeset
|
1392 TRACE_ENTRY("%p %p", msg, session); |
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:
920
diff
changeset
|
1393 |
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:
920
diff
changeset
|
1394 /* Check we received valid parameters */ |
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:
920
diff
changeset
|
1395 CHECK_PARAMS( CHECK_MSG(msg) ); |
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:
920
diff
changeset
|
1396 CHECK_PARAMS( session ); |
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:
920
diff
changeset
|
1397 CHECK_PARAMS( msg->msg_sess == NULL ); |
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:
920
diff
changeset
|
1398 |
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:
920
diff
changeset
|
1399 msg->msg_sess = session; |
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:
920
diff
changeset
|
1400 return 0; |
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:
920
diff
changeset
|
1401 } |
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:
920
diff
changeset
|
1402 |
895
fbf77629cb7b
Added received and sent timestamps in the messages; added logs on emission and reception
Sebastien Decugis <sdecugis@freediameter.net>
parents:
894
diff
changeset
|
1403 |
85
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1404 /* Retrieve the session of the message */ |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1405 int fd_msg_sess_get(struct dictionary * dict, struct msg * msg, struct session ** session, int * new) |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1406 { |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1407 struct avp * avp; |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1408 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1409 TRACE_ENTRY("%p %p %p", msg, session, new); |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1410 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1411 /* Check we received valid parameters */ |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1412 CHECK_PARAMS( CHECK_MSG(msg) ); |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1413 CHECK_PARAMS( session ); |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1414 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1415 /* If we already resolved the session, just send it back */ |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1416 if (msg->msg_sess) { |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1417 *session = msg->msg_sess; |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1418 if (new) |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1419 *new = 0; |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1420 return 0; |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1421 } |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1422 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1423 /* OK, we have to search for Session-Id AVP -- it is usually the first AVP, but let's be permissive here */ |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1424 /* -- note: we accept messages that have not yet been dictionary parsed... */ |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1425 CHECK_FCT( fd_msg_browse(msg, MSG_BRW_FIRST_CHILD, &avp, NULL) ); |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1426 while (avp) { |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1427 if ( (avp->avp_public.avp_code == AC_SESSION_ID) |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1428 && (avp->avp_public.avp_vendor == 0) ) |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1429 break; |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1430 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1431 /* Otherwise move to next AVP in the message */ |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1432 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) ); |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1433 } |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1434 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1435 if (!avp) { |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1436 TRACE_DEBUG(FULL, "No Session-Id AVP found in message %p", msg); |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1437 *session = NULL; |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1438 return 0; |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1439 } |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1440 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1441 if (!avp->avp_model) { |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
1442 CHECK_FCT( fd_msg_parse_dict ( avp, dict, NULL ) ); |
85
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1443 } |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1444 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1445 ASSERT( avp->avp_public.avp_value ); |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1446 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1447 /* Resolve the session and we are done */ |
919
b1776283d69e
Do not kill framework when a message with 0b session-id is dispatched
Sebastien Decugis <sdecugis@freediameter.net>
parents:
916
diff
changeset
|
1448 if (avp->avp_public.avp_value->os.len > 0) { |
b1776283d69e
Do not kill framework when a message with 0b session-id is dispatched
Sebastien Decugis <sdecugis@freediameter.net>
parents:
916
diff
changeset
|
1449 CHECK_FCT( fd_sess_fromsid_msg ( avp->avp_public.avp_value->os.data, avp->avp_public.avp_value->os.len, &msg->msg_sess, new) ); |
b1776283d69e
Do not kill framework when a message with 0b session-id is dispatched
Sebastien Decugis <sdecugis@freediameter.net>
parents:
916
diff
changeset
|
1450 *session = msg->msg_sess; |
b1776283d69e
Do not kill framework when a message with 0b session-id is dispatched
Sebastien Decugis <sdecugis@freediameter.net>
parents:
916
diff
changeset
|
1451 } else { |
b1776283d69e
Do not kill framework when a message with 0b session-id is dispatched
Sebastien Decugis <sdecugis@freediameter.net>
parents:
916
diff
changeset
|
1452 TRACE_DEBUG(FULL, "Session-Id AVP with 0-byte length found in message %p", msg); |
b1776283d69e
Do not kill framework when a message with 0b session-id is dispatched
Sebastien Decugis <sdecugis@freediameter.net>
parents:
916
diff
changeset
|
1453 *session = NULL; |
b1776283d69e
Do not kill framework when a message with 0b session-id is dispatched
Sebastien Decugis <sdecugis@freediameter.net>
parents:
916
diff
changeset
|
1454 } |
85
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1455 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1456 return 0; |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1457 } |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1458 |
e5fcd672caff
Added new function to retrieve messages sessions easily
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
83
diff
changeset
|
1459 |
0 | 1460 /******************* End-to-end counter *********************/ |
686
f83d9878bf66
Fixed in case of termination of several modules (before initialization completed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
658
diff
changeset
|
1461 static uint32_t fd_eteid; |
f83d9878bf66
Fixed in case of termination of several modules (before initialization completed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
658
diff
changeset
|
1462 static pthread_mutex_t fd_eteid_lck = PTHREAD_MUTEX_INITIALIZER; |
0 | 1463 |
1464 void fd_msg_eteid_init(void) | |
1465 { | |
1466 fd_eteid = ((uint32_t)time(NULL) << 20) | ((uint32_t)lrand48() & ( (1 << 20) - 1 )); | |
1467 } | |
1468 | |
1469 uint32_t fd_msg_eteid_get ( void ) | |
1470 { | |
1471 uint32_t ret; | |
1472 | |
1473 CHECK_POSIX_DO( pthread_mutex_lock(&fd_eteid_lck), /* continue */ ); | |
1474 | |
1475 ret = fd_eteid ++; | |
1476 | |
1477 CHECK_POSIX_DO( pthread_mutex_unlock(&fd_eteid_lck), /* continue */ ); | |
1478 | |
1479 return ret; | |
1480 } | |
1481 | |
1482 /***************************************************************************************************************/ | |
1483 /* Manage AVPs values */ | |
1484 | |
1485 /* Set the value of an AVP */ | |
1486 int fd_msg_avp_setvalue ( struct avp *avp, union avp_value *value ) | |
1487 { | |
1488 enum dict_avp_basetype type = -1; | |
1489 | |
1490 TRACE_ENTRY("%p %p", avp, value); | |
1491 | |
1492 /* Check parameter */ | |
1493 CHECK_PARAMS( CHECK_AVP(avp) && avp->avp_model ); | |
1494 | |
1495 /* Retrieve information from the AVP model */ | |
1496 { | |
1497 enum dict_object_type dicttype; | |
1498 struct dict_avp_data dictdata; | |
1499 | |
1500 CHECK_PARAMS( (fd_dict_gettype(avp->avp_model, &dicttype) == 0) && (dicttype == DICT_AVP) ); | |
1501 CHECK_FCT( fd_dict_getval(avp->avp_model, &dictdata) ); | |
1502 type = dictdata.avp_basetype; | |
1503 CHECK_PARAMS( type != AVP_TYPE_GROUPED ); | |
1504 } | |
1505 | |
1506 /* First, clean any previous value */ | |
1507 if (avp->avp_mustfreeos != 0) { | |
1508 free(avp->avp_storage.os.data); | |
1509 avp->avp_mustfreeos = 0; | |
1510 } | |
1511 | |
1512 memset(&avp->avp_storage, 0, sizeof(union avp_value)); | |
1513 | |
1514 /* If the request was to delete a value: */ | |
1515 if (!value) { | |
1516 avp->avp_public.avp_value = NULL; | |
1517 return 0; | |
1518 } | |
1519 | |
1520 /* Now we have to set the value */ | |
1521 memcpy(&avp->avp_storage, value, sizeof(union avp_value)); | |
1522 | |
730 | 1523 /* Duplicate an octetstring if needed. */ |
387
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
1524 if (type == AVP_TYPE_OCTETSTRING) { |
753
71833fa5e35f
allow applications to create empty AVP also
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
752
diff
changeset
|
1525 CHECK_MALLOC( avp->avp_storage.os.data = os0dup(value->os.data, value->os.len) ); |
71833fa5e35f
allow applications to create empty AVP also
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
752
diff
changeset
|
1526 avp->avp_mustfreeos = 1; |
0 | 1527 } |
1528 | |
1529 /* Set the data pointer of the public part */ | |
1530 avp->avp_public.avp_value = &avp->avp_storage; | |
1531 | |
1532 return 0; | |
1533 } | |
1534 | |
1535 /* Set the value of an AVP, using formatted data */ | |
1536 int fd_msg_avp_value_encode ( void *data, struct avp *avp ) | |
1537 { | |
1538 enum dict_avp_basetype type = -1; | |
1539 struct dict_type_data type_data; | |
1540 | |
1541 TRACE_ENTRY("%p %p", data, avp); | |
1542 | |
1543 /* Check parameter */ | |
1544 CHECK_PARAMS( CHECK_AVP(avp) && avp->avp_model ); | |
1545 | |
1546 /* Retrieve information from the AVP model and it's parent type */ | |
1547 { | |
1548 enum dict_object_type dicttype; | |
1549 struct dict_avp_data dictdata; | |
1550 struct dictionary * dict; | |
1551 struct dict_object * parenttype = NULL; | |
1552 | |
1553 /* First check the base type of the AVP */ | |
1554 CHECK_PARAMS( (fd_dict_gettype(avp->avp_model, &dicttype) == 0) && (dicttype == DICT_AVP) ); | |
1555 CHECK_FCT( fd_dict_getval(avp->avp_model, &dictdata) ); | |
1556 type = dictdata.avp_basetype; | |
1557 CHECK_PARAMS( type != AVP_TYPE_GROUPED ); | |
1558 | |
1559 /* Then retrieve information about the parent's type (= derived type) */ | |
1560 CHECK_FCT( fd_dict_getdict( avp->avp_model, &dict ) ); | |
1561 CHECK_FCT( fd_dict_search( dict, DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &parenttype, EINVAL) ); | |
1562 CHECK_FCT( fd_dict_getval(parenttype, &type_data) ); | |
1563 if (type_data.type_encode == NULL) { | |
1564 TRACE_DEBUG(INFO, "This AVP type does not provide a callback to encode formatted data. ENOTSUP."); | |
1565 return ENOTSUP; | |
1566 } | |
1567 } | |
1568 | |
1569 /* Ok, now we can encode the value */ | |
1570 | |
1571 /* First, clean any previous value */ | |
1572 if (avp->avp_mustfreeos != 0) { | |
1573 free(avp->avp_storage.os.data); | |
1574 avp->avp_mustfreeos = 0; | |
1575 } | |
1576 avp->avp_public.avp_value = NULL; | |
1577 memset(&avp->avp_storage, 0, sizeof(union avp_value)); | |
1578 | |
1579 /* Now call the type's callback to encode the data */ | |
1580 CHECK_FCT( (*type_data.type_encode)(data, &avp->avp_storage) ); | |
1581 | |
1582 /* If an octetstring has been allocated, let's mark it to be freed */ | |
1583 if (type == AVP_TYPE_OCTETSTRING) | |
1584 avp->avp_mustfreeos = 1; | |
1585 | |
1586 /* Set the data pointer of the public part */ | |
1587 avp->avp_public.avp_value = &avp->avp_storage; | |
1588 | |
1589 return 0; | |
1590 } | |
1591 | |
1592 /* Interpret the value of an AVP into formatted data */ | |
1593 int fd_msg_avp_value_interpret ( struct avp *avp, void *data ) | |
1594 { | |
1595 struct dict_type_data type_data; | |
1596 | |
1597 TRACE_ENTRY("%p %p", avp, data); | |
1598 | |
1599 /* Check parameter */ | |
1600 CHECK_PARAMS( CHECK_AVP(avp) && avp->avp_model && avp->avp_public.avp_value ); | |
1601 | |
1602 /* Retrieve information about the AVP parent type */ | |
1603 { | |
1604 struct dictionary * dict; | |
1605 struct dict_object * parenttype = NULL; | |
1606 | |
1607 CHECK_FCT( fd_dict_getdict( avp->avp_model, &dict ) ); | |
1608 CHECK_FCT( fd_dict_search( dict, DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &parenttype, EINVAL) ); | |
1609 CHECK_FCT( fd_dict_getval(parenttype, &type_data) ); | |
1610 if (type_data.type_interpret == NULL) { | |
1611 TRACE_DEBUG(INFO, "This AVP type does not provide a callback to interpret value in formatted data. ENOTSUP."); | |
1612 return ENOTSUP; | |
1613 } | |
1614 } | |
1615 | |
1616 /* Ok, now we can interpret the value */ | |
1617 | |
1618 CHECK_FCT( (*type_data.type_interpret)(avp->avp_public.avp_value, data) ); | |
1619 | |
1620 return 0; | |
1621 } | |
1622 | |
1623 /***************************************************************************************************************/ | |
1624 /* Creating a buffer from memory objects (bufferize a struct msg) */ | |
1625 | |
1626 /* Following macros are used to store 32 and 64 bit fields into a buffer in network byte order */ | |
1627 #define PUT_in_buf_32( _u32data, _bufptr ) { \ | |
1628 *(uint32_t *)(_bufptr) = htonl((uint32_t)(_u32data)); \ | |
1629 } | |
791
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
1630 |
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
1631 /* The location is not on 64b boundary, so we split the writing in two operations to avoid sigbus */ |
0 | 1632 #define PUT_in_buf_64( _u64data, _bufptr ) { \ |
791
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
1633 uint64_t __v = htonll((uint64_t)(_u64data)); \ |
792
0f566e550813
improved the previous fix... not sure it was correct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
791
diff
changeset
|
1634 memcpy(_bufptr, &__v, sizeof(__v)); \ |
0 | 1635 } |
1636 | |
1637 /* Write a message header in the buffer */ | |
1638 static int bufferize_msg(unsigned char * buffer, size_t buflen, size_t * offset, struct msg * msg) | |
1639 { | |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1640 TRACE_ENTRY("%p %zd %p %p", buffer, buflen, offset, msg); |
0 | 1641 |
1642 if ((buflen - *offset) < GETMSGHDRSZ()) | |
1643 return ENOSPC; | |
1644 | |
1645 if (*offset & 0x3) | |
1646 return EFAULT; /* We are supposed to start on 32 bit boundaries */ | |
1647 | |
1648 PUT_in_buf_32(msg->msg_public.msg_length, buffer + *offset); | |
1649 buffer[*offset] = msg->msg_public.msg_version; | |
1650 *offset += 4; | |
1651 | |
1652 PUT_in_buf_32(msg->msg_public.msg_code, buffer + *offset); | |
1653 buffer[*offset] = msg->msg_public.msg_flags; | |
1654 *offset += 4; | |
1655 | |
1656 PUT_in_buf_32(msg->msg_public.msg_appl, buffer + *offset); | |
1657 *offset += 4; | |
1658 | |
1659 PUT_in_buf_32(msg->msg_public.msg_hbhid, buffer + *offset); | |
1660 *offset += 4; | |
1661 | |
1662 PUT_in_buf_32(msg->msg_public.msg_eteid, buffer + *offset); | |
1663 *offset += 4; | |
1664 | |
1665 return 0; | |
1666 } | |
1667 | |
1668 static int bufferize_chain(unsigned char * buffer, size_t buflen, size_t * offset, struct fd_list * list); | |
1669 | |
1670 /* Write an AVP in the buffer */ | |
1671 static int bufferize_avp(unsigned char * buffer, size_t buflen, size_t * offset, struct avp * avp) | |
1672 { | |
1673 struct dict_avp_data dictdata; | |
1674 | |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1675 TRACE_ENTRY("%p %zd %p %p", buffer, buflen, offset, avp); |
0 | 1676 |
1677 if ((buflen - *offset) < avp->avp_public.avp_len) | |
1678 return ENOSPC; | |
1679 | |
1680 /* Write the header */ | |
1681 PUT_in_buf_32(avp->avp_public.avp_code, buffer + *offset); | |
1682 *offset += 4; | |
1683 | |
1684 PUT_in_buf_32(avp->avp_public.avp_len, buffer + *offset); | |
1685 buffer[*offset] = avp->avp_public.avp_flags; | |
1686 *offset += 4; | |
1687 | |
1688 if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) { | |
1689 PUT_in_buf_32(avp->avp_public.avp_vendor, buffer + *offset); | |
1690 *offset += 4; | |
1691 } | |
1692 | |
1693 /* Then we must write the AVP value */ | |
1694 | |
1695 if (avp->avp_model == NULL) { | |
1696 /* In the case where we don't know the type of AVP, just copy the raw data or source */ | |
1697 CHECK_PARAMS( avp->avp_source || avp->avp_rawdata ); | |
1698 | |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
1699 if ( avp->avp_rawdata != NULL ) { |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
1700 /* the content was stored in rawdata */ |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
1701 memcpy(&buffer[*offset], avp->avp_rawdata, avp->avp_rawlen); |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
1702 *offset += PAD4(avp->avp_rawlen); |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
1703 } else { |
0 | 1704 /* the message was not parsed completely */ |
1705 size_t datalen = avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags); | |
1706 memcpy(&buffer[*offset], avp->avp_source, datalen); | |
1707 *offset += PAD4(datalen); | |
1708 } | |
1709 | |
1710 } else { | |
1711 /* The AVP is defined in the dictionary */ | |
1712 CHECK_FCT( fd_dict_getval(avp->avp_model, &dictdata) ); | |
1713 | |
1714 CHECK_PARAMS( ( dictdata.avp_basetype == AVP_TYPE_GROUPED ) || avp->avp_public.avp_value ); | |
1715 | |
1716 switch (dictdata.avp_basetype) { | |
1717 case AVP_TYPE_GROUPED: | |
1718 return bufferize_chain(buffer, buflen, offset, &avp->avp_chain.children); | |
1719 | |
1720 case AVP_TYPE_OCTETSTRING: | |
387
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
1721 if (avp->avp_public.avp_value->os.len) |
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
1722 memcpy(&buffer[*offset], avp->avp_public.avp_value->os.data, avp->avp_public.avp_value->os.len); |
0 | 1723 *offset += PAD4(avp->avp_public.avp_value->os.len); |
1724 break; | |
1725 | |
1726 case AVP_TYPE_INTEGER32: | |
1727 PUT_in_buf_32(avp->avp_public.avp_value->i32, buffer + *offset); | |
1728 *offset += 4; | |
1729 break; | |
1730 | |
1731 case AVP_TYPE_INTEGER64: | |
1732 PUT_in_buf_64(avp->avp_public.avp_value->i64, buffer + *offset); | |
1733 *offset += 8; | |
1734 break; | |
1735 | |
1736 case AVP_TYPE_UNSIGNED32: | |
1737 PUT_in_buf_32(avp->avp_public.avp_value->u32, buffer + *offset); | |
1738 *offset += 4; | |
1739 break; | |
1740 | |
1741 case AVP_TYPE_UNSIGNED64: | |
1742 PUT_in_buf_64(avp->avp_public.avp_value->u64, buffer + *offset); | |
1743 *offset += 8; | |
1744 break; | |
1745 | |
1746 case AVP_TYPE_FLOAT32: | |
1747 /* We read the f32 as "u32" here to avoid casting to uint make decimals go away. | |
1748 The alternative would be something like "*(uint32_t *)(& f32)" but | |
1749 then the compiler complains about strict-aliasing rules. */ | |
1750 PUT_in_buf_32(avp->avp_public.avp_value->u32, buffer + *offset); | |
1751 *offset += 4; | |
1752 break; | |
1753 | |
1754 case AVP_TYPE_FLOAT64: | |
1755 /* Same remark as previously */ | |
1756 PUT_in_buf_64(avp->avp_public.avp_value->u64, buffer + *offset); | |
1757 *offset += 8; | |
1758 break; | |
1759 | |
1760 default: | |
1761 ASSERT(0); | |
1762 } | |
1763 } | |
1764 return 0; | |
1765 } | |
1766 | |
1767 /* Write a chain of AVPs in the buffer */ | |
1768 static int bufferize_chain(unsigned char * buffer, size_t buflen, size_t * offset, struct fd_list * list) | |
1769 { | |
1770 struct fd_list * avpch; | |
1771 | |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1772 TRACE_ENTRY("%p %zd %p %p", buffer, buflen, offset, list); |
0 | 1773 |
1774 for (avpch = list->next; avpch != list; avpch = avpch->next) { | |
1775 /* Bufferize the AVP */ | |
1776 CHECK_FCT( bufferize_avp(buffer, buflen, offset, _A(avpch->o)) ); | |
1777 } | |
1778 return 0; | |
1779 } | |
1780 | |
1781 /* Create the message buffer, in network-byte order. We browse the tree twice, this could be probably improved if needed */ | |
1782 int fd_msg_bufferize ( struct msg * msg, unsigned char ** buffer, size_t * len ) | |
1783 { | |
1784 int ret = 0; | |
1785 unsigned char * buf = NULL; | |
1786 size_t offset = 0; | |
1787 | |
1788 TRACE_ENTRY("%p %p %p", msg, buffer, len); | |
1789 | |
1790 /* Check the parameters */ | |
1791 CHECK_PARAMS( buffer && CHECK_MSG(msg) ); | |
1792 | |
1793 /* Update the length. This also checks that all AVP have their values set */ | |
1794 CHECK_FCT( fd_msg_update_length(msg) ); | |
1795 | |
1796 /* Now allocate a buffer to store the message */ | |
1797 CHECK_MALLOC( buf = malloc(msg->msg_public.msg_length) ); | |
1798 | |
1799 /* Clear the memory, so that the padding is always 0 (should not matter) */ | |
1800 memset(buf, 0, msg->msg_public.msg_length); | |
1801 | |
1802 /* Write the message header in the buffer */ | |
1803 CHECK_FCT_DO( ret = bufferize_msg(buf, msg->msg_public.msg_length, &offset, msg), | |
1804 { | |
1805 free(buf); | |
1806 return ret; | |
1807 } ); | |
1808 | |
1809 /* Write the list of AVPs */ | |
1810 CHECK_FCT_DO( ret = bufferize_chain(buf, msg->msg_public.msg_length, &offset, &msg->msg_chain.children), | |
1811 { | |
1812 free(buf); | |
1813 return ret; | |
1814 } ); | |
1815 | |
1816 ASSERT(offset == msg->msg_public.msg_length); /* or the msg_update_length is buggy */ | |
1817 | |
1818 if (len) { | |
1819 *len = offset; | |
1820 } | |
1821 | |
1822 *buffer = buf; | |
1823 return 0; | |
1824 } | |
1825 | |
1826 | |
1827 /***************************************************************************************************************/ | |
1828 /* Parsing buffers and building AVP objects lists (not parsing the AVP values which requires dictionary knowledge) */ | |
1829 | |
1830 /* Parse a buffer containing a supposed list of AVPs */ | |
1831 static int parsebuf_list(unsigned char * buf, size_t buflen, struct fd_list * head) | |
1832 { | |
1833 size_t offset = 0; | |
1834 | |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1835 TRACE_ENTRY("%p %zd %p", buf, buflen, head); |
0 | 1836 |
1837 while (offset < buflen) { | |
1838 struct avp * avp; | |
1839 | |
920
cb439d57d0c5
Fix parsing of incoming AVPs with 0-byte length at the end of the message
Sebastien Decugis <sdecugis@freediameter.net>
parents:
919
diff
changeset
|
1840 if (buflen - offset < AVPHDRSZ_NOVEND) { |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1841 TRACE_DEBUG(INFO, "truncated buffer: remaining only %zd bytes", buflen - offset); |
0 | 1842 return EBADMSG; |
1843 } | |
1844 | |
1845 /* Create a new AVP object */ | |
1846 CHECK_MALLOC( avp = malloc (sizeof(struct avp)) ); | |
1847 | |
1848 init_avp(avp); | |
1849 | |
1850 /* Initialize the header */ | |
1851 avp->avp_public.avp_code = ntohl(*(uint32_t *)(buf + offset)); | |
1852 avp->avp_public.avp_flags = buf[offset + 4]; | |
1853 avp->avp_public.avp_len = ((uint32_t)buf[offset+5]) << 16 | ((uint32_t)buf[offset+6]) << 8 | ((uint32_t)buf[offset+7]) ; | |
1854 | |
1855 offset += 8; | |
1856 | |
1857 if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) { | |
920
cb439d57d0c5
Fix parsing of incoming AVPs with 0-byte length at the end of the message
Sebastien Decugis <sdecugis@freediameter.net>
parents:
919
diff
changeset
|
1858 if (buflen - offset < 4) { |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1859 TRACE_DEBUG(INFO, "truncated buffer: remaining only %zd bytes for vendor and data", buflen - offset); |
0 | 1860 free(avp); |
1861 return EBADMSG; | |
1862 } | |
1863 avp->avp_public.avp_vendor = ntohl(*(uint32_t *)(buf + offset)); | |
1864 offset += 4; | |
1865 } | |
1866 | |
1867 /* Check there is enough remaining data in the buffer */ | |
920
cb439d57d0c5
Fix parsing of incoming AVPs with 0-byte length at the end of the message
Sebastien Decugis <sdecugis@freediameter.net>
parents:
919
diff
changeset
|
1868 if ( (avp->avp_public.avp_len > GETAVPHDRSZ(avp->avp_public.avp_flags)) |
cb439d57d0c5
Fix parsing of incoming AVPs with 0-byte length at the end of the message
Sebastien Decugis <sdecugis@freediameter.net>
parents:
919
diff
changeset
|
1869 && (buflen - offset < avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags))) { |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1870 TRACE_DEBUG(INFO, "truncated buffer: remaining only %zd bytes for data, and avp data size is %d", |
0 | 1871 buflen - offset, |
1872 avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags)); | |
1873 free(avp); | |
1874 return EBADMSG; | |
1875 } | |
1876 | |
1877 /* buf[offset] is now the beginning of the data */ | |
1878 avp->avp_source = &buf[offset]; | |
1879 | |
1880 /* Now eat the data and eventual padding */ | |
1881 offset += PAD4(avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags)); | |
1882 | |
1883 /* And insert this avp in the list, at the end */ | |
1884 fd_list_insert_before( head, &avp->avp_chain.chaining ); | |
1885 } | |
1886 | |
1887 return 0; | |
1888 } | |
1889 | |
1890 /* Create a message object from a buffer. Dictionary objects are not resolved, AVP contents are not interpreted, buffer is saved in msg */ | |
1891 int fd_msg_parse_buffer ( unsigned char ** buffer, size_t buflen, struct msg ** msg ) | |
1892 { | |
1893 struct msg * new = NULL; | |
1894 int ret = 0; | |
1895 uint32_t msglen = 0; | |
1896 unsigned char * buf; | |
1897 | |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1898 TRACE_ENTRY("%p %zd %p", buffer, buflen, msg); |
0 | 1899 |
1900 CHECK_PARAMS( buffer && *buffer && msg && (buflen >= GETMSGHDRSZ()) ); | |
1901 buf = *buffer; | |
1902 *buffer = NULL; | |
1903 | |
1904 if ( buf[0] != DIAMETER_VERSION) { | |
1905 TRACE_DEBUG(INFO, "Invalid version in message: %d (supported: %d)", buf[0], DIAMETER_VERSION); | |
1906 free(buf); | |
1907 return EBADMSG; | |
1908 } | |
1909 | |
1910 msglen = ntohl(*(uint32_t *)buf) & 0x00ffffff; | |
1911 if ( buflen < msglen ) { | |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1014
diff
changeset
|
1912 TRACE_DEBUG(INFO, "Truncated message (%zd / %d)", buflen, msglen ); |
0 | 1913 free(buf); |
1914 return EBADMSG; | |
1915 } | |
1916 | |
1917 /* Create a new object */ | |
1918 CHECK_MALLOC_DO( new = malloc (sizeof(struct msg)), { free(buf); return ENOMEM; } ); | |
1919 | |
1920 /* Initialize the fields */ | |
1921 init_msg(new); | |
1922 | |
1923 /* Now read from the buffer */ | |
1924 new->msg_public.msg_version = buf[0]; | |
1925 new->msg_public.msg_length = msglen; | |
1926 | |
1927 new->msg_public.msg_flags = buf[4]; | |
1928 new->msg_public.msg_code = ntohl(*(uint32_t *)(buf+4)) & 0x00ffffff; | |
1929 | |
1930 new->msg_public.msg_appl = ntohl(*(uint32_t *)(buf+8)); | |
1931 new->msg_public.msg_hbhid = ntohl(*(uint32_t *)(buf+12)); | |
1932 new->msg_public.msg_eteid = ntohl(*(uint32_t *)(buf+16)); | |
1933 | |
1934 new->msg_rawbuffer = buf; | |
1935 | |
1936 /* Parse the AVP list */ | |
1937 CHECK_FCT_DO( ret = parsebuf_list(buf + GETMSGHDRSZ(), buflen - GETMSGHDRSZ(), &new->msg_chain.children), { destroy_tree(_C(new)); return ret; } ); | |
1938 | |
1939 *msg = new; | |
1940 return 0; | |
1941 } | |
1942 | |
1943 | |
1944 /***************************************************************************************************************/ | |
1945 /* Parsing messages and AVP with dictionary information */ | |
1946 | |
1947 /* Resolve dictionary objects of the cmd and avp instances, from their headers. | |
1948 * When the model is found, the data is interpreted from the avp_source buffer and copied to avp_storage. | |
1949 * When the model is not found, the data is copied as rawdata and saved (in case we FW the message). | |
1950 * Therefore, after this function has been called, the source buffer can be freed. | |
1951 * For command, if the dictionary model is not found, an error is returned. | |
1952 */ | |
1953 | |
889
4a299daed8b2
Add information about parsing errors
Sebastien Decugis <sdecugis@freediameter.net>
parents:
871
diff
changeset
|
1954 static char error_message[256]; |
4a299daed8b2
Add information about parsing errors
Sebastien Decugis <sdecugis@freediameter.net>
parents:
871
diff
changeset
|
1955 |
0 | 1956 /* Process an AVP. If we are not in recheck, the avp_source must be set. */ |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
1957 static int parsedict_do_avp(struct dictionary * dict, struct avp * avp, int mandatory, struct fd_pei *error_info) |
0 | 1958 { |
1959 struct dict_avp_data dictdata; | |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
1960 uint8_t * source; |
0 | 1961 |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
1962 TRACE_ENTRY("%p %p %d %p", dict, avp, mandatory, error_info); |
0 | 1963 |
1964 /* First check we received an AVP as input */ | |
1965 CHECK_PARAMS( CHECK_AVP(avp) ); | |
1966 | |
1967 if (avp->avp_model != NULL) { | |
1968 /* the model has already been resolved. we do check it is still valid */ | |
1969 | |
1970 CHECK_FCT( fd_dict_getval(avp->avp_model, &dictdata) ); | |
1971 | |
1972 if ( avp->avp_public.avp_code == dictdata.avp_code ) { | |
1973 /* Ok then just process the children if any */ | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
1974 return parsedict_do_chain(dict, &avp->avp_chain.children, mandatory && (avp->avp_public.avp_flags & AVP_FLAG_MANDATORY), error_info); |
0 | 1975 } else { |
1976 /* We just erase the old model */ | |
1977 avp->avp_model = NULL; | |
1978 } | |
1979 } | |
1980 | |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1981 /* Check if we already searched for this model without success */ |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1982 if ((avp->avp_model_not_found.mnf_code != avp->avp_public.avp_code) |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1983 || (avp->avp_model_not_found.mnf_vendor != avp->avp_public.avp_vendor)) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1984 |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1985 /* Now try and resolve the model from the avp code and vendor */ |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1986 if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1987 struct dict_avp_request_ex avpreq; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1988 memset(&avpreq, 0, sizeof(avpreq)); |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1989 avpreq.avp_vendor.vendor_id = avp->avp_public.avp_vendor; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1990 avpreq.avp_data.avp_code = avp->avp_public.avp_code; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1991 CHECK_FCT( fd_dict_search ( dict, DICT_AVP, AVP_BY_STRUCT, &avpreq, &avp->avp_model, 0)); |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1992 } else { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1993 /* no vendor */ |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1994 CHECK_FCT( fd_dict_search ( dict, DICT_AVP, AVP_BY_CODE, &avp->avp_public.avp_code, &avp->avp_model, 0)); |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1995 } |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1996 |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1997 if (!avp->avp_model) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1998 avp->avp_model_not_found.mnf_code = avp->avp_public.avp_code; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1999 avp->avp_model_not_found.mnf_vendor = avp->avp_public.avp_vendor; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2000 } |
0 | 2001 } |
2002 | |
2003 /* First handle the case where we have not found this AVP in the dictionary */ | |
2004 if (!avp->avp_model) { | |
2005 | |
2006 if (mandatory && (avp->avp_public.avp_flags & AVP_FLAG_MANDATORY)) { | |
2007 TRACE_DEBUG(INFO, "Unsupported mandatory AVP found:"); | |
804
c5b7d4a2cc77
Log message dumps in one call to the dump function to avoid fragmentation in the log files, as per Zack comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
792
diff
changeset
|
2008 fd_msg_dump_one(INFO, avp); |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2009 if (error_info) { |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2010 error_info->pei_errcode = "DIAMETER_AVP_UNSUPPORTED"; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2011 error_info->pei_avp = avp; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2012 } |
0 | 2013 return ENOTSUP; |
2014 } | |
2015 | |
2016 if (avp->avp_source) { | |
2017 /* we must copy the data from the source to the internal buffer area */ | |
2018 CHECK_PARAMS( !avp->avp_rawdata ); | |
2019 | |
2020 avp->avp_rawlen = avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ); | |
2021 | |
387
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
2022 if (avp->avp_rawlen) { |
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
2023 CHECK_MALLOC( avp->avp_rawdata = malloc(avp->avp_rawlen) ); |
0 | 2024 |
387
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
2025 memcpy(avp->avp_rawdata, avp->avp_source, avp->avp_rawlen); |
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
2026 } |
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
2027 |
0 | 2028 avp->avp_source = NULL; |
2029 | |
2030 TRACE_DEBUG(FULL, "Unsupported optional AVP found, raw source data saved in avp_rawdata."); | |
2031 } | |
2032 | |
2033 return 0; | |
2034 } | |
2035 | |
2036 /* Ok we have resolved the object. Now we need to interpret its content. */ | |
2037 | |
2038 CHECK_FCT( fd_dict_getval(avp->avp_model, &dictdata) ); | |
2039 | |
2040 if (avp->avp_rawdata) { | |
2041 /* This happens if the dictionary object was defined after the first check */ | |
2042 avp->avp_source = avp->avp_rawdata; | |
2043 } | |
2044 | |
2045 /* A bit of sanity here... */ | |
2046 ASSERT(CHECK_BASETYPE(dictdata.avp_basetype)); | |
2047 | |
2048 /* Check the size is valid */ | |
2049 if ((avp_value_sizes[dictdata.avp_basetype] != 0) && | |
2050 (avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ) != avp_value_sizes[dictdata.avp_basetype])) { | |
889
4a299daed8b2
Add information about parsing errors
Sebastien Decugis <sdecugis@freediameter.net>
parents:
871
diff
changeset
|
2051 TRACE_DEBUG(INFO, "The AVP size is not suitable for the type:"); |
4a299daed8b2
Add information about parsing errors
Sebastien Decugis <sdecugis@freediameter.net>
parents:
871
diff
changeset
|
2052 fd_msg_dump_one(INFO, avp); |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2053 if (error_info) { |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2054 error_info->pei_errcode = "DIAMETER_INVALID_AVP_LENGTH"; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2055 error_info->pei_avp = avp; |
889
4a299daed8b2
Add information about parsing errors
Sebastien Decugis <sdecugis@freediameter.net>
parents:
871
diff
changeset
|
2056 snprintf(error_message, sizeof(error_message), "I expected a size of %d for this AVP according to my dictionary", avp_value_sizes[dictdata.avp_basetype]); |
4a299daed8b2
Add information about parsing errors
Sebastien Decugis <sdecugis@freediameter.net>
parents:
871
diff
changeset
|
2057 error_info->pei_message = error_message; |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2058 } |
891
9432ac55823c
Tentative fix for the parse_or_error function
Sebastien Decugis <sdecugis@freediameter.net>
parents:
889
diff
changeset
|
2059 avp->avp_model = NULL; |
0 | 2060 return EBADMSG; |
2061 } | |
2062 | |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2063 source = avp->avp_source; |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2064 avp->avp_source = NULL; |
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2065 |
0 | 2066 /* Now get the value inside */ |
2067 switch (dictdata.avp_basetype) { | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2068 case AVP_TYPE_GROUPED: { |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2069 int ret; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2070 |
0 | 2071 /* This is a grouped AVP, so let's parse the list of AVPs inside */ |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2072 CHECK_FCT_DO( ret = parsebuf_list(source, avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ), &avp->avp_chain.children), |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2073 { |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2074 if ((ret == EBADMSG) && (error_info)) { |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2075 error_info->pei_errcode = "DIAMETER_INVALID_AVP_VALUE"; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2076 error_info->pei_avp = avp; |
889
4a299daed8b2
Add information about parsing errors
Sebastien Decugis <sdecugis@freediameter.net>
parents:
871
diff
changeset
|
2077 snprintf(error_message, sizeof(error_message), "I cannot parse this AVP as a Grouped AVP"); |
4a299daed8b2
Add information about parsing errors
Sebastien Decugis <sdecugis@freediameter.net>
parents:
871
diff
changeset
|
2078 error_info->pei_message = error_message; |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2079 } |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2080 avp->avp_source = source; |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2081 return ret; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2082 } ); |
0 | 2083 |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2084 return parsedict_do_chain(dict, &avp->avp_chain.children, mandatory && (avp->avp_public.avp_flags & AVP_FLAG_MANDATORY), error_info); |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2085 } |
0 | 2086 |
2087 case AVP_TYPE_OCTETSTRING: | |
2088 /* We just have to copy the string into the storage area */ | |
387
743195485eec
Additional fixes for empty octet string AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
2089 CHECK_PARAMS_DO( avp->avp_public.avp_len >= GETAVPHDRSZ( avp->avp_public.avp_flags ), |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2090 { |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2091 if (error_info) { |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2092 error_info->pei_errcode = "DIAMETER_INVALID_AVP_LENGTH"; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2093 error_info->pei_avp = avp; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2094 } |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2095 avp->avp_source = source; |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2096 return EBADMSG; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2097 } ); |
0 | 2098 avp->avp_storage.os.len = avp->avp_public.avp_len - GETAVPHDRSZ( avp->avp_public.avp_flags ); |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2099 CHECK_MALLOC( avp->avp_storage.os.data = os0dup(source, avp->avp_storage.os.len) ); |
752
9e9840ccf059
Attempt to handle more gracefully (invalid) AVPs that contain an empty octetstring
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2100 avp->avp_mustfreeos = 1; |
0 | 2101 break; |
2102 | |
2103 case AVP_TYPE_INTEGER32: | |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2104 avp->avp_storage.i32 = (int32_t)ntohl(*(uint32_t *)source); |
0 | 2105 break; |
2106 | |
2107 case AVP_TYPE_INTEGER64: | |
791
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2108 /* the storage might not be aligned on 64b boundary, so no direct indirection here is possible */ |
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2109 { |
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2110 uint64_t __stor; |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2111 memcpy(&__stor, source, sizeof(__stor)); |
791
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2112 avp->avp_storage.i64 = (int64_t)ntohll(__stor); |
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2113 } |
0 | 2114 break; |
2115 | |
2116 case AVP_TYPE_UNSIGNED32: | |
2117 case AVP_TYPE_FLOAT32: /* For float, we must not cast, or the value is changed. Instead we use implicit cast by changing the member of the union */ | |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2118 avp->avp_storage.u32 = (uint32_t)ntohl(*(uint32_t *)source); |
0 | 2119 break; |
2120 | |
2121 case AVP_TYPE_UNSIGNED64: | |
2122 case AVP_TYPE_FLOAT64: /* same as 32 bits */ | |
791
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2123 { |
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2124 uint64_t __stor; |
1001
d03f7e3805ad
Fix generation of the Proxy-Info AVP in fd_msg_new_answer_from_req
Sebastien Decugis <sdecugis@freediameter.net>
parents:
995
diff
changeset
|
2125 memcpy(&__stor, source, sizeof(__stor)); |
791
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2126 avp->avp_storage.u64 = (uint64_t)ntohll(__stor); |
42fa209a8cc4
Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
765
diff
changeset
|
2127 } |
0 | 2128 break; |
2129 | |
2130 } | |
2131 | |
2132 /* The value is now set, so set the data pointer and return 0 */ | |
2133 avp->avp_public.avp_value = &avp->avp_storage; | |
2134 return 0; | |
2135 } | |
2136 | |
2137 /* Process a list of AVPs */ | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2138 static int parsedict_do_chain(struct dictionary * dict, struct fd_list * head, int mandatory, struct fd_pei *error_info) |
0 | 2139 { |
2140 struct fd_list * avpch; | |
2141 | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2142 TRACE_ENTRY("%p %p %d %p", dict, head, mandatory, error_info); |
0 | 2143 |
2144 /* Sanity check */ | |
2145 ASSERT ( head == head->head ); | |
2146 | |
2147 /* Now process the list */ | |
2148 for (avpch=head->next; avpch != head; avpch = avpch->next) { | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2149 CHECK_FCT( parsedict_do_avp(dict, _A(avpch->o), mandatory, error_info) ); |
0 | 2150 } |
2151 | |
2152 /* Done */ | |
2153 return 0; | |
2154 } | |
2155 | |
2156 /* Process a msg header. */ | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2157 static int parsedict_do_msg(struct dictionary * dict, struct msg * msg, int only_hdr, struct fd_pei *error_info) |
0 | 2158 { |
2159 int ret = 0; | |
2160 | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2161 TRACE_ENTRY("%p %p %d %p", dict, msg, only_hdr, error_info); |
0 | 2162 |
2163 CHECK_PARAMS( CHECK_MSG(msg) ); | |
2164 | |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2165 /* First, check if we already have a model. */ |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2166 if (msg->msg_model != NULL) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2167 /* Check if this model is still valid for the message data */ |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2168 enum dict_object_type dicttype; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2169 struct dict_cmd_data data; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2170 ASSERT(((fd_dict_gettype(msg->msg_model, &dicttype) == 0) && (dicttype == DICT_COMMAND))); |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2171 (void)fd_dict_getval( msg->msg_model, &data); |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2172 if ((data.cmd_code != msg->msg_public.msg_code) |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2173 || ((data.cmd_flag_val & data.cmd_flag_mask) != (msg->msg_public.msg_flags && data.cmd_flag_mask))) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2174 msg->msg_model = NULL; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2175 } else { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2176 goto chain; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2177 } |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2178 } |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2179 |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2180 /* Check if we already searched for this model without success */ |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2181 if ((msg->msg_model_not_found.mnf_code == msg->msg_public.msg_code) |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2182 && (msg->msg_model_not_found.mnf_flags == msg->msg_public.msg_flags)) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2183 goto no_model; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2184 } else { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2185 msg->msg_model_not_found.mnf_code = 0; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2186 } |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2187 |
0 | 2188 /* Look for the model from the header */ |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2189 CHECK_FCT_DO( ret = fd_dict_search ( dict, DICT_COMMAND, |
0 | 2190 (msg->msg_public.msg_flags & CMD_FLAG_REQUEST) ? CMD_BY_CODE_R : CMD_BY_CODE_A, |
2191 &msg->msg_public.msg_code, | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2192 &msg->msg_model, ENOTSUP), |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2193 { |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2194 if (ret == ENOTSUP) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2195 /* update the model not found info */ |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2196 msg->msg_model_not_found.mnf_code = msg->msg_public.msg_code; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2197 msg->msg_model_not_found.mnf_flags = msg->msg_public.msg_flags; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2198 goto no_model; |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2199 } |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2200 return ret; |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2201 } ); |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2202 chain: |
0 | 2203 if (!only_hdr) { |
2204 /* Then process the children */ | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2205 ret = parsedict_do_chain(dict, &msg->msg_chain.children, 1, error_info); |
0 | 2206 |
2207 /* Free the raw buffer if any */ | |
2208 if ((ret == 0) && (msg->msg_rawbuffer != NULL)) { | |
2209 free(msg->msg_rawbuffer); | |
2210 msg->msg_rawbuffer=NULL; | |
2211 } | |
2212 } | |
2213 | |
2214 return ret; | |
1092
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2215 no_model: |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2216 if (error_info) { |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2217 error_info->pei_errcode = "DIAMETER_COMMAND_UNSUPPORTED"; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2218 error_info->pei_protoerr = 1; |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2219 } |
e40374ddfeef
Optimization: do not attempt resolving dictionary objects again when it already failed during message parsing
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
2220 return ENOTSUP; |
0 | 2221 } |
2222 | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2223 int fd_msg_parse_dict ( msg_or_avp * object, struct dictionary * dict, struct fd_pei *error_info ) |
0 | 2224 { |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2225 TRACE_ENTRY("%p %p %p", dict, object, error_info); |
0 | 2226 |
2227 CHECK_PARAMS( VALIDATE_OBJ(object) ); | |
2228 | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2229 if (error_info) |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2230 memset(error_info, 0, sizeof(struct fd_pei)); |
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2231 |
0 | 2232 switch (_C(object)->type) { |
2233 case MSG_MSG: | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2234 return parsedict_do_msg(dict, _M(object), 0, error_info); |
0 | 2235 |
2236 case MSG_AVP: | |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2237 return parsedict_do_avp(dict, _A(object), 0, error_info); |
0 | 2238 |
2239 default: | |
2240 ASSERT(0); | |
2241 } | |
2242 return EINVAL; | |
2243 } | |
2244 | |
2245 /***************************************************************************************************************/ | |
2246 /* Parsing messages and AVP for rules (ABNF) compliance */ | |
2247 | |
2248 /* This function is used to get stats (first occurence position, last occurence position, number of occurences) | |
2249 of AVP instances of a given model in a chain of AVP */ | |
2250 static void parserules_stat_avps( struct dict_object * model_avp, struct fd_list *list, int * count, int * firstpos, int * lastpos) | |
2251 { | |
2252 struct fd_list * li; | |
2253 int curpos = 0; /* The current position in the list */ | |
2254 | |
2255 TRACE_ENTRY("%p %p %p %p %p", model_avp, list, count, firstpos, lastpos); | |
2256 | |
2257 *count = 0; /* number of instances found */ | |
2258 *firstpos = 0; /* position of the first instance */ | |
2259 *lastpos = 0; /* position of the last instance, starting from the end */ | |
2260 | |
2261 for (li = list->next; li != list; li = li->next) { | |
2262 /* Increment the current position counter */ | |
2263 curpos++; | |
2264 | |
2265 /* If we previously saved a "lastpos" information, increment it */ | |
2266 if (*lastpos != 0) | |
2267 (*lastpos)++; | |
2268 | |
2269 /* Check the type of the next AVP. We can compare the references directly, it is safe. */ | |
2270 if (_A(li->o)->avp_model == model_avp) { | |
2271 | |
2272 /* This AVP is of the type we are searching */ | |
2273 (*count)++; | |
2274 | |
2275 /* If we don't have yet a "firstpos", save it */ | |
2276 if (*firstpos == 0) | |
2277 *firstpos = curpos; | |
2278 | |
2279 /* Reset the lastpos */ | |
2280 (*lastpos) = 1; | |
2281 } | |
2282 } | |
2283 } | |
2284 | |
2285 /* We use this structure as parameter for the next function */ | |
2286 struct parserules_data { | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2287 struct fd_list * sentinel; /* Sentinel of the list of children AVP */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2288 struct fd_pei * pei; /* If the rule conflicts, save the error here */ |
0 | 2289 }; |
2290 | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2291 /* Create an empty AVP of a given model (to use in Failed-AVP) */ |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2292 static struct avp * empty_avp(struct dict_object * model_avp) |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2293 { |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2294 struct avp * avp = NULL; |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2295 struct dict_avp_data avp_info; |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2296 union avp_value val; |
400
bb8a4fa301b3
Fix compilation warning
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
387
diff
changeset
|
2297 unsigned char os[1] = { '\0' }; |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2298 |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2299 /* Create an instance */ |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2300 CHECK_FCT_DO( fd_msg_avp_new(model_avp, 0, &avp ), return NULL ); |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2301 |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2302 /* Type of the AVP */ |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2303 CHECK_FCT_DO( fd_dict_getval(model_avp, &avp_info), return NULL ); |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2304 |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2305 /* Prepare the empty value */ |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2306 memset(&val, 0, sizeof(val)); |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2307 switch (avp_info.avp_basetype) { |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2308 case AVP_TYPE_OCTETSTRING: |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2309 val.os.data = os; |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2310 val.os.len = sizeof(os); |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2311 case AVP_TYPE_INTEGER32: |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2312 case AVP_TYPE_INTEGER64: |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2313 case AVP_TYPE_UNSIGNED32: |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2314 case AVP_TYPE_UNSIGNED64: |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2315 case AVP_TYPE_FLOAT32: |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2316 case AVP_TYPE_FLOAT64: |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2317 CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), return NULL ); |
400
bb8a4fa301b3
Fix compilation warning
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
387
diff
changeset
|
2318 case AVP_TYPE_GROUPED: |
bb8a4fa301b3
Fix compilation warning
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
387
diff
changeset
|
2319 /* For AVP_TYPE_GROUPED we don't do anything */ |
bb8a4fa301b3
Fix compilation warning
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
387
diff
changeset
|
2320 break; |
bb8a4fa301b3
Fix compilation warning
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
387
diff
changeset
|
2321 default: |
bb8a4fa301b3
Fix compilation warning
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
387
diff
changeset
|
2322 ASSERT(0); /* not handled */ |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2323 } |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2324 |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2325 return avp; |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2326 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2327 |
0 | 2328 /* Check that a list of AVPs is compliant with a given rule -- will be iterated on the list of rules */ |
2329 static int parserules_check_one_rule(void * data, struct dict_rule_data *rule) | |
2330 { | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2331 int count, first, last, min; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2332 struct parserules_data * pr_data = data; |
280
3019f6220122
Provide more useful debug information for non-ABNF-compliant messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
2333 char * avp_name = "<unresolved name>"; |
0 | 2334 |
2335 TRACE_ENTRY("%p %p", data, rule); | |
2336 | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2337 /* Get statistics of the AVP concerned by this rule in the parent instance */ |
0 | 2338 parserules_stat_avps( rule->rule_avp, pr_data->sentinel, &count, &first, &last); |
2339 | |
280
3019f6220122
Provide more useful debug information for non-ABNF-compliant messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
2340 if (TRACE_BOOL(INFO)) |
0 | 2341 { |
2342 struct dict_avp_data avpdata; | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2343 int ret; |
0 | 2344 ret = fd_dict_getval(rule->rule_avp, &avpdata); |
280
3019f6220122
Provide more useful debug information for non-ABNF-compliant messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
2345 if (ret == 0) |
3019f6220122
Provide more useful debug information for non-ABNF-compliant messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
2346 avp_name = avpdata.avp_name; |
0 | 2347 |
2348 TRACE_DEBUG(ANNOYING, "Checking rule: p:%d(%d) m/M:%2d/%2d. Counted %d (first: %d, last:%d) of AVP '%s'", | |
2349 rule->rule_position, | |
2350 rule->rule_order, | |
2351 rule->rule_min, | |
2352 rule->rule_max, | |
2353 count, | |
2354 first, | |
2355 last, | |
280
3019f6220122
Provide more useful debug information for non-ABNF-compliant messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
2356 avp_name |
0 | 2357 ); |
2358 } | |
2359 | |
2360 /* Now check the rule is not conflicting */ | |
2361 | |
2362 /* Check the "min" value */ | |
2363 if ((min = rule->rule_min) == -1) { | |
2364 if (rule->rule_position == RULE_OPTIONAL) | |
2365 min = 0; | |
2366 else | |
2367 min = 1; | |
2368 } | |
2369 if (count < min) { | |
1062
56bf0377e2ff
Raise "Conflicting rules" to error level since it causes validation
Thomas Klausner <tk@giga.or.at>
parents:
1036
diff
changeset
|
2370 fd_log_error("Conflicting rule: the number of occurences (%d) is < the rule min (%d) for '%s'.", count, min, avp_name); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2371 if (pr_data->pei) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2372 pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2373 pr_data->pei->pei_avp = empty_avp(rule->rule_avp); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2374 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2375 return EBADMSG; |
0 | 2376 } |
2377 | |
2378 /* Check the "max" value */ | |
2379 if ((rule->rule_max != -1) && (count > rule->rule_max)) { | |
1062
56bf0377e2ff
Raise "Conflicting rules" to error level since it causes validation
Thomas Klausner <tk@giga.or.at>
parents:
1036
diff
changeset
|
2380 fd_log_error("Conflicting rule: the number of occurences (%d) is > the rule max (%d) for '%s'.", count, rule->rule_max, avp_name); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2381 if (pr_data->pei) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2382 if (rule->rule_max == 0) |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2383 pr_data->pei->pei_errcode = "DIAMETER_AVP_NOT_ALLOWED"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2384 else |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2385 pr_data->pei->pei_errcode = "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2386 pr_data->pei->pei_avp = empty_avp(rule->rule_avp); /* Well we are supposed to return the (max + 1)th instance of the AVP instead... Pfff... */ TODO("Improve..."); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2387 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2388 return EBADMSG; |
0 | 2389 } |
2390 | |
2391 /* Check the position and order (if relevant) */ | |
2392 switch (rule->rule_position) { | |
2393 case RULE_OPTIONAL: | |
2394 case RULE_REQUIRED: | |
2395 /* No special position constraints */ | |
2396 break; | |
2397 | |
2398 case RULE_FIXED_HEAD: | |
2399 /* Since "0*1<fixed>" is a valid rule specifier, we only reject cases where the AVP appears *after* its fixed position */ | |
2400 if (first > rule->rule_order) { | |
1062
56bf0377e2ff
Raise "Conflicting rules" to error level since it causes validation
Thomas Klausner <tk@giga.or.at>
parents:
1036
diff
changeset
|
2401 fd_log_error("Conflicting rule: the FIXED_HEAD AVP appears first in (%d) position, the rule requires (%d) for '%s'.", first, rule->rule_order, avp_name); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2402 if (pr_data->pei) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2403 pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2404 pr_data->pei->pei_message = "AVP was not in its fixed position"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2405 pr_data->pei->pei_avp = empty_avp(rule->rule_avp); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2406 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2407 return EBADMSG; |
0 | 2408 } |
2409 break; | |
2410 | |
2411 case RULE_FIXED_TAIL: | |
2412 /* Since "0*1<fixed>" is a valid rule specifier, we only reject cases where the AVP appears *before* its fixed position */ | |
2413 if (last > rule->rule_order) { /* We have a ">" here because we count in reverse order (i.e. from the end) */ | |
1062
56bf0377e2ff
Raise "Conflicting rules" to error level since it causes validation
Thomas Klausner <tk@giga.or.at>
parents:
1036
diff
changeset
|
2414 fd_log_error("Conflicting rule: the FIXED_TAIL AVP appears last in (%d) position, the rule requires (%d) for '%s'.", last, rule->rule_order, avp_name); |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2415 if (pr_data->pei) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2416 pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2417 pr_data->pei->pei_message = "AVP was not in its fixed position"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2418 pr_data->pei->pei_avp = empty_avp(rule->rule_avp); |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2419 } |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2420 return EBADMSG; |
0 | 2421 } |
2422 break; | |
2423 | |
2424 default: | |
2425 /* What is this position ??? */ | |
2426 ASSERT(0); | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2427 return ENOTSUP; |
0 | 2428 } |
2429 | |
2430 /* We've checked all the parameters */ | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2431 return 0; |
0 | 2432 } |
2433 | |
2434 /* Check the rules recursively */ | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2435 static int parserules_do ( struct dictionary * dict, msg_or_avp * object, struct fd_pei *error_info, int mandatory) |
0 | 2436 { |
2437 struct parserules_data data; | |
2438 struct dict_object * model = NULL; | |
2439 | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2440 TRACE_ENTRY("%p %p %p %d", dict, object, error_info, mandatory); |
0 | 2441 |
2442 /* object has already been checked and dict-parsed when we are called. */ | |
2443 | |
2444 /* First, handle the cases where there is no model */ | |
2445 { | |
2446 if (CHECK_MSG(object)) { | |
2447 if ( _M(object)->msg_public.msg_flags & CMD_FLAG_ERROR ) { | |
2448 /* The case of error messages: the ABNF is different */ | |
2449 CHECK_FCT( fd_dict_get_error_cmd(dict, &model) ); | |
2450 } else { | |
2451 model = _M(object)->msg_model; | |
2452 } | |
2453 /* Commands MUST be supported in the dictionary */ | |
2454 if (model == NULL) { | |
2455 TRACE_DEBUG(INFO, "Message with no dictionary model. EBADMSG"); | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2456 if (error_info) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2457 error_info->pei_errcode = "DIAMETER_COMMAND_UNSUPPORTED"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2458 error_info->pei_protoerr = 1; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2459 } |
0 | 2460 return EBADMSG; |
2461 } | |
2462 } | |
2463 | |
2464 /* AVP with the 'M' flag must also be recognized in the dictionary -- except inside an optional grouped AVP */ | |
2465 if (CHECK_AVP(object) && ((model = _A(object)->avp_model) == NULL)) { | |
2466 if ( mandatory && (_A(object)->avp_public.avp_flags & AVP_FLAG_MANDATORY)) { | |
2467 /* Return an error in this case */ | |
2468 TRACE_DEBUG(INFO, "Mandatory AVP with no dictionary model. EBADMSG"); | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2469 if (error_info) { |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2470 error_info->pei_errcode = "DIAMETER_AVP_UNSUPPORTED"; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2471 error_info->pei_avp = object; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2472 } |
0 | 2473 return EBADMSG; |
2474 } else { | |
2475 /* We don't know any rule for this object, so assume OK */ | |
2476 TRACE_DEBUG(FULL, "Unknown informational AVP, ignoring..."); | |
2477 return 0; | |
2478 } | |
2479 } | |
2480 } | |
2481 | |
2482 /* At this point we know "model" is set and points to the object's model */ | |
2483 | |
2484 /* If we are an AVP with no children, just return OK */ | |
2485 if (CHECK_AVP(object)) { | |
2486 struct dict_avp_data dictdata; | |
2487 CHECK_FCT( fd_dict_getval(model, &dictdata) ); | |
2488 if (dictdata.avp_basetype != AVP_TYPE_GROUPED) { | |
2489 /* This object has no children and no rules */ | |
2490 return 0; | |
2491 } | |
2492 } | |
2493 | |
2494 /* If this object has children, first check the rules for all its children */ | |
2495 { | |
2496 int is_child_mand = 0; | |
2497 struct fd_list * ch = NULL; | |
2498 if ( CHECK_MSG(object) | |
2499 || (mandatory && (_A(object)->avp_public.avp_flags & AVP_FLAG_MANDATORY)) ) | |
2500 is_child_mand = 1; | |
2501 for (ch = _C(object)->children.next; ch != &_C(object)->children; ch = ch->next) { | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2502 CHECK_FCT( parserules_do ( dict, _C(ch->o), error_info, is_child_mand ) ); |
0 | 2503 } |
2504 } | |
2505 | |
2506 /* Now check all rules of this object */ | |
2507 data.sentinel = &_C(object)->children; | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2508 data.pei = error_info; |
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2509 CHECK_FCT( fd_dict_iterate_rules ( model, &data, parserules_check_one_rule ) ); |
0 | 2510 |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2511 return 0; |
0 | 2512 } |
2513 | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2514 int fd_msg_parse_rules ( msg_or_avp * object, struct dictionary * dict, struct fd_pei *error_info) |
0 | 2515 { |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2516 TRACE_ENTRY("%p %p %p", object, dict, error_info); |
0 | 2517 |
35
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2518 if (error_info) |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2519 memset(error_info, 0, sizeof(struct fd_pei)); |
6486e97f56ae
Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
34
diff
changeset
|
2520 |
0 | 2521 /* Resolve the dictionary objects when missing. This also validates the object. */ |
114
5b3868944e2b
Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
112
diff
changeset
|
2522 CHECK_FCT( fd_msg_parse_dict ( object, dict, error_info ) ); |
0 | 2523 |
2524 /* Call the recursive function */ | |
34
0e2b57789361
Backup for the WE, some warnings remaining
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2525 return parserules_do ( dict, object, error_info, 1 ) ; |
0 | 2526 } |
2527 | |
2528 /***************************************************************************************************************/ | |
2529 | |
2530 /* Compute the lengh of an object and its subtree. */ | |
2531 int fd_msg_update_length ( msg_or_avp * object ) | |
2532 { | |
2533 size_t sz = 0; | |
2534 struct dict_object * model; | |
2535 union { | |
2536 struct dict_cmd_data cmddata; | |
2537 struct dict_avp_data avpdata; | |
2538 } dictdata; | |
2539 | |
2540 TRACE_ENTRY("%p", object); | |
2541 | |
2542 /* Get the model of the object. This also validates the object */ | |
2543 CHECK_FCT( fd_msg_model ( object, &model ) ); | |
2544 | |
2545 /* Get the information of the model */ | |
2546 if (model) { | |
2547 CHECK_FCT( fd_dict_getval(model, &dictdata) ); | |
2548 } else { | |
2549 /* For unknown AVP, just don't change the size */ | |
2550 if (_C(object)->type == MSG_AVP) | |
2551 return 0; | |
2552 } | |
2553 | |
2554 /* Deal with easy cases: AVPs without children */ | |
2555 if ((_C(object)->type == MSG_AVP) && (dictdata.avpdata.avp_basetype != AVP_TYPE_GROUPED)) { | |
2556 /* Sanity check */ | |
2557 ASSERT(FD_IS_LIST_EMPTY(&_A(object)->avp_chain.children)); | |
2558 | |
2559 /* Now check that the data is set in the AVP */ | |
2560 CHECK_PARAMS( _A(object)->avp_public.avp_value ); | |
2561 | |
2562 sz = GETAVPHDRSZ( _A(object)->avp_public.avp_flags ); | |
2563 | |
2564 switch (dictdata.avpdata.avp_basetype) { | |
2565 case AVP_TYPE_OCTETSTRING: | |
2566 sz += _A(object)->avp_public.avp_value->os.len; | |
2567 break; | |
2568 | |
2569 case AVP_TYPE_INTEGER32: | |
2570 case AVP_TYPE_INTEGER64: | |
2571 case AVP_TYPE_UNSIGNED32: | |
2572 case AVP_TYPE_UNSIGNED64: | |
2573 case AVP_TYPE_FLOAT32: | |
2574 case AVP_TYPE_FLOAT64: | |
2575 sz += avp_value_sizes[dictdata.avpdata.avp_basetype]; | |
2576 break; | |
2577 | |
2578 default: | |
2579 /* Something went wrong... */ | |
2580 ASSERT(0); | |
2581 } | |
2582 } | |
2583 else /* message or grouped AVP */ | |
2584 { | |
2585 struct fd_list * ch = NULL; | |
2586 | |
2587 /* First, compute the header size */ | |
2588 if (_C(object)->type == MSG_AVP) { | |
2589 sz = GETAVPHDRSZ( _A(object)->avp_public.avp_flags ); | |
2590 } else { | |
2591 sz = GETMSGHDRSZ( ); | |
2592 } | |
2593 | |
2594 /* Recurse in all children and update the sz information */ | |
2595 for (ch = _C(object)->children.next; ch != &_C(object)->children; ch = ch->next) { | |
2596 CHECK_FCT( fd_msg_update_length ( ch->o ) ); | |
2597 | |
2598 /* Add the padded size to the parent */ | |
2599 sz += PAD4( _A(ch->o)->avp_public.avp_len ); | |
2600 } | |
2601 } | |
2602 | |
2603 /* When we arrive here, the "sz" variable contains the size to write in the object */ | |
2604 if (_C(object)->type == MSG_AVP) | |
2605 _A(object)->avp_public.avp_len = sz; | |
2606 else | |
2607 _M(object)->msg_public.msg_length = sz; | |
2608 | |
2609 return 0; | |
2610 } | |
2611 | |
2612 /***************************************************************************************************************/ | |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2613 /* Macro to check if further callbacks must be called */ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2614 #define TEST_ACTION_STOP() \ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2615 if ((*msg == NULL) || (*action != DISP_ACT_CONT)) \ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2616 goto out; |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2617 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2618 /* Call all dispatch callbacks for a given message */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
704
diff
changeset
|
2619 int fd_msg_dispatch ( struct msg ** msg, struct session * session, enum disp_action *action, char ** error_code) |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2620 { |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2621 struct dictionary * dict; |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2622 struct dict_object * app; |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2623 struct dict_object * cmd; |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2624 struct avp * avp; |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2625 struct fd_list * cb_list; |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2626 int ret = 0, r2; |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2627 |
90
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2628 TRACE_ENTRY("%p %p %p %p", msg, session, action, error_code); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2629 CHECK_PARAMS( msg && CHECK_MSG(*msg) && action); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2630 |
90
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2631 if (error_code) |
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2632 *error_code = NULL; |
132 | 2633 *action = DISP_ACT_CONT; |
90
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2634 |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2635 /* Take the dispatch lock */ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2636 CHECK_FCT( pthread_rwlock_rdlock(&fd_disp_lock) ); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2637 pthread_cleanup_push( fd_cleanup_rwlock, &fd_disp_lock ); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2638 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2639 /* First, call the DISP_HOW_ANY callbacks */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2640 CHECK_FCT_DO( ret = fd_disp_call_cb_int( NULL, msg, NULL, session, action, NULL, NULL, NULL, NULL ), goto out ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2641 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2642 TEST_ACTION_STOP(); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2643 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2644 /* If we don't know the model at this point, we stop cause we cannot get the dictionary. It's invalid: an error should already have been trigged by ANY callbacks */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2645 CHECK_PARAMS_DO(cmd = (*msg)->msg_model, { ret = EINVAL; goto out; } ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2646 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2647 /* Now resolve message application */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2648 CHECK_FCT_DO( ret = fd_dict_getdict( cmd, &dict ), goto out ); |
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2649 CHECK_FCT_DO( ret = fd_dict_search( dict, DICT_APPLICATION, APPLICATION_BY_ID, &(*msg)->msg_public.msg_appl, &app, 0 ), goto out ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2650 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2651 if (app == NULL) { |
90
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2652 if ((*msg)->msg_public.msg_flags & CMD_FLAG_REQUEST) { |
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2653 if (error_code) |
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2654 *error_code = "DIAMETER_APPLICATION_UNSUPPORTED"; |
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2655 *action = DISP_ACT_ERROR; |
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2656 } else { |
1078
74bba7975864
Cleanup the timing data and fd_msg_log feature that will be replaced by the new hooks mechanism. Kept the calls to fd_msg_log in comments to find the locations easily. WORK IN PROGRESS.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1062
diff
changeset
|
2657 //fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Internal error: Received this answer to a local query with an unsupported application %d", (*msg)->msg_public.msg_appl); |
90
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2658 fd_msg_free(*msg); |
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2659 *msg = NULL; |
2c9444152e4b
Added the dispatch thread code
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
85
diff
changeset
|
2660 } |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2661 goto out; |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2662 } |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2663 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2664 /* So start browsing the message */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2665 CHECK_FCT_DO( ret = fd_msg_browse( *msg, MSG_BRW_FIRST_CHILD, &avp, NULL ), goto out ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2666 while (avp != NULL) { |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2667 /* For unknown AVP, we don't have a callback registered, so just skip */ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2668 if (avp->avp_model) { |
330
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2669 struct dict_object * enumval = NULL; |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2670 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2671 /* Get the list of callback for this AVP */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2672 CHECK_FCT_DO( ret = fd_dict_disp_cb(DICT_AVP, avp->avp_model, &cb_list), goto out ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2673 |
330
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2674 /* We search enumerated values only in case of non-grouped AVP */ |
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2675 if ( avp->avp_public.avp_value ) { |
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2676 struct dict_object * type; |
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2677 /* Check if the AVP has a constant value */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2678 CHECK_FCT_DO( ret = fd_dict_search(dict, DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &type, 0), goto out ); |
330
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2679 if (type) { |
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2680 struct dict_enumval_request req; |
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2681 memset(&req, 0, sizeof(struct dict_enumval_request)); |
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2682 req.type_obj = type; |
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2683 memcpy( &req.search.enum_value, avp->avp_public.avp_value, sizeof(union avp_value) ); |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2684 CHECK_FCT_DO( ret = fd_dict_search(dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &req, &enumval, 0), goto out ); |
330
e283e18b2673
Removed incorrect ASSERT -- thanks to Alexandre for the bug finding.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
291
diff
changeset
|
2685 } |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2686 } |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2687 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2688 /* Call the callbacks */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2689 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, avp, session, action, app, cmd, avp->avp_model, enumval ), goto out ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2690 TEST_ACTION_STOP(); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2691 } |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2692 /* Go to next AVP */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2693 CHECK_FCT_DO( ret = fd_msg_browse( avp, MSG_BRW_WALK, &avp, NULL ), goto out ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2694 } |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2695 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2696 /* Now call command and application callbacks */ |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2697 CHECK_FCT_DO( ret = fd_dict_disp_cb(DICT_COMMAND, cmd, &cb_list), goto out ); |
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2698 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, NULL, session, action, app, cmd, NULL, NULL ), goto out ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2699 TEST_ACTION_STOP(); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2700 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2701 if (app) { |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2702 CHECK_FCT_DO( ret = fd_dict_disp_cb(DICT_APPLICATION, app, &cb_list), goto out ); |
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2703 CHECK_FCT_DO( ret = fd_disp_call_cb_int( cb_list, msg, NULL, session, action, app, cmd, NULL, NULL ), goto out ); |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2704 TEST_ACTION_STOP(); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2705 } |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2706 out: |
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2707 ; /* some systems would complain without this */ |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2708 pthread_cleanup_pop(0); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2709 |
690
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2710 CHECK_POSIX_DO(r2 = pthread_rwlock_unlock(&fd_disp_lock), /* ignore */ ); |
a29e4201d511
It seems FreeBSD does not unstack cancelation cleanups if we skip the pthread_cleanup_pop call
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
689
diff
changeset
|
2711 return ret ?: r2; |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
4
diff
changeset
|
2712 } |
687
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
2713 |
026802543f57
Prepare for new message log facility
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
686
diff
changeset
|
2714 |