-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.h
More file actions
42 lines (33 loc) · 1.75 KB
/
Copy pathheader.h
File metadata and controls
42 lines (33 loc) · 1.75 KB
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
// Copyright (c) 2023-2025, Ericsson AB and Ericsson Telecommunication Hungary
// All rights reserved.
#ifndef DNT_HEADER_H
#define DNT_HEADER_H
#include "protocol.h"
#include "value.h"
// identifies a field in a packet header
// @header_idx identifies which header of the packet to look at (starts with 0)
// @bitoffset is the number of bits to skip at the beginning of the header
// @bitcount is the number of bits the header field has
struct HeaderField {
unsigned header_idx;
unsigned bitoffset;
unsigned bitcount;
};
// the caller has to make sure that @header_idx points to a header that has the correct type
struct HeaderField *new_headerfield(unsigned header_idx, const struct ProtocolField *pfield);
// @returns a suitable function for writing to @target field from @source
// the decision is based on the offsets and the lengths
// the HeaderField::header_idx is ignored
// the state of the returned writer function should be @target
value_consumer *header_get_field_writer(const struct HeaderField *target, const struct Value *source);
// returns a suitable function for reading this @source field into @target
// the decision is based on the offsets and the lengths
// the HeaderField::header_idx is ignored
// the state of the returned reader function should be @source
value_producer *header_get_field_reader(const struct Value *target, const struct HeaderField *source);
// @returns a suitable function for comparing @target field of the header with @match value
// the decision is based on the offsets and the lengths
// the HeaderField::header_idx is ignored
// the state of the returned comparator function should be @target
value_comparator *header_get_field_comprator(const struct HeaderField *target, const struct Value *match);
#endif // DNT_HEADER_H