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

# libvdeslirp(3)

simple API for slirp

## NAME

vdeslirp\_open, vdeslirp\_send, vdeslirp\_recv, vdeslirp\_fd, vdeslirp\_close - simple API for slirp

## SYNOPSIS

**#include \<libvdeslirp.h\>**

**struct vdeslirp \*vdeslirp\_open(SlirpConfig \****cfg***);**

**ssize\_t vdeslirp\_send(struct vdeslirp \****slirp***, const void \****buf***, size\_t** *count***);**

**ssize\_t vdeslirp\_recv(struct vdeslirp \****slirp***, void \****buf***, size\_t** *count***);**

**int vdeslirp\_fd(struct vdeslirp \****slirp***);**

**int vdeslirp\_close(struct vdeslirp \****slirp***);**

These functions are provided by libvdeslirp. Link with -lvdeslirp.

## DESCRIPTION

Slirp is a TCP/IP emulator. Slirp generates a virtual network using standard user privileges (no need for root access of CAP\_NET\_ADMIN). This implementation uses libslirp.

**vdeslirp\_open** creates a slirp network. The **SlirpConfig** structure is defined by libslirp and contains the following fields:

-

  ```
  typedef struct SlirpConfig {
      /* Version must be provided */
      uint32_t version;
      /*
       * Fields introduced in SlirpConfig version 1 begin
       */
      int restricted;
      bool in_enabled;
      struct in_addr vnetwork;
      struct in_addr vnetmask;
      struct in_addr vhost;
      bool in6_enabled;
      struct in6_addr vprefix_addr6;
      uint8_t vprefix_len;
      struct in6_addr vhost6;
      const char *vhostname;
      const char *tftp_server_name;
      const char *tftp_path;
      const char *bootfile;
      struct in_addr vdhcp_start;
      struct in_addr vnameserver;
      struct in6_addr vnameserver6;
      const char **vdnssearch;
      const char *vdomainname;
      /* Default: IF_MTU_DEFAULT */
      size_t if_mtu;
      /* Default: IF_MRU_DEFAULT */
      size_t if_mru;
      /* Prohibit connecting to 127.0.0.1:* */
      bool disable_host_loopback;
      /*
       * Enable emulation code (*warning*: this code isn´t safe, it is not
       * recommended to enable it)
       */
      bool enable_emu;
      /*
       * Fields introduced in SlirpConfig version 2 begin
       */
  } SlirpConfig;
  ```

-

  **libvdeslirp** provides helper functions to fill in the fields of this structure, see [**libvdeslirpcfg**(3)](/libvdeslirpcfg/3.md).

Programs using **libvdeslirp** can send and receive packets using **vdeslirp\_send** and **vdeslirp\_recv** as if they were connected to host network (commonly the Internet) by a NAT/Masquerading router. **vdeslirp\_fd** provides a valid file descriptor which can be used to wait for incoming packets (using select or poll) and **vdeslirp\_close** terminates a slirp network created by **vdeslirp\_open**.

## RETURN VALUE

**vdeslirp\_open** returns the **struct vdeslirp** pointer in case of success. NULL is returned otherwise. The return value of **vdeslirp\_open** is the descriptor that must be passed as first argument to all the other functions of this man page. **vdeslirp\_send** and **vdeslirp\_recv** return the number of bytes sent or received, -1 in case of error. **vdeslirp\_fd** returns a valid file descriptor which can be used to wait for incoming packets (using select or poll). **vdeslirp\_close** returns zero in case of success, -1 in case of error. In case of failure, **errno** is set to indicate the type of error.

## SEE ALSO

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

## BUGS

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

## AUTHOR

VirtualSquare. Project leader: Renzo Davoli.
