diff options
Diffstat (limited to 'src/analysis/db/client.c')
-rw-r--r-- | src/analysis/db/client.c | 86 |
1 files changed, 78 insertions, 8 deletions
diff --git a/src/analysis/db/client.c b/src/analysis/db/client.c index b4e856f..c1bcd28 100644 --- a/src/analysis/db/client.c +++ b/src/analysis/db/client.c @@ -908,6 +908,8 @@ static void *g_hub_client_update(GHubClient *client) case DBC_SET_CUR_SNAPSHOT: case DBC_SET_SNAPSHOT_NAME: case DBC_SET_SNAPSHOT_DESC: + case DBC_CREATE_SNAPSHOT: + case DBC_REMOVE_SNAPSHOT: log_variadic_message(LMT_INFO, _("This command is not available on this side: 0x%08x"), command); goto gdcu_bad_exchange; @@ -1586,9 +1588,32 @@ bool g_hub_client_set_snapshot_desc(GHubClient *client, const snapshot_id_t *id, bool g_hub_client_restore_snapshot(GHubClient *client, const snapshot_id_t *id) { - bool result; /* Bilan à retourner */ + bool result; /* Bilan partiel à remonter */ + packed_buffer out_pbuf; /* Tampon d'émission */ + SSL *tls_fd; /* Canal de communication SSL */ + + init_packed_buffer(&out_pbuf); + + tls_fd = g_hub_client_get_ssl_fd(client); + + if (tls_fd == NULL) + result = false; - result = false; + else + { + result = extend_packed_buffer(&out_pbuf, (uint32_t []) { DBC_SET_CUR_SNAPSHOT }, sizeof(uint32_t), true); + + if (result) + result = pack_snapshot_id(id, &out_pbuf); + + if (result) + result = ssl_send_packed_buffer(&out_pbuf, tls_fd); + + g_hub_client_put_ssl_fd(client, tls_fd); + + } + + exit_packed_buffer(&out_pbuf); return result; @@ -1598,7 +1623,6 @@ bool g_hub_client_restore_snapshot(GHubClient *client, const snapshot_id_t *id) /****************************************************************************** * * * Paramètres : client = client pour les accès distants à manipuler. * -* id = identifiant d'instantané à traiter. * * * * Description : Crée un nouvel instantané à partir d'un autre. * * * @@ -1608,11 +1632,31 @@ bool g_hub_client_restore_snapshot(GHubClient *client, const snapshot_id_t *id) * * ******************************************************************************/ -bool g_hub_client_create_snapshot(GHubClient *client, const snapshot_id_t *id) +bool g_hub_client_create_snapshot(GHubClient *client) { - bool result; /* Bilan à retourner */ + bool result; /* Bilan partiel à remonter */ + packed_buffer out_pbuf; /* Tampon d'émission */ + SSL *tls_fd; /* Canal de communication SSL */ - result = false; + init_packed_buffer(&out_pbuf); + + tls_fd = g_hub_client_get_ssl_fd(client); + + if (tls_fd == NULL) + result = false; + + else + { + result = extend_packed_buffer(&out_pbuf, (uint32_t []) { DBC_CREATE_SNAPSHOT }, sizeof(uint32_t), true); + + if (result) + result = ssl_send_packed_buffer(&out_pbuf, tls_fd); + + g_hub_client_put_ssl_fd(client, tls_fd); + + } + + exit_packed_buffer(&out_pbuf); return result; @@ -1635,9 +1679,35 @@ bool g_hub_client_create_snapshot(GHubClient *client, const snapshot_id_t *id) bool g_hub_client_remove_snapshot(GHubClient *client, const snapshot_id_t *id, bool rec) { - bool result; /* Bilan à retourner */ + bool result; /* Bilan partiel à remonter */ + packed_buffer out_pbuf; /* Tampon d'émission */ + SSL *tls_fd; /* Canal de communication SSL */ + + init_packed_buffer(&out_pbuf); + + tls_fd = g_hub_client_get_ssl_fd(client); + + if (tls_fd == NULL) + result = false; + + else + { + result = extend_packed_buffer(&out_pbuf, (uint32_t []) { DBC_REMOVE_SNAPSHOT }, sizeof(uint32_t), true); + + if (result) + result = pack_snapshot_id(id, &out_pbuf); + + if (result) + result = extend_packed_buffer(&out_pbuf, (uint8_t []) { rec ? 0x1 : 0x0 }, sizeof(uint8_t), false); - result = false; + if (result) + result = ssl_send_packed_buffer(&out_pbuf, tls_fd); + + g_hub_client_put_ssl_fd(client, tls_fd); + + } + + exit_packed_buffer(&out_pbuf); return result; |