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