mirror of https://git.48k.eu/ogserver
#995 Add link speed parsing to client probe response
If a probe response contains speedinformation, parse and store it inside the client struct. Speed is interpreted as an unsigned integer representing Mbit/s.master
parent
a7cce8d442
commit
40d4279b31
|
@ -28,6 +28,7 @@ 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;
|
||||
|
||||
|
@ -39,6 +40,11 @@ static int og_resp_probe(struct og_client *cli, json_t *data)
|
|||
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;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -389,6 +389,7 @@ static int og_json_client_append(json_t *array, struct og_client *client)
|
|||
return -1;
|
||||
}
|
||||
json_object_set_new(object, "state", state);
|
||||
json_object_set_new(object, "speed", json_integer(client->speed));
|
||||
json_array_append_new(array, object);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -55,6 +55,7 @@ struct og_client {
|
|||
enum og_cmd_type last_cmd;
|
||||
unsigned int last_cmd_id;
|
||||
bool autorun;
|
||||
uint32_t speed;
|
||||
};
|
||||
|
||||
void og_client_add(struct og_client *cli);
|
||||
|
|
Loading…
Reference in New Issue