From cd0fdedcf5b2c3919e99cf8e090976bf85fa1e0f Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Thu, 12 Aug 2021 12:08:36 +0200 Subject: [PATCH] slightly redesigned --- src/pEpEngine.h | 15 +++++++++++++++ src/trans_auto.c | 6 ++++-- src/trans_auto.h | 8 ++++++-- src/transport.h | 30 +++++++++++++++++++++--------- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/pEpEngine.h b/src/pEpEngine.h index 689eeaa1..3b5e6044 100644 --- a/src/pEpEngine.h +++ b/src/pEpEngine.h @@ -162,6 +162,21 @@ typedef enum { PEP_STORAGE_ILLEGAL_MESSAGE = 0x1102, PEP_PEPMESSAGE_ILLEGAL_MESSAGE = 0x1202, + // transport cannot init at all + PEP_TRANSPORT_CANNOT_INIT = 0x2000, + + // transport can init recv but not send + PEP_TRANSPORT_CANNOT_INIT_SEND = 0x2001, + + // transport can init send but not recv + PEP_TRANSPORT_CANNOT_INIT_RECV = 0x2002, + + // transport init good but temporary down + PEP_TRANSPORT_DOWN = 0x2003, + + // general error in transport + PEP_TRANSPORT_ERROR = 0x20ff, + PEP_COMMIT_FAILED = 0xff01, PEP_MESSAGE_CONSUME = 0xff02, PEP_MESSAGE_IGNORE = 0xff03, diff --git a/src/trans_auto.c b/src/trans_auto.c index ae371ca9..0f03ae59 100644 --- a/src/trans_auto.c +++ b/src/trans_auto.c @@ -6,13 +6,15 @@ #include "trans_auto.h" -PEP_STATUS auto_sendto(PEP_SESSION session, const message *msg) +PEP_STATUS auto_sendto(PEP_SESSION session, message *msg, + PEP_transport_status_code *tsc) { return PEP_STATUS_OK; } -PEP_STATUS auto_readnext(PEP_SESSION session, message **msg, PEP_transport_t **via) +PEP_STATUS auto_readnext(PEP_SESSION session, message **msg, + PEP_transport_status_code *tsc) { return PEP_STATUS_OK; diff --git a/src/trans_auto.h b/src/trans_auto.h index 1cd85e3d..4a1584dc 100644 --- a/src/trans_auto.h +++ b/src/trans_auto.h @@ -9,7 +9,9 @@ #include "transport.h" -PEP_STATUS auto_sendto(PEP_SESSION session, const message *msg); +PEP_STATUS auto_sendto(PEP_SESSION session, message *msg, + PEP_transport_status_code *tsc); + /** * * @@ -20,6 +22,8 @@ PEP_STATUS auto_sendto(PEP_SESSION session, const message *msg); * @param[out] via PEP_transport_t** * */ -PEP_STATUS auto_readnext(PEP_SESSION session, message **msg, PEP_transport_t **via); + +PEP_STATUS auto_readnext(PEP_SESSION session, message **msg, + PEP_transport_status_code *tsc); #endif diff --git a/src/transport.h b/src/transport.h index 062fb52e..1315a67f 100644 --- a/src/transport.h +++ b/src/transport.h @@ -29,11 +29,19 @@ typedef enum _PEP_transports { PEP_trans__count } PEP_transports; +// transports are delivering the transport status code +// this is defined here: +// https://dev.pep.foundation/Engine/TransportStatusCode + +typedef uint32_t PEP_transport_status_code; + typedef struct _PEP_transport_t PEP_transport_t; -typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, const message *msg); -typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, message **msg, - PEP_transport_t **via); +typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, message *msg, + PEP_transport_status_code *tsc); + +typedef PEP_STATUS (*recvnext_t)(PEP_SESSION session, message **msg, + PEP_transport_status_code *tsc); /** * @struct _PEP_transport_t @@ -42,13 +50,17 @@ typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, message **msg, * */ struct _PEP_transport_t { - uint8_t id; // transport ID + PEP_transports id; // transport ID + sendto_t sendto; // sendto function - readnext_t readnext; // readnext function - bool long_message_supported; // flag if this transport supports - // long messages - bool formatted_message_supported; // flag if this transport supports - // formatted messages + recvnext_t readnext; // readnext function + + bool is_online_transport; + + bool shortmsg_supported; + bool longmsg_supported; + bool longmsg_formatted_supported; + PEP_text_format native_text_format; // native format of the transport };