botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
bsProxyRequest.c
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: BotSense
4 //
5 // Program: bsProxy
6 //
7 // File: bsProxyRequest.c
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2010-08-20 11:36:38 -0600 (Fri, 20 Aug 2010) $
12  * $Rev: 568 $
13  *
14  * \brief \h_botsense bsProxy server-terminated requests.
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  *
18  * \copyright
19  * \h_copy 2007-2017. RoadNarrows LLC.\n
20  * http://www.roadnarrows.com\n
21  * All Rights Reserved
22  */
23 // Permission is hereby granted, without written agreement and without
24 // license or royalty fees, to use, copy, modify, and distribute this
25 // software and its documentation for any purpose, provided that
26 // (1) The above copyright notice and the following two paragraphs
27 // appear in all copies of the source code and (2) redistributions
28 // including binaries reproduces these notices in the supporting
29 // documentation. Substantial modifications to this software may be
30 // copyrighted by their authors and need not follow the licensing terms
31 // described here, provided that the new terms are clearly indicated in
32 // all files where they apply.
33 //
34 // IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
35 // OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
36 // PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
37 // DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
38 // EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
39 // THE POSSIBILITY OF SUCH DAMAGE.
40 //
41 // THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
42 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
43 // FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
44 // "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
45 // PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
46 //
47 ////////////////////////////////////////////////////////////////////////////////
48 
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <string.h>
52 
53 #include "rnr/rnrconfig.h"
54 #include "rnr/log.h"
55 #include "rnr/new.h"
56 
57 #include "botsense/BotSense.h"
58 #include "botsense/bsProxyModIF.h"
59 #include "botsense/bsProxyMsgs.h"
60 
61 #include "bsProxy.h"
62 #include "version.h"
63 
64 
65 // ---------------------------------------------------------------------------
66 // Private Interface
67 // ---------------------------------------------------------------------------
68 
69 /*!
70  * \brief Service client's request to perform a loopback.
71  *
72  * \par Execution Context:
73  * Server service thread.
74  *
75  * \param hndClient \h_botsense client handle.
76  * \param hndVConn Virtual connection handle.
77  * \param uTid Request-response transaction id.
78  * \param uMsgId Request message id.
79  * \param [in] bufReq Packed request message body buffer.
80  * \param uReqLen Length of packed request (number of bytes).
81  * \param bTrace Do [not] trace this request-repsonse.
82  *
83  * \copydoc doc_return_std
84  */
85 static int ReqLoopback(BsProxyClientHnd_T hndClient,
86  BsVConnHnd_T hndVConn,
87  BsTid_T uTid,
88  BsMsgId_T uMsgId,
89  byte_t bufReq[],
90  size_t uReqLen,
91  bool_t bTrace)
92 {
93  static BsProxyMsgId_T uMsgIdRsp = BsProxyMsgIdRspLoopback;
94 
95  BsProxyReqLoopback_T msgReq;
96  BsProxyRspLoopback_T msgRsp;
97  int rc;
98 
99  //
100  // Unpack client request.
101  //
102  rc = BsProxyUnpackReqLoopback(bufReq, uReqLen, &msgReq, bTrace);
103 
104  if( rc < 0 )
105  {
106  BSPROXY_SEND_NMERROR_RSP(hndClient, hndVConn, uTid, rc, "MsgId=%u", uMsgId);
107  return -BS_ECODE_BAD_MSG;
108  }
109 
110  //
111  // Execute client request.
112  //
114 
115  // print to standard error
116  fprintf(stderr, "%s: %s\n", ClientHasName(hndClient), msgReq.m_cdata);
117 
118  //
119  // Fill in response.
120  //
121  strcpy_s(msgRsp.m_cdata, BSPROXY_RSPLOOPBACK_CDATA_LEN+1, msgReq.m_cdata);
122 
123  //
124  // Send server response.
125  //
126  rc = ClientSendServerRsp(hndClient, uTid, uMsgIdRsp, &msgRsp);
127 
128  return rc;
129 }
130 
131 /*!
132  * \brief Service client's request to set the server's logging level.
133  *
134  * \par Execution Context:
135  * Server service thread.
136  *
137  * \param hndClient \h_botsense client handle.
138  * \param hndVConn Virtual connection handle.
139  * \param uTid Request-response transaction id.
140  * \param uMsgId Request message id.
141  * \param [in] bufReq Packed request message body buffer.
142  * \param uReqLen Length of packed request (number of bytes).
143  * \param bTrace Do [not] trace this request-repsonse.
144  *
145  * \copydoc doc_return_std
146  */
147 static int ReqSetLogging(BsProxyClientHnd_T hndClient,
148  BsVConnHnd_T hndVConn,
149  BsTid_T uTid,
150  BsMsgId_T uMsgId,
151  byte_t bufReq[],
152  size_t uReqLen,
153  bool_t bTrace)
154 {
155  BsProxyReqSetLogging_T msgReq;
156  int rc;
157 
158  //
159  // Unpack client request.
160  //
161  rc = BsProxyUnpackReqSetLogging(bufReq, uReqLen, &msgReq, bTrace);
162 
163  if( rc < 0 )
164  {
165  BSPROXY_SEND_NMERROR_RSP(hndClient, hndVConn, uTid, rc, "MsgId=%u", uMsgId);
166  return -BS_ECODE_BAD_MSG;
167  }
168 
169  //
170  // Execute client request.
171  //
172  LOG_SET_THRESHOLD(msgReq.m_level);
173 
174  //
175  // Send server response.
176  //
177  return ClientSendOkRsp(hndClient, uTid);
178 }
179 
180 /*!
181  * \brief Service client's request to set server or client terminated message
182  * tracing.
183  *
184  * \par Execution Context:
185  * Server service thread.
186  *
187  * \param hndClient \h_botsense client handle.
188  * \param hndVConn Virtual connection handle.
189  * \param uTid Request-response transaction id.
190  * \param uMsgId Request message id.
191  * \param [in] bufReq Packed request message body buffer.
192  * \param uReqLen Length of packed request (number of bytes).
193  * \param bTrace Do [not] trace this request-repsonse.
194  *
195  * \copydoc doc_return_std
196  */
197 static int ReqMsgTrace(BsProxyClientHnd_T hndClient,
198  BsVConnHnd_T hndVConn,
199  BsTid_T uTid,
200  BsMsgId_T uMsgId,
201  byte_t bufReq[],
202  size_t uReqLen,
203  bool_t bTrace)
204 {
205  BsProxyReqMsgTrace_T msgReq;
206  BsProxyVConn_T *pVConn;
207  int rc;
208 
209  //
210  // Unpack client request.
211  //
212  rc = BsProxyUnpackReqMsgTrace(bufReq, uReqLen, &msgReq, bTrace);
213 
214  if( rc < 0 )
215  {
216  BSPROXY_SEND_NMERROR_RSP(hndClient, hndVConn, uTid, rc, "MsgId=%u", uMsgId);
217  return -BS_ECODE_BAD_MSG;
218  }
219 
220  //
221  // Execute client request.
222  //
223  if( msgReq.m_vconn == BSPROXY_VCONN_SERVER )
224  {
225  ClientSetTraceState(hndClient, msgReq.m_trace);
226  }
227  else if( (pVConn = VConnAcquire(msgReq.m_vconn)) == NULL )
228  {
229  BSPROXY_SEND_ERROR_RSP(hndClient, hndVConn, uTid, BS_ECODE_NO_VCONN,
230  "VConn=%d", msgReq.m_vconn);
231  return -BS_ECODE_NO_VCONN;
232  }
233  else
234  {
235  pVConn->m_pModIF->m_fnModTrace(msgReq.m_vconn, msgReq.m_trace);
236  VConnRelease(msgReq.m_vconn);
237  }
238 
239  //
240  // Send server response.
241  //
242  return ClientSendOkRsp(hndClient, uTid);
243 }
244 
245 /*!
246  * \brief Service client's request to get the server's version.
247  *
248  * \par Execution Context:
249  * Server service thread.
250  *
251  * \param hndClient \h_botsense client handle.
252  * \param hndVConn Virtual connection handle.
253  * \param uTid Request-response transaction id.
254  * \param uMsgId Request message id.
255  * \param [in] bufReq Packed request message body buffer.
256  * \param uReqLen Length of packed request (number of bytes).
257  * \param bTrace Do [not] trace this request-repsonse.
258  *
259  * \copydoc doc_return_std
260  */
261 static int ReqGetVersion(BsProxyClientHnd_T hndClient,
262  BsVConnHnd_T hndVConn,
263  BsTid_T uTid,
264  BsMsgId_T uMsgId,
265  byte_t bufReq[],
266  size_t uReqLen,
267  bool_t bTrace)
268 {
269  static BsProxyMsgId_T uMsgIdRsp = BsProxyMsgIdRspGetVersion;
270 
271  BsProxyRspGetVersion_T msgRsp;
272  int rc;
273 
274  // Get the version strings.
275  sprintf_s(msgRsp.m_version, BSPROXY_RSPGETVERSION_VERSION_LEN+1,
276  "bsProxy %s %s", PKG_VERSION, PKG_TIMESTAMP);
277 
278  //
279  // Send server response.
280  //
281  rc = ClientSendServerRsp(hndClient, uTid, uMsgIdRsp, &msgRsp);
282 
283  return rc;
284 }
285 
286 /*!
287  * \brief Service client's request to open a proxied device virtual connection.
288  *
289  * \par Execution Context:
290  * Server service thread.
291  *
292  * \param hndClient \h_botsense client handle.
293  * \param hndVConn Virtual connection handle.
294  * \param uTid Request-response transaction id.
295  * \param uMsgId Request message id.
296  * \param [in] bufReq Packed request message body buffer.
297  * \param uReqLen Length of packed request (number of bytes).
298  * \param bTrace Do [not] trace this request-repsonse.
299  *
300  * \copydoc doc_return_std
301  */
302 static int ReqDevOpen(BsProxyClientHnd_T hndClient,
303  BsVConnHnd_T hndVConn,
304  BsTid_T uTid,
305  BsMsgId_T uMsgId,
306  byte_t bufReq[],
307  size_t uReqLen,
308  bool_t bTrace)
309 {
310  static BsProxyMsgId_T uMsgIdRsp = BsProxyMsgIdRspDevOpen;
311 
312  BsProxyReqDevOpen_T msgReq;
313  BsProxyRspDevOpen_T msgRsp;
314  BsProxyClientCtl_T *pClient;
315  int n;
316  int rc;
317 
318  //
319  // Unpack client request.
320  //
321  rc = BsProxyUnpackReqDevOpen(bufReq, uReqLen, &msgReq, bTrace);
322 
323  if( rc < 0 )
324  {
325  BSPROXY_SEND_NMERROR_RSP(hndClient, hndVConn, uTid, rc, "MsgId=%u", uMsgId);
326  return -BS_ECODE_BAD_MSG;
327  }
328 
329  //
330  // Execute client request.
331  //
332 
333  //
334  // Acquire the client, locking it from other threads. If it cannot be
335  // acquired, the client has a bad connection or is disconnected and is
336  // (being) unregistered. Don't send response message.
337  //
338  if( (pClient = ClientAcquire(hndClient)) == NULL )
339  {
341  }
342 
343  //
344  // Open a new virtual connection.
345  //
346  n = VConnOpenDev(hndClient, msgReq.m_devname, msgReq.m_modname,
347  msgReq.m_argbuf.u.m_buf, (size_t)msgReq.m_argbuf.m_count,
348  msgReq.m_trace);
349 
350  if( n >= 0 )
351  {
352  pClient->m_uRefCnt++;
353  }
354 
355  // Unlock the client. Response message may now be sent on this client.
356  ClientRelease(hndClient);
357 
358  if( n < 0 )
359  {
360  BSPROXY_SEND_ERROR_RSP(hndClient, hndVConn, uTid, n,
361  "DevName=%s, ModName=%s", msgReq.m_devname, msgReq.m_modname);
362  return -n;
363  }
364 
365  //
366  // Fill in response.
367  //
368  msgRsp.m_vconn = (byte_t)n;
369 
370  //
371  // Send server response.
372  //
373  rc = ClientSendServerRsp(hndClient, uTid, uMsgIdRsp, &msgRsp);
374 
375  return rc;
376 }
377 
378 /*!
379  * \brief Service client's request to close a device virtual connection.
380  *
381  * \par Execution Context:
382  * Server service thread.
383  *
384  * \param hndClient \h_botsense client handle.
385  * \param hndVConn Virtual connection handle.
386  * \param uTid Request-response transaction id.
387  * \param uMsgId Request message id.
388  * \param [in] bufReq Packed request message body buffer.
389  * \param uReqLen Length of packed request (number of bytes).
390  * \param bTrace Do [not] trace this request-repsonse.
391  *
392  * \copydoc doc_return_std
393  */
394 static int ReqDevClose(BsProxyClientHnd_T hndClient,
395  BsVConnHnd_T hndVConn,
396  BsTid_T uTid,
397  BsMsgId_T uMsgId,
398  byte_t bufReq[],
399  size_t uReqLen,
400  bool_t bTrace)
401 {
402  BsProxyReqDevClose_T msgReq;
403  BsProxyClientCtl_T *pClient;
404  int rc;
405 
406  //
407  // Unpack client request.
408  //
409  rc = BsProxyUnpackReqDevClose(bufReq, uReqLen, &msgReq, bTrace);
410 
411  if( rc < 0 )
412  {
413  BSPROXY_SEND_NMERROR_RSP(hndClient, hndVConn, uTid, rc, "MsgId=%u", uMsgId);
414  return -BS_ECODE_BAD_MSG;
415  }
416 
417  //
418  // Execute client request.
419  //
420 
421  //
422  // Acquire the client, locking it from other threads. If it cannot be
423  // acquired, the client has a bad connection or is disconnected and is (being)
424  // unregistered. Don't send response message.
425  //
426  if( (pClient = ClientAcquire(hndClient)) == NULL )
427  {
429  }
430 
431  if( (rc = VConnClose(hndClient, msgReq.m_vconn)) == BS_OK )
432  {
433  pClient->m_uRefCnt--;
434  }
435 
436  // Unlock the client. Response message may now be sent on this client.
437  ClientRelease(hndClient);
438 
439  if( rc < 0 )
440  {
441  BSPROXY_SEND_ERROR_RSP(hndClient, hndVConn, uTid, rc,
442  "VConn=%d", (int)msgReq.m_vconn);
443  return -rc;
444  }
445 
446  //
447  // Send server response.
448  //
449  return ClientSendOkRsp(hndClient, uTid);
450 }
451 
452 /*!
453  * \brief Service client's request to get the list of all of the client's
454  * opened virtual connection handles.
455  *
456  * \par Execution Context:
457  * Server service thread.
458  *
459  * \param hndClient \h_botsense client handle.
460  * \param hndVConn Virtual connection handle.
461  * \param uTid Request-response transaction id.
462  * \param uMsgId Request message id.
463  * \param [in] bufReq Packed request message body buffer.
464  * \param uReqLen Length of packed request (number of bytes).
465  * \param bTrace Do [not] trace this request-repsonse.
466  *
467  * \copydoc doc_return_std
468  */
469 static int ReqGetVConnList(BsProxyClientHnd_T hndClient,
470  BsVConnHnd_T hndVConn,
471  BsTid_T uTid,
472  BsMsgId_T uMsgId,
473  byte_t bufReq[],
474  size_t uReqLen,
475  bool_t bTrace)
476 {
477  static BsProxyMsgId_T uMsgIdRsp = BsProxyMsgIdRspGetVConnList;
478 
480  BsProxyVConn_T *pVConn;
481  int n, i;
482  int rc;
483 
484  //
485  // Execute client request.
486  //
487 
488  //
489  // Loop through the device virtual connections.
490  //
491  for(i=0, n=BSPROXY_VCONN_MOD_MIN; n<=BSPROXY_VCONN_MOD_MAX; ++n)
492  {
493  if( (pVConn = VConnAcquire(n)) != NULL )
494  {
495  // pointers point to the same client allocated object
496  if( pVConn->m_hndClient == hndClient )
497  {
498  msgRsp.m_vconn.u.m_buf[i++] = (byte_t)n;
499  }
500  VConnRelease(n);
501  }
502  }
503 
504  msgRsp.m_vconn.m_count = (size_t)i;
505 
506  //
507  // Send server response.
508  //
509  rc = ClientSendServerRsp(hndClient, uTid, uMsgIdRsp, &msgRsp);
510 
511  return rc;
512 }
513 
514 /*!
515  * \brief Service client's request to get a virtual connection's information.
516  *
517  * \par Execution Context:
518  * Server service thread.
519  *
520  * \param hndClient \h_botsense client handle.
521  * \param hndVConn Virtual connection handle.
522  * \param uTid Request-response transaction id.
523  * \param uMsgId Request message id.
524  * \param [in] bufReq Packed request message body buffer.
525  * \param uReqLen Length of packed request (number of bytes).
526  * \param bTrace Do [not] trace this request-repsonse.
527  *
528  * \copydoc doc_return_std
529  */
530 static int ReqGetVConnInfo(BsProxyClientHnd_T hndClient,
531  BsVConnHnd_T hndVConn,
532  BsTid_T uTid,
533  BsMsgId_T uMsgId,
534  byte_t bufReq[],
535  size_t uReqLen,
536  bool_t bTrace)
537 {
538  static BsProxyMsgId_T uMsgIdRsp = BsProxyMsgIdRspGetVConnInfo;
539 
542  BsProxyVConn_T *pVConn;
543  const BsModInfo_T *pModInfo;
544  int rc;
545 
546  //
547  // Unpack client request.
548  //
549  rc = BsProxyUnpackReqGetVConnInfo(bufReq, uReqLen, &msgReq, bTrace);
550 
551  if( rc < 0 )
552  {
553  BSPROXY_SEND_NMERROR_RSP(hndClient, hndVConn, uTid, rc, "MsgId=%u", uMsgId);
554  return -BS_ECODE_BAD_MSG;
555  }
556 
557  //
558  // Execute client request.
559  //
560 
561  if( (pVConn = VConnAcquire(msgReq.m_vconn)) != NULL )
562  {
563  msgRsp.m_vconn = (byte_t)pVConn->m_hndVConn;
564  msgRsp.m_rd = pVConn->m_rd;
565  strcpy_s(msgRsp.m_client, BSPROXY_RSPGETVCONNINFO_CLIENT_LEN+1,
566  ClientHasName(hndClient));
567  strcpy_s(msgRsp.m_devuri, BSPROXY_RSPGETVCONNINFO_DEVURI_LEN+1,
568  pVConn->m_pThCtl->m_sDevUri);
569  strcpy_s(msgRsp.m_moduri, BSPROXY_RSPGETVCONNINFO_MODURI_LEN+1,
570  pVConn->m_pModIF->m_sModUri);
571 
572  pModInfo = pVConn->m_pModIF->m_fnModInfo();
573 
574  strcpy_s(msgRsp.m_modver, BSPROXY_RSPGETVCONNINFO_MODVER_LEN+1,
575  pModInfo->version);
577  pModInfo->date);
578 
579  VConnRelease(msgReq.m_vconn);
580  }
581 
582  //
583  // Send server response.
584  //
585  rc = ClientSendServerRsp(hndClient, uTid, uMsgIdRsp, &msgRsp);
586 
587  return rc;
588 }
589 
590 
591 // ---------------------------------------------------------------------------
592 // Public Interface
593 // ---------------------------------------------------------------------------
594 
595 /*!
596  * \brief Server service thread request handler.
597  *
598  * \par Execution Context:
599  * Server service thread.
600  *
601  * \param hndClient \h_botsense client handle.
602  * \param hndVConn Virtual connection handle.
603  * \param uTid Request-response transaction id.
604  * \param uMsgId Request message id.
605  * \param [in] bufReq Packed request message body buffer.
606  * \param uReqLen Length of packed request (number of bytes).
607  *
608  * \copydoc doc_return_std
609  */
611  BsVConnHnd_T hndVConn,
612  BsTid_T uTid,
613  BsMsgId_T uMsgId,
614  byte_t bufReq[],
615  size_t uReqLen)
616 
617 {
618  bool_t bServerTrace = ClientGetTraceState(hndClient);
619 
620  switch( uMsgId )
621  {
623  return ReqLoopback(hndClient, hndVConn, uTid, uMsgId, bufReq, uReqLen,
624  bServerTrace);
625 
627  return ReqSetLogging(hndClient, hndVConn, uTid, uMsgId, bufReq, uReqLen,
628  bServerTrace);
629 
631  return ReqMsgTrace(hndClient, hndVConn, uTid, uMsgId, bufReq, uReqLen,
632  bServerTrace);
633 
635  return ReqGetVersion(hndClient, hndVConn, uTid, uMsgId, bufReq, uReqLen,
636  bServerTrace);
637 
639  return ReqDevOpen(hndClient, hndVConn, uTid, uMsgId, bufReq, uReqLen,
640  bServerTrace);
641 
643  return ReqDevClose(hndClient, hndVConn, uTid, uMsgId, bufReq, uReqLen,
644  bServerTrace);
645 
647  return ReqGetVConnList(hndClient, hndVConn, uTid, uMsgId, bufReq, uReqLen,
648  bServerTrace);
649 
651  return ReqGetVConnInfo(hndClient, hndVConn, uTid, uMsgId, bufReq, uReqLen,
652  bServerTrace);
653 
654  default:
655  BSPROXY_SEND_ERROR_RSP(hndClient, hndVConn, uTid, BS_ECODE_UNKNOWN_REQ,
656  "MsgId=%u", uMsgId);
657  return -BS_ECODE_UNKNOWN_REQ;
658  }
659 }
char m_cdata[(NMFVAL_LEN_MAX_STRING)+1]
cdata
Definition: bsProxyMsgs.h:109
uint_t BsMsgId_T
client message id type [0-64k].
Definition: BotSense.h:188
#define BSPROXY_RSPGETVCONNINFO_MODURI_LEN
Definition: bsProxyMsgs.h:266
#define BS_ECODE_UNKNOWN_REQ
unknown request
Definition: BotSense.h:81
<b><i>BotSense</i></b> bsProxy IP server declarations.
INLINE_IN_H int BsProxyUnpackReqSetLogging(byte_t buf[], size_t uMsgLen, BsProxyReqSetLogging_T *pStruct, bool_t bTrace)
Unpack a BsProxyReqSetLogging ITV message in big-endian byte order from the input buffer...
Definition: bsProxyMsgs.h:495
BsProxyClientCtl_T * ClientAcquire(BsProxyClientHnd_T hndClient)
Acquire client, locking it from other threads.
int VConnOpenDev(BsProxyClientHnd_T hndClient, const char *sDevName, const char *sModName, byte_t argbuf[], size_t uArgLen, bool_t bTrace)
Open a virtual device connection.
Definition: bsProxyVConn.c:325
static int ReqMsgTrace(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen, bool_t bTrace)
Service client&#39;s request to set server or client terminated message tracing.
int m_rd
module resource descriptor
Definition: bsProxy.h:227
BotSense client application - bsProxy server-terminated core messages.
static int ReqGetVersion(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen, bool_t bTrace)
Service client&#39;s request to get the server&#39;s version.
INLINE_IN_H int BsProxyUnpackReqMsgTrace(byte_t buf[], size_t uMsgLen, BsProxyReqMsgTrace_T *pStruct, bool_t bTrace)
Unpack a BsProxyReqMsgTrace ITV message in big-endian byte order from the input buffer.
Definition: bsProxyMsgs.h:581
void VConnRelease(BsVConnHnd_T hndVConn)
Release the locked virtual client.
Definition: bsProxyVConn.c:585
#define BSPROXY_RSPGETVCONNINFO_CLIENT_LEN
Definition: bsProxyMsgs.h:260
char m_modname[(NMFVAL_LEN_MAX_STRING)+1]
modname
Definition: bsProxyMsgs.h:179
static int ReqGetVConnInfo(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen, bool_t bTrace)
Service client&#39;s request to get a virtual connection&#39;s information.
union BsProxyRspGetVConnList_T::@12::@13 u
aligned vector items
static int ReqGetVConnList(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen, bool_t bTrace)
Service client&#39;s request to get the list of all of the client&#39;s opened virtual connection handles...
uint_t BsTid_T
client transaction id type [0-255].
Definition: BotSense.h:172
bool_t m_trace
trace
Definition: bsProxyMsgs.h:154
#define BSPROXY_SEND_NMERROR_RSP(hndClient, hndVConn, uTid, nmecode, efmt,...)
Log NetMsgs (Un)Packing Error and Send Error Response.
Definition: bsProxy.h:348
char m_cdata[(NMFVAL_LEN_MAX_STRING)+1]
cdata
Definition: bsProxyMsgs.h:92
#define BSPROXY_VCONN_SERVER
handle for server-terminated msgs
Definition: BotSense.h:140
BsProxyThCtl_T * m_pThCtl
service thread
Definition: bsProxy.h:225
#define BSPROXY_RSPGETVERSION_VERSION_LEN
Definition: bsProxyMsgs.h:132
void ClientRelease(BsProxyClientHnd_T hndClient)
Release the locked client.
INLINE_IN_H int BsProxyUnpackReqLoopback(byte_t buf[], size_t uMsgLen, BsProxyReqLoopback_T *pStruct, bool_t bTrace)
Unpack a BsProxyReqLoopback ITV message in big-endian byte order from the input buffer.
Definition: bsProxyMsgs.h:409
ReqGetVConnInfo.
Definition: bsProxyMsgs.h:51
static int ReqSetLogging(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen, bool_t bTrace)
Service client&#39;s request to set the server&#39;s logging level.
bool_t m_trace
trace
Definition: bsProxyMsgs.h:176
#define BS_OK
not an error, success
Definition: BotSense.h:66
#define BSPROXY_VCONN_MOD_MIN
minimum module-specific handle value
Definition: BotSense.h:141
struct BsProxyRspGetVConnList_T::@12 m_vconn
vector
#define BSPROXY_VCONN_MOD_MAX
maximum module-specific handle value
Definition: BotSense.h:142
static int ReqDevClose(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen, bool_t bTrace)
Service client&#39;s request to close a device virtual connection.
int BsProxyClientHnd_T
bsProxy server client handle
Definition: bsProxy.h:114
static int ReqDevOpen(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen, bool_t bTrace)
Service client&#39;s request to open a proxied device virtual connection.
int VConnClose(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn)
Close the virtual connection.
Definition: bsProxyVConn.c:478
RspGetVConnInfo.
Definition: bsProxyMsgs.h:52
#define PKG_VERSION
Definition: version.h:24
size_t m_count
vector item count
Definition: bsProxyMsgs.h:183
INLINE_IN_H int BsProxyUnpackReqGetVConnInfo(byte_t buf[], size_t uMsgLen, BsProxyReqGetVConnInfo_T *pStruct, bool_t bTrace)
Unpack a BsProxyReqGetVConnInfo ITV message in big-endian byte order from the input buffer...
Definition: bsProxyMsgs.h:796
BsModInfoFunc_P m_fnModInfo
static info
Definition: bsProxy.h:131
int ClientSendOkRsp(BsProxyClientHnd_T hndClient, BsTid_T uTid)
Send an ok response to the client.
static int ReqLoopback(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen, bool_t bTrace)
Service client&#39;s request to perform a loopback.
#define BSPROXY_RSPGETVCONNINFO_DEVURI_LEN
Definition: bsProxyMsgs.h:263
#define BS_ECODE_BAD_MSG
bad message
Definition: BotSense.h:76
INLINE_IN_H int BsProxyUnpackReqDevOpen(byte_t buf[], size_t uMsgLen, BsProxyReqDevOpen_T *pStruct, bool_t bTrace)
Unpack a BsProxyReqDevOpen ITV message in big-endian byte order from the input buffer.
Definition: bsProxyMsgs.h:624
INLINE_IN_H bool_t ClientGetTraceState(BsProxyClientHnd_T hndClient)
Get the <b><i>BotSense</i></b> client&#39;s server-terminated message trace state.
Definition: bsProxy.h:602
BsProxyVConn_T * VConnAcquire(BsVConnHnd_T hndVConn)
Acquire virtual connection, locking it from other threads.
Definition: bsProxyVConn.c:552
char m_devuri[(NMFVAL_LEN_MAX_STRING)+1]
devuri
Definition: bsProxyMsgs.h:283
#define BSPROXY_SEND_ERROR_RSP(hndClient, hndVConn, uTid, ecode, efmt,...)
Log <b><i>BotSense</i></b> Error and Send Error Response.
Definition: bsProxy.h:330
RspGetVConnList.
Definition: bsProxyMsgs.h:50
BsProxyClientHnd_T m_hndClient
proxied client handle
Definition: bsProxy.h:224
char m_version[(NMFVAL_LEN_MAX_STRING)+1]
version
Definition: bsProxyMsgs.h:139
BsModTraceFunc_P m_fnModTrace
tracing
Definition: bsProxy.h:130
int ServerRequest(BsProxyClientHnd_T hndClient, BsVConnHnd_T hndVConn, BsTid_T uTid, BsMsgId_T uMsgId, byte_t bufReq[], size_t uReqLen)
Server service thread request handler.
uint_t m_uRefCnt
vconn ref count for this client
Definition: bsProxy.h:198
ReqGetVConnList.
Definition: bsProxyMsgs.h:49
byte_t m_vconn
vconn
Definition: bsProxyMsgs.h:203
union BsProxyReqDevOpen_T::@10::@11 u
aligned vector items
struct BsProxyReqDevOpen_T::@10 m_argbuf
vector
const char * date
version date
Definition: bsProxyModIF.h:124
Standard bsProxy static interface module information structure type.
Definition: bsProxyModIF.h:119
Package version information.
size_t m_count
vector item count
Definition: bsProxyMsgs.h:231
const char * m_sModUri
module Uniform Resource Id
Definition: bsProxy.h:122
BsProxyMsgId_T
Definition: bsProxyMsgs.h:35
BsVConnHnd_T m_hndVConn
self reference
Definition: bsProxy.h:223
char m_client[(NMFVAL_LEN_MAX_STRING)+1]
client
Definition: bsProxyMsgs.h:281
#define BSPROXY_RSPGETVCONNINFO_MODDATE_LEN
Definition: bsProxyMsgs.h:272
<b><i>BotSense</i></b> bsProxy Dynamically Linked Library module interface.
#define BS_ECODE_SERVER_BAD_CLIENT
server detected bad client
Definition: BotSense.h:91
#define BSPROXY_RSPLOOPBACK_CDATA_LEN
Definition: bsProxyMsgs.h:102
#define PKG_TIMESTAMP
Definition: version.h:27
#define BS_ECODE_NO_VCONN
virtual connection not found
Definition: BotSense.h:80
const char * version
dotted version x.y.z[-app[-a.b.c]]
Definition: bsProxyModIF.h:123
INLINE_IN_H void ClientSetTraceState(BsProxyClientHnd_T hndClient, bool_t bTrace)
Set the <b><i>BotSense</i></b> client&#39;s server-terminated message trace state.
Definition: bsProxy.h:617
char m_devname[(NMFVAL_LEN_MAX_STRING)+1]
devname
Definition: bsProxyMsgs.h:177
byte_t m_vconn
vconn
Definition: bsProxyMsgs.h:153
#define BSPROXY_REQLOOPBACK_CDATA_LEN
Definition: bsProxyMsgs.h:85
#define BSPROXY_RSPGETVCONNINFO_MODVER_LEN
Definition: bsProxyMsgs.h:269
byte_t m_vconn
vconn
Definition: bsProxyMsgs.h:216
char m_modver[(NMFVAL_LEN_MAX_STRING)+1]
modver
Definition: bsProxyMsgs.h:287
INLINE_IN_H int BsProxyUnpackReqDevClose(byte_t buf[], size_t uMsgLen, BsProxyReqDevClose_T *pStruct, bool_t bTrace)
Unpack a BsProxyReqDevClose ITV message in big-endian byte order from the input buffer.
Definition: bsProxyMsgs.h:710
INLINE_IN_H const char * ClientHasName(BsProxyClientHnd_T hndClient)
Get the <b><i>BotSense</i></b> client official name.
Definition: bsProxy.h:588
const char * m_sDevUri
proxied device URI or server
Definition: bsProxy.h:150
BsProxyModIF_T * m_pModIF
interface module I/F
Definition: bsProxy.h:226
<b><i>BotSense</i></b> package top-level, unifying header declarations.
char m_moduri[(NMFVAL_LEN_MAX_STRING)+1]
moduri
Definition: bsProxyMsgs.h:285
int BsVConnHnd_T
virtual connection handle type
Definition: BotSense.h:151
int ClientSendServerRsp(BsProxyClientHnd_T hndClient, BsTid_T uTid, BsProxyMsgId_T uMsgId, void *pMsgRsp)
Send a server-terminated response message to client.
char m_moddate[(NMFVAL_LEN_MAX_STRING)+1]
moddate
Definition: bsProxyMsgs.h:289