mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
sim/usrsock: increase the sim usrsock buffer size
1. Increase the sim usrsock buffer size: arch/sim/src/sim/up_usrsock.c 2. Fix build break arch/sim/src/sim/up_usrsock_host.c Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
@@ -35,6 +35,12 @@
|
|||||||
|
|
||||||
#include "up_usrsock_host.h"
|
#include "up_usrsock_host.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define SIM_USRSOCK_BUFSIZE (400 * 1024)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Type Declarations
|
* Private Type Declarations
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -42,7 +48,8 @@
|
|||||||
struct usrsock_s
|
struct usrsock_s
|
||||||
{
|
{
|
||||||
struct file usock;
|
struct file usock;
|
||||||
uint8_t data[4096];
|
uint8_t in [SIM_USRSOCK_BUFSIZE];
|
||||||
|
uint8_t out[SIM_USRSOCK_BUFSIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -206,10 +213,10 @@ static int usrsock_recvfrom_handler(FAR struct usrsock_s *usrsock,
|
|||||||
size_t buflen = req->max_buflen;
|
size_t buflen = req->max_buflen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ack = (struct usrsock_message_datareq_ack_s *)usrsock->data;
|
ack = (struct usrsock_message_datareq_ack_s *)usrsock->out;
|
||||||
if (sizeof(*ack) + inaddrlen + buflen > sizeof(usrsock->data))
|
if (sizeof(*ack) + inaddrlen + buflen > sizeof(usrsock->out))
|
||||||
{
|
{
|
||||||
buflen = sizeof(usrsock->data) - sizeof(*ack) - inaddrlen;
|
buflen = sizeof(usrsock->out) - sizeof(*ack) - inaddrlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = usrsock_host_recvfrom(req->usockid,
|
ret = usrsock_host_recvfrom(req->usockid,
|
||||||
@@ -246,7 +253,7 @@ static int usrsock_getsockopt_handler(FAR struct usrsock_s *usrsock,
|
|||||||
socklen_t optlen = req->max_valuelen;
|
socklen_t optlen = req->max_valuelen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->data;
|
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out;
|
||||||
ret = usrsock_host_getsockopt(req->usockid,
|
ret = usrsock_host_getsockopt(req->usockid,
|
||||||
req->level, req->option,
|
req->level, req->option,
|
||||||
ack + 1, &optlen);
|
ack + 1, &optlen);
|
||||||
@@ -264,7 +271,7 @@ static int usrsock_getsockname_handler(FAR struct usrsock_s *usrsock,
|
|||||||
socklen_t inaddrlen = req->max_addrlen;
|
socklen_t inaddrlen = req->max_addrlen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->data;
|
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out;
|
||||||
ret = usrsock_host_getsockname(req->usockid,
|
ret = usrsock_host_getsockname(req->usockid,
|
||||||
(FAR struct sockaddr *)(ack + 1), &outaddrlen);
|
(FAR struct sockaddr *)(ack + 1), &outaddrlen);
|
||||||
|
|
||||||
@@ -281,7 +288,7 @@ static int usrsock_getpeername_handler(FAR struct usrsock_s *usrsock,
|
|||||||
socklen_t inaddrlen = req->max_addrlen;
|
socklen_t inaddrlen = req->max_addrlen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->data;
|
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out;
|
||||||
ret = usrsock_host_getpeername(req->usockid,
|
ret = usrsock_host_getpeername(req->usockid,
|
||||||
(FAR struct sockaddr *)(ack + 1), &outaddrlen);
|
(FAR struct sockaddr *)(ack + 1), &outaddrlen);
|
||||||
|
|
||||||
@@ -319,7 +326,7 @@ static int usrsock_accept_handler(FAR struct usrsock_s *usrsock,
|
|||||||
int sockfd;
|
int sockfd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->data;
|
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out;
|
||||||
sockfd = usrsock_host_accept(req->usockid,
|
sockfd = usrsock_host_accept(req->usockid,
|
||||||
outaddrlen ?
|
outaddrlen ?
|
||||||
(FAR struct sockaddr *)(ack + 1) : NULL,
|
(FAR struct sockaddr *)(ack + 1) : NULL,
|
||||||
@@ -361,7 +368,7 @@ static int usrsock_ioctl_handler(FAR struct usrsock_s *usrsock,
|
|||||||
FAR struct usrsock_message_datareq_ack_s *ack;
|
FAR struct usrsock_message_datareq_ack_s *ack;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->data;
|
ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out;
|
||||||
memcpy(ack + 1, req + 1, req->arglen);
|
memcpy(ack + 1, req + 1, req->arglen);
|
||||||
ret = usrsock_host_ioctl(req->usockid, req->cmd,
|
ret = usrsock_host_ioctl(req->usockid, req->cmd,
|
||||||
(unsigned long)(ack + 1));
|
(unsigned long)(ack + 1));
|
||||||
@@ -404,7 +411,6 @@ int usrsock_init(void)
|
|||||||
void usrsock_loop(void)
|
void usrsock_loop(void)
|
||||||
{
|
{
|
||||||
FAR struct usrsock_request_common_s *common;
|
FAR struct usrsock_request_common_s *common;
|
||||||
uint8_t data[4096];
|
|
||||||
int ret;
|
int ret;
|
||||||
struct pollfd pfd =
|
struct pollfd pfd =
|
||||||
{
|
{
|
||||||
@@ -415,16 +421,16 @@ void usrsock_loop(void)
|
|||||||
ret = poll(&pfd, 1, 0);
|
ret = poll(&pfd, 1, 0);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
ret = file_read(&g_usrsock.usock, data, sizeof(data));
|
ret = file_read(&g_usrsock.usock, g_usrsock.in, sizeof(g_usrsock.in));
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
common = (FAR struct usrsock_request_common_s *)data;
|
common = (FAR struct usrsock_request_common_s *)g_usrsock.in;
|
||||||
|
|
||||||
if (common->reqid >= 0 &&
|
if (common->reqid >= 0 &&
|
||||||
common->reqid < USRSOCK_REQUEST__MAX)
|
common->reqid < USRSOCK_REQUEST__MAX)
|
||||||
{
|
{
|
||||||
ret = g_usrsock_handler[common->reqid](&g_usrsock,
|
ret = g_usrsock_handler[common->reqid](&g_usrsock,
|
||||||
data, ret);
|
g_usrsock.in, ret);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, "Usrsock request %d failed: %d\n",
|
syslog(LOG_ERR, "Usrsock request %d failed: %d\n",
|
||||||
|
|||||||
@@ -444,7 +444,6 @@ int usrsock_host_accept(int sockfd, struct nuttx_sockaddr *addr,
|
|||||||
{
|
{
|
||||||
socklen_t naddrlen = sizeof(socklen_t);
|
socklen_t naddrlen = sizeof(socklen_t);
|
||||||
struct sockaddr naddr;
|
struct sockaddr naddr;
|
||||||
socklen_t naddrlen;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = accept(sockfd, &naddr, &naddrlen);
|
ret = accept(sockfd, &naddr, &naddrlen);
|
||||||
|
|||||||
Reference in New Issue
Block a user