📄 net_conn.c
字号:
* application function(s) [see also Note #1].
*
* Note(s) : (1) NetConn_CloseAllConnsHandler() is called by network protocol suite function(s) &
* MUST be called with the global network lock already acquired.
*
* See also 'NetConn_CloseAllConns() Note #2'.
*********************************************************************************************************
*/
void NetConn_CloseAllConnsHandler (void)
{
NET_CONN **pconn_list;
NET_CONN_LIST_QTY i;
/* -------- CLOSE SERVER CONN LIST'S NET CONNS -------- */
pconn_list = &NetConn_ServerConnListHead[0];
for (i = 0; i < NET_CONN_CFG_PROTOCOL_MAX; i++) {
NetConn_CloseAllConnListConns(pconn_list);
*pconn_list = (NET_CONN *)0;
pconn_list++;
}
/* -------- CLOSE CLIENT CONN LIST'S NET CONNS -------- */
pconn_list = &NetConn_ClientConnListHead[0];
for (i = 0; i < NET_CONN_CFG_PROTOCOL_MAX; i++) {
NetConn_CloseAllConnListConns(pconn_list);
*pconn_list = (NET_CONN *)0;
pconn_list++;
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetConn_ID_AppGet()
*
* Description : Get a network connection's application layer handle identifier.
*
* Argument(s) : conn_id Handle identifier of network connection to get application layer handle identifier.
*
* perr Pointer to variable that will receive the return error code from this function :
*
* NET_CONN_ERR_NONE Network connection handle identifier get
* successful.
*
* ---- RETURNED BY NetConn_IsUsed() : ----
* NET_ERR_INIT_INCOMPLETE Network initialization NOT complete.
* NET_CONN_ERR_INVALID_CONN Invalid network connection number.
* NET_CONN_ERR_NOT_USED Network connection NOT currently used.
*
* Return(s) : Network connection's application layer handle identifier, if NO errors.
*
* NET_CONN_ID_NONE, otherwise.
*
* Caller(s) : various.
*
* This function is an INTERNAL network protocol suite function & SHOULD NOT be called by
* application function(s).
*
* Note(s) : none.
*********************************************************************************************************
*/
NET_CONN_ID NetConn_ID_AppGet (NET_CONN_ID conn_id,
NET_ERR *perr)
{
NET_CONN *pconn;
NET_CONN_ID conn_id_app;
/* ---------------- VALIDATE NET CONN ----------------- */
if (conn_id == NET_CONN_ID_NONE) {
*perr = NET_CONN_ERR_NONE;
return (NET_CONN_ID_NONE);
}
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED) /* -------------- VALIDATE NET CONN USED -------------- */
(void)NetConn_IsUsed(conn_id, perr);
if (*perr != NET_CONN_ERR_NONE) {
return (NET_CONN_ID_NONE);
}
#endif
pconn = &NetConn_Tbl[conn_id];
conn_id_app = pconn->ID_App; /* Get net conn's app id. */
*perr = NET_CONN_ERR_NONE;
return (conn_id_app);
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetConn_ID_AppSet()
*
* Description : Set a network connection's application layer handle identifier.
*
* Argument(s) : conn_id Handle identifier of network connection to set application layer handle
* identifier.
*
* conn_id_app Connection's application layer handle identifier.
*
* perr Pointer to variable that will receive the return error code from this function :
*
* NET_CONN_ERR_NONE Network connection's handle identifier
* successfully set.
*
* --- RETURNED BY NetConn_IsUsed() : ---
* NET_ERR_INIT_INCOMPLETE Network initialization NOT complete.
* NET_CONN_ERR_INVALID_CONN Invalid network connection number.
* NET_CONN_ERR_NOT_USED Network connection NOT currently used.
*
* Return(s) : none.
*
* Caller(s) : various.
*
* This function is an INTERNAL network protocol suite function & MUST NOT be called by
* application function(s).
*
* Note(s) : none.
*********************************************************************************************************
*/
void NetConn_ID_AppSet (NET_CONN_ID conn_id,
NET_CONN_ID conn_id_app,
NET_ERR *perr)
{
#if ((NET_CTR_CFG_ERR_EN == DEF_ENABLED) && \
(CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL))
CPU_SR cpu_sr;
#endif
NET_CONN *pconn;
/* ---------------- VALIDATE NET CONN ----------------- */
if (conn_id == NET_CONN_ID_NONE) {
*perr = NET_CONN_ERR_NONE;
return;
}
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED) /* -------------- VALIDATE NET CONN USED -------------- */
(void)NetConn_IsUsed(conn_id, perr);
if (*perr != NET_CONN_ERR_NONE) {
return;
}
#endif
/* --------------- VALIDATE APP CONN ID --------------- */
if (conn_id_app < NET_CONN_ID_NONE) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return;
}
pconn = &NetConn_Tbl[conn_id];
pconn->ID_App = conn_id_app; /* Set net conn's app id. */
*perr = NET_CONN_ERR_NONE;
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetConn_ID_AppCloneGet()
*
* Description : Get a network connection's application layer clone handle identifier.
*
* Argument(s) : conn_id Handle identifier of network connection to get application layer clone handle
* identifier.
*
* perr Pointer to variable that will receive the return error code from this function :
*
* NET_CONN_ERR_NONE Network connection handle identifier get
* successful.
*
* ---- RETURNED BY NetConn_IsUsed() : ----
* NET_ERR_INIT_INCOMPLETE Network initialization NOT complete.
* NET_CONN_ERR_INVALID_CONN Invalid network connection number.
* NET_CONN_ERR_NOT_USED Network connection NOT currently used.
*
* Return(s) : Network connection's application layer clone handle identifier, if NO errors.
*
* NET_CONN_ID_NONE, otherwise.
*
* Caller(s) : various.
*
* This function is an INTERNAL network protocol suite function & SHOULD NOT be called by
* application function(s).
*
* Note(s) : none.
*********************************************************************************************************
*/
NET_CONN_ID NetConn_ID_AppCloneGet (NET_CONN_ID conn_id,
NET_ERR *perr)
{
NET_CONN *pconn;
NET_CONN_ID conn_id_app_clone;
/* ---------------- VALIDATE NET CONN ----------------- */
if (conn_id == NET_CONN_ID_NONE) {
*perr = NET_CONN_ERR_NONE;
return (NET_CONN_ID_NONE);
}
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED) /* -------------- VALIDATE NET CONN USED -------------- */
(void)NetConn_IsUsed(conn_id, perr);
if (*perr != NET_CONN_ERR_NONE) {
return (NET_CONN_ID_NONE);
}
#endif
pconn = &NetConn_Tbl[conn_id];
conn_id_app_clone = pconn->ID_AppClone; /* Get net conn's app clone id. */
*perr = NET_CONN_ERR_NONE;
return (conn_id_app_clone);
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetConn_ID_AppCloneSet()
*
* Description : Set a network connection's application layer clone handle identifier.
*
* Argument(s) : conn_id Handle identifier of network connection to set application layer clone
* handle identifier.
*
* conn_id_app Connection's application layer handle identifier.
*
* perr Pointer to variable that will receive the return error code from this function :
*
* NET_CONN_ERR_NONE Network connection's handle identifier
* successfully set.
*
* --- RETURNED BY NetConn_IsUsed() : ---
* NET_ERR_INIT_INCOMPLETE Network initialization NOT complete.
* NET_CONN_ERR_INVALID_CONN Invalid network connection number.
* NET_CONN_ERR_NOT_USED Network connection NOT currently used.
*
* Return(s) : none.
*
* Caller(s) : various.
*
* This function is an INTERNAL network protocol suite function & MUST NOT be called by
* application function(s).
*
* Note(s) : none.
*********************************************************************************************************
*/
void NetConn_ID_AppCloneSet (NET_CONN_ID conn_id,
NET_CONN_ID conn_id_app,
NET_ERR *perr)
{
#if ((NET_CTR_CFG_ERR_EN == DEF_ENABLED) && \
(CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL))
CPU_SR cpu_sr;
#endif
NET_CONN *pconn;
/* ---------------- VALIDATE NET CONN ----------------- */
if (conn_id == NET_CONN_ID_NONE) {
*perr = NET_CONN_ERR_NONE;
return;
}
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED) /* -------------- VALIDATE NET CONN USED -------------- */
(void)NetConn_IsUsed(conn_id, perr);
if (*perr != NET_CONN_ERR_NONE) {
return;
}
#endif
/* --------------- VALIDATE APP CONN ID --------------- */
if (conn_id_app < NET_CONN_ID_NONE) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return;
}
pconn = &NetConn_Tbl[conn_id];
pconn->ID_AppClone = conn_id_app; /* Set net conn's app clone id. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -