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 <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-06-22 16:35:55 +03:00
commit 9331b2bc7b
3 changed files with 9 additions and 4 deletions

View file

@ -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)) {

View file

@ -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);
/**

View file

@ -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.