48 #include <sys/types.h> 56 #include "rnr/rnrconfig.h" 59 #include "rnr/netmsgs.h" 78 .brief =
"The /dev/null proxied device.",
81 .maintainer =
"RaodNarrows LLC",
82 .license =
"(C) 2010 RoadNarrows LLC. All rights reserved." 100 #define BSMOD_MAX_HANDLES BSPROXY_VCONN_MOD_NUMOF 144 if( pCtlBlk != NULL )
183 "Module vconn handle out-of-range.");
190 if( pCtlBlk == NULL )
193 "No resources for virtual connection found.");
206 "MsgId=%u", uMsgIdReq);
220 "write(fd=%d, ...).", pCtlBlk->
m_fd);
224 LOGDIAG3(
"VConn=%d: %d=write(fd=%d, buf=%p, count=%zu).",
240 "MsgId=%u", uMsgIdRsp);
247 BsModCallbacks->
m_cbSendRsp(hndVConn, uTid, uMsgIdRsp, bufRsp, (
size_t)n);
273 BsModCallbacks = pCallbacks;
298 if( pCtlBlk->
m_fd >= 0 )
300 close(pCtlBlk->
m_fd);
353 "InUseCount=%u: No more resources available.",
362 "Module virtual connection handle already in use");
367 fd = open(sDevUri, O_WRONLY);
381 LOGDIAG2(
"VConn=%d: %d=open(dev=%s, ...).", hndVConn, fd, sDevUri);
408 "Resources for virtual connection not found.");
416 if( pCtlBlk == NULL )
422 if( pCtlBlk->
m_fd >= 0 )
424 close(pCtlBlk->
m_fd);
425 LOGDIAG2(
"VConn=%d: close(fd=%d).", hndVConn, pCtlBlk->
m_fd);
458 "Module vconn handle out-of-range.");
466 if( pCtlBlk == NULL )
469 "No resources for virtual connection found.");
479 "MsgId=%u.", uMsgIdReq);
500 "Module vconn handle out-of-range.");
508 if( pCtlBlk == NULL )
511 "No resources for virtual connection found.");
uint_t BsMsgId_T
client message id type [0-64k].
#define BSMOD_LOG_ERROR(hndVConn, ecode, efmt,...)
Log Interface Module Error.
static const BsModProxyCb_T * BsModCallbacks
module to bsProxy callbacks
#define BS_ECODE_UNKNOWN_REQ
unknown request
Useful indirect indexing of handle to resource instance structure.
#define BSMOD_RSRC_IS_INUSE(pRsrcTbl, hndVConn)
Test if the resource table resource handle slot is in-use.
int bsModRequest(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
Service an /dev/null request.
int bsModClose(BsVConnHnd_T hndVConn)
Close the /dev/null device and disassociate virtual connection handle.
void(* m_cbModRsrcTblDelete)(BsModRsrcTbl_T *pRsrcTbl)
Delete an allocated resource table.
static BsModCtlBlk_T * bsModCtlBlkNew(int fd, bool_t bTrace)
Allocate a new resource control block.
uint_t BsTid_T
client transaction id type [0-255].
#define BSMOD_LOG_SYSERROR(hndVConn, efmt,...)
Log Interface Module System Error.
union BsNullReqWrite_T::@8::@9 u
aligned vector items
Module resource control block structure type.
bool_t m_bTrace
do [not] trace messages
INLINE_IN_H int BsNullUnpackReqWrite(byte_t buf[], size_t uMsgLen, BsNullReqWrite_T *pStruct, bool_t bTrace)
Unpack a BsNullReqWrite ITV message in big-endian byte order from the input buffer.
#define BSMOD_IS_VCONN_HANDLE(hndVConn)
Test if the handle is in the valid module virtual connection range.
<b><i>BotSense</i></b> bsProxy client library /dev/null interface.
int(* m_cbModRsrcAdd)(BsModRsrcTbl_T *pRsrcTbl, BsVConnHnd_T hndVConn, void *pRsrc)
Add a new resource to the resource table.
#define BS_OK
not an error, success
#define BS_ECODE_BAD_VCONN_HND
bad virtual connection handle
#define BS_ECODE_SYS
system (errno) error
const char * mod_name
module load name sans OS dependent substrings
static BsModRsrcTbl_T * BsModRsrcTbl
module resource table
#define BSMOD_TRY_VCONN_HND_RANGE(hndVConn)
Check if handle is within the range of module handles.
Interface Module callbacks to bsProxy services type.
<b><i>BotSense</i></b> client library declarations.
#define BS_ECODE_BAD_MSG
bad message
#define BS_NULL_SERVER_MOD
server plugin dll module
int bsModTrace(BsVConnHnd_T hndVConn, bool_t bTrace)
Enable/disable message tracing on handle.
#define BSMOD_RSRC_INUSE_COUNT(pRsrcTbl)
Get the resouce table current in-use count.
#define BSMOD_MAX_HANDLES
Maximum number of module supported simultaneous virtual connections.
void(* m_cbSendRsp)(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufRsp[], size_t uRspLen)
Send module-specific repsonse callback function.
static const char * BsModUri
module canonical name
INLINE_IN_H int BsNullPackRspWrite(BsNullRspWrite_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsNullRspWrite ITV message in big-endian byte order into the output buffer.
const BsModInfo_T * bsModInfo()
Query for the static module information.
int bsModOpen(BsVConnHnd_T hndVConn, bool_t bTrace, const char *sDevUri, byte_t argbuf[], size_t uArgSize)
Open an /dev/null device and associate with the given handle.
#define BS_ECODE_NO_RSRC
no resource available
#define BSMOD_RSRC(pRsrcTbl, hndVConn)
Get the resource given the handle.
Standard bsProxy static interface module information structure type.
void bsModExit()
Exit /dev/null module.
void *(* m_cbModRsrcRemove)(BsModRsrcTbl_T *pRsrcTbl, BsVConnHnd_T hndVConn)
Remove a resource from the resource table.
#define BSMOD_SEND_NMERROR_RSP(pCb, hndVConn, uTid, nmecode, efmt,...)
Log NetMsgs (Un)Packing Error and Send Error Response.
<b><i>BotSense</i></b> bsProxy Dynamically Linked Library module interface.
BsModRsrcTbl_T *(* m_cbModRsrcTblNew)(int nMaxResources)
Allocatae a new module resource table of fixed size.
struct BsNullReqWrite_T::@8 m_writebuf
vector
byte_t m_byteswritten
byteswritten
static void bsModCtlBlkDelete(BsModCtlBlk_T *pCtlBlk)
Delete an allocated resource control block.
#define BS_ECODE_INTERNAL
internal error (bug)
#define BSPROXY_BUF_BODY(buf)
Convenience macro to produce a buffer (offset, size) 2-tuple.
#define BS_ECODE_NO_VCONN
virtual connection not found
#define BSMOD_SEND_SYSERROR_RSP(pCb, hndVConn, uTid, efmt,...)
Log System Error and Send Error Response.
#define BSPROXY_MSG_MAX_LEN
total message maximum length
void ** m_vecRsrc
vecRsrc[index] -> rsrc
int bsModInit(const char *sModUri, const BsModProxyCb_T *pCallbacks)
Initialize /dev/null module.
#define BSMOD_SEND_ERROR_RSP(pCb, hndVConn, uTid, ecode, efmt,...)
Log <b><i>BotSense</i></b> Error and Send Error Response.
#define BS_ECODE_BUSY
resource busy
<b><i>BotSense</i></b> package top-level, unifying header declarations.
size_t m_count
vector item count
BotSense bsProxy server - client /dev/null NetMsgs XML Definition.
int BsVConnHnd_T
virtual connection handle type
static int bsModNullReqWrite(BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgIdReq, byte_t bufReq[], size_t uReqLen)
Service a /dev/null write request.
int m_fd
/dev/null open file descriptor
static BsModInfo_T BsModInfo
Module static information.