mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
drivers:alt1250: Correspond to shutdown
ALT1250 driver to support shutdown.
This commit is contained in:
@@ -159,6 +159,14 @@
|
|||||||
|
|
||||||
#define ALTCOM_IPV6_V6ONLY 27 /* Refer to IPV6_V6ONLY on lwIP */
|
#define ALTCOM_IPV6_V6ONLY 27 /* Refer to IPV6_V6ONLY on lwIP */
|
||||||
|
|
||||||
|
/* Options for level ALTCOM_SHUT
|
||||||
|
* Referenced from sockets.h of lwIP-v2.02
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ALTCOM_SHUT_RD 0 /* Refer to SHUT_RD on lwIP */
|
||||||
|
#define ALTCOM_SHUT_WR 1 /* Refer to SHUT_WR on lwIP */
|
||||||
|
#define ALTCOM_SHUT_RDWR 2 /* Refer to SHUT_RDWR on lwIP */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ static compose_inst_t g_composehdlrs[] =
|
|||||||
CTABLE_CONTENT(RECVFROM, altcom_recvfrom),
|
CTABLE_CONTENT(RECVFROM, altcom_recvfrom),
|
||||||
CTABLE_CONTENT(SELECT, altcom_select),
|
CTABLE_CONTENT(SELECT, altcom_select),
|
||||||
CTABLE_CONTENT(SENDTO, altcom_sendto),
|
CTABLE_CONTENT(SENDTO, altcom_sendto),
|
||||||
|
CTABLE_CONTENT(SHUTDOWN, altcom_shutdown),
|
||||||
CTABLE_CONTENT(SOCKET, altcom_socket),
|
CTABLE_CONTENT(SOCKET, altcom_socket),
|
||||||
CTABLE_CONTENT(SETSOCKOPT, altcom_setsockopt),
|
CTABLE_CONTENT(SETSOCKOPT, altcom_setsockopt),
|
||||||
CTABLE_CONTENT(SENDATCMD, altcom_sendatcmd),
|
CTABLE_CONTENT(SENDATCMD, altcom_sendatcmd),
|
||||||
@@ -199,6 +200,7 @@ static parse_inst_t g_parsehdlrs[] =
|
|||||||
PTABLE_CONTENT(SOCK_RECVFROM, altcom_recvfrom),
|
PTABLE_CONTENT(SOCK_RECVFROM, altcom_recvfrom),
|
||||||
PTABLE_CONTENT(SOCK_SELECT, altcom_select),
|
PTABLE_CONTENT(SOCK_SELECT, altcom_select),
|
||||||
PTABLE_CONTENT(SOCK_SENDTO, altcom_sockcomm),
|
PTABLE_CONTENT(SOCK_SENDTO, altcom_sockcomm),
|
||||||
|
PTABLE_CONTENT(SOCK_SHUTDOWN, altcom_sockcomm),
|
||||||
PTABLE_CONTENT(SOCK_SOCKET, altcom_sockcomm),
|
PTABLE_CONTENT(SOCK_SOCKET, altcom_sockcomm),
|
||||||
PTABLE_CONTENT(SOCK_SETSOCKOPT, altcom_sockcomm),
|
PTABLE_CONTENT(SOCK_SETSOCKOPT, altcom_sockcomm),
|
||||||
PTABLE_CONTENT(SEND_ATCMD, altcom_sendatcmd),
|
PTABLE_CONTENT(SEND_ATCMD, altcom_sendatcmd),
|
||||||
|
|||||||
@@ -1069,6 +1069,37 @@ int32_t altcom_select_pkt_compose(FAR void **arg, size_t arglen,
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t altcom_shutdown_pkt_compose(FAR void **arg, size_t arglen,
|
||||||
|
uint8_t altver, FAR uint8_t *pktbuf,
|
||||||
|
const size_t pktsz, FAR uint16_t *altcid)
|
||||||
|
{
|
||||||
|
FAR int32_t sockfd = *((FAR int32_t *)arg[0]);
|
||||||
|
FAR int32_t how = *((FAR int32_t *)arg[1]);
|
||||||
|
FAR struct apicmd_shutdown_s *out =
|
||||||
|
(FAR struct apicmd_shutdown_s *)pktbuf;
|
||||||
|
|
||||||
|
switch (how)
|
||||||
|
{
|
||||||
|
case SHUT_RD:
|
||||||
|
how = ALTCOM_SHUT_RD;
|
||||||
|
break;
|
||||||
|
case SHUT_WR:
|
||||||
|
how = ALTCOM_SHUT_WR;
|
||||||
|
break;
|
||||||
|
case SHUT_RDWR:
|
||||||
|
how = ALTCOM_SHUT_RDWR;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
out->sockfd = htonl(sockfd);
|
||||||
|
out->how = htonl(how);
|
||||||
|
*altcid = APICMDID_SOCK_SHUTDOWN;
|
||||||
|
|
||||||
|
return sizeof(struct apicmd_shutdown_s);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t altcom_sockcomm_pkt_parse(FAR struct alt1250_dev_s *dev,
|
int32_t altcom_sockcomm_pkt_parse(FAR struct alt1250_dev_s *dev,
|
||||||
FAR uint8_t *pktbuf, size_t pktsz,
|
FAR uint8_t *pktbuf, size_t pktsz,
|
||||||
uint8_t altver, FAR void **arg,
|
uint8_t altver, FAR void **arg,
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ int32_t altcom_setsockopt_pkt_compose(FAR void **arg, size_t arglen,
|
|||||||
int32_t altcom_select_pkt_compose(FAR void **arg, size_t arglen,
|
int32_t altcom_select_pkt_compose(FAR void **arg, size_t arglen,
|
||||||
uint8_t altver, FAR uint8_t *pktbuf,
|
uint8_t altver, FAR uint8_t *pktbuf,
|
||||||
const size_t pktsz, FAR uint16_t *altcid);
|
const size_t pktsz, FAR uint16_t *altcid);
|
||||||
|
int32_t altcom_shutdown_pkt_compose(FAR void **arg, size_t arglen,
|
||||||
|
uint8_t altver, FAR uint8_t *pktbuf,
|
||||||
|
const size_t pktsz,
|
||||||
|
FAR uint16_t *altcid);
|
||||||
int32_t altcom_sockcomm_pkt_parse(FAR struct alt1250_dev_s *dev,
|
int32_t altcom_sockcomm_pkt_parse(FAR struct alt1250_dev_s *dev,
|
||||||
FAR uint8_t *pktbuf, size_t pktsz,
|
FAR uint8_t *pktbuf, size_t pktsz,
|
||||||
uint8_t altver, FAR void **arg,
|
uint8_t altver, FAR void **arg,
|
||||||
|
|||||||
Reference in New Issue
Block a user