16#include "./endpoint_msgio_p.h"
18#include <gwenhywfar/debug.h>
21#define GWEN_ENDPOINT_MSGIO_BUFFERSIZE 1024
53 GWEN_ENDPOINT_MSGIO *xep;
67 GWEN_ENDPOINT_MSGIO *xep;
70 xep=(GWEN_ENDPOINT_MSGIO*) p;
80 GWEN_ENDPOINT_MSGIO *xep;
84 xep->getBytesNeededFn=f;
93 GWEN_ENDPOINT_MSGIO *xep;
97 xep->sendMsgStartFn=f;
106 GWEN_ENDPOINT_MSGIO *xep;
110 xep->sendMsgFinishFn=f;
119 GWEN_ENDPOINT_MSGIO *xep;
122 if (xep && xep->sendMsgStartFn)
123 return xep->sendMsgStartFn(ep, msg);
134 GWEN_ENDPOINT_MSGIO *xep;
137 if (xep && xep->sendMsgStartFn)
138 xep->sendMsgFinishFn(ep, msg);
147 GWEN_ENDPOINT_MSGIO *xep;
168 else if (xep->addSocketsFn) {
170 xep->addSocketsFn(ep, readSet, writeSet, xSet);
181 GWEN_ENDPOINT_MSGIO *xep;
197 "Endpoint %s: Error writing current message (%d), disconnecting",
210 "Endpoint %s: Error reading current message (%d), disconnecting",
219 else if (xep->checkSocketsFn) {
221 xep->checkSocketsFn(ep, readSet, writeSet, xSet);
242 if (pos==0 && remaining>0) {
325 GWEN_ENDPOINT_MSGIO *xep;
329 if (xep->getBytesNeededFn) {
345 bytesNeeded=xep->getBytesNeededFn(ep, msg);
347 if (bytesNeeded==0) {
351 else if (bytesNeeded<0) {
359 if (bytesNeeded>bufferLen)
360 bytesNeeded=bufferLen;
367 if (xep->getBytesNeededFn(ep, msg)==0) {
374 bufferPtr+=bytesNeeded;
375 bufferLen-=bytesNeeded;
#define DBG_INFO(dbg_logger, format,...)
#define DBG_ERROR(dbg_logger, format,...)
#define DBG_DEBUG(dbg_logger, format,...)
GWEN_MSG * GWEN_MsgEndpoint_GetCurrentlyReceivedMsg(const GWEN_MSG_ENDPOINT *ep)
GWEN_SOCKET * GWEN_MsgEndpoint_GetSocket(const GWEN_MSG_ENDPOINT *ep)
void GWEN_MsgEndpoint_SetCurrentlyReceivedMsg(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m)
int GWEN_MsgEndpoint_GetState(const GWEN_MSG_ENDPOINT *ep)
int GWEN_MsgEndpoint_WriteToSocket(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPtr, uint32_t bufferLen)
int GWEN_MsgEndpoint_GetGroupId(const GWEN_MSG_ENDPOINT *ep)
GWEN_MSG_ENDPOINT_ADDSOCKETS_FN GWEN_MsgEndpoint_SetAddSocketsFn(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT_ADDSOCKETS_FN fn)
void GWEN_MsgEndpoint_Disconnect(GWEN_MSG_ENDPOINT *ep)
void GWEN_MsgEndpoint_AddReceivedMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *m)
const char * GWEN_MsgEndpoint_GetName(const GWEN_MSG_ENDPOINT *ep)
int GWEN_MsgEndpoint_HaveMessageToSend(const GWEN_MSG_ENDPOINT *ep)
int GWEN_MsgEndpoint_GetDefaultMessageSize(const GWEN_MSG_ENDPOINT *ep)
GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN GWEN_MsgEndpoint_SetCheckSocketsFn(GWEN_MSG_ENDPOINT *ep, GWEN_MSG_ENDPOINT_CHECKSOCKETS_FN fn)
int GWEN_MsgEndpoint_ReadFromSocket(GWEN_MSG_ENDPOINT *ep, uint8_t *bufferPtr, uint32_t bufferLen)
GWEN_MSG * GWEN_MsgEndpoint_GetFirstSendMessage(const GWEN_MSG_ENDPOINT *ep)
struct GWEN_MSG_ENDPOINT GWEN_MSG_ENDPOINT
Object which can send and receive messages (base class).
#define GWEN_MSG_ENDPOINT_STATE_CONNECTED
#define GWEN_ENDPOINT_MSGIO_BUFFERSIZE
void GWEN_MsgIoEndpoint_SetSendMsgFinishFn(GWEN_MSG_ENDPOINT *ep, GWEN_ENDPOINT_MSGIO_SENDMSGFINISH_FN f)
static int _distributeBufferContent(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPtr, int bufferLen)
static void _sendMsgFinish(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
static void _addSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_UNUSED GWEN_SOCKETSET *xSet)
static void GWENHYWFAR_CB _freeData(void *bp, void *p)
static int _readCurrentMessage(GWEN_MSG_ENDPOINT *ep)
void GWEN_MsgIoEndpoint_Extend(GWEN_MSG_ENDPOINT *ep)
static void _checkSockets(GWEN_MSG_ENDPOINT *ep, GWEN_SOCKETSET *readSet, GWEN_SOCKETSET *writeSet, GWEN_SOCKETSET *xSet)
static int _writeCurrentMessage(GWEN_MSG_ENDPOINT *ep)
void GWEN_MsgIoEndpoint_SetSendMsgStartFn(GWEN_MSG_ENDPOINT *ep, GWEN_ENDPOINT_MSGIO_SENDMSGSTART_FN f)
static int _sendMsgStart(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
void GWEN_MsgIoEndpoint_SetGetNeededBytesFn(GWEN_MSG_ENDPOINT *ep, GWEN_ENDPOINT_MSGIO_GETBYTESNEEDED_FN f)
int(* GWEN_ENDPOINT_MSGIO_SENDMSGSTART_FN)(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
void(* GWEN_ENDPOINT_MSGIO_SENDMSGFINISH_FN)(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
int(* GWEN_ENDPOINT_MSGIO_GETBYTESNEEDED_FN)(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *msg)
#define GWEN_ERROR_TIMEOUT
#define GWEN_ERROR_GENERIC
GWENHYWFAR_API int GWEN_SocketSet_HasSocket(GWEN_SOCKETSET *ssp, const GWEN_SOCKET *sp)
GWENHYWFAR_API int GWEN_SocketSet_AddSocket(GWEN_SOCKETSET *ssp, const GWEN_SOCKET *sp)
GWENHYWFAR_API int GWEN_Socket_GetSocketInt(const GWEN_SOCKET *sp)
struct GWEN_SOCKETSETSTRUCT GWEN_SOCKETSET
struct GWEN_SOCKET GWEN_SOCKET
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
#define GWEN_INHERIT(bt, t)
#define GWEN_INHERIT_GETDATA(bt, t, element)
void GWEN_Msg_List_Del(GWEN_MSG *element)
#define GWEN_FREE_OBJECT(varname)
#define GWEN_NEW_OBJECT(typ, varname)
uint32_t GWEN_Msg_GetCurrentPos(const GWEN_MSG *msg)
int GWEN_Msg_AddBytes(GWEN_MSG *msg, const uint8_t *bufferPtr, uint32_t bufferLen)
int GWEN_Msg_GetRemainingBytes(const GWEN_MSG *msg)
int GWEN_Msg_IncCurrentPos(GWEN_MSG *msg, uint32_t i)
void GWEN_Msg_SetGroupId(GWEN_MSG *msg, int groupId)
uint8_t * GWEN_Msg_GetBuffer(GWEN_MSG *msg)
void GWEN_Msg_free(GWEN_MSG *msg)
GWEN_MSG * GWEN_Msg_new(uint32_t bufferSize)
static void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p)