supla-device
Loading...
Searching...
No Matches
web_server.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*/
18
19#ifndef SRC_SUPLA_NETWORK_WEB_SERVER_H_
20#define SRC_SUPLA_NETWORK_WEB_SERVER_H_
21
22#include <supla/network/html_generator.h>
23#include <supla/network/html_element.h>
24#include <supla/device/security_logger.h>
25#include <stdint.h>
26
28
29#define HTML_KEY_LENGTH 16
30#define HTML_VAL_LENGTH 4000
31
32namespace Supla {
33
34extern const unsigned char favico[1150];
35
36class WebServer {
37 public:
38 static WebServer *Instance();
39 explicit WebServer(Supla::HtmlGenerator *);
40 virtual ~WebServer();
41 virtual void start() = 0;
42 virtual void stop() = 0;
43 void setSuplaDeviceClass(SuplaDeviceClass *);
44 void notifyClientConnected(bool isPost = false);
45 virtual void parsePost(const char *postContent,
46 int size,
47 bool lastChunk = true);
48 virtual void resetParser();
49 void setBetaProcessing();
50
51 virtual bool verifyCertificatesFormat();
52
53 Supla::HtmlGenerator *htmlGenerator = nullptr;
54
55 protected:
56 void addSecurityLog(Supla::SecurityLogSource source, const char *log) const;
57 void addSecurityLog(uint32_t source, const char *log) const;
66 bool isSectionAllowed(Supla::HtmlSection section) const;
67
68 static WebServer *webServerInstance;
69 bool destroyGenerator = false;
70 SuplaDeviceClass *sdc = nullptr;
71 bool keyFound = false;
72 int partialSize = 0;
73 char key[HTML_KEY_LENGTH] = {};
74 char *value = nullptr;
75 bool betaProcessing = false;
76};
77
78}; // namespace Supla
79
80#endif // SRC_SUPLA_NETWORK_WEB_SERVER_H_
Definition SuplaDevice.h:153
Definition html_generator.h:35
bool isSectionAllowed(Supla::HtmlSection section) const
Check if section is allowed in current POST request.
Definition web_server.cpp:269