summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary.c7
-rw-r--r--src/analysis/binary.h4
-rw-r--r--src/analysis/db/client.c21
3 files changed, 18 insertions, 14 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 639d6cc..5d72c41 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -958,9 +958,10 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *binary)
/******************************************************************************
* *
-* Paramètres : binary = élément binaire à consulter. *
+* Paramètres : binary = élément binaire à consulter. *
+* internal = sélectionne le client à renvoyer selon sa nature. *
* *
-* Description : Fournit le client assurant la liaison avec un serveur. *
+* Description : Fournit un client assurant la liaison avec un serveur. *
* *
* Retour : Client connecté ou NULL. *
* *
@@ -968,7 +969,7 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *binary)
* *
******************************************************************************/
-GHubClient *g_loaded_binary_get_db_client(const GLoadedBinary *binary)
+GHubClient *g_loaded_binary_get_client(const GLoadedBinary *binary, bool internal)
{
GHubClient *result; /* Instance à retourner */
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 9b3aa6b..36966c9 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -116,8 +116,8 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *);
/* -------------------------- MANIPULATION DES COLLECTIONS -------------------------- */
-/* Fournit le client assurant la liaison avec un serveur. */
-GHubClient *g_loaded_binary_get_db_client(const GLoadedBinary *);
+/* Fournit un client assurant la liaison avec un serveur. */
+GHubClient *g_loaded_binary_get_client(const GLoadedBinary *, bool);
/* Fournit l'ensemble des collections utilisées par un binaire. */
GDbCollection **g_loaded_binary_get_all_collections(const GLoadedBinary *, size_t *);
diff --git a/src/analysis/db/client.c b/src/analysis/db/client.c
index 2bfa978..329d57d 100644
--- a/src/analysis/db/client.c
+++ b/src/analysis/db/client.c
@@ -61,8 +61,6 @@ struct _GHubClient
{
GObject parent; /* A laisser en premier */
- const char *name; /* Désignation du binaire */
-
rle_string hash; /* Empreinte du binaire lié */
GList *collections; /* Collections d'un binaire */
@@ -756,10 +754,10 @@ static void *g_hub_client_update(GHubClient *client)
if (error == DBE_NONE)
log_variadic_message(LMT_INFO, _("Archive saved for binary '%s'"),
- client->name);
+ get_rle_string(&client->hash));
else
log_variadic_message(LMT_ERROR, _("Failed to save the archive for binary '%s'"),
- client->name);
+ get_rle_string(&client->hash));
break;
@@ -951,16 +949,21 @@ void g_hub_client_put_ssl_fd(GHubClient *client, SSL *tls_fd)
bool g_hub_client_save(GHubClient *client)
{
bool result; /* Bilan partiel à remonter */
- int sent; /* Quantité de données traitées*/
+ packed_buffer out_pbuf; /* Tampon d'émission */
+
+ init_packed_buffer(&out_pbuf);
g_hub_client_get_ssl_fd(client);
- sent = SSL_write(client->tls_fd, (uint32_t []) { htobe32(DBC_SAVE) }, sizeof(uint32_t));
+ result = extend_packed_buffer(&out_pbuf, (uint32_t []) { DBC_SAVE }, sizeof(uint32_t), true);
- result = (sent == sizeof(uint32_t));
+ if (result)
+ result = ssl_send_packed_buffer(&out_pbuf, client->tls_fd);
g_hub_client_put_ssl_fd(client, client->tls_fd);
+ exit_packed_buffer(&out_pbuf);
+
return result;
}
@@ -993,11 +996,11 @@ bool g_hub_client_set_last_active(GHubClient *client, timestamp_t timestamp)
if (result)
result = pack_timestamp(&timestamp, &out_pbuf);
- g_hub_client_put_ssl_fd(client, client->tls_fd);
-
if (result)
result = ssl_send_packed_buffer(&out_pbuf, client->tls_fd);
+ g_hub_client_put_ssl_fd(client, client->tls_fd);
+
exit_packed_buffer(&out_pbuf);
return result;