?? net_conn.c
字號(hào):
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_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.
* 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_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
#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_AppClone = conn_id_app; /* Set net conn's app clone id. */
*perr = NET_CONN_ERR_NONE;
return (DEF_OK);
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetConn_ID_TransportGet()
*
* Description : Get a network connection's transport layer handle identifier.
*
* Argument(s) : conn_id Handle identifier of network connection to get transport 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 transport 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_TransportGet (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_transport;
/* ---------------- 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_transport = pconn->ID_Transport; /* Get net conn's transport id. */
*perr = NET_CONN_ERR_NONE;
return (conn_id_transport);
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetConn_ID_TransportSet()
*
* Description : Set a network connection's transport layer handle identifier.
*
* Argument(s) : conn_id Handle identifier of network connection to set transport layer handle
* identifier.
*
* conn_id_transport Connection's transport 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_TransportSet (NET_CONN_ID conn_id,
NET_CONN_ID conn_id_transport,
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 TRANSPORT CONN ID ------------ */
if (conn_id_transport < NET_CONN_ID_NONE) {
NET_CTR_ERR_INC(NetConn_ErrInvalidConnCtr);
*perr = NET_CONN_ERR_INVALID_CONN;
return (DEF_FAIL);
}
pconn->ID_Transport = conn_id_transport; /* Set net conn's transport id. */
*perr = NET_CONN_ERR_NONE;
return (DEF_OK);
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetConn_AddrLocalGet()
*
* Description : Get a network connection's local address.
*
* Argument(s) : conn_id Handle identifier of network connection to get local address.
*
* paddr_local Pointer to variable that will receive the return local address (see Note #1),
* if NO errors.
*
* paddr_len Pointer to a variable to ... :
*
* (a) Pass the size of the address buffer pointed to by 'paddr_local'.
* (b) Return the actual local address length, if NO er
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -