2008-11-17 02:48:29 +08:00
|
|
|
/****************************************************************************
|
2014-06-29 07:25:18 +08:00
|
|
|
* net/socket/net_poll.c
|
2008-11-17 02:48:29 +08:00
|
|
|
*
|
2024-09-11 20:39:39 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2008-11-17 02:48:29 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-11-17 02:48:29 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2008-11-17 02:48:29 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2017-07-15 00:57:38 +08:00
|
|
|
#include <assert.h>
|
2008-11-17 02:48:29 +08:00
|
|
|
#include <errno.h>
|
2008-11-19 06:14:25 +08:00
|
|
|
|
2017-07-15 00:57:38 +08:00
|
|
|
#include <nuttx/net/net.h>
|
|
|
|
|
2014-06-29 07:25:18 +08:00
|
|
|
#include "socket/socket.h"
|
2008-11-17 02:48:29 +08:00
|
|
|
|
2008-11-19 01:30:30 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
2008-11-17 02:48:29 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 06:33:14 +08:00
|
|
|
* Name: psock_poll
|
2008-11-17 02:48:29 +08:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The standard poll() operation redirects operations on socket descriptors
|
|
|
|
* to this function.
|
|
|
|
*
|
2008-11-19 01:30:30 +08:00
|
|
|
* Input Parameters:
|
2013-01-25 03:19:38 +08:00
|
|
|
* psock - An instance of the internal socket structure.
|
2008-11-20 02:43:50 +08:00
|
|
|
* fds - The structure describing the events to be monitored, OR NULL if
|
|
|
|
* this is a request to stop monitoring events.
|
2009-12-15 23:57:25 +08:00
|
|
|
* setup - true: Setup up the poll; false: Teardown the poll
|
2008-11-17 02:48:29 +08:00
|
|
|
*
|
|
|
|
* Returned Value:
|
2008-11-19 01:30:30 +08:00
|
|
|
* 0: Success; Negated errno on failure
|
2008-11-17 02:48:29 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-01-25 03:19:38 +08:00
|
|
|
int psock_poll(FAR struct socket *psock, FAR struct pollfd *fds, bool setup)
|
2008-11-17 02:48:29 +08:00
|
|
|
{
|
2017-07-15 00:57:38 +08:00
|
|
|
DEBUGASSERT(psock != NULL && fds != NULL);
|
2017-03-31 22:58:14 +08:00
|
|
|
|
2017-07-15 00:57:38 +08:00
|
|
|
/* Let the address family's poll() method handle the operation */
|
2013-05-23 21:16:46 +08:00
|
|
|
|
2023-03-06 13:24:00 +08:00
|
|
|
DEBUGASSERT(psock->s_sockif != NULL);
|
|
|
|
if (psock->s_sockif->si_poll == NULL)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2017-07-15 00:57:38 +08:00
|
|
|
return psock->s_sockif->si_poll(psock, fds, setup);
|
2013-01-25 03:19:38 +08:00
|
|
|
}
|