---
name: "vdeslirp_remove_fwd"
section: "3"
platform: "linux"
package: "libvdeslirp0"
version: "0.1.1-2+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/libvdeslirpfwd"
---

# vdeslirp\_remove\_fwd(3)

simple API for slirp, port forwarding

Part of [libvdeslirpfwd(3)](/libvdeslirpfwd/3.md).

## NAME

vdeslirp\_add\_fwd, vdeslirp\_remove\_fwd, vdeslirp\_add\_unixfwd, vdeslirp\_remove\_unixfwd, vdeslirp\_add\_cmdexec - 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, see libvdelirp(3), is a TCP/IP emulator. Slirp generates a virtual network using standard user privileges (no need for root access of CAP\_NET\_ADMIN). These functions manage port forwarding services.

**vdeslirp\_add\_fwd** and **vdeslirp\_remove\_fwd** respectively add and remove udp or tcp port forwarding services (depending upon 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. All the connections or datagrams to *host\_addr* and *host\_port* will be diverted to *guest\_addr* and *guest\_port* in the slirp virtual network.

**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* will be diverted to the **PF\_UNIX** bound to the pathname path. This feature is commonly used to run X-window clients in the virtual network (e.g. the value of path could be **/tmp/.X11-unix/X0**).

If libslirp does not support **slirp\_add\_unix**, **vdeslirp\_add\_unixfwd** is implemented by a workaround based on [**nc**(1)](/nc/1.md).

**vdeslirp\_cmd\_fwd** adds a forwarding service to a command. A TCP connection to *guest\_addr* and *guest\_port* activates the command *cmdline*. Data exchanged on the TCP connection is forwarded as stdin/stdout to the command.

**vdeslirp\_remove\_cmdexec** removes a command forwarding service.

## RETURN VALUE

All these functions return 0 in case of success, -1 otherwise (and **errno** is set consequently). **vdeslirp\_remove\_cmdexec** and **vdeslirp\_remove\_unixfwd** return -1 and set errno to **ENOSYS** if libslirp does not support **slirp\_remove\_guestfwd**.

## SEE ALSO

[**libvdeslirp**(3)](/libvdeslirp/3.md), [**libvdeslirpcfg**(3)](/libvdeslirpcfg/3.md)

## BUGS

Bug reports should be addressed to \<info@virtualsquare.org\>

## AUTHOR

VirtualSquare. Project leader: Renzo Davoli.
