lte/alt1250: Correspond to shutdown
ALT1250 daemon to support shutdown.
This commit is contained in:
parent
049aaa4c96
commit
d6ed8880d8
@ -27,10 +27,46 @@
|
|||||||
|
|
||||||
#include "alt1250_dbg.h"
|
#include "alt1250_dbg.h"
|
||||||
#include "alt1250_container.h"
|
#include "alt1250_container.h"
|
||||||
|
#include "alt1250_devif.h"
|
||||||
#include "alt1250_socket.h"
|
#include "alt1250_socket.h"
|
||||||
|
#include "alt1250_usrsock_hdlr.h"
|
||||||
#include "alt1250_usockevent.h"
|
#include "alt1250_usockevent.h"
|
||||||
#include "alt1250_postproc.h"
|
#include "alt1250_postproc.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* name: send_shutdown_command
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int send_shutdown_command(FAR struct alt1250_s *dev,
|
||||||
|
FAR struct alt_container_s *container,
|
||||||
|
FAR struct usock_s *usock, int32_t how,
|
||||||
|
FAR int32_t *usock_result)
|
||||||
|
{
|
||||||
|
int idx = 0;
|
||||||
|
FAR void *inparam[2];
|
||||||
|
|
||||||
|
/* These members are referenced only when sending a command and
|
||||||
|
* not when receiving a response, so local variables are used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
inparam[0] = &USOCKET_ALTSOCKID(usock);
|
||||||
|
inparam[1] = &how;
|
||||||
|
|
||||||
|
USOCKET_SET_RESPONSE(usock, idx++, USOCKET_REP_RESULT(usock));
|
||||||
|
USOCKET_SET_RESPONSE(usock, idx++, USOCKET_REP_ERRCODE(usock));
|
||||||
|
|
||||||
|
set_container_ids(container, USOCKET_USOCKID(usock), LTE_CMDID_SHUTDOWN);
|
||||||
|
set_container_argument(container, inparam, nitems(inparam));
|
||||||
|
set_container_response(container, USOCKET_REP_RESPONSE(usock), idx);
|
||||||
|
set_container_postproc(container, postproc_sockcommon, 0);
|
||||||
|
|
||||||
|
return altdevice_send_command(dev->altfd, container, usock_result);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -47,13 +83,65 @@ int usockreq_shutdown(FAR struct alt1250_s *dev,
|
|||||||
{
|
{
|
||||||
FAR struct usrsock_request_shutdown_s *request =
|
FAR struct usrsock_request_shutdown_s *request =
|
||||||
&req->request.shutdown_req;
|
&req->request.shutdown_req;
|
||||||
|
FAR struct usock_s *usock;
|
||||||
|
FAR struct alt_container_s *container;
|
||||||
|
int ret = REP_SEND_ACK_WOFREE;
|
||||||
|
|
||||||
dbg_alt1250("%s start\n", __func__);
|
dbg_alt1250("%s start\n", __func__);
|
||||||
|
|
||||||
/* Not support */
|
*usock_result = OK;
|
||||||
|
|
||||||
*usock_result = -ENOTSUP;
|
|
||||||
*usock_xid = request->head.xid;
|
*usock_xid = request->head.xid;
|
||||||
|
|
||||||
return REP_SEND_ACK_WOFREE;
|
if (request->how != SHUT_RD &&
|
||||||
|
request->how != SHUT_WR &&
|
||||||
|
request->how != SHUT_RDWR)
|
||||||
|
{
|
||||||
|
dbg_alt1250("Invalid parameter: %d\n", request->how);
|
||||||
|
*usock_result = -EINVAL;
|
||||||
|
return REP_SEND_ACK_WOFREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
usock = usocket_search(dev, request->usockid);
|
||||||
|
if (usock == NULL)
|
||||||
|
{
|
||||||
|
dbg_alt1250("Failed to get socket context: %u\n",
|
||||||
|
request->usockid);
|
||||||
|
*usock_result = -EBADFD;
|
||||||
|
return REP_SEND_ACK_WOFREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
USOCKET_SET_REQUEST(usock, request->head.reqid, request->head.xid);
|
||||||
|
|
||||||
|
switch (USOCKET_STATE(usock))
|
||||||
|
{
|
||||||
|
case SOCKET_STATE_CLOSED:
|
||||||
|
case SOCKET_STATE_CLOSING:
|
||||||
|
dbg_alt1250("Unexpected state: %d\n", USOCKET_STATE(usock));
|
||||||
|
*usock_result = -EBADFD;
|
||||||
|
ret = REP_SEND_ACK_WOFREE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOCKET_STATE_PREALLOC:
|
||||||
|
*usock_result = OK;
|
||||||
|
ret = REP_SEND_ACK_WOFREE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
container = container_alloc();
|
||||||
|
if (container == NULL)
|
||||||
|
{
|
||||||
|
dbg_alt1250("no container\n");
|
||||||
|
return REP_NO_CONTAINER;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = send_shutdown_command(dev, container, usock,
|
||||||
|
request->how, usock_result);
|
||||||
|
if (IS_NEED_CONTAINER_FREE(ret))
|
||||||
|
{
|
||||||
|
container_free(container);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user