Skip to content

Commit

Permalink
drivers: wifi: winc1500: Rename socket functions to avoid multiple de…
Browse files Browse the repository at this point in the history
…finitions

Renamed socket functions to avoid multiple definitions in the HAL library

Signed-off-by: Andreas Ålgård <[email protected]>
  • Loading branch information
icsys-aal committed Nov 6, 2024
1 parent 531e4f3 commit fb26007
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions drivers/wifi/winc1500/wifi_winc1500.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ typedef void (*tpfAppSocketCb) (SOCKET sock, uint8 u8Msg, void *pvMsg);
typedef void (*tpfAppResolveCb) (uint8 *pu8DomainName, uint32 u32ServerIP);
NMI_API void registerSocketCallback(tpfAppSocketCb socket_cb,
tpfAppResolveCb resolve_cb);
NMI_API SOCKET socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags);
NMI_API sint8 bind(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
NMI_API sint8 listen(SOCKET sock, uint8 backlog);
NMI_API sint8 accept(SOCKET sock, struct sockaddr *addr, uint8 *addrlen);
NMI_API sint8 connect(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
NMI_API sint16 recv(SOCKET sock, void *pvRecvBuf,
NMI_API SOCKET winc1500_socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags);
NMI_API sint8 winc1500_socket_bind(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
NMI_API sint8 winc1500_socket_listen(SOCKET sock, uint8 backlog);
NMI_API sint8 winc1500_socket_accept(SOCKET sock, struct sockaddr *addr, uint8 *addrlen);
NMI_API sint8 winc1500_socket_connect(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
NMI_API sint16 winc1500_socket_recv(SOCKET sock, void *pvRecvBuf,
uint16 u16BufLen, uint32 u32Timeoutmsec);
NMI_API sint16 send(SOCKET sock, void *pvSendBuffer,
NMI_API sint16 winc1500_socket_send(SOCKET sock, void *pvSendBuffer,
uint16 u16SendLength, uint16 u16Flags);
NMI_API sint16 sendto(SOCKET sock, void *pvSendBuffer,
NMI_API sint16 winc1500_socket_sendto(SOCKET sock, void *pvSendBuffer,
uint16 u16SendLength, uint16 flags,
struct sockaddr *pstrDestAddr, uint8 u8AddrLen);
NMI_API sint8 winc1500_close(SOCKET sock);
Expand Down Expand Up @@ -306,7 +306,7 @@ static int winc1500_get(sa_family_t family,
* we have checked if family is AF_INET so we can hardcode this
* for now.
*/
sock = socket(2, type, 0);
sock = winc1500_socket(2, type, 0);
if (sock < 0) {
LOG_ERR("socket error!");
return -1;
Expand Down Expand Up @@ -337,7 +337,7 @@ static int winc1500_bind(struct net_context *context,
return 0;
}

ret = bind((int)context->offload_context, (struct sockaddr *)addr,
ret = winc1500_socket_bind((intptr_t)context->offload_context, (struct sockaddr *)addr,
addrlen);
if (ret) {
LOG_ERR("bind error %d %s!",
Expand All @@ -363,7 +363,7 @@ static int winc1500_listen(struct net_context *context, int backlog)
SOCKET socket = (int)context->offload_context;
int ret;

ret = listen((int)context->offload_context, backlog);
ret = winc1500_socket_listen((int)context->offload_context, backlog);
if (ret) {
LOG_ERR("listen error %d %s!",
ret, socket_error_string(ret));
Expand Down Expand Up @@ -396,7 +396,7 @@ static int winc1500_connect(struct net_context *context,
w1500_data.socket_data[socket].connect_user_data = user_data;
w1500_data.socket_data[socket].ret_code = 0;

ret = connect(socket, (struct sockaddr *)addr, addrlen);
ret = winc1500_socket_connect(socket, (struct sockaddr *)addr, addrlen);
if (ret) {
LOG_ERR("connect error %d %s!",
ret, socket_error_string(ret));
Expand Down Expand Up @@ -426,7 +426,7 @@ static int winc1500_accept(struct net_context *context,
w1500_data.socket_data[socket].accept_cb = cb;
w1500_data.socket_data[socket].accept_user_data = user_data;

ret = accept(socket, NULL, 0);
ret = winc1500_socket_accept(socket, NULL, 0);
if (ret) {
LOG_ERR("accept error %d %s!",
ret, socket_error_string(ret));
Expand Down Expand Up @@ -468,7 +468,7 @@ static int winc1500_send(struct net_pkt *pkt,

net_buf_add(buf, net_pkt_get_len(pkt));

ret = send(socket, buf->data, buf->len, 0);
ret = winc1500_socket_send(socket, buf->data, buf->len, 0);
if (ret) {
LOG_ERR("send error %d %s!", ret, socket_error_string(ret));
goto out;
Expand Down Expand Up @@ -508,7 +508,7 @@ static int winc1500_sendto(struct net_pkt *pkt,

net_buf_add(buf, net_pkt_get_len(pkt));

ret = sendto(socket, buf->data, buf->len, 0,
ret = winc1500_socket_sendto(socket, buf->data, buf->len, 0,
(struct sockaddr *)dst_addr, addrlen);
if (ret) {
LOG_ERR("sendto error %d %s!", ret, socket_error_string(ret));
Expand Down Expand Up @@ -572,7 +572,7 @@ static int winc1500_recv(struct net_context *context,
}


ret = recv(socket, w1500_data.socket_data[socket].pkt_buf->data,
ret = winc1500_socket_recv(socket, w1500_data.socket_data[socket].pkt_buf->data,
CONFIG_WIFI_WINC1500_MAX_PACKET_SIZE, timeout);
if (ret) {
LOG_ERR("recv error %d %s!",
Expand Down Expand Up @@ -817,6 +817,8 @@ static bool handle_socket_msg_recv(SOCKET sock,
}
} else if (pstrRx->pu8Buffer == NULL) {
if (pstrRx->s16BufferSize == SOCK_ERR_CONN_ABORTED) {
winc1500_close(sock);

net_pkt_unref(sd->rx_pkt);
return false;
}
Expand Down

0 comments on commit fb26007

Please sign in to comment.