LIBVDESLIRPFWD(3)

πŸ’– LIBVDESLIRPFWD(3) πŸ’–

okay bestie, welcome to the Library Functions Manual section for LIBVDESLIRPFWD β€” yes she's a (3), that's library functions babes, we're in the C headers today πŸŽ€


✨ NAME ✨

vdeslirp_add_fwd, vdeslirp_remove_fwd, vdeslirp_add_unixfwd, vdeslirp_remove_unixfwd, vdeslirp_add_cmdexec β€” a simple API for slirp, port forwarding πŸ¦‹


🌸 SYNOPSIS 🌸

#include *libvdeslirp.h*
int vdeslirp_add_fwd(struct vdeslirp *slirp, int is_udp, struct in_addr
host_addr, int host_port, struct in_addr guest_addr, int guest_port);

int vdeslirp_remove_fwd(struct vdeslirp *slirp, int is_udp, struct
in_addr host_addr, int host_port);

int vdeslirp_add_unixfwd(struct vdeslirp *slirp, char *path, struct
in_addr guest_addr, int guest_port);

int vdeslirp_remove_unixfwd(struct vdeslirp *slirp, struct in_addr
guest_addr, int guest_port);

int vdeslirp_add_cmdexec(struct vdeslirp *slirp, const char *cmdline,
struct in_addr *guest_addr, int guest_port);

int vdeslirp_remove_cmdexec(struct vdeslirp *slirp, struct in_addr
guest_addr, int guest_port);

🫢 DESCRIPTION 🫢

Slirp (peep libvdelirp(3) for the lore πŸ‘€) is a TCP/IP emulator. Slirp spins up a whole virtual network using just standard user privileges β€” like, no root access, no CAP_NET_ADMIN, none of that stressful stuff, we love a low-maintenance icon πŸ’…. And these functions right here? They're the ones managing your port forwarding services. Slay.

vdeslirp_add_fwd and vdeslirp_remove_fwd respectively add and remove udp or tcp port forwarding services β€” which one you get depends on the value of is_udp 😌. host_addr and host_port are the IP address and port number bound for the service in the host system. And the way that all the connections or datagrams to host_addr and host_port get diverted to guest_addr and guest_port in the slirp virtual network?? iconic. literally the whole point. periodt.

vdeslirp_add_unixfwd and vdeslirp_remove_unixfwd respectively add and remove a forwarding service towards a PF_UNIX stream socket on the hosting system 🧚. All the connections from a node of the virtual network to guest_addr and guest_port get diverted to the PF_UNIX bound to the pathname path. This feature is commonly used to run X-window clients in the virtual network β€” like fr fr, the value of path could be /tmp/.X11-unix/X0 πŸ’–.

ngl, if libslirp does not support slirp_add_unix, then vdeslirp_add_unixfwd is implemented by a workaround based on nc(1). so that's the tea β˜•

vdeslirp_cmd_fwd adds a forwarding service to a command πŸŽ€. A TCP connection to guest_addr and guest_port activates the command cmdline. And the data exchanged on that TCP connection is forwarded as stdin/stdout to the command. chef's kiss, no notes πŸ”₯.

vdeslirp_remove_cmdexec removes a command forwarding service. bye bye πŸ‘‹


πŸ’œ RETURN VALUE πŸ’œ

All these functions return 0 in case of success, -1 otherwise β€” and yup, errno is set consequently, she always tells on you 😭.

vdeslirp_remove_cmdexec and vdeslirp_remove_unixfwd return -1 and set errno to ENOSYS if libslirp does not support slirp_remove_guestfwd. so like, rude, but okay πŸ’€


πŸ¦‹ SEE ALSO πŸ¦‹


πŸŽ€ BUGS πŸŽ€

Found a bug bestie?? 😭 Bug reports should be addressed to info@virtualsquare.org β€” they wanna hear from you, fr fr 🫢


πŸ‘‘ AUTHOR πŸ‘‘

VirtualSquare. Project leader: Renzo Davoli. main character energy honestly ⭐


and that's the whole page babes!! written by VirtualSquare, January 2024 β€” go forth and forward some ports, you absolute legend πŸ’–βœ¨πŸŒˆ

πŸ“¦ where this page comes from