/src/wireshark/epan/uat.h
Line | Count | Source |
1 | | /** @file |
2 | | * |
3 | | * User Accessible Tables |
4 | | * Maintain an array of user accessible data structures |
5 | | * |
6 | | * (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org> |
7 | | * |
8 | | * Wireshark - Network traffic analyzer |
9 | | * By Gerald Combs <gerald@wireshark.org> |
10 | | * Copyright 2001 Gerald Combs |
11 | | * |
12 | | * SPDX-License-Identifier: GPL-2.0-or-later |
13 | | */ |
14 | | #pragma once |
15 | | #include <stdlib.h> |
16 | | |
17 | | #include "ws_symbol_export.h" |
18 | | #include <wsutil/strtoi.h> |
19 | | #include <wsutil/dtoa.h> |
20 | | |
21 | | #ifdef __cplusplus |
22 | | extern "C" { |
23 | | #endif /* __cplusplus */ |
24 | | |
25 | | /* |
26 | | * UAT maintains a dynamically allocated table accessible to the user |
27 | | * via a file and/or via GUI preference dialogs. |
28 | | * |
29 | | * The file is read from and written in the personal configuration directory. If |
30 | | * there is no such file, defaults will be loaded from the global data |
31 | | * directory. |
32 | | * |
33 | | * The behaviour of the table is controlled by a series of callbacks which |
34 | | * the caller (e.g. a dissector) must provide. |
35 | | * |
36 | | * BEWARE that the user can change an UAT at (almost) any time (via the GUI). |
37 | | * That is, pointers to records in an UAT are valid only during the call |
38 | | * to the function that obtains them (do not store pointers to these records). |
39 | | * The records contents are only guaranteed to be valid in the post_update_cb |
40 | | * function. (Implementation detail: currently a race condition is possible |
41 | | * where the UAT consumer (dissector code) tries to use the UAT while the GUI |
42 | | * user frees a record resulting in use-after-free. This is not ideal and might |
43 | | * be fixed later.) |
44 | | * |
45 | | * UATs are meant for short tables of user data (passwords and such), there is |
46 | | * no quick access, you must iterate through them each time to fetch the record |
47 | | * you are looking for. |
48 | | * |
49 | | * Only users via GUI or editing the file can add/remove records, your |
50 | | * (dissector) code cannot. |
51 | | */ |
52 | | |
53 | | /* opaque data type to handle an uat */ |
54 | | typedef struct epan_uat uat_t; |
55 | | /******************************************** |
56 | | * Callbacks: |
57 | | * these instruct uat on how to deal with user info and data in records |
58 | | ********************************************/ |
59 | | |
60 | | /******** |
61 | | * Callbacks dealing with the entire table |
62 | | ********/ |
63 | | |
64 | | /* |
65 | | * Post-Update CB |
66 | | * |
67 | | * To be called by the GUI code after to the table has being edited. |
68 | | * Will be called once the user clicks the Apply or OK button |
69 | | * optional |
70 | | */ |
71 | | typedef void (*uat_post_update_cb_t)(void); |
72 | | |
73 | | |
74 | | /******** |
75 | | * Callbacks dealing with records (these deal with entire records) |
76 | | ********/ |
77 | | |
78 | | /** |
79 | | * Copy CB |
80 | | * copy(dest, source, len) |
81 | | * |
82 | | * Used to duplicate the contents of one record to another. |
83 | | * Optional, memcpy will be used if not given. |
84 | | */ |
85 | | typedef void* (*uat_copy_cb_t)(void *dest, const void *source, size_t len); |
86 | | |
87 | | /** |
88 | | * Free CB |
89 | | * free(record) |
90 | | * |
91 | | * Destroy the contents of a record, possibly freeing some fields. |
92 | | * Do not free the container itself, this memory is owned by the UAT core. |
93 | | * Optional if the record contains no pointers that need to be freed. |
94 | | */ |
95 | | typedef void (*uat_free_cb_t)(void *record); |
96 | | |
97 | | /** |
98 | | * Reset DB |
99 | | * |
100 | | * Used to free resources associated with a UAT loaded from file (e.g. post_update_cb) |
101 | | * Optional. |
102 | | */ |
103 | | typedef void (*uat_reset_cb_t)(void); |
104 | | |
105 | | /** |
106 | | * Update CB |
107 | | * update(record,&error) |
108 | | * |
109 | | * Validates the contents of the record contents, to be called after any record |
110 | | * fields had been updated (either from file or after modifications in the GUI). |
111 | | * |
112 | | * Optional, the record will be considered valid if the callback is omitted. |
113 | | * It must return true if the contents are considered valid and false otherwise |
114 | | * in which case the failure reason is set in 'error'. The error string will be |
115 | | * freed by g_free. |
116 | | * |
117 | | * XXX: This should only validate the record. Any changes to the record |
118 | | * made here will *not* be persistent if the UAT is saved again, unless |
119 | | * the same changes are also done to a new record created by the copy cb, |
120 | | * e.g. by having the the copy callback call this. |
121 | | * It should probably be made into a const void* to make that clear. |
122 | | */ |
123 | | typedef bool (*uat_update_cb_t)(void *record, char **error); |
124 | | |
125 | | |
126 | | /******* |
127 | | * Callbacks for single fields (these deal with single values) |
128 | | * the caller should provide one of these for every field! |
129 | | ********/ |
130 | | |
131 | | /* |
132 | | * Check CB |
133 | | * chk(record, ptr, len, chk_data, fld_data, &error) |
134 | | * |
135 | | * given an input string (ptr, len) checks if the value is OK for a field in the record. |
136 | | * it will return true if OK or else |
137 | | * it will return false and set *error to inform the user on what's |
138 | | * wrong with the given input |
139 | | * The error string must be allocated with g_malloc() or |
140 | | * a routine that calls it. |
141 | | * optional, if not given any input is considered OK and the set cb will be called |
142 | | */ |
143 | | typedef bool (*uat_fld_chk_cb_t)(void *record, const char *ptr, unsigned len, const void *chk_data, const void *fld_data, char **error); |
144 | | |
145 | | /* |
146 | | * Set Field CB |
147 | | * set(record, ptr, len, set_data, fld_data) |
148 | | * |
149 | | * given an input string (ptr, len) sets the value of a field in the record, |
150 | | * it is mandatory |
151 | | */ |
152 | | typedef void (*uat_fld_set_cb_t)(void *record, const char *ptr, unsigned len, const void *set_data, const void *fld_data); |
153 | | |
154 | | /* |
155 | | * Convert-to-string CB |
156 | | * tostr(record, &out_ptr, &out_len, tostr_data, fld_data) |
157 | | * |
158 | | * given a record returns a string representation of the field |
159 | | * mandatory |
160 | | */ |
161 | | typedef void (*uat_fld_tostr_cb_t)(void *record, char **out_ptr, unsigned *out_len, const void *tostr_data, const void *fld_data); |
162 | | |
163 | | /*********** |
164 | | * Text Mode |
165 | | * |
166 | | * used for file and dialog representation of fields in columns, |
167 | | * when the file is read it modifies the way the value is passed back to the fld_set_cb |
168 | | * (see definition bellow for description) |
169 | | ***********/ |
170 | | |
171 | | /** |
172 | | * @brief Controls how a UAT (User Accessible Table) field is rendered and parsed |
173 | | * in both the preferences file and the GUI editor dialog. |
174 | | */ |
175 | | typedef enum _uat_text_mode_t { |
176 | | PT_TXTMOD_NONE, |
177 | | /* not used */ |
178 | | |
179 | | PT_TXTMOD_STRING, |
180 | | /* |
181 | | file: |
182 | | reads: |
183 | | ,"\x20\x00\x30", as " \00",3 ("space nil zero" of length 3) |
184 | | ,"", as "",0 |
185 | | ,, as NULL,0 |
186 | | writes: |
187 | | ,"\x20\x30\x00\x20", for " 0\0 ",4 |
188 | | ,"", for *, 0 |
189 | | ,, for NULL, * |
190 | | dialog: |
191 | | accepts \x?? and other escapes |
192 | | gets "",0 on empty string |
193 | | */ |
194 | | PT_TXTMOD_HEXBYTES, |
195 | | /* |
196 | | file: |
197 | | reads: |
198 | | ,A1b2C3d4, as "\xa1\xb2\xc3\xd4",4 |
199 | | ,, as NULL,0 |
200 | | writes: |
201 | | ,, on NULL, * |
202 | | ,a1b2c3d4, on "\xa1\xb2\xc3\xd4",4 |
203 | | dialog: |
204 | | interprets the following input ... as ...: |
205 | | "a1b2c3d4" as "\xa1\xb2\xc3\xd4",4 |
206 | | "a1 b2:c3d4" as "\xa1\xb2\xc3\xd4",4 |
207 | | "" as NULL,0 |
208 | | "invalid" as NULL,3 |
209 | | "a1b" as NULL, 1 |
210 | | */ |
211 | | PT_TXTMOD_ENUM, |
212 | | /* Read/Writes/displays the string value (not number!) */ |
213 | | PT_TXTMOD_DISSECTOR, |
214 | | /* Shows a combobox of dissectors */ |
215 | | |
216 | | PT_TXTMOD_COLOR, |
217 | | /* Reads/Writes/display color in #RRGGBB format */ |
218 | | |
219 | | PT_TXTMOD_FILENAME, |
220 | | /* processed like a PT_TXTMOD_STRING, but shows a filename dialog */ |
221 | | PT_TXTMOD_DIRECTORYNAME, |
222 | | /* processed like a PT_TXTMOD_STRING, but shows a directory dialog */ |
223 | | PT_TXTMOD_DISPLAY_FILTER, |
224 | | /* processed like a PT_TXTMOD_STRING, but verifies display filter */ |
225 | | PT_TXTMOD_PROTO_FIELD, |
226 | | /* processed like a PT_TXTMOD_STRING, but verifies protocol field name (e.g tcp.flags.syn) */ |
227 | | PT_TXTMOD_BOOL |
228 | | /* Displays a checkbox for value */ |
229 | | } uat_text_mode_t; |
230 | | |
231 | | /** |
232 | | * @brief Describes a single editable field within a UAT (User Accessible Table). |
233 | | */ |
234 | | typedef struct _uat_field_t { |
235 | | const char *name; /**< Internal name of the field, used as the key in the preferences file */ |
236 | | const char *title; /**< Human-readable column header label shown in the UAT editor dialog */ |
237 | | uat_text_mode_t mode; /**< Controls how the field value is rendered, parsed, and edited */ |
238 | | |
239 | | /** @brief Callbacks for validating, applying, and serializing this field's value. */ |
240 | | struct { |
241 | | uat_fld_chk_cb_t chk; /**< Validation callback; returns false and sets an error message if the value is invalid */ |
242 | | uat_fld_set_cb_t set; /**< Apply callback; writes a parsed value into the UAT record struct */ |
243 | | uat_fld_tostr_cb_t tostr; /**< Serialization callback; converts the field's current value to a string for display and file output */ |
244 | | } cb; |
245 | | |
246 | | /** @brief Opaque context pointers passed as auxiliary data to each corresponding callback. */ |
247 | | struct { |
248 | | const void *chk; /**< Auxiliary data pointer passed to @ref cb.chk */ |
249 | | const void *set; /**< Auxiliary data pointer passed to @ref cb.set */ |
250 | | const void *tostr; /**< Auxiliary data pointer passed to @ref cb.tostr */ |
251 | | } cbdata; |
252 | | |
253 | | const void *fld_data; /**< Pointer to static field-type metadata (e.g., an enum_val_t array for PT_TXTMOD_ENUM) */ |
254 | | const char *desc; /**< Tooltip or help text describing the field's purpose, shown in the UAT editor */ |
255 | | struct _fld_data_t *priv; /**< Internal private state managed by the UAT framework; not for use by dissectors */ |
256 | | } uat_field_t; |
257 | | |
258 | 8.79k | #define FLDFILL NULL |
259 | 1.78k | #define UAT_END_FIELDS {NULL,NULL,PT_TXTMOD_NONE,{0,0,0},{0,0,0},0,0,FLDFILL} |
260 | | |
261 | | /* |
262 | | * Flags to indicate what the settings in this UAT affect. |
263 | | * This is used when UATs are changed interactively, to indicate what needs |
264 | | * to be redone when the UAT is changed. |
265 | | * |
266 | | * UAT_AFFECTS_FIELDS does *not* trigger a redissection, so usually one |
267 | | * will also want UAT_AFFECTS_DISSECTION. A rare exception is changing |
268 | | * the defined dfilter macros. |
269 | | */ |
270 | 1.92k | #define UAT_AFFECTS_DISSECTION 0x00000001 /* affects packet dissection */ |
271 | 330 | #define UAT_AFFECTS_FIELDS 0x00000002 /* affects what named fields exist */ |
272 | | |
273 | | /** Create a new UAT. |
274 | | * |
275 | | * @param name The name of the table |
276 | | * @param size The size of the structure |
277 | | * @param filename The filename to be used (either in userdir or datadir) |
278 | | * @param from_profile true if profile directory to be used |
279 | | * @param data_ptr Although a void*, this is really a pointer to a null terminated array of pointers to the data |
280 | | * @param num_items_ptr A pointer with number of items |
281 | | * @param flags flags indicating what this UAT affects |
282 | | * @param help A pointer to the name of a Users Guide section |
283 | | * @param copy_cb A function that copies the data in the struct |
284 | | * @param update_cb Will be called when a record is updated |
285 | | * @param free_cb Will be called to destroy a struct in the dataset |
286 | | * @param post_update_cb Will be called once the user clicks the Apply or OK button |
287 | | * @param reset_cb Will be called to destroy internal data |
288 | | * @param flds_array A pointer to an array of uat_field_t structs |
289 | | * |
290 | | * @return A freshly-allocated and populated uat_t struct. |
291 | | */ |
292 | | WS_DLL_PUBLIC |
293 | | uat_t* uat_new(const char* name, |
294 | | size_t size, |
295 | | const char* filename, |
296 | | bool from_profile, |
297 | | void* data_ptr, |
298 | | unsigned* num_items_ptr, |
299 | | unsigned flags, |
300 | | const char* help, |
301 | | uat_copy_cb_t copy_cb, |
302 | | uat_update_cb_t update_cb, |
303 | | uat_free_cb_t free_cb, |
304 | | uat_post_update_cb_t post_update_cb, |
305 | | uat_reset_cb_t reset_cb, |
306 | | uat_field_t* flds_array); |
307 | | |
308 | | /** |
309 | | * @brief Free and deregister a single UAT. |
310 | | * @param uat The UAT to be destroyed. |
311 | | */ |
312 | | WS_DLL_PUBLIC |
313 | | void uat_destroy(uat_t *uat); |
314 | | |
315 | | /** |
316 | | * @brief Cleanup all UATs. |
317 | | * |
318 | | */ |
319 | | void uat_cleanup(void); |
320 | | |
321 | | /** |
322 | | * @brief Populate a UAT using its file. |
323 | | * |
324 | | * @param uat_in Pointer to a uat. Must not be NULL. |
325 | | * @param filename Filename to load, NULL to fetch from current profile. |
326 | | * @param app_env_var_prefix The prefix for the application environment variable used to get the personal config directory. |
327 | | * @param err Upon failure, points to an error string. |
328 | | * |
329 | | * @return true on success, false on failure. |
330 | | */ |
331 | | WS_DLL_PUBLIC |
332 | | bool uat_load(uat_t* uat_in, const char *filename, const char* app_env_var_prefix, char** err); |
333 | | |
334 | | /** |
335 | | * @brief Create or update a single UAT entry using a string. |
336 | | * |
337 | | * @param uat_in Pointer to a uat. Must not be NULL. |
338 | | * @param entry The string representation of the entry. Format must match |
339 | | * what's written to the uat's output file. |
340 | | * @param err Upon failure, points to an error string. |
341 | | * |
342 | | * @return true on success, false on failure. |
343 | | */ |
344 | | WS_DLL_PUBLIC |
345 | | bool uat_load_str(uat_t* uat_in, const char* entry, char** err); |
346 | | |
347 | | /** |
348 | | * @brief Given a UAT name or filename, find its pointer. |
349 | | * |
350 | | * @param name The name or filename of the uat |
351 | | * |
352 | | * @return A pointer to the uat on success, NULL on failure. |
353 | | */ |
354 | | uat_t *uat_find(char *name); |
355 | | |
356 | | /** |
357 | | * @brief Retrieve a UAT table by its name. |
358 | | * |
359 | | * @param name The name of the UAT table to retrieve. Must not be NULL. |
360 | | * @return Pointer to the UAT table if found, otherwise NULL. |
361 | | */ |
362 | | WS_DLL_PUBLIC |
363 | | uat_t* uat_get_table_by_name(const char* name); |
364 | | |
365 | | /** |
366 | | * Provide default field values for a UAT. |
367 | | * |
368 | | * This can be used to provide forward compatibility when fields are added |
369 | | * to a UAT. |
370 | | * |
371 | | * @param uat_in Pointer to a uat. Must not be NULL. |
372 | | * @param default_values An array of strings with default values. Must |
373 | | * be the same length as flds_array. Individual elements can be NULL, |
374 | | * and can be used to distinguish between mandatory and optional fields, |
375 | | * e.g. { NULL, NULL, NULL, "default value (optional)" } |
376 | | * @todo Use this to provide default values for empty tables. |
377 | | */ |
378 | | WS_DLL_PUBLIC |
379 | | void uat_set_default_values(uat_t *uat_in, const char *default_values[]); |
380 | | |
381 | | /* |
382 | | * Some common uat_fld_chk_cbs |
383 | | */ |
384 | | /** |
385 | | * @brief UAT field validator for generic string values. |
386 | | * |
387 | | * @param record Pointer to the UAT record being validated (unused). |
388 | | * @param ptr The NUL-terminated string value to validate. |
389 | | * @param len Length of @p ptr in bytes, not including the terminator. |
390 | | * @param chk_data Field-level checker data supplied at UAT field |
391 | | * registration time (unused). |
392 | | * @param fld_data Record-level field data (unused). |
393 | | * @param err On failure, receives a newly allocated human-readable |
394 | | * error string that the UAT framework will display and |
395 | | * then @c g_free(). Set to NULL on success. |
396 | | * @return true if the value is acceptable; false if validation failed and |
397 | | * @p *err has been set. |
398 | | */ |
399 | | WS_DLL_PUBLIC |
400 | | bool uat_fld_chk_str(void *record, const char *ptr, unsigned len, |
401 | | const void *chk_data, const void *fld_data, char **err); |
402 | | |
403 | | /** |
404 | | * @brief UAT field validator for ASN.1 Object Identifier strings. |
405 | | * |
406 | | * @param record Pointer to the UAT record being validated (unused). |
407 | | * @param ptr The NUL-terminated OID string to validate. |
408 | | * @param len Length of @p ptr in bytes, not including the terminator. |
409 | | * @param chk_data Field-level checker data supplied at UAT field |
410 | | * registration time (unused). |
411 | | * @param fld_data Record-level field data (unused). |
412 | | * @param err On failure, receives a newly allocated error string |
413 | | * describing the OID syntax violation. Set to NULL on |
414 | | * success. |
415 | | * @return true if @p ptr is a valid dotted-decimal OID; false otherwise. |
416 | | */ |
417 | | WS_DLL_PUBLIC |
418 | | bool uat_fld_chk_oid(void *record, const char *ptr, unsigned len, |
419 | | const void *chk_data, const void *fld_data, char **err); |
420 | | |
421 | | /** |
422 | | * @brief UAT field validator for Wireshark protocol name strings. |
423 | | * |
424 | | * @param record Pointer to the UAT record being validated (unused). |
425 | | * @param ptr The NUL-terminated protocol short name to validate |
426 | | * (e.g. @c "http", @c "tls"). |
427 | | * @param len Length of @p ptr in bytes, not including the terminator. |
428 | | * @param chk_data Field-level checker data supplied at UAT field |
429 | | * registration time (unused). |
430 | | * @param fld_data Record-level field data (unused). |
431 | | * @param err On failure, receives a newly allocated error string |
432 | | * stating that the protocol is unknown. Set to NULL on |
433 | | * success. |
434 | | * @return true if @p ptr names a registered protocol; false otherwise. |
435 | | */ |
436 | | WS_DLL_PUBLIC |
437 | | bool uat_fld_chk_proto(void *record, const char *ptr, unsigned len, |
438 | | const void *chk_data, const void *fld_data, char **err); |
439 | | |
440 | | /** |
441 | | * @brief Checks if a field name is valid. |
442 | | * |
443 | | * @param u1 User data pointer, not used in this function. |
444 | | * @param strptr String to check. |
445 | | * @param len Length of the string being checked. |
446 | | * @param u2 User data pointer, not used in this function. |
447 | | * @param u3 User data pointer, not used in this function. |
448 | | * @param err Error message buffer if an error occurs. |
449 | | * @return true if the field value is valid, false otherwise. |
450 | | */ |
451 | | WS_DLL_PUBLIC |
452 | | bool uat_fld_chk_field(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
453 | | |
454 | | /** |
455 | | * @brief Checks if a field value is a valid decimal number. |
456 | | * |
457 | | * @param u1 User data pointer, not used in this function. |
458 | | * @param strptr String to check. |
459 | | * @param len Length of the string being checked. |
460 | | * @param u2 User data pointer, not used in this function. |
461 | | * @param u3 User data pointer, not used in this function. |
462 | | * @param err Error message buffer if an error occurs. |
463 | | * @return true if the field value is valid, false otherwise. |
464 | | */ |
465 | | WS_DLL_PUBLIC |
466 | | bool uat_fld_chk_num_dec(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
467 | | |
468 | | /** |
469 | | * @brief Checks if a field value is a valid decimal 64-bit number. |
470 | | * |
471 | | * @param u1 User data pointer, not used in this function. |
472 | | * @param strptr String to check. |
473 | | * @param len Length of the string being checked. |
474 | | * @param u2 User data pointer, not used in this function. |
475 | | * @param u3 User data pointer, not used in this function. |
476 | | * @param err Error message buffer if an error occurs. |
477 | | * @return true if the field value is valid, false otherwise. |
478 | | */ |
479 | | WS_DLL_PUBLIC |
480 | | bool uat_fld_chk_num_dec64(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
481 | | |
482 | | /** |
483 | | * @brief Checks if a field contains a valid hexadecimal number. |
484 | | * |
485 | | * @param u1 User data pointer, not used in this function. |
486 | | * @param strptr String to check. |
487 | | * @param len Length of the string being checked. |
488 | | * @param u2 User data pointer, not used in this function. |
489 | | * @param u3 User data pointer, not used in this function. |
490 | | * @param err Error message buffer if an error occurs. |
491 | | * @return true if the field value is valid, false otherwise. |
492 | | */ |
493 | | WS_DLL_PUBLIC |
494 | | bool uat_fld_chk_num_hex(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
495 | | |
496 | | /** |
497 | | * @brief Check if a field contains a valid hexadecimal number. |
498 | | * |
499 | | * @param u1 User data pointer, not used in this function. |
500 | | * @param strptr String to check. |
501 | | * @param len Length of the string being checked. |
502 | | * @param u2 User data pointer, not used in this function. |
503 | | * @param u3 User data pointer, not used in this function. |
504 | | * @param err Error message buffer if an error occurs. |
505 | | * @return true if the field value is valid, false otherwise. |
506 | | */ |
507 | | WS_DLL_PUBLIC |
508 | | bool uat_fld_chk_num_hex64(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
509 | | |
510 | | /** |
511 | | * @brief Check if a field contains a signed decimal number. |
512 | | * |
513 | | * @param u1 User data pointer, not used in this function. |
514 | | * @param strptr String to check. |
515 | | * @param len Length of the string being checked. |
516 | | * @param u2 User data pointer, not used in this function. |
517 | | * @param u3 User data pointer, not used in this function. |
518 | | * @param err Error message buffer if an error occurs. |
519 | | * @return true if the field value is valid, false otherwise. |
520 | | */ |
521 | | WS_DLL_PUBLIC |
522 | | bool uat_fld_chk_num_signed_dec(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
523 | | |
524 | | /** |
525 | | * @brief Check if a field value is a signed decimal 64-bit number. |
526 | | * |
527 | | * @param u1 User data pointer, not used in this function. |
528 | | * @param strptr String to check. |
529 | | * @param len Length of the string being checked. |
530 | | * @param u2 User data pointer, not used in this function. |
531 | | * @param u3 User data pointer, not used in this function. |
532 | | * @param err Error message buffer if an error occurs. |
533 | | * @return true if the field value is valid, false otherwise. |
534 | | */ |
535 | | WS_DLL_PUBLIC |
536 | | bool uat_fld_chk_num_signed_dec64(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
537 | | |
538 | | /** |
539 | | * @brief Check if a field value is a numeric double. |
540 | | * |
541 | | * @param u1 User data pointer, not used in this function. |
542 | | * @param strptr String to check. |
543 | | * @param len Length of the string being checked. |
544 | | * @param u2 User data pointer, not used in this function. |
545 | | * @param u3 User data pointer, not used in this function. |
546 | | * @param err Error message buffer if an error occurs. |
547 | | * @return true if the field value is valid, false otherwise. |
548 | | */ |
549 | | WS_DLL_PUBLIC |
550 | | bool uat_fld_chk_num_dbl(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
551 | | |
552 | | /** |
553 | | * @brief Check if a field value is a boolean. |
554 | | * |
555 | | * @param u1 User data pointer, not used in this function. |
556 | | * @param strptr String to check. |
557 | | * @param len Length of the string being checked. |
558 | | * @param u2 User data pointer, not used in this function. |
559 | | * @param u3 User data pointer, not used in this function. |
560 | | * @param err Error message buffer if an error occurs. |
561 | | * @return true if the field value is valid, false otherwise. |
562 | | */ |
563 | | WS_DLL_PUBLIC |
564 | | bool uat_fld_chk_bool(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
565 | | |
566 | | /** |
567 | | * @brief Checks if a field value is a valid enum. |
568 | | * |
569 | | * @param u1 User data pointer, not used in this function. |
570 | | * @param strptr String to check. |
571 | | * @param len Length of the string being checked. |
572 | | * @param v Value string. |
573 | | * @param u3 User data pointer, not used in this function. |
574 | | * @param err Error message buffer if an error occurs. |
575 | | * @return true if the field value is valid, false otherwise. |
576 | | */ |
577 | | WS_DLL_PUBLIC |
578 | | bool uat_fld_chk_enum(void* u1, const char* strptr, unsigned len, const void* v, const void* u3, char** err); |
579 | | |
580 | | /** |
581 | | * @brief Checks if a field value is a range object. |
582 | | * |
583 | | * @param u1 User data pointer, not used in this function. |
584 | | * @param strptr String to check. |
585 | | * @param len Length of the string being checked. |
586 | | * @param u2 User data pointer, not used in this function. |
587 | | * @param u3 User data pointer, not used in this function. |
588 | | * @param err Error message buffer if an error occurs. |
589 | | * @return true if the field value is valid, false otherwise. |
590 | | */ |
591 | | WS_DLL_PUBLIC |
592 | | bool uat_fld_chk_range(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
593 | | |
594 | | /** |
595 | | * @brief Checks if a color field is valid. |
596 | | * |
597 | | * @param u1 User data pointer, not used in this function. |
598 | | * @param strptr String to check. |
599 | | * @param len Length of the string being checked. |
600 | | * @param u2 User data pointer, not used in this function. |
601 | | * @param u3 User data pointer, not used in this function. |
602 | | * @param err Error message buffer if an error occurs. |
603 | | * @return true if the field value is valid, false otherwise. |
604 | | */ |
605 | | WS_DLL_PUBLIC |
606 | | bool uat_fld_chk_color(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
607 | | |
608 | | typedef void (*uat_cb_t)(void* uat,void* user_data); |
609 | | |
610 | | /** |
611 | | * @brief Iterates over all UAT tables and calls a callback function for each. |
612 | | * |
613 | | * @param cb Callback function to be called for each UAT table. |
614 | | * @param user_data User data to be passed to the callback function. |
615 | | */ |
616 | | WS_DLL_PUBLIC |
617 | | void uat_foreach_table(uat_cb_t cb,void* user_data); |
618 | | |
619 | | /** |
620 | | * @brief Unloads all UATs that are not loaded from a profile. |
621 | | * |
622 | | * This function iterates through all UATs and unloads those that are not marked as being loaded from a profile. |
623 | | */ |
624 | | void uat_unload_all(void); |
625 | | |
626 | | /** |
627 | | * @brief Converts an ASCII string using C-style escapes (e.g., for unprintable |
628 | | * |
629 | | * Converts an ASCII string using C-style escapes (e.g., for unprintable |
630 | | * characters) into a "stringlike" array of bytes that may include internal |
631 | | * NUL bytes and other unprintable characters. This is the PT_TEXTMOD_STRING |
632 | | * format. |
633 | | * |
634 | | * @param si The escaped ASCII input string. |
635 | | * @param in_len Length of @p si in bytes, not including any NUL terminator. |
636 | | * @param len_p Receives the length of the returned byte array in bytes. |
637 | | * @return A newly allocated byte array of @p *len_p bytes. The caller must |
638 | | * free it with @c g_free(). |
639 | | */ |
640 | | uint8_t *uat_unesc(const char *si, unsigned in_len, unsigned *len_p); |
641 | | |
642 | | /** |
643 | | * @brief Decode a quoted, C-style escaped ASCII string into a raw byte array. |
644 | | * |
645 | | * The same as uat_unesc, but removing the first and last byte. The |
646 | | * assumption is that the first and last byte are quote characters. When |
647 | | * writing the PT_TEXTMOD_STRING format to file, the escaped string is |
648 | | * enclosed in quotes; this function undoes that. |
649 | | * |
650 | | * TODO - This should probably return a uint8_t* as well, but requires |
651 | | * changing types (or casting pointers) in several other files to do so. |
652 | | * |
653 | | * @param si The quoted, escaped ASCII input string (including surrounding |
654 | | * quote characters). |
655 | | * @param in_len Length of @p si in bytes, including the quote characters. |
656 | | * @param len_p Receives the length of the decoded byte array in bytes. |
657 | | * @return A newly allocated byte array of @p *len_p bytes. The caller must |
658 | | * free it with @c g_free(). |
659 | | */ |
660 | | char *uat_undquote(const char *si, unsigned in_len, unsigned *len_p); |
661 | | |
662 | | /** |
663 | | * @brief Encode a raw byte array as a NUL-terminated C-style escaped ASCII string. |
664 | | * |
665 | | * Converts a "stringlike" array of bytes into a null-terminated ASCII string |
666 | | * using C-style escapes. The inverse of uat_unesc. |
667 | | * |
668 | | * @param buf The raw byte array to encode. |
669 | | * @param len Number of bytes in @p buf. |
670 | | * @return A newly allocated NUL-terminated escaped ASCII string. The caller |
671 | | * must free it with @c g_free(). |
672 | | */ |
673 | | char *uat_esc(const uint8_t *buf, unsigned len); |
674 | | |
675 | | /** |
676 | | * @brief Decode an ASCII hex-digit string into a raw byte array. |
677 | | * |
678 | | * Converts a ASCII hexstring into an array of bytes. Used to convert |
679 | | * the PT_TXTMOD_HEXBYTES format. |
680 | | * TODO - This should probably return a uint8_t* as well. |
681 | | * |
682 | | * @param si The ASCII hex-digit input string. |
683 | | * @param in_len Length of @p si in bytes. |
684 | | * @param len_p Receives the number of decoded bytes in the returned array. |
685 | | * @return A newly allocated byte array of @p *len_p bytes, or NULL if |
686 | | * @p si contains non-hex characters or an odd number of digits. |
687 | | * The caller must free it with @c g_free(). |
688 | | */ |
689 | | char *uat_unbinstring(const char *si, unsigned in_len, unsigned *len_p); |
690 | | |
691 | | /* Some strings entirely made of ... already declared */ |
692 | | |
693 | | /** |
694 | | * @brief Checks if a string contains only printable characters. |
695 | | * |
696 | | * @param u1 User data pointer, not used in this function. |
697 | | * @param strptr String to check. |
698 | | * @param len Length of the string being checked. |
699 | | * @param u2 User data pointer, not used in this function. |
700 | | * @param u3 User data pointer, not used in this function. |
701 | | * @param err Error message buffer if an error occurs. |
702 | | * @return true if the field value is valid, false otherwise. |
703 | | */ |
704 | | WS_DLL_PUBLIC |
705 | | bool uat_fld_chk_str_isprint(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
706 | | |
707 | | /** |
708 | | * @brief Checks if a string contains only alphabetic characters. |
709 | | * |
710 | | * @param u1 User data pointer, not used in this function. |
711 | | * @param strptr String to check. |
712 | | * @param len Length of the string being checked. |
713 | | * @param u2 User data pointer, not used in this function. |
714 | | * @param u3 User data pointer, not used in this function. |
715 | | * @param err Error message buffer if an error occurs. |
716 | | * @return true if the field value is valid, false otherwise. |
717 | | */ |
718 | | WS_DLL_PUBLIC |
719 | | bool uat_fld_chk_str_isalpha(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
720 | | |
721 | | /** |
722 | | * @brief Checks if a string is alphanumeric. |
723 | | * |
724 | | * @param u1 User data pointer, not used in this function. |
725 | | * @param strptr String to check. |
726 | | * @param len Length of the string being checked. |
727 | | * @param u2 User data pointer, not used in this function. |
728 | | * @param u3 User data pointer, not used in this function. |
729 | | * @param err Error message buffer if an error occurs. |
730 | | * @return true if the field value is valid, false otherwise. |
731 | | */ |
732 | | WS_DLL_PUBLIC |
733 | | bool uat_fld_chk_str_isalnum(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
734 | | |
735 | | /** |
736 | | * @brief Checks if a string contains only digits. |
737 | | * |
738 | | * @param u1 User data pointer, not used in this function. |
739 | | * @param strptr String to check. |
740 | | * @param len Length of the string being checked. |
741 | | * @param u2 User data pointer, not used in this function. |
742 | | * @param u3 User data pointer, not used in this function. |
743 | | * @param err Error message buffer if an error occurs. |
744 | | * @return true if the field value is valid, false otherwise. |
745 | | */ |
746 | | WS_DLL_PUBLIC |
747 | | bool uat_fld_chk_str_isdigit(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
748 | | |
749 | | /** |
750 | | * @brief Checks if a string contains only hexadecimal digits. |
751 | | * |
752 | | * @param u1 User data pointer, not used in this function. |
753 | | * @param strptr String to check. |
754 | | * @param len Length of the string being checked. |
755 | | * @param u2 User data pointer, not used in this function. |
756 | | * @param u3 User data pointer, not used in this function. |
757 | | * @param err Error message buffer if an error occurs. |
758 | | * @return true if the field value is valid, false otherwise. |
759 | | */ |
760 | | WS_DLL_PUBLIC |
761 | | bool uat_fld_chk_str_isxdigit(void* u1, const char* strptr, unsigned len, const void* u2, const void* u3, char** err); |
762 | | |
763 | | |
764 | | /* |
765 | | * Macros |
766 | | * to define basic uat_fld_set_cbs, uat_fld_tostr_cbs |
767 | | * for those elements in uat_field_t array |
768 | | */ |
769 | | |
770 | | #ifdef __cplusplus |
771 | | #define UNUSED_PARAMETER(n) |
772 | | #else |
773 | | #define UNUSED_PARAMETER(n) n _U_ |
774 | | #endif |
775 | | |
776 | | /* |
777 | | * CSTRING macros, |
778 | | * a simple c-string contained in (((rec_t*)rec)->(field_name)) |
779 | | */ |
780 | | #define UAT_CSTRING_CB_DEF(basename,field_name,rec_t) \ |
781 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
782 | 0 | char* new_buf = g_strndup(buf,len); \ |
783 | 0 | g_free((((rec_t*)rec)->field_name)); \ |
784 | 0 | (((rec_t*)rec)->field_name) = new_buf; } \ Unexecuted instantiation: expert.c:uat_expert_entries_field_set_cb Unexecuted instantiation: dfilter-macro-uat.c:macro_name_set_cb Unexecuted instantiation: dfilter-macro-uat.c:macro_text_set_cb Unexecuted instantiation: addr_resolv.c:dnsserverlist_uats_ipaddr_set_cb Unexecuted instantiation: filter_expressions.c:display_filter_macro_uat_label_set_cb Unexecuted instantiation: filter_expressions.c:display_filter_macro_uat_expression_set_cb Unexecuted instantiation: filter_expressions.c:display_filter_macro_uat_comment_set_cb Unexecuted instantiation: aggregation_fields.c:uat_aggregation_field_set_cb Unexecuted instantiation: packet-amqp.c:message_decode_topic_pattern_set_cb Unexecuted instantiation: packet-amqp.c:message_decode_topic_more_info_set_cb Unexecuted instantiation: packet-asam-cmp.c:asam_cmp_devices_name_set_cb Unexecuted instantiation: packet-asam-cmp.c:asam_cmp_interfaces_name_set_cb Unexecuted instantiation: packet-autosar-nm.c:user_data_fields_udf_name_set_cb Unexecuted instantiation: packet-autosar-nm.c:user_data_fields_udf_desc_set_cb Unexecuted instantiation: packet-autosar-nm.c:user_data_fields_udf_value_desc_set_cb Unexecuted instantiation: packet-autosar-ipdu-multiplexer.c:ipdum_message_list_name_set_cb Unexecuted instantiation: packet-ber.c:oid_users_oid_set_cb Unexecuted instantiation: packet-ber.c:oid_users_name_set_cb Unexecuted instantiation: packet-bluetooth.c:bt_uuids_uuid_set_cb Unexecuted instantiation: packet-bluetooth.c:bt_uuids_label_set_cb Unexecuted instantiation: packet-btmesh.c:uat_btmesh_records_network_key_string_set_cb Unexecuted instantiation: packet-btmesh.c:uat_btmesh_records_application_key_string_set_cb Unexecuted instantiation: packet-btmesh.c:uat_btmesh_records_ivindex_string_set_cb Unexecuted instantiation: packet-btmesh.c:uat_btmesh_dev_key_records_device_key_string_set_cb Unexecuted instantiation: packet-btmesh.c:uat_btmesh_dev_key_records_src_string_set_cb Unexecuted instantiation: packet-btmesh.c:uat_btmesh_label_uuid_records_label_uuid_string_set_cb Unexecuted instantiation: packet-collectd.c:uat_collectd_records_username_set_cb Unexecuted instantiation: packet-collectd.c:uat_collectd_records_password_set_cb Unexecuted instantiation: packet-dhcp.c:uat_dhcp_records_text_set_cb Unexecuted instantiation: packet-dmp.c:dmp_security_class_name_set_cb Unexecuted instantiation: packet-dof.c:secmode_list_domain_set_cb Unexecuted instantiation: packet-dof.c:secmode_list_identity_set_cb Unexecuted instantiation: packet-dof.c:secmode_list_kek_set_cb Unexecuted instantiation: packet-dof.c:seckey_list_key_set_cb Unexecuted instantiation: packet-dof.c:identsecret_list_domain_set_cb Unexecuted instantiation: packet-dof.c:identsecret_list_identity_set_cb Unexecuted instantiation: packet-dof.c:identsecret_list_secret_set_cb Unexecuted instantiation: packet-doip.c:doip_diag_addresses_name_set_cb Unexecuted instantiation: packet-doip.c:doip_payload_types_name_set_cb Unexecuted instantiation: packet-epl.c:device_profile_list_uats_path_set_cb Unexecuted instantiation: packet-epl.c:nodeid_profile_list_uats_path_set_cb Unexecuted instantiation: packet-flexray.c:sender_receiver_configs_sender_name_set_cb Unexecuted instantiation: packet-flexray.c:sender_receiver_configs_receiver_name_set_cb Unexecuted instantiation: packet-gtp.c:pdcp_lte_users_ip_addr_str_set_cb Unexecuted instantiation: packet-gtp.c:pdcp_lte_users_teid_str_set_cb Unexecuted instantiation: packet-gtp.c:pdcp_nr_users_ip_addr_str_set_cb Unexecuted instantiation: packet-gtp.c:pdcp_nr_users_teid_str_set_cb Unexecuted instantiation: packet-hsfz.c:udf_diag_addr_name_set_cb Unexecuted instantiation: packet-http.c:header_fields_header_name_set_cb Unexecuted instantiation: packet-http.c:header_fields_header_desc_set_cb Unexecuted instantiation: packet-ieee80211.c:uat_wep_key_records_string_set_cb Unexecuted instantiation: packet-ieee802154.c:key_uat_pref_key_set_cb Unexecuted instantiation: packet-imf.c:header_fields_header_name_set_cb Unexecuted instantiation: packet-imf.c:header_fields_description_set_cb Unexecuted instantiation: packet-ipsec.c:uat_esp_sa_records_srcIP_set_cb Unexecuted instantiation: packet-ipsec.c:uat_esp_sa_records_dstIP_set_cb Unexecuted instantiation: packet-ipsec.c:uat_esp_sa_records_spi_set_cb Unexecuted instantiation: packet-ipsec.c:uat_esp_sa_records_encryption_key_string_set_cb Unexecuted instantiation: packet-ipsec.c:uat_esp_sa_records_authentication_key_string_set_cb Unexecuted instantiation: packet-ipv6.c:nat64_prefix_uats_ipaddr_set_cb Unexecuted instantiation: packet-k12.c:k12_match_set_cb Unexecuted instantiation: packet-k12.c:k12_protos_set_cb Unexecuted instantiation: packet-lbmpdmtcp.c:lbmpdm_tcp_tag_name_set_cb Unexecuted instantiation: packet-lbmr.c:lbmr_tag_name_set_cb Unexecuted instantiation: packet-lbmsrs.c:lbmsrs_tag_name_set_cb Unexecuted instantiation: packet-lbtrm.c:lbtrm_tag_name_set_cb Unexecuted instantiation: packet-lbtru.c:lbtru_tag_name_set_cb Unexecuted instantiation: packet-lbttcp.c:lbttcp_tag_name_set_cb Unexecuted instantiation: packet-lin.c:interface_configs_interface_name_set_cb Unexecuted instantiation: packet-lin.c:sender_receiver_configs_sender_name_set_cb Unexecuted instantiation: packet-lin.c:sender_receiver_configs_receiver_name_set_cb Unexecuted instantiation: packet-lorawan.c:root_keys_deveui_string_set_cb Unexecuted instantiation: packet-lorawan.c:root_keys_appkey_string_set_cb Unexecuted instantiation: packet-lorawan.c:session_keys_dev_addr_string_set_cb Unexecuted instantiation: packet-lorawan.c:session_keys_nwkskey_string_set_cb Unexecuted instantiation: packet-lorawan.c:session_keys_appskey_string_set_cb Unexecuted instantiation: packet-lwm2mtlv.c:object_name_name_set_cb Unexecuted instantiation: packet-lwm2mtlv.c:resource_name_set_cb Unexecuted instantiation: packet-macsec.c:psk_config_data_name_set_cb Unexecuted instantiation: packet-mka.c:mka_ckn_uat_data_name_set_cb Unexecuted instantiation: packet-mqtt.c:message_decode_topic_pattern_set_cb Unexecuted instantiation: packet-ntlmssp.c:ntlmssp_creds_value_set_cb Unexecuted instantiation: packet-oscore.c:oscore_context_uat_sender_id_prefs_set_cb Unexecuted instantiation: packet-oscore.c:oscore_context_uat_recipient_id_prefs_set_cb Unexecuted instantiation: packet-oscore.c:oscore_context_uat_master_secret_prefs_set_cb Unexecuted instantiation: packet-oscore.c:oscore_context_uat_master_salt_prefs_set_cb Unexecuted instantiation: packet-oscore.c:oscore_context_uat_id_context_prefs_set_cb Unexecuted instantiation: packet-pdcp-lte.c:uat_ue_keys_records_rrcCipherKeyString_set_cb Unexecuted instantiation: packet-pdcp-lte.c:uat_ue_keys_records_upCipherKeyString_set_cb Unexecuted instantiation: packet-pdcp-lte.c:uat_ue_keys_records_rrcIntegrityKeyString_set_cb Unexecuted instantiation: packet-pdcp-nr.c:uat_ue_keys_records_rrcCipherKeyString_set_cb Unexecuted instantiation: packet-pdcp-nr.c:uat_ue_keys_records_upCipherKeyString_set_cb Unexecuted instantiation: packet-pdcp-nr.c:uat_ue_keys_records_rrcIntegrityKeyString_set_cb Unexecuted instantiation: packet-pdcp-nr.c:uat_ue_keys_records_upIntegrityKeyString_set_cb Unexecuted instantiation: packet-pdu-transport.c:pdu_transport_pdus_name_set_cb Unexecuted instantiation: packet-protobuf.c:protobuf_search_paths_path_set_cb Unexecuted instantiation: packet-protobuf.c:protobuf_udp_message_types_message_type_set_cb Unexecuted instantiation: packet-protobuf.c:protobuf_uri_message_type_uri_set_cb Unexecuted instantiation: packet-protobuf.c:protobuf_uri_message_type_message_type_set_cb Unexecuted instantiation: packet-reload.c:kindidlist_uats_name_set_cb Unexecuted instantiation: packet-sctp.c:type_fields_type_name_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_message_ident_name_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_name_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_filter_string_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_data_type_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_scaler_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_offset_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_value_names_value_name_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_dlt_mapping_ecu_id_set_cb Unexecuted instantiation: packet-sip.c:sip_custom_header_fields_header_name_set_cb Unexecuted instantiation: packet-sip.c:sip_custom_header_fields_header_desc_set_cb Unexecuted instantiation: packet-sip.c:sip_authorization_users_username_set_cb Unexecuted instantiation: packet-sip.c:sip_authorization_users_realm_set_cb Unexecuted instantiation: packet-sip.c:sip_authorization_users_password_set_cb Unexecuted instantiation: packet-socketcan.c:interface_configs_interface_name_set_cb Unexecuted instantiation: packet-socketcan.c:sender_receiver_configs_sender_name_set_cb Unexecuted instantiation: packet-socketcan.c:sender_receiver_configs_receiver_name_set_cb Unexecuted instantiation: packet-someip.c:someip_service_ident_name_set_cb Unexecuted instantiation: packet-someip.c:someip_method_ident_name_set_cb Unexecuted instantiation: packet-someip.c:someip_eventgroup_ident_name_set_cb Unexecuted instantiation: packet-someip.c:someip_client_ident_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_list_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_list_filter_string_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_base_type_list_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_base_type_list_data_type_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_strings_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_strings_encoding_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_arrays_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_arrays_filter_string_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_structs_struct_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_structs_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_structs_filter_string_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_unions_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_unions_type_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_unions_filter_string_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_typedefs_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_enums_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_enums_value_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_bitfields_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_bitfields_bit_name_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_bitfields_filter_string_set_cb Unexecuted instantiation: packet-tecmp.c:tecmp_devices_name_set_cb Unexecuted instantiation: packet-tecmp.c:tecmp_interfaces_name_set_cb Unexecuted instantiation: packet-tecmp.c:tecmp_ctrl_msgs_name_set_cb Unexecuted instantiation: packet-tibia.c:xteakeylist_uats_key_set_cb Unexecuted instantiation: packet-uds.c:uds_uat_routine_ids_name_set_cb Unexecuted instantiation: packet-uds.c:uds_uat_data_ids_name_set_cb Unexecuted instantiation: packet-uds.c:uds_uat_dtc_ids_name_set_cb Unexecuted instantiation: packet-uds.c:uds_uat_addresses_name_set_cb Unexecuted instantiation: packet-wireguard.c:wg_key_uat_key_set_cb Unexecuted instantiation: packet-xcp.c:xcp_memory_addresses_name_set_cb Unexecuted instantiation: packet-xcp.c:xcp_uat_eth_mappings_ip_address_set_cb Unexecuted instantiation: packet-zbee-direct.c:uat_key_records_zdd_ieee_set_cb Unexecuted instantiation: packet-zbee-direct.c:uat_key_records_zvd_ieee_set_cb Unexecuted instantiation: packet-zbee-direct.c:uat_key_records_key_set_cb Unexecuted instantiation: packet-zbee-direct.c:uat_key_records_label_set_cb Unexecuted instantiation: packet-zbee-nwk-gp.c:gp_uat_key_records_string_set_cb Unexecuted instantiation: packet-zbee-nwk-gp.c:gp_uat_key_records_label_set_cb Unexecuted instantiation: packet-zbee-security.c:uat_key_records_string_set_cb Unexecuted instantiation: packet-zbee-security.c:uat_key_records_label_set_cb Unexecuted instantiation: packet-rf4ce-nwk.c:uat_security_records_sec_str_set_cb Unexecuted instantiation: packet-rf4ce-nwk.c:uat_security_records_label_set_cb Unexecuted instantiation: packet-zmtp.c:zmtp_tcp_protocols_protocol_set_cb Unexecuted instantiation: packet-ess.c:ess_category_attributes_oid_set_cb Unexecuted instantiation: packet-ess.c:ess_category_attributes_name_set_cb Unexecuted instantiation: packet-ldap.c:attribute_types_attribute_type_set_cb Unexecuted instantiation: packet-ldap.c:attribute_types_attribute_desc_set_cb Unexecuted instantiation: packet-pres.c:pres_users_oid_set_cb Unexecuted instantiation: packet-snmp.c:specific_traps_enterprise_set_cb Unexecuted instantiation: packet-snmp.c:specific_traps_desc_set_cb |
785 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
786 | 0 | if (((rec_t*)rec)->field_name ) { \ |
787 | 0 | *out_ptr = g_strdup((((rec_t*)rec)->field_name)); \ |
788 | 0 | *out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \ |
789 | 0 | } else { \ |
790 | 0 | *out_ptr = g_strdup(""); *out_len = 0; \ |
791 | 0 | } } |
792 | | |
793 | | #define UAT_FLD_CSTRING(basename,field_name,title,desc) \ |
794 | 2.13k | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_str,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
795 | | |
796 | | #define UAT_FLD_CSTRING_ISPRINT(basename,field_name,title,desc) \ |
797 | 15 | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_str_isprint,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
798 | | |
799 | | #define UAT_FLD_CSTRING_OTHER(basename,field_name,title,chk,desc) \ |
800 | 165 | {#field_name, title, PT_TXTMOD_STRING,{ chk ,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
801 | | |
802 | | /* |
803 | | * FILENAME and DIRECTORYNAME, |
804 | | * a simple c-string contained in (((rec_t*)rec)->(field_name)) |
805 | | */ |
806 | | #define UAT_FILENAME_CB_DEF(basename,field_name,rec_t) UAT_CSTRING_CB_DEF(basename,field_name,rec_t) |
807 | | |
808 | | /* XXX UAT_FLD_FILENAME is currently unused. */ |
809 | | #define UAT_FLD_FILENAME(basename,field_name,title,desc) \ |
810 | | {#field_name, title, PT_TXTMOD_FILENAME,{uat_fld_chk_str,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
811 | | |
812 | | /* |
813 | | * Both the Qt and GTK+ UIs assume that we're opening a preexisting |
814 | | * file. We might want to split the ..._FILENAME defines into |
815 | | * ..._FILE_OPEN and ..._FILE_SAVE if we ever need to specify a |
816 | | * file that we're creating. |
817 | | */ |
818 | | #define UAT_FLD_FILENAME_OTHER(basename,field_name,title,chk,desc) \ |
819 | | {#field_name, title, PT_TXTMOD_FILENAME,{chk,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
820 | | |
821 | | #define UAT_DIRECTORYNAME_CB_DEF(basename,field_name,rec_t) UAT_CSTRING_CB_DEF(basename,field_name,rec_t) |
822 | | |
823 | | #define UAT_FLD_DIRECTORYNAME(basename,field_name,title,desc) \ |
824 | 15 | {#field_name, title, PT_TXTMOD_DIRECTORYNAME,{uat_fld_chk_str,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
825 | | |
826 | | /* |
827 | | * DISPLAY_FILTER, |
828 | | * a simple c-string contained in (((rec_t*)rec)->(field_name)) |
829 | | */ |
830 | | #define UAT_DISPLAY_FILTER_CB_DEF(basename,field_name,rec_t) UAT_CSTRING_CB_DEF(basename,field_name,rec_t) |
831 | | |
832 | | #define UAT_FLD_DISPLAY_FILTER(basename,field_name,title,desc) \ |
833 | | {#field_name, title, PT_TXTMOD_DISPLAY_FILTER, {uat_fld_chk_str,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
834 | | |
835 | | /* |
836 | | * PROTO_FIELD, |
837 | | * a simple c-string contained in (((rec_t*)rec)->(field_name)) |
838 | | */ |
839 | | #define UAT_PROTO_FIELD_CB_DEF(basename,field_name,rec_t) UAT_CSTRING_CB_DEF(basename,field_name,rec_t) |
840 | | |
841 | | #define UAT_FLD_PROTO_FIELD(basename,field_name,title,desc) \ |
842 | | {#field_name, title, PT_TXTMOD_PROTO_FIELD, {uat_fld_chk_field,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
843 | | |
844 | | /* |
845 | | * OID - just a CSTRING with a specific check routine |
846 | | */ |
847 | | #define UAT_FLD_OID(basename,field_name,title,desc) \ |
848 | | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_oid,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
849 | | |
850 | | |
851 | | /* |
852 | | * LSTRING MACROS - a "string" with an explicit length, so it can contain |
853 | | * internal null characters and possibly unprintable characters, that are |
854 | | * displayed to the user and written to the file using C-style escapes. An |
855 | | * alternative to BUFFER for when the data is often but not necessarily an |
856 | | * ASCII printable string, such as in some types of encryption keys. |
857 | | */ |
858 | | #define UAT_LSTRING_CB_DEF(basename,field_name,rec_t,ptr_element,len_element) \ |
859 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
860 | 0 | uint8_t* new_val = uat_unesc(buf,len,&(((rec_t*)rec)->len_element)); \ |
861 | 0 | g_free((((rec_t*)rec)->ptr_element)); \ |
862 | 0 | (((rec_t*)rec)->ptr_element) = new_val; } \ Unexecuted instantiation: packet-snmp.c:snmp_users_userName_set_cb Unexecuted instantiation: packet-snmp.c:snmp_users_authPassword_set_cb Unexecuted instantiation: packet-snmp.c:snmp_users_privPassword_set_cb |
863 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
864 | 0 | if (((rec_t*)rec)->ptr_element ) { \ |
865 | 0 | *out_ptr = uat_esc(((rec_t*)rec)->ptr_element, (((rec_t*)rec)->len_element)); \ |
866 | 0 | *out_len = (unsigned)strlen(*out_ptr); \ |
867 | 0 | } else { \ |
868 | 0 | *out_ptr = g_strdup(""); \ |
869 | 0 | *out_len = 0; \ |
870 | 0 | } } |
871 | | |
872 | 60 | #define UAT_FLD_LSTRING(basename,field_name,title, desc) \ |
873 | 60 | {#field_name, title, PT_TXTMOD_STRING,{0,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
874 | | |
875 | | |
876 | | /* |
877 | | * BUFFER macros, |
878 | | * a buffer_ptr contained in (((rec_t*)rec)->(field_name)) |
879 | | * and its len in (((rec_t*)rec)->(len_name)) |
880 | | */ |
881 | | #define UAT_BUFFER_CB_DEF(basename,field_name,rec_t,ptr_element,len_element) \ |
882 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
883 | 0 | unsigned char* new_buf = len ? (unsigned char *)g_memdup2(buf,len) : NULL; \ |
884 | 0 | g_free((((rec_t*)rec)->ptr_element)); \ |
885 | 0 | (((rec_t*)rec)->ptr_element) = new_buf; \ |
886 | 0 | (((rec_t*)rec)->len_element) = len; } \ |
887 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
888 | 0 | *out_ptr = ((rec_t*)rec)->ptr_element ? (char*)g_memdup2(((rec_t*)rec)->ptr_element,((rec_t*)rec)->len_element) : g_strdup(""); \ |
889 | 0 | *out_len = ((rec_t*)rec)->len_element; } |
890 | | |
891 | | #define UAT_FLD_BUFFER(basename,field_name,title,desc) \ |
892 | 375 | {#field_name, title, PT_TXTMOD_HEXBYTES,{0,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
893 | | |
894 | | |
895 | | /* |
896 | | * DEC Macros, |
897 | | * an unsigned decimal number contained in (((rec_t*)rec)->(field_name)) |
898 | | */ |
899 | | #define UAT_DEC_CB_DEF(basename,field_name,rec_t) \ |
900 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
901 | 0 | char* tmp_str = g_strndup(buf,len); \ |
902 | 0 | ws_strtou32(tmp_str, NULL, &((rec_t*)rec)->field_name); \ |
903 | 0 | g_free(tmp_str); } \ |
904 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
905 | 0 | *out_ptr = ws_strdup_printf("%u",((rec_t*)rec)->field_name); \ |
906 | 0 | *out_len = (unsigned)strlen(*out_ptr); } |
907 | | |
908 | | #define UAT_FLD_DEC(basename,field_name,title,desc) \ |
909 | 1.17k | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_num_dec,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
910 | | |
911 | | /* |
912 | | * an unsigned 64bit decimal number contained in (((rec_t*)rec)->(field_name)) |
913 | | */ |
914 | | #define UAT_DEC64_CB_DEF(basename,field_name,rec_t) \ |
915 | | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
916 | | char* tmp_str = g_strndup(buf,len); \ |
917 | | ws_strtou64(tmp_str, NULL, &((rec_t*)rec)->field_name); \ |
918 | | g_free(tmp_str); } \ |
919 | | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
920 | | *out_ptr = ws_strdup_printf("%" PRIu64,((rec_t*)rec)->field_name); \ |
921 | | *out_len = (unsigned)strlen(*out_ptr); } |
922 | | |
923 | | #define UAT_FLD_DEC64(basename,field_name,title,desc) \ |
924 | | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_num_dec64,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
925 | | |
926 | | /* |
927 | | * a *signed* decimal number contained in (((rec_t*)rec)->(field_name)) |
928 | | */ |
929 | | #define UAT_SIGNED_DEC_CB_DEF(basename,field_name,rec_t) \ |
930 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
931 | 0 | char* tmp_str = g_strndup(buf,len); \ |
932 | 0 | ws_strtoi32(tmp_str, NULL, &((rec_t*)rec)->field_name); \ |
933 | 0 | g_free(tmp_str); } \ |
934 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
935 | 0 | *out_ptr = ws_strdup_printf("%d",((rec_t*)rec)->field_name); \ |
936 | 0 | *out_len = (unsigned)strlen(*out_ptr); } |
937 | | |
938 | | #define UAT_FLD_SIGNED_DEC(basename,field_name,title,desc) \ |
939 | 15 | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_num_signed_dec,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
940 | | |
941 | | /* |
942 | | * and a *signed* 64bit decimal number contained in (((rec_t*)rec)->(field_name)) |
943 | | */ |
944 | | #define UAT_SIGNED_DEC64_CB_DEF(basename,field_name,rec_t) \ |
945 | | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
946 | | char* tmp_str = g_strndup(buf,len); \ |
947 | | ws_strtoi64(tmp_str, NULL, &((rec_t*)rec)->field_name); \ |
948 | | g_free(tmp_str); } \ |
949 | | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
950 | | *out_ptr = ws_strdup_printf("%" PRId64,((rec_t*)rec)->field_name); \ |
951 | | *out_len = (unsigned)strlen(*out_ptr); } |
952 | | |
953 | | #define UAT_FLD_SIGNED_DEC64(basename,field_name,title,desc) \ |
954 | | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_num_signed_dec64,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
955 | | |
956 | | #define UAT_FLD_NONE(basename,field_name,title,desc) \ |
957 | 15 | {#field_name, title, PT_TXTMOD_NONE,{uat_fld_chk_num_dec,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
958 | | |
959 | | |
960 | | /* |
961 | | * HEX Macros, |
962 | | * an unsigned hexadecimal number contained in (((rec_t*)rec)->(field_name)) |
963 | | */ |
964 | | #define UAT_HEX_CB_DEF(basename,field_name,rec_t) \ |
965 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
966 | 0 | char* tmp_str = g_strndup(buf,len); \ |
967 | 0 | ws_hexstrtou32(tmp_str, NULL, &((rec_t*)rec)->field_name); \ |
968 | 0 | g_free(tmp_str); } \ |
969 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
970 | 0 | *out_ptr = ws_strdup_printf("%x",((rec_t*)rec)->field_name); \ |
971 | 0 | *out_len = (unsigned)strlen(*out_ptr); } |
972 | | |
973 | 1.83k | #define UAT_FLD_HEX(basename,field_name,title,desc) \ |
974 | 1.83k | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_num_hex,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
975 | | |
976 | | /* |
977 | | * HEX Macros for 64bit, |
978 | | * an unsigned long long hexadecimal number contained in (((rec_t*)rec)->(field_name)) |
979 | | */ |
980 | | #define UAT_HEX64_CB_DEF(basename,field_name,rec_t) \ |
981 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
982 | 0 | char* tmp_str = g_strndup(buf,len); \ |
983 | 0 | ws_hexstrtou64(tmp_str, NULL, &((rec_t*)rec)->field_name); \ |
984 | 0 | g_free(tmp_str); } \ |
985 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
986 | 0 | *out_ptr = ws_strdup_printf("%" PRIx64,((rec_t*)rec)->field_name); \ |
987 | 0 | *out_len = (unsigned)strlen(*out_ptr); } |
988 | | |
989 | 45 | #define UAT_FLD_HEX64(basename,field_name,title,desc) \ |
990 | 45 | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_num_hex64,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
991 | | |
992 | | /* |
993 | | * DBL Macros, |
994 | | * a double precision floating-point number contained in (((rec_t*)rec)->(field_name)) |
995 | | * |
996 | | * [using g_ascii_dtostr() would be fine for tostr_cb for storing data, but |
997 | | * produces more ugly looking values when presenting to the user. dtoa_g_fmt |
998 | | * produces the shortest string which also is a unique round-trip for any |
999 | | * particular value.] |
1000 | | */ |
1001 | | #define UAT_DBL_CB_DEF(basename,field_name,rec_t) \ |
1002 | | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1003 | | char* tmp_str = g_strndup(buf,len); \ |
1004 | | ((rec_t*)rec)->field_name = g_ascii_strtod(tmp_str, NULL); \ |
1005 | | g_free(tmp_str); } \ |
1006 | | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1007 | | char buf[32]; \ |
1008 | | *out_ptr = ws_strdup(dtoa_g_fmt(buf, ((rec_t*)rec)->field_name)); \ |
1009 | | *out_len = (unsigned)strlen(*out_ptr); } |
1010 | | |
1011 | | #define UAT_FLD_DBL(basename,field_name,title,desc) \ |
1012 | | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_num_dbl,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
1013 | | |
1014 | | /* |
1015 | | * BOOL Macros, |
1016 | | * an boolean value contained in (((rec_t*)rec)->(field_name)) |
1017 | | * |
1018 | | * Write "TRUE" or "FALSE" for backwards compatibility with pre-4.4 |
1019 | | * versions that expect that capitalization. |
1020 | | */ |
1021 | | #define UAT_BOOL_CB_DEF(basename,field_name,rec_t) \ |
1022 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1023 | 0 | char* tmp_str = g_strndup(buf,len); \ |
1024 | 0 | if (tmp_str && g_ascii_strcasecmp(tmp_str, "true") == 0) \ |
1025 | 0 | ((rec_t*)rec)->field_name = 1; \ |
1026 | 0 | else \ |
1027 | 0 | ((rec_t*)rec)->field_name = 0; \ |
1028 | 0 | g_free(tmp_str); } \ Unexecuted instantiation: filter_expressions.c:display_filter_macro_uat_enabled_set_cb Unexecuted instantiation: packet-bluetooth.c:bt_uuids_long_attr_set_cb Unexecuted instantiation: packet-iso15765.c:config_can_addr_mappings_extended_address_set_cb Unexecuted instantiation: packet-pdu-transport.c:pdu_transport_ext_cfg_tcp_set_cb Unexecuted instantiation: packet-protobuf.c:protobuf_search_paths_load_all_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_big_endian_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_multiplexer_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_hidden_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_aggregate_sum_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_aggregate_avg_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_signal_list_aggregate_int_set_cb Unexecuted instantiation: packet-signal-pdu.c:spdu_uds_mapping_reply_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_list_wtlv_encoding_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_base_type_list_big_endian_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_strings_dynamic_length_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_strings_big_endian_set_cb Unexecuted instantiation: packet-someip.c:someip_parameter_structs_wtlv_encoding_set_cb |
1029 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1030 | 0 | *out_ptr = ws_strdup_printf("%s",((rec_t*)rec)->field_name ? "TRUE" : "FALSE"); \ |
1031 | 0 | *out_len = (unsigned)strlen(*out_ptr); } |
1032 | | |
1033 | 240 | #define UAT_FLD_BOOL(basename,field_name,title,desc) \ |
1034 | 240 | {#field_name, title, PT_TXTMOD_BOOL,{uat_fld_chk_bool,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
1035 | | |
1036 | | /* |
1037 | | * ENUM macros |
1038 | | * enum_t: name = ((enum_t*)ptr)->strptr |
1039 | | * value = ((enum_t*)ptr)->value |
1040 | | * rec_t: |
1041 | | * value |
1042 | | */ |
1043 | | #define UAT_VS_DEF(basename,field_name,rec_t,default_t,default_val,default_str) \ |
1044 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* vs, const void* UNUSED_PARAMETER(u2)) {\ |
1045 | 0 | unsigned i; \ |
1046 | 0 | char* str = g_strndup(buf,len); \ |
1047 | 0 | const char* cstr; \ |
1048 | 0 | ((rec_t*)rec)->field_name = default_val; \ |
1049 | 0 | for(i=0; ( cstr = ((const value_string*)vs)[i].strptr ) ;i++) { \ |
1050 | 0 | if (g_str_equal(cstr,str)) { \ |
1051 | 0 | ((rec_t*)rec)->field_name = (default_t)((const value_string*)vs)[i].value; \ |
1052 | 0 | g_free(str); \ |
1053 | 0 | return; \ |
1054 | 0 | } \ |
1055 | 0 | } \ |
1056 | 0 | g_free(str); } \ |
1057 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* vs, const void* UNUSED_PARAMETER(u2)) {\ |
1058 | 0 | unsigned i; \ |
1059 | 0 | for(i=0;((const value_string*)vs)[i].strptr;i++) { \ |
1060 | 0 | if ( ((const value_string*)vs)[i].value == ((rec_t*)rec)->field_name ) { \ |
1061 | 0 | *out_ptr = g_strdup(((const value_string*)vs)[i].strptr); \ |
1062 | 0 | *out_len = (unsigned)strlen(*out_ptr); \ |
1063 | 0 | return; \ |
1064 | 0 | } \ |
1065 | 0 | } \ |
1066 | 0 | *out_ptr = g_strdup(default_str); \ |
1067 | 0 | *out_len = (unsigned)strlen(default_str); } |
1068 | | |
1069 | | #define UAT_VS_CSTRING_DEF(basename,field_name,rec_t,default_val,default_str) \ |
1070 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* vs, const void* UNUSED_PARAMETER(u2)) {\ |
1071 | 0 | unsigned i; \ |
1072 | 0 | char* str = g_strndup(buf,len); \ |
1073 | 0 | const char* cstr; \ |
1074 | 0 | ((rec_t*)rec)->field_name = default_val; \ |
1075 | 0 | for(i=0; ( cstr = ((const value_string*)vs)[i].strptr ) ;i++) { \ |
1076 | 0 | if (g_str_equal(cstr,str)) { \ |
1077 | 0 | ((rec_t*)rec)->field_name = g_strdup(((const value_string*)vs)[i].strptr); \ |
1078 | 0 | g_free(str); \ |
1079 | 0 | return; \ |
1080 | 0 | } \ |
1081 | 0 | } \ |
1082 | 0 | g_free(str);} \ |
1083 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(vs), const void* UNUSED_PARAMETER(u2)) {\ |
1084 | 0 | if (((rec_t*)rec)->field_name ) { \ |
1085 | 0 | *out_ptr = g_strdup((((rec_t*)rec)->field_name)); \ |
1086 | 0 | *out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \ |
1087 | 0 | } else { \ |
1088 | 0 | *out_ptr = g_strdup(""); *out_len = 0; } } |
1089 | | |
1090 | | #define UAT_FLD_VS(basename,field_name,title,enum,desc) \ |
1091 | 795 | {#field_name, title, PT_TXTMOD_ENUM,{uat_fld_chk_enum,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{&(enum),&(enum),&(enum)},&(enum),desc,FLDFILL} |
1092 | | |
1093 | | |
1094 | | /* |
1095 | | * Color Macros, |
1096 | | * an #RRGGBB color value contained in (((rec_t*)rec)->(field_name)) |
1097 | | */ |
1098 | | #define UAT_COLOR_CB_DEF(basename,field_name,rec_t) \ |
1099 | | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1100 | | if (len < 1) { \ |
1101 | | ((rec_t*)rec)->field_name = 0; \ |
1102 | | return; \ |
1103 | | } \ |
1104 | | char* tmp_str = g_strndup(buf+1,len-1); \ |
1105 | | ((rec_t*)rec)->field_name = (unsigned)strtol(tmp_str,NULL,16); \ |
1106 | | g_free(tmp_str); } \ |
1107 | | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1108 | | *out_ptr = ws_strdup_printf("#%06X",((rec_t*)rec)->field_name); \ |
1109 | | *out_len = (unsigned)strlen(*out_ptr); } |
1110 | | |
1111 | | #define UAT_FLD_COLOR(basename,field_name,title,desc) \ |
1112 | | {#field_name, title, PT_TXTMOD_COLOR,{uat_fld_chk_color,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
1113 | | |
1114 | | |
1115 | | /* |
1116 | | * DISSECTOR macros |
1117 | | */ |
1118 | | |
1119 | | #define UAT_DISSECTOR_DEF(basename, field_name, dissector_field, name_field, rec_t) \ |
1120 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1121 | 0 | if (len) { \ |
1122 | 0 | ((rec_t*)rec)->name_field = g_strndup(buf, len); \ |
1123 | 0 | g_strstrip(((rec_t*)rec)->name_field); \ |
1124 | 0 | ((rec_t*)rec)->dissector_field = find_dissector(((rec_t*)rec)->name_field); \ |
1125 | 0 | } else { \ |
1126 | 0 | ((rec_t*)rec)->dissector_field = find_dissector("data"); \ |
1127 | 0 | ((rec_t*)rec)->name_field = NULL; \ |
1128 | 0 | } } \ |
1129 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1130 | 0 | if ( ((rec_t*)rec)->name_field ) { \ |
1131 | 0 | *out_ptr = g_strdup((((rec_t*)rec)->name_field)); \ |
1132 | 0 | *out_len = (unsigned)strlen(*out_ptr); \ |
1133 | 0 | } else { \ |
1134 | 0 | *out_ptr = g_strdup(""); *out_len = 0; \ |
1135 | 0 | } } |
1136 | | |
1137 | | |
1138 | | #define UAT_FLD_DISSECTOR(basename,field_name,title,desc) \ |
1139 | 75 | {#field_name, title, PT_TXTMOD_DISSECTOR,{uat_fld_chk_proto,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
1140 | | |
1141 | | #define UAT_FLD_DISSECTOR_OTHER(basename,field_name,title,chk,desc) \ |
1142 | | {#field_name, title, PT_TXTMOD_DISSECTOR,{chk,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL} |
1143 | | |
1144 | | /* |
1145 | | * RANGE macros |
1146 | | */ |
1147 | | |
1148 | | #define UAT_RANGE_CB_DEF(basename,field_name,rec_t) \ |
1149 | 0 | static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* UNUSED_PARAMETER(u1), const void* u2) {\ |
1150 | 0 | char* rng = g_strndup(buf,len);\ |
1151 | 0 | range_convert_str(NULL, &(((rec_t*)rec)->field_name), rng,GPOINTER_TO_UINT(u2)); \ |
1152 | 0 | g_free(rng); \ |
1153 | 0 | } \ |
1154 | 0 | static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\ |
1155 | 0 | if ( ((rec_t*)rec)->field_name ) { \ |
1156 | 0 | *out_ptr = range_convert_range(NULL, ((rec_t*)rec)->field_name); \ |
1157 | 0 | *out_len = (unsigned)strlen(*out_ptr); \ |
1158 | 0 | } else { \ |
1159 | 0 | *out_ptr = g_strdup(""); *out_len = 0; \ |
1160 | 0 | } } |
1161 | | |
1162 | | |
1163 | | #define UAT_FLD_RANGE(basename,field_name,title,max,desc) \ |
1164 | 60 | {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_range,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},\ |
1165 | 60 | {0,0,0},GUINT_TO_POINTER(max),desc,FLDFILL} |
1166 | | |
1167 | | #ifdef __cplusplus |
1168 | | } |
1169 | | #endif /* __cplusplus */ |
1170 | | |
1171 | | /* |
1172 | | * Editor modelines |
1173 | | * |
1174 | | * Local Variables: |
1175 | | * c-basic-offset: 4 |
1176 | | * tab-width: 8 |
1177 | | * indent-tabs-mode: nil |
1178 | | * End: |
1179 | | * |
1180 | | * ex: set shiftwidth=4 tabstop=8 expandtab: |
1181 | | * :indentSize=4:tabSize=8:noTabs=true: |
1182 | | */ |