?? net_conn.c
字號:
NetOS_Lock(&err); /* Acquire net lock (see Note #2b). */
if (err != NET_OS_ERR_NONE) {
return;
}
NetConn_CloseAllConnsHandler(); /* Close all net conns. */
NetOS_Unlock(); /* Release net lock. */
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetConn_CloseAllConnsHandler()
*
* Description : Close ALL network connections in ALL network connection lists.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : NetConn_CloseAllConns().
*
* This function is an INTERNAL network protocol suite function & MUST NOT be called by
* 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.
* NET_CONN_ERR_INVALID_CONN Invalid 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) : (1) #### 'perr' may NOT be necessary (remove if unnecessary).
*********************************************************************************************************
*/
NET_CONN_ID NetConn_ID_AppGet (NET_CONN_ID conn_id,
NET_ERR *perr)
{
#if ((NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED) && \
(NET_CTR_CFG_ERR_EN == DEF_ENABLED) && \
(CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL))
CPU_SR cpu_sr;
#endif
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
CPU_BOOLEAN used;
#endif
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)
if (conn_id < NET_CONN_ID_MIN) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return (NET_CONN_ID_NONE);
}
if (conn_id > NET_CONN_ID_MAX) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return (NET_CONN_ID_NONE);
}
#endif
pconn = &NetConn_Tbl[conn_id];
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
/* -------------- VALIDATE NET CONN USED -------------- */
used = DEF_BIT_IS_SET(pconn->Flags, NET_CONN_FLAG_USED);
if (used != DEF_YES) { /* If net conn NOT used, rtn err. */
NET_CTR_ERR_INC(NetConn_ErrNotUsedCtr);
*perr = NET_CONN_ERR_NOT_USED;
return (NET_CONN_ID_NONE);
}
#endif
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.
* NET_CONN_ERR_INVALID_CONN Invalid connection number.
* NET_CONN_ERR_NOT_USED Network connection NOT currently used.
*
* Return(s) : DEF_OK, if NO errors.
*
* DEF_FAIL, otherwise.
*
* Caller(s) : various.
*
* This function is an INTERNAL network protocol suite function & MUST NOT be called by
* application function(s).
*
* Note(s) : (1) #### Return value may NOT be necessary (remove if unnecessary).
*********************************************************************************************************
*/
CPU_BOOLEAN 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
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
CPU_BOOLEAN used;
#endif
NET_CONN *pconn;
/* ---------------- VALIDATE NET CONN ----------------- */
if (conn_id == NET_CONN_ID_NONE) {
*perr = NET_CONN_ERR_NONE;
return (DEF_FAIL);
}
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
if (conn_id < NET_CONN_ID_MIN) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return (DEF_FAIL);
}
if (conn_id > NET_CONN_ID_MAX) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return (DEF_FAIL);
}
#endif
pconn = &NetConn_Tbl[conn_id];
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
/* -------------- VALIDATE NET CONN USED -------------- */
used = DEF_BIT_IS_SET(pconn->Flags, NET_CONN_FLAG_USED);
if (used != DEF_YES) { /* If net conn NOT used, rtn err. */
NET_CTR_ERR_INC(NetConn_ErrNotUsedCtr);
*perr = NET_CONN_ERR_NOT_USED;
return (DEF_FAIL);
}
#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 (DEF_FAIL);
}
pconn->ID_App = conn_id_app; /* Set net conn's app id. */
*perr = NET_CONN_ERR_NONE;
return (DEF_OK);
}
/*$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.
* NET_CONN_ERR_INVALID_CONN Invalid 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) : (1) #### 'perr' may NOT be necessary (remove if unnecessary).
*********************************************************************************************************
*/
NET_CONN_ID NetConn_ID_AppCloneGet (NET_CONN_ID conn_id,
NET_ERR *perr)
{
#if ((NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED) && \
(NET_CTR_CFG_ERR_EN == DEF_ENABLED) && \
(CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL))
CPU_SR cpu_sr;
#endif
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
CPU_BOOLEAN used;
#endif
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)
if (conn_id < NET_CONN_ID_MIN) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return (NET_CONN_ID_NONE);
}
if (conn_id > NET_CONN_ID_MAX) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return (NET_CONN_ID_NONE);
}
#endif
pconn = &NetConn_Tbl[conn_id];
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
/* -------------- VALIDATE NET CONN USED -------------- */
used = DEF_BIT_IS_SET(pconn->Flags, NET_CONN_FLAG_USED);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -