summaryrefslogtreecommitdiffstats
path: root/tc/m_pedit.h
blob: 8f3771e162553d852d8dc7afc7a05dbc89d53414 (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
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
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * m_pedit.h		generic packet editor actions module
 *
 *
 * Authors:  J Hadi Salim (hadi@cyberus.ca)
 *
 */

#ifndef _ACT_PEDIT_H_
#define _ACT_PEDIT_H_ 1

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "utils.h"
#include "tc_util.h"
#include <linux/tc_act/tc_pedit.h>

#define MAX_OFFS 128

#define TIPV4 1
#define TIPV6 2
#define TINT 3
#define TU32 4
#define TMAC 5

#define RU32 0xFFFFFFFF
#define RU16 0xFFFF
#define RU8 0xFF

#define PEDITKINDSIZ 16

enum m_pedit_flags {
	PEDIT_ALLOW_DEC = 1<<0,
};

struct m_pedit_key {
	__u32           mask;  /* AND */
	__u32           val;   /*XOR */
	__u32           off;  /*offset */
	__u32           at;
	__u32           offmask;
	__u32           shift;

	enum pedit_header_type htype;
	enum pedit_cmd cmd;
};

struct m_pedit_key_ex {
	enum pedit_header_type htype;
	enum pedit_cmd cmd;
};

struct m_pedit_sel {
	struct tc_pedit_sel sel;
	struct tc_pedit_key keys[MAX_OFFS];
	struct m_pedit_key_ex keys_ex[MAX_OFFS];
	bool extended;
};

struct m_pedit_util {
	struct m_pedit_util *next;
	char    id[PEDITKINDSIZ];
	int     (*parse_peopt)(int *argc_p, char ***argv_p,
			       struct m_pedit_sel *sel,
			       struct m_pedit_key *tkey);
};

int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type,
	      __u32 retain,
	      struct m_pedit_sel *sel, struct m_pedit_key *tkey, int flags);
#endif