GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
connection_info.c
Go to the documentation of this file.
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
25#include "internal.h"
26
27
43enum MHD_Bool
45 enum MHD_ConnectionInformationType info_type,
46 union MHD_ConnectionInformation *return_value,
47 size_t return_value_size)
48{
49#define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \
50 return MHD_NO
51
52 switch (info_type)
53 {
54#ifdef HTTPS_SUPPORT
55 case MHD_CONNECTION_INFORMATION_CIPHER_ALGO:
56 CHECK_SIZE (int);
57 if (NULL == connection->tls_cs)
58 return MHD_NO;
59 // return_value->cipher_algorithm
60 // = gnutls_cipher_get (connection->tls_session);
61 return MHD_NO; // FIXME: to be implemented
62 case MHD_CONNECTION_INFORMATION_PROTOCOL:
63 CHECK_SIZE (int);
64 if (NULL == connection->tls_cs)
65 return MHD_NO;
66 // return_value->protocol
67 // = gnutls_protocol_get_version (connection->tls_session);
68 return MHD_NO; // FIXME: to be implemented
69 case MHD_CONNECTION_INFORMATION_GNUTLS_SESSION:
70 CHECK_SIZE (void *);
71 if (NULL == connection->tls_cs)
72 return MHD_NO;
73 // return_value->tls_session = connection->tls_session;
74 return MHD_NO; // FIXME: to be implemented
75#endif /* HTTPS_SUPPORT */
76 case MHD_CONNECTION_INFORMATION_CLIENT_ADDRESS:
77 CHECK_SIZE (struct sockaddr *);
78 return_value->client_addr
79 = (const struct sockaddr *) &connection->addr;
80 return MHD_YES;
81 case MHD_CONNECTION_INFORMATION_DAEMON:
82 CHECK_SIZE (struct MHD_Daemon *);
83 return_value->daemon = connection->daemon;
84 return MHD_YES;
85 case MHD_CONNECTION_INFORMATION_CONNECTION_FD:
87 return_value->connect_fd = connection->socket_fd;
88 return MHD_YES;
89 case MHD_CONNECTION_INFORMATION_SOCKET_CONTEXT:
90 CHECK_SIZE (void **);
91 return_value->socket_context = &connection->socket_context;
92 return MHD_YES;
93 case MHD_CONNECTION_INFORMATION_CONNECTION_SUSPENDED:
94 CHECK_SIZE (enum MHD_Bool);
95 return_value->suspended
96 = connection->suspended ? MHD_YES : MHD_NO;
97 return MHD_YES;
98 case MHD_CONNECTION_INFORMATION_CONNECTION_TIMEOUT:
99 CHECK_SIZE (unsigned int);
100 return_value->connection_timeout
101 = (unsigned int) connection->connection_timeout;
102 return MHD_YES;
103 default:
104 return MHD_NO;
105 }
106
107#undef CHECK_SIZE
108}
109
110
111/* end of connection_info.c */
#define CHECK_SIZE(type)
enum MHD_Bool MHD_connection_get_information_sz(struct MHD_Connection *connection, enum MHD_ConnectionInformationType info_type, union MHD_ConnectionInformation *return_value, size_t return_value_size)
#define NULL
MHD internal shared structures.
int MHD_socket
Definition microhttpd.h:207
@ MHD_YES
Definition microhttpd.h:167
@ MHD_NO
Definition microhttpd.h:162
MHD_socket socket_fd
Definition internal.h:752
void * socket_context
Definition internal.h:694
time_t connection_timeout
Definition internal.h:745
struct sockaddr_storage addr
Definition internal.h:728
struct MHD_Daemon * daemon
Definition internal.h:675