Skip to content

Commit

Permalink
drivers:alt1250: Correspond to shutdown
Browse files Browse the repository at this point in the history
ALT1250 driver to support shutdown.
  • Loading branch information
SPRESENSE authored and xiaoxiang781216 committed Sep 22, 2023
1 parent e930476 commit 7f57421
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/modem/alt1250/altcom_cmd_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@

#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
****************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions drivers/modem/alt1250/altcom_hdlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static compose_inst_t g_composehdlrs[] =
CTABLE_CONTENT(RECVFROM, altcom_recvfrom),
CTABLE_CONTENT(SELECT, altcom_select),
CTABLE_CONTENT(SENDTO, altcom_sendto),
CTABLE_CONTENT(SHUTDOWN, altcom_shutdown),
CTABLE_CONTENT(SOCKET, altcom_socket),
CTABLE_CONTENT(SETSOCKOPT, altcom_setsockopt),
CTABLE_CONTENT(SENDATCMD, altcom_sendatcmd),
Expand Down Expand Up @@ -199,6 +200,7 @@ static parse_inst_t g_parsehdlrs[] =
PTABLE_CONTENT(SOCK_RECVFROM, altcom_recvfrom),
PTABLE_CONTENT(SOCK_SELECT, altcom_select),
PTABLE_CONTENT(SOCK_SENDTO, altcom_sockcomm),
PTABLE_CONTENT(SOCK_SHUTDOWN, altcom_sockcomm),
PTABLE_CONTENT(SOCK_SOCKET, altcom_sockcomm),
PTABLE_CONTENT(SOCK_SETSOCKOPT, altcom_sockcomm),
PTABLE_CONTENT(SEND_ATCMD, altcom_sendatcmd),
Expand Down
31 changes: 31 additions & 0 deletions drivers/modem/alt1250/altcom_hdlr_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,37 @@ int32_t altcom_select_pkt_compose(FAR void **arg, size_t arglen,
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,
FAR uint8_t *pktbuf, size_t pktsz,
uint8_t altver, FAR void **arg,
Expand Down
4 changes: 4 additions & 0 deletions drivers/modem/alt1250/altcom_hdlr_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
uint8_t altver, FAR uint8_t *pktbuf,
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,
FAR uint8_t *pktbuf, size_t pktsz,
uint8_t altver, FAR void **arg,
Expand Down

0 comments on commit 7f57421

Please sign in to comment.