From 9331b2bc7bdf64b04c0b1142dce346352a7b3a3a Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Wed, 22 Jun 2016 16:35:55 +0300 Subject: [PATCH] net: Add net_conn pointer to callback When a UDP packet has been received and if a watcher match is found, then a callback is called. It is useful to have a pointer to net_conn when calling the callback. Change-Id: Ifa97b37c22b1fc9cac7eadfba23aa68dfd473fda Signed-off-by: Jukka Rissanen --- net/yaip/connection.c | 2 +- net/yaip/connection.h | 3 ++- tests/net/udp/src/main.c | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/net/yaip/connection.c b/net/yaip/connection.c index 75305f202c6..2cb0704232b 100644 --- a/net/yaip/connection.c +++ b/net/yaip/connection.c @@ -330,7 +330,7 @@ static inline enum net_verdict cache_check(enum ip_protocol proto, net_nbuf_family(buf), *pos, conn_cache[*pos].value); - return conn->cb(buf, conn->user_data); + return conn->cb(conn, buf, conn->user_data); } } else if (*cache_value > 0) { if (cache_check_neg(*cache_value)) { diff --git a/net/yaip/connection.h b/net/yaip/connection.h index 58dd245c058..b90664ae895 100644 --- a/net/yaip/connection.h +++ b/net/yaip/connection.h @@ -42,7 +42,8 @@ struct net_conn; * packet is received and which matches local and remote IP address * and port. */ -typedef enum net_verdict (*net_conn_cb_t)(struct net_buf *buf, +typedef enum net_verdict (*net_conn_cb_t)(struct net_conn *conn, + struct net_buf *buf, void *user_data); /** diff --git a/tests/net/udp/src/main.c b/tests/net/udp/src/main.c index a24d49394f0..a93901ee61f 100644 --- a/tests/net/udp/src/main.c +++ b/tests/net/udp/src/main.c @@ -141,7 +141,9 @@ struct ud { static struct ud *returned_ud; -static enum net_verdict test_ok(struct net_buf *buf, void *user_data) +static enum net_verdict test_ok(struct net_conn *conn, + struct net_buf *buf, + void *user_data) { struct ud *ud = (struct ud *)user_data; @@ -164,7 +166,9 @@ static enum net_verdict test_ok(struct net_buf *buf, void *user_data) return NET_OK; } -static enum net_verdict test_fail(struct net_buf *buf, void *user_data) +static enum net_verdict test_fail(struct net_conn *conn, + struct net_buf *buf, + void *user_data) { /* This function should never be called as there should not * be a matching UDP connection.