From 3a3f5804ccfcefca2066a7c83c45f3f09077a308 Mon Sep 17 00:00:00 2001 From: Granyaa Date: Thu, 15 Jan 2026 11:30:56 +0200 Subject: [PATCH] Fixed forward delcaration of NanoAttachment in nano_attachment_io fixed return from PopResponseVerdictFromQueue --- .../nano_attachment/nano_attachment_bucket.h | 2 + .../nano_attachment/nano_attachment_io.c | 41 ++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/attachments/nano_attachment/nano_attachment_bucket.h b/attachments/nano_attachment/nano_attachment_bucket.h index 5a49d6b..7c236dc 100644 --- a/attachments/nano_attachment/nano_attachment_bucket.h +++ b/attachments/nano_attachment/nano_attachment_bucket.h @@ -7,6 +7,8 @@ #define CP_ASYNC_CTX_BUCKETS 2048 ///< Hash table buckets for better distribution +typedef struct NanoAttachment NanoAttachment; + AttachmentVerdictResponse NanoAsyncFindResponse(NanoAttachment *attachment, SessionID session_id); NanoCommunicationResult NanoAsyncAddResponse(NanoAttachment *attachment, SessionID session_id, AttachmentVerdictResponse *response); diff --git a/attachments/nano_attachment/nano_attachment_io.c b/attachments/nano_attachment/nano_attachment_io.c index 2d149a7..c899688 100755 --- a/attachments/nano_attachment/nano_attachment_io.c +++ b/attachments/nano_attachment/nano_attachment_io.c @@ -1757,13 +1757,19 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment) HttpReplyFromService *reply_p; int pop_result; SessionID session_id = 0; + AttachmentVerdictResponse response = { + .verdict = ATTACHMENT_VERDICT_INSPECT, + .session_id = 0, + .web_response_data = NULL, + .modifications = NULL + }; if (attachment == NULL || attachment->nano_service_ipc == NULL) { - return 0; + return response; } if (!isDataAvailable(attachment->nano_service_ipc)) { - return 0; + return response; } pop_result = receiveData(attachment->nano_service_ipc, &reply_size, &reply_data); @@ -1774,7 +1780,7 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment) DBG_LEVEL_WARNING, "Failed to receive data from queue" ); - return 0; + return response; } reply_p = (HttpReplyFromService *)reply_data; @@ -1787,10 +1793,35 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment) DBG_LEVEL_WARNING, "Failed to pop data from queue" ); - return 0; + return response; } - response.verdict = reply_p->verdict; + // Convert ServiceVerdict to AttachmentVerdict + switch ((ServiceVerdict)reply_p->verdict) { + case TRAFFIC_VERDICT_INSPECT: + response.verdict = ATTACHMENT_VERDICT_INSPECT; + break; + case TRAFFIC_VERDICT_ACCEPT: + response.verdict = ATTACHMENT_VERDICT_ACCEPT; + break; + case TRAFFIC_VERDICT_DROP: + response.verdict = ATTACHMENT_VERDICT_DROP; + break; + case TRAFFIC_VERDICT_INJECT: + // Not yet supported + response.verdict = ATTACHMENT_VERDICT_INSPECT; + break; + default: + write_dbg( + attachment, + reply_p->session_id, + DBG_LEVEL_WARNING, + "Unknown verdict %d", + reply_p->verdict + ); + response.verdict = ATTACHMENT_VERDICT_INSPECT; + break; + } response.session_id = reply_p->session_id; // TODO: Deal with data leak.