Implemented several options in set/getsockopts

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@334 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-09-08 19:50:59 +00:00
parent cdfb48dac6
commit a3d199f7ac
19 changed files with 692 additions and 117 deletions
+17 -4
View File
@@ -45,6 +45,7 @@
#include <semaphore.h>
#include <nuttx/os_external.h>
#include <net/uip/uip.h>
#include <net/uip/psock.h>
@@ -71,18 +72,30 @@
typedef uint16 sockopt_t;
/* This defines the storage size of a timeout value. This effects only
* range of supported timeout values. With an LSB in seciseconds, the
* 16-bit maximum of 65535 corresponds to 1 hr 49 min 13.5 sec at decisecond
* resolution.
*/
typedef uint16 socktimeo_t;
/* This is the internal representation of a socket reference by a file
* descriptor.
*/
struct socket
{
int s_crefs; /* Reference count on the socket */
uint8 s_type; /* Protocol type: Only SOCK_STREAM or SOCK_DGRAM */
int s_crefs; /* Reference count on the socket */
uint8 s_type; /* Protocol type: Only SOCK_STREAM or SOCK_DGRAM */
#ifdef CONFIG_NET_SOCKOPTS
sockopt_t s_options; /* Selected socket options */
sockopt_t s_options; /* Selected socket options */
#ifndef CONFIG_DISABLE_CLOCK
socktimeo_t s_rcvtimeo; /* Receive timeout value (in deciseconds) */
socktimeo_t s_sndtimeo; /* Send timeout value (in deciseconds) */
#endif
void *s_conn; /* Connection: struct uip_conn * or uip_udp_conn * */
#endif
void *s_conn; /* Connection: struct uip_conn or uip_udp_conn */
};
/* This defines a list of sockets indexed by the socket descriptor */
+66 -15
View File
@@ -1,4 +1,4 @@
/************************************************************
/****************************************************************************
* os_external.h
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
@@ -31,31 +31,82 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************/
****************************************************************************/
#ifndef __OS_EXTERNAL_H
#define __OS_EXTERNAL_H
/************************************************************
/****************************************************************************
* Included Files
************************************************************/
****************************************************************************/
#include <nuttx/config.h>
#include <pthread.h>
#include <sched.h>
#include <nuttx/compiler.h>
/************************************************************
/****************************************************************************
* Definitions
************************************************************/
****************************************************************************/
/************************************************************
* Global Function Prototypes
************************************************************/
/* Timing constants */
/************************************************************
#define NSEC_PER_SEC 1000000000
#define USEC_PER_SEC 1000000
#define MSEC_PER_SEC 1000
#define DSEC_PER_SEC 10
#define NSEC_PER_DSEC 100000000
#define USEC_PER_DSEC 100000
#define MSEC_PER_DSEC 100
#define NSEC_PER_MSEC 1000000
#define USEC_PER_MSEC 1000
#define NSEC_PER_USEC 1000
/* The interrupt interval of the system timer is given by MSEC_PER_TICK.
* This is the expected number of milliseconds between calls from the
* processor-specific logic to sched_process_timer(). The default value
* of MSEC_PER_TICK is 10 milliseconds (100KHz). However, this default
* setting can be overridden by defining the interval in milliseconds as
* CONFIG_MSEC_PER_TICK in the board configuration file.
*
* The following calculations are only accurate when (1) there is no
* truncation involved and (2) the underlying system timer is an even
* multiple of milliseconds. If (2) is not true, you will probably want
* to redefine all of the following.
*/
#ifdef CONFIG_MSEC_PER_TICK
# define MSEC_PER_TICK (CONFIG_MSEC_PER_TICK)
#else
# define MSEC_PER_TICK (10)
#endif
#define TICK_PER_SEC (MSEC_PER_SEC / MSEC_PER_TICK) /* Truncates! */
#define NSEC_PER_TICK (MSEC_PER_TICK * NSEC_PER_MSEC) /* Exact */
#define USEC_PER_TICK (MSEC_PER_TICK * USEC_PER_MSEC) /* Exact */
#define NSEC2TICK(nsec) (((nsec)+(NSEC_PER_TICK/2))/NSEC_PER_TICK) /* Rounds */
#define USEC2TICK(usec) (((usec)+(USEC_PER_TICK/2))/USEC_PER_TICK) /* Rounds */
#define MSEC2TICK(msec) (((msec)+(MSEC_PER_TICK/2))/MSEC_PER_TICK) /* Rounds */
#define DSEC2TICK(dsec) MSEC2TICK((dsec)*DSEC_PER_MSEC)
#define SEC2TICK(sec) MSEC2TICK((sec)*SEC_PER_MSEC)
/****************************************************************************
* Global Data
****************************************************************************/
/* Access to raw system clock ***********************************************/
#ifndef CONFIG_DISABLE_CLOCK
extern volatile uint32 g_system_timer;
#endif
/****************************************************************************
* Global Function Prototypes
************************************************************/
****************************************************************************/
/****************************************************************************
* Global Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
@@ -69,16 +120,16 @@ extern "C" {
EXTERN void weak_function user_initialize(void);
EXTERN int user_start(int argc, char *argv[]);
/* Functions contained in os_task.c *************************/
/* Functions contained in os_task.c *****************************************/
EXTERN void os_start(void); /* OS entry point called by boot logic */
/* Functions contained in mm_initialize.c *******************/
/* Functions contained in mm_initialize.c ***********************************/
EXTERN void mm_initialize(FAR void *heap_start, size_t heap_size);
EXTERN void mm_addregion(FAR void *heapstart, size_t heapsize);
/* Functions contained in mm_sem.c **************************/
/* Functions contained in mm_sem.c ******************************************/
EXTERN int mm_trysemaphore(void);
EXTERN void mm_givesemaphore(void);
+10 -9
View File
@@ -118,26 +118,27 @@
/* Socket options */
#define SO_DEBUG 0 /* Enables recording of debugging information (get/set).
* arg: integer contain boolean value */
* arg: pointer to integer containing a boolean value */
#define SO_ACCEPTCONN 1 /* Reports whether socket listening is enabled (get only).
* arg: returns integer contain boolean value */
* arg: pointer to integer containing a boolean value */
#define SO_BROADCAST 2 /* Permits sending of broadcast messages (get/set).
* arg: integer contain boolean value */
* arg: pointer to integer containing a boolean value */
#define SO_REUSEADDR 3 /* Allow reuse of local addresses (get/set)
* arg: integer contain boolean value */
* arg: pointer to integer containing a boolean value */
#define SO_KEEPALIVE 4 /* Keeps connections active by enabling the periodic transmission
* of messages (get/set). arg: int */
* of messages (get/set).
* arg: pointer to integer containing a boolean value */
#define SO_LINGER 5 /* Lingers on a close() if data is present (get/set)
* arg: struct linger */
#define SO_OOBINLINE 6 /* Leaves received out-of-band data (data marked urgent) inline
* (get/set) arg: integer contain boolean value */
* (get/set) arg: pointer to integer containing a boolean value */
#define SO_SNDBUF 7 /* Sets send buffer size. arg: integer value (get/set). */
#define SO_RCVBUF 8 /* Sets receive buffer size. arg: integer value (get/set). */
#define SO_ERROR 9 /* Reports and clears error statust (get only). arg: returns
#define SO_ERROR 9 /* Reports and clears error status (get only). arg: returns
* an integer value
#define SO_TYPE 10 /* Reports the socket type (get only). return: int */
#define SO_DONTROUTE 11 /* equests that outgoing messages bypass standard routing (get/set)
* arg: integer contain boolean value */
#define SO_DONTROUTE 11 /* Requests that outgoing messages bypass standard routing (get/set)
* arg: pointer to integer containing a boolean value */
#define SO_RCVLOWAT 12 /* Sets the minimum number of bytes to process for socket input
* (get/set). arg: integer value */
#define SO_RCVTIMEO 13 /* Sets the timeout value that specifies the maximum amount of time