mgmt: hawkbit: remove NET_SOCKETS_POSIX_NAMES dependency

Currently, it is not possible to use hawkbit with code that requires
POSIX_API to be set due to the dependency on NET_SOCKETS_POSIX_NAMES.
Since a lot of other code has already been moved to `zsock_`, this
commit does the same for hawkbit.

Co-authored-by: rojedag <r.ojeda@vogl-electronic.com>
Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
This commit is contained in:
Matthias Breithaupt 2023-05-23 20:24:41 +02:00 committed by Fabio Baltieri
parent abc5f4cad2
commit 04ce5b9e58
3 changed files with 9 additions and 11 deletions

View file

@ -13,7 +13,6 @@ CONFIG_NETWORKING=y
CONFIG_HTTP_CLIENT=y
CONFIG_DNS_RESOLVER=y
CONFIG_JSON_LIBRARY=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_BOOTLOADER_MCUBOOT=y
#Main Stack Size

View file

@ -14,7 +14,6 @@ menuconfig HAWKBIT
depends on HTTP_CLIENT
depends on DNS_RESOLVER
depends on JSON_LIBRARY
depends on NET_SOCKETS_POSIX_NAMES
depends on BOOTLOADER_MCUBOOT
select MPU_ALLOW_FLASH_WRITE
select IMG_ENABLE_IMAGE_CHECK

View file

@ -203,8 +203,8 @@ static const struct json_obj_descr json_dep_fbk_descr[] = {
static bool start_http_client(void)
{
int ret = -1;
struct addrinfo *addr;
struct addrinfo hints;
struct zsock_addrinfo *addr;
struct zsock_addrinfo hints;
int resolve_attempts = 10;
#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
@ -224,7 +224,7 @@ static bool start_http_client(void)
}
while (resolve_attempts--) {
ret = getaddrinfo(CONFIG_HAWKBIT_SERVER, CONFIG_HAWKBIT_PORT, &hints, &addr);
ret = zsock_getaddrinfo(CONFIG_HAWKBIT_SERVER, CONFIG_HAWKBIT_PORT, &hints, &addr);
if (ret == 0) {
break;
}
@ -237,7 +237,7 @@ static bool start_http_client(void)
return false;
}
hb_context.sock = socket(addr->ai_family, SOCK_STREAM, protocol);
hb_context.sock = zsock_socket(addr->ai_family, SOCK_STREAM, protocol);
if (hb_context.sock < 0) {
LOG_ERR("Failed to create TCP socket");
goto err;
@ -260,24 +260,24 @@ static bool start_http_client(void)
}
#endif
if (connect(hb_context.sock, addr->ai_addr, addr->ai_addrlen) < 0) {
if (zsock_connect(hb_context.sock, addr->ai_addr, addr->ai_addrlen) < 0) {
LOG_ERR("Failed to connect to server");
goto err_sock;
}
freeaddrinfo(addr);
zsock_freeaddrinfo(addr);
return true;
err_sock:
close(hb_context.sock);
zsock_close(hb_context.sock);
err:
freeaddrinfo(addr);
zsock_freeaddrinfo(addr);
return false;
}
static void cleanup_connection(void)
{
if (close(hb_context.sock) < 0) {
if (zsock_close(hb_context.sock) < 0) {
LOG_ERR("Could not close the socket");
}
}