Codebase list slirp4netns / 1cddc73
Merge tag 'upstream/0.2.1' Upstream version 0.2.1 Reinhard Tartler 5 years ago
6 changed file(s) with 36 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
6666 libslirp_a_SOURCES = rd235_libslirp/src/qemu2libslirp.c
6767
6868 # define specific commit if git available or it was replaced during git-archive creation
69 COMMIT := $(shell V=5e4789b9a21cab3315801e1750670e10a1c86a2a ; \
69 COMMIT := $(shell V=1797e46728440e93f9229d5a34874befe00b4cab ; \
7070 expr match "$$V" ormat: >/dev/null \
7171 && (cd "$$abs_srcdir" && [ -d .git ] && git describe --always --abbrev=0 --dirty --exclude=\* || echo unknown) \
7272 || echo "$$V" )
4141 $ sudo dnf install slirp4netns
4242 ```
4343
44 #### [Arch Linux](https://aur.archlinux.org/packages/slirp4netns-git/):
44 #### [Arch Linux](https://aur.archlinux.org/packages/slirp4netns/):
4545
46 If you're running Arch Linux you can install `slirp4netns-git` from AUR. When you're using an AUR helper ([yay](https://github.com/Jguer/yay), for example) simply use:
46 If you're running Arch Linux you can install `slirp4netns` (or [`slirp4netns-git`](https://aur.archlinux.org/packages/slirp4netns-git/)) from AUR. When you're using an AUR helper ([yay](https://github.com/Jguer/yay), for example) simply use:
4747
48 yay -S slirp4netns-git
48 yay -S slirp4netns
4949
5050 Otherwise make sure you have [base-devel](https://www.archlinux.org/groups/x86_64/base-devel/) installed and build a package manually:
5151
5252 cd $(mktemp -d)
53 curl -Lo PKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=slirp4netns-git"
53 curl -Lo PKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=slirp4netns"
5454 makepkg
55 sudo pacman -U slirp4netns-git-*.pkg.tar.*
55 sudo pacman -U slirp4netns-*.pkg.tar.*
5656
5757 #### [openSUSE Tumbleweed](https://build.opensuse.org/package/show/openSUSE%3AFactory/slirp4netns)
5858
7272 ```console
7373 $ sudo zypper addrepo --refresh http://download.opensuse.org/repositories/devel:/kubic/SLE_15/devel:kubic.repo
7474 $ sudo zypper install slirp4netns
75 ```
76
77 #### [Debian GNU/Linux Sid](https://packages.debian.org/sid/slirp4netns)
78
79 ```console
80 $ sudo apt install slirp4netns
7581 ```
7682
7783 ### Usage
00 AC_PREREQ([2.69])
1 AC_INIT([slirp4netns], [0.1], [https://github.com/rootless-containers/slirp4netns/issues])
1 AC_INIT([slirp4netns], [0.2.1], [https://github.com/rootless-containers/slirp4netns/issues])
22 AC_CONFIG_SRCDIR([main.c])
33 AC_CONFIG_HEADERS([config.h])
44
638638 struct sockaddr_in addr;
639639 socklen_t addrlen = sizeof(struct sockaddr_in);
640640 struct sbuf *so_rcv = &so->so_rcv;
641
642 if (m->m_len > so_rcv->sb_datalen
643 - (so_rcv->sb_wptr - so_rcv->sb_data)) {
644 return 1;
645 }
641646
642647 memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
643648 so_rcv->sb_wptr += m->m_len;
22 function wait_for_network_namespace {
33 # Wait that the namespace is ready.
44 COUNTER=0
5 while [ $COUNTER -lt 10 ]; do
5 while [ $COUNTER -lt 40 ]; do
66 if nsenter --preserve-credentials -U -n --target=$1 true; then
77 break
88 else
1515 function wait_for_network_device {
1616 # Wait that the device appears.
1717 COUNTER=0
18 while [ $COUNTER -lt 20 ]; do
18 while [ $COUNTER -lt 40 ]; do
1919 if nsenter --preserve-credentials -U -n --target=$1 ip addr show $2; then
2020 break
2121 else
2727
2828 function wait_process_exits {
2929 COUNTER=0
30 while [ $COUNTER -lt 20 ]; do
30 while [ $COUNTER -lt 40 ]; do
3131 if kill -0 $1; then
3232 sleep 0.5
3333 else
3939
4040 function wait_for_ping_connectivity {
4141 COUNTER=0
42 while [ $COUNTER -lt 20 ]; do
42 while [ $COUNTER -lt 40 ]; do
4343 if nsenter --preserve-credentials -U -n --target=$1 ping -c 1 -w 1 $2; then
4444 break
4545 else
4848 let COUNTER=COUNTER+1
4949 done
5050 }
51
52 function wait_for_file_content {
53 # Wait for a file to get the specified content.
54 COUNTER=0
55 while [ $COUNTER -lt 20 ]; do
56 if grep $1 $2; then
57 break
58 else
59 sleep 0.5
60 fi
61 let COUNTER=COUNTER+1
62 done
63 }
2121
2222 wait_for_network_device $child tun11
2323
24 grep 1 configured
24 wait_for_file_content 1 configured
2525
2626 exit 0