zephyr/samples/net/dns_client/README_IPv4
Flavio Santes ac7300611c net: Restructure network protocols
This commit restructures the network protocols. Changes applied are:

- Move lib/iot/ to subsys/net/lib
- Move network protocol headers to include/net
- Move lib/iot/zoap/link-format.h to include/net/zoap_link_format.h
  and link-format.c to zoap_link_format.c
- Move tests/iot/ to tests/net/lib/
- Adapt sample code
- Adapt build system
- Modify doxygen paths

Change-Id: I37085fa4cc76a8a8e19a499ecb4e87b451120349
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-02 10:03:19 +01:00

187 lines
4.6 KiB
Text

DNS Client Application
======================
The DNS resolver or DNS client application demonstrates how to use the
DNS resolver API.
The DNS API allows to recover IPv4 and IPv6 addresses.
API Return Codes
================
API return codes are documented in the API (see include/net/dns_client.h).
Macro | Value | Description
------------------------------------------------------------------------
O is always success
-EINVAL -22 if an invalid parameter was detected
-EIO -5 network error
-ENOMEM -12 memory error, perhaps related to network buffers
Requirements
============
'net_tools':
https://wiki.zephyrproject.org/view/Networking-with-Qemu
'dnsmasq' application. The dnsmasq version used in this sample is:
dnsmasq -v
Dnsmasq version 2.76 Copyright (c) 2000-2016 Simon Kelley
Read the "Getting Started Guide":
https://www.zephyrproject.org/doc/getting_started/getting_started.html
Building Instructions
=====================
Read src/config.h, change the IP addresses according to the LAN
environment.
* QEMU x86:
In a terminal window, type:
make pristine && make
* FRDM K64F (firmware version: 0226)
make pristine && make BOARD=frdm_k64f
The FRDM K64F board is detected as a USB storage device. The board
must be mounted (i.e. to /mnt) to 'flash' the binary:
cp outdir/frdm_k64f/zephyr.bin /mnt
See https://developer.mbed.org/platforms/frdm-k64f/ for more information
about this board.
* For Arduino 101 with the ENC Ethernet module, see the README_arduino_101
file.
Usage QEMU
==========
Run 'loop_socat.sh' and 'loop-slip-tap.sh' as indicated at:
https://gerrit.zephyrproject.org/r/gitweb?p=net-tools.git;a=blob;f=README
Set the IPv4 ip address:
ip addr add 192.0.2.2/24 dev tap0
Open a terminal window and type:
dnsmasq -i tap0 -p 5353 -d
NOTE: some systems may require root privileges to run dnsmaq, use sudo or su.
If dnsmasq fails to start with an error like this:
dnsmasq: failed to create listening socket for port 5353: Address already in use
open a terminal window and type:
killall -s KILL dnsmasq
Open a terminal where the project was build (i.e. samples/net/dns_client) and type:
make qemu
Usage FRDM K64F
===============
Open a terminal window and type:
screen /dev/ttyACM0 115200
Use 'dmesg' to find the right USB device.
Once the binary is loaded into the FRDM board, press the RESET button.
Sample Output (CONFIG_NET_IPV6=n, CONFIG_NET_IPV4=y)
====================================================
To exit from QEMU enter: 'CTRL+a, x'
[QEMU] CPU: qemu32
-------------------------------------------
[run_dns:141] name: not_a_real_domain_name
rc: -5
-------------------------------------------
[run_dns:141] name: zephyrproject.org
rc: -22
-------------------------------------------
[run_dns:141] name: linux.org
[run_dns:158] 192.243.104.10
-------------------------------------------
[run_dns:141] name: www.zephyrproject.org
[run_dns:158] 140.211.169.8
-------------------------------------------
[run_dns:141] name: kernel.org
[run_dns:158] 149.20.4.69
[run_dns:158] 199.204.44.194
[run_dns:158] 198.145.20.140
-------------------------------------------
[run_dns:141] name: gerrit.zephyrproject.org
[run_dns:158] 199.19.213.246
-------------------------------------------
[run_dns:141] name: linuxfoundation.org
[run_dns:158] 140.211.169.4
-------------------------------------------
[run_dns:141] name: jira.zephyrproject.org
[run_dns:158] 199.19.213.246
-------------------------------------------
[run_dns:141] name: www.wikipedia.org
[run_dns:158] 208.80.153.224
-------------------------------------------
[run_dns:141] name: collabprojects.linuxfoundation.org
[run_dns:158] 140.211.169.4
-------------------------------------------
[run_dns:141] name: gcc.gnu.org
[run_dns:158] 209.132.180.131
-------------------------------------------
[run_dns:141] name: events.linuxfoundation.org
[run_dns:158] 140.211.169.4
-------------------------------------------
[run_dns:141] name: www.google.com
[run_dns:158] 189.203.166.207
[run_dns:158] 189.203.166.241
[run_dns:158] 189.203.166.234
[run_dns:158] 189.203.166.211
Bye!
Known Issues
============
The above sample contains a rc: -22 (-EINVAL). This is the expected behavior
for that domain name.
If a lot of rc: -5 (-EIO) errors are flooding the screen, increment
APP_SLEEP_MSECS to 500 or even 1000. See src/config.h.
There is still an issue not yet isolated that causes the application to fail
during the first two queries. The issue lies between L2 (ARP) and UDP and it
only appears during application startup.