source: ogServer-Git/src/rest.h @ a801e78

Last change on this file since a801e78 was b6b1040, checked in by Jose M. Guisado <jguisado@…>, 3 years ago

#1065 client: add support for ogclient win state

ogClient can be run in windows mode, enabling connection with ogServer
when running on a Windows machine.

Don't expect the same payload in windows mode as a in live or virtual.
Client in windows mode does not send partition setup information, only
the status/state. (same case for linux mode)

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