gwenhywfar 5.12.0
endpoint_ipc.c
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the project Gwenhywfar.
3 * Gwenhywfar (c) by 2023 Martin Preuss, all rights reserved.
4 *
5 * The license for this file can be found in the file COPYING which you
6 * should have received along with this file.
7 ****************************************************************************/
8
9#ifdef HAVE_CONFIG_H
10# include <config.h>
11#endif
12
13/*#define DISABLE_DEBUGLOG*/
14
15
16#include "./endpoint_ipc.h"
17#include "./endpoint_msgio.h"
18#include "./endpoint_tcpc.h"
19#include "./msg_ipc.h"
20
21#include <gwenhywfar/debug.h>
22
23
24#define GWEN_MSG_ENDPOINT_IPC_NAME "ipc"
25
26
27
28/* ------------------------------------------------------------------------------------------------
29 * forward declarations
30 * ------------------------------------------------------------------------------------------------
31 */
32
34
35
36
37/* ------------------------------------------------------------------------------------------------
38 * implementations
39 * ------------------------------------------------------------------------------------------------
40 */
41
48
49
50
52{
53 uint32_t bytesInMsg;
54
55 bytesInMsg=GWEN_Msg_GetBytesInBuffer(msg);
56 if (bytesInMsg<GWEN_MSGIPC_OFFS_PAYLOAD) {
57 DBG_DEBUG(GWEN_LOGDOMAIN, "Header not yet complete");
58 return (int) (GWEN_MSGIPC_OFFS_PAYLOAD-bytesInMsg);
59 }
60 else {
61 uint32_t msgSize;
62
63 msgSize=GWEN_IpcMsg_GetMsgSize(msg); /* IPC length field contains ALL bytes including header */
64 return (int) (msgSize-bytesInMsg);
65 }
66}
67
68
69
70GWEN_MSG_ENDPOINT *GWEN_IpcEndpoint_CreateIpcTcpClient(const char *host, int port, const char *name, int groupId)
71{
73
74 ep=GWEN_TcpcEndpoint_new(host, port, name?name:GWEN_MSG_ENDPOINT_IPC_NAME, groupId);
77 return ep;
78}
79
80
81
92
93
94
#define DBG_DEBUG(dbg_logger, format,...)
Definition debug.h:214
GWEN_MSG_ENDPOINT * GWEN_MsgEndpoint_new(const char *name, int groupId)
Definition endpoint.c:31
void GWEN_MsgEndpoint_SetSocket(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKET *sk)
Definition endpoint.c:111
struct GWEN_MSG_ENDPOINT GWEN_MSG_ENDPOINT
Object which can send and receive messages (base class).
Definition endpoint.h:37
void GWEN_IpcEndpoint_Extend(GWEN_MSG_ENDPOINT *ep)
GWEN_MSG_ENDPOINT * GWEN_IpcEndpoint_CreateIpcTcpServiceForSocket(GWEN_SOCKET *sk, const char *name, int groupId)
GWEN_MSG_ENDPOINT * GWEN_IpcEndpoint_CreateIpcTcpClient(const char *host, int port, const char *name, int groupId)
#define GWEN_MSG_ENDPOINT_IPC_NAME
static int _getBytesNeededForMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
void GWEN_MsgIoEndpoint_Extend(GWEN_MSG_ENDPOINT *ep)
void GWEN_MsgIoEndpoint_SetGetNeededBytesFn(GWEN_MSG_ENDPOINT *ep, GWEN_ENDPOINT_MSGIO_GETBYTESNEEDED_FN f)
GWEN_MSG_ENDPOINT * GWEN_TcpcEndpoint_new(const char *host, int port, const char *name, int groupId)
#define GWEN_UNUSED
struct GWEN_SOCKET GWEN_SOCKET
Definition inetsocket.h:40
#define GWEN_LOGDOMAIN
Definition logger.h:35
uint32_t GWEN_Msg_GetBytesInBuffer(const GWEN_MSG *msg)
Definition msg.c:151
struct GWEN_MSG GWEN_MSG
Definition msg.h:24
uint32_t GWEN_IpcMsg_GetMsgSize(const GWEN_MSG *msg)
Definition msg_ipc.c:74
#define GWEN_MSGIPC_OFFS_PAYLOAD
Definition msg_ipc.h:23