vdeslirp_add_fwd, vdeslirp_remove_fwd, vdeslirp_add_unixfwd, vdeslirp_remove_unixfwd,
Contents
Bugs
Bug reports should be addressed to <info@virtualsquare.org>
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).
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.
Name
vdeslirp_add_fwd, vdeslirp_remove_fwd, vdeslirp_add_unixfwd, vdeslirp_remove_unixfwd,
vdeslirp_add_cmdexec - simple API for slirp, port forwarding
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), libvdeslirpcfg(3)
Synopsis
#include<libvdeslirp.h>intvdeslirp_add_fwd(structvdeslirp*slirp,intis_udp,structin_addrhost_addr,inthost_port,structin_addrguest_addr,intguest_port);intvdeslirp_remove_fwd(structvdeslirp*slirp,intis_udp,structin_addrhost_addr,inthost_port);intvdeslirp_add_unixfwd(structvdeslirp*slirp,char*path,structin_addrguest_addr,intguest_port);intvdeslirp_remove_unixfwd(structvdeslirp*slirp,structin_addrguest_addr,intguest_port);intvdeslirp_add_cmdexec(structvdeslirp*slirp,constchar*cmdline,structin_addr*guest_addr,intguest_port);intvdeslirp_remove_cmdexec(structvdeslirp*slirp,structin_addrguest_addr,intguest_port);
