.\" Copyright (C) 2019 VirtualSquare. Project Leader: Renzo Davoli .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License, .\" as published by the Free Software Foundation, either version 2 .\" of the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, .\" MA 02110-1301 USA. .\" .\" generated with Ronn-NG/v0.8.0 .\" http://github.com/apjanke/ronn-ng/tree/0.8.0 .TH "LIBVDESLIRPFWD" "3" "January 2020" "VirtualSquare" .SH "NAME" vdeslirp_add_fwd, vdeslirp_remove_fwd, vdeslirp_add_unixfwd, vdeslirp_remove_unixfwd, vdeslirp_add_cmdexec \- simple API for slirp, port forwarding .SH "SYNOPSIS" \fB#include \fR .P \fBint vdeslirp_add_fwd(struct vdeslirp *\fR\fIslirp\fR\fB, int\fR \fIis_udp\fR\fB, struct in_addr\fR \fIhost_addr\fR\fB, int\fR \fIhost_port\fR\fB, struct in_addr\fR \fIguest_addr\fR\fB, int\fR \fIguest_port\fR\fB);\fR .P \fBint vdeslirp_remove_fwd(struct vdeslirp *\fR\fIslirp\fR\fB, int\fR \fIis_udp\fR\fB, struct in_addr\fR \fIhost_addr\fR\fB, int\fR \fIhost_port\fR\fB);\fR .P \fBint vdeslirp_add_unixfwd(struct vdeslirp *\fR\fIslirp\fR\fB, char *\fR\fIpath\fR\fB, struct in_addr\fR \fIguest_addr\fR\fB, int\fR \fIguest_port\fR\fB);\fR .P \fBint vdeslirp_remove_unixfwd(struct vdeslirp *\fR\fIslirp\fR\fB, struct in_addr\fR \fIguest_addr\fR\fB, int\fR \fIguest_port\fR\fB);\fR .P \fBint vdeslirp_add_cmdexec(struct vdeslirp *\fR\fIslirp\fR\fB, const char *\fR\fIcmdline\fR\fB, struct in_addr *\fR\fIguest_addr\fR\fB, int\fR \fIguest_port\fR\fB);\fR .P \fBint vdeslirp_remove_cmdexec(struct vdeslirp *\fR\fIslirp\fR\fB, struct in_addr\fR \fIguest_addr\fR\fB, int\fR \fIguest_port\fR\fB);\fR .SH "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\. .P \fBvdeslirp_add_fwd\fR and \fBvdeslirp_remove_fwd\fR respectively add and remove udp or tcp port forwarding services (depending upon the value of is_udp)\. \fIhost_addr\fR and \fIhost_port\fR are the IP address and port number bound for the service in the host system\. All the connections or datagrams to \fIhost_addr\fR and \fIhost_port\fR will be diverted to \fIguest_addr\fR and \fIguest_port\fR in the slirp virtual network\. .P \fBvdeslirp_add_unixfwd\fR and \fBvdeslirp_remove_unixfwd\fR respectively add and remove a forwarding service towards a \fBPF_UNIX\fR stream socket on the hosting system\. All the connections from a node of the virtual network to \fIguest_addr\fR and \fIguest_port\fR will be diverted to the \fBPF_UNIX\fR 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 \fB/tmp/\.X11\-unix/X0\fR)\. .P If libslirp does not support \fBslirp_add_unix\fR, \fBvdeslirp_add_unixfwd\fR is implemented by a workaround based on \fBnc\fR(1)\. .P \fBvdeslirp_cmd_fwd\fR adds a forwarding service to a command\. A TCP connection to \fIguest_addr\fR and \fIguest_port\fR activates the command \fIcmdline\fR\. Data exchanged on the TCP connection is forwarded as stdin/stdout to the command\. .P \fBvdeslirp_remove_cmdexec\fR removes a command forwarding service\. .SH "RETURN VALUE" All these functions return 0 in case of success, \-1 otherwise (and \fBerrno\fR is set consequently)\. \fBvdeslirp_remove_cmdexec\fR and \fBvdeslirp_remove_unixfwd\fR return \-1 and set errno to \fBENOSYS\fR if libslirp does not support \fBslirp_remove_guestfwd\fR\. .SH "SEE ALSO" \fBlibvdeslirp\fR(3), \fBlibvdeslirpcfg\fR(3) .SH "BUGS" Bug reports should be addressed to .SH "AUTHOR" VirtualSquare\. Project leader: Renzo Davoli\.