diff --git a/include/net/net_context.h b/include/net/net_context.h index ce2e83517b7..6188145aab4 100644 --- a/include/net/net_context.h +++ b/include/net/net_context.h @@ -446,9 +446,13 @@ int net_context_listen(struct net_context *context, * established. * * @param context The context to use. + * @param status Status of the connection establishment. This is 0 + * if the connection was established successfully, <0 if there was an + * error. * @param user_data The user data given in net_context_connect() call. */ typedef void (*net_context_connect_cb_t)(struct net_context *context, + int status, void *user_data); /** diff --git a/subsys/net/ip/net_context.c b/subsys/net/ip/net_context.c index a04092f5831..6525c1d211b 100644 --- a/subsys/net/ip/net_context.c +++ b/subsys/net/ip/net_context.c @@ -1081,7 +1081,7 @@ int net_context_connect(struct net_context *context, #if defined(CONFIG_NET_UDP) if (net_context_get_type(context) == SOCK_DGRAM) { if (cb) { - cb(context, user_data); + cb(context, 0, user_data); } return 0; @@ -1112,7 +1112,7 @@ int net_context_connect(struct net_context *context, send_syn(context, addr); if (cb) { - cb(context, user_data); + cb(context, 0, user_data); } /* in tcp_synack_received() we give back this semaphore */ diff --git a/tests/net/context/src/main.c b/tests/net/context/src/main.c index 76d2df3b854..560e9a28784 100644 --- a/tests/net/context/src/main.c +++ b/tests/net/context/src/main.c @@ -349,7 +349,8 @@ static bool net_ctx_listen_v4(void) return true; } -static void connect_cb(struct net_context *context, void *user_data) +static void connect_cb(struct net_context *context, int status, + void *user_data) { sa_family_t family = POINTER_TO_INT(user_data);