New upstream version 8.1.0
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#include <app/App.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include "GetHostByNameMsg.h"
|
||||
|
||||
const struct NetMessageOps GetHostByNameMsg_Ops = {
|
||||
.serializePayload = GetHostByNameMsg_serializePayload,
|
||||
.deserializePayload = GetHostByNameMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void GetHostByNameMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
GetHostByNameMsg* thisCast = (GetHostByNameMsg*)this;
|
||||
|
||||
// hostname
|
||||
Serialization_serializeStr(ctx, thisCast->hostnameLen, thisCast->hostname);
|
||||
}
|
||||
|
||||
bool GetHostByNameMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
GetHostByNameMsg* thisCast = (GetHostByNameMsg*)this;
|
||||
|
||||
// hostname
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->hostnameLen, &thisCast->hostname) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef GETHOSTBYNAMEMSG_H_
|
||||
#define GETHOSTBYNAMEMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
struct GetHostByNameMsg;
|
||||
typedef struct GetHostByNameMsg GetHostByNameMsg;
|
||||
|
||||
static inline void GetHostByNameMsg_init(GetHostByNameMsg* this);
|
||||
static inline void GetHostByNameMsg_initFromHostname(GetHostByNameMsg* this,
|
||||
const char* hostname);
|
||||
|
||||
// virtual functions
|
||||
extern void GetHostByNameMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool GetHostByNameMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
struct GetHostByNameMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
unsigned hostnameLen;
|
||||
const char* hostname;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps GetHostByNameMsg_Ops;
|
||||
|
||||
void GetHostByNameMsg_init(GetHostByNameMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetHostByName, &GetHostByNameMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostname just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void GetHostByNameMsg_initFromHostname(GetHostByNameMsg* this,
|
||||
const char* hostname)
|
||||
{
|
||||
GetHostByNameMsg_init(this);
|
||||
|
||||
this->hostname = hostname;
|
||||
this->hostnameLen = strlen(hostname);
|
||||
}
|
||||
|
||||
#endif /*GETHOSTBYNAMEMSG_H_*/
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <app/App.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include "GetHostByNameRespMsg.h"
|
||||
|
||||
const struct NetMessageOps GetHostByNameRespMsg_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = GetHostByNameRespMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
bool GetHostByNameRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
GetHostByNameRespMsg* thisCast = (GetHostByNameRespMsg*)this;
|
||||
|
||||
// hostAddr
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->hostAddrLen, &thisCast->hostAddr) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef GETHOSTBYNAMERESPMSG_H_
|
||||
#define GETHOSTBYNAMERESPMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
struct GetHostByNameRespMsg;
|
||||
typedef struct GetHostByNameRespMsg GetHostByNameRespMsg;
|
||||
|
||||
static inline void GetHostByNameRespMsg_init(GetHostByNameRespMsg* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool GetHostByNameRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// getters & setters
|
||||
static inline const char* GetHostByNameRespMsg_getHostAddr(GetHostByNameRespMsg* this);
|
||||
|
||||
|
||||
struct GetHostByNameRespMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
unsigned hostAddrLen;
|
||||
const char* hostAddr;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps GetHostByNameRespMsg_Ops;
|
||||
|
||||
void GetHostByNameRespMsg_init(GetHostByNameRespMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetHostByNameResp, &GetHostByNameRespMsg_Ops);
|
||||
}
|
||||
|
||||
const char* GetHostByNameRespMsg_getHostAddr(GetHostByNameRespMsg* this)
|
||||
{
|
||||
return this->hostAddr;
|
||||
}
|
||||
|
||||
#endif /*GETHOSTBYNAMERESPMSG_H_*/
|
||||
61
client_module/source/common/net/message/helperd/LogMsg.c
Normal file
61
client_module/source/common/net/message/helperd/LogMsg.c
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <app/App.h>
|
||||
#include <common/nodes/Node.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include <common/toolkit/ListTk.h>
|
||||
#include <nodes/NodeStoreEx.h>
|
||||
#include "LogMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps LogMsg_Ops = {
|
||||
.serializePayload = LogMsg_serializePayload,
|
||||
.deserializePayload = LogMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void LogMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
LogMsg* thisCast = (LogMsg*)this;
|
||||
|
||||
// level
|
||||
Serialization_serializeInt(ctx, thisCast->level);
|
||||
|
||||
// threadID
|
||||
Serialization_serializeInt(ctx, thisCast->threadID);
|
||||
|
||||
// threadName
|
||||
Serialization_serializeStr(ctx, thisCast->threadNameLen, thisCast->threadName);
|
||||
|
||||
// context
|
||||
Serialization_serializeStr(ctx, thisCast->contextLen, thisCast->context);
|
||||
|
||||
// logMsg
|
||||
Serialization_serializeStr(ctx, thisCast->logMsgLen, thisCast->logMsg);
|
||||
}
|
||||
|
||||
bool LogMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
LogMsg* thisCast = (LogMsg*)this;
|
||||
|
||||
// level
|
||||
if(!Serialization_deserializeInt(ctx, &thisCast->level) )
|
||||
return false;
|
||||
|
||||
// threadID
|
||||
if(!Serialization_deserializeInt(ctx, &thisCast->threadID) )
|
||||
return false;
|
||||
|
||||
// threadName
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->threadNameLen, &thisCast->threadName) )
|
||||
return false;
|
||||
|
||||
// context
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->contextLen, &thisCast->context) )
|
||||
return false;
|
||||
|
||||
// logMsg
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->logMsgLen, &thisCast->logMsg) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
62
client_module/source/common/net/message/helperd/LogMsg.h
Normal file
62
client_module/source/common/net/message/helperd/LogMsg.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef LOGMSG_H_
|
||||
#define LOGMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
struct LogMsg;
|
||||
typedef struct LogMsg LogMsg;
|
||||
|
||||
static inline void LogMsg_init(LogMsg* this);
|
||||
static inline void LogMsg_initFromEntry(LogMsg* this, int level,
|
||||
int threadID, const char* threadName, const char* context, const char* logMsg);
|
||||
|
||||
// virtual functions
|
||||
extern void LogMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool LogMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
|
||||
struct LogMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
int level;
|
||||
int threadID;
|
||||
unsigned threadNameLen;
|
||||
const char* threadName;
|
||||
unsigned contextLen;
|
||||
const char* context;
|
||||
unsigned logMsgLen;
|
||||
const char* logMsg;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps LogMsg_Ops;
|
||||
|
||||
void LogMsg_init(LogMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_Log, &LogMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context just a reference, so do not free it as long as you use this object!
|
||||
* @param logMsg just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void LogMsg_initFromEntry(LogMsg* this, int level, int threadID, const char* threadName,
|
||||
const char* context, const char* logMsg)
|
||||
{
|
||||
LogMsg_init(this);
|
||||
|
||||
this->level = level;
|
||||
this->threadID = threadID;
|
||||
|
||||
this->threadName = threadName;
|
||||
this->threadNameLen = strlen(threadName);
|
||||
|
||||
this->context = context;
|
||||
this->contextLen = strlen(context);
|
||||
|
||||
this->logMsg = logMsg;
|
||||
this->logMsgLen = strlen(logMsg);
|
||||
}
|
||||
|
||||
#endif /*LOGMSG_H_*/
|
||||
32
client_module/source/common/net/message/helperd/LogRespMsg.h
Normal file
32
client_module/source/common/net/message/helperd/LogRespMsg.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef LOGRESPMSG_H_
|
||||
#define LOGRESPMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
|
||||
|
||||
struct LogRespMsg;
|
||||
typedef struct LogRespMsg LogRespMsg;
|
||||
|
||||
static inline void LogRespMsg_init(LogRespMsg* this);
|
||||
|
||||
// getters & setters
|
||||
static inline int LogRespMsg_getValue(LogRespMsg* this);
|
||||
|
||||
struct LogRespMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void LogRespMsg_init(LogRespMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_LogResp);
|
||||
}
|
||||
|
||||
int LogRespMsg_getValue(LogRespMsg* this)
|
||||
{
|
||||
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*LOGRESPMSG_H_*/
|
||||
Reference in New Issue
Block a user