summaryrefslogtreecommitdiffstats
path: root/include/udata.h
blob: 407a3b9552d1d0dede0438440fadb2b4c80e7b75 (plain)
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
#ifndef _LIBNFTNL_UDATA_INTERNAL_H_
#define _LIBNFTNL_UDATA_INTERNAL_H_

#include <stdint.h>
#include <stddef.h>

/*
 * TLV structures:
 * nftnl_udata
 *  <-------- HEADER --------> <------ PAYLOAD ------>
 * +------------+-------------+- - - - - - - - - - - -+
 * |    type    |     len     |         value         |
 * |  (1 byte)  |   (1 byte)  |                       |
 * +--------------------------+- - - - - - - - - - - -+
 *  <-- sizeof(nftnl_udata) -> <-- nftnl_udata->len -->
 */
struct nftnl_udata {
	uint8_t		type;
	uint8_t		len;
	unsigned char	value[];
} __attribute__((__packed__));

/*
 *              +---------------------------------++
 *              | data[]                          ||
 *              |   ||                            ||
 *              |   \/                            \/
 *  +-------+-------+-------+-------+ ... +-------+- - - - - - -+
 *  | size  |  end  |  TLV  |  TLV  |     |  TLV  |    Empty    |
 *  +-------+-------+-------+-------+ ... +-------+- - - - - - -+
 *                  |<---- nftnl_udata_len() ---->|
 *                  |<----------- nftnl_udata_size() ---------->|
 */
struct nftnl_udata_buf {
	uint32_t	size;
	char		*end;
	char		data[];
};

#endif /* _LIBNFTNL_UDATA_INTERNAL_H_ */