dup() and dup2() support for socket descriptors

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1884 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2009-06-15 18:58:22 +00:00
parent 613d405fd4
commit fdf76b48bc
23 changed files with 948 additions and 126 deletions
+1
View File
@@ -134,6 +134,7 @@ struct uip_conn
* connection */
uint16 initialmss; /* Initial maximum segment size for the
* connection */
uint8 crefs; /* Reference counts on this instance */
uint8 sa; /* Retransmission time-out calculation state
* variable */
uint8 sv; /* Retransmission time-out calculation state
+1
View File
@@ -77,6 +77,7 @@ struct uip_udp_conn
uint16 lport; /* The local port number in network byte order */
uint16 rport; /* The remote port number in network byte order */
uint8 ttl; /* Default time-to-live */
uint8 crefs; /* Reference counts on this instance */
/* Defines the list of UDP callbacks */
+24
View File
@@ -342,6 +342,30 @@ EXTERN int files_addreflist(FAR struct filelist *list);
EXTERN int files_releaselist(FAR struct filelist *list);
EXTERN int files_dup(FAR struct file *filep1, FAR struct file *filep2);
/* fs_filedup.c **************************************************************/
/* This alternative naming is used when dup could operate on both file and
* socket descritors to avoid drawing unused socket support into the link.
*/
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
EXTERN int file_dup(int fd);
#else
# defile file_dup(fd) dup(fd)
#endif
/* fs_filedup2.c *************************************************************/
/* This alternative naming is used when dup could operate on both file and
* socket descritors to avoid drawing unused socket support into the link.
*/
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
EXTERN int file_dup2(int fd1, int fd2);
#else
# defile file_dup2(fd1, fd2) dup2(fd1, fd2)
#endif
/* fs_openblockdriver.c ******************************************************/
EXTERN int open_blockdriver(FAR const char *pathname, int mountflags,
+13 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* nuttx/net.h
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -138,14 +138,14 @@ EXTERN FAR struct socketlist *net_alloclist(void);
EXTERN int net_addreflist(FAR struct socketlist *list);
EXTERN int net_releaselist(FAR struct socketlist *list);
/* net-close.c ***************************************************************/
/* net_close.c ***************************************************************/
/* The standard close() operation redirects operations on socket descriptors
* to this function.
*/
EXTERN int net_close(int sockfd);
/* net-ioctl.c ***************************************************************/
/* net_ioctl.c ***************************************************************/
/* The standard ioctl() operation redirects operations on socket descriptors
* to this function.
*/
@@ -153,7 +153,7 @@ EXTERN int net_close(int sockfd);
struct ifreq; /* Forward reference -- see net/ioctls.h */
EXTERN int netdev_ioctl(int sockfd, int cmd, struct ifreq *req);
/* net-poll.c ****************************************************************/
/* net_poll.c ****************************************************************/
/* The standard poll() operation redirects operations on socket descriptors
* to this function.
*/
@@ -163,6 +163,14 @@ struct pollfd; /* Forward reference -- see poll.h */
EXTERN int net_poll(int sockfd, struct pollfd *fds, boolean setup);
#endif
/* net_dup.c *****************************************************************/
/* The standard dup() and dup2() operations redirect operations on socket
* descriptors to these function.
*/
EXTERN int net_dup(int sockfd);
EXTERN int net_dup2(int sockfd1, int sockfd2);
/* netdev-register.c *********************************************************/
/* This function is called by network interface device drivers to inform the
* socket layer of their existence. This registration is necesary to support
@@ -172,7 +180,7 @@ EXTERN int net_poll(int sockfd, struct pollfd *fds, boolean setup);
EXTERN int netdev_register(FAR struct uip_driver_s *dev);
/* net-foreach.c ************************************************************/
/* net_foreach.c ************************************************************/
/* Enumerates all registered network devices */
EXTERN int netdev_foreach(netdev_callback_t callback, void *arg);