54 #include "rnr/rnrconfig.h" 105 const char *(*fnGetMsgName)(BsClient_P pClient,
132 #define BSCLIENT_INFO_STR_MAX_SIZE 256 156 #define BSCLIENT_LOG_WARN(pClient, ecode, wfmt, ...) \ 157 LOGDIAG3("Warning: %s: %s(): %s(ecode=%d): " wfmt, \ 158 bsClientAttrGetName(pClient), LOGFUNCNAME, \ 159 bsStrError(ecode), ((ecode)>=0? (ecode): -(ecode)), \ 170 #define BSCLIENT_LOG_ERROR(pClient, ecode, efmt, ...) \ 171 LOGERROR("%s: %s(): %s(ecode=%d): " efmt, \ 172 bsClientAttrGetName(pClient), LOGFUNCNAME, \ 173 bsStrError(ecode), (ecode>=0? ecode: -ecode), \ 184 #define BSCLIENT_LOG_NM_ERROR(pClient, nmecode, efmt, ...) \ 185 BSCLIENT_LOG_ERROR(pClient, BS_ECODE_BAD_MSG, "%s(nmecode=%d): " efmt, \ 186 nmStrError(nmecode), (nmecode>=0? nmecode: -nmecode), ##__VA_ARGS__) 196 #define BSCLIENT_LOG_SYSERROR(pClient, ecode, efmt, ...) \ 197 LOGERROR("%s: %s(): %s(ecode=%d): %s(errno=%d)" efmt, \ 198 bsClientAttrGetName(pClient), LOGFUNCNAME, \ 199 bsStrError(ecode), ((ecode)>=0? (ecode): -(ecode)), \ 200 strerror(errno), errno, ##__VA_ARGS__) 214 #define BSCLIENT_TRY_ECODE(pClient, ecode, efmt, ...) \ 219 BSCLIENT_LOG_ERROR(pClient, ecode, efmt, ##__VA_ARGS__); \ 236 #define BSCLIENT_TRY_NM_ECODE(pClient, nmecode, efmt, ...) \ 239 if( (nmecode) < 0 ) \ 241 BSCLIENT_LOG_NM_ERROR(pClient, nmecode, efmt, ##__VA_ARGS__); \ 242 return -BS_ECODE_BAD_MSG; \ 259 #define BSCLIENT_TRY_EXPR(pClient, expr, ecode, efmt, ...) \ 264 BSCLIENT_LOG_ERROR(pClient, ecode, "%s: " efmt, #expr, ##__VA_ARGS__); \ 265 return (ecode)>0? -(ecode): (ecode); \ 274 #define BSCLIENT_IS_VCONN_HANDLE(hnd) \ 275 (((int)(hnd) >= BSPROXY_VCONN_MOD_MIN) && \ 276 ((int)(hnd) <= BSPROXY_VCONN_MOD_MAX)) 285 #define BSCLIENT_HAS_VCONN(pClient, hnd) \ 286 (BSCLIENT_IS_VCONN_HANDLE(hnd) && bsClientAttrHasVConn(pClient, hnd)) 308 extern void bsLogBuf(
const char *sBufName, byte_t buf[],
size_t uCount);
310 extern void bsLogAsciiBuf(
const char *sBufName, byte_t buf[],
size_t uCount);
319 extern BsClient_P
bsClientNew(
const char *sClientName);
336 uint_t *pRspTimeout);
373 const char *sPreface,
384 const char *sServerHostName,
402 const char *sDevName,
403 const char *sModName,
423 #endif // _BSCLIENT_H BsClient_P bsClientNew(const char *sClientName)
Create a new unconnected proxied client.
void bsClientAttrSetTimeouts(BsClient_P pClient, uint_t uReqTimeout, uint_t uRspTimeout)
Set client request (write) and response (read) timeouts.
void bsClientFillMsgHdr(BsClient_P pClient, BsVConnHnd_T hndVConn, uint_t uMsgId, size_t uBodyLen, BsProxyMsgHdr_T *pMsgHdr)
Fill in message header.
int bsPackMsgHdr(BsProxyMsgHdr_T *pMsgHdr, byte_t buf[], size_t bufSize)
Pack <b><i>BotSense</i></b> bsProxy message header.
int bsServerReqGetVersion(BsClient_P pClient, char buf[], size_t sizeBuf)
Request server to return the server's version string.
byte_t m_vconn
virtual connection handle
const char * brief
brief one-line description
bool_t m_bIsConnected
client is [not] connected to server
const char * date
version date
int bsServerReqGetVConnList(BsClient_P pClient, BsVecHandles_T *pVecHandles)
Request server to retrieve the server's list of virtual connection handles for this client...
const char * bsStrError(int nECode)
Get the error string describing the <b><i>BotSense</i></b> error code.
const char * maintainer
maintainer/owner
The Client Structure Type.
const char * license
short license/copyright statement
const char * m_sServerHostName
server host name
const char * version
dotted version x.y.z[-app]
const char * bsClientGetMsgName(BsClient_P pClient, BsVConnHnd_T hndVConn, uint_t uMsgId)
Get the message name.
bool_t bsClientAttrGetTraceState(BsClient_P pClient, BsVConnHnd_T hndVConn)
Get client virtual connection trace state.
int bsServerDisconnect(BsClient_P pClient)
Disconnect from the bsProxy server.
int bsServerReqLoopback(BsClient_P pClient, char sLoopbackMsg[])
Request server to loopback the requested message data.
const char * bsClientAttrGetName(BsClient_P pClient)
Get client name.
void bsClientDelete(BsClient_P pClient)
Delete a proxied client.
int bsServerReqOpenDev(BsClient_P pClient, const char *sDevName, const char *sModName, byte_t argbuf[], size_t arglen, const BsClientAppInfo_T *pAppInfo, bool_t bTrace)
Request server to establish a virtual connection to the device end point.
const char * bsClientAttrGetModName(BsClient_P pClient, BsVConnHnd_T hndVConn)
Get client virtual connection interface module name.
int bsClientAttrGetVConnCount(BsClient_P pClient)
Get the number of active virtual connections for this client.
void bsLogAsciiBuf(const char *sBufName, byte_t buf[], size_t uCount)
Log ascii data bytes.
int bsUnpackMsgHdr(byte_t buf[], size_t bufSize, BsProxyMsgHdr_T *pMsgHdr)
Unpack <b><i>BotSense</i></b> bsProxy message header.
<b><i>BotSense</i></b> client library information and callbacks to application-specific data...
void bsClientAttrSetLogging(BsClient_P pClient, int nLevel)
Set client's diagnostics logging threshold.
const char * bsClientAttrGetDevName(BsClient_P pClient, BsVConnHnd_T hndVConn)
Get client virtual connection device name.
size_t m_uCount
vector length
bool_t bsClientAttrHasVConn(BsClient_P pClient, BsVConnHnd_T hndVConn)
Test if client has a virtual connection identified by the handle.
void bsClientAttrGetTimeouts(BsClient_P pClient, uint_t *pReqTimeout, uint_t *pRspTimeout)
Get client request (write) and response (read) timeouts.
int bsServerConnect(BsClient_P pClient, const char *sServerHostName, int ipPortServer)
Connect to the bsProxy server.
#define BSCLIENT_INFO_STR_MAX_SIZE
void bsClientAttrGetConnState(BsClient_P pClient, BsClientConnState_T *pConnState)
Get client's connection state.
void bsClientLogMsgHdr(BsClient_P pClient, const char *sPreface, BsProxyMsgHdr_T *pMsgHdr)
Log [pre/un]packed message header.
int bsClientTrans(BsClient_P pClient, int hndVConn, uint_t uReqMsgId, byte_t bufReq[], size_t uReqBodyLen, uint_t uRspMsgId, byte_t bufRsp[], size_t sizeRspBuf)
Execute a request - response transaction with the server.
int bsServerReqCloseDev(BsClient_P pClient, BsVConnHnd_T hndVConn)
Request server to close a client's vitual connection.
BotSense Proxy Message Header Structure.
struct _bsClientStruct * BsClient_P
Pointer to client structure forward declaration.
#define BSPROXY_VCONN_CLIENT_MAX
max number of virtual conn/client
int m_rd
resource descriptor
int bsServerReqMsgTrace(BsClient_P pClient, BsVConnHnd_T hndVConn, bool_t bTrace)
Request server to enable/disable message tracing on a virtual connection.
int bsServerReqGetVConnInfo(BsClient_P pClient, BsVConnHnd_T hndVConn, BsVConnInfo_T *pVConnInfo)
Request server to retrieve the server's information for a given virtual connection.
const char * app_name
application name
<b><i>BotSense</i></b> package top-level, unifying header declarations.
int BsVConnHnd_T
virtual connection handle type
void bsLogBuf(const char *sBufName, byte_t buf[], size_t uCount)
Log data bytes.
int bsServerReqSetLogging(BsClient_P pClient, int nLogLevel)
Request server to set the server's logging level.