Skip to content
This repository has been archived by the owner on Oct 25, 2020. It is now read-only.
/ libslirp Public archive

A TCP-IP emulator as a library.

License

Unknown, GPL-2.0 licenses found

Licenses found

Unknown
LICENSE
GPL-2.0
COPYING
Notifications You must be signed in to change notification settings

rd235/libslirp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THIS LIBRARY IS DEPRECATED

Please use libvdeslirp instead.

  • libvdeslirp supports (almost) all the features of this library (to the date the only missing feature is the port forwarding to a UNIX socket);
  • libvdeslirp is based on qemu's libslirp;
  • qemu's libslirp has been included in Debian Sid (and possibly in other distribution): there is a name clash with this library)
  • qemu's libslirp is actively maintained and updated
  • for all the reasons here above this library will no longer be maintained

libslirp

A TCP-IP emulator as a library.

Slirp

Originally designed to provide PPP/SLIP over terminal lines, slirp is a general purpose TCP-IP emulator widely used by virtual machine hypervisors to provide virtual networking services.

Qemu, virtualbox, user-mode linux include slirp to provide the guest os with a virtual network while requiring no configuration nor privileged services on the host.

This project wraps the slirp code in a library featuring a clean and simple interface.

Install libslirp:

$ autoreconf -if
$ ./configure
$ make
$ sudo make install

libslirp tutorial

The first operation to use a slirp virtual network is slirp_open.

SLIRP *myslirp = slirp_open(SLIRP_IPV4 | SLIRP_IPV6);

myslirp is the descriptor of the slirp network.

The library has been designed to assign suitable default values for all the parameters:

  • default route: 10.0.2.2/24
  • DNS forward: 10.0.2.3
  • DHCP addresses: 10.0.2.15 - 10.0.2.31
  • default route ipv6: fe80::2/64
  • DNS forward IPv6: fe80::3
  • Virtual Router Advertisement daemon: active.

Libslirp provides functions to override the values (see man libslirpcfg).

After the (eventual) configuration of all the parameters the slirp network can be activated:

slirp_start(myslirp);

Now virtual networking (ethernet) packets can be sent and received using slirp_send and slirp_recv. e.g.:

sentlen = slirp_send(myslirp, pkt, pktlen);
pktlen = slirp_recv(myslirp, buf, buflen);

slirp_fd returns a file descriptor which can be used to wait for incoming packets using poll or select.

myslirpfd = slirp_fd(myslirp);

It is also possible to set up port forwarding for TCP, UDP (currently IPV4 only) or connect X-window clients running in the virtual network to a X server UNIX socket, see man libslirpfwd.

To terminate the slirp network, call:

slirp_close(myslirp)

About

A TCP-IP emulator as a library.

Resources

License

Unknown, GPL-2.0 licenses found

Licenses found

Unknown
LICENSE
GPL-2.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages