--- l2_ut_sa.h 2001/10/06 14:33:09 1.9
+++ l2_ut_sa.h 2001/10/10 15:58:27 1.10
@@ -1,7 +1,8 @@
/*
** SA - OSSP Socket Abstraction Library
-** Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
-** Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+** Copyright (c) 2001 Ralf S. Engelschall <rse@engelschall.com>
+** Copyright (c) 2001 The OSSP Project <http://www.ossp.org/>
+** Copyright (c) 2001 Cable & Wireless Deutschland <http://www.cw.com/de/>
**
** This file is part of OSSP SA, a socket abstraction library which
** can be found at http://www.ossp.org/pkg/sa/.
@@ -37,6 +38,14 @@
#include <sys/types.h>
#include <sys/socket.h>
+/* include optional Autoconf header */
+#include "l2_config.h"
+
+/* fallback for POSIX socklen_t */
+#if defined(HAVE_CONFIG_H) && !defined(HAVE_SOCKLEN_T)
+#define socklen_t int
+#endif
+
/* embedding support */
#ifdef SA_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
@@ -95,15 +104,43 @@
/* return codes */
typedef enum {
- SA_OK, /* everything ok */
- SA_ERR_ARG, /* invalid argument (wrong parameter) */
- SA_ERR_USE, /* invalid use (wrong context) */
- SA_ERR_MEM, /* out of memory */
- SA_ERR_SYS, /* system error (see errno) */
- SA_ERR_EOF, /* end of file/socket communication */
- SA_ERR_INT /* internal error */
+ SA_OK, /* Everything Ok */
+ SA_ERR_ARG, /* Invalid Argument */
+ SA_ERR_USE, /* Invalid Use Or Context */
+ SA_ERR_MEM, /* Not Enough Memory */
+ SA_ERR_MTC, /* Matching Failed */
+ SA_ERR_EOF, /* End Of Communication */
+ SA_ERR_TMT, /* Communication Timeout */
+ SA_ERR_SYS, /* Operating System Error */
+ SA_ERR_INT /* Internal Error */
} sa_rc_t;
+/* list of timeouts */
+typedef enum {
+ SA_TIMEOUT_ALL = -1,
+ SA_TIMEOUT_ACCEPT = 0,
+ SA_TIMEOUT_CONNECT = 1,
+ SA_TIMEOUT_READ = 2,
+ SA_TIMEOUT_WRITE = 3
+} sa_timeout_t;
+
+/* list of buffers */
+typedef enum {
+ SA_BUFFER_READ,
+ SA_BUFFER_WRITE
+} sa_buffer_t;
+
+/* list of system calls */
+typedef enum {
+ SA_SYSCALL_CONNECT,
+ SA_SYSCALL_ACCEPT,
+ SA_SYSCALL_SELECT,
+ SA_SYSCALL_READ,
+ SA_SYSCALL_WRITE,
+ SA_SYSCALL_RECVFROM,
+ SA_SYSCALL_SENDTO
+} sa_syscall_t;
+
/* address object operations */
sa_rc_t sa_addr_create (sa_addr_t **saa);
sa_rc_t sa_addr_destroy (sa_addr_t *saa);
@@ -113,6 +150,7 @@
sa_rc_t sa_addr_s2a (sa_addr_t *saa, const struct sockaddr *sabuf, socklen_t salen);
sa_rc_t sa_addr_a2u (sa_addr_t *saa, char **uri);
sa_rc_t sa_addr_a2s (sa_addr_t *saa, struct sockaddr **sabuf, socklen_t *salen);
+sa_rc_t sa_addr_match (sa_addr_t *saa1, sa_addr_t *saa2, int prefixlen);
/* socket object operations */
sa_rc_t sa_create (sa_t **sa);
@@ -120,8 +158,9 @@
/* socket parameter operations */
sa_rc_t sa_type (sa_t *sa, sa_type_t type);
-sa_rc_t sa_timeout (sa_t *sa, long sec, long usec);
-sa_rc_t sa_buffers (sa_t *sa, size_t rsize, size_t wsize);
+sa_rc_t sa_timeout (sa_t *sa, sa_timeout_t id, long sec, long usec);
+sa_rc_t sa_buffer (sa_t *sa, sa_buffer_t id, size_t size);
+sa_rc_t sa_syscall (sa_t *sa, sa_syscall_t id, void (*fptr)(), void *fctx);
/* socket connection operations */
sa_rc_t sa_bind (sa_t *sa, sa_addr_t *laddr);
@@ -144,5 +183,13 @@
sa_rc_t sa_recv (sa_t *sa, char *buf, size_t buflen, size_t *bufdone, sa_addr_t **raddr);
sa_rc_t sa_send (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone, sa_addr_t *raddr);
+/* error handling operations */
+char *sa_error (sa_rc_t rv);
+
+/* cleanup */
+#if defined(HAVE_CONFIG_H) && !defined(HAVE_SOCKLEN_T)
+#undef socklen_t
+#endif
+
#endif /* __SA_H__ */
|