Remove psock_send and sockfd_socket from net/socket/socket.h

Since both is already declared in include/nuttx/net/net.h and fix other minor issue in network socket layer.
This commit is contained in:
Xiang Xiao 2020-02-01 02:09:01 +08:00 committed by Gregory Nutt
parent 0fc7668d65
commit c1b0aa118c
19 changed files with 33 additions and 129 deletions

View file

@ -118,13 +118,13 @@ in_addr_t inet_lnaof(struct in_addr in);
in_addr_t inet_netof(struct in_addr in);
#else
FAR char *_inet_ntoa(in_addr_t in);
# define inet_ntoa(in) _inet_ntoa(in.s_addr);
# define inet_ntoa(in) _inet_ntoa(in.s_addr)
in_addr_t _inet_lnaof(in_addr_t in);
# define inet_lnaof(in) _inet_lnaof(in.s_addr);
# define inet_lnaof(in) _inet_lnaof(in.s_addr)
in_addr_t _inet_netof(in_addr_t in);
# define inet_netof(in) _inet_netof(in.s_addr);
# define inet_netof(in) _inet_netof(in.s_addr)
#endif
struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host);

View file

@ -176,7 +176,7 @@ struct lifreq
#define lifr_mii_val_in lifr_ifru.lifru_mii_data.val_in /* PHY input data */
#define lifr_mii_val_out lifr_ifru.lifru_mii_data.val_out /* PHY output data */
/* Used only with the SIOCGLIFCONF IOCTL commnd*/
/* Used only with the SIOCGLIFCONF IOCTL commnd */
struct lifconf
{
@ -221,7 +221,6 @@ struct ifreq
#define ifr_flags ifr_ifru.ifru_flags /* interface flags */
#define ifr_mii_notify_pid ifr_ifru.ifru_mii_notify.pid /* PID to be notified */
#define ifr_mii_notify_event ifr_ifru.ifru_mii_notify.event /* Describes notification */
#define ifr_mii_notify_arg ifr_ifru.ifru_mii_notify.arg /* sigval argument */
#define ifr_mii_phy_id ifr_ifru.ifru_mii_data.phy_id /* PHY device address */
#define ifr_mii_reg_num ifr_ifru.ifru_mii_data.reg_num /* PHY register address */
#define ifr_mii_val_in ifr_ifru.ifru_mii_data.val_in /* PHY input data */

View file

@ -110,8 +110,8 @@ int addroute(int sockfd, FAR struct sockaddr_storage *target,
* Name: net_delroute
*
* Description:
* Add a new route to the routing table. This is just a convenience
* wrapper for the SIOCADDRT ioctl call.
* Delete a route from the routing table. This is just a convenience
* wrapper for the SIOCDELRT ioctl call.
*
* Input Parameters:
* sockfd - Any socket descriptor

View file

@ -43,16 +43,14 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <net/if.h>
#include <nuttx/fs/ioctl.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Three ioctls are available on all PF_INET sockets, but only if the NuttX
* configuration CONFIG_NET_ARPIOCTLS is defined. Each ioctl takes a pointer
* to a 'struct arpreq' as its parameter.
/* Three ioctls are available on all PF_INET sockets. Each ioctl takes a
* pointer to a 'struct arpreq' as its parameter.
*/
#define SIOCSARP _ARPIOC(1) /* Set a ARP mapping */
@ -102,15 +100,9 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
/* If CONFIG_NET_ARPIOCTLS is defined then the semi-standard ioctl commands
* described above are supported. If not, you can call the network ARP
* interfaces directly in a very non-standard way. See
* include/nuttx/net/arp.h for prototypes.
*/
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NETINET_ARP_H */
#endif /* __INCLUDE_NETINET_ARP_H */

View file

@ -76,4 +76,4 @@ int ether_line(FAR const char *line, FAR struct ether_addr *addr,
}
#endif
#endif /* __INCLUDE_NETINET_ETHER_H */
#endif /* __INCLUDE_NETINET_ETHER_H */

View file

@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __INCLUDE_NETINET_I6P_H
#define __INCLUDE_NETINET_I6P_H
#ifndef __INCLUDE_NETINET_IP6_H
#define __INCLUDE_NETINET_IP6_H
/****************************************************************************
* Included Files
@ -51,4 +51,4 @@
* Public Function Prototypes
****************************************************************************/
#endif /* __INCLUDE_NETINET_I6P_H */
#endif /* __INCLUDE_NETINET_IP6_H */

View file

@ -310,7 +310,7 @@
#define _CAIOCVALID(c) (_IOC_TYPE(c)==_CAIOCBASE)
#define _CAIOC(nr) _IOC(_CAIOCBASE,nr)
/* NuttX USB CDC/ACM serial driver ioctl definitions ************************/
/* NuttX battery driver ioctl definitions ***********************************/
/* (see nuttx/power/battery.h) */
@ -368,7 +368,7 @@
/* Discrete Joystick (see nuttx/include/input/djoystick.h */
#define _JOYIOCVALID(c) (_IOC_SMASK(c)==_JOYBASE)
#define _JOYIOCVALID(c) (_IOC_TYPE(c)==_JOYBASE)
#define _JOYIOC(nr) _IOC(_JOYBASE,nr)
/* FIFOs and pipe driver ioctl definitions **********************************/

View file

@ -51,7 +51,6 @@
#include <nuttx/net/netconfig.h>
#include <nuttx/net/ip.h>
#include <nuttx/net/tcp.h>
/****************************************************************************
* Pre-processor Definitions

View file

@ -51,7 +51,6 @@
#include <nuttx/net/netconfig.h>
#include <nuttx/net/ip.h>
#include <nuttx/net/tcp.h>
/****************************************************************************
* Pre-processor Definitions

View file

@ -50,12 +50,8 @@
#include <stdint.h>
#include <stdbool.h>
#include <semaphore.h>
#include <netinet/in.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/ip.h>
#ifdef CONFIG_NET_IGMP

View file

@ -52,7 +52,6 @@
#include <stdint.h>
#include <stdbool.h>
#include <queue.h>
#include <arpa/inet.h>
#include <netinet/in.h>
@ -564,7 +563,7 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
* Name: net_is_addr_loopback
*
* Description:
* Is Ithe Pv6 address a the loopback address? See RFC 4291 (replaces
* Is the IPv6 address a the loopback address? See RFC 4291 (replaces
* 3513).
*
****************************************************************************/

View file

@ -1,6 +1,6 @@
/****************************************************************************
* include/nuttx/net/ipv6ext.h
* IPv4 Extension Header Definitions
* IPv6 Extension Header Definitions
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -107,9 +107,13 @@
*/
#define NEXT_HOPBYBOT_EH 0 /* 0 Hop-by-Hop Options Header */
/* 1 See IP_PROTO_ICMP in
* include/nuttx/net/ip.h. */
/* 2 See IP_PROTO_IGMP in
* include/nuttx/net/ip.h. */
/* 6 See IP_PROTO_TCP in
* include/nuttx/net/ip.h. */
/* 17 See IP_PROTO_TCP in
/* 17 See IP_PROTO_UDP in
* include/nuttx/net/ip.h. */
#define NEXT_ENCAP_EH 41 /* 41 Encapsulated IPv6 Header */
#define NEXT_ROUTING_EH 43 /* 43 Routing Header */

View file

@ -1376,7 +1376,7 @@ int net_dup2(int sockfd1, int sockfd2);
*
* Input Parameters:
* sockfd - Socket descriptor of the socket to operate on
* bug - Caller-provided location in which to return the fstat data
* buf - Caller-provided location in which to return the fstat data
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on

View file

@ -56,7 +56,7 @@
#include <stdint.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/arp.h>
#include <nuttx/net/ethernet.h>
#include <nuttx/net/ip.h>
/****************************************************************************

View file

@ -44,7 +44,6 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/net.h>
#include <nuttx/net/netdev.h>
@ -64,7 +63,7 @@
*
* Input Parameters:
* sockfd - Socket descriptor of the socket to operate on
* bug - Caller-provided location in which to return the fstat data
* buf - Caller-provided location in which to return the fstat data
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on

View file

@ -75,7 +75,7 @@
****************************************************************************/
FAR const struct sock_intf_s *
net_sockif(sa_family_t family, int type, int protocol)
net_sockif(sa_family_t family, int type, int protocol)
{
FAR const struct sock_intf_s *sockif = NULL;

View file

@ -124,9 +124,9 @@
/* Macros to convert timeout value */
#ifdef CONFIG_NET_SOCKOPTS
#define _SO_TIMEOUT(t) ((t) ? (t) * MSEC_PER_DSEC : UINT_MAX)
# define _SO_TIMEOUT(t) ((t) ? (t) * MSEC_PER_DSEC : UINT_MAX)
#else
#define _SO_TIMEOUT(t) (UINT_MAX)
# define _SO_TIMEOUT(t) (UINT_MAX)
#endif /* CONFIG_NET_SOCKOPTS */
/* Macro to set socket errors */
@ -212,23 +212,6 @@ void psock_release(FAR struct socket *psock);
void sockfd_release(int sockfd);
/****************************************************************************
* Name: sockfd_socket
*
* Description:
* Given a socket descriptor, return the underlying socket structure.
*
* Input Parameters:
* sockfd - The socket descriptor index to use.
*
* Returned Value:
* On success, a reference to the socket structure associated with the
* the socket descriptor is returned. NULL is returned on any failure.
*
****************************************************************************/
FAR struct socket *sockfd_socket(int sockfd);
/****************************************************************************
* Name: net_sockif
*
@ -247,7 +230,7 @@ FAR struct socket *sockfd_socket(int sockfd);
****************************************************************************/
FAR const struct sock_intf_s *
net_sockif(sa_family_t family, int type, int protocol);
net_sockif(sa_family_t family, int type, int protocol);
/****************************************************************************
* Name: net_timeo
@ -271,70 +254,5 @@ FAR const struct sock_intf_s *
int net_timeo(clock_t start_time, socktimeo_t timeo);
#endif
/****************************************************************************
* Name: psock_send
*
* Description:
* The send() call may be used only when the socket is in a connected state
* (so that the intended recipient is known). The only difference between
* send() and write() is the presence of flags. With zero flags parameter,
* send() is equivalent to write(). Also, send(sockfd,buf,len,flags) is
* equivalent to sendto(sockfd,buf,len,flags,NULL,0).
*
* Input Parameters:
* psock An instance of the internal socket structure.
* buf Data to send
* len Length of data to send
* flags Send flags
*
* Returned Value:
* On success, returns the number of characters sent. On error,
* -1 is returned, and errno is set appropriately:
*
* EAGAIN or EWOULDBLOCK
* The socket is marked non-blocking and the requested operation
* would block.
* EBADF
* An invalid descriptor was specified.
* ECONNRESET
* Connection reset by peer.
* EDESTADDRREQ
* The socket is not connection-mode, and no peer address is set.
* EFAULT
* An invalid user space address was specified for a parameter.
* EINTR
* A signal occurred before any data was transmitted.
* EINVAL
* Invalid argument passed.
* EISCONN
* The connection-mode socket was connected already but a recipient
* was specified. (Now either this error is returned, or the recipient
* specification is ignored.)
* EMSGSIZE
* The socket type requires that message be sent atomically, and the
* size of the message to be sent made this impossible.
* ENOBUFS
* The output queue for a network interface was full. This generally
* indicates that the interface has stopped sending, but may be
* caused by transient congestion.
* ENOMEM
* No memory available.
* ENOTCONN
* The socket is not connected, and no target has been given.
* ENOTSOCK
* The argument s is not a socket.
* EOPNOTSUPP
* Some bit in the flags argument is inappropriate for the socket
* type.
* EPIPE
* The local end has been shut down on a connection oriented socket.
* In this case the process will also receive a SIGPIPE unless
* MSG_NOSIGNAL is set.
*
****************************************************************************/
ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
int flags);
#endif /* CONFIG_NET */
#endif /* _NET_SOCKET_SOCKET_H */

View file

@ -40,14 +40,13 @@
#include <nuttx/config.h>
#include <unistd.h>
#include <semaphore.h>
#include <sched.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <time.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/semaphore.h>
#include <nuttx/mm/iob.h>
@ -66,8 +65,8 @@
****************************************************************************/
static sem_t g_netlock;
static pid_t g_holder = NO_HOLDER;
static unsigned int g_count = 0;
static pid_t g_holder = NO_HOLDER;
static unsigned int g_count = 0;
/****************************************************************************
* Private Functions

View file

@ -98,7 +98,7 @@ void net_lockinitialize(void);
int net_breaklock(FAR unsigned int *count);
/****************************************************************************
* Name: net_breaklock
* Name: net_restorelock
*
* Description:
* Restore the locked state