aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/lib/nat_inlines.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/nat/lib/nat_inlines.h')
-rw-r--r--src/plugins/nat/lib/nat_inlines.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/nat/lib/nat_inlines.h b/src/plugins/nat/lib/nat_inlines.h
index c75b8043cc1..0bd7993ac04 100644
--- a/src/plugins/nat/lib/nat_inlines.h
+++ b/src/plugins/nat/lib/nat_inlines.h
@@ -77,6 +77,20 @@ mss_clamping (u16 mss_clamping, tcp_header_t * tcp, ip_csum_t * sum)
}
}
+static_always_inline u16
+nat_random_port (u32 *random_seed, u16 min, u16 max)
+{
+ u32 rwide;
+ u16 r;
+
+ rwide = random_u32 (random_seed);
+ r = rwide & 0xFFFF;
+ if (r >= min && r <= max)
+ return r;
+
+ return min + (rwide % (max - min + 1));
+}
+
#endif /* __included_lib_nat_inlines_h__ */
/*