aboutgitcodebugslistschat
path: root/port_fwd.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-24 19:08:17 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-24 14:48:35 +0200
commit163dc5f18899808e97b92ddae0314928c903bb4b (patch)
treed2e8984fe9f1b77fbdf5e878173a666c7a66f801 /port_fwd.h
parent1128fa03fe73092dc68f30d0550283f0897d1f89 (diff)
downloadpasst-163dc5f18899808e97b92ddae0314928c903bb4b.tar
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.gz
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.bz2
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.lz
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.xz
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.zst
passt-163dc5f18899808e97b92ddae0314928c903bb4b.zip
Consolidate port forwarding configuration into a common structure
The configuration for how to forward ports in and out of the guest/ns is divided between several different variables. For each connect direction and protocol we have a mode in the udp/tcp context structure, a bitmap of which ports to forward also in the context structure and an array of deltas to apply if the outward facing and inward facing port numbers are different. This last is a separate global variable, rather than being in the context structure, for no particular reason. UDP also requires an additional array which has the reverse mapping used for return packets. Consolidate these into a re-used substructure in the context structure. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'port_fwd.h')
-rw-r--r--port_fwd.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/port_fwd.h b/port_fwd.h
index b938022..7e6a7d7 100644
--- a/port_fwd.h
+++ b/port_fwd.h
@@ -16,4 +16,16 @@ enum port_fwd_mode {
#define PORT_BITMAP_SIZE DIV_ROUND_UP(USHRT_MAX, 8)
+/**
+ * port_fwd - Describes port forwarding for one protocol and direction
+ * @mode: Overall forwarding mode (all, none, auto, specific ports)
+ * @map: Bitmap describing which ports are forwarded
+ * @delta: Offset between the original destination and mapped port number
+ */
+struct port_fwd {
+ enum port_fwd_mode mode;
+ uint8_t map[PORT_BITMAP_SIZE];
+ in_port_t delta[USHRT_MAX];
+};
+
#endif /* PORT_FWD_H */