1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _ACT_PEDIT_H_
14#define _ACT_PEDIT_H_ 1
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <unistd.h>
19#include <fcntl.h>
20#include <sys/socket.h>
21#include <netinet/in.h>
22#include <arpa/inet.h>
23#include <string.h>
24#include "utils.h"
25#include "tc_util.h"
26#include <linux/tc_act/tc_pedit.h>
27
28#define MAX_OFFS 128
29
30#define TIPV4 1
31#define TIPV6 2
32#define TINT 3
33#define TU32 4
34#define TMAC 5
35
36#define RU32 0xFFFFFFFF
37#define RU16 0xFFFF
38#define RU8 0xFF
39
40#define PEDITKINDSIZ 16
41
42enum m_pedit_flags {
43 PEDIT_ALLOW_DEC = 1<<0,
44};
45
46struct m_pedit_key {
47 __u32 mask;
48 __u32 val;
49 __u32 off;
50 __u32 at;
51 __u32 offmask;
52 __u32 shift;
53
54 enum pedit_header_type htype;
55 enum pedit_cmd cmd;
56};
57
58struct m_pedit_key_ex {
59 enum pedit_header_type htype;
60 enum pedit_cmd cmd;
61};
62
63struct m_pedit_sel {
64 struct tc_pedit_sel sel;
65 struct tc_pedit_key keys[MAX_OFFS];
66 struct m_pedit_key_ex keys_ex[MAX_OFFS];
67 bool extended;
68};
69
70struct m_pedit_util {
71 struct m_pedit_util *next;
72 char id[PEDITKINDSIZ];
73 int (*parse_peopt)(int *argc_p, char ***argv_p,
74 struct m_pedit_sel *sel,
75 struct m_pedit_key *tkey);
76};
77
78int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type,
79 __u32 retain,
80 struct m_pedit_sel *sel, struct m_pedit_key *tkey, int flags);
81#endif
82