54 #include "rnr/rnrconfig.h" 76 #define _BS_LOG_VCONN_OPEN(pClient, index) \ 79 if( LOGABLE(LOG_LEVEL_DIAG2) ) \ 81 bsLogVConnOpenEvent(pClient, index); \ 102 fprintf(fp,
"%s: internal data corruption.\n", pClient->
m_sClientName);
108 fprintf(fp,
"%s: Opened Virtual Connection\n", pClient->
m_sClientName);
110 fprintf(fp,
" VConn: %d\n", pVConn->
m_hndVConn);
111 fprintf(fp,
" Device: %s\n", pVConn->
m_sDevName);
112 fprintf(fp,
" I/F Module: %s\n", pVConn->
m_sModName);
113 if( pAppInfo != NULL )
115 fprintf(fp,
" Application = {\n");
118 fprintf(fp,
" Name: %s\n", pAppInfo->
app_name);
120 if( pAppInfo->
brief != NULL )
122 fprintf(fp,
" Brief: %s\n", pAppInfo->
brief);
124 if( pAppInfo->
version != NULL )
126 fprintf(fp,
" Version: %s\n", pAppInfo->
version);
128 if( pAppInfo->
date != NULL )
130 fprintf(fp,
" Date: %s\n", pAppInfo->
date);
134 fprintf(fp,
" Maintainer: %s\n", pAppInfo->
maintainer);
148 #define _BS_LOG_VCONN_OPEN(pClient, hndVConn) 168 const char *sServerHostName,
174 if( SocketStateIsOpen(pClient->
m_pSocket) )
180 pSocket = SocketOpenTcpConnection(sServerHostName, ipServerPort);
182 if( pSocket == NULL )
185 "%s:%d", sServerHostName, ipServerPort);
190 SocketAttrSetNonBlocking(pSocket);
192 LOGDIAG2(
"%s: Connected to server at %s.\n",
209 if( SocketStateIsOpen(pClient->
m_pSocket) )
211 LOGDIAG2(
"%s: Disconnected from server at %s.\n",
248 m = strlen(sLoopbackMsg) + 1;
249 if(
sizeof(msgReq.
m_cdata) < m )
254 strcpy_s(msgReq.
m_cdata, m, sLoopbackMsg);
268 msgIdReq, buf, (
size_t)n,
269 msgIdRsp, buf,
sizeof(buf));
285 strcpy_s(sLoopbackMsg, m, msgRsp.
m_cdata);
328 msgIdReq, buf, (
size_t)n,
329 msgIdRsp, buf,
sizeof(buf));
379 msgIdReq, buf, (
size_t)0,
380 msgIdRsp, buf,
sizeof(buf));
396 strcpy_s(bufVer, bufSize, msgRsp.
m_version);
429 msgReq.
m_vconn = (byte_t)hndVConn;
444 msgIdReq, buf, (
size_t)n,
445 msgIdRsp, buf,
sizeof(buf));
486 const char *sDevName,
487 const char *sModName,
522 if((index=
bsVConnNew(pClient, sDevName, sModName, pAppInfo, bInitTrace)) < 0)
536 memcpy(msgReq.
m_argbuf.
u.m_buf, argbuf, arglen);
552 msgIdReq, buf, (
size_t)n,
553 msgIdRsp, buf,
sizeof(buf))) < 0 )
621 msgReq.
m_vconn = (byte_t)hndVConn;
635 msgIdReq, buf, (
size_t)n,
636 msgIdRsp, buf,
sizeof(buf));
657 LOGDIAG2(
"%s: Virtual connecton %u closed.",
699 msgIdReq, buf, (
size_t)0,
700 msgIdRsp, buf,
sizeof(buf));
761 msgReq.
m_vconn = (byte_t)hndVConn;
775 msgIdReq, buf, (
size_t)n,
776 msgIdRsp, buf,
sizeof(buf));
char m_cdata[(NMFVAL_LEN_MAX_STRING)+1]
cdata
BsVConnHnd_T m_hndVConn
virtual connection handle
const BsClientAppInfo_T * m_pAppInfo
app-specific info (optional)
BsVConn_T * m_tblVConn[BSPROXY_VCONN_CLIENT_MAX]
table of virtual connections
int bsVConnNew(BsClient_T *pClient, const char *sDevName, const char *sModName, const BsClientAppInfo_T *pAppInfo, bool_t bTrace)
Reserve a new client vConnection (and proxied device) in the client's tblVConn table.
const char * m_sModName
interface module path name
#define BSCLIENT_TRY_ECODE(pClient, ecode, efmt,...)
Check if <b><i>BotSense</i></b> return value is not an error ( < 0).
#define BS_ECODE_BAD_VAL
bad value
BotSense client application - bsProxy server-terminated core messages.
#define BSPROXY_REQDEVOPEN_MODNAME_LEN
int bsServerReqGetVConnInfo(BsClient_P pClient, BsVConnHnd_T hndVConn, BsVConnInfo_T *pVConnInfo)
Request server to retrieve the server's information for a given virtual connection.
The libBotSense internal declarations.
int bsServerReqLoopback(BsClient_P pClient, char sLoopbackMsg[])
Request server to loopback the requested message data.
char m_modname[(NMFVAL_LEN_MAX_STRING)+1]
modname
Socket_T * m_pSocket
IP socket to server.
Client Virtual Connection Info Structure.
union BsProxyRspGetVConnList_T::@12::@13 u
aligned vector items
INLINE_IN_H int BsProxyPackReqLoopback(BsProxyReqLoopback_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsProxyReqLoopback ITV message in big-endian byte order into the output buffer.
int bsVConnRemove(BsClient_T *pClient, BsVConnHnd_T hndVConn)
Remove a vConnection from the client's tblHndIndex table.
INLINE_IN_H int BsProxyPackReqDevClose(BsProxyReqDevClose_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsProxyReqDevClose ITV message in big-endian byte order into the output buffer.
byte_t m_vconn
virtual connection handle
const char * brief
brief one-line description
#define BS_ECODE_SERVER_CONN_FAIL
cannot connect to server
char m_cdata[(NMFVAL_LEN_MAX_STRING)+1]
cdata
#define BSPROXY_VCONN_SERVER
handle for server-terminated msgs
const char * date
version date
#define BSCLIENT_LOG_SYSERROR(pClient, ecode, efmt,...)
Log System Error.
INLINE_IN_H int BsProxyPackReqGetVConnInfo(BsProxyReqGetVConnInfo_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsProxyReqGetVConnInfo ITV message in big-endian byte order into the output buffer...
const char * maintainer
maintainer/owner
int bsServerDisconnect(BsClient_P pClient)
Disconnect from the bsProxy server.
#define BSCLIENT_LOG_ERROR(pClient, ecode, efmt,...)
Log Error.
The Client Structure Type.
int bsServerReqGetVConnList(BsClient_P pClient, BsVecHandles_T *pVecHandles)
Request server to retrieve the server's list of virtual connection handles for this client...
INLINE_IN_H int BsProxyUnpackRspGetVConnList(byte_t buf[], size_t uMsgLen, BsProxyRspGetVConnList_T *pStruct, bool_t bTrace)
Unpack a BsProxyRspGetVConnList ITV message in big-endian byte order from the input buffer...
#define BS_OK
not an error, success
BsVConnHnd_T m_vecHnd[BSPROXY_VCONN_CLIENT_MAX]
vector of handles
struct BsProxyRspGetVConnList_T::@12 m_vconn
vector
INLINE_IN_H int BsProxyPackReqMsgTrace(BsProxyReqMsgTrace_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsProxyReqMsgTrace ITV message in big-endian byte order into the output buffer.
const char * version
dotted version x.y.z[-app]
INLINE_IN_H int BsProxyUnpackRspDevOpen(byte_t buf[], size_t uMsgLen, BsProxyRspDevOpen_T *pStruct, bool_t bTrace)
Unpack a BsProxyRspDevOpen ITV message in big-endian byte order from the input buffer.
#define BSCLIENT_LOG_NM_ERROR(pClient, nmecode, efmt,...)
Log NetMsgs Error.
size_t m_count
vector item count
int bsServerReqMsgTrace(BsClient_P pClient, BsVConnHnd_T hndVConn, bool_t bNewTrace)
Request server to enable/disable message tracing on a virtual connection.
INLINE_IN_H int BsProxyPackReqSetLogging(BsProxyReqSetLogging_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsProxyReqSetLogging ITV message in big-endian byte order into the output buffer.
int bsVConnAdd(BsClient_T *pClient, BsVConnHnd_T hndVConn, int index)
Add a created vConnection to the client's tblHndIndex table.
char m_moddate[256]
i/f module date
int bsServerReqGetVersion(BsClient_P pClient, char bufVer[], size_t bufSize)
Request server to return the server's version string.
char m_modver[256]
i/f module version
<b><i>BotSense</i></b> client library declarations.
#define BS_ECODE_BAD_MSG
bad message
#define BSPROXY_REQDEVOPEN_DEVNAME_LEN
const char * m_sDevName
device path name
char m_devuri[(NMFVAL_LEN_MAX_STRING)+1]
devuri
int bsServerReqCloseDev(BsClient_P pClient, BsVConnHnd_T hndVConn)
Request server to close a client's vitual connection.
static void bsLogVConnOpenEvent(BsClient_T *pClient, int index)
Log virtual connection open event.
<b><i>BotSense</i></b> client library information and callbacks to application-specific data...
#define _BS_LOG_VCONN_OPEN(pClient, index)
Log virtual connection open event.
char m_version[(NMFVAL_LEN_MAX_STRING)+1]
version
int bsServerReqSetLogging(BsClient_P pClient, int nLogLevel)
Request server to set the server's logging level.
char m_client[256]
client name
int bsVConnDelete(BsClient_T *pClient, int index)
Delete a vConnection (and proxied device) from the client's tblVConn table.
INLINE_IN_H int BsProxyUnpackRspGetVConnInfo(byte_t buf[], size_t uMsgLen, BsProxyRspGetVConnInfo_T *pStruct, bool_t bTrace)
Unpack a BsProxyRspGetVConnInfo ITV message in big-endian byte order from the input buffer...
void bsVConnClearAll(BsClient_T *pClient)
Remove and delete all of a client's vConnections.
size_t m_uCount
vector length
union BsProxyReqDevOpen_T::@10::@11 u
aligned vector items
struct BsProxyReqDevOpen_T::@10 m_argbuf
vector
const char * m_sClientName
client name
char m_moduri[256]
i/f module URI
#define BSCLIENT_TRY_EXPR(pClient, expr, ecode, efmt,...)
Check if expression evaluates to true.
int bsServerConnect(BsClient_P pClient, const char *sServerHostName, int ipServerPort)
Connect to the bsProxy server.
size_t m_count
vector item count
INLINE_IN_H int BsProxyUnpackRspGetVersion(byte_t buf[], size_t uMsgLen, BsProxyRspGetVersion_T *pStruct, bool_t bTrace)
Unpack a BsProxyRspGetVersion ITV message in big-endian byte order from the input buffer...
char m_client[(NMFVAL_LEN_MAX_STRING)+1]
client
#define BSPROXY_VCONN_CLIENT_MAX
max number of virtual conn/client
INLINE_IN_H int BsProxyUnpackRspLoopback(byte_t buf[], size_t uMsgLen, BsProxyRspLoopback_T *pStruct, bool_t bTrace)
Unpack a BsProxyRspLoopback ITV message in big-endian byte order from the input buffer.
int bsServerReqOpenDev(BsClient_P pClient, const char *sDevName, const char *sModName, byte_t argbuf[], size_t arglen, const BsClientAppInfo_T *pAppInfo, bool_t bInitTrace)
Request server to establish a virtual connection to the device end point.
#define BSPROXY_BUF_BODY(buf)
Convenience macro to produce a buffer (offset, size) 2-tuple.
#define BSCLIENT_HAS_VCONN(pClient, hnd)
Tests if the handle is valid and there is an established virtual connection.
#define BSPROXY_REQDEVOPEN_ARGBUF_LEN
#define BSCLIENT_TRY_NM_ECODE(pClient, nmecode, efmt,...)
Check if NetMsgs (un)packing return value is not an error ( < 0).
int m_rd
resource descriptor
#define BSPROXY_MSG_MAX_LEN
total message maximum length
char m_devname[(NMFVAL_LEN_MAX_STRING)+1]
devname
char m_modver[(NMFVAL_LEN_MAX_STRING)+1]
modver
INLINE_IN_H int BsProxyPackReqDevOpen(BsProxyReqDevOpen_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsProxyReqDevOpen ITV message in big-endian byte order into the output buffer.
const char * app_name
application name
<b><i>BotSense</i></b> package top-level, unifying header declarations.
char m_moduri[(NMFVAL_LEN_MAX_STRING)+1]
moduri
int BsVConnHnd_T
virtual connection handle type
char m_devuri[256]
device URI
char m_moddate[(NMFVAL_LEN_MAX_STRING)+1]
moddate