blob: 45b820cb395dcc6d69e78148a241d82805353087 [file] [log] [blame]
Willy Tarreaub1ec8c42015-04-03 13:53:24 +02001/*
Willy Tarreau48d25b32020-06-04 18:58:52 +02002 * include/haproxy/session-t.h
Willy Tarreaub1ec8c42015-04-03 13:53:24 +02003 * This file defines everything related to sessions.
4 *
Willy Tarreau48d25b32020-06-04 18:58:52 +02005 * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
Willy Tarreaub1ec8c42015-04-03 13:53:24 +02006 *
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
Willy Tarreau48d25b32020-06-04 18:58:52 +020022#ifndef _HAPROXY_SESSION_T_H
23#define _HAPROXY_SESSION_T_H
Willy Tarreaub1ec8c42015-04-03 13:53:24 +020024
25
26#include <sys/time.h>
27#include <unistd.h>
28#include <netinet/in.h>
29#include <arpa/inet.h>
30
Willy Tarreau4c7e4b72020-05-27 12:58:42 +020031#include <haproxy/api-t.h>
Willy Tarreau8efbdfb2020-06-04 11:29:21 +020032#include <haproxy/obj_type-t.h>
Willy Tarreau872f2ea2020-06-04 18:46:44 +020033#include <haproxy/stick_table-t.h>
Willy Tarreaucea0e1b2020-06-04 17:25:40 +020034#include <haproxy/task-t.h>
Willy Tarreau48d25b32020-06-04 18:58:52 +020035#include <haproxy/vars-t.h>
Olivier Houchard00cf70f2018-11-30 17:24:55 +010036
Olivier Houchard00cf70f2018-11-30 17:24:55 +010037
Olivier Houchard250031e2019-05-29 15:01:50 +020038/* session flags */
39enum {
40 SESS_FL_NONE = 0x00000000, /* nothing */
41 SESS_FL_PREFER_LAST = 0x00000001, /* NTML authent, we should reuse last conn */
42};
43
Willy Tarreau48d25b32020-06-04 18:58:52 +020044/* max number of idle server connections kept attached to a session */
45#define MAX_SRV_LIST 5
46
Willy Tarreaub1ec8c42015-04-03 13:53:24 +020047struct session {
Willy Tarreaue36cbcb2015-04-03 15:40:56 +020048 struct proxy *fe; /* the proxy this session depends on for the client side */
Willy Tarreaufb0afa72015-04-03 14:46:27 +020049 struct listener *listener; /* the listener by which the request arrived */
Willy Tarreau40606ab2015-04-03 18:08:29 +020050 enum obj_type *origin; /* the connection / applet which initiated this session */
Willy Tarreau7ea671b2015-04-04 14:46:56 +020051 struct timeval accept_date; /* date of the session's accept() in user date */
52 struct timeval tv_accept; /* date of the session's accept() in internal date (monotonic) */
Willy Tarreaub2bf8332015-04-04 15:58:58 +020053 struct stkctr stkctr[MAX_SESS_STKCTR]; /* stick counters for tcp-connection */
Willy Tarreauebcd4842015-06-19 11:59:02 +020054 struct vars vars; /* list of variables for the session scope. */
Willy Tarreau0b74eae2017-08-28 19:02:51 +020055 struct task *task; /* handshake timeout processing */
Willy Tarreau590a0512018-09-05 11:56:48 +020056 long t_handshake; /* handshake duration, -1 = not completed */
Christopher Fauletd5173962020-09-30 10:28:02 +020057 long t_idle; /* idle duration, -1 if never occurs */
Olivier Houcharda2dbeb22018-12-28 18:50:57 +010058 int idle_conns; /* Number of connections we're currently responsible for that we are not using */
Olivier Houchard250031e2019-05-29 15:01:50 +020059 unsigned int flags; /* session flags, SESS_FL_* */
Christopher Fauletd5173962020-09-30 10:28:02 +020060 struct list srv_list; /* List of servers and the connections the session is currently responsible for */
Willy Tarreaub1ec8c42015-04-03 13:53:24 +020061};
62
Willy Tarreau48d25b32020-06-04 18:58:52 +020063struct sess_srv_list {
64 void *target;
65 struct list conn_list; /* Head of the connections list */
66 struct list srv_list; /* Next element of the server list */
67};
68
69#endif /* _HAPROXY_SESSION_T_H */
Willy Tarreaub1ec8c42015-04-03 13:53:24 +020070
71/*
72 * Local variables:
73 * c-indent-level: 8
74 * c-basic-offset: 8
75 * End:
76 */