public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob 0458a3c5078d87664a63db56764b0df26f1a8c10 1815 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright Red Hat
 * Author: Stefano Brivio <sbrivio@redhat.com>
 * Author: David Gibson <david@gibson.dropbear.id.au>
 */

#ifndef FWD_H
#define FWD_H

union inany_addr;
struct flowside;

/* Number of ports for both TCP and UDP */
#define	NUM_PORTS	(1U << 16)

void fwd_probe_ephemeral(void);
bool fwd_port_is_ephemeral(in_port_t port);

enum fwd_ports_mode {
	FWD_UNSET = 0,
	FWD_SPEC = 1,
	FWD_NONE,
	FWD_AUTO,
	FWD_ALL,
};

#define PORT_BITMAP_SIZE	DIV_ROUND_UP(NUM_PORTS, 8)

/**
 * fwd_ports - Describes port forwarding for one protocol and direction
 * @mode:	Overall forwarding mode (all, none, auto, specific ports)
 * @scan4:	/proc/net fd to scan for IPv4 ports when in AUTO mode
 * @scan6:	/proc/net fd to scan for IPv6 ports when in AUTO mode
 * @map:	Bitmap describing which ports are forwarded
 * @delta:	Offset between the original destination and mapped port number
 */
struct fwd_ports {
	enum fwd_ports_mode mode;
	int scan4;
	int scan6;
	uint8_t map[PORT_BITMAP_SIZE];
	in_port_t delta[NUM_PORTS];
};

void fwd_scan_ports_tcp(struct fwd_ports *fwd, const struct fwd_ports *rev);
void fwd_scan_ports_udp(struct fwd_ports *fwd, const struct fwd_ports *rev,
			const struct fwd_ports *tcp_fwd,
			const struct fwd_ports *tcp_rev);
void fwd_scan_ports_init(struct ctx *c);

bool nat_inbound(const struct ctx *c, const union inany_addr *addr,
		 union inany_addr *translated);
uint8_t fwd_nat_from_tap(const struct ctx *c, uint8_t proto,
			 const struct flowside *ini, struct flowside *tgt);
uint8_t fwd_nat_from_splice(const struct ctx *c, uint8_t proto,
			    const struct flowside *ini, struct flowside *tgt);
uint8_t fwd_nat_from_host(const struct ctx *c, uint8_t proto,
			  const struct flowside *ini, struct flowside *tgt);

#endif /* FWD_H */

debug log:

solving 0458a3c5 ...
found 0458a3c5 in https://archives.passt.top/passt-dev/20250416090707.393497-5-david@gibson.dropbear.id.au/ ||
	https://archives.passt.top/passt-dev/20250417015543.457310-5-david@gibson.dropbear.id.au/
found 3562f3ca in https://passt.top/passt
preparing index
index prepared:
100644 3562f3caee761c4ad51a19f89313d5386b3557f0	fwd.h

applying [1/1] https://archives.passt.top/passt-dev/20250416090707.393497-5-david@gibson.dropbear.id.au/
diff --git a/fwd.h b/fwd.h
index 3562f3ca..0458a3c5 100644

Checking patch fwd.h...
Applied patch fwd.h cleanly.

skipping https://archives.passt.top/passt-dev/20250417015543.457310-5-david@gibson.dropbear.id.au/ for 0458a3c5
index at:
100644 0458a3c5078d87664a63db56764b0df26f1a8c10	fwd.h

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).