-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Labels
area: NetworkingbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug
Description
Describe the bug
I am using the RT1170-EVKB. I was trying to use the default hostname zephyr
and then use said hostname with getaddrinfo
. But it failed with EAI_NONAME
.
Afterward, I set the host name to a random string to the same result.
I was able to make it work if I used localhost
for the hostname.
Regression
- This is a regression.
Steps to reproduce
Step to reproduce this behaviour:
- mkdir test; cd test
- mkdir src
- Copy the following in src/main.c
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(Main, LOG_LEVEL_INF);
#include <zephyr/kernel.h>
#include <stdio.h>
#include <zephyr/net/hostname.h>
#include <zephyr/posix/netdb.h>
int main() {
const char *hostname;
int result;
struct addrinfo hints = { 0 };
struct addrinfo *addrinfos;
hints.ai_family = AF_INET;
hostname = net_hostname_get();
result = getaddrinfo(hostname, NULL, &hints, &addrinfos);
if (result < 0) {
LOG_ERR("The function getaddrinfo failed with %d (%s)", result, gai_strerror(result));
return -1;
}
LOG_INF("The function getaddrinfo was successful");
return 0;
}
- Copy the following to CMakeLists.txt
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(test)
target_sources(app PRIVATE src/main.c)
- Copy the following to prj.conf
CONFIG_NETWORKING=y
CONFIG_POSIX_API=y
CONFIG_NET_HOSTNAME_ENABLE=y
- west build -p -b <your_board>
- west flash
Relevant log output
Impact
Functional Limitation – Some features not working as expected, but system usable.
Environment
- OS: Windows
- SDK: 0.17.1
- Version 4.1
Additional Context
No response
Metadata
Metadata
Labels
area: NetworkingbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug