rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #ifndef _L5MIPC_STRUCT_H_ |
| 2 | #define _L5MIPC_STRUCT_H_ |
| 3 | |
| 4 | #include "l5_common.h" |
| 5 | |
| 6 | /** Filter rule */ |
| 7 | #define IPC_FILTER_BY_PROTOCOL (0x0001 << 0) |
| 8 | #define IPC_FILTER_BY_SRC_PORT (0x0001 << 1) |
| 9 | #define IPC_FILTER_BY_DST_PORT (0x0001 << 2) |
| 10 | #define IPC_FILTER_BY_SRC_IPV4 (0x0001 << 3) |
| 11 | #define IPC_FILTER_BY_DST_IPV4 (0x0001 << 4) |
| 12 | #define IPC_FILTER_BY_SRC_IPV6 (0x0001 << 5) |
| 13 | #define IPC_FILTER_BY_DST_IPV6 (0x0001 << 6) |
| 14 | #define IPC_FILTER_BY_ICMPV4_TYPE (0x0001 << 7) |
| 15 | #define IPC_FILTER_BY_ICMPV6_TYPE (0x0001 << 8) |
| 16 | #define IPC_FILTER_BY_EBI (0x0001 << 9) |
| 17 | #define IPC_FILTER_BY_PDN_ID (0x0001 << 10) |
| 18 | #define IPC_FILTER_BY_NETIF_ID (0x0001 << 11) |
| 19 | #define IPC_FILTER_BY_TCP_FLAGS (0x0001 << 12) |
| 20 | #define IPC_FILTER_BY_SPI (0x0001 << 13) |
| 21 | |
| 22 | #define IPC_IP_TYPE_IPV4 1 |
| 23 | #define IPC_IP_TYPE_IPV6 2 |
| 24 | |
| 25 | /* |
| 26 | * IANA IP Protocol Numbers. |
| 27 | * Ref: http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml |
| 28 | */ |
| 29 | #define IPC_HDR_PROT_IPV6_HOP 0 /* IPv6 Hop-by-Hop Option */ |
| 30 | #define IPC_HDR_PROT_ICMP 1 /* Internet Control Message */ |
| 31 | #define IPC_HDR_PROT_IPV4_ENC 4 /* IPv4 encapsulation */ |
| 32 | #define IPC_HDR_PROT_TCP 6 /* Transmission Control */ |
| 33 | #define IPC_HDR_PROT_UDP 17 /* User Datagram */ |
| 34 | #define IPC_HDR_PROT_IPV6_ENC 41 /* IPv6 encapsulation */ |
| 35 | #define IPC_HDR_PROT_IPV6_ROUTE 43 /* Routing Header for IPv6 */ |
| 36 | #define IPC_HDR_PROT_IPV6_FRAG 44 /* Fragment Header for IPv6 */ |
| 37 | #define IPC_HDR_PROT_ESP 50 /* Encap Security Payload */ |
| 38 | #define IPC_HDR_PROT_AH 51 /* Authentication Header */ |
| 39 | #define IPC_HDR_PROT_ICMPV6 58 /* ICMP for IPv6 */ |
| 40 | #define IPC_HDR_PROT_IPV6_NONEXT 59 /* No Next Header for IPv6 */ |
| 41 | #define IPC_HDR_PROT_IPV6_DEST 60 /* Destination Options for IPv6 */ |
| 42 | |
| 43 | /* |
| 44 | * TCP_FLAG. |
| 45 | */ |
| 46 | #define IPC_HDR_TCP_FLAG_FIN 0x01 |
| 47 | #define IPC_HDR_TCP_FLAG_SYN 0x02 |
| 48 | #define IPC_HDR_TCP_FLAG_RST 0x04 // Reset |
| 49 | #define IPC_HDR_TCP_FLAG_PUSH 0x08 |
| 50 | #define IPC_HDR_TCP_FLAG_ACK 0x10 |
| 51 | #define IPC_HDR_TCP_FLAG_URG 0x20 // Urgent |
| 52 | #define IPC_HDR_TCP_FLAG_ECE 0x40 // ECN Echo |
| 53 | #define IPC_HDR_TCP_FLAG_CWR 0x80 // Congestion Window Reduced |
| 54 | #define IPC_HDR_TCP_FLAG_NS 0x100 // ECN-nonce concealment protection (added to header by RFC 3540) |
| 55 | |
| 56 | typedef struct { |
| 57 | L5IO_L5U_LOCAL_PARA_HDR |
| 58 | |
| 59 | kal_uint8 nccmni_net_if; //kal_uint8 |
| 60 | kal_uint8 reserve1; |
| 61 | kal_uint16 nccmni_seq; |
| 62 | |
| 63 | kal_uint32 valid_field; //mandatory, a bitmap, refer to IPC_FILTER_BY_XXX |
| 64 | kal_uint8 ip_type; //IPC_IP_TYPE_IPV4 or IPC_IP_TYPE_IPV6 |
| 65 | kal_uint8 ctrl_protocol; //IPC_HDR_PROT_XXX |
| 66 | kal_uint16 src_port; |
| 67 | kal_uint16 dst_port; |
| 68 | kal_uint16 tcp_flags; //IPC_HDR_TCP_FLAG_XXX |
| 69 | kal_uint32 spi; // |
| 70 | union{ |
| 71 | kal_uint8 addr8[4]; |
| 72 | kal_uint32 addr32; |
| 73 | } src_ipv4; // Source IPv4 address to filter. |
| 74 | union{ |
| 75 | kal_uint8 addr8[4]; |
| 76 | kal_uint32 addr32; |
| 77 | } dst_ipv4; // Destination IPv4 address to filter. |
| 78 | |
| 79 | union{ |
| 80 | kal_uint8 addr8[16]; |
| 81 | kal_uint32 addr32[4]; |
| 82 | } src_ipv6; // Source IPv6 address to filter. |
| 83 | union{ |
| 84 | kal_uint8 addr8[16]; |
| 85 | kal_uint32 addr32[4]; |
| 86 | } dst_ipv6; // Destination IPv6 address to filter. |
| 87 | |
| 88 | kal_uint8 icmpv4_type; // Type field of ICMPv4 header to filter. |
| 89 | kal_uint8 icmpv6_type; // Type field of ICMPv6 header to filter. |
| 90 | kal_uint16 reserve2; |
| 91 | kal_uint32 features; |
| 92 | } l5io_set_filter_req_struct; |
| 93 | |
| 94 | typedef struct { |
| 95 | L5IO_L5U_LOCAL_PARA_HDR |
| 96 | |
| 97 | kal_uint8 nccmni_net_if; //kal_uint8 |
| 98 | kal_uint8 reserve1; |
| 99 | kal_uint16 nccmni_seq; |
| 100 | |
| 101 | kal_int32 filter_id; //>=0: filter id, <0: set failed |
| 102 | } l5io_set_filter_cnf_struct; |
| 103 | |
| 104 | typedef struct { |
| 105 | L5IO_L5U_LOCAL_PARA_HDR |
| 106 | |
| 107 | kal_uint8 nccmni_net_if; //kal_uint8 |
| 108 | kal_uint8 reserve1; |
| 109 | kal_uint16 nccmni_seq; |
| 110 | |
| 111 | kal_int32 is_deregister_all_filter; //0: deregister the filter id only, 1: deregister all filter |
| 112 | kal_int32 filter_id; //filter id to deregister |
| 113 | } l5io_reset_filter_req_struct; |
| 114 | |
| 115 | typedef struct { |
| 116 | L5IO_L5U_LOCAL_PARA_HDR |
| 117 | |
| 118 | kal_uint8 nccmni_net_if; //kal_uint8 |
| 119 | kal_uint8 reserve1; |
| 120 | kal_uint16 nccmni_seq; |
| 121 | |
| 122 | kal_int32 is_success; //1: succes |
| 123 | } l5io_reset_filter_cnf_struct; |
| 124 | |
| 125 | |
| 126 | #endif |
| 127 | |