Mercurial > hg > freeDiameter
annotate libfdproto/dictionary.c @ 1562:6219359a36a9 default tip
Merge latest changes from proposed branch
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Mon, 21 Jun 2021 19:08:18 +0800 |
parents | 566bb46cc73f |
children |
rev | line source |
---|---|
0 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
740
4a9f08d6b6ba
Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
0 | 4 * * |
1554
566bb46cc73f
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1451
diff
changeset
|
5 * Copyright (c) 2020, 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 | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
36 #include "fdproto-internal.h" |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
37 #include "dictionary-internal.h" |
1027
0117a7746b21
Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents:
979
diff
changeset
|
38 #include <inttypes.h> |
0 | 39 |
40 /* Names of the base types */ | |
41 const char * type_base_name[] = { /* must keep in sync with dict_avp_basetype */ | |
42 "GROUPED", /* AVP_TYPE_GROUPED */ | |
43 "OCTETSTRING", /* AVP_TYPE_OCTETSTRING */ | |
44 "INTEGER32", /* AVP_TYPE_INTEGER32 */ | |
45 "INTEGER64", /* AVP_TYPE_INTEGER64 */ | |
46 "UNSIGNED32", /* AVP_TYPE_UNSIGNED32 */ | |
47 "UNSIGNED64", /* AVP_TYPE_UNSIGNED64 */ | |
48 "FLOAT32", /* AVP_TYPE_FLOAT32 */ | |
49 "FLOAT64" /* AVP_TYPE_FLOAT64 */ | |
50 }; | |
51 | |
52 /* Some eye catchers definitions */ | |
53 #define OBJECT_EYECATCHER (0x0b13c7) | |
54 #define DICT_EYECATCHER (0x00d1c7) | |
55 | |
56 /* Forward declarations of dump functions */ | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
57 static DECLARE_FD_DUMP_PROTOTYPE(dump_vendor_data, void * data ); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
58 static DECLARE_FD_DUMP_PROTOTYPE(dump_application_data, void * data ); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
59 static DECLARE_FD_DUMP_PROTOTYPE(dump_type_data, void * data ); |
0 | 60 /* the dump function for enum has a different prototype since it need the datatype */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
61 static DECLARE_FD_DUMP_PROTOTYPE(dump_avp_data, void * data ); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
62 static DECLARE_FD_DUMP_PROTOTYPE(dump_command_data, void * data ); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
63 static DECLARE_FD_DUMP_PROTOTYPE(dump_rule_data, void * data ); |
0 | 64 |
65 /* Forward declarations of search functions */ | |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
66 static int search_vendor ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ); |
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
67 static int search_application ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ); |
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
68 static int search_type ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ); |
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
69 static int search_enumval ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ); |
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
70 static int search_avp ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ); |
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
71 static int search_cmd ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ); |
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
72 static int search_rule ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ); |
0 | 73 |
74 /* The following array contains lot of data about the different types of objects, for automated handling */ | |
75 static struct { | |
76 enum dict_object_type type; /* information for this type */ | |
77 char * name; /* string describing this object, for debug */ | |
78 size_t datasize; /* The size of the data structure */ | |
79 int parent; /* 0: never; 1: may; 2: must */ | |
80 enum dict_object_type parenttype; /* The type of the parent, when relevant */ | |
81 int eyecatcher; /* A kind of signature for this object */ | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
82 DECLARE_FD_DUMP_PROTOTYPE( (*dump_data), void * data ); /* The function to dump the data section */ |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
83 int (*search_fct)(struct dictionary * dict, int criteria, const void * what, struct dict_object **result );; /* The function to search an object of this type */ |
0 | 84 int haslist[NB_LISTS_PER_OBJ]; /* Tell if this list is used */ |
85 } dict_obj_info[] = { { 0, "(error)", 0, 0, 0, 0, NULL, NULL, {0, 0, 0} } | |
86 | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
87 /* type name datasize parent parenttype |
0 | 88 eyecatcher dump_data search_fct, haslist[] */ |
89 | |
90 ,{ DICT_VENDOR, "VENDOR", sizeof(struct dict_vendor_data), 0, 0, | |
91 OBJECT_EYECATCHER + 1, dump_vendor_data, search_vendor, { 1, 0, 0 } } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
92 |
0 | 93 ,{ DICT_APPLICATION, "APPLICATION", sizeof(struct dict_application_data), 1, DICT_VENDOR, |
94 OBJECT_EYECATCHER + 2, dump_application_data, search_application, { 1, 0, 0 } } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
95 |
0 | 96 ,{ DICT_TYPE, "TYPE", sizeof(struct dict_type_data), 1, DICT_APPLICATION, |
97 OBJECT_EYECATCHER + 3, dump_type_data, search_type, { 1, 0, 0 } } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
98 |
0 | 99 ,{ DICT_ENUMVAL, "ENUMVAL", sizeof(struct dict_enumval_data), 2, DICT_TYPE, |
100 OBJECT_EYECATCHER + 4, NULL, search_enumval, { 1, 1, 0 } } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
101 |
0 | 102 ,{ DICT_AVP, "AVP", sizeof(struct dict_avp_data), 1, DICT_TYPE, |
103 OBJECT_EYECATCHER + 5, dump_avp_data, search_avp, { 1, 1, 0 } } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
104 |
0 | 105 ,{ DICT_COMMAND, "COMMAND", sizeof(struct dict_cmd_data), 1, DICT_APPLICATION, |
106 OBJECT_EYECATCHER + 6, dump_command_data, search_cmd, { 1, 1, 0 } } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
107 |
0 | 108 ,{ DICT_RULE, "RULE", sizeof(struct dict_rule_data), 2, -1 /* special case: grouped avp or command */, |
109 OBJECT_EYECATCHER + 7, dump_rule_data, search_rule, { 1, 0, 0 } } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
110 |
0 | 111 }; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
112 |
0 | 113 /* Macro to verify a "type" value */ |
114 #define CHECK_TYPE( type ) ( ((type) > 0) && ((type) <= DICT_TYPE_MAX) ) | |
115 | |
116 /* Cast macro */ | |
117 #define _O( object ) ((struct dict_object *) (object)) | |
118 | |
119 /* Get information line for a given object */ | |
120 #define _OBINFO(object) (dict_obj_info[CHECK_TYPE(_O(object)->type) ? _O(object)->type : 0]) | |
121 | |
122 | |
123 | |
124 | |
125 /*******************************************************************************************************/ | |
126 /*******************************************************************************************************/ | |
127 /* */ | |
128 /* Objects management */ | |
129 /* */ | |
130 /*******************************************************************************************************/ | |
131 /*******************************************************************************************************/ | |
132 | |
133 /* Functions to manage the objects creation and destruction. */ | |
134 | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
135 /* Duplicate a string inplace, save its length */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
136 #define DUP_string_len( str, plen ) { \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
137 *(plen) = strlen((str)); \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
138 str = os0dup( str, *(plen)); \ |
0 | 139 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
140 |
0 | 141 /* Initialize an object */ |
142 static void init_object( struct dict_object * obj, enum dict_object_type type ) | |
143 { | |
144 int i; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
145 |
0 | 146 TRACE_ENTRY("%p %d", obj, type); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
147 |
0 | 148 /* Clean the object first */ |
149 memset ( obj, 0, sizeof(struct dict_object)); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
150 |
0 | 151 CHECK_PARAMS_DO( CHECK_TYPE(type), return ); |
152 | |
153 obj->type = type; | |
154 obj->objeyec = OBJECT_EYECATCHER; | |
155 obj->typeyec = _OBINFO(obj).eyecatcher; | |
156 | |
157 /* We don't initialize the data nor the parent here */ | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
158 |
0 | 159 /* Now init the lists */ |
160 for (i=0; i<NB_LISTS_PER_OBJ; i++) { | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
161 if (_OBINFO(obj).haslist[i] != 0) |
0 | 162 fd_list_init(&obj->list[i], obj); |
163 else | |
164 fd_list_init(&obj->list[i], NULL); | |
165 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
166 |
0 | 167 fd_list_init(&obj->disp_cbs, NULL); |
168 } | |
169 | |
170 /* Initialize the "data" part of an object */ | |
1316
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
171 static int init_object_data(struct dict_object * dest, void * source, enum dict_object_type type, int dupos) |
0 | 172 { |
173 TRACE_ENTRY("%p %p %d", dest, source, type); | |
174 CHECK_PARAMS( dest && source && CHECK_TYPE(type) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
175 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
176 /* Generic: copy the full data structure */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
177 memcpy( &dest->data, source, dict_obj_info[type].datasize ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
178 |
0 | 179 /* Then strings must be duplicated, not copied */ |
180 /* This function might be simplified by always defining the "name" field as the first field of the structures, but... it's error-prone */ | |
181 switch (type) { | |
182 case DICT_VENDOR: | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
183 DUP_string_len( dest->data.vendor.vendor_name, &dest->datastr_len ); |
0 | 184 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
185 |
0 | 186 case DICT_APPLICATION: |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
187 DUP_string_len( dest->data.application.application_name, &dest->datastr_len ); |
0 | 188 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
189 |
0 | 190 case DICT_TYPE: |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
191 DUP_string_len( dest->data.type.type_name, &dest->datastr_len ); |
0 | 192 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
193 |
0 | 194 case DICT_ENUMVAL: |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
195 DUP_string_len( dest->data.enumval.enum_name, &dest->datastr_len ); |
1316
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
196 if (dupos) { |
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
197 // we also need to duplicate the octetstring constant value since it is a pointer. |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
198 dest->data.enumval.enum_value.os.data = os0dup( |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
199 ((struct dict_enumval_data *)source)->enum_value.os.data, |
1316
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
200 ((struct dict_enumval_data *)source)->enum_value.os.len |
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
201 ); |
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
202 } |
0 | 203 break; |
204 | |
205 case DICT_AVP: | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
206 DUP_string_len( dest->data.avp.avp_name, &dest->datastr_len ); |
0 | 207 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
208 |
0 | 209 case DICT_COMMAND: |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
210 DUP_string_len( dest->data.cmd.cmd_name, &dest->datastr_len ); |
0 | 211 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
212 |
0 | 213 default: |
214 /* Nothing to do for RULES */ | |
215 ; | |
216 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
217 |
0 | 218 return 0; |
219 } | |
220 | |
221 /* Check that an object is valid (1: OK, 0: error) */ | |
222 static int verify_object( struct dict_object * obj ) | |
223 { | |
224 TRACE_ENTRY("%p", obj); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
225 |
0 | 226 CHECK_PARAMS_DO( obj |
227 && (obj->objeyec == OBJECT_EYECATCHER) | |
228 && CHECK_TYPE(obj->type) | |
229 && (obj->typeyec == dict_obj_info[obj->type].eyecatcher), | |
230 { | |
231 if (obj) { | |
979 | 232 TRACE_DEBUG(FULL, "Invalid object: %p, obj->objeyec: %x/%x, obj->type: %d, obj->objeyec: %x/%x, obj->typeyec: %x/%x", |
0 | 233 obj, |
234 obj->objeyec, OBJECT_EYECATCHER, | |
235 obj->type, | |
236 obj->objeyec, OBJECT_EYECATCHER, | |
237 obj->typeyec, _OBINFO(obj).eyecatcher); | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
238 } else { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
239 TRACE_DEBUG(FULL, "Invalid object : NULL pointer"); |
0 | 240 } |
241 return 0; | |
242 } ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
243 |
0 | 244 /* The object is probably valid. */ |
245 return 1; | |
246 } | |
247 | |
248 /* Free the data associated to an object */ | |
249 static void destroy_object_data(struct dict_object * obj) | |
250 { | |
251 /* TRACE_ENTRY("%p", obj); */ | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
252 |
0 | 253 switch (obj->type) { |
254 case DICT_VENDOR: | |
255 free( obj->data.vendor.vendor_name ); | |
256 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
257 |
0 | 258 case DICT_APPLICATION: |
259 free( obj->data.application.application_name ); | |
260 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
261 |
0 | 262 case DICT_TYPE: |
263 free( obj->data.type.type_name ); | |
264 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
265 |
0 | 266 case DICT_ENUMVAL: |
267 free( obj->data.enumval.enum_name ); | |
268 break; | |
269 | |
270 case DICT_AVP: | |
271 free( obj->data.avp.avp_name ); | |
272 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
273 |
0 | 274 case DICT_COMMAND: |
275 free( obj->data.cmd.cmd_name ); | |
276 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
277 |
0 | 278 default: |
279 /* nothing to do */ | |
280 ; | |
281 } | |
282 } | |
283 | |
284 /* Forward declaration */ | |
285 static void destroy_object(struct dict_object * obj); | |
286 | |
287 /* Destroy all objects in a list - the lock must be held */ | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
288 static void destroy_list(struct fd_list * head) |
0 | 289 { |
290 /* TRACE_ENTRY("%p", head); */ | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
291 |
0 | 292 /* loop in the list */ |
293 while (!FD_IS_LIST_EMPTY(head)) | |
294 { | |
295 /* When destroying the object, it is unlinked from the list */ | |
296 destroy_object(_O(head->next->o)); | |
297 } | |
298 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
299 |
0 | 300 /* Free an object and its sublists */ |
301 static void destroy_object(struct dict_object * obj) | |
302 { | |
303 int i; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
304 |
0 | 305 /* TRACE_ENTRY("%p", obj); */ |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
306 |
0 | 307 /* Update global count */ |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
308 if (obj->dico) |
0 | 309 obj->dico->dict_count[obj->type]--; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
310 |
0 | 311 /* Mark the object as invalid */ |
312 obj->objeyec = 0xdead; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
313 |
0 | 314 /* First, destroy the data associated to the object */ |
315 destroy_object_data(obj); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
316 |
0 | 317 for (i=0; i<NB_LISTS_PER_OBJ; i++) { |
318 if (_OBINFO(obj).haslist[i]) | |
319 /* unlink the element from the list */ | |
320 fd_list_unlink( &obj->list[i] ); | |
321 else | |
322 /* This is either a sentinel or unused (=emtpy) list, let's destroy it */ | |
323 destroy_list( &obj->list[i] ); | |
324 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
325 |
0 | 326 /* Unlink all elements from the dispatch list; they will be freed when callback is unregistered */ |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
327 CHECK_POSIX_DO( pthread_rwlock_wrlock(&fd_disp_lock), /* continue */ ); |
0 | 328 while (!FD_IS_LIST_EMPTY(&obj->disp_cbs)) { |
329 fd_list_unlink( obj->disp_cbs.next ); | |
330 } | |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
331 CHECK_POSIX_DO( pthread_rwlock_unlock(&fd_disp_lock), /* continue */ ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
332 |
0 | 333 /* Last, destroy the object */ |
334 free(obj); | |
335 } | |
336 | |
337 /*******************************************************************************************************/ | |
338 /*******************************************************************************************************/ | |
339 /* */ | |
340 /* Compare functions */ | |
341 /* */ | |
342 /*******************************************************************************************************/ | |
343 /*******************************************************************************************************/ | |
344 | |
345 /* Compare two values */ | |
346 #define ORDER_scalar( i1, i2 ) \ | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
347 ((i1 < i2 ) ? -1 : ( i1 > i2 ? 1 : 0 )) |
0 | 348 |
349 | |
350 /* Compare two vendor objects by their id (checks already performed) */ | |
351 static int order_vendor_by_id ( struct dict_object *o1, struct dict_object *o2 ) | |
352 { | |
353 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
354 |
0 | 355 return ORDER_scalar( o1->data.vendor.vendor_id, o2->data.vendor.vendor_id ); |
356 } | |
357 | |
358 /* Compare two application objects by their id (checks already performed) */ | |
359 static int order_appli_by_id ( struct dict_object *o1, struct dict_object *o2 ) | |
360 { | |
361 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
362 |
0 | 363 return ORDER_scalar( o1->data.application.application_id, o2->data.application.application_id ); |
364 } | |
365 | |
366 /* Compare two type objects by their name (checks already performed) */ | |
367 static int order_type_by_name ( struct dict_object *o1, struct dict_object *o2 ) | |
368 { | |
369 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
370 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
371 return fd_os_cmp( o1->data.type.type_name, o1->datastr_len, o2->data.type.type_name, o2->datastr_len ); |
0 | 372 } |
373 | |
374 /* Compare two type_enum objects by their names (checks already performed) */ | |
375 static int order_enum_by_name ( struct dict_object *o1, struct dict_object *o2 ) | |
376 { | |
377 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
378 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
379 return fd_os_cmp( o1->data.enumval.enum_name, o1->datastr_len, o2->data.enumval.enum_name, o2->datastr_len ); |
0 | 380 } |
381 | |
382 /* Compare two type_enum objects by their values (checks already performed) */ | |
383 static int order_enum_by_val ( struct dict_object *o1, struct dict_object *o2 ) | |
384 { | |
385 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
386 |
0 | 387 /* The comparison function depends on the type of data */ |
388 switch ( o1->parent->data.type.type_base ) { | |
389 case AVP_TYPE_OCTETSTRING: | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
390 return fd_os_cmp( o1->data.enumval.enum_value.os.data, o1->data.enumval.enum_value.os.len, |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
391 o2->data.enumval.enum_value.os.data, o2->data.enumval.enum_value.os.len); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
392 |
0 | 393 case AVP_TYPE_INTEGER32: |
394 return ORDER_scalar( o1->data.enumval.enum_value.i32, o2->data.enumval.enum_value.i32 ); | |
395 | |
396 case AVP_TYPE_INTEGER64: | |
397 return ORDER_scalar( o1->data.enumval.enum_value.i64, o2->data.enumval.enum_value.i64 ); | |
398 | |
399 case AVP_TYPE_UNSIGNED32: | |
400 return ORDER_scalar( o1->data.enumval.enum_value.u32, o2->data.enumval.enum_value.u32 ); | |
401 | |
402 case AVP_TYPE_UNSIGNED64: | |
403 return ORDER_scalar( o1->data.enumval.enum_value.u64, o2->data.enumval.enum_value.u64 ); | |
404 | |
405 case AVP_TYPE_FLOAT32: | |
406 return ORDER_scalar( o1->data.enumval.enum_value.f32, o2->data.enumval.enum_value.f32 ); | |
407 | |
408 case AVP_TYPE_FLOAT64: | |
409 return ORDER_scalar( o1->data.enumval.enum_value.f64, o2->data.enumval.enum_value.f64 ); | |
410 | |
411 case AVP_TYPE_GROUPED: | |
412 default: | |
413 ASSERT(0); | |
414 } | |
415 return 0; | |
416 } | |
417 | |
418 /* Compare two avp objects by their codes (checks already performed) */ | |
419 static int order_avp_by_code ( struct dict_object *o1, struct dict_object *o2 ) | |
420 { | |
421 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
422 |
0 | 423 return ORDER_scalar( o1->data.avp.avp_code, o2->data.avp.avp_code ); |
424 } | |
425 | |
426 /* Compare two avp objects by their names (checks already performed) */ | |
427 static int order_avp_by_name ( struct dict_object *o1, struct dict_object *o2 ) | |
428 { | |
429 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
430 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
431 return fd_os_cmp( o1->data.avp.avp_name, o1->datastr_len, o2->data.avp.avp_name, o2->datastr_len ); |
0 | 432 } |
433 | |
434 /* Compare two command objects by their names (checks already performed) */ | |
435 static int order_cmd_by_name ( struct dict_object *o1, struct dict_object *o2 ) | |
436 { | |
437 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
438 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
439 return fd_os_cmp( o1->data.cmd.cmd_name, o1->datastr_len, o2->data.cmd.cmd_name, o2->datastr_len ); |
0 | 440 } |
441 | |
442 /* Compare two command objects by their codes and flags (request or answer) (checks already performed) */ | |
443 static int order_cmd_by_codefl( struct dict_object *o1, struct dict_object *o2 ) | |
444 { | |
445 uint8_t fl1, fl2; | |
446 int cmp = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
447 |
0 | 448 TRACE_ENTRY("%p %p", o1, o2); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
449 |
0 | 450 cmp = ORDER_scalar( o1->data.cmd.cmd_code, o2->data.cmd.cmd_code ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
451 if (cmp) |
0 | 452 return cmp; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
453 |
0 | 454 /* Same command code, we must compare the value of the 'R' flag */ |
455 fl1 = o1->data.cmd.cmd_flag_val & CMD_FLAG_REQUEST; | |
456 fl2 = o2->data.cmd.cmd_flag_val & CMD_FLAG_REQUEST; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
457 |
0 | 458 /* We want requests first, so we reverse the operators here */ |
459 return ORDER_scalar(fl2, fl1); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
460 |
0 | 461 } |
462 | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
463 /* Compare two rule object by the AVP vendor & code that they refer (checks already performed) */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
464 static int order_rule_by_avpvc ( struct dict_object *o1, struct dict_object *o2 ) |
0 | 465 { |
466 TRACE_ENTRY("%p %p", o1, o2); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
467 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
468 return ORDER_scalar(o1->data.rule.rule_avp->data.avp.avp_vendor, o2->data.rule.rule_avp->data.avp.avp_vendor) |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
469 ?: ORDER_scalar(o1->data.rule.rule_avp->data.avp.avp_code, o2->data.rule.rule_avp->data.avp.avp_code) ; |
0 | 470 } |
471 | |
472 /*******************************************************************************************************/ | |
473 /*******************************************************************************************************/ | |
474 /* */ | |
475 /* Search functions */ | |
476 /* */ | |
477 /*******************************************************************************************************/ | |
478 /*******************************************************************************************************/ | |
479 | |
480 /* Functions used to search for objects in the lists, according to some criteria */ | |
481 | |
482 /* On a general note, if result is not NULL, ENOENT is not returned but *result is NULL. */ | |
483 | |
484 /* The following macros assume that "what", "ret", "result" (variables), and "end" (label) exist | |
485 in the local context where they are called. They are meant to be called only from the functions that follow. */ | |
486 | |
487 /* For searchs of type "xxx_OF_xxx": children's parent or default parent */ | |
488 #define SEARCH_childs_parent( type_of_child, default_parent ) { \ | |
489 struct dict_object *__child = (struct dict_object *) what; \ | |
490 CHECK_PARAMS_DO( verify_object(__child) && \ | |
491 (__child->type == (type_of_child)), \ | |
492 { ret = EINVAL; goto end; } ); \ | |
493 ret = 0; \ | |
494 if (result) \ | |
495 *result = (__child->parent ? __child->parent :(default_parent));\ | |
496 } | |
497 | |
498 /* For search of strings in lists. isindex= 1 if the string is the ordering key of the list */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
499 /* it is expected that object->datastr_len is the length of the datafield parameter */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
500 #define SEARCH_os0_l( str, len, sentinel, datafield, isindex ) { \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
501 char * __str = (char *) (str); \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
502 size_t __strlen = (size_t)(len); \ |
0 | 503 int __cmp; \ |
504 struct fd_list * __li; \ | |
505 ret = 0; \ | |
602
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
506 for (__li = (sentinel)->next; __li != (sentinel); __li = __li->next) { \ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
507 __cmp = fd_os_cmp(__str, __strlen, \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
508 _O(__li->o)->data. datafield, _O(__li->o)->datastr_len);\ |
0 | 509 if (__cmp == 0) { \ |
510 if (result) \ | |
602
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
511 *result = _O(__li->o); \ |
0 | 512 goto end; \ |
513 } \ | |
514 if ((isindex) && (__cmp < 0)) \ | |
515 break; \ | |
516 } \ | |
517 if (result) \ | |
518 *result = NULL; \ | |
519 else \ | |
520 ret = ENOENT; \ | |
521 } | |
522 | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
523 /* When len is not provided */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
524 #define SEARCH_os0( str, sentinel, datafield, isindex ) { \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
525 char * _str = (char *) (str); \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
526 size_t _strlen = strlen(_str); \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
527 SEARCH_os0_l( _str, _strlen, sentinel, datafield, isindex ); \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
528 } |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
529 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
530 |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
531 /* For search of octetstrings in lists. */ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
532 #define SEARCH_os( str, strlen, sentinel, osdatafield, isindex ) { \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
533 uint8_t * __str = (uint8_t *) (str); \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
534 size_t __strlen = (size_t)(strlen); \ |
0 | 535 int __cmp; \ |
536 struct fd_list * __li; \ | |
537 ret = 0; \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
538 for (__li = (sentinel)->next; __li != (sentinel); __li = __li->next) { \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
539 __cmp = fd_os_cmp(__str, __strlen, \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
540 _O(__li->o)->data. osdatafield .data, \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
541 _O(__li->o)->data. osdatafield .len); \ |
0 | 542 if (__cmp == 0) { \ |
543 if (result) \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
544 *result = _O(__li->o); \ |
0 | 545 goto end; \ |
546 } \ | |
547 if ((isindex) && (__cmp < 0)) \ | |
548 break; \ | |
549 } \ | |
550 if (result) \ | |
551 *result = NULL; \ | |
552 else \ | |
553 ret = ENOENT; \ | |
554 } | |
555 | |
910
8500947421cb
Fix bug in fd_dict_search for rules. Thank you Thomas for bug & fix.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
907
diff
changeset
|
556 /* For search of AVP name in rule lists -- the list is not ordered by AVP names! */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
557 #define SEARCH_ruleavpname( str, strlen, sentinel ) { \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
558 char * __str = (char *) (str); \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
559 size_t __strlen = (size_t) (strlen); \ |
0 | 560 int __cmp; \ |
561 struct fd_list * __li; \ | |
562 ret = 0; \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
563 for (__li = (sentinel)->next; __li != (sentinel); __li = __li->next) { \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
564 __cmp = fd_os_cmp(__str, __strlen, \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
565 _O(__li->o)->data.rule.rule_avp->data.avp.avp_name, \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
566 _O(__li->o)->data.rule.rule_avp->datastr_len); \ |
0 | 567 if (__cmp == 0) { \ |
568 if (result) \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
569 *result = _O(__li->o); \ |
0 | 570 goto end; \ |
571 } \ | |
572 } \ | |
573 if (result) \ | |
574 *result = NULL; \ | |
575 else \ | |
576 ret = ENOENT; \ | |
577 } | |
578 | |
579 /* For search of scalars in lists. isindex= 1 if the value is the ordering key of the list */ | |
580 #define SEARCH_scalar( value, sentinel, datafield, isindex, defaultobj ) { \ | |
581 int __cmp; \ | |
582 struct fd_list * __li; \ | |
583 ret = 0; \ | |
584 if ( ((defaultobj) != NULL) \ | |
585 && (_O(defaultobj)->data. datafield == value)) { \ | |
586 if (result) \ | |
587 *result = _O(defaultobj); \ | |
588 goto end; \ | |
589 } \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
590 for (__li = (sentinel)->next; __li != (sentinel); __li = __li->next) { \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
591 __cmp= ORDER_scalar(value, _O(__li->o)->data. datafield ); \ |
0 | 592 if (__cmp == 0) { \ |
593 if (result) \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
594 *result = _O(__li->o); \ |
0 | 595 goto end; \ |
596 } \ | |
597 if ((isindex) && (__cmp < 0)) \ | |
598 break; \ | |
599 } \ | |
600 if (result) \ | |
601 *result = NULL; \ | |
602 else \ | |
603 ret = ENOENT; \ | |
604 } | |
605 | |
606 /* For search of commands in lists by code and flag. R_flag_val = 0 or CMD_FLAG_REQUEST */ | |
607 #define SEARCH_codefl( value, R_flag_val, sentinel) { \ | |
608 int __cmp; \ | |
609 struct fd_list * __li; \ | |
610 ret = 0; \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
611 for (__li = (sentinel)->next; __li != (sentinel); __li = __li->next) { \ |
0 | 612 __cmp = ORDER_scalar(value, \ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
613 _O(__li->o)->data.cmd.cmd_code ); \ |
0 | 614 if (__cmp == 0) { \ |
615 uint8_t __mask, __val; \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
616 __mask = _O(__li->o)->data.cmd.cmd_flag_mask; \ |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
617 __val = _O(__li->o)->data.cmd.cmd_flag_val; \ |
0 | 618 if ( ! (__mask & CMD_FLAG_REQUEST) ) \ |
619 continue; \ | |
620 if ( ( __val & CMD_FLAG_REQUEST ) != R_flag_val ) \ | |
621 continue; \ | |
622 if (result) \ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
623 *result = _O(__li->o); \ |
0 | 624 goto end; \ |
625 } \ | |
626 if (__cmp < 0) \ | |
627 break; \ | |
628 } \ | |
629 if (result) \ | |
630 *result = NULL; \ | |
631 else \ | |
632 ret = ENOENT; \ | |
633 } | |
634 | |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
635 /* For searchs of type "xxx_OF_xxx": if the search object is sentinel list for the "what" object */ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
636 #define SEARCH_sentinel( type_of_what, what_list_nr, sentinel_list_nr ) { \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
637 struct dict_object *__what = (struct dict_object *) what; \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
638 CHECK_PARAMS_DO( verify_object(__what) && \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
639 (__what->type == (type_of_what)), \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
640 { ret = EINVAL; goto end; } ); \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
641 ret = 0; \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
642 if (result) { \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
643 /* this is similar to the "container_of" */ \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
644 *result = (struct dict_object *)((char *)(__what->list[what_list_nr].head) - \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
645 (size_t)&(((struct dict_object *)0)->list[sentinel_list_nr])); \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
646 } \ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
647 } |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
648 |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
649 |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
650 static int search_vendor ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ) |
0 | 651 { |
652 int ret = 0; | |
653 vendor_id_t id; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
654 |
0 | 655 TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
656 |
0 | 657 switch (criteria) { |
658 case VENDOR_BY_ID: | |
659 id = *(vendor_id_t *) what; | |
660 SEARCH_scalar( id, &dict->dict_vendors.list[0], vendor.vendor_id, 1, &dict->dict_vendors ); | |
661 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
662 |
0 | 663 case VENDOR_BY_NAME: |
664 /* "what" is a vendor name */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
665 SEARCH_os0( what, &dict->dict_vendors.list[0], vendor.vendor_name, 0); |
0 | 666 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
667 |
0 | 668 case VENDOR_OF_APPLICATION: |
669 /* "what" should be an application object */ | |
670 SEARCH_childs_parent( DICT_APPLICATION, &dict->dict_vendors ); | |
671 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
672 |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
673 case VENDOR_OF_AVP: |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
674 /* "what" should be an avp object */ |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
675 SEARCH_sentinel( DICT_AVP, 0, 1 ); |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
676 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
677 |
0 | 678 default: |
679 /* Invalid criteria */ | |
680 CHECK_PARAMS( criteria = 0 ); | |
681 } | |
682 end: | |
683 return ret; | |
684 } | |
685 | |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
686 static int search_application ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ) |
0 | 687 { |
688 int ret = 0; | |
689 application_id_t id; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
690 |
0 | 691 TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
692 |
0 | 693 switch (criteria) { |
694 case APPLICATION_BY_ID: | |
695 id = *(application_id_t *) what; | |
696 | |
697 SEARCH_scalar( id, &dict->dict_applications.list[0], application.application_id, 1, &dict->dict_applications ); | |
698 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
699 |
0 | 700 case APPLICATION_BY_NAME: |
701 /* "what" is an application name */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
702 SEARCH_os0( what, &dict->dict_applications.list[0], application.application_name, 0); |
0 | 703 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
704 |
0 | 705 case APPLICATION_OF_TYPE: |
706 /* "what" should be a type object */ | |
707 SEARCH_childs_parent( DICT_TYPE, &dict->dict_applications ); | |
708 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
709 |
0 | 710 case APPLICATION_OF_COMMAND: |
711 /* "what" should be a command object */ | |
712 SEARCH_childs_parent( DICT_COMMAND, &dict->dict_applications ); | |
713 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
714 |
0 | 715 default: |
716 /* Invalid criteria */ | |
717 CHECK_PARAMS( criteria = 0 ); | |
718 } | |
719 end: | |
720 return ret; | |
721 } | |
722 | |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
723 static int search_type ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ) |
0 | 724 { |
725 int ret = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
726 |
0 | 727 TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
728 |
0 | 729 switch (criteria) { |
730 case TYPE_BY_NAME: | |
731 /* "what" is a type name */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
732 SEARCH_os0( what, &dict->dict_types, type.type_name, 1); |
0 | 733 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
734 |
0 | 735 case TYPE_OF_ENUMVAL: |
736 /* "what" should be a type_enum object */ | |
737 SEARCH_childs_parent( DICT_ENUMVAL, NULL ); | |
738 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
739 |
0 | 740 case TYPE_OF_AVP: |
741 /* "what" should be an avp object */ | |
742 SEARCH_childs_parent( DICT_AVP, NULL ); | |
743 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
744 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
745 |
0 | 746 default: |
747 /* Invalid criteria */ | |
748 CHECK_PARAMS( criteria = 0 ); | |
749 } | |
750 end: | |
751 return ret; | |
752 } | |
753 | |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
754 static int search_enumval ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ) |
0 | 755 { |
756 int ret = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
757 |
0 | 758 TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
759 |
0 | 760 switch (criteria) { |
761 case ENUMVAL_BY_STRUCT: | |
762 { | |
763 struct dict_object * parent = NULL; | |
764 struct dict_enumval_request * _what = (struct dict_enumval_request *) what; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
765 |
0 | 766 CHECK_PARAMS( _what && ( _what->type_obj || _what->type_name ) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
767 |
0 | 768 if (_what->type_obj != NULL) { |
769 parent = _what->type_obj; | |
770 CHECK_PARAMS( verify_object(parent) && (parent->type == DICT_TYPE) ); | |
771 } else { | |
772 /* We received only the type name, we must find it first */ | |
773 CHECK_FCT_DO( search_type( dict, TYPE_BY_NAME, _what->type_name, &parent ), | |
774 CHECK_PARAMS( 0 ) ); | |
775 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
776 |
0 | 777 /* From here the "parent" object is valid */ |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
778 |
0 | 779 if ( _what->search.enum_name != NULL ) { |
780 /* We are looking for this string */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
781 SEARCH_os0( _what->search.enum_name, &parent->list[1], enumval.enum_name, 1 ); |
0 | 782 } else { |
783 /* We are looking for the value in enum_value */ | |
784 switch (parent->data.type.type_base) { | |
785 case AVP_TYPE_OCTETSTRING: | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
786 SEARCH_os( _what->search.enum_value.os.data, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
787 _what->search.enum_value.os.len, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
788 &parent->list[2], |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
789 enumval.enum_value.os , |
0 | 790 1 ); |
791 break; | |
792 | |
793 case AVP_TYPE_INTEGER32: | |
794 SEARCH_scalar( _what->search.enum_value.i32, | |
795 &parent->list[2], | |
796 enumval.enum_value.i32, | |
797 1, | |
798 (struct dict_object *)NULL); | |
799 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
800 |
0 | 801 case AVP_TYPE_INTEGER64: |
802 SEARCH_scalar( _what->search.enum_value.i64, | |
803 &parent->list[2], | |
804 enumval.enum_value.i64, | |
805 1, | |
806 (struct dict_object *)NULL); | |
807 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
808 |
0 | 809 case AVP_TYPE_UNSIGNED32: |
810 SEARCH_scalar( _what->search.enum_value.u32, | |
811 &parent->list[2], | |
812 enumval.enum_value.u32, | |
813 1, | |
814 (struct dict_object *)NULL); | |
815 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
816 |
0 | 817 case AVP_TYPE_UNSIGNED64: |
818 SEARCH_scalar( _what->search.enum_value.u64, | |
819 &parent->list[2], | |
820 enumval.enum_value.u64, | |
821 1, | |
822 (struct dict_object *)NULL); | |
823 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
824 |
0 | 825 case AVP_TYPE_FLOAT32: |
826 SEARCH_scalar( _what->search.enum_value.f32, | |
827 &parent->list[2], | |
828 enumval.enum_value.f32, | |
829 1, | |
830 (struct dict_object *)NULL); | |
831 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
832 |
0 | 833 case AVP_TYPE_FLOAT64: |
834 SEARCH_scalar( _what->search.enum_value.f64, | |
835 &parent->list[2], | |
836 enumval.enum_value.f64, | |
837 1, | |
838 (struct dict_object *)NULL); | |
839 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
840 |
0 | 841 default: |
842 /* Invalid parent type basetype */ | |
843 CHECK_PARAMS( parent = NULL ); | |
844 } | |
845 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
846 |
0 | 847 } |
848 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
849 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
850 |
0 | 851 default: |
852 /* Invalid criteria */ | |
853 CHECK_PARAMS( criteria = 0 ); | |
854 } | |
855 end: | |
856 return ret; | |
857 } | |
858 | |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
859 static int search_avp ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ) |
0 | 860 { |
861 int ret = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
862 |
0 | 863 TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
864 |
0 | 865 switch (criteria) { |
866 case AVP_BY_CODE: | |
867 { | |
868 avp_code_t code; | |
869 code = *(avp_code_t *) what; | |
870 | |
871 SEARCH_scalar( code, &dict->dict_vendors.list[1], avp.avp_code, 1, (struct dict_object *)NULL ); | |
872 } | |
873 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
874 |
0 | 875 case AVP_BY_NAME: |
876 /* "what" is the AVP name, vendor 0 */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
877 SEARCH_os0( what, &dict->dict_vendors.list[2], avp.avp_name, 1); |
0 | 878 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
879 |
0 | 880 case AVP_BY_CODE_AND_VENDOR: |
881 case AVP_BY_NAME_AND_VENDOR: | |
882 { | |
883 struct dict_avp_request * _what = (struct dict_avp_request *) what; | |
884 struct dict_object * vendor = NULL; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
885 |
0 | 886 CHECK_PARAMS( (criteria != AVP_BY_NAME_AND_VENDOR) || _what->avp_name ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
887 |
0 | 888 /* Now look for the vendor first */ |
889 CHECK_FCT( search_vendor( dict, VENDOR_BY_ID, &_what->avp_vendor, &vendor ) ); | |
890 if (vendor == NULL) { | |
891 if (result) | |
892 *result = NULL; | |
893 else | |
894 ret = ENOENT; | |
895 goto end; | |
896 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
897 |
0 | 898 /* We now have our vendor = head of the appropriate avp list */ |
899 if (criteria == AVP_BY_NAME_AND_VENDOR) { | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
900 SEARCH_os0( _what->avp_name, &vendor->list[2], avp.avp_name, 1); |
0 | 901 } else { |
902 /* AVP_BY_CODE_AND_VENDOR */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
903 SEARCH_scalar( _what->avp_code, &vendor->list[1], avp.avp_code, 1, (struct dict_object *)NULL ); |
0 | 904 } |
905 } | |
906 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
907 |
903
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
908 case AVP_BY_STRUCT: |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
909 { |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
910 struct dict_avp_request_ex * _what = (struct dict_avp_request_ex *) what; |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
911 struct dict_object * vendor = NULL; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
912 |
903
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
913 CHECK_PARAMS( _what->avp_vendor.vendor || _what->avp_vendor.vendor_id || _what->avp_vendor.vendor_name ); |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
914 CHECK_PARAMS( _what->avp_data.avp_code || _what->avp_data.avp_name ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
915 |
903
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
916 /* Now look for the vendor first */ |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
917 if (_what->avp_vendor.vendor) { |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
918 CHECK_PARAMS( ! _what->avp_vendor.vendor_id && ! _what->avp_vendor.vendor_name ); |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
919 vendor = _what->avp_vendor.vendor; |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
920 } else if (_what->avp_vendor.vendor_id) { |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
921 CHECK_PARAMS( ! _what->avp_vendor.vendor_name ); |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
922 CHECK_FCT( search_vendor( dict, VENDOR_BY_ID, &_what->avp_vendor.vendor_id, &vendor ) ); |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
923 } else { |
906
ebe479bfcd4b
Fix typo in new code
Sebastien Decugis <sdecugis@freediameter.net>
parents:
903
diff
changeset
|
924 CHECK_FCT( search_vendor( dict, VENDOR_BY_NAME, _what->avp_vendor.vendor_name, &vendor ) ); |
903
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
925 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
926 |
903
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
927 if (vendor == NULL) { |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
928 if (result) |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
929 *result = NULL; |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
930 else |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
931 ret = ENOENT; |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
932 goto end; |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
933 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
934 |
903
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
935 /* We now have our vendor = head of the appropriate avp list */ |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
936 if (_what->avp_data.avp_code) { |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
937 CHECK_PARAMS( ! _what->avp_data.avp_name ); |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
938 SEARCH_scalar( _what->avp_data.avp_code, &vendor->list[1], avp.avp_code, 1, (struct dict_object *)NULL ); |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
939 } else { |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
940 SEARCH_os0( _what->avp_data.avp_name, &vendor->list[2], avp.avp_name, 1); |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
941 } |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
942 } |
4382d7420e65
Add new AVP_BY_STRUCT method for searching vendor-specific AVPs. This allows more flexibility and superseeds AVP_BY_NAME_AND_VENDOR and AVP_BY_CODE_AND_VENDOR.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
834
diff
changeset
|
943 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
944 |
602
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
945 case AVP_BY_NAME_ALL_VENDORS: |
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
946 { |
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
947 struct fd_list * li; |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
948 size_t wl = strlen((char *)what); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
949 |
602
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
950 /* First, search for vendor 0 */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
951 SEARCH_os0_l( what, wl, &dict->dict_vendors.list[2], avp.avp_name, 1); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
952 |
602
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
953 /* If not found, loop for all vendors, until found */ |
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
954 for (li = dict->dict_vendors.list[0].next; li != &dict->dict_vendors.list[0]; li = li->next) { |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
955 SEARCH_os0_l( what, wl, &_O(li->o)->list[2], avp.avp_name, 1); |
602
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
956 } |
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
957 } |
0b5d21c87855
Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
446
diff
changeset
|
958 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
959 |
0 | 960 default: |
961 /* Invalid criteria */ | |
962 CHECK_PARAMS( criteria = 0 ); | |
963 } | |
964 end: | |
965 return ret; | |
966 } | |
967 | |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
968 static int search_cmd ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ) |
0 | 969 { |
970 int ret = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
971 |
0 | 972 TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
973 |
0 | 974 switch (criteria) { |
975 case CMD_BY_NAME: | |
976 /* "what" is a command name */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
977 SEARCH_os0( what, &dict->dict_cmd_name, cmd.cmd_name, 1); |
0 | 978 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
979 |
0 | 980 case CMD_BY_CODE_R: |
981 case CMD_BY_CODE_A: | |
982 { | |
983 command_code_t code; | |
984 uint8_t searchfl = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
985 |
0 | 986 /* The command code that we are searching */ |
987 code = *(command_code_t *) what; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
988 |
0 | 989 /* The flag (request or answer) of the command we are searching */ |
990 if (criteria == CMD_BY_CODE_R) { | |
991 searchfl = CMD_FLAG_REQUEST; | |
992 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
993 |
0 | 994 /* perform the search */ |
995 SEARCH_codefl( code, searchfl, &dict->dict_cmd_code ); | |
996 } | |
997 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
998 |
0 | 999 case CMD_ANSWER: |
1000 { | |
1001 /* "what" is a command object of type "request" */ | |
1002 struct dict_object * req = (struct dict_object *) what; | |
1003 struct dict_object * ans = NULL; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1004 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1005 CHECK_PARAMS( verify_object(req) |
0 | 1006 && (req->type == DICT_COMMAND) |
1007 && (req->data.cmd.cmd_flag_mask & CMD_FLAG_REQUEST) | |
1008 && (req->data.cmd.cmd_flag_val & CMD_FLAG_REQUEST) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1009 |
0 | 1010 /* The answer is supposed to be the next element in the list, if it exists */ |
1011 ans = req->list[1].next->o; | |
1012 if ( ans == NULL ) { | |
1013 TRACE_DEBUG( FULL, "the request was the last element in the list" ); | |
1014 ret = ENOENT; | |
1015 goto end; | |
1016 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1017 |
0 | 1018 /* Now check that the ans element is really the correct one */ |
1019 if ( (ans->data.cmd.cmd_code != req->data.cmd.cmd_code) | |
1020 || (!(ans->data.cmd.cmd_flag_mask & CMD_FLAG_REQUEST)) | |
1021 || ( ans->data.cmd.cmd_flag_val & CMD_FLAG_REQUEST ) ) { | |
1022 TRACE_DEBUG( FULL, "the answer does not follow the request in the list" ); | |
1023 ret = ENOENT; | |
1024 goto end; | |
1025 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1026 |
0 | 1027 if (result) |
1028 *result = ans; | |
1029 ret = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1030 } |
0 | 1031 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1032 |
0 | 1033 default: |
1034 /* Invalid criteria */ | |
1035 CHECK_PARAMS( criteria = 0 ); | |
1036 } | |
1037 end: | |
1038 return ret; | |
1039 } | |
1040 | |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
1041 static int search_rule ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ) |
0 | 1042 { |
1043 int ret = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1044 |
0 | 1045 TRACE_ENTRY("%p %d %p %p", dict, criteria, what, result); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1046 |
0 | 1047 switch (criteria) { |
1048 case RULE_BY_AVP_AND_PARENT: | |
1049 { | |
1050 struct dict_object * parent = NULL; | |
1051 struct dict_object * avp = NULL; | |
1052 struct dict_rule_request * _what = (struct dict_rule_request *) what; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1053 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1054 CHECK_PARAMS( _what |
0 | 1055 && (parent = _what->rule_parent) |
1056 && (avp = _what->rule_avp ) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1057 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1058 CHECK_PARAMS( verify_object(parent) |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1059 && ((parent->type == DICT_COMMAND) |
0 | 1060 || ((parent->type == DICT_AVP) && (parent->data.avp.avp_basetype == AVP_TYPE_GROUPED))) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1061 |
0 | 1062 CHECK_PARAMS( verify_object(avp) && (avp->type == DICT_AVP) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1063 |
0 | 1064 /* Perform the search */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
1065 SEARCH_ruleavpname( avp->data.avp.avp_name, avp->datastr_len, &parent->list[2]); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1066 |
0 | 1067 } |
1068 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1069 |
0 | 1070 default: |
1071 /* Invalid criteria */ | |
1072 CHECK_PARAMS( criteria = 0 ); | |
1073 } | |
1074 end: | |
1075 return ret; | |
1076 } | |
1077 | |
1078 /*******************************************************************************************************/ | |
1079 /*******************************************************************************************************/ | |
1080 /* */ | |
1081 /* Dump / debug functions */ | |
1082 /* */ | |
1083 /*******************************************************************************************************/ | |
1084 /*******************************************************************************************************/ | |
1085 /* The following functions are used to debug the module, and allow to print out the content of the dictionary */ | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1086 static DECLARE_FD_DUMP_PROTOTYPE(dump_vendor_data, void * data ) |
0 | 1087 { |
1088 struct dict_vendor_data * vendor = (struct dict_vendor_data *)data; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1089 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1090 return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: %-6u \"%s\"", vendor->vendor_id, vendor->vendor_name); |
0 | 1091 } |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1092 static DECLARE_FD_DUMP_PROTOTYPE(dump_application_data, void * data ) |
0 | 1093 { |
1094 struct dict_application_data * appli = (struct dict_application_data *) data; | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1095 return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: %-6u \"%s\"", appli->application_id, appli->application_name); |
0 | 1096 } |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1097 static DECLARE_FD_DUMP_PROTOTYPE(dump_type_data, void * data ) |
0 | 1098 { |
1099 struct dict_type_data * type = ( struct dict_type_data * ) data; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1100 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1101 return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: %-12s \"%s\"", |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1102 type_base_name[type->type_base], |
0 | 1103 type->type_name); |
1104 } | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1105 static DECLARE_FD_DUMP_PROTOTYPE(dump_enumval_data, struct dict_enumval_data * enumval, enum dict_avp_basetype type ) |
0 | 1106 { |
1107 const int LEN_MAX = 20; | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1108 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "data: (%-12s) \"%s\" -> ", type_base_name[type], enumval->enum_name), return NULL); |
0 | 1109 switch (type) { |
1110 case AVP_TYPE_OCTETSTRING: | |
1111 { | |
1112 int i, n=LEN_MAX; | |
1113 if (enumval->enum_value.os.len < LEN_MAX) | |
1114 n = enumval->enum_value.os.len; | |
1115 for (i=0; i < n; i++) | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1116 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "0x%2hhX/'%c' ", enumval->enum_value.os.data[i], ASCII(enumval->enum_value.os.data[i])), return NULL); |
0 | 1117 if (n == LEN_MAX) |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1118 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "..."), return NULL); |
0 | 1119 } |
1120 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1121 |
0 | 1122 case AVP_TYPE_INTEGER32: |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1123 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "%i", enumval->enum_value.i32), return NULL); |
0 | 1124 break; |
1125 | |
1126 case AVP_TYPE_INTEGER64: | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1127 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "%"PRId64, enumval->enum_value.i64), return NULL); |
0 | 1128 break; |
1129 | |
1130 case AVP_TYPE_UNSIGNED32: | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1131 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "%u", enumval->enum_value.u32), return NULL); |
0 | 1132 break; |
1133 | |
1134 case AVP_TYPE_UNSIGNED64: | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1135 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "%"PRIu64, enumval->enum_value.u64), return NULL); |
0 | 1136 break; |
1137 | |
1138 case AVP_TYPE_FLOAT32: | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1139 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "%f", enumval->enum_value.f32), return NULL); |
0 | 1140 break; |
1141 | |
1142 case AVP_TYPE_FLOAT64: | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1143 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "%g", enumval->enum_value.f64), return NULL); |
0 | 1144 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1145 |
0 | 1146 default: |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1147 CHECK_MALLOC_DO(fd_dump_extend( FD_DUMP_STD_PARAMS, "??? (ERROR unknown type %d)", type), return NULL); |
0 | 1148 } |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1149 return *buf; |
0 | 1150 } |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1151 static DECLARE_FD_DUMP_PROTOTYPE(dump_avp_data, void * data ) |
0 | 1152 { |
1153 struct dict_avp_data * avp = (struct dict_avp_data * ) data; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1154 return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: v/m:" DUMP_AVPFL_str "/" DUMP_AVPFL_str ", %12s, %-6u \"%s\"", |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1155 DUMP_AVPFL_val(avp->avp_flag_val), |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1156 DUMP_AVPFL_val(avp->avp_flag_mask), |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1157 type_base_name[avp->avp_basetype], |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1158 avp->avp_code, |
0 | 1159 avp->avp_name ); |
1160 } | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1161 static DECLARE_FD_DUMP_PROTOTYPE(dump_command_data, void * data ) |
0 | 1162 { |
1163 struct dict_cmd_data * cmd = (struct dict_cmd_data *) data; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1164 return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: v/m:" DUMP_CMDFL_str "/" DUMP_CMDFL_str ", %-6u \"%s\"", |
0 | 1165 DUMP_CMDFL_val(cmd->cmd_flag_val), DUMP_CMDFL_val(cmd->cmd_flag_mask), cmd->cmd_code, cmd->cmd_name); |
1166 } | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1167 static DECLARE_FD_DUMP_PROTOTYPE(dump_rule_data, void * data ) |
0 | 1168 { |
1169 struct dict_rule_data * rule = (struct dict_rule_data * )data; | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1170 return fd_dump_extend( FD_DUMP_STD_PARAMS, "data: pos:%d ord:%d m/M:%2d/%2d avp:\"%s\"", |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1171 rule->rule_position, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1172 rule->rule_order, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1173 rule->rule_min, |
0 | 1174 rule->rule_max, |
1175 rule->rule_avp->data.avp.avp_name); | |
1176 } | |
1177 | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1178 static DECLARE_FD_DUMP_PROTOTYPE(dump_object, struct dict_object * obj, int parents, int depth, int indent ); |
0 | 1179 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1180 static DECLARE_FD_DUMP_PROTOTYPE(dump_list, struct fd_list * sentinel, int parents, int depth, int indent ) |
0 | 1181 { |
1182 struct fd_list * li = sentinel; | |
1183 /* We don't lock here, the caller must have taken the dictionary lock for reading already */ | |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1184 if (FD_IS_LIST_EMPTY(sentinel)) { |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1185 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*s{empty list}", indent, ""), return NULL); |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1186 } else { |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1187 while (li->next != sentinel) |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1188 { |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1189 li = li->next; |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1190 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1191 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, _O(li->o), parents, depth, indent ), return NULL); |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1192 } |
0 | 1193 } |
1119
79dd22145f52
Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1093
diff
changeset
|
1194 return *buf; |
0 | 1195 } |
1196 | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1197 static DECLARE_FD_DUMP_PROTOTYPE(dump_object, struct dict_object * obj, int parents, int depth, int indent ) |
0 | 1198 { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1199 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*s{dictobj}(@%p): ", indent, "", obj), return NULL); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1200 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1201 if (!verify_object(obj)) { |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1202 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID/NULL"), return NULL); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1203 return *buf; |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1204 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1205 |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1206 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s p:%p ", |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1207 _OBINFO(obj).name, |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1208 obj->parent), return NULL); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1209 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1210 if (obj->type == DICT_ENUMVAL) { |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1211 CHECK_MALLOC_DO( dump_enumval_data ( FD_DUMP_STD_PARAMS, &obj->data.enumval, obj->parent->data.type.type_base ), return NULL); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1212 } else { |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1213 CHECK_MALLOC_DO( _OBINFO(obj).dump_data(FD_DUMP_STD_PARAMS, &obj->data), return NULL); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1214 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1215 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1216 if (parents) { |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1217 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*sparent:", indent + 1, ""), return NULL); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1218 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, obj->parent, parents-1, 0, 0 ), return NULL); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1219 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1220 |
0 | 1221 if (depth) { |
1222 int i; | |
1223 for (i=0; i<NB_LISTS_PER_OBJ; i++) { | |
1224 if ((obj->list[i].o == NULL) && (obj->list[i].next != &obj->list[i])) { | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1225 CHECK_MALLOC_DO( dump_list(FD_DUMP_STD_PARAMS, &obj->list[i], 0, depth - 1, indent + 2), return NULL); |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1226 break; /* we get duplicate information sorted by another criteria otherwise, which is not very useful */ |
0 | 1227 } |
1228 } | |
1229 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1230 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1231 return *buf; |
0 | 1232 } |
1233 | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1234 DECLARE_FD_DUMP_PROTOTYPE(fd_dict_dump_object, struct dict_object * obj) |
0 | 1235 { |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1236 FD_DUMP_HANDLE_OFFSET(); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1237 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1238 CHECK_MALLOC_DO( dump_object(FD_DUMP_STD_PARAMS, obj, 1, 2, 0), return NULL); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1239 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1240 return *buf; |
0 | 1241 } |
1242 | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1243 DECLARE_FD_DUMP_PROTOTYPE(fd_dict_dump, struct dictionary * dict) |
0 | 1244 { |
1245 int i; | |
828
78307a61c578
Fix regression in dictionary dump
Sebastien Decugis <sdecugis@freediameter.net>
parents:
804
diff
changeset
|
1246 struct fd_list * li; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1247 |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1248 FD_DUMP_HANDLE_OFFSET(); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1249 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1250 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{dictionary}(@%p): ", dict), return NULL); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1251 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1252 if ((dict == NULL) || (dict->dict_eyec != DICT_EYECATCHER)) { |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1253 return fd_dump_extend(FD_DUMP_STD_PARAMS, "INVALID/NULL"); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1254 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1255 |
0 | 1256 CHECK_POSIX_DO( pthread_rwlock_rdlock( &dict->dict_lock ), /* ignore */ ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1257 |
1444
ab7cb954f17e
fd_dict_dump: consistency improvements
Luke Mewburn <luke@mewburn.net>
parents:
1316
diff
changeset
|
1258 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): VENDORS / AVP / RULES\n", dict), goto error); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1259 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, &dict->dict_vendors, 0, 3, 3 ), goto error); |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1260 for (li = dict->dict_vendors.list[0].next; li != &dict->dict_vendors.list[0]; li = li->next) { |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1261 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1262 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, li->o, 0, 3, 3 ), goto error); |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1263 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1264 |
1444
ab7cb954f17e
fd_dict_dump: consistency improvements
Luke Mewburn <luke@mewburn.net>
parents:
1316
diff
changeset
|
1265 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): APPLICATIONS\n", dict), goto error); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1266 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, &dict->dict_applications, 0, 1, 3 ), goto error); |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1267 for (li = dict->dict_applications.list[0].next; li != &dict->dict_applications.list[0]; li = li->next) { |
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1268 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1269 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, li->o, 0, 1, 3 ), goto error); |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1270 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1271 |
1444
ab7cb954f17e
fd_dict_dump: consistency improvements
Luke Mewburn <luke@mewburn.net>
parents:
1316
diff
changeset
|
1272 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): TYPES / ENUMVAL", dict), goto error); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1273 CHECK_MALLOC_DO( dump_list(FD_DUMP_STD_PARAMS, &dict->dict_types, 0, 2, 3 ), goto error); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1274 |
1444
ab7cb954f17e
fd_dict_dump: consistency improvements
Luke Mewburn <luke@mewburn.net>
parents:
1316
diff
changeset
|
1275 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): COMMANDS / RULES", dict), goto error); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1276 CHECK_MALLOC_DO( dump_list(FD_DUMP_STD_PARAMS, &dict->dict_cmd_code, 0, 0, 3 ), goto error); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1277 |
1444
ab7cb954f17e
fd_dict_dump: consistency improvements
Luke Mewburn <luke@mewburn.net>
parents:
1316
diff
changeset
|
1278 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict}(@%p): statistics", dict), goto error); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1279 for (i=1; i<=DICT_TYPE_MAX; i++) |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1280 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n %5d: %s", dict->dict_count[i], dict_obj_info[i].name), goto error); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1281 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1282 CHECK_POSIX_DO( pthread_rwlock_unlock( &dict->dict_lock ), /* ignore */ ); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1283 return *buf; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1284 error: |
0 | 1285 /* Free the rwlock */ |
1286 CHECK_POSIX_DO( pthread_rwlock_unlock( &dict->dict_lock ), /* ignore */ ); | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1287 return NULL; |
0 | 1288 } |
1289 | |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1290 /**************************** Dump AVP values ********************************/ |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1291 |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1292 /* Default dump functions */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1293 static DECLARE_FD_DUMP_PROTOTYPE(dump_val_os, union avp_value * value) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1294 { |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1295 int i; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1296 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1297 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "<"), return NULL); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1298 for (i = 0; i < value->os.len; i++) { |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1299 if (i == 1024) { /* Dump only up to 1024 bytes of the buffer */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1300 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "[...] (len=%zd)", value->os.len), return NULL); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1301 break; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1302 } |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1303 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s%02hhX", (i==0 ? "" : " "), value->os.data[i]), return NULL); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1304 } |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1305 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, ">"), return NULL); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1306 return *buf; |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1307 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1308 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1309 static DECLARE_FD_DUMP_PROTOTYPE(dump_val_i32, union avp_value * value) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1310 { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1311 return fd_dump_extend( FD_DUMP_STD_PARAMS, "%i (0x%x)", value->i32, value->i32); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1312 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1313 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1314 static DECLARE_FD_DUMP_PROTOTYPE(dump_val_i64, union avp_value * value) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1315 { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1316 return fd_dump_extend( FD_DUMP_STD_PARAMS, "%" PRId64 " (0x%" PRIx64 ")", value->i64, value->i64); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1317 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1318 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1319 static DECLARE_FD_DUMP_PROTOTYPE(dump_val_u32, union avp_value * value) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1320 { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1321 return fd_dump_extend( FD_DUMP_STD_PARAMS, "%u (0x%x)", value->u32, value->u32); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1322 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1323 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1324 static DECLARE_FD_DUMP_PROTOTYPE(dump_val_u64, union avp_value * value) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1325 { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1326 return fd_dump_extend( FD_DUMP_STD_PARAMS, "%" PRIu64 " (0x%" PRIx64 ")", value->u64, value->u64); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1327 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1328 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1329 static DECLARE_FD_DUMP_PROTOTYPE(dump_val_f32, union avp_value * value) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1330 { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1331 return fd_dump_extend( FD_DUMP_STD_PARAMS, "%f", value->f32); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1332 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1333 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1334 static DECLARE_FD_DUMP_PROTOTYPE(dump_val_f64, union avp_value * value) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1335 { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1336 return fd_dump_extend( FD_DUMP_STD_PARAMS, "%g", value->f64); |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1337 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1338 |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1339 /* Get the dump function for basic dict_avp_basetype */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1340 static DECLARE_FD_DUMP_PROTOTYPE((*get_default_dump_val_cb(enum dict_avp_basetype datatype)), union avp_value *) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1341 { |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1342 switch (datatype) { |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1343 case AVP_TYPE_OCTETSTRING: |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1344 return &dump_val_os; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1345 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1346 case AVP_TYPE_INTEGER32: |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1347 return &dump_val_i32; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1348 |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1349 case AVP_TYPE_INTEGER64: |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1350 return &dump_val_i64; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1351 |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1352 case AVP_TYPE_UNSIGNED32: |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1353 return &dump_val_u32; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1354 |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1355 case AVP_TYPE_UNSIGNED64: |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1356 return &dump_val_u64; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1357 |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1358 case AVP_TYPE_FLOAT32: |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1359 return &dump_val_f32; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1360 |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1361 case AVP_TYPE_FLOAT64: |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1362 return &dump_val_f64; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1363 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1364 case AVP_TYPE_GROUPED: |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1365 TRACE_DEBUG(FULL, "error: grouped AVP with a value!"); |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1366 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1367 return NULL; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1368 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1369 |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1370 /* indent inside an object (duplicate from messages.c) */ |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1371 #define INOBJHDR "%*s " |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1372 #define INOBJHDRVAL indent<0 ? 1 : indent, indent<0 ? "-" : "|" |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1373 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1374 typedef DECLARE_FD_DUMP_PROTOTYPE((*dump_val_cb_t), union avp_value *); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1375 |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1376 /* Formatter for the AVP value dump line */ |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1377 static DECLARE_FD_DUMP_PROTOTYPE(dump_avp_val, union avp_value *avp_value, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1378 dump_val_cb_t def_dump_val_cb, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1379 dump_val_cb_t dump_val_cb, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1380 enum dict_avp_basetype datatype, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1381 char * type_name, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1382 char * const_name, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1383 int indent, |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1384 int header) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1385 { |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1386 if (header) { |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1387 /* Header for all AVP values dumps: */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1388 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, INOBJHDR "value ", INOBJHDRVAL), return NULL); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1389 |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1390 /* If the type is provided, write it */ |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1391 if (type_name) { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1392 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "t: '%s' ", type_name), return NULL); |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1393 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1394 |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1395 /* Always give the base datatype anyway */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1396 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(%s) ", type_base_name[datatype]), return NULL); |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1397 |
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1398 /* Now, the value */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1399 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "v: "), return NULL); |
1036
aecdc2fbf222
Add fd_msg_dump_full function that dumps a message in human-readable format.
Thomas Klausner <tk@giga.or.at>
parents:
1030
diff
changeset
|
1400 } |
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:
788
diff
changeset
|
1401 if (const_name) { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1402 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "'%s' (", const_name), return NULL); |
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:
788
diff
changeset
|
1403 } |
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:
788
diff
changeset
|
1404 if (dump_val_cb) { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1405 CHECK_MALLOC_DO( (*dump_val_cb)( FD_DUMP_STD_PARAMS, avp_value), fd_dump_extend( FD_DUMP_STD_PARAMS, "(dump failed)")); |
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:
788
diff
changeset
|
1406 } else { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1407 CHECK_MALLOC_DO( (*def_dump_val_cb)( FD_DUMP_STD_PARAMS, avp_value), return NULL); |
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:
788
diff
changeset
|
1408 } |
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:
788
diff
changeset
|
1409 if (const_name) { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1410 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, ")"), return NULL); |
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:
788
diff
changeset
|
1411 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1412 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1413 /* Done! */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1414 return *buf; |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1415 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1416 |
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:
788
diff
changeset
|
1417 /* Dump the value of an AVP of known type into the returned str */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1418 DECLARE_FD_DUMP_PROTOTYPE(fd_dict_dump_avp_value, union avp_value *avp_value, struct dict_object * model, int indent, int header) |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1419 { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1420 DECLARE_FD_DUMP_PROTOTYPE((*dump_val_cb), union avp_value *avp_value) = NULL; |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1421 struct dict_object * type = NULL; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1422 char * type_name = NULL; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1423 char * const_name = NULL; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1424 |
1093
44f3e48dfe27
Align the behavior of all fd_*dump functions wrt final \n
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1085
diff
changeset
|
1425 FD_DUMP_HANDLE_OFFSET(); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1426 |
1252
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1427 /* Handle invalid parameters */ |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1428 if (!avp_value) { |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1429 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(avp value not set)"), return NULL); |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1430 return *buf; |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1431 } |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1432 |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1433 if (!model) { |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1434 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(model not set)"), return NULL); |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1435 return *buf; |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1436 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1437 |
1252
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1438 if (! ( verify_object(model) && (model->type == DICT_AVP) )) { |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1439 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(invalid model)"), return NULL); |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1440 return *buf; |
5c6e94202c64
Fix dump of Failed-AVP content as a value is set while the model is not
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1121
diff
changeset
|
1441 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1442 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1443 /* Get the type definition of this AVP */ |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1444 type = model->parent; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1445 if (type) { |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1446 struct dict_enumval_request request; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1447 struct dict_object * enumval = NULL; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1448 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1449 type_name = type->data.type.type_name; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1450 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1451 /* overwrite the dump function ? */ |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1452 if (type->data.type.type_dump) |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1453 dump_val_cb = type->data.type.type_dump; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1454 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1455 /* Now check if the AVP value matches a constant */ |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1456 memset(&request, 0, sizeof(request)); |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1457 request.type_obj = type; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1458 memcpy(&request.search.enum_value, avp_value, sizeof(union avp_value)); |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1459 /* bypass checks */ |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1460 if ((search_enumval( type->dico, ENUMVAL_BY_STRUCT, &request, &enumval ) == 0) && (enumval)) { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1461 /* We found a constant, get its name */ |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1462 const_name = enumval->data.enumval.enum_name; |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1463 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1464 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1465 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1466 /* And finally, dump the value */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1467 CHECK_MALLOC_DO( dump_avp_val(FD_DUMP_STD_PARAMS, avp_value, get_default_dump_val_cb(model->data.avp.avp_basetype), dump_val_cb, model->data.avp.avp_basetype, type_name, const_name, indent, header), return NULL ); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1468 return *buf; |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1469 } |
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
111
diff
changeset
|
1470 |
0 | 1471 /*******************************************************************************************************/ |
1472 /*******************************************************************************************************/ | |
1473 /* */ | |
1474 /* Exported functions */ | |
1475 /* */ | |
1476 /*******************************************************************************************************/ | |
1477 /*******************************************************************************************************/ | |
1478 | |
1
bafb831ba688
Fix names to proper case for freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
1479 /* These are the functions exported outside libfreeDiameter. */ |
0 | 1480 |
1481 /* Get the data associated to an object */ | |
1482 int fd_dict_gettype ( struct dict_object * object, enum dict_object_type * type) | |
1483 { | |
1484 TRACE_ENTRY("%p %p", object, type); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1485 |
0 | 1486 CHECK_PARAMS( type && verify_object(object) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1487 |
0 | 1488 /* Copy the value and return */ |
1489 *type = object->type; | |
1490 return 0; | |
1491 } | |
1492 | |
1493 int fd_dict_getdict ( struct dict_object * object, struct dictionary ** dict) | |
1494 { | |
1495 TRACE_ENTRY("%p %p", object, dict); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1496 |
0 | 1497 CHECK_PARAMS( dict && verify_object(object) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1498 |
0 | 1499 /* Copy the value and return */ |
1500 *dict = object->dico; | |
1501 return 0; | |
1502 } | |
1503 | |
1504 | |
1505 /* Get the data associated to an object */ | |
1506 int fd_dict_getval ( struct dict_object * object, void * val) | |
1507 { | |
1508 TRACE_ENTRY("%p %p", object, val); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1509 |
0 | 1510 CHECK_PARAMS( val && verify_object(object) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1511 |
0 | 1512 /* Copy the value and return */ |
1513 memcpy(val, &object->data, _OBINFO(object).datasize);; | |
1514 return 0; | |
1515 } | |
1516 | |
1517 /* Add a new object in the dictionary */ | |
1518 int fd_dict_new ( struct dictionary * dict, enum dict_object_type type, void * data, struct dict_object * parent, struct dict_object **ref ) | |
1519 { | |
1520 int ret = 0; | |
1316
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
1521 int dupos = 0; |
0 | 1522 struct dict_object * new = NULL; |
1523 struct dict_object * vendor = NULL; | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1524 struct dict_object * locref = NULL; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1525 |
0 | 1526 TRACE_ENTRY("%p %d(%s) %p %p %p", dict, type, dict_obj_info[CHECK_TYPE(type) ? type : 0].name, data, parent, ref); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1527 |
0 | 1528 /* Check parameters */ |
1529 CHECK_PARAMS( dict && (dict->dict_eyec == DICT_EYECATCHER) && CHECK_TYPE(type) && data ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1530 |
0 | 1531 /* Check the "parent" parameter */ |
1532 switch (dict_obj_info[type].parent) { | |
1533 case 0: /* parent is forbidden */ | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1534 CHECK_PARAMS_DO( parent == NULL, goto error_param ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1535 |
0 | 1536 case 1: /* parent is optional */ |
1537 if (parent == NULL) | |
1538 break; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1539 |
0 | 1540 case 2: /* parent is mandatory */ |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1541 CHECK_PARAMS_DO( verify_object(parent), goto error_param ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1542 |
0 | 1543 if (type == DICT_RULE ) { /* Special case : grouped AVP or Command parents are allowed */ |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1544 CHECK_PARAMS_DO( (parent->type == DICT_COMMAND ) |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1545 || ( (parent->type == DICT_AVP) && (parent->data.avp.avp_basetype == AVP_TYPE_GROUPED ) ), goto error_param ); |
0 | 1546 } else { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1547 CHECK_PARAMS_DO( parent->type == dict_obj_info[type].parenttype, goto error_param ); |
0 | 1548 } |
1549 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1550 |
0 | 1551 /* For AVP object, we must also check that the "vendor" referenced exists */ |
1552 if (type == DICT_AVP) { | |
1553 CHECK_FCT_DO( fd_dict_search( dict, DICT_VENDOR, VENDOR_BY_ID, &(((struct dict_avp_data *)data)->avp_vendor), (void*)&vendor, ENOENT ), | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1554 { TRACE_DEBUG(INFO, "Unable to find vendor '%d' referenced in the AVP data", ((struct dict_avp_data *)data)->avp_vendor); goto error_param; } ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1555 |
0 | 1556 /* Also check if a parent is provided, that the type are the same */ |
1557 if (parent) { | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1558 CHECK_PARAMS_DO( parent->data.type.type_base == ((struct dict_avp_data *)data)->avp_basetype, goto error_param ); |
0 | 1559 } |
1560 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1561 |
0 | 1562 /* For RULE object, we must also check that the "avp" referenced exists */ |
1563 if (type == DICT_RULE) { | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1564 CHECK_PARAMS_DO( verify_object(((struct dict_rule_data *)data)->rule_avp), goto error_param ); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1565 CHECK_PARAMS_DO( ((struct dict_rule_data *)data)->rule_avp->type == DICT_AVP, goto error_param ); |
0 | 1566 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1567 |
0 | 1568 /* For COMMAND object, check that the 'R' flag is fixed */ |
1569 if (type == DICT_COMMAND) { | |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1570 CHECK_PARAMS_DO( ((struct dict_cmd_data *)data)->cmd_flag_mask & CMD_FLAG_REQUEST, goto error_param ); |
0 | 1571 } |
1316
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
1572 |
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
1573 /* For ENUMVAL object, check if the parent type is an OctetString */ |
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
1574 if (type == DICT_ENUMVAL) { |
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
1575 if (parent->data.type.type_base == AVP_TYPE_OCTETSTRING) |
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
1576 dupos = 1; |
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
1577 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1578 |
109
a522268ec95b
Less permissive in fd_dict_new
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
1579 /* We have to check that the new values are not equal to the sentinels */ |
a522268ec95b
Less permissive in fd_dict_new
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
1580 if (type == DICT_VENDOR) { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1581 CHECK_PARAMS_DO( ((struct dict_vendor_data *)data)->vendor_id != 0, goto error_param ); |
109
a522268ec95b
Less permissive in fd_dict_new
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
1582 } |
a522268ec95b
Less permissive in fd_dict_new
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
1583 if (type == DICT_APPLICATION) { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1584 CHECK_PARAMS_DO( ((struct dict_application_data *)data)->application_id != 0, goto error_param ); |
109
a522268ec95b
Less permissive in fd_dict_new
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
1585 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1586 |
0 | 1587 /* Parameters are valid, create the new object */ |
1588 CHECK_MALLOC( new = malloc(sizeof(struct dict_object)) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1589 |
0 | 1590 /* Initialize the data of the new object */ |
1591 init_object(new, type); | |
1316
2e868f71832f
Tentative fix for invalid pointers reported by Thomas.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1281
diff
changeset
|
1592 init_object_data(new, data, type, dupos); |
0 | 1593 new->dico = dict; |
1594 new->parent = parent; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1595 |
0 | 1596 /* We will change the dictionary => acquire the write lock */ |
1597 CHECK_POSIX_DO( ret = pthread_rwlock_wrlock(&dict->dict_lock), goto error_free ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1598 |
0 | 1599 /* Now link the object -- this also checks that no object with same keys already exists */ |
1600 switch (type) { | |
1601 case DICT_VENDOR: | |
1602 /* A vendor object is linked in the g_dict_vendors.list[0], by their id */ | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1603 ret = fd_list_insert_ordered ( &dict->dict_vendors.list[0], &new->list[0], (int (*)(void*, void *))order_vendor_by_id, (void **)&locref ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1604 if (ret) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1605 goto error_unlock; |
0 | 1606 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1607 |
0 | 1608 case DICT_APPLICATION: |
1609 /* An application object is linked in the g_dict_applciations.list[0], by their id */ | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1610 ret = fd_list_insert_ordered ( &dict->dict_applications.list[0], &new->list[0], (int (*)(void*, void *))order_appli_by_id, (void **)&locref ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1611 if (ret) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1612 goto error_unlock; |
0 | 1613 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1614 |
0 | 1615 case DICT_TYPE: |
1616 /* A type object is linked in g_list_types by its name */ | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1617 ret = fd_list_insert_ordered ( &dict->dict_types, &new->list[0], (int (*)(void*, void *))order_type_by_name, (void **)&locref ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1618 if (ret) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1619 goto error_unlock; |
0 | 1620 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1621 |
0 | 1622 case DICT_ENUMVAL: |
1623 /* A type_enum object is linked in it's parent 'type' object lists 1 and 2 by its name and values */ | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1624 ret = fd_list_insert_ordered ( &parent->list[1], &new->list[0], (int (*)(void*, void *))order_enum_by_name, (void **)&locref ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1625 if (ret) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1626 goto error_unlock; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1627 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1628 ret = fd_list_insert_ordered ( &parent->list[2], &new->list[1], (int (*)(void*, void *))order_enum_by_val, (void **)&locref ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1629 if (ret) { |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1630 fd_list_unlink(&new->list[0]); |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1631 goto error_unlock; |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1632 } |
0 | 1633 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1634 |
0 | 1635 case DICT_AVP: |
1636 /* An avp object is linked in lists 1 and 2 of its vendor, by code and name */ | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1637 ret = fd_list_insert_ordered ( &vendor->list[1], &new->list[0], (int (*)(void*, void *))order_avp_by_code, (void **)&locref ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1638 if (ret) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1639 goto error_unlock; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1640 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1641 ret = fd_list_insert_ordered ( &vendor->list[2], &new->list[1], (int (*)(void*, void *))order_avp_by_name, (void **)&locref ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1642 if (ret) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1643 fd_list_unlink(&new->list[0]); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1644 goto error_unlock; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1645 } |
0 | 1646 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1647 |
0 | 1648 case DICT_COMMAND: |
1649 /* A command object is linked in g_list_cmd_name and g_list_cmd_code by its name and code */ | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1650 ret = fd_list_insert_ordered ( &dict->dict_cmd_code, &new->list[1], (int (*)(void*, void *))order_cmd_by_codefl, (void **)&locref ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1651 if (ret) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1652 goto error_unlock; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1653 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1654 ret = fd_list_insert_ordered ( &dict->dict_cmd_name, &new->list[0], (int (*)(void*, void *))order_cmd_by_name, (void **)&locref ); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1655 if (ret) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1656 fd_list_unlink(&new->list[1]); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1657 goto error_unlock; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1658 } |
0 | 1659 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1660 |
0 | 1661 case DICT_RULE: |
1662 /* A rule object is linked in list[2] of its parent command or AVP by the name of the AVP it refers */ | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
1663 ret = fd_list_insert_ordered ( &parent->list[2], &new->list[0], (int (*)(void*, void *))order_rule_by_avpvc, (void **)&locref ); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1664 if (ret) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1665 goto error_unlock; |
0 | 1666 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1667 |
0 | 1668 default: |
1669 ASSERT(0); | |
1670 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1671 |
0 | 1672 /* A new object has been created, increment the global counter */ |
1673 dict->dict_count[type]++; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1674 |
0 | 1675 /* Unlock the dictionary */ |
1676 CHECK_POSIX_DO( ret = pthread_rwlock_unlock(&dict->dict_lock), goto error_free ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1677 |
0 | 1678 /* Save the pointer to the new object */ |
1679 if (ref) | |
1680 *ref = new; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1681 |
0 | 1682 return 0; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1683 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1684 error_param: |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1685 ret = EINVAL; |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1686 goto all_errors; |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1687 |
0 | 1688 error_unlock: |
1689 CHECK_POSIX_DO( pthread_rwlock_unlock(&dict->dict_lock), /* continue */ ); | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1690 if (ret == EEXIST) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1691 /* We have a duplicate key in locref. Check if the pointed object is the same or not */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1692 switch (type) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1693 case DICT_VENDOR: |
952
17ac99255475
Be explicit which entry already exists in the dictionary.
Thomas Klausner <tk@giga.or.at>
parents:
949
diff
changeset
|
1694 TRACE_DEBUG(FULL, "Vendor %s already in dictionary", new->data.vendor.vendor_name); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
1695 /* if we are here, it means the two vendors id are identical */ |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1696 if (fd_os_cmp(locref->data.vendor.vendor_name, locref->datastr_len, |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
1697 new->data.vendor.vendor_name, new->datastr_len)) { |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1698 TRACE_DEBUG(INFO, "Conflicting vendor name: %s", new->data.vendor.vendor_name); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1699 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1700 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1701 /* Otherwise (same name), we consider the function succeeded, since the (same) object is in the dictionary */ |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1702 ret = 0; |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1703 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1704 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1705 case DICT_APPLICATION: |
952
17ac99255475
Be explicit which entry already exists in the dictionary.
Thomas Klausner <tk@giga.or.at>
parents:
949
diff
changeset
|
1706 TRACE_DEBUG(FULL, "Application %s already in dictionary", new->data.application.application_name); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1707 /* got same id */ |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1708 if (fd_os_cmp(locref->data.application.application_name, locref->datastr_len, |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
1709 new->data.application.application_name, new->datastr_len)) { |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1710 TRACE_DEBUG(FULL, "Conflicting application name"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1711 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1712 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1713 ret = 0; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1714 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1715 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1716 case DICT_TYPE: |
952
17ac99255475
Be explicit which entry already exists in the dictionary.
Thomas Klausner <tk@giga.or.at>
parents:
949
diff
changeset
|
1717 TRACE_DEBUG(FULL, "Type %s already in dictionary", new->data.type.type_name); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1718 /* got same name */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1719 if (locref->data.type.type_base != new->data.type.type_base) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1720 TRACE_DEBUG(FULL, "Conflicting base type"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1721 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1722 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1723 /* discard new definition only it a callback is provided and different from the previous one */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1724 if ((new->data.type.type_interpret) && (locref->data.type.type_interpret != new->data.type.type_interpret)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1725 TRACE_DEBUG(FULL, "Conflicting interpret cb"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1726 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1727 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1728 if ((new->data.type.type_encode) && (locref->data.type.type_encode != new->data.type.type_encode)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1729 TRACE_DEBUG(FULL, "Conflicting encode cb"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1730 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1731 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1732 if ((new->data.type.type_dump) && (locref->data.type.type_dump != new->data.type.type_dump)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1733 TRACE_DEBUG(FULL, "Conflicting dump cb"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1734 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1735 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1736 ret = 0; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1737 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1738 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1739 case DICT_ENUMVAL: |
952
17ac99255475
Be explicit which entry already exists in the dictionary.
Thomas Klausner <tk@giga.or.at>
parents:
949
diff
changeset
|
1740 TRACE_DEBUG(FULL, "Enum %s already in dictionary", new->data.enumval.enum_name); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1741 /* got either same name or same value. We check that both are true */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1742 if (order_enum_by_name(locref, new)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1743 TRACE_DEBUG(FULL, "Conflicting enum name"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1744 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1745 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1746 if (order_enum_by_val(locref, new)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1747 TRACE_DEBUG(FULL, "Conflicting enum value"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1748 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1749 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1750 ret = 0; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1751 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1752 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1753 case DICT_AVP: |
952
17ac99255475
Be explicit which entry already exists in the dictionary.
Thomas Klausner <tk@giga.or.at>
parents:
949
diff
changeset
|
1754 TRACE_DEBUG(FULL, "AVP %s already in dictionary", new->data.avp.avp_name); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1755 /* got either same name or code */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1756 if (order_avp_by_code(locref, new)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1757 TRACE_DEBUG(FULL, "Conflicting AVP code"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1758 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1759 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1760 if (order_avp_by_name(locref, new)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1761 TRACE_DEBUG(FULL, "Conflicting AVP name"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1762 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1763 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1764 if (locref->data.avp.avp_vendor != new->data.avp.avp_vendor) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1765 TRACE_DEBUG(FULL, "Conflicting AVP vendor"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1766 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1767 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1768 if (locref->data.avp.avp_flag_mask != new->data.avp.avp_flag_mask) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1769 TRACE_DEBUG(FULL, "Conflicting AVP flags mask"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1770 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1771 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1772 if ((locref->data.avp.avp_flag_val & locref->data.avp.avp_flag_mask) != (new->data.avp.avp_flag_val & new->data.avp.avp_flag_mask)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1773 TRACE_DEBUG(FULL, "Conflicting AVP flags value"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1774 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1775 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1776 if (locref->data.avp.avp_basetype != new->data.avp.avp_basetype) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1777 TRACE_DEBUG(FULL, "Conflicting AVP base type"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1778 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1779 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1780 ret = 0; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1781 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1782 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1783 case DICT_COMMAND: |
952
17ac99255475
Be explicit which entry already exists in the dictionary.
Thomas Klausner <tk@giga.or.at>
parents:
949
diff
changeset
|
1784 TRACE_DEBUG(FULL, "Command %s already in dictionary", new->data.cmd.cmd_name); |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1785 /* We got either same name, or same code + R flag */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1786 if (order_cmd_by_name(locref, new)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1787 TRACE_DEBUG(FULL, "Conflicting command name"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1788 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1789 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1790 if (locref->data.cmd.cmd_code != new->data.cmd.cmd_code) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1791 TRACE_DEBUG(FULL, "Conflicting command code"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1792 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1793 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1794 if (locref->data.cmd.cmd_flag_mask != new->data.cmd.cmd_flag_mask) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1795 TRACE_DEBUG(FULL, "Conflicting command flags mask %hhx:%hhx", locref->data.cmd.cmd_flag_mask, new->data.cmd.cmd_flag_mask); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1796 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1797 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1798 if ((locref->data.cmd.cmd_flag_val & locref->data.cmd.cmd_flag_mask) != (new->data.cmd.cmd_flag_val & new->data.cmd.cmd_flag_mask)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1799 TRACE_DEBUG(FULL, "Conflicting command flags value"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1800 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1801 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1802 ret = 0; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1803 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1804 |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1805 case DICT_RULE: |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
1806 /* Both rules point to the same AVPs (code & vendor) */ |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1807 if (locref->data.rule.rule_position != new->data.rule.rule_position) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1808 TRACE_DEBUG(FULL, "Conflicting rule position"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1809 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1810 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1811 if ( ((locref->data.rule.rule_position == RULE_FIXED_HEAD) || |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1812 (locref->data.rule.rule_position == RULE_FIXED_TAIL)) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1813 && (locref->data.rule.rule_order != new->data.rule.rule_order)) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1814 TRACE_DEBUG(FULL, "Conflicting rule order"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1815 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1816 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1817 if (locref->data.rule.rule_min != new->data.rule.rule_min) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1818 int r1 = locref->data.rule.rule_min; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1819 int r2 = new->data.rule.rule_min; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1820 int p = locref->data.rule.rule_position; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1821 if ( ((r1 != -1) && (r2 != -1)) /* none of the definitions contains the "default" value */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1822 || ((p == RULE_OPTIONAL) && (r1 != 0) && (r2 != 0)) /* the other value is not 0 for an optional rule */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1823 || ((r1 != 1) && (r2 != 1)) /* the other value is not 1 for another rule */ |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1824 ) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1825 TRACE_DEBUG(FULL, "Conflicting rule min"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1826 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1827 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1828 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1829 if (locref->data.rule.rule_max != new->data.rule.rule_max) { |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1830 TRACE_DEBUG(FULL, "Conflicting rule max"); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1831 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1832 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1833 ret = 0; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1834 break; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1835 } |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1836 if (!ret) { |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1837 TRACE_DEBUG(FULL, "An existing object with the same data was found, ignoring the error..."); |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1838 } |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1839 if (ref) |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1840 *ref = locref; |
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
602
diff
changeset
|
1841 } |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1842 all_errors: |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1843 if (ret != 0) { |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1844 char * buf = NULL; |
1121
ccbd1426e04a
Improve testmesg_stress to measure impact of loaded dictionary
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
1845 size_t len = 0, offset=0; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1846 |
1121
ccbd1426e04a
Improve testmesg_stress to measure impact of loaded dictionary
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
1847 if (type == DICT_ENUMVAL) { |
ccbd1426e04a
Improve testmesg_stress to measure impact of loaded dictionary
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
1848 CHECK_MALLOC( dump_enumval_data ( &buf, &len, &offset, data, parent->data.type.type_base )); |
ccbd1426e04a
Improve testmesg_stress to measure impact of loaded dictionary
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
1849 } else { |
ccbd1426e04a
Improve testmesg_stress to measure impact of loaded dictionary
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
1850 CHECK_MALLOC( dict_obj_info[CHECK_TYPE(type) ? type : 0].dump_data(&buf, &len, &offset, data) ); |
ccbd1426e04a
Improve testmesg_stress to measure impact of loaded dictionary
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
1851 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1852 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1853 TRACE_DEBUG(INFO, "An error occurred while adding the following data in the dictionary: %s", buf); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1854 |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1855 if (ret == EEXIST) { |
1121
ccbd1426e04a
Improve testmesg_stress to measure impact of loaded dictionary
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
1856 offset=0; |
ccbd1426e04a
Improve testmesg_stress to measure impact of loaded dictionary
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1119
diff
changeset
|
1857 CHECK_MALLOC( dump_object(&buf, &len, &offset, locref, 0, 0, 0) ); |
1085
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1858 TRACE_DEBUG(INFO, "Conflicting entry in the dictionary: %s", buf); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1859 } |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1860 free(buf); |
7d7266115a34
Cleaning of the traces in progress
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1052
diff
changeset
|
1861 } |
0 | 1862 error_free: |
1863 free(new); | |
1864 return ret; | |
1865 } | |
1866 | |
778
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1867 |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1868 int fd_dict_delete(struct dict_object * obj) |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1869 { |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1870 int i; |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1871 struct dictionary * dict; |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1872 int ret=0; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1873 |
778
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1874 /* check params */ |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1875 CHECK_PARAMS( verify_object(obj) && obj->dico); |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1876 dict = obj->dico; |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1877 |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1878 /* Lock the dictionary for change */ |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1879 CHECK_POSIX( pthread_rwlock_wrlock(&dict->dict_lock) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1880 |
778
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1881 /* check the object is not sentinel for another list */ |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1882 for (i=0; i<NB_LISTS_PER_OBJ; i++) { |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1883 if (!_OBINFO(obj).haslist[i] && !(FD_IS_LIST_EMPTY(&obj->list[i]))) { |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1884 /* There are children, this is not good */ |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1885 ret = EINVAL; |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1886 TRACE_DEBUG (FULL, "Cannot delete object, list %d not empty:", i); |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1887 #if 0 |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1888 dump_list(&obj->list[i], 0,0,0); |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1889 #endif |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1890 break; |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1891 } |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1892 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1893 |
778
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1894 /* ok, now destroy the object */ |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1895 if (!ret) |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1896 destroy_object(obj); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1897 |
778
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1898 /* Unlock */ |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1899 CHECK_POSIX( pthread_rwlock_unlock(&dict->dict_lock) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1900 |
778
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1901 return ret; |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1902 } |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1903 |
003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
770
diff
changeset
|
1904 |
907
b772af200865
Add a few const declaration so that C++ is less picky
Sebastien Decugis <sdecugis@freediameter.net>
parents:
906
diff
changeset
|
1905 int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, const void * what, struct dict_object **result, int retval ) |
0 | 1906 { |
1907 int ret = 0; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1908 |
0 | 1909 TRACE_ENTRY("%p %d(%s) %d %p %p %d", dict, type, dict_obj_info[CHECK_TYPE(type) ? type : 0].name, criteria, what, result, retval); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1910 |
0 | 1911 /* Check param */ |
1912 CHECK_PARAMS( dict && (dict->dict_eyec == DICT_EYECATCHER) && CHECK_TYPE(type) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1913 |
0 | 1914 /* Lock the dictionary for reading */ |
1915 CHECK_POSIX( pthread_rwlock_rdlock(&dict->dict_lock) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1916 |
0 | 1917 /* Now call the type-specific search function */ |
1918 ret = dict_obj_info[type].search_fct (dict, criteria, what, result); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1919 |
0 | 1920 /* Unlock */ |
1921 CHECK_POSIX( pthread_rwlock_unlock(&dict->dict_lock) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1922 |
0 | 1923 /* Update the return value as needed */ |
1924 if ((result != NULL) && (*result == NULL)) | |
1925 ret = retval; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1926 |
0 | 1927 return ret; |
1928 } | |
1929 | |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1930 /* Function to retrieve list of objects in the dictionary. Use with care (read only). |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1931 |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1932 All returned list must be accessed like this: |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1933 |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1934 for (li = sentinel->next; li != sentinel; li=li->next) { |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1935 struct dict_object * obj = li->o; |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1936 ... |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1937 } |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1938 |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1939 The following criteria are allowed, with corresponding parent. |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1940 The parent is either struct dictionary * or struct dict_object * |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1941 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1942 VENDOR_BY_ID : (parent = dictionary) returns list of vendors ordered by ID |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1943 APPLICATION_BY_ID : (parent = dictionary) returns list of applications ordered by ID |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1944 ** for these two lists, the Vendor with id 0 and applciation with id 0 are excluded. |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1945 You must resolve them separatly with dict_search. |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1946 |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1947 TYPE_BY_NAME : (parent = dictionary) returns list of types ordered by name (osstring order) |
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1948 ENUMVAL_BY_NAME : (parent = type object) return list of constants for this type ordered by name (osstring order) |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1949 ENUMVAL_BY_VALUE : (parent = type object) return list of constants for this type ordered by values |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1950 AVP_BY_NAME : (parent = vendor object) return list of AVP for this vendor ordered by name (osstring order) |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1951 AVP_BY_CODE : (parent = vendor object) return list of AVP for this vendor ordered by code |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1952 CMD_BY_NAME : (parent = dictionary) returns list of commands ordered by name (osstring order) |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1953 CMD_BY_CODE_R : (parent = dictionary) returns list of commands ordered by code |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1954 RULE_BY_AVP_AND_PARENT: (parent = command or grouped AVP object) return list of rules for this object ordered by AVP vendor/code |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1955 |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1956 All other criteria are rejected. |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1957 */ |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1958 int fd_dict_getlistof(int criteria, void * parent, struct fd_list ** sentinel) |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1959 { |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1960 struct dictionary * dict = parent; |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1961 struct dict_object * obj_parent = parent; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1962 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1963 TRACE_ENTRY("%i %p %p", criteria, parent, sentinel); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1964 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1965 CHECK_PARAMS(sentinel && parent); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1966 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1967 switch(criteria) { |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1968 case VENDOR_BY_ID: /* parent must be the dictionary */ |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1969 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1970 *sentinel = &dict->dict_vendors.list[0]; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1971 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1972 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1973 case APPLICATION_BY_ID: /* parent must be the dictionary */ |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1974 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1975 *sentinel = &dict->dict_applications.list[0]; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1976 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1977 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1978 case TYPE_BY_NAME: /* parent must be the dictionary */ |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1979 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1980 *sentinel = &dict->dict_types; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1981 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1982 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1983 case ENUMVAL_BY_NAME: /* parent must be a type object */ |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1984 CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_TYPE)); |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1985 *sentinel = &obj_parent->list[1]; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1986 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1987 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1988 case ENUMVAL_BY_VALUE: /* parent must be a type object */ |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1989 CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_TYPE)); |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1990 *sentinel = &obj_parent->list[2]; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1991 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1992 |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1993 case AVP_BY_NAME: /* parent must be a VENDOR object */ |
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1994 CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_VENDOR)); |
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1995 *sentinel = &obj_parent->list[2]; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
1996 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
1997 |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1998 case AVP_BY_CODE: /* parent must be a VENDOR object */ |
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
1999 CHECK_PARAMS(verify_object(obj_parent) && (obj_parent->type == DICT_VENDOR)); |
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
2000 *sentinel = &obj_parent->list[1]; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2001 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2002 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2003 case CMD_BY_NAME: /* parent must be the dictionary */ |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2004 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
2005 *sentinel = &dict->dict_cmd_name; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2006 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2007 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2008 case CMD_BY_CODE_R: /* parent must be the dictionary */ |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2009 CHECK_PARAMS(dict->dict_eyec == DICT_EYECATCHER); |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
2010 *sentinel = &dict->dict_cmd_code; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2011 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2012 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2013 case RULE_BY_AVP_AND_PARENT: /* parent must be command or grouped AVP */ |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2014 CHECK_PARAMS(verify_object(obj_parent)); |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2015 CHECK_PARAMS( (obj_parent->type == DICT_COMMAND) || |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2016 ((obj_parent->type == DICT_AVP) |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2017 && (obj_parent->data.avp.avp_basetype == AVP_TYPE_GROUPED)) ); |
769
99136ec7d9d4
Fixed fd_dict_getlistof function, added a simple test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
764
diff
changeset
|
2018 *sentinel = &obj_parent->list[2]; |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2019 break; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2020 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2021 default: |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2022 CHECK_PARAMS(0); |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2023 } |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2024 |
764
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2025 return 0; |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2026 } |
f53e5b5fdfd3
Added new experimental function fd_dict_getlistof -- see http://lists.freediameter.net/pipermail/help/2011-October/000268.html for context and rationale. WARNING: this function was not tested yet...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
2027 |
0 | 2028 /*******************************************************************************************************/ |
2029 /*******************************************************************************************************/ | |
2030 /* */ | |
2031 /* The init/fini functions */ | |
2032 /* */ | |
2033 /*******************************************************************************************************/ | |
2034 /*******************************************************************************************************/ | |
2035 | |
2036 /* Initialize the dictionary */ | |
2037 int fd_dict_init ( struct dictionary ** dict) | |
2038 { | |
2039 struct dictionary * new = NULL; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2040 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2041 TRACE_ENTRY("%p", dict); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2042 |
0 | 2043 /* Sanity checks */ |
2044 ASSERT( (sizeof(type_base_name) / sizeof(type_base_name[0])) == (AVP_TYPE_MAX + 1) ); | |
2045 ASSERT( (sizeof(dict_obj_info) / sizeof(dict_obj_info[0])) == (DICT_TYPE_MAX + 1) ); | |
2046 CHECK_PARAMS(dict); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2047 |
0 | 2048 /* Allocate the memory for the dictionary */ |
2049 CHECK_MALLOC( new = malloc(sizeof(struct dictionary)) ); | |
2050 memset(new, 0, sizeof(struct dictionary)); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2051 |
0 | 2052 new->dict_eyec = DICT_EYECATCHER; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2053 |
0 | 2054 /* Initialize the lock for the dictionary */ |
2055 CHECK_POSIX( pthread_rwlock_init(&new->dict_lock, NULL) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2056 |
0 | 2057 /* Initialize the sentinel for vendors and AVP lists */ |
2058 init_object( &new->dict_vendors, DICT_VENDOR ); | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2059 #define NO_VENDOR_NAME "(no vendor)" |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2060 new->dict_vendors.data.vendor.vendor_name = NO_VENDOR_NAME; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2061 new->dict_vendors.datastr_len = CONSTSTRLEN(NO_VENDOR_NAME); |
770
27fef2ca2cf6
Improved usability of fd_dict_getlistof for vendors and apps
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
769
diff
changeset
|
2062 /* new->dict_vendors.list[0].o = NULL; *//* overwrite since element is also sentinel for this list. */ |
111
3b6174b6b35b
Fix fd_dict_getdict command for sentinels in the dictionary
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
109
diff
changeset
|
2063 new->dict_vendors.dico = new; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2064 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
7
diff
changeset
|
2065 /* Initialize the sentinel for applications */ |
0 | 2066 init_object( &new->dict_applications, DICT_APPLICATION ); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2067 #define APPLICATION_0_NAME "Diameter Common Messages" |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2068 new->dict_applications.data.application.application_name = APPLICATION_0_NAME; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2069 new->dict_applications.datastr_len = CONSTSTRLEN(APPLICATION_0_NAME); |
770
27fef2ca2cf6
Improved usability of fd_dict_getlistof for vendors and apps
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
769
diff
changeset
|
2070 /* new->dict_applications.list[0].o = NULL; *//* overwrite since since element is also sentinel for this list. */ |
111
3b6174b6b35b
Fix fd_dict_getdict command for sentinels in the dictionary
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
109
diff
changeset
|
2071 new->dict_applications.dico = new; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2072 |
0 | 2073 /* Initialize the sentinel for types */ |
2074 fd_list_init ( &new->dict_types, NULL ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2075 |
0 | 2076 /* Initialize the sentinels for commands */ |
2077 fd_list_init ( &new->dict_cmd_name, NULL ); | |
2078 fd_list_init ( &new->dict_cmd_code, NULL ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2079 |
0 | 2080 /* Initialize the error command object */ |
2081 init_object( &new->dict_cmd_error, DICT_COMMAND ); | |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2082 #define GENERIC_ERROR_NAME "(generic error format)" |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2083 new->dict_cmd_error.data.cmd.cmd_name = GENERIC_ERROR_NAME; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
687
diff
changeset
|
2084 new->dict_cmd_error.datastr_len = CONSTSTRLEN(GENERIC_ERROR_NAME); |
0 | 2085 new->dict_cmd_error.data.cmd.cmd_flag_mask=CMD_FLAG_ERROR | CMD_FLAG_REQUEST | CMD_FLAG_RETRANSMIT; |
2086 new->dict_cmd_error.data.cmd.cmd_flag_val =CMD_FLAG_ERROR; | |
111
3b6174b6b35b
Fix fd_dict_getdict command for sentinels in the dictionary
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
109
diff
changeset
|
2087 new->dict_cmd_error.dico = new; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2088 |
0 | 2089 *dict = new; |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2090 |
0 | 2091 /* Done */ |
2092 return 0; | |
2093 } | |
2094 | |
2095 /* Destroy a dictionary */ | |
2096 int fd_dict_fini ( struct dictionary ** dict) | |
2097 { | |
2098 int i; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2099 |
0 | 2100 TRACE_ENTRY(""); |
2101 CHECK_PARAMS( dict && *dict && ((*dict)->dict_eyec == DICT_EYECATCHER) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2102 |
0 | 2103 /* Acquire the write lock to make sure no other operation is ongoing */ |
2104 CHECK_POSIX( pthread_rwlock_wrlock(&(*dict)->dict_lock) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2105 |
0 | 2106 /* Empty all the lists, free the elements */ |
2107 destroy_list ( &(*dict)->dict_cmd_error.list[2] ); | |
2108 destroy_list ( &(*dict)->dict_cmd_code ); | |
2109 destroy_list ( &(*dict)->dict_cmd_name ); | |
2110 destroy_list ( &(*dict)->dict_types ); | |
2111 for (i=0; i< NB_LISTS_PER_OBJ; i++) { | |
2112 destroy_list ( &(*dict)->dict_applications.list[i] ); | |
2113 destroy_list ( &(*dict)->dict_vendors.list[i] ); | |
2114 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2115 |
0 | 2116 /* Dictionary is empty, now destroy the lock */ |
2117 CHECK_POSIX( pthread_rwlock_unlock(&(*dict)->dict_lock) ); | |
2118 CHECK_POSIX( pthread_rwlock_destroy(&(*dict)->dict_lock) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2119 |
0 | 2120 free(*dict); |
2121 *dict = NULL; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2122 |
0 | 2123 return 0; |
2124 } | |
2125 | |
2126 /*******************************************************************************************************/ | |
2127 /*******************************************************************************************************/ | |
2128 /* */ | |
2129 /* Other functions */ | |
2130 /* */ | |
2131 /*******************************************************************************************************/ | |
2132 /*******************************************************************************************************/ | |
2133 | |
2134 /* Iterate a callback on the rules for an object */ | |
2135 int fd_dict_iterate_rules ( struct dict_object *parent, void * data, int (*cb)(void *, struct dict_rule_data *) ) | |
2136 { | |
2137 int ret = 0; | |
2138 struct fd_list * li; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2139 |
0 | 2140 TRACE_ENTRY("%p %p %p", parent, data, cb); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2141 |
0 | 2142 /* Check parameters */ |
2143 CHECK_PARAMS( verify_object(parent) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2144 CHECK_PARAMS( (parent->type == DICT_COMMAND) |
0 | 2145 || ((parent->type == DICT_AVP) && (parent->data.avp.avp_basetype == AVP_TYPE_GROUPED)) ); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2146 TRACE_DEBUG (FULL, "Iterating on rules of %s: '%s'.", |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2147 _OBINFO(parent).name, |
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2148 parent->type == DICT_COMMAND ? |
0 | 2149 parent->data.cmd.cmd_name |
2150 : parent->data.avp.avp_name); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2151 |
0 | 2152 /* Acquire the read lock */ |
2153 CHECK_POSIX( pthread_rwlock_rdlock(&parent->dico->dict_lock) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2154 |
0 | 2155 /* go through the list and call the cb on each rule data */ |
2156 for (li = &(parent->list[2]); li->next != &(parent->list[2]); li = li->next) { | |
2157 ret = (*cb)(data, &(_O(li->next->o)->data.rule)); | |
2158 if (ret != 0) | |
2159 break; | |
2160 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2161 |
0 | 2162 /* Release the lock */ |
2163 CHECK_POSIX( pthread_rwlock_unlock(&parent->dico->dict_lock) ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2164 |
0 | 2165 return ret; |
2166 } | |
2167 | |
2168 /* Create the list of vendors. Returns a 0-terminated array, that must be freed after use. Returns NULL on error. */ | |
2169 uint32_t * fd_dict_get_vendorid_list(struct dictionary * dict) | |
2170 { | |
2171 uint32_t * ret = NULL; | |
2172 int i = 0; | |
2173 struct fd_list * li; | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2174 |
0 | 2175 TRACE_ENTRY(); |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2176 |
0 | 2177 /* Acquire the read lock */ |
2178 CHECK_POSIX_DO( pthread_rwlock_rdlock(&dict->dict_lock), return NULL ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2179 |
0 | 2180 /* Allocate an array to contain all the elements */ |
2181 CHECK_MALLOC_DO( ret = calloc( dict->dict_count[DICT_VENDOR] + 1, sizeof(uint32_t) ), goto out ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2182 |
0 | 2183 /* Copy the vendors IDs */ |
2184 for (li = dict->dict_vendors.list[0].next; li != &(dict->dict_vendors.list[0]); li = li->next) { | |
2185 ret[i] = _O(li->o)->data.vendor.vendor_id; | |
2186 i++; | |
2187 ASSERT( i <= dict->dict_count[DICT_VENDOR] ); | |
2188 } | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2189 out: |
0 | 2190 /* Release the lock */ |
2191 CHECK_POSIX_DO( pthread_rwlock_unlock(&dict->dict_lock), return NULL ); | |
1451
6c3485887511
Move some structures to a header file for use by dbg_dict_dump_json.
Thomas Klausner <tk@giga.or.at>
parents:
1444
diff
changeset
|
2192 |
0 | 2193 return ret; |
2194 } | |
2195 | |
2196 /* Return the location of the cb list for an object, after checking its type */ | |
2197 int fd_dict_disp_cb(enum dict_object_type type, struct dict_object *obj, struct fd_list ** cb_list) | |
2198 { | |
2199 TRACE_ENTRY("%d %p %p", type, obj, cb_list); | |
2200 CHECK_PARAMS( verify_object(obj) ); | |
2201 CHECK_PARAMS( _OBINFO(obj).type == type ); | |
2202 CHECK_PARAMS( cb_list ); | |
2203 *cb_list = &obj->disp_cbs; | |
2204 return 0; | |
2205 } | |
2206 | |
2207 int fd_dict_get_error_cmd(struct dictionary * dict, struct dict_object **obj) | |
2208 { | |
2209 TRACE_ENTRY("%p %p", dict, obj); | |
2210 CHECK_PARAMS( dict && (dict->dict_eyec == DICT_EYECATCHER) && obj ); | |
2211 *obj = &dict->dict_cmd_error; | |
2212 return 0; | |
2213 } |