nat: Include platform specific headers on FreeBSD
[vpp.git] / src / plugins / nat / pnat / pnat.rst
1 PNAT 1:1 match & rewrite NAT
2 ============================
3
4 PNAT is a stateless statically configured, match and rewrite plugin. It
5 uses a set of match and rewrite rules that are applied on the IP input
6 and output feature paths. A PNAT rule is unidirectional.
7
8 The match is done using up to a 6-tuple; IP source and destination
9 address, IP protocol, transport layer source and destination ports, and
10 FIB table / interface index.
11
12 While multiple match/rewrite rules can be applied to an interface (per
13 direction), the match pattern must be the same across all rules on that
14 interface/direction.
15
16 If required in the future, matching could be done using the general
17 classifier, allowing matching on any protocol field, as well having an
18 ordered set of match patterns.
19
20 If the packet does not match, it will by default be passed to the next
21 graph node in the feature chain. If desired a different miss behaviour
22 could be implemented, e.g. similarly to dynamic NAT, the packet punted
23 to a slow path.
24
25 Rewrite instructions
26 --------------------
27
28 .. code:: c
29
30    typedef enum {
31      PNAT_INSTR_NONE                   = 1 << 0,
32      PNAT_INSTR_SOURCE_ADDRESS         = 1 << 1,
33      PNAT_INSTR_SOURCE_PORT            = 1 << 2,
34      PNAT_INSTR_DESTINATION_ADDRESS    = 1 << 3,
35      PNAT_INSTR_DESTINATION_PORT       = 1 << 4,
36    } pnat_instructions_t;
37
38 These are the supported rewrite instructions. The IP checksum and the
39 TCP/UDP checksum are incrementally updated as required.
40
41 There are only a few “sanity checks” on the rewrites. For example, the
42 rewrite in the outbound direction is applied on the ip-output feature
43 chain. If one were to rewrite the IP destination address, the routing
44 decision and determination of the next-hop has already been done, and
45 the packet would still be forwarded to the original next-hop.