Willy Tarreau | 56e9c5e | 2012-07-06 09:47:57 +0200 | [diff] [blame] | 1 | /* |
| 2 | * include/types/connection.h |
| 3 | * This file describes the connection struct and associated constants. |
| 4 | * |
| 5 | * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef _TYPES_CONNECTION_H |
| 23 | #define _TYPES_CONNECTION_H |
| 24 | |
| 25 | #include <stdlib.h> |
| 26 | #include <sys/socket.h> |
| 27 | |
| 28 | #include <common/config.h> |
| 29 | |
| 30 | /* referenced below */ |
| 31 | struct sock_ops; |
| 32 | struct protocol; |
| 33 | |
Willy Tarreau | 900bc93 | 2012-07-06 09:52:14 +0200 | [diff] [blame] | 34 | /* flags for use in connection->flags */ |
| 35 | enum { |
| 36 | CO_FL_NONE = 0x00000000, |
| 37 | CO_FL_ERROR = 0x00000001, /* a fatal error was reported */ |
Willy Tarreau | c76ae33 | 2012-07-12 15:32:13 +0200 | [diff] [blame] | 38 | CO_FL_CONNECTED = 0x00000002, /* the connection is now established */ |
| 39 | CO_FL_WAIT_L4_CONN = 0x00000004, /* waiting for L4 to be connected */ |
| 40 | CO_FL_WAIT_L6_CONN = 0x00000008, /* waiting for L6 to be connected (eg: SSL) */ |
| 41 | |
| 42 | CO_FL_NOTIFY_SI = 0x00000010, /* notify stream interface about changes */ |
| 43 | |
Willy Tarreau | 2c6be84 | 2012-07-06 17:12:34 +0200 | [diff] [blame] | 44 | /* flags below are used for connection handshakes */ |
Willy Tarreau | c76ae33 | 2012-07-12 15:32:13 +0200 | [diff] [blame] | 45 | CO_FL_SI_SEND_PROXY = 0x00000020, /* send a valid PROXY protocol header */ |
| 46 | |
| 47 | /* below we have all handshake flags grouped into one */ |
| 48 | CO_FL_HANDSHAKE = CO_FL_SI_SEND_PROXY, |
Willy Tarreau | 900bc93 | 2012-07-06 09:52:14 +0200 | [diff] [blame] | 49 | }; |
| 50 | |
Willy Tarreau | 56e9c5e | 2012-07-06 09:47:57 +0200 | [diff] [blame] | 51 | /* This structure describes a connection with its methods and data. |
| 52 | * A connection may be performed to proxy or server via a local or remote |
| 53 | * socket, and can also be made to an internal applet. It can support |
| 54 | * several data schemes (applet, raw, ssl, ...). It can support several |
| 55 | * connection control schemes, generally a protocol for socket-oriented |
| 56 | * connections, but other methods for applets. |
| 57 | */ |
| 58 | struct connection { |
| 59 | const struct sock_ops *data; /* operations at the data layer */ |
| 60 | const struct protocol *ctrl; /* operations at the control layer, generally a protocol */ |
| 61 | union { /* definitions which depend on connection type */ |
| 62 | struct { /*** information used by socket-based connections ***/ |
| 63 | int fd; /* file descriptor for a stream driver when known */ |
| 64 | } sock; |
| 65 | } t; |
Willy Tarreau | 900bc93 | 2012-07-06 09:52:14 +0200 | [diff] [blame] | 66 | unsigned int flags; /* CO_F_* */ |
Willy Tarreau | 56e9c5e | 2012-07-06 09:47:57 +0200 | [diff] [blame] | 67 | int data_st; /* data layer state, initialized to zero */ |
| 68 | void *data_ctx; /* general purpose pointer, initialized to NULL */ |
| 69 | struct sockaddr *peeraddr; /* pointer to peer's network address, or NULL if unset */ |
| 70 | socklen_t peerlen; /* peer's address length, or 0 if unset */ |
| 71 | }; |
| 72 | |
| 73 | #endif /* _TYPES_CONNECTION_H */ |
| 74 | |
| 75 | /* |
| 76 | * Local variables: |
| 77 | * c-indent-level: 8 |
| 78 | * c-basic-offset: 8 |
| 79 | * End: |
| 80 | */ |