LIBVDESLIRP(3)
π LIBVDESLIRP(3) β the library functions manual, but make it cute π
okay so bestie, welcome to LIBVDESLIRP(3) from the Library Functions Manual. this is the whole entire slirp API and it's genuinely iconic, no cap. sit down, grab a strawberry π, and let's go.
β¨ NAME β¨
vdeslirp_open, vdeslirp_send, vdeslirp_recv, vdeslirp_fd, vdeslirp_close β the 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, periodt. π
π DESCRIPTION π
slirp is a TCP/IP emulator. it generates a virtual network using standard user privileges β so no root access needed, no CAP_NET_ADMIN, none of that πβ¨. this particular implementation uses libslirp.
vdeslirp_open creates a slirp network. the SlirpConfig structure is defined by libslirp and it contains these fields, ok? look at her, she's everything π
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;
β οΈ heads up bestie:versionis mandatory, you literally have to provide it. andenable_emuturns on emulation code β the original says, and i quote, warning: this code isn't safe, it is not recommended to enable it. so like... don't π. also don't forgetif_mtudefaults toIF_MTU_DEFAULTandif_mrudefaults toIF_MRU_DEFAULT, anddisable_host_loopbackprohibits connecting to127.0.0.1:*. π
libvdeslirp provides helper functions to fill in the fields of this structure β go check libvdeslirpcfg(3) for those.
programs using libvdeslirp can send and receive packets with vdeslirp_send and vdeslirp_recv, and it feels exactly like being plugged into the host network (commonly the Internet, iykyk) through a NAT/Masquerading router π. vdeslirp_fd hands you a valid file descriptor you can use to wait for incoming packets β with select or poll β and vdeslirp_close terminates a slirp network that vdeslirp_open created. clean up after yourself bestie π§
β RETURN VALUE β
vdeslirp_open returns the struct vdeslirp pointer when it works out π. NULL is returned otherwise, sadly π. the return value of vdeslirp_open is the descriptor that must be passed as the first argument to every other function on this man page β yes, all of them, so hold onto it.
vdeslirp_sendandvdeslirp_recvreturn the number of bytes sent or received, and-1in case of error.vdeslirp_fdreturns a valid file descriptor which can be used to wait for incoming packets (usingselectorpoll).vdeslirp_closereturns zero in case of success,-1in case of error.
in case of failure, errno is set to indicate the type of error. classic errno behaviour, she ate π₯
π«Ά SEE ALSO π«Ά
libvdeslirpfwd(3), libvdeslirpcfg(3)
π BUGS π
found a bug? not the vibe. bug reports should be addressed to info@virtualsquare.org π§
π AUTHOR π
VirtualSquare. project leader: Renzo Davoli.
okay that's the whole page bestie, you're so smart for reading all of it πβ¨ this absolute banger of a man page is brought to you by VirtualSquare, dated January 2024, and it lives at LIBVDESLIRP(3). bye love you, go write some packets π
π
π¦ where this page comes from
- ubuntu stonking: libvdeslirp0 0.1.4-1 Β· LGPL-2.1-or-later
- Copyright (C) 2019 VirtualSquare. Project Leader: Renzo Davoli
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms