Giter Site home page Giter Site logo

saravana815 / dhtest Goto Github PK

View Code? Open in Web Editor NEW
286.0 26.0 102.0 126 KB

A DHCP client simulation on linux. It can simulates multiple DHCP clients behind a network device. It can help in testing the DHCP servers or in testing switch/router by loading the device with multiple DHCP clients.

License: GNU General Public License v2.0

Makefile 0.16% C 93.84% Python 4.33% Shell 1.33% Dockerfile 0.35%

dhtest's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dhtest's Issues

Invalid checksum

I'm occasionally able to generate packets with invalid UDP checksums using commands of the form dhtest -m 38:f9:d3:00:00:35 -i eth0.

See raw packet and tcpdump -vv taken from sending host.
dhtest_bad_request.txt

Built from da07f6e.

DHCPINFORM packet type

Could you add a DHCPINFORM packet? I am curious to check out the behavior of different servers.

Enhancement to support dhcpv6

Hi Saravana,
This is a very helpful tool. Can there be an enhancement for v6 support or would you know of any other such available tools?
Thanks,
Deepika.

Send Request only.

Hi everyone

So, this might be a bit of a weird request, but is it possible to add an Option, where dhtest directly sends a DHCP request, without first sending a DHCP Discover?

I have a bit of a special case, where I would like to verify a network, before installing a new type of device.
The network has a central DHCP server and a DHCP relay on every router.
While the device under question gets its first IP address normally, using broadcast and the relay, all subsequent requests are sent to the DHCP server directly, using unicast. These requests however do not start with a DHCP discover, but a DHCP request directly.
This I would like to replicate, using dhtest.

I'd add a pull request, but I'm afraid my programming skills are not good enough, to do so in a quality that I would deem decent.

vlan option doesn't work

vlan option (-v) doesn't work, I see in wireshark tagged DHCP Discovers and Offers, but dhtest doesn't recognize Offers at all and keeps sending Discover.
Tried on dhtest version 1.5, also on 1.1, the same behavior.
ubuntu@ubuntu:~/dhtest-master$ sudo ./dhtest -m 00:00:00:11:11:11 -i ens3 -v 300
DHCP discover sent - Client MAC : 00:00:00:11:11:11
DHCP discover sent - Client MAC : 00:00:00:11:11:11
DHCP discover sent - Client MAC : 00:00:00:11:11:11
DHCP discover sent - Client MAC : 00:00:00:11:11:11
DHCP discover sent - Client MAC : 00:00:00:11:11:11

image

rfc3442-classless-static-routes support

Hi,

This is a nice tool.

Do you plan to add support for rfc3442-classless-static-routes (option 121) to debug static route returned by the server?

Cheers

segmentation fault when using -h argument

Tried to run dhtest in a cronjob which usually runs with a minimal environment. Unfortunately on my (Debian stretch) machine dhtest throws a "Segmentation fault".

Simulating the cron environment with:

env - `cat envfile` /bin/sh -c "/opt/dhtest/dhtest -m 90:80:40:ba:ff:ff -i eth23"

using an envfile with a content like:

HOME=/root
LOGNAME=root
PATH=/usr/bin:/bin
LANG=en_US.UTF-8
SHELL=/bin/sh
PWD=/root

I was unable to determine when a segfault is thrown and when not. Sometimes adding a FOO=bar made a difference, sometimes leaving out the -i eth23 argument. Seems random to me.

Not a complete dhclient, and code style too ugly

It can't set interface ip/ mask / route / dns , it only printf out received info. And the code use SO MANY GLOBAL PARAMATERS ... ...

Maybe I will delete all above, but I can't hide my disappointment now.

[Enhancement] Can it be made to full-fledged network client

Hi Sarvana,

Good job with the code.

I have been working on Griggi & we have to constantly deploy newer version of Openwrt router with our changes on top of it. I am looking to have a testing setup where I could run one (or more) full-fledged network client, that connects to the router, does some network activity like downloading/uploading some data, go off the network, come back & repeat.

This project looks like a good starting point for it. Can you pass me some links as to how this can be extended. I am an application layer guy & very much a noob when it comes to mac layer of things.

Thanks
Ashish

compile failed under lede 17.01.4

Hi:
I want to use dhtest under openwrt/lede. dhtest 1.4/1.5 compiles and works fine under openwrt 15.05.1, but under openwrt/lede 17.01.4 it won't compile. I don't know what's wrong, maybe the gcc version is too new(version 5.4)? the compile message show as below:

make[1]: Entering directory `/share/openwrt/lede-source-archer-c20v1-v17.01.4-release'
make[2]: Entering directory `/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/package/libs/toolchain'
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
echo "libc" >> /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
echo "libgcc" >> /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
echo "libpthread" >> /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
if [ -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean ]; then rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/pkginfo/toolchain.default.install.clean; fi
make[2]: Leaving directory `/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/package/libs/toolchain'
make[2]: Entering directory `/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/package/dhtest'
mkdir -p /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5
cp -fpR ./src/* /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/
touch /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/.prepared_38d65216c06da35f0e020708e7a7ee2f
rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/stamp/.dhtest_installed
(cd /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/./; if [ -x ./configure ]; then find /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/ -name config.guess | xargs -r chmod u+w; find /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/ -name config.guess | xargs -r -n1 cp --remove-destination /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/scripts/config.guess; find /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/ -name config.sub | xargs -r chmod u+w; find /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/ -name config.sub | xargs -r -n1 cp --remove-destination /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/scripts/config.sub; AR="mipsel-openwrt-linux-musl-gcc-ar" AS="mipsel-openwrt-linux-musl-gcc -c -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -iremap /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5:dhtest-1.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=mipsel-openwrt-linux-musl-ld NM="mipsel-openwrt-linux-musl-gcc-nm" CC="mipsel-openwrt-linux-musl-gcc" GCC="mipsel-openwrt-linux-musl-gcc" CXX="mipsel-openwrt-linux-musl-g++" RANLIB="mipsel-openwrt-linux-musl-gcc-ranlib" STRIP=mipsel-openwrt-linux-musl-strip OBJCOPY=mipsel-openwrt-linux-musl-objcopy OBJDUMP=mipsel-openwrt-linux-musl-objdump SIZE=mipsel-openwrt-linux-musl-size CFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5:dhtest-1.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CXXFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5:dhtest-1.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CPPFLAGS="-I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/usr/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/usr/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/include/fortify -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/include " LDFLAGS="-L/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/usr/lib -L/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/lib -L/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/usr/lib -L/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/lib -znow -zrelro "   ./configure --target=mipsel-openwrt-linux --host=mipsel-openwrt-linux --build=x86_64-redhat-linux --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls   ; fi; )
rm -f /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/.configured_*
touch /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/.configured_yyyyyyy
CFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5:dhtest-1.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" CPPFLAGS="-I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/usr/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/usr/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/include/fortify -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/include" make -C /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5 AR="mipsel-openwrt-linux-musl-gcc-ar" AS="mipsel-openwrt-linux-musl-gcc -c -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -iremap /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5:dhtest-1.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=mipsel-openwrt-linux-musl-ld NM="mipsel-openwrt-linux-musl-gcc-nm" CC="mipsel-openwrt-linux-musl-gcc" GCC="mipsel-openwrt-linux-musl-gcc" CXX="mipsel-openwrt-linux-musl-g++" RANLIB="mipsel-openwrt-linux-musl-gcc-ranlib" STRIP=mipsel-openwrt-linux-musl-strip OBJCOPY=mipsel-openwrt-linux-musl-objcopy OBJDUMP=mipsel-openwrt-linux-musl-objdump SIZE=mipsel-openwrt-linux-musl-size
make[3]: Entering directory `/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5'
mipsel-openwrt-linux-musl-gcc -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5:dhtest-1.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/usr/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/usr/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/include/fortify -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/include  -c -o dhtest.o dhtest.c
mipsel-openwrt-linux-musl-gcc -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap /share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5:dhtest-1.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/usr/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/target-mipsel_24kc_musl-1.1.16/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/usr/include -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/include/fortify -I/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/include  -c -o functions.o functions.c
functions.c: In function 'build_dhpacket':
functions.c:871:5: error: 'struct udphdr' has no member named 'source'
   uh->source = htons(port + 1);
     ^
functions.c:872:5: error: 'struct udphdr' has no member named 'dest'
   uh->dest = htons(port);
     ^
functions.c:875:5: error: 'struct udphdr' has no member named 'len'
   uh->len = htons(l4_len);
     ^
functions.c:876:5: error: 'struct udphdr' has no member named 'check'
   uh->check = 0; /* UDP checksum will be done after dhcp header*/
     ^
functions.c:903:5: error: 'struct udphdr' has no member named 'check'
   uh->check = l4_sum((u_int16_t *) (dhcp_packet_disc + l2_hdr_size + l3_hdr_size), ((dhcp_hdr_size + dhopt_size + l4_hdr_size) / 2), (u_int16_t *)&iph->saddr, (u_int16_t *)&iph->daddr,
     ^
functions.c:944:5: error: 'struct udphdr' has no member named 'source'
   uh->source = htons(port + 1);
     ^
functions.c:945:5: error: 'struct udphdr' has no member named 'dest'
   uh->dest = htons(port);
     ^
functions.c:948:5: error: 'struct udphdr' has no member named 'len'
   uh->len = htons(l4_len);
     ^
functions.c:949:5: error: 'struct udphdr' has no member named 'check'
   uh->check = 0; /* UDP checksum will be done after building dhcp header*/
     ^
functions.c:976:5: error: 'struct udphdr' has no member named 'check'
   uh->check = l4_sum((u_int16_t *) (dhcp_packet_request + l2_hdr_size + l3_hdr_size), ((dhcp_hdr_size + dhopt_size + l4_hdr_size) / 2), (u_int16_t *)&iph->saddr, (u_int16_t *)&iph->dadd
     ^
functions.c:1014:5: error: 'struct udphdr' has no member named 'source'
   uh->source = htons(port + 1);
     ^
functions.c:1015:5: error: 'struct udphdr' has no member named 'dest'
   uh->dest = htons(port);
     ^
functions.c:1018:5: error: 'struct udphdr' has no member named 'len'
   uh->len = htons(l4_len);
     ^
functions.c:1019:5: error: 'struct udphdr' has no member named 'check'
   uh->check = 0; /* UDP checksum will be done after dhcp header*/
     ^
functions.c:1043:5: error: 'struct udphdr' has no member named 'check'
   uh->check = l4_sum((u_int16_t *) (dhcp_packet_release + l2_hdr_size + l3_hdr_size), ((dhcp_hdr_size + dhopt_size + l4_hdr_size) / 2), (u_int16_t *)&iph->saddr, (u_int16_t *)&iph->dadd
     ^
functions.c:1081:5: error: 'struct udphdr' has no member named 'source'
   uh->source = htons(port + 1);
     ^
functions.c:1082:5: error: 'struct udphdr' has no member named 'dest'
   uh->dest = htons(port);
     ^
functions.c:1085:5: error: 'struct udphdr' has no member named 'len'
   uh->len = htons(l4_len);
     ^
functions.c:1086:5: error: 'struct udphdr' has no member named 'check'
   uh->check = 0; /* UDP checksum will be done after dhcp header*/
     ^
functions.c:1110:5: error: 'struct udphdr' has no member named 'check'
   uh->check = l4_sum((u_int16_t *) (dhcp_packet_decline + l2_hdr_size + l3_hdr_size), ((dhcp_hdr_size + dhopt_size + l4_hdr_size) / 2), (u_int16_t *)&iph->saddr, (u_int16_t *)&iph->dadd
     ^
functions.c: In function 'check_packet':
functions.c:1205:145: error: 'struct udphdr' has no member named 'source'
   if((ntohs(vlan_hg->vlan_priority_c_vid) & VLAN_VIDMASK) == vlan && ntohs(vlan_hg->vlan_tpi) == ETHERTYPE_VLAN && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest ==
                                                                                                                                                 ^
functions.c:1205:177: error: 'struct udphdr' has no member named 'dest'
 if((ntohs(vlan_hg->vlan_priority_c_vid) & VLAN_VIDMASK) == vlan && ntohs(vlan_hg->vlan_tpi) == ETHERTYPE_VLAN && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == h
                                                                                                                                                                               ^
functions.c:1205:210: error: 'struct udphdr' has no member named 'dest'
 c_vid) & VLAN_VIDMASK) == vlan && ntohs(vlan_hg->vlan_tpi) == ETHERTYPE_VLAN && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == htons(port + 1) || uh_g->dest == h
                                                                                                                                                                               ^
functions.c:1227:144: error: 'struct udphdr' has no member named 'source'
   if((ntohs(vlan_hg->vlan_priority_c_vid) & VLAN_VIDMASK)== vlan && ntohs(vlan_hg->vlan_tpi) == ETHERTYPE_VLAN && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest ==
                                                                                                                                                ^
functions.c:1227:176: error: 'struct udphdr' has no member named 'dest'
  if((ntohs(vlan_hg->vlan_priority_c_vid) & VLAN_VIDMASK)== vlan && ntohs(vlan_hg->vlan_tpi) == ETHERTYPE_VLAN && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == h
                                                                                                                                                                               ^
functions.c:1227:209: error: 'struct udphdr' has no member named 'dest'
 _c_vid) & VLAN_VIDMASK)== vlan && ntohs(vlan_hg->vlan_tpi) == ETHERTYPE_VLAN && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == htons(port + 1) || uh_g->dest == h
                                                                                                                                                                               ^
functions.c:1253:80: error: 'struct udphdr' has no member named 'source'
   if(eth_hg->ether_type == htons(ETHERTYPE_IP) && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == htons(port + 1) || uh_g->dest == htons(port))) {
                                                                                ^
functions.c:1253:112: error: 'struct udphdr' has no member named 'dest'
   if(eth_hg->ether_type == htons(ETHERTYPE_IP) && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == htons(port + 1) || uh_g->dest == htons(port))) {
                                                                                                                ^
functions.c:1253:145: error: 'struct udphdr' has no member named 'dest'
   if(eth_hg->ether_type == htons(ETHERTYPE_IP) && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == htons(port + 1) || uh_g->dest == htons(port))) {
                                                                                                                                                 ^
functions.c:1275:80: error: 'struct udphdr' has no member named 'source'
   if(eth_hg->ether_type == htons(ETHERTYPE_IP) && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == htons(port + 1) || uh_g->dest == htons(port))) {
                                                                                ^
functions.c:1275:112: error: 'struct udphdr' has no member named 'dest'
   if(eth_hg->ether_type == htons(ETHERTYPE_IP) && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == htons(port + 1) || uh_g->dest == htons(port))) {
                                                                                                                ^
functions.c:1275:145: error: 'struct udphdr' has no member named 'dest'
   if(eth_hg->ether_type == htons(ETHERTYPE_IP) && iph_g->protocol == 17 && uh_g->source == htons(port) && (uh_g->dest == htons(port + 1) || uh_g->dest == htons(port))) {
                                                                                                                                                 ^
make[3]: *** [functions.o] Error 1
make[3]: Leaving directory `/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5'
make[2]: *** [/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/build_dir/target-mipsel_24kc_musl-1.1.16/dhtest-1.5/.built] Error 2
make[2]: Leaving directory `/share/openwrt/lede-source-archer-c20v1-v17.01.4-release/package/dhtest'
make[1]: *** [package/dhtest/compile] Error 2
make[1]: Leaving directory `/share/openwrt/lede-source-archer-c20v1-v17.01.4-release'
make: *** [package/dhtest/compile] Error 2

Misleading output if it does not get reply to the DHCP discover

Hi, I had a test scenario calling dhclient in a loop. Sometimes it did not get answer for the DHCP discover and in this case it give a quite misleading output, giving the impression that is keeps resending the DHCP discover, but in fact it did not. I am not sure if it is "just" a display issue or a bug.

The misleading output makes the impression that it keeps sending the DHCP discovers:

DHCP discover sent	 - Client MAC : 00:04:a3:64:15:3e
DHCP discover sent	 - Client MAC : 00:04:a3:64:15:3e
DHCP discover sent	 - Client MAC : 00:04:a3:64:15:3e
DHCP discover sent	 - Client MAC : 00:04:a3:64:15:3e
DHCP discover sent	 - Client MAC : 00:04:a3:64:15:3e
DHCP discover sent	 - Client MAC : 00:04:a3:64:15:3e
DHCP discover sent	 - Client MAC : 00:04:a3:64:15:3e

In fact, only the 1st one is sent out, you can verify it with something like tcpdump -i any port 67 or port 68.

So, to reproduce, make sure that the DHCP discover is just dropped somehow, not answered in any way.

(Once I realized the misleading output, I just set the smallest timeout (-T 5) and retried the calling of dhtest, and I could finish my testing that way. But it caused several hours of time wasted, as I first suspected the problem on the server side and just later started to tcpdump what is happening on the client side.)

Version: current master: c8f1dbb

Missing License

Hi @saravana815, I'm interested in playing around with this but need some licensing info. What license is your code under? Could you add a LICENSE file? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.