home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / xinetd / xinetd.2.0.6 / connection.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-22  |  1.7 KB  |  73 lines

  1. /*
  2.  * (c) Copyright 1992 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef CONNECTION_H
  8. #define CONNECTION_H
  9.  
  10. /*
  11.  * $Id: connection.h,v 5.1 1992/10/31 23:59:07 panos Exp $
  12.  */
  13.  
  14. #include <sys/types.h>
  15. #include <netinet/in.h>
  16.  
  17. #include "mask.h"
  18. #include "service.h"
  19.  
  20. #define MAX_ALTERNATIVES                3
  21.  
  22. typedef enum { CONN_CLOSED = 0, CONN_OPEN } conn_state_e ;
  23.  
  24. #define COF_HAVE_ADDRESS                1
  25. #define COF_SHUTDOWN                        2
  26. #define COF_CLEANUP                        3
  27. #define COF_NEW_DESCRIPTOR                4
  28.  
  29. struct connection
  30. {
  31.     conn_state_e state ;
  32.     struct service *sp ;
  33.     int descriptor ;
  34.     mask_t flags ;
  35.     struct sockaddr_in remote_address ;
  36.     unsigned alternative_count ;
  37.     unsigned next_alternative ;
  38.     struct service *alternatives[ MAX_ALTERNATIVES ] ;
  39. } ;
  40.  
  41. typedef struct connection connection_s ;
  42.  
  43. #define COP( p )                            ((connection_s *)(p))
  44.  
  45. #define conn_set_flag( cp, flag )    M_SET( (cp)->flags, flag )
  46.  
  47. #define conn_shutdown( cp )            conn_set_flag( cp, COF_SHUTDOWN )
  48. #define conn_cleanup( cp )                conn_set_flag( cp, COF_CLEANUP )
  49.  
  50. #define conn_fill( cp, sinp )                                                                \
  51.                             {                                                                        \
  52.                                 conn_set_flag( cp, COF_HAVE_ADDRESS ) ;                \
  53.                                 (cp)->remote_address = *(sinp) ;                            \
  54.                             }
  55.  
  56. #define conn_descriptor( cp )            (cp)->descriptor
  57. #define conn_address( cp )                                                                    \
  58.                                     (                                                                \
  59.                                         M_IS_SET( (cp)->flags, COF_HAVE_ADDRESS )        \
  60.                                                     ? &(cp)->remote_address                 \
  61.                                                     : SOCKADDRIN_NULL                            \
  62.                                     )
  63.  
  64. status_e conn_init() ;
  65. connection_s *conn_new() ;
  66. void conn_close() ;
  67. void conn_free() ;
  68. status_e conn_add_alternative() ;
  69. status_e conn_start_alternative() ;
  70. void conn_dump() ;
  71.  
  72. #endif    /* CONNECTION_H */
  73.