include/socket.h

/* [<][>][^][v][top]
[bottom][index][help] */

FUNCTIONS

This source file includes following functions.

   1 #ifndef READ_SOCKET
   2 #define READ_SOCKET
   3 /***************************************
   4   $Revision: 1.13 $
   5 
   6   Socket module (sk)
   7 
   8   Status: NOT REVUED, NOT TESTED
   9 
  10   ******************/ /******************
  11   Copyright (c) 1999                              RIPE NCC
  12  
  13   All Rights Reserved
  14   
  15   Permission to use, copy, modify, and distribute this software and its
  16   documentation for any purpose and without fee is hereby granted,
  17   provided that the above copyright notice appear in all copies and that
  18   both that copyright notice and this permission notice appear in
  19   supporting documentation, and that the name of the author not be
  20   used in advertising or publicity pertaining to distribution of the
  21   software without specific, written prior permission.
  22   
  23   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  24   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
  25   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
  26   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  27   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  28   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  29   ***************************************/
  30 #include <sys/types.h>
  31 #include <sys/socket.h>
  32 #include <netinet/in.h>
  33 
  34 #include <stdlib.h>
  35 #include <errno.h>
  36 #include <netdb.h>
  37 
  38 #include <signal.h>
  39 #include <stdio.h>
  40 
  41 #include <iproutines.h>
  42 
  43 /* connection data -> helps keep track of all errors etc */
  44 typedef struct {
  45   int            sock;         /* socket descriptor # */
  46   struct timeval rd_timeout;   /* preset timeout values */
  47   struct timeval wr_timeout; 
  48   unsigned short rtc;                   /* RTC flags (reason-to-close) */
  49 
  50   pthread_t      watchdog;     /* thread id of the watchdog associated */
  51   pthread_t      killthis;     /* thread to be killed by watchdog */
  52   void * (*execthis)(void *);  /* function to be called if watchdog triggers */
  53   void *         execargs;     /* argument to be passed to that function */
  54   pthread_mutex_t watchmutex;
  55 
  56   unsigned char  lasterr;      /* timeout, interrupt, etc. */
  57   ip_addr_t rIP;              /* real IP */
  58   ip_addr_t eIP;              /* effective IP */
  59   char *ip;                    /* text of the eIP */
  60 } sk_conn_st;
  61 
  62 /* reasons to close: socket-wise .... */
  63 #define SK_DISCONNECT 0x0001
  64 #define SK_INTERRUPT  0x0002
  65 #define SK_TIMEOUT    0x0004
  66 
  67 /* ... and user-wise: */
  68 #define SK_NOTEXT     0x0100
  69 
  70 int SK_atoport(const char *service, const char *proto);
  71 void SK_close(int socket);
  72 int SK_getsock(int socket_type, u_short port, uint32_t bind_address);
  73 int SK_accept_connection(int listening_socket);
  74 int SK_read(int sockfd, char *buf, size_t count);
  75 int SK_write(int sockfd, const char *buf, size_t count);
  76 int SK_gets(int sockfd, char *str, size_t count);
  77 int SK_puts(int sockfd, const char *str);
  78 int SK_putc(int sockfd, char ch);
  79 int SK_getc(int sockfd);
  80 char *SK_getpeername(int sockfd);
  81 int SK_getpeerip(int sockfd, ip_addr_t *ip);
  82 int SK_cd_puts(sk_conn_st *condat, const char *str);
  83 int SK_cd_gets(sk_conn_st *condat, char *str, size_t count);
  84 int SK_cd_close(sk_conn_st *condat);
  85 int SK_cd_printf(sk_conn_st *condat, char *txt, ...);
  86 
  87 #endif /* READ_SOCKET */
  88 
  89 er_ret_t SK_watchstart(sk_conn_st *condat);
  90 er_ret_t SK_watchstop(sk_conn_st *condat);
  91 void SK_watchkill(sk_conn_st *condat, pthread_t killthis);
  92 void SK_watchexec( sk_conn_st *condat, void *(*function)(void *), void *args);
  93 void SK_watchclear(sk_conn_st *condat);

/* [<][>][^][v][top][bottom][index][help] */