mirror of https://git.48k.eu/ogserver
parent
491bf6f5e9
commit
760a82af2c
37
src/client.c
37
src/client.c
|
@ -168,40 +168,6 @@ static int og_resp_early_hints(struct og_client *cli, json_t *data)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int og_resp_probe(struct og_client *cli, json_t *data)
|
|
||||||
{
|
|
||||||
const char *status = NULL;
|
|
||||||
const char *key;
|
|
||||||
uint32_t speed;
|
|
||||||
json_t *value;
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if (json_typeof(data) != JSON_OBJECT)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
json_object_foreach(data, key, value) {
|
|
||||||
if (!strcmp(key, "status")) {
|
|
||||||
err = og_json_parse_string(value, &status);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
} else if (!strcmp(key, "speed")) {
|
|
||||||
err = og_json_parse_uint(value, &speed);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
cli->speed = speed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(status, "BSY"))
|
|
||||||
cli->status = OG_CLIENT_STATUS_BUSY;
|
|
||||||
else if (!strcmp(status, "OPG"))
|
|
||||||
cli->status = OG_CLIENT_STATUS_OGLIVE;
|
|
||||||
else if (!strcmp(status, "VDI"))
|
|
||||||
cli->status = OG_CLIENT_STATUS_VIRTUAL;
|
|
||||||
|
|
||||||
return status ? 0 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int og_resp_shell_run(struct og_client *cli, json_t *data)
|
static int og_resp_shell_run(struct og_client *cli, json_t *data)
|
||||||
{
|
{
|
||||||
const char *cmd = NULL, *output = NULL;
|
const char *cmd = NULL, *output = NULL;
|
||||||
|
@ -1387,9 +1353,6 @@ int og_agent_state_process_response(struct og_client *cli)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cli->last_cmd) {
|
switch (cli->last_cmd) {
|
||||||
case OG_CMD_PROBE:
|
|
||||||
err = og_resp_probe(cli, root);
|
|
||||||
break;
|
|
||||||
case OG_CMD_SHELL_RUN:
|
case OG_CMD_SHELL_RUN:
|
||||||
err = og_resp_shell_run(cli, root);
|
err = og_resp_shell_run(cli, root);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -124,7 +124,6 @@ static const char *og_client_status(const struct og_client *cli)
|
||||||
{
|
{
|
||||||
switch (cli->last_cmd) {
|
switch (cli->last_cmd) {
|
||||||
case OG_CMD_UNSPEC:
|
case OG_CMD_UNSPEC:
|
||||||
case OG_CMD_PROBE:
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return "BSY";
|
return "BSY";
|
||||||
|
@ -219,7 +218,6 @@ int og_json_parse_partition_setup(json_t *element, struct og_msg_params *params)
|
||||||
|
|
||||||
static const char *og_cmd_to_uri[OG_CMD_MAX] = {
|
static const char *og_cmd_to_uri[OG_CMD_MAX] = {
|
||||||
[OG_CMD_WOL] = "wol",
|
[OG_CMD_WOL] = "wol",
|
||||||
[OG_CMD_PROBE] = "probe",
|
|
||||||
[OG_CMD_SHELL_RUN] = "shell/run",
|
[OG_CMD_SHELL_RUN] = "shell/run",
|
||||||
[OG_CMD_SESSION] = "session",
|
[OG_CMD_SESSION] = "session",
|
||||||
[OG_CMD_POWEROFF] = "poweroff",
|
[OG_CMD_POWEROFF] = "poweroff",
|
||||||
|
|
|
@ -26,7 +26,6 @@ enum og_client_status {
|
||||||
enum og_cmd_type {
|
enum og_cmd_type {
|
||||||
OG_CMD_UNSPEC,
|
OG_CMD_UNSPEC,
|
||||||
OG_CMD_WOL,
|
OG_CMD_WOL,
|
||||||
OG_CMD_PROBE,
|
|
||||||
OG_CMD_SHELL_RUN,
|
OG_CMD_SHELL_RUN,
|
||||||
OG_CMD_SESSION,
|
OG_CMD_SESSION,
|
||||||
OG_CMD_POWEROFF,
|
OG_CMD_POWEROFF,
|
||||||
|
|
Loading…
Reference in New Issue