/usr/include/paristraceroute/protocol_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 | #ifndef PROTOCOL_FIELD_H
#define PROTOCOL_FIELD_H
/**
* \file protocol_field.h
* \brief Header for the data fields of a protocol
*/
#include <stdint.h>
#include <stdbool.h>
#include "use.h" // USE_BITS
#include "field.h"
/**
* \struct protocol_field_t
* \brief Structure describing a data field for a protocol
*/
typedef struct {
const char * key; /**< Pointer to an identifying key */
fieldtype_t type; /**< Enum to set the type of data stored in the field */
size_t offset; /**< Offset from start of segment data */
#ifdef USE_BITS
size_t offset_in_bits; /**< Additional offset in bits for non-aligned fields (set to 0 otherwise) */
size_t size_in_bits; /**< Size in bits (only useful for non-aligned fields and fields not having a size equal to 8 * n bits */
#endif
// The following callbacks allows to perform specific treatment when we translate
// field content in packet content and vice versa. Most of time there are set
// to NULL and we call default functions which manage endianness and so on.
field_t * (*get)(const uint8_t * segment); /**< Allocate a field_t instance corresponding to this field */
bool (*set)(uint8_t * segment, const field_t * field); /**< Update a segment according to a field. Return true iif successful */
} protocol_field_t;
/**
* \brief Retrieve the size (in bytes) to a protocol field
* \param protocol_field A pointer to the protocol_field_t instance
* \return The corresponding size (in bytes)
*/
size_t protocol_field_get_size(const protocol_field_t * protocol_field);
/**
* \brief Write in a segment (a section of packet) the value stored in a field
* according to the size and the offset stored in a protocol_field_t instance.
* \param protocol_field A pointer to the corresponding protocol field.
* \param segment The segment related to the layer we're setting.
* \param field The field storing the value to write in the segment.
* \return true iif successful
*/
bool protocol_field_set(const protocol_field_t * protocol_field, uint8_t * segment, const field_t * field);
/**
* \brief Retrieve the offset stored in a protocol_field_t instance.
* \param protocol_field A pointer to a protocol_field_t instance.
* \return The corresponding offset.
*/
size_t protocol_field_get_offset(const protocol_field_t * protocol_field);
/**
* \brief Print information related to a protocol_field_t instance
* \param protocol_field The protocol_field_t instance to print
*/
void protocol_field_dump(const protocol_field_t * protocol_field);
#endif
|