developer | 0f54b52 | 2023-03-08 10:04:11 +0800 | [diff] [blame] | 1 | #include <netinet/in.h> |
| 2 | #include <arpa/inet.h> |
| 3 | #include <libnfnetlink/libnfnetlink.h> |
| 4 | |
| 5 | struct ftnl_handle { |
| 6 | struct nfnl_handle *nfnlh; |
| 7 | struct nfnl_subsys_handle *ftnlssh; |
| 8 | }; |
| 9 | |
| 10 | struct flow_tuple { |
| 11 | struct in_addr sip4; |
| 12 | struct in_addr dip4; |
| 13 | unsigned char proto; |
| 14 | unsigned short int sport; |
| 15 | unsigned short int dport; |
| 16 | }; |
| 17 | |
| 18 | enum ft_msg_types { |
| 19 | FT_MSG_DEL, |
| 20 | FT_MSG_ADD, //not support now |
| 21 | FT_MSG_FLUSH, |
| 22 | FT_MSG_MAX |
| 23 | }; |
| 24 | |
| 25 | enum ftattr_type { |
| 26 | FTA_UNSPEC, |
| 27 | FTA_TUPLE, |
| 28 | __FTA_MAX |
| 29 | }; |
| 30 | #define FTA_MAX (__FTA_MAX - 1) |
| 31 | |
| 32 | enum ftattr_tuple { |
| 33 | FTA_TUPLE_UNSPEC, |
| 34 | FTA_TUPLE_IP, |
| 35 | FTA_TUPLE_PROTO, |
| 36 | FTA_TUPLE_ZONE, |
| 37 | __FTA_TUPLE_MAX |
| 38 | }; |
| 39 | #define FTA_TUPLE_MAX (__FTA_TUPLE_MAX - 1) |
| 40 | |
| 41 | enum ftattr_ip { |
| 42 | FTA_IP_UNSPEC, |
| 43 | FTA_IP_V4_SRC, |
| 44 | FTA_IP_V4_DST, |
| 45 | FTA_IP_V6_SRC, |
| 46 | FTA_IP_V6_DST, |
| 47 | __FTA_IP_MAX |
| 48 | }; |
| 49 | #define FTA_IP_MAX (__FTA_IP_MAX - 1) |
| 50 | |
| 51 | enum ftattr_l4proto { |
| 52 | FTA_PROTO_UNSPEC, |
| 53 | FTA_PROTO_NUM, |
| 54 | FTA_PROTO_SPORT, |
| 55 | FTA_PROTO_DPORT, |
| 56 | __FTA_PROTO_MAX |
| 57 | }; |
| 58 | #define FTA_PROTO_MAX (__FTA_PROTO_MAX - 1) |
| 59 | |
| 60 | struct ftnl_handle *ftnl_open(void); |
| 61 | void ftnl_close(struct ftnl_handle *h); |
| 62 | int ftnl_flush_table(struct ftnl_handle *h); |
| 63 | int ftnl_del_flow(struct ftnl_handle *h, struct flow_tuple *tuple); |