Fix obsolete comment regarding FSM truncation.
[PostgreSQL.git] / src / include / libpq / libpq-be.h
blob886ce8feafc2474b7930b94b2a3684c0a86d53de
1 /*-------------------------------------------------------------------------
3 * libpq_be.h
4 * This file contains definitions for structures and externs used
5 * by the postmaster during client authentication.
7 * Note that this is backend-internal and is NOT exported to clients.
8 * Structs that need to be client-visible are in pqcomm.h.
11 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
12 * Portions Copyright (c) 1994, Regents of the University of California
14 * $PostgreSQL$
16 *-------------------------------------------------------------------------
18 #ifndef LIBPQ_BE_H
19 #define LIBPQ_BE_H
21 #ifdef HAVE_SYS_TIME_H
22 #include <sys/time.h>
23 #endif
24 #ifdef USE_SSL
25 #include <openssl/ssl.h>
26 #include <openssl/err.h>
27 #endif
28 #ifdef HAVE_NETINET_TCP_H
29 #include <netinet/tcp.h>
30 #endif
32 #ifdef ENABLE_GSS
33 #if defined(HAVE_GSSAPI_H)
34 #include <gssapi.h>
35 #else
36 #include <gssapi/gssapi.h>
37 #endif /* HAVE_GSSAPI_H */
39 * GSSAPI brings in headers that set a lot of things in the global namespace on win32,
40 * that doesn't match the msvc build. It gives a bunch of compiler warnings that we ignore,
41 * but also defines a symbol that simply does not exist. Undefine it again.
43 #ifdef WIN32_ONLY_COMPILER
44 #undef HAVE_GETADDRINFO
45 #endif
46 #endif /* ENABLE_GSS */
48 #ifdef ENABLE_SSPI
49 #define SECURITY_WIN32
50 #include <security.h>
51 #undef SECURITY_WIN32
53 #ifndef ENABLE_GSS
55 * Define a fake structure compatible with GSSAPI on Unix.
57 typedef struct
59 void *value;
60 int length;
61 } gss_buffer_desc;
62 #endif
63 #endif /* ENABLE_SSPI */
65 #include "libpq/hba.h"
66 #include "libpq/pqcomm.h"
67 #include "utils/timestamp.h"
70 typedef enum CAC_state
72 CAC_OK, CAC_STARTUP, CAC_SHUTDOWN, CAC_RECOVERY, CAC_TOOMANY,
73 CAC_WAITBACKUP
74 } CAC_state;
78 * GSSAPI specific state information
80 #if defined(ENABLE_GSS) | defined(ENABLE_SSPI)
81 typedef struct
83 gss_buffer_desc outbuf; /* GSSAPI output token buffer */
84 #ifdef ENABLE_GSS
85 gss_cred_id_t cred; /* GSSAPI connection cred's */
86 gss_ctx_id_t ctx; /* GSSAPI connection context */
87 gss_name_t name; /* GSSAPI client name */
88 #endif
89 } pg_gssinfo;
90 #endif
93 * This is used by the postmaster in its communication with frontends. It
94 * contains all state information needed during this communication before the
95 * backend is run. The Port structure is kept in malloc'd memory and is
96 * still available when a backend is running (see MyProcPort). The data
97 * it points to must also be malloc'd, or else palloc'd in TopMemoryContext,
98 * so that it survives into PostgresMain execution!
101 typedef struct Port
103 int sock; /* File descriptor */
104 ProtocolVersion proto; /* FE/BE protocol version */
105 SockAddr laddr; /* local addr (postmaster) */
106 SockAddr raddr; /* remote addr (client) */
107 char *remote_host; /* name (or ip addr) of remote host */
108 char *remote_port; /* text rep of remote port */
109 CAC_state canAcceptConnections; /* postmaster connection status */
112 * Information that needs to be saved from the startup packet and passed
113 * into backend execution. "char *" fields are NULL if not set.
114 * guc_options points to a List of alternating option names and values.
116 char *database_name;
117 char *user_name;
118 char *cmdline_options;
119 List *guc_options;
122 * Information that needs to be held during the authentication cycle.
124 HbaLine *hba;
125 char md5Salt[4]; /* Password salt */
128 * Information that really has no business at all being in struct Port,
129 * but since it gets used by elog.c in the same way as database_name and
130 * other members of this struct, we may as well keep it here.
132 TimestampTz SessionStartTime; /* backend start time */
135 * TCP keepalive settings.
137 * default values are 0 if AF_UNIX or not yet known; current values are 0
138 * if AF_UNIX or using the default. Also, -1 in a default value means we
139 * were unable to find out the default (getsockopt failed).
141 int default_keepalives_idle;
142 int default_keepalives_interval;
143 int default_keepalives_count;
144 int keepalives_idle;
145 int keepalives_interval;
146 int keepalives_count;
148 #if defined(ENABLE_GSS) || defined(ENABLE_SSPI)
151 * If GSSAPI is supported, store GSSAPI information. Oterwise, store a
152 * NULL pointer to make sure offsets in the struct remain the same.
154 pg_gssinfo *gss;
155 #else
156 void *gss;
157 #endif
160 * SSL structures (keep these last so that USE_SSL doesn't affect
161 * locations of other fields)
163 #ifdef USE_SSL
164 SSL *ssl;
165 X509 *peer;
166 char peer_dn[128 + 1];
167 char peer_cn[SM_USER + 1];
168 unsigned long count;
169 #endif
170 } Port;
173 extern ProtocolVersion FrontendProtocol;
175 /* TCP keepalives configuration. These are no-ops on an AF_UNIX socket. */
177 extern int pq_getkeepalivesidle(Port *port);
178 extern int pq_getkeepalivesinterval(Port *port);
179 extern int pq_getkeepalivescount(Port *port);
181 extern int pq_setkeepalivesidle(int idle, Port *port);
182 extern int pq_setkeepalivesinterval(int interval, Port *port);
183 extern int pq_setkeepalivescount(int count, Port *port);
185 #endif /* LIBPQ_BE_H */