source: ogServer-Git/src/rest.h @ 42c2253

Last change on this file since 42c2253 was 0a09c5b, checked in by OpenGnSys Support Team <soporte-og@…>, 4 years ago

#1022 increase maximum API REST request size

Software inventory generates a request larger that 64 Kbytes.
Rise the maximum API REST request size to 128 Kbytes.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#ifndef OG_REST_H
2#define OG_REST_H
3
4#include <ev.h>
5
6extern struct ev_loop *og_loop;
7
8enum og_client_state {
9        OG_CLIENT_RECEIVING_HEADER      = 0,
10        OG_CLIENT_RECEIVING_PAYLOAD,
11        OG_CLIENT_PROCESSING_REQUEST,
12};
13
14enum og_client_status {
15        OG_CLIENT_STATUS_OGLIVE,
16        OG_CLIENT_STATUS_BUSY,
17        OG_CLIENT_STATUS_VIRTUAL,
18};
19
20enum og_cmd_type {
21        OG_CMD_UNSPEC,
22        OG_CMD_WOL,
23        OG_CMD_PROBE,
24        OG_CMD_SHELL_RUN,
25        OG_CMD_SESSION,
26        OG_CMD_POWEROFF,
27        OG_CMD_REFRESH,
28        OG_CMD_REBOOT,
29        OG_CMD_STOP,
30        OG_CMD_HARDWARE,
31        OG_CMD_SOFTWARE,
32        OG_CMD_IMAGE_CREATE,
33        OG_CMD_IMAGE_RESTORE,
34        OG_CMD_SETUP,
35        OG_CMD_RUN_SCHEDULE,
36        OG_CMD_IMAGES,
37        OG_CMD_MAX
38};
39
40#define OG_MSG_REQUEST_MAXLEN   131072
41
42struct og_client {
43        struct list_head        list;
44        struct ev_io            io;
45        struct ev_timer         timer;
46        struct sockaddr_in      addr;
47        enum og_client_state    state;
48        char                    buf[OG_MSG_REQUEST_MAXLEN];
49        unsigned int            buf_len;
50        unsigned int            msg_len;
51        int                     keepalive_idx;
52        bool                    rest;
53        bool                    agent;
54        int                     content_length;
55        char                    auth_token[64];
56        enum og_client_status   status;
57        enum og_cmd_type        last_cmd;
58        unsigned int            last_cmd_id;
59        bool                    autorun;
60};
61
62void og_client_add(struct og_client *cli);
63
64static inline int og_client_socket(const struct og_client *cli)
65{
66        return cli->io.fd;
67}
68
69#include "json.h"
70
71int og_client_state_process_payload_rest(struct og_client *cli);
72
73enum og_rest_method {
74        OG_METHOD_GET   = 0,
75        OG_METHOD_POST,
76        OG_METHOD_NO_HTTP
77};
78
79int og_send_request(enum og_rest_method method, enum og_cmd_type type,
80                    const struct og_msg_params *params,
81                    const json_t *data);
82
83struct og_cmd {
84        uint32_t                id;
85        struct list_head        list;
86        uint32_t                client_id;
87        const char              *ip;
88        const char              *mac;
89        enum og_cmd_type        type;
90        enum og_rest_method     method;
91        struct og_msg_params    params;
92        json_t                  *json;
93};
94
95const struct og_cmd *og_cmd_find(const char *client_ip);
96void og_cmd_free(const struct og_cmd *cmd);
97
98#endif
Note: See TracBrowser for help on using the repository browser.