Dave Hudson | dcd08fb | 2013-11-22 09:25:16 -0600 | [diff] [blame] | 1 | /* |
| 2 | * sfe_ipv4.h |
| 3 | * Shortcut forwarding engine. |
| 4 | * |
| 5 | * XXX - fill in the appropriate GPL notice. |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * IPv4 connection flags. |
| 10 | */ |
| 11 | #define SFE_IPV4_CREATE_FLAG_NO_SEQ_CHECK 0x1 |
| 12 | /* Indicates that we should not check sequence numbers */ |
| 13 | |
| 14 | /* |
| 15 | * IPv4 connection creation structure. |
| 16 | */ |
| 17 | struct sfe_ipv4_create { |
| 18 | int protocol; |
| 19 | struct net_device *src_dev; |
| 20 | struct net_device *dest_dev; |
| 21 | uint32_t flags; |
| 22 | uint32_t src_mtu; |
| 23 | uint32_t dest_mtu; |
| 24 | __be32 src_ip; |
| 25 | __be32 src_ip_xlate; |
| 26 | __be32 dest_ip; |
| 27 | __be32 dest_ip_xlate; |
| 28 | __be16 src_port; |
| 29 | __be16 src_port_xlate; |
| 30 | __be16 dest_port; |
| 31 | __be16 dest_port_xlate; |
| 32 | uint8_t src_mac[ETH_ALEN]; |
| 33 | uint8_t src_mac_xlate[ETH_ALEN]; |
| 34 | uint8_t dest_mac[ETH_ALEN]; |
| 35 | uint8_t dest_mac_xlate[ETH_ALEN]; |
| 36 | uint8_t src_td_window_scale; |
| 37 | uint32_t src_td_max_window; |
| 38 | uint32_t src_td_end; |
| 39 | uint32_t src_td_max_end; |
| 40 | uint8_t dest_td_window_scale; |
| 41 | uint32_t dest_td_max_window; |
| 42 | uint32_t dest_td_end; |
| 43 | uint32_t dest_td_max_end; |
Matthew McClintock | be7b47d | 2013-11-27 13:26:23 -0600 | [diff] [blame^] | 44 | uint32_t mark; |
Dave Hudson | dcd08fb | 2013-11-22 09:25:16 -0600 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | /* |
| 48 | * IPv4 connection destruction structure. |
| 49 | */ |
| 50 | struct sfe_ipv4_destroy { |
| 51 | int protocol; |
| 52 | __be32 src_ip; |
| 53 | __be32 dest_ip; |
| 54 | __be16 src_port; |
| 55 | __be16 dest_port; |
| 56 | }; |
| 57 | |
| 58 | /* |
| 59 | * Structure used to sync IPv4 connection stats/state back within the system. |
| 60 | * |
| 61 | * NOTE: The addresses here are NON-NAT addresses, i.e. the true endpoint addressing. |
| 62 | * 'src' is the creator of the connection. |
| 63 | */ |
| 64 | struct sfe_ipv4_sync { |
| 65 | int protocol; /* IP protocol number (IPPROTO_...) */ |
| 66 | __be32 src_ip; /* Non-NAT source address, i.e. the creator of the connection */ |
| 67 | __be16 src_port; /* Non-NAT source port */ |
| 68 | __be32 dest_ip; /* Non-NAT destination address, i.e. to whom the connection was created */ |
| 69 | __be16 dest_port; /* Non-NAT destination port */ |
| 70 | uint32_t src_td_max_window; |
| 71 | uint32_t src_td_end; |
| 72 | uint32_t src_td_max_end; |
| 73 | uint64_t src_packet_count; |
| 74 | uint64_t src_byte_count; |
| 75 | uint32_t dest_td_max_window; |
| 76 | uint32_t dest_td_end; |
| 77 | uint32_t dest_td_max_end; |
| 78 | uint64_t dest_packet_count; |
| 79 | uint64_t dest_byte_count; |
| 80 | uint64_t delta_jiffies; /* Time to be added to the current timeout to keep the connection alive */ |
| 81 | }; |
| 82 | |
| 83 | /* |
| 84 | * Type used for a sync rule callback. |
| 85 | */ |
| 86 | typedef void (*sfe_ipv4_sync_rule_callback_t)(struct sfe_ipv4_sync *); |
| 87 | |
| 88 | extern int sfe_ipv4_recv(struct net_device *dev, struct sk_buff *skb); |
| 89 | extern void sfe_ipv4_create_rule(struct sfe_ipv4_create *sic); |
| 90 | extern void sfe_ipv4_destroy_rule(struct sfe_ipv4_destroy *sid); |
| 91 | extern void sfe_ipv4_destroy_all_rules_for_dev(struct net_device *dev); |
| 92 | extern void sfe_ipv4_register_sync_rule_callback(sfe_ipv4_sync_rule_callback_t callback); |
| 93 | |
Matthew McClintock | be7b47d | 2013-11-27 13:26:23 -0600 | [diff] [blame^] | 94 | /* |
| 95 | * IPv4 connection mark structure |
| 96 | */ |
| 97 | struct sfe_ipv4_mark { |
| 98 | int protocol; |
| 99 | __be32 src_ip; |
| 100 | __be32 dest_ip; |
| 101 | __be16 src_port; |
| 102 | __be16 dest_port; |
| 103 | uint32_t mark; |
| 104 | }; |
| 105 | static void sfe_ipv4_mark_rule(struct sfe_ipv4_mark *mark); |