net: conn: Move net_conn_change_callback() to static
The net_conn_change_callback() is not currently being called by anyone, so this commit moves to static function, and replaces the change callback parameter process in net_conn_register(). Signed-off-by: Takuya Sasaki <takuya.sasaki@spacecubics.com>
This commit is contained in:
parent
947d4a13c3
commit
49c6da51ce
|
@ -268,6 +268,16 @@ static struct net_conn *conn_find_handler(struct net_if *iface,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void net_conn_change_callback(struct net_conn *conn,
|
||||
net_conn_cb_t cb, void *user_data)
|
||||
{
|
||||
NET_DBG("[%zu] connection handler %p changed callback",
|
||||
conn - conns, conn);
|
||||
|
||||
conn->cb = cb;
|
||||
conn->user_data = user_data;
|
||||
}
|
||||
|
||||
int net_conn_register(uint16_t proto, uint8_t family,
|
||||
const struct sockaddr *remote_addr,
|
||||
const struct sockaddr *local_addr,
|
||||
|
@ -376,8 +386,8 @@ int net_conn_register(uint16_t proto, uint8_t family,
|
|||
net_sin(&conn->local_addr)->sin_port = htons(local_port);
|
||||
}
|
||||
|
||||
conn->cb = cb;
|
||||
conn->user_data = user_data;
|
||||
net_conn_change_callback(conn, cb, user_data);
|
||||
|
||||
conn->flags = flags;
|
||||
conn->proto = proto;
|
||||
conn->family = family;
|
||||
|
@ -422,28 +432,6 @@ int net_conn_unregister(struct net_conn_handle *handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int net_conn_change_callback(struct net_conn_handle *handle,
|
||||
net_conn_cb_t cb, void *user_data)
|
||||
{
|
||||
struct net_conn *conn = (struct net_conn *)handle;
|
||||
|
||||
if (conn < &conns[0] || conn > &conns[CONFIG_NET_MAX_CONN]) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!(conn->flags & NET_CONN_IN_USE)) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
NET_DBG("[%zu] connection handler %p changed callback",
|
||||
conn - conns, conn);
|
||||
|
||||
conn->cb = cb;
|
||||
conn->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool conn_addr_cmp(struct net_pkt *pkt,
|
||||
union net_ip_header *ip_hdr,
|
||||
struct sockaddr *addr,
|
||||
|
|
|
@ -156,19 +156,6 @@ static inline int net_conn_unregister(struct net_conn_handle *handle)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Change the callback and user_data for a registered connection
|
||||
* handle.
|
||||
*
|
||||
* @param handle A handle registered with net_conn_register()
|
||||
* @param cb Callback to be called
|
||||
* @param user_data User data supplied by caller.
|
||||
*
|
||||
* @return Return 0 if the the change succeed, <0 otherwise.
|
||||
*/
|
||||
int net_conn_change_callback(struct net_conn_handle *handle,
|
||||
net_conn_cb_t cb, void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Called by net_core.c when a network packet is received.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue