fix(arch): Missing network definitions added

This commit is contained in:
Noel Graf 2025-03-11 12:06:34 +01:00
parent 6c798b1487
commit 6af42fc9e7
3 changed files with 25 additions and 19 deletions

View File

@ -120,6 +120,7 @@ lwip_gethostname(char *name, size_t len) {
#define UA_poll lwip_poll
#define UA_socket lwip_socket
#define UA_bind lwip_bind
#define UA_recvfrom lwip_recvfrom
#define UA_listen lwip_listen
#define UA_accept lwip_accept
#define UA_send lwip_send
@ -128,13 +129,18 @@ lwip_gethostname(char *name, size_t len) {
#define UA_close lwip_close
#define UA_select lwip_select
#define UA_connect lwip_connect
#define UA_shutdown lwip_shutdown
#define UA_getsockopt lwip_getsockopt
#define UA_setsockopt lwip_setsockopt
#define UA_inet_pton lwip_inet_pton
#define UA_if_nametoindex lwip_if_nametoindex
#define UA_getsockname lwip_getsockname
// #define UA_getaddrinfo lwip_getaddrinfo
// #define UA_freeaddrinfo lwip_freeaddrinfo
#define UA_inet_ntop lwip_inet_ntop
#if LWIP_DNS
#define UA_getaddrinfo lwip_getaddrinfo
#define UA_freeaddrinfo lwip_freeaddrinfo
#endif
#define UA_clean_errno(STR_FUN) (errno == 0 ? (char*) "None" : (STR_FUN)(errno))
#define UA_LOG_SOCKET_ERRNO_WRAP(LOG) { \

View File

@ -126,7 +126,7 @@ static int
getSockError(TCP_FD *conn) {
int error = 0;
socklen_t errlen = sizeof(int);
int err = getsockopt(conn->rfd.fd, SOL_SOCKET, SO_ERROR, &error, &errlen);
int err = UA_getsockopt(conn->rfd.fd, SOL_SOCKET, SO_ERROR, &error, &errlen);
return (err == 0) ? error : err;
}
@ -552,7 +552,7 @@ TCP_registerListenSockets(UA_LWIPConnectionManager *pcm, const char *hostname,
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
int retcode = lwip_getaddrinfo(hostname, portstr, &hints, &res);
int retcode = UA_getaddrinfo(hostname, portstr, &hints, &res);
if(retcode != 0) {
UA_LOG_WARNING(pcm->cm.eventSource.eventLoop->logger, UA_LOGCATEGORY_NETWORK,
"TCP\t| Lookup for \"%s\" on port %u failed (%s)",
@ -569,7 +569,7 @@ TCP_registerListenSockets(UA_LWIPConnectionManager *pcm, const char *hostname,
connectionCallback, validate, reuseaddr);
ai = ai->ai_next;
}
lwip_freeaddrinfo(res);
UA_freeaddrinfo(res);
return total_result;
#else
@ -616,7 +616,7 @@ TCP_shutdown(UA_ConnectionManager *cm, TCP_FD *conn) {
}
/* Shutdown the socket to cancel the current select/epoll */
shutdown(conn->rfd.fd, UA_SHUT_RDWR);
UA_shutdown(conn->rfd.fd, UA_SHUT_RDWR);
UA_LOG_DEBUG(el->eventLoop.logger, UA_LOGCATEGORY_NETWORK,
"TCP %u\t| Shutdown triggered",
@ -822,7 +822,7 @@ TCP_openActiveConnection(UA_LWIPConnectionManager *pcm, const UA_KeyValueMap *pa
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
int error = lwip_getaddrinfo(hostname, portStr, &hints, &info);
int error = UA_getaddrinfo(hostname, portStr, &hints, &info);
if(error != 0) {
UA_LOG_WARNING(el->eventLoop.logger, UA_LOGCATEGORY_NETWORK,
"TCP\t| Lookup of %s failed (%s)",
@ -833,7 +833,7 @@ TCP_openActiveConnection(UA_LWIPConnectionManager *pcm, const UA_KeyValueMap *pa
/* Create a socket */
UA_FD newSock = UA_socket(info->ai_family, info->ai_socktype, info->ai_protocol);
if(newSock == UA_INVALID_FD) {
lwip_freeaddrinfo(info);
UA_freeaddrinfo(info);
UA_LOG_SOCKET_ERRNO_WRAP(
UA_LOG_WARNING(el->eventLoop.logger, UA_LOGCATEGORY_NETWORK,
"TCP\t| Could not create socket to connect to %s (%s)",
@ -862,7 +862,7 @@ TCP_openActiveConnection(UA_LWIPConnectionManager *pcm, const UA_KeyValueMap *pa
UA_LOG_WARNING(el->eventLoop.logger, UA_LOGCATEGORY_NETWORK,
"TCP\t| Could not set socket options: %s", errno_str));
#if LWIP_DNS
lwip_freeaddrinfo(info);
UA_freeaddrinfo(info);
#endif
UA_close(newSock);
return res;
@ -871,7 +871,7 @@ TCP_openActiveConnection(UA_LWIPConnectionManager *pcm, const UA_KeyValueMap *pa
/* Only validate, don't actually open the connection */
if(validate) {
#if LWIP_DNS
lwip_freeaddrinfo(info);
UA_freeaddrinfo(info);
#endif
UA_close(newSock);
return UA_STATUSCODE_GOOD;
@ -880,7 +880,7 @@ TCP_openActiveConnection(UA_LWIPConnectionManager *pcm, const UA_KeyValueMap *pa
/* Non-blocking connect */
#if LWIP_DNS
error = UA_connect(newSock, info->ai_addr, info->ai_addrlen);
lwip_freeaddrinfo(info);
UA_freeaddrinfo(info);
if(error != 0 &&
UA_ERRNO != UA_INPROGRESS &&
UA_ERRNO != UA_WOULDBLOCK) {

View File

@ -620,11 +620,11 @@ UDP_connectionSocketCallback(UA_LWIPConnectionManager *pcm, UDP_FD *conn,
struct sockaddr_storage source;
#ifndef _WIN32
socklen_t sourceSize = (socklen_t)sizeof(struct sockaddr_storage);
ssize_t ret = recvfrom(conn->rfd.fd, (char*)response.data, response.length,
ssize_t ret = UA_recvfrom(conn->rfd.fd, (char*)response.data, response.length,
MSG_DONTWAIT, (struct sockaddr*)&source, &sourceSize);
#else
int sourceSize = (int)sizeof(struct sockaddr_storage);
int ret = recvfrom(conn->rfd.fd, (char*)response.data, (int)response.length,
int ret = UA_recvfrom(conn->rfd.fd, (char*)response.data, (int)response.length,
MSG_DONTWAIT, (struct sockaddr*)&source, &sourceSize);
#endif
@ -651,13 +651,13 @@ UDP_connectionSocketCallback(UA_LWIPConnectionManager *pcm, UDP_FD *conn,
UA_UInt16 sourcePort;
switch(source.ss_family) {
case AF_INET:
inet_ntop(AF_INET, &((struct sockaddr_in *)&source)->sin_addr,
UA_inet_ntop(AF_INET, &((struct sockaddr_in *)&source)->sin_addr,
sourceAddr, 64);
sourcePort = htons(((struct sockaddr_in *)&source)->sin_port);
break;
#if UA_IPV6
case AF_INET6:
inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)&source)->sin6_addr),
UA_inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)&source)->sin6_addr),
sourceAddr, 64);
sourcePort = htons(((struct sockaddr_in6 *)&source)->sin6_port);
break;
@ -745,7 +745,7 @@ UDP_registerListenSocket(UA_LWIPConnectionManager *pcm, UA_UInt16 port,
struct sockaddr_in sin;
memset(&sin, 0, sizeof(sin));
socklen_t len = sizeof(sin);
getsockname(listenSocket, (struct sockaddr *)&sin, &len);
UA_getsockname(listenSocket, (struct sockaddr *)&sin, &len);
port = ntohs(sin.sin_port);
}
@ -846,7 +846,7 @@ UDP_registerListenSockets(UA_LWIPConnectionManager *pcm, const char *hostname,
char portstr[6];
mp_snprintf(portstr, 6, "%d", port);
int retcode = getaddrinfo(hostname, portstr, &hints, &res);
int retcode = UA_getaddrinfo(hostname, portstr, &hints, &res);
if(retcode != 0) {
UA_LOG_SOCKET_ERRNO_GAI_WRAP(
UA_LOG_WARNING(pcm->cm.eventSource.eventLoop->logger,
@ -866,7 +866,7 @@ UDP_registerListenSockets(UA_LWIPConnectionManager *pcm, const char *hostname,
break;
ai = ai->ai_next;
}
lwip_freeaddrinfo(res);
UA_freeaddrinfo(res);
return rv;
#else
struct addrinfo hints;
@ -913,7 +913,7 @@ UDP_shutdown(UA_ConnectionManager *cm, UA_RegisteredFD *rfd) {
}
/* Shutdown the socket to cancel the current select/epoll */
shutdown(rfd->fd, UA_SHUT_RDWR);
UA_shutdown(rfd->fd, UA_SHUT_RDWR);
UA_LOG_DEBUG(el->eventLoop.logger, UA_LOGCATEGORY_NETWORK,
"UDP %u\t| Shutdown called", (unsigned)rfd->fd);