home *** CD-ROM | disk | FTP | other *** search
- /*
- * (c) Copyright 1992 by Panagiotis Tsirigotis
- * All rights reserved. The file named COPYRIGHT specifies the terms
- * and conditions for redistribution.
- */
-
- #ifndef CONNECTION_H
- #define CONNECTION_H
-
- /*
- * $Id: connection.h,v 5.1 1992/10/31 23:59:07 panos Exp $
- */
-
- #include <sys/types.h>
- #include <netinet/in.h>
-
- #include "mask.h"
- #include "service.h"
-
- #define MAX_ALTERNATIVES 3
-
- typedef enum { CONN_CLOSED = 0, CONN_OPEN } conn_state_e ;
-
- #define COF_HAVE_ADDRESS 1
- #define COF_SHUTDOWN 2
- #define COF_CLEANUP 3
- #define COF_NEW_DESCRIPTOR 4
-
- struct connection
- {
- conn_state_e state ;
- struct service *sp ;
- int descriptor ;
- mask_t flags ;
- struct sockaddr_in remote_address ;
- unsigned alternative_count ;
- unsigned next_alternative ;
- struct service *alternatives[ MAX_ALTERNATIVES ] ;
- } ;
-
- typedef struct connection connection_s ;
-
- #define COP( p ) ((connection_s *)(p))
-
- #define conn_set_flag( cp, flag ) M_SET( (cp)->flags, flag )
-
- #define conn_shutdown( cp ) conn_set_flag( cp, COF_SHUTDOWN )
- #define conn_cleanup( cp ) conn_set_flag( cp, COF_CLEANUP )
-
- #define conn_fill( cp, sinp ) \
- { \
- conn_set_flag( cp, COF_HAVE_ADDRESS ) ; \
- (cp)->remote_address = *(sinp) ; \
- }
-
- #define conn_descriptor( cp ) (cp)->descriptor
- #define conn_address( cp ) \
- ( \
- M_IS_SET( (cp)->flags, COF_HAVE_ADDRESS ) \
- ? &(cp)->remote_address \
- : SOCKADDRIN_NULL \
- )
-
- status_e conn_init() ;
- connection_s *conn_new() ;
- void conn_close() ;
- void conn_free() ;
- status_e conn_add_alternative() ;
- status_e conn_start_alternative() ;
- void conn_dump() ;
-
- #endif /* CONNECTION_H */
-