RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

net/hosts: add module for static hostname definitions

Open benpicco opened this issue 8 months ago • 2 comments

Contribution description

Operating with hostnames instead of raw IP addresses can be more convenient in applications. On Linux we have /etc/hosts where we can statically define hostname -> IP mappings.

This module adds something similar to RIOT.

Testing procedure

Enable the hosts module. The XFA is by default populated with a localhost entry:

2025-04-11 17:49:05,409 # > ping localhost
2025-04-11 17:49:05,414 # 12 bytes from ::1: icmp_seq=0 ttl=64 time=0.202 ms
2025-04-11 17:49:06,414 # 12 bytes from ::1: icmp_seq=1 ttl=64 time=0.202 ms
2025-04-11 17:49:07,414 # 12 bytes from ::1: icmp_seq=2 ttl=64 time=0.202 ms
2025-04-11 17:49:07,415 # 
2025-04-11 17:49:07,417 # --- localhost PING statistics ---
2025-04-11 17:49:07,422 # 3 packets transmitted, 3 packets received, 0% packet loss
2025-04-11 17:49:07,426 # round-trip min/avg/max = 0.202/0.202/0.202 ms

Issues/PRs references

benpicco avatar Apr 11 '25 16:04 benpicco

Murdock results

:heavy_check_mark: PASSED

c826d0cddb4add3503a8d7abba9f4291e6b4bf6c sys/net/sock_util: make unconditional use of dns_query()

Success Failures Total Runtime
10516 0 10516 12m:43s

Artifacts

riot-ci avatar Apr 11 '25 16:04 riot-ci

I would like to keep the API compatible with the other backends of dns_query().

Adding support for AF_INET is trivial and useful for lwIP.

benpicco avatar May 07 '25 12:05 benpicco

@Teufelchen1 you still have an open change-request, is that still valid after Ben's answer?

crasbe avatar Sep 08 '25 13:09 crasbe

Thanks for the ping. Please proceed.

Teufelchen1 avatar Sep 08 '25 13:09 Teufelchen1

I'm not familiar with the networking subsystem in RIOT, but the ping localhost does not appear to work with examples/networking/gnrc_networking.

> ping localhost
2025-09-08 15:49:00,780 # ping localhost
2025-09-08 15:49:00,781 # can't resolve localhost

The gnrc_border_router example seems to only enable the hosts module when the DNS modules are loaded, but on the other hand there is no error when loading the hosts module as it is.

crasbe avatar Sep 08 '25 13:09 crasbe

Whats the status here? Rebase is done, @crasbe, can we merge?

Teufelchen1 avatar Oct 06 '25 09:10 Teufelchen1

Whats the status here? Rebase is done, @crasbe, can we merge?

You didn't give an approval and I can't really judge the technical aspects of it. But from my side it's good, although my side is mostly style related 🤔 😅

crasbe avatar Oct 06 '25 09:10 crasbe