This file is indexed.

/usr/include/paristraceroute/field.h is in libparistraceroute-dev 0.93+git20160927-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
#ifndef FIELD_H
#define FIELD_H

/**
 * \file field.h
 * \brief A field is a part of a header network protocol.
 */

#include <stddef.h>  // size_t
#include <stdint.h>  // uint*_t
#include <stdbool.h> // bool

#include "address.h" // address_t, ipv4_t, ipv6_t

struct generator_s;

typedef union{
	uint32_t	d32[4];
	uint64_t	d64[2];
} uint128_t;

/**
 * \enum fieldtype_t
 * \brief Enumeration of the possible data types for a field
 */

typedef enum {
#ifdef USE_IPV4
    TYPE_IPV4,              /**< ipv4_t structure */
#endif
#ifdef USE_IPV6
    TYPE_IPV6,              /**< ipv6_t structure */
#endif
#ifdef USE_BITS
    TYPE_BITS,              /**< n < 8 bits integer (right aligned) */
#endif
    TYPE_UINT8,             /**< 8 bits integer     */
    TYPE_UINT16,            /**< 16 bits integer    */
    TYPE_UINT32,            /**< 32 bits integer    */
    TYPE_UINT64,            /**< 64 bits integer    */
    TYPE_UINT128,           /**< 128 bits integer   */
    TYPE_UINTMAX,           /**< max integer        */
    TYPE_DOUBLE,            /**< double             */
    TYPE_STRING,            /**< string             */
    TYPE_GENERATOR          /**< generator          */
} fieldtype_t;

/**
 * \brief Convert a field type in the corresponding human
 *    readable string. 
 * \param type A field type.
 * \return The corresponding string.
 */

const char * field_type_to_string(fieldtype_t type);

/**
 * \union value_t
 * \brief Store a value carried by a field.
 */

typedef union {
    void                * value;     /**< Pointer to raw data                */
#ifdef USE_IPV4
    ipv4_t                ipv4;      /**< Value of data as a IPv4 address    */
#endif
#ifdef USE_IPV6
    ipv6_t                ipv6;      /**< Value of data as a IPv6 address    */
#endif
#ifdef USE_BITS
    // TODO test with uint128_t to handle bigger bit-level fields
    uint8_t               bits;      /**< Value of data as a n<8 bit integer */
#endif
    uint8_t               int8;      /**< Value of data as a   8 bit integer */
    uint16_t              int16;     /**< Value of data as a  16 bit integer */
    uint32_t              int32;     /**< Value of data as a  32 bit integer */
    uint64_t              int64;     /**< Value of data as a  64 bit integer */
    uint128_t             int128;    /**< Value of data as a 128 bit integer */
    uintmax_t             intmax;    /**< Value of data as a max integer     */
    double                dbl;       /**< Value of data as a double          */
    char                * string;    /**< Pointer to string data             */
    struct generator_s  * generator; /**< Pointer to generator_t data        */
} value_t;

/**
 * \brief Print a value_t instance in the standard output.
 * \param value The value_t instance to print.
 * \param type The value type. 
 */

void value_dump(const value_t * value, fieldtype_t type); 

/**
 * \brief Print a value_t instance in the standard output.
 *    Most of time you're interested in pritting this information
 *    using the network-side endianness, so you should previously
 *    do this translation using value_htons().
 * \param value The value_t instance to print.
 * \param type The value type. 
 */

void value_dump_hex(const value_t * value, size_t num_bytes, size_t offset_in_bits, size_t num_bits);

/**
 * \struct field_t
 * \brief Structure describing a header field
 */

typedef struct {
    const char  * key;   /**< Pointer to a unique identifier key; the
                          * referenced memory is not freed when the
                          * field is freed */
    value_t       value; /**< Union of all field data; the referenced
                          * memory is freed if it's a string or
                          * generator, when the field is freed */
    fieldtype_t   type;  /**< Type of data stored in the field */
} field_t;

/**
 * \brief Create a field structure to hold a generic address. 
 * \param key The name which identify the field to create.
 * \param address Address to store in the field.
 * \return Structure containing the newly created field.
 */

field_t * field_create_address(const char * key, const address_t * address);

#ifdef USE_IPV4
/**
 * \brief Create a field structure to hold an IPv4 address. 
 * \param key The name which identify the field to create.
 * \param address Address to store in the field.
 * \return Structure containing the newly created field.
 */

field_t * field_create_ipv4(const char * key, ipv4_t ipv4);
#endif

#ifdef USE_IPV6
/**
 * \brief Create a field structure to hold an IPv6 address. 
 * \param key The name which identify the field to create.
 * \param address Address to store in the field.
 * \return Structure containing the newly created field.
 */

field_t * field_create_ipv6(const char * key, ipv6_t ipv6);
#endif

#ifdef USE_BITS
/**
 * \brief Create a field structure to hold an n<8 bit integer value.
 * \param key The name which identify the field to create.
 * \param value Value to store in the field.
 * \param size_in_bits
 * \return Structure containing the newly created field.
 */

field_t * field_create_bits(const char * key, const void * value, size_t offset_in_bits, size_t size_in_bits);
#endif

/**
 * \brief Create a field structure to hold an 8 bit integer value
 * \param key The name which identify the field to create
 * \param value Value to store in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_uint8(const char * key, uint8_t value);

/**
 * \brief Create a field structure to hold a 16 bit integer value
 * \param key The name which identify the field to create
 * \param value Value to store in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_uint16(const char * key, uint16_t value);

/**
 * \brief Create a field structure to hold a 32 bit integer value
 * \param key The name which identify the field to create
 * \param value Value to store in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_uint32(const char * key, uint32_t value);

/**
 * \brief Create a field structure to hold a 64 bit integer value
 * \param key The name which identify the field to create
 * \param value Value to store in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_uint64(const char * key, uint64_t value);

/**
 * \brief Create a field structure to hold a 128 bit integer value
 * \param key The name which identify the field to create
 * \param value Value to store in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_uint128(const char * key, uint128_t value);

/**
 * \brief Create a field structure to hold a uintmax_t value
 * \param key The name which identify the field to create
 * \param value Value to store in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_uintmax(const char * key, uintmax_t value);

/**
 * \brief Create a field structure to hold a double value
 * \param key The name which identify the field to create
 * \param value Value to store in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_double(const char * key, double value);

/**
 * \brief Create a field structure to hold a string
 * \param key The name which identify the field to create
 * \param value Value to copy in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_string(const char * key, const char * value);

/**
 * \brief Create a field structure to hold a generator
 * \param key The name which identify the field to create
 * \param value Value to copy in the field
 * \return Structure containing the newly created field
 */

field_t * field_create_generator(const char * key, struct generator_s * value);

/**
 * \brief Create a field structure to hold an address
 * \param key The name which identify the field to create
 * \param value Address to copy in the field. You may pass NULL to
 *    let the value field uninitialized.
 * \return Structure containing the newly created field
 */

field_t * field_create(fieldtype_t type, const char * key, const void * value);

/**
 * \brief Delete a field structure
 * \param field Pointer to the field structure to delete
 */

void field_free(field_t * field);

/**
 * \brief Duplicate a field instance
 * \param field The field instance that we're duplicating .
 * \return The duplicated field instance if successful, NULL otherwise.
 */

field_t * field_dup(const field_t * field);

#ifdef USE_IPV4
/**
 * \brief Macro shorthand for field_create_ipv4
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#    define IPV4(x, y)  field_create_ipv4(x, (ipv4_t) y)
#endif

#ifdef USE_IPV6
/**
 * \brief Macro shorthand for field_create_ipv6
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#    define IPV6(x, y)  field_create_ipv6(x, (ipv6_t) y)
#endif

/**
 * \brief Macro shorthand for field_create_address
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#define ADDRESS(x, y)  field_create_address(x, y)

#ifdef USE_BITS
#    define BITS(key, size_in_bits, value)  field_create_bits(key, (const void *) (value), sizeof(value) - size_in_bits, size_in_bits)
#endif

/**
 * \brief Macro shorthand for field_create_uint8
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#define I8(x, y)  field_create_uint8(x, (uint8_t) y)

/**
 * \brief Macro shorthand for field_create_uint16
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#define I16(x, y) field_create_uint16(x, (uint16_t) y)

/**
 * \brief Macro shorthand for field_create_uint32
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#define I32(x, y) field_create_uint32(x, (uint32_t) y)

/**
 * \brief Macro shorthand for field_create_uint64
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#define I64(x, y) field_create_uint64(x, (uint64_t) y)

/**
 * \brief Macro shorthand for field_create_uint128
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#define I128(x, y) field_create_uint64(x, (uint128_t) y)

/**
 * \brief Macro shorthand for field_create_double
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#define DOUBLE(x, y) field_create_double(x, (double) y)

/**
 * \brief Macro shorthand for field_create_intmax
 * \param x Pointer to a char * key to identify the field
 * \param y Value to store in the field
 * \return Structure containing the newly created field
 */

#define IMAX(x, y) field_create_uintmax(x, (uintmax_t) y)

/**
 * \brief Macro shorthand for field_create_string
 * \param x Pointer to a char * key to identify the field
 * \param y String to store in the field
 * \return Structure containing the newly created field
 */

#define STR(x, y) field_create_string(x, y)

/**
 * \brief Macro shorthand for field_create_generator
 * \param x Pointer to a char * key to identify the field
 * \param y Pointer to the generator to store in the field
 * \return Structure containing the newly created field
 */

#define GENERATOR(x, y) field_create_generator(x, y)

/**
 * \brief Return the size (in bytes) related to a field type
 * \param type A field type
 * \return
 *    1               if type == TYPE_UINT4
 *    sizeof(void * ) if type == TYPE_STRING or TYPE_GENERATOR
 *    the size of the field value in bytes otherwise 
 */

size_t field_get_type_size(fieldtype_t type);

/**
 * \brief Return the size (in bytes) related to a field
 * \param field A field instance
 * \return See field_get_type_size 
 */

size_t field_get_size(const field_t * field);

/**
 * \brief Compare two fields value, for instance in order to sort them
 * \param field1 The first field instance
 * \param field2 The second field instance
 * \return -2 if field1 and field2 cannot be compared
 *         -3 if the field type is not supported
 *          1 if field1 < field2
 *         -1 if field1 > field2
 *          0 if field1 == field2
 */
//int field_compare(const field_t * field1, const field_t * field2);

bool field_match(const field_t * field1, const field_t * field2);


const char * field_get_key(field_t * field);

bool field_set_value(field_t * field, void * value);

/**
 * \brief Print the content of a field
 * \param field A field instance
 */

void field_dump(const field_t * field);

#endif