Browse Source

extending transport system

pull/57/head
Volker Birk 4 months ago
parent
commit
54e3758a3e
4 changed files with 57 additions and 12 deletions
  1. +16
    -1
      src/trans_auto.c
  2. +7
    -1
      src/trans_auto.h
  3. +4
    -0
      src/transport.c
  4. +30
    -10
      src/transport.h

+ 16
- 1
src/trans_auto.c View File

@ -6,8 +6,15 @@
#include "trans_auto.h"
PEP_STATUS auto_init(PEP_transport_t *transport,
PEP_SESSION session, PEP_transport_status_code *tsc)
{
return PEP_STATUS_OK;
}
PEP_STATUS auto_sendto(PEP_SESSION session, message *msg,
PEP_transport_status_code *tsc)
stringlist_t **unreachable_addresses, PEP_transport_status_code *tsc)
{
return PEP_STATUS_OK;
@ -19,3 +26,11 @@ PEP_STATUS auto_readnext(PEP_SESSION session, message **msg,
return PEP_STATUS_OK;
}
PEP_STATUS auto_signal_statuschange(PEP_transport_id id,
PEP_transport_status_code tsc)
{
return PEP_STATUS_OK;
}

+ 7
- 1
src/trans_auto.h View File

@ -10,7 +10,7 @@
#include "transport.h"
PEP_STATUS auto_sendto(PEP_SESSION session, message *msg,
PEP_transport_status_code *tsc);
stringlist_t **unreachable_addresses, PEP_transport_status_code *tsc);
/**
* <!-- auto_readnext() -->
@ -23,7 +23,13 @@ PEP_STATUS auto_sendto(PEP_SESSION session, message *msg,
*
*/
PEP_STATUS auto_init(PEP_transport_t *transport,
PEP_SESSION session, PEP_transport_status_code *tsc);
PEP_STATUS auto_readnext(PEP_SESSION session, message **msg,
PEP_transport_status_code *tsc);
PEP_STATUS auto_signal_statuschange(PEP_transport_id id,
PEP_transport_status_code tsc);
#endif

+ 4
- 0
src/transport.c View File

@ -22,8 +22,12 @@ PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first)
memset(transports, 0, sizeof(PEP_transport_t) * PEP_trans__count);
transports[PEP_trans_auto].id = PEP_trans_auto;
transports[PEP_trans_auto].init = auto_init;
transports[PEP_trans_auto].sendto = auto_sendto;
transports[PEP_trans_auto].readnext = auto_readnext;
transports[PEP_trans_auto].signal_statuschange = auto_signal_statuschange;
}
return PEP_STATUS_OK;


+ 30
- 10
src/transport.h View File

@ -15,19 +15,20 @@ extern "C" {
#endif
/**
* @enum PEP_transports
* @enum PEP_transport_id
*
* @brief TODO
*
*/
typedef enum _PEP_transports {
typedef enum _PEP_transport_id {
// auto transport chooses transport per message automatically
PEP_trans_auto = 0,
// PEP_trans_email,
// PEP_trans_whatsapp,
// PEP_trans_Email = 0x01,
// PEP_trans_RCE = 0x02,
PEP_trans__count
} PEP_transports;
PEP_trans__count,
PEP_trans_CC = 0xfe
} PEP_transport_id;
// transports are delivering the transport status code
// this is defined here:
@ -37,12 +38,22 @@ typedef uint32_t PEP_transport_status_code;
typedef struct _PEP_transport_t PEP_transport_t;
// functions offered by transport
typedef PEP_STATUS (*init_transport_t)(PEP_transport_t *transport,
PEP_SESSION session, PEP_transport_status_code *tsc);
typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, message *msg,
PEP_transport_status_code *tsc);
stringlist_t **unreachable_addresses, PEP_transport_status_code *tsc);
typedef PEP_STATUS (*recvnext_t)(PEP_SESSION session, message **msg,
PEP_transport_status_code *tsc);
// functions offered by transport system
typedef PEP_STATUS (*signal_statuschange_t)(PEP_transport_id id,
PEP_transport_status_code tsc);
/**
* @struct _PEP_transport_t
*
@ -50,10 +61,19 @@ typedef PEP_STATUS (*recvnext_t)(PEP_SESSION session, message **msg,
*
*/
struct _PEP_transport_t {
PEP_transports id; // transport ID
PEP_transport_id id; // transport ID
const char *uri_scheme; // URI scheme this transport is
// covering
// functions offered by transport
init_transport_t init;
sendto_t sendto;
recvnext_t readnext;
// functions offered by transport system
sendto_t sendto; // sendto function
recvnext_t readnext; // readnext function
signal_statuschange_t signal_statuschange;
bool is_online_transport;


Loading…
Cancel
Save