25
25
* SOFTWARE.
26
26
*/
27
27
28
+ #include <errno.h>
28
29
#include <zephyr/net/socket.h>
29
30
#ifdef CONFIG_NET_SOCKETS_SOCKOPT_TLS
30
31
#include <zephyr/net/tls_credentials.h>
@@ -124,7 +125,7 @@ mender_net_connect(const char *host, const char *port, int *sock) {
124
125
125
126
/* Perform DNS resolution of the host */
126
127
if (0 != (result = getaddrinfo (host , port , & hints , & addr ))) {
127
- mender_log_error ("Unable to resolve host name '%s:%s', result = %d" , host , port , result );
128
+ mender_log_error ("Unable to resolve host name '%s:%s', result = %d, errno = %d " , host , port , result , errno );
128
129
ret = MENDER_FAIL ;
129
130
goto END ;
130
131
}
@@ -135,7 +136,7 @@ mender_net_connect(const char *host, const char *port, int *sock) {
135
136
#else
136
137
if ((result = socket (addr -> ai_family , SOCK_STREAM , IPPROTO_TCP )) < 0 ) {
137
138
#endif /* CONFIG_NET_SOCKETS_SOCKOPT_TLS */
138
- mender_log_error ("Unable to create socket, result = %d" , result );
139
+ mender_log_error ("Unable to create socket, result = %d, errno= %d " , result , errno );
139
140
ret = MENDER_FAIL ;
140
141
goto END ;
141
142
}
@@ -148,7 +149,7 @@ mender_net_connect(const char *host, const char *port, int *sock) {
148
149
CONFIG_MENDER_NET_CA_CERTIFICATE_TAG ,
149
150
};
150
151
if ((result = setsockopt (* sock , SOL_TLS , TLS_SEC_TAG_LIST , sec_tag , sizeof (sec_tag ))) < 0 ) {
151
- mender_log_error ("Unable to set TLS_SEC_TAG_LIST option, result = %d" , result );
152
+ mender_log_error ("Unable to set TLS_SEC_TAG_LIST option, result = %d, errno = %d " , result , errno );
152
153
close (* sock );
153
154
* sock = -1 ;
154
155
ret = MENDER_FAIL ;
@@ -157,7 +158,7 @@ mender_net_connect(const char *host, const char *port, int *sock) {
157
158
158
159
/* Set TLS_HOSTNAME option */
159
160
if ((result = setsockopt (* sock , SOL_TLS , TLS_HOSTNAME , host , strlen (host ))) < 0 ) {
160
- mender_log_error ("Unable to set TLS_HOSTNAME option, result = %d" , result );
161
+ mender_log_error ("Unable to set TLS_HOSTNAME option, result = %d, errno = %d " , result , errno );
161
162
close (* sock );
162
163
* sock = -1 ;
163
164
ret = MENDER_FAIL ;
@@ -167,7 +168,7 @@ mender_net_connect(const char *host, const char *port, int *sock) {
167
168
/* Set TLS_PEER_VERIFY option */
168
169
int verify = CONFIG_MENDER_NET_TLS_PEER_VERIFY ;
169
170
if ((result = setsockopt (* sock , SOL_TLS , TLS_PEER_VERIFY , & verify , sizeof (int ))) < 0 ) {
170
- mender_log_error ("Unable to set TLS_PEER_VERIFY option, result = %d" , result );
171
+ mender_log_error ("Unable to set TLS_PEER_VERIFY option, result = %d, errno = %d " , result , errno );
171
172
close (* sock );
172
173
* sock = -1 ;
173
174
ret = MENDER_FAIL ;
@@ -178,7 +179,7 @@ mender_net_connect(const char *host, const char *port, int *sock) {
178
179
179
180
/* Connect to the host */
180
181
if (0 != (result = connect (* sock , addr -> ai_addr , addr -> ai_addrlen ))) {
181
- mender_log_error ("Unable to connect to the host '%s:%s', result = %d" , host , port , result );
182
+ mender_log_error ("Unable to connect to the host '%s:%s', result = %d, errno = %d " , host , port , result , errno );
182
183
close (* sock );
183
184
* sock = -1 ;
184
185
ret = MENDER_FAIL ;
0 commit comments