Add wormhole state check function 98/2698/3
authorE. Scott Daniels <daniels@research.att.com>
Fri, 6 Mar 2020 17:29:28 +0000 (12:29 -0500)
committerE. Scott Daniels <daniels@research.att.com>
Fri, 6 Mar 2020 18:06:51 +0000 (13:06 -0500)
This change adds a new function allowing the state of a wormhole
to be checked by the user programme.

Issue-ID: RICAPP-79

Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: Id685dcb163f7266aa40f04317bee2b23fade4f43

27 files changed:
CHANGES
CMakeLists.txt
doc/CMakeLists.txt
doc/src/man/env_var_list.im
doc/src/man/rmr_alloc_msg.3.xfm
doc/src/man/rmr_set_fack.3.xfm [new file with mode: 0644]
doc/src/man/rmr_wh_open.3.xfm
doc/src/man/rmr_wh_send_msg.3.xfm
doc/src/man/rmr_wh_state.3.xfm [new file with mode: 0644]
doc/src/rst.im
doc/src/rtd/.gitignore [new file with mode: 0644]
doc/src/rtd/Makefile
doc/src/rtd/README
doc/src/rtd/gen_man_list.sh [new file with mode: 0755]
doc/src/rtd/user-guide.xfm
docs/config-deploy.rst
docs/overview.rst
docs/rel-notes.rst
docs/user-guide.rst
src/rmr/common/include/rmr.h
src/rmr/common/src/wormholes.c
src/rmr/si/src/si95/siproto.h
src/rmr/si/src/si95/sisetup.h
src/rmr/si/src/si95/sistruct.h
src/rmr/si/src/si95/sitrash.c
test/si95_test.c [new file with mode: 0644]
test/wormhole_static_test.c

diff --git a/CHANGES b/CHANGES
index ed6495b..aa261b0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 API and build change  and fix summaries. Doc correctsions
 and/or changes are not mentioned here; see the commit messages.
 
+2020 March 6; version 3.4.0
+       Add new wormhole state function: rmr_wh_state().
+
 2020 March 5; Version 3.3.1
        Correct several "bugs" identified by automatic code analysis.
 
index ed86d4d..97e5c8b 100644 (file)
@@ -39,8 +39,8 @@ project( rmr LANGUAGES C )
 cmake_minimum_required( VERSION 3.5 )
 
 set( major_version "3" )               # should be automatically populated from git tag later, but until CI process sets a tag we use this
-set( minor_version "3" )
-set( patch_level "1" )
+set( minor_version "4" )
+set( patch_level "0" )
 
 set( install_root "${CMAKE_INSTALL_PREFIX}" )
 set( install_inc "include/rmr" )
index c0efdcb..f8757de 100644 (file)
@@ -88,6 +88,7 @@ if( BUILD_DOC )
                rmr_trace_ref.3
                rmr_set_stimeout.3
                rmr_get_xact.3
+               rmr_wh_state.3.xfm
        )
 
        # initialise lists of files we generated
index e1ed9a9..1399e00 100644 (file)
@@ -1,4 +1,4 @@
-).** vim: ts=4 noet sw=42
+.** vim: ts=4 noet sw=42
 .if false
 ==================================================================================
        Copyright (c) 2019 Nokia
index ed814b8..44bcce0 100644 (file)
@@ -109,7 +109,6 @@ The ID is optional with the exception of when the user application uses the &cw(
 function to send a message and wait for the reply; the underlying RMR processing
 expects that the matching reply message will also contain the same data in the
 &ital(xaction) field.
-&end_dlist
 
 &half_space
 &diitem(sub_id)
diff --git a/doc/src/man/rmr_set_fack.3.xfm b/doc/src/man/rmr_set_fack.3.xfm
new file mode 100644 (file)
index 0000000..61ebfc3
--- /dev/null
@@ -0,0 +1,62 @@
+.if false
+==================================================================================
+       Copyright (c) 2019-2020 Nokia 
+       Copyright (c) 2018-2020 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+.fi
+.if false
+       Mnemonic        rmr_set_fack.3.xfm
+       Abstract        The manual page for the set fast ack function.
+       Author          E. Scott Daniels
+       Date            19 Fabruary 2020
+.fi
+
+.gv e LIB lib
+.im &{lib}/man/setup.im 
+
+&line_len(6i)
+
+&h1(RMR Library Functions)
+&h2(NAME)
+       rmr_set_fack
+
+&h2(SYNOPSIS )
+&indent
+&ex_start
+#include <rmr/rmr.h>
+
+void rmr_set_fack( void* vctx );
+
+&ex_end
+&uindent
+
+&h2(DESCRIPTION)
+The &cw(rmr_set_fack) function enables &ital(fast TCP acknowledgements) if
+the underlying transport library supports it. 
+This might be useful for applications which must send messages as a maximum
+rate. 
+
+&h2(RETURN VALUE)
+There is no return value.
+
+
+&h2(ERRORS)
+This function does not generate any errors.
+
+&h2(SEE ALSO )
+.ju off
+rmr_init(3),
+.ju on
+
index 5b26cf3..704af91 100644 (file)
@@ -113,6 +113,7 @@ rmr_has_str(3),
 rmr_tokenise(3),
 rmr_mk_ring(3),
 rmr_ring_free(3),
+rmr_wh_close(3),
 rmr_wh_send_msg(3),
-rmr_wh_close(3)
+rmr_wh_state(3)
 .ju on
index bebc110..6dcdbe8 100644 (file)
@@ -188,6 +188,7 @@ rmr_mk_ring(3),
 rmr_ring_free(3),
 rmr_set_stimeout(3),
 rmr_wh_open(3),
-rmr_wh_close(3)
+rmr_wh_close(3),
+rmr_wh_state(3)
 .ju on
 
diff --git a/doc/src/man/rmr_wh_state.3.xfm b/doc/src/man/rmr_wh_state.3.xfm
new file mode 100644 (file)
index 0000000..ea4c960
--- /dev/null
@@ -0,0 +1,90 @@
+.if false
+==================================================================================
+       Copyright (c) 2020 Nokia 
+       Copyright (c) 2020 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+.fi
+
+.if false
+       Mnemonic        rmr_wh_state.xfm
+       Abstract        The manual page for the rmr_wh_state function.
+       Author          E. Scott Daniels
+       Date            6 March 2020
+.fi
+
+.gv e LIB lib
+.im &{lib}/man/setup.im 
+
+&line_len(6i)
+
+&h1(RMR Library Functions)
+&h2(NAME)
+       rmr_wh_state
+
+&h2(SYNOPSIS)
+&indent
+&ex_start
+#include <rmr/rmr.h>
+
+int rmr_wh_state( void* vctx, rmr_whid_t whid )
+&ex_end
+
+&uindent
+
+&h2(DESCRIPTION)
+The &cw(rmr_wh_state) function will return the current state of the connection
+associated with the given wormhole (whid). 
+The return value indicates whether the connection is open (RMR_OK), or closed
+(any other return value).
+
+&space
+When using some transport mechanisms (e.g. NNG), it may not be possible for
+RMR to know the actual state and the connection may always be reported as
+"open."
+
+&h2(RETURN)
+The following values are potential return values.
+
+&space
+&beg_dlist(.75i : ^&bold_font )
+&di(RMR_OK)    
+       The wormhole ID is valid and the connection is "open."
+       &half_space
+
+&di(RMR_ERR_WHID)
+       THe wormhole ID passed into the function was not valid.
+       &half_space
+
+&di(RMR_ERR_NOENDPT)
+       The wormhole is not open (not connected).
+       &half_space
+
+&di(RMR_ERR_BADARG)
+       The context passed to the function was nil or invalid.
+       &half_space
+
+&di(RMR_ERR_NOWHOPEN)
+       Wormholes have not been initialised (no wormhole open call has been made).
+       &half_space
+&end_dlist
+
+
+&h2(SEE ALSO )
+.ju off
+rmr_wh_open(3),
+rmr_wh_send_msg(3),
+rmr_wh_close(3)
+
+.ju on
index e2444b1..b9c791a 100644 (file)
@@ -75,7 +75,8 @@
 
        .** for now we allow only a single layer of defitems
        .dv di     .in 0i .br  $1 .br .in +3
-       .** .dv diitem .in 0i .br  $1 .br .in +.25i
+       .dv ditem .in 0i .br  $1 .br .in +3
+       .** diitem is odd and deprecated
        .dv diitem .in 0i .br  $1 .br .in +3
        .dv item .br &lic
        .dv li .br &lic
diff --git a/doc/src/rtd/.gitignore b/doc/src/rtd/.gitignore
new file mode 100644 (file)
index 0000000..397a25f
--- /dev/null
@@ -0,0 +1,2 @@
+
+man_list.im
index a714e6a..768349d 100644 (file)
 # {X}fm is required to compile the source. 
 
 
-%.rst:: %.xfm
+%.rst:: %.xfm  man_list.im
        OUTPUT_TYPE=rst tfm $< | sed 's/^ //' >$@
 
-%.ps:: %.xfm
+%.ps:: %.xfm   man_list.im
        OUTPUT_TYPE=ps pfm $< $@
 
-%.txt:: %.xfm
+%.txt:: %.xfm  man_list.im
        OUTPUT_TYPE=txt tfm $< $@
 
-%.md:: %.xfm
+%.md:: %.xfm   man_list.im
        OUTPUT_TYPE=markdown tfm $<  | sed 's/^ //' >$@
 
 docs = config-deploy developer-guide user-guide rel-notes overview
 
 all:: $(docs:%=%.rst) $(docs:%=%.txt) $(docs:%=%.md)
 
+man_list.im:: always
+       bash gen_man_list.sh >man_list.im
+
 rel-notes.xfm: ../../../CHANGES
        ksh fmt_changes.ksh >rel-notes.xfm
 
+
 # we force the docs to always be out of date so that we don't have to
 # manage the list of man pages and other files that are read to generate the
 # output needed for RTD.
index b491113..0adb444 100644 (file)
@@ -10,6 +10,10 @@ rtd documentation. Follow that with 'make publish' to actually move
 the .rst files into the docs directory at the root; only the changed
 files are moved.
 
+Adding A New Man Page
+WHen a new manual page is added to the source (../man), it must be 
+added to the list in the user's guide source in this directory.
+
 Rationale
 Documentation is just code, and by maintaining the documentation as
 source is is possible to generate various forms of output with a 
diff --git a/doc/src/rtd/gen_man_list.sh b/doc/src/rtd/gen_man_list.sh
new file mode 100755 (executable)
index 0000000..d952cf4
--- /dev/null
@@ -0,0 +1,31 @@
+#/usr/bin/env bash
+# vim: sw=4 ts=4 noet :
+
+#==================================================================================
+#      Copyright (c) 2020 Nokia 
+#      Copyright (c) 2020 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#==================================================================================
+
+# generate the list of man pages to include in the user guide
+
+printf ".** CAUTION: this file is automatically generated; do not manually edit\n\n"
+ls -al ../man/*.xfm|sed 's!^.*man/!!' | while read x
+do
+       if [[ $x != *".7.xfm" ]]
+       then
+               printf ".ju off &space\n"
+               printf ".im &{lib}/man/$x\n"
+       fi
+done
index 5329484..8a29b02 100644 (file)
@@ -46,76 +46,8 @@ Read the manual pages :)
 
 .** turn of header 1 so that the rmr library header isn't generated for each page
 .dv h1
-.** .im &{lib}/man/rmr.7.xfm
-.ju off &space
-.im &{lib}/man/rmr_alloc_msg.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_bytes2meid.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_bytes2payload.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_bytes2xact.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_call.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_close.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_free_msg.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_get_meid.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_get_rcvfd.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_get_src.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_get_srcip.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_get_trace.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_get_trlen.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_get_xact.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_init.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_init_trace.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_mt_call.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_mt_rcv.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_payload_size.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_rcv_msg.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_ready.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_realloc_payload.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_rts_msg.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_send_msg.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_set_stimeout.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_set_trace.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_str2meid.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_str2xact.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_support.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_torcv_msg.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_trace_ref.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_tralloc_msg.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_wh_close.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_wh_open.3.xfm
-.ju off &space
-.im &{lib}/man/rmr_wh_send_msg.3.xfm
-.ju off &space
+
+.** CAUTION: man_list.im is generated by a script when make is used!
+.im man_list.im
+
 
index d6ae082..1726fb8 100644 (file)
@@ -33,44 +33,156 @@ package for more details).
  
 RMR_ASYNC_CONN 
    
-  Allows the asynch connection mode to be turned off (by 
+  Allows the async connection mode to be turned off (by 
   setting the value to 0. When set to 1, or missing from the 
   environment, RMR will invoke the connection interface in 
-  the transport mechanism using the non-blocking (asynch
+  the transport mechanism using the non-blocking (async) 
   mode. This will likely result in many "soft failures" 
   (retry) until the connection is established, but allows 
   the application to continue unimpeeded should the 
   connection be slow to set up. 
+   
  
 RMR_BIND_IF 
    
-  This provides the interface that RMr will bind listen 
+  This provides the interface that RMR will bind listen 
   ports to allowing for a single interface to be used rather 
   than listening across all interfaces. This should be the 
-  IP address assigned to the interface that RMr should 
-  listen on, and if not defined RMr will listen on all 
+  IP address assigned to the interface that RMR should 
+  listen on, and if not defined RMR will listen on all 
   interfaces. 
+   
+RMR_CTL_PORT 
+   
+  This variable defines the port that RMR should open for 
+  communications with Route Manager, and other RMR control 
+  applications. If not defined, the port 4561 is assumed. 
+   
+  Previously, the RMR_RTG_SVC (route table generator service 
+  port) was used to define this port. However, a future 
+  version of Route Manager will require RMR to connect and 
+  request tables, thus that variable is now used to supply 
+  the Route Manager well known address and port. 
+   
+  To maintain backwards compatablibility with the older 
+  Route Manager versions, the presence of this variable in 
+  the environment will shift RMR's behaviour with respect to 
+  the default value used when RMR_RTG_SVC is **not** 
+  defined. 
+   
+  When RMR_CTL_PORT is **defined:** RMR assumes that Route 
+  Manager requires RMR to connect and request table updates 
+  is made, and the default well known address for Route 
+  manager is used (routemgr:4561). 
+   
+  When RMR_CTL_PORT is **undefined:** RMR assumes that Route 
+  Manager will connect and push table updates, thus the 
+  default listen port (4561) is used. 
+   
+  To avoid any possible misinterpretation and/or incorrect 
+  assumptions on the part of RMR, it is recommended that 
+  both the RMR_CTL_PORT and RMR_RTG_SVC be defined. In the 
+  case where both variables are defined, RMR will behave 
+  exactly as is communicated with the variable's values. 
+   
  
 RMR_RTG_SVC 
    
-  RMr opens a TCP listen socket using the port defined by 
-  this environment variable and expects that the route table 
-  generator process will connect to this port. If not 
-  supplied the port 4561 is used. 
+  The value of this variable depends on the Route Manager in 
+  use. 
+   
+  When the Route Manager is expecting to connect to an xAPP 
+  and push route tables, this variable must indicate the 
+  port which RMR should use to listen for these connections. 
+   
+  When the Route Manager is expecting RMR to connect and 
+  request a table update during initialisation, the variable 
+  should be the host of the Route Manager process. 
+   
+  The RMR_CTL_PORT variable (added with the support of 
+  sending table update requests to Route manager), controls 
+  the behaviour if this variable is not set. See the 
+  description of that variable for details. 
+   
+RMR_HR_LOG 
+   
+  By default RMR writes messages to standard error 
+  (incorrectly referred to as log messages) in human 
+  readable format. If this environment variable is set to 0, 
+  the format of standard error messages might be written in 
+  some format not easily read by humans. If missing, a value 
+  of 1 is assumed. 
+   
+RMR_LOG_VLEVEL 
+   
+  This is a numeric value which corresponds to the verbosity 
+  level used to limit messages written to standard error. 
+  The lower the number the less chatty RMR functions are 
+  during execution. The following is the current 
+  relationship between the value set on this variable and 
+  the messages written: 
+   
+0 
+   
+  Off; no messages of any sort are written. 
+   
+1 
+   
+  Only critical messages are written (default if this 
+  variable does not exist) 
+   
+2 
+   
+  Errors and all messages written with a lower value. 
+   
+3 
+   
+  Warnings and all messages written with a lower value. 
+   
+4 
+   
+  Informational and all messages written with a lower 
+  value. 
+   
+5 
+   
+  Debugging mode -- all messages written, however this 
+  requires RMR to have been compiled with debugging 
+  support enabled. 
  
 RMR_RTG_ISRAW 
    
-  Is set to 1 if the route table generator is sending 
-  "plain" messages (not using RMr to send messages, 0 if the 
-  rtg is using RMr to send. The default is 1 as we don't 
-  expect the rtg to use RMr. 
+  **Deprecated.** Should be set to 1 if the route table 
+  generator is sending "plain" messages (not using RMR to 
+  send messages, 0 if the rtg is using RMR to send. The 
+  default is 1 as we don't expect the rtg to use RMR. 
+   
+  This variable is only recognised when using the NNG 
+  transport library as it is not possible to support NNG 
+  "raw" communications with other transport libraries. It is 
+  also necessary to match the value of this variable with 
+  the capabilities of the Route Manager; at some point in 
+  the future RMR will assume that all Route Manager messages 
+  will arrive via an RMR connection and will ignore this 
+  variable. 
  
 RMR_SEED_RT 
    
   This is used to supply a static route table which can be 
   used for debugging, testing, or if no route table 
   generator process is being used to supply the route table. 
-  If not defined, no static table is used and RMr will not 
+  If not defined, no static table is used and RMR will not 
   report *ready* until a table is received. The static route 
   table may contain both the route table (between newrt 
   start and end records), and the MEID map (between meid_map 
@@ -84,6 +196,9 @@ RMR_SRC_ID
   function to return a response to the sender. If not 
   supplied RMR will use the hostname which in some container 
   environments might not be routable. 
+   
+  The value of this variable is also used for Route Manager 
+  messages which are sent via an RMR connection. 
  
 RMR_VCTL_FILE 
    
index e29b633..8ca7f86 100644 (file)
@@ -184,44 +184,156 @@ if undefined.
  
 RMR_ASYNC_CONN 
    
-  Allows the asynch connection mode to be turned off (by 
+  Allows the async connection mode to be turned off (by 
   setting the value to 0. When set to 1, or missing from the 
   environment, RMR will invoke the connection interface in 
-  the transport mechanism using the non-blocking (asynch
+  the transport mechanism using the non-blocking (async) 
   mode. This will likely result in many "soft failures" 
   (retry) until the connection is established, but allows 
   the application to continue unimpeeded should the 
   connection be slow to set up. 
+   
  
 RMR_BIND_IF 
    
-  This provides the interface that RMr will bind listen 
+  This provides the interface that RMR will bind listen 
   ports to allowing for a single interface to be used rather 
   than listening across all interfaces. This should be the 
-  IP address assigned to the interface that RMr should 
-  listen on, and if not defined RMr will listen on all 
+  IP address assigned to the interface that RMR should 
+  listen on, and if not defined RMR will listen on all 
   interfaces. 
+   
+RMR_CTL_PORT 
+   
+  This variable defines the port that RMR should open for 
+  communications with Route Manager, and other RMR control 
+  applications. If not defined, the port 4561 is assumed. 
+   
+  Previously, the RMR_RTG_SVC (route table generator service 
+  port) was used to define this port. However, a future 
+  version of Route Manager will require RMR to connect and 
+  request tables, thus that variable is now used to supply 
+  the Route Manager well known address and port. 
+   
+  To maintain backwards compatablibility with the older 
+  Route Manager versions, the presence of this variable in 
+  the environment will shift RMR's behaviour with respect to 
+  the default value used when RMR_RTG_SVC is **not** 
+  defined. 
+   
+  When RMR_CTL_PORT is **defined:** RMR assumes that Route 
+  Manager requires RMR to connect and request table updates 
+  is made, and the default well known address for Route 
+  manager is used (routemgr:4561). 
+   
+  When RMR_CTL_PORT is **undefined:** RMR assumes that Route 
+  Manager will connect and push table updates, thus the 
+  default listen port (4561) is used. 
+   
+  To avoid any possible misinterpretation and/or incorrect 
+  assumptions on the part of RMR, it is recommended that 
+  both the RMR_CTL_PORT and RMR_RTG_SVC be defined. In the 
+  case where both variables are defined, RMR will behave 
+  exactly as is communicated with the variable's values. 
+   
  
 RMR_RTG_SVC 
    
-  RMr opens a TCP listen socket using the port defined by 
-  this environment variable and expects that the route table 
-  generator process will connect to this port. If not 
-  supplied the port 4561 is used. 
+  The value of this variable depends on the Route Manager in 
+  use. 
+   
+  When the Route Manager is expecting to connect to an xAPP 
+  and push route tables, this variable must indicate the 
+  port which RMR should use to listen for these connections. 
+   
+  When the Route Manager is expecting RMR to connect and 
+  request a table update during initialisation, the variable 
+  should be the host of the Route Manager process. 
+   
+  The RMR_CTL_PORT variable (added with the support of 
+  sending table update requests to Route manager), controls 
+  the behaviour if this variable is not set. See the 
+  description of that variable for details. 
+   
+RMR_HR_LOG 
+   
+  By default RMR writes messages to standard error 
+  (incorrectly referred to as log messages) in human 
+  readable format. If this environment variable is set to 0, 
+  the format of standard error messages might be written in 
+  some format not easily read by humans. If missing, a value 
+  of 1 is assumed. 
+   
+RMR_LOG_VLEVEL 
+   
+  This is a numeric value which corresponds to the verbosity 
+  level used to limit messages written to standard error. 
+  The lower the number the less chatty RMR functions are 
+  during execution. The following is the current 
+  relationship between the value set on this variable and 
+  the messages written: 
+   
+0 
+   
+  Off; no messages of any sort are written. 
+   
+1 
+   
+  Only critical messages are written (default if this 
+  variable does not exist) 
+   
+2 
+   
+  Errors and all messages written with a lower value. 
+   
+3 
+   
+  Warnings and all messages written with a lower value. 
+   
+4 
+   
+  Informational and all messages written with a lower 
+  value. 
+   
+5 
+   
+  Debugging mode -- all messages written, however this 
+  requires RMR to have been compiled with debugging 
+  support enabled. 
  
 RMR_RTG_ISRAW 
    
-  Is set to 1 if the route table generator is sending 
-  "plain" messages (not using RMr to send messages, 0 if the 
-  rtg is using RMr to send. The default is 1 as we don't 
-  expect the rtg to use RMr. 
+  **Deprecated.** Should be set to 1 if the route table 
+  generator is sending "plain" messages (not using RMR to 
+  send messages, 0 if the rtg is using RMR to send. The 
+  default is 1 as we don't expect the rtg to use RMR. 
+   
+  This variable is only recognised when using the NNG 
+  transport library as it is not possible to support NNG 
+  "raw" communications with other transport libraries. It is 
+  also necessary to match the value of this variable with 
+  the capabilities of the Route Manager; at some point in 
+  the future RMR will assume that all Route Manager messages 
+  will arrive via an RMR connection and will ignore this 
+  variable. 
  
 RMR_SEED_RT 
    
   This is used to supply a static route table which can be 
   used for debugging, testing, or if no route table 
   generator process is being used to supply the route table. 
-  If not defined, no static table is used and RMr will not 
+  If not defined, no static table is used and RMR will not 
   report *ready* until a table is received. The static route 
   table may contain both the route table (between newrt 
   start and end records), and the MEID map (between meid_map 
@@ -235,6 +347,9 @@ RMR_SRC_ID
   function to return a response to the sender. If not 
   supplied RMR will use the hostname which in some container 
   environments might not be routable. 
+   
+  The value of this variable is also used for Route Manager 
+  messages which are sent via an RMR connection. 
  
 RMR_VCTL_FILE 
    
index a9b2ab7..133abf1 100644 (file)
@@ -15,6 +15,107 @@ file at the repo root; please refer to that file for a
 completely up to date listing of API changes. 
  
  
+2020 March 6; version 3.4.0 
+-------------------------------------------------------------------------------------------- 
+Add new wormhole state function: rmr_wh_state(). 
+2020 March 5; Version 3.3.1 
+-------------------------------------------------------------------------------------------- 
+Correct several "bugs" identified by automatic code analysis. 
+2020 March 4; Version 3.3.0 
+-------------------------------------------------------------------------------------------- 
+Add SI95 based unit testing Health check support binary added 
+(reason for minor bump) 
+2020 February 29; Version 2.4.0 
+-------------------------------------------------------------------------------------------- 
+Add consolidated testing under CMake Add support binary for 
+health check (SI95 only) 
+2020 February 28; Version 2.3.6 
+-------------------------------------------------------------------------------------------- 
+Fix bug in Rt. Mgr comm which prevented table ID from being 
+sent on ack message (RIC-232). 
+2020 February 26; version 3.2.5 
+-------------------------------------------------------------------------------------------- 
+Fix source address bug in SI95 receive/send funcitons. Fix 
+threading issues involving session disconnection in SI95 
+Remove unused SI95 status variable. 
+2020 February 24; version 3.2.4 
+-------------------------------------------------------------------------------------------- 
+Fix meid bug (RIC-220) causing core dump. 
+2020 February 21; version 3.2.3 
+-------------------------------------------------------------------------------------------- 
+Add meid routing support to the SI95 interface. 
+2020 February 20; version 3.2.2 
+-------------------------------------------------------------------------------------------- 
+Fix receive thread related core dump (ring early unlock). 
+2020 February 19; version 3.2.1 
+-------------------------------------------------------------------------------------------- 
+Added missing message types (E2-Setup) 
+2020 February 18; version 3.2.0 
+-------------------------------------------------------------------------------------------- 
+Added support for new Route Manager and it's ability to 
+accept a request for table update. 
+2020 February 14; version 3.1.3 
+-------------------------------------------------------------------------------------------- 
+Fix bug in SIsend which was causing a core dump in some cases 
+where the application attempted to send on a connection that 
+had disconnected. (RIC-207). 
+2020 February 6; version 3.1.2 
+-------------------------------------------------------------------------------------------- 
+Fix disconnection detection bug in interface to SI95. 
+2020 January 31; verison 3.1.1 
+-------------------------------------------------------------------------------------------- 
+Allow route table thread logging to be completely disabled 
+when logging is turned off. 
+2020 January 26; verison 3.1.0 
+-------------------------------------------------------------------------------------------- 
+First step to allowing the user programme to control messages 
+written to standard error. Introduces the rmr_set_vlevel() 
+function, and related environment variable. 
 2020 January 24; verison 3.0.5 
 -------------------------------------------------------------------------------------------- 
  
index c0b7bc8..a59239d 100644 (file)
@@ -128,8 +128,7 @@ xaction
   and wait for the reply; the underlying RMR processing 
   expects that the matching reply message will also contain 
   the same data in the *xaction* field. 
+   
  
 sub_id 
    
@@ -147,21 +146,21 @@ tp_state
    
   For C applications making use of RMR, the state of a 
   transport based failure will often be available via errno. 
-  However, some wrapper environments may not have direct access 
-  to the C-lib errno value. RMR send and receive operations 
-  will place the current value of errno into this field which 
-  should make it available to wrapper functions. User 
-  applications are strongly cautioned against relying on the 
-  value of errno as some transport mechanisms may not set this 
-  value on all calls. This value should also be ignored any 
-  time the message status is RMR_OK. 
+  However, some wrapper environments may not have direct 
+  access to the C-lib errno value. RMR send and receive 
+  operations will place the current value of errno into this 
+  field which should make it available to wrapper functions. 
+  User applications are strongly cautioned against relying 
+  on the value of errno as some transport mechanisms may not 
+  set this value on all calls. This value should also be 
+  ignored any time the message status is RMR_OK. 
  
  
 RETURN VALUE 
 -------------------------------------------------------------------------------------------- 
  
-The function returns a pointer to a rmr_mbuf structure, or NULL 
-on error. 
+The function returns a pointer to a rmr_mbuf structure, or 
+NULL on error. 
  
 ERRORS 
 -------------------------------------------------------------------------------------------- 
@@ -176,12 +175,12 @@ ENOMEM
 SEE ALSO 
 -------------------------------------------------------------------------------------------- 
  
-rmr_tralloc_msg(3), rmr_call(3), rmr_free_msg(3), rmr_init(3), 
-rmr_init_trace(3), rmr_get_trace(3), rmr_get_trlen(3), 
-rmr_payload_size(3), rmr_send_msg(3), rmr_rcv_msg(3), 
-rmr_rcv_specific(3), rmr_rts_msg(3), rmr_ready(3), rmr_fib(3), 
-rmr_has_str(3), rmr_tokenise(3), rmr_mk_ring(3), 
-rmr_ring_free(3), rmr_set_trace(3) 
+rmr_tralloc_msg(3), rmr_call(3), rmr_free_msg(3), 
+rmr_init(3), rmr_init_trace(3), rmr_get_trace(3), 
+rmr_get_trlen(3), rmr_payload_size(3), rmr_send_msg(3), 
+rmr_rcv_msg(3), rmr_rcv_specific(3), rmr_rts_msg(3), 
+rmr_ready(3), rmr_fib(3), rmr_has_str(3), rmr_tokenise(3), 
+rmr_mk_ring(3), rmr_ring_free(3), rmr_set_trace(3) 
  
  
 NAME 
@@ -1214,12 +1213,15 @@ RMRFL_MTCALL
    
   Enable multi-threaded call support. 
    
-  &ditem Some underlying transport providers (e.g. SI95) 
-  enable locking to be turned off if the user application is 
-  single threaded, or otherwise can guarantee that RMR 
-  functions will not be invoked concurrently from different 
-  threads. Turning off locking can help make message receipt 
-  more efficient. If this flag is set when the underlying 
+RMRFL_NOLOCK 
+   
+  Some underlying transport providers (e.g. SI95) enable 
+  locking to be turned off if the user application is single 
+  threaded, or otherwise can guarantee that RMR functions 
+  will not be invoked concurrently from different threads. 
+  Turning off locking can help make message receipt more 
+  efficient. If this flag is set when the underlying 
   transport does not support disabling locks, it will be 
   ignored. 
  
@@ -1257,24 +1259,194 @@ setup. The following variables will be used when found.
  
  
  
-RMR_SEED_RT 
+RMR_ASYNC_CONN 
+   
+  Allows the async connection mode to be turned off (by 
+  setting the value to 0. When set to 1, or missing from the 
+  environment, RMR will invoke the connection interface in 
+  the transport mechanism using the non-blocking (async) 
+  mode. This will likely result in many "soft failures" 
+  (retry) until the connection is established, but allows 
+  the application to continue unimpeeded should the 
+  connection be slow to set up. 
+   
+RMR_BIND_IF 
+   
+  This provides the interface that RMR will bind listen 
+  ports to allowing for a single interface to be used rather 
+  than listening across all interfaces. This should be the 
+  IP address assigned to the interface that RMR should 
+  listen on, and if not defined RMR will listen on all 
+  interfaces. 
+   
+RMR_CTL_PORT 
+   
+  This variable defines the port that RMR should open for 
+  communications with Route Manager, and other RMR control 
+  applications. If not defined, the port 4561 is assumed. 
+   
+  Previously, the RMR_RTG_SVC (route table generator service 
+  port) was used to define this port. However, a future 
+  version of Route Manager will require RMR to connect and 
+  request tables, thus that variable is now used to supply 
+  the Route Manager well known address and port. 
+   
+  To maintain backwards compatablibility with the older 
+  Route Manager versions, the presence of this variable in 
+  the environment will shift RMR's behaviour with respect to 
+  the default value used when RMR_RTG_SVC is **not** 
+  defined. 
+   
+  When RMR_CTL_PORT is **defined:** RMR assumes that Route 
+  Manager requires RMR to connect and request table updates 
+  is made, and the default well known address for Route 
+  manager is used (routemgr:4561). 
+   
+  When RMR_CTL_PORT is **undefined:** RMR assumes that Route 
+  Manager will connect and push table updates, thus the 
+  default listen port (4561) is used. 
    
-  Assumes this is the filename of the seed route table file 
-  to use. In normal situations, the library will wait for an 
-  update from the route table generator (expected within a 
-  few seconds of initialisation) before being able to send 
-  messages. However, in some situations where a bootstrap 
-  table is necessary, this is the means to supply it to the 
-  library. 
+  To avoid any possible misinterpretation and/or incorrect 
+  assumptions on the part of RMR, it is recommended that 
+  both the RMR_CTL_PORT and RMR_RTG_SVC be defined. In the 
+  case where both variables are defined, RMR will behave 
+  exactly as is communicated with the variable's values. 
    
  
 RMR_RTG_SVC 
    
-  The route table generator assumes that RMr is listening on 
-  a well known port (4561) by default, but this environment 
-  variable can be used to change the listening port if 
-  needed. The value of the variable is expected to be just 
-  the port. 
+  The value of this variable depends on the Route Manager in 
+  use. 
+   
+  When the Route Manager is expecting to connect to an xAPP 
+  and push route tables, this variable must indicate the 
+  port which RMR should use to listen for these connections. 
+   
+  When the Route Manager is expecting RMR to connect and 
+  request a table update during initialisation, the variable 
+  should be the host of the Route Manager process. 
+   
+  The RMR_CTL_PORT variable (added with the support of 
+  sending table update requests to Route manager), controls 
+  the behaviour if this variable is not set. See the 
+  description of that variable for details. 
+   
+RMR_HR_LOG 
+   
+  By default RMR writes messages to standard error 
+  (incorrectly referred to as log messages) in human 
+  readable format. If this environment variable is set to 0, 
+  the format of standard error messages might be written in 
+  some format not easily read by humans. If missing, a value 
+  of 1 is assumed. 
+   
+RMR_LOG_VLEVEL 
+   
+  This is a numeric value which corresponds to the verbosity 
+  level used to limit messages written to standard error. 
+  The lower the number the less chatty RMR functions are 
+  during execution. The following is the current 
+  relationship between the value set on this variable and 
+  the messages written: 
+   
+0 
+   
+  Off; no messages of any sort are written. 
+   
+1 
+   
+  Only critical messages are written (default if this 
+  variable does not exist) 
+   
+2 
+   
+  Errors and all messages written with a lower value. 
+   
+3 
+   
+  Warnings and all messages written with a lower value. 
+   
+4 
+   
+  Informational and all messages written with a lower 
+  value. 
+   
+5 
+   
+  Debugging mode -- all messages written, however this 
+  requires RMR to have been compiled with debugging 
+  support enabled. 
+RMR_RTG_ISRAW 
+   
+  **Deprecated.** Should be set to 1 if the route table 
+  generator is sending "plain" messages (not using RMR to 
+  send messages, 0 if the rtg is using RMR to send. The 
+  default is 1 as we don't expect the rtg to use RMR. 
+   
+  This variable is only recognised when using the NNG 
+  transport library as it is not possible to support NNG 
+  "raw" communications with other transport libraries. It is 
+  also necessary to match the value of this variable with 
+  the capabilities of the Route Manager; at some point in 
+  the future RMR will assume that all Route Manager messages 
+  will arrive via an RMR connection and will ignore this 
+  variable. 
+RMR_SEED_RT 
+   
+  This is used to supply a static route table which can be 
+  used for debugging, testing, or if no route table 
+  generator process is being used to supply the route table. 
+  If not defined, no static table is used and RMR will not 
+  report *ready* until a table is received. The static route 
+  table may contain both the route table (between newrt 
+  start and end records), and the MEID map (between meid_map 
+  start and end records) 
+RMR_SRC_ID 
+   
+  This is either the name or IP address which is placed into 
+  outbound messages as the message source. This will used 
+  when an RMR based application uses the rmr_rts_msg() 
+  function to return a response to the sender. If not 
+  supplied RMR will use the hostname which in some container 
+  environments might not be routable. 
+   
+  The value of this variable is also used for Route Manager 
+  messages which are sent via an RMR connection. 
+RMR_VCTL_FILE 
+   
+  This supplies the name of a verbosity control file. The 
+  core RMR functions do not produce messages unless there is 
+  a critical failure. However, the route table collection 
+  thread, not a part of the main message processing 
+  component, can write additional messages to standard 
+  error. If this variable is set, RMR will extract the 
+  verbosity level for these messages (0 is silent) from the 
+  first line of the file. Changes to the file are detected 
+  and thus the level can be changed dynamically, however RMR 
+  will only suss out this variable during initialisation, so 
+  it is impossible to enable verbosity after startup. 
+RMR_WARNINGS 
+   
+  If set to 1, RMR will write some warnings which are 
+  non-performance impacting. If the variable is not defined, 
+  or set to 0, RMR will not write these additional warnings. 
  
  
 RETURN VALUE 
@@ -1928,10 +2100,37 @@ ERRORS
 -------------------------------------------------------------------------------------------- 
  
 The *state* field in the message buffer will indicate either 
-RMR_OK or RMR_ERR_EMPTY if an empty message was received. If 
-a nil pointer is returned, or any other state value was set 
-in the message buffer, errno will be set to one of the 
-following: 
+RMR_OK when the message receive process was successful and 
+the message can be used by the caller. Depending on the 
+underlying transport mechanism, one of the following RMR 
+error stats may be returned: 
+RMR_ERR_EMPTY 
+   
+  The message received had no payload, or was completely 
+  empty. 
+   
+RMR_ERR_TIMEOUT 
+   
+  For some transport mechanisms, or if reading the receive 
+  queue from multiple threads, it is possible for one thread 
+  to find no data waiting when it queries the queue. When 
+  this state is reported, the message buffer does not 
+  contain message data and the user application should 
+  reinvoke the receive function. 
+When an RMR error state is reported, the underlying errno 
+value might provide more information. The following is a list 
+of possible values that might accompany the states listed 
+above: 
+RMR_ERR_EMPTY if an empty message was received. If a nil 
+pointer is returned, or any other state value was set in the 
+message buffer, errno will be set to one of the following: 
  
  
  
@@ -2653,6 +2852,46 @@ rmr_rts_msg(3), rmr_ready(3), rmr_mk_ring(3),
 rmr_ring_free(3), rmr_torcv_rcv(3), rmr_wh_send_msg(3) 
  
  
+NAME 
+-------------------------------------------------------------------------------------------- 
+rmr_set_fack 
+SYNOPSIS 
+-------------------------------------------------------------------------------------------- 
+:: 
+  
+ #include <rmr/rmr.h>
+ void rmr_set_fack( void* vctx );
+DESCRIPTION 
+-------------------------------------------------------------------------------------------- 
+The rmr_set_fack function enables *fast TCP acknowledgements* 
+if the underlying transport library supports it. This might 
+be useful for applications which must send messages as a 
+maximum rate. 
+RETURN VALUE 
+-------------------------------------------------------------------------------------------- 
+There is no return value. 
+ERRORS 
+-------------------------------------------------------------------------------------------- 
+This function does not generate any errors. 
+SEE ALSO 
+-------------------------------------------------------------------------------------------- 
+rmr_init(3), 
 NAME 
 -------------------------------------------------------------------------------------------- 
  
@@ -2755,7 +2994,7 @@ SYNOPSIS
 :: 
   
  #include <rmr/rmr.h>
- int rmr_bytes2payload( rmr_mbuf_t* mbuf, unsigned char* data, int len )
+ int rmr_set_trace( rmr_mbuf_t* mbuf, unsigned char* data, int len )
  
  
  
@@ -2789,6 +3028,99 @@ rmr_ring_free(3), rmr_str2meid(3), rmr_str2xact(3),
 rmr_wh_open(3), rmr_wh_send_msg(3) 
  
  
+NAME 
+-------------------------------------------------------------------------------------------- 
+rmr_set_trace 
+SYNOPSIS 
+-------------------------------------------------------------------------------------------- 
+:: 
+  
+ #include <rmr/rmr.h>
+ #include <rmr/rmr_logging.h>
+ void rmr_set_vlevel( int new_level )
+DESCRIPTION 
+-------------------------------------------------------------------------------------------- 
+The rmr_set_vlevel allows the user programme to set the 
+verbosity level which is used to determine the messages RMR 
+writes to standard error. The new_vlevel value must be one of 
+the following constants which have the indicated meanings: 
+RMR_VL_OFF 
+   
+  Turns off all message writing. This includes the stats and 
+  debugging messages generated by the route collector thread 
+  which are normally affected only by the externally managed 
+  verbose level file (and related environment variable). 
+   
+RMR_VL_CRIT 
+   
+  Write only messages of critical importance. From the point 
+  of view of RMR, when a critical proper behaviour of the 
+  library cannot be expected or guaranteed. 
+RMR_VL_ERR 
+   
+  Include error messages in the output. An error is an event 
+  from which RMR has no means to recover. Continued proper 
+  execution is likely except where the affected connection 
+  and/or component mentioned in the error is concerned. 
+RMR_VL_WARN 
+   
+  Include warning messages in the output. A warning 
+  indicates an event which is not considered to be normal, 
+  but is expected and continued acceptable behaviour of the 
+  system is assured. 
+RMR_VL_INFO 
+   
+  Include informational messagees in the output. 
+  Informational messages include some diagnostic information 
+  which explain the activities of RMR. 
+RMR_VL_DEBUG 
+   
+  Include all debugging messages in the output. Debugging 
+  must have also been enabled during the build as a 
+  precaution to accidentally enabling this level of output 
+  as it can grossly affect performance. 
+generally RMR does not write messages to the standard error 
+device from *critical path* functions, therefore it is 
+usually not harmful to enable a verbosity level of either 
+RMR_VL_CRIT, or RMR_VL_ERR. 
+Messages written from the route table collection thread are 
+still governed by the value placed into the verbose level 
+control file (see the man page for rmr_init()); those 
+messages are affected only when logging is completely 
+disabled by passing RMR_VL_OFF to this function. 
+The verbosity level can also be set via an environment 
+variable prior to the start of the RMR based application. The 
+environment variable is read only during initialisation; if 
+the programme must change the value during execution, this 
+function must be used. The default value, if this function is 
+never called, and the environment variable is not present, is 
+RMR_VL_ERR. 
+SEE ALSO 
+-------------------------------------------------------------------------------------------- 
+rmr_init(3) 
 NAME 
 -------------------------------------------------------------------------------------------- 
  
@@ -3509,8 +3841,8 @@ rmr_alloc_msg(3), rmr_call(3), rmr_free_msg(3),
 rmr_get_rcvfd(3), rmr_payload_size(3), rmr_send_msg(3), 
 rmr_rcv_msg(3), rmr_rcv_specific(3), rmr_rts_msg(3), 
 rmr_ready(3), rmr_fib(3), rmr_has_str(3), rmr_tokenise(3), 
-rmr_mk_ring(3), rmr_ring_free(3), rmr_wh_send_msg(3), 
-rmr_wh_close(3) 
+rmr_mk_ring(3), rmr_ring_free(3), rmr_wh_close(3), 
+rmr_wh_send_msg(3), rmr_wh_state(3) 
  
  
 NAME 
@@ -3771,5 +4103,73 @@ rmr_alloc_msg(3), rmr_call(3), rmr_free_msg(3), rmr_init(3),
 rmr_payload_size(3), rmr_rcv_msg(3), rmr_rcv_specific(3), 
 rmr_rts_msg(3), rmr_ready(3), rmr_fib(3), rmr_has_str(3), 
 rmr_tokenise(3), rmr_mk_ring(3), rmr_ring_free(3), 
-rmr_set_stimeout(3), rmr_wh_open(3), rmr_wh_close(3) 
+rmr_set_stimeout(3), rmr_wh_open(3), rmr_wh_close(3), 
+rmr_wh_state(3) 
+NAME 
+-------------------------------------------------------------------------------------------- 
+rmr_wh_state 
+SYNOPSIS 
+-------------------------------------------------------------------------------------------- 
+:: 
+  
+ #include <rmr/rmr.h>
+ int rmr_wh_state( void* vctx, rmr_whid_t whid )
+DESCRIPTION 
+-------------------------------------------------------------------------------------------- 
+The rmr_wh_state function will return the current state of 
+the connection associated with the given wormhole (whid). The 
+return value indicates whether the connection is open 
+(RMR_OK), or closed (any other return value). 
+When using some transport mechanisms (e.g. NNG), it may not 
+be possible for RMR to know the actual state and the 
+connection may always be reported as "open." 
+RETURN 
+-------------------------------------------------------------------------------------------- 
+The following values are potential return values. 
+RMR_OK 
+   
+  The wormhole ID is valid and the connection is "open." 
+   
+RMR_ERR_WHID 
+   
+  THe wormhole ID passed into the function was not valid. 
+   
+RMR_ERR_NOENDPT 
+   
+  The wormhole is not open (not connected). 
+   
+RMR_ERR_BADARG 
+   
+  The context passed to the function was nil or invalid. 
+   
+RMR_ERR_NOWHOPEN 
+   
+  Wormholes have not been initialised (no wormhole open call 
+  has been made). 
+   
+SEE ALSO 
+-------------------------------------------------------------------------------------------- 
  
+rmr_wh_open(3), rmr_wh_send_msg(3), rmr_wh_close(3) 
index 5d4583a..cc2c0c8 100644 (file)
@@ -136,6 +136,7 @@ extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to );
 extern rmr_mbuf_t*  rmr_tralloc_msg( void* context, int msize, int trsize, unsigned const char* data );
 extern rmr_whid_t rmr_wh_open( void* vctx, char const* target );
 extern rmr_mbuf_t* rmr_wh_send_msg( void* vctx, rmr_whid_t whid, rmr_mbuf_t* msg );
+extern int rmr_wh_state( void* vctx, rmr_whid_t whid );
 extern void rmr_wh_close( void* vctx, int whid );
 
 // ----- mt call support --------------------------------------------------------------------------------
index 76567f9..d66ecdd 100644 (file)
@@ -323,3 +323,43 @@ extern void rmr_wh_close( void* vctx, int whid ) {
 
        whm->eps[whid] = NULL;
 }
+
+/*
+       Check the state of an endpoint that is associated with the wormhold ID
+       passed in. If the state is "open" then we return RMR_OK. Other possible
+       return codes:
+
+               RMR_ERR_WHID        // wormhole id was invalid
+               RMR_ERR_NOENDPT     // the endpoint connection is not open
+               RMR_ERR_BADARG          // context or other arg was invalid
+               RMR_ERR_NOWHOPEN        // wormhole(s) have not been initalised
+
+*/
+extern int rmr_wh_state( void* vctx, rmr_whid_t whid ) {
+       uta_ctx_t*      ctx;
+       wh_mgt_t*       whm;                    // easy reference to wh mgt stuff
+       endpoint_t*     ep;                             // enpoint that wormhole ID references
+
+       if( (ctx = (uta_ctx_t *) vctx) == NULL ) {              // bad stuff, bail fast
+               errno = EINVAL;
+               return RMR_ERR_BADARG;
+       }
+
+       if( (whm = ctx->wormholes) == NULL ) {
+               errno = EINVAL;                                                                                         // no wormholes open
+               return RMR_ERR_NOWHOPEN;
+       }
+
+       if( whid < 0 || whid >= whm->nalloc || whm->eps[whid] == NULL ) {
+               errno = EINVAL;
+               return RMR_ERR_WHID;
+       }
+
+       errno = 0;
+
+       if( (ep = whm->eps[whid]) != NULL ) {
+               return ep->open ? RMR_OK : RMR_ERR_NOENDPT;
+       }
+
+       return RMR_ERR_NOENDPT;
+}
index c59d626..e8d9ba5 100644 (file)
@@ -29,6 +29,8 @@
 -----------------------------------------------------------------------------------
 */
 
+#ifndef _si_proto_h
+#define _si_proto_h
 
 extern void *SInew( int type );
 extern char *sigetname( int sid );
@@ -59,3 +61,5 @@ extern void SIterm( struct ginfo_blk* gptr, struct tp_blk *tpptr );
 extern void SItrash( int type, void *bp );
 extern int SIwait( struct ginfo_blk *gptr );
 extern struct ginfo_blk* SIinitialise( int opts );
+
+#endif
index 5c88c27..be428db 100644 (file)
@@ -28,6 +28,9 @@
 *****************************************************************************
 */
  
+#ifndef        _sisetup_h
+#define _sisetup_h
+
 #include <stdio.h>              //  standard io 
 #include <stdlib.h>
 #include <unistd.h>
@@ -51,3 +54,5 @@
 #include "siconst.h"                   //  internal constants  and prototypes 
 #include "sistruct.h"                  //  real structure defs
 #include "siproto.h"
+
+#endif
index 0713395..51a1e6a 100644 (file)
@@ -30,6 +30,9 @@
 ******************************************************************************
 */
 
+#ifndef        _sistruct_h
+#define _sistruct_h
+
 struct ioq_blk              //  block to queue on session when i/o waiting 
 {
        struct ioq_blk *next;     //  next block in the queue 
@@ -80,3 +83,5 @@ struct ginfo_blk {                            //  general info block  (context)
        int     sierr;                                  // our internal error number (SI_ERR_* constants)
        struct tp_blk** tp_map;         // direct fd -> tp block map
 };
+
+#endif
index 679e2f4..83671c7 100644 (file)
@@ -40,6 +40,10 @@ extern void SItrash( int type, void *bp )
         struct ioq_blk *iptr;
         struct ioq_blk *inext;
 
+               if( bp == NULL ) {
+                       return;
+               }
+
         switch( type )
         {
                 case IOQ_BLK:
diff --git a/test/si95_test.c b/test/si95_test.c
new file mode 100644 (file)
index 0000000..399ff78
--- /dev/null
@@ -0,0 +1,164 @@
+// :vi sw=4 ts=4 noet:
+/*
+==================================================================================
+       Copyright (c) 2020 Nokia
+       Copyright (c) 2020 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+*/
+
+/*
+       Mmemonic:       si95_test.c
+       Abstract:       This is the main driver to test the si95 core functions
+                               (within rmr/src/si/src/si95). 
+
+       Author:         E. Scott Daniels
+       Date:           6 March 2018
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <netdb.h>
+#include <errno.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <ctype.h>
+
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <errno.h>
+#include <string.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <sys/epoll.h>
+#include <pthread.h>
+#include <semaphore.h>
+
+#define DEBUG 1
+
+                                                                                       // specific test tools in this directory
+#undef NNG_UNDER_TEST                                          // NNG is NOT under test so undefine if set
+#define NO_EMULATION 1                                         // no emulation of transport functions
+#define NO_PRIVATE_HEADERS 1                           // no rmr_si or rmr_nng headers
+#define NO_DUMMY_RMR 1                                         // no msg things
+#include "test_support.c"                                      // things like fail_if()
+
+
+/*
+#include "rmr.h"                                       // things the users see
+#include "rmr_symtab.h"
+#include "rmr_agnostic.h"                      // transport agnostic header
+*/
+#include <rmr_logging.h>
+#include <logging.c>
+
+//#include <si95/siaddress.c>
+//#include <si95/sialloc.c>
+//#include <si95/sibldpoll.c>
+//#include <si95/sicbreg.c>
+//#include <si95/sicbstat.c>
+//#include <si95/siclose.c>
+//#include <si95/siconnect.c>
+//#include <si95/siestablish.c>
+//#include <si95/sigetadd.c>
+//#include <si95/sigetname.c>
+#include <si95/siinit.c>
+//#include <si95/silisten.c>
+#include <si95/sinew.c>
+//#include <si95/sinewses.c>
+//#include <si95/sipoll.c>
+//#include <si95/sircv.c>
+//#include <si95/sisend.c>
+//#include <si95/sisendt.c>
+#include <si95/sishutdown.c>
+#include <si95/siterm.c>
+#include <si95/sitrash.c>
+//#include <si95/siwait.c>
+
+
+/*
+       Memory allocation/free related tests
+*/
+static int memory( ) {
+       int             errors = 0;
+       void*   ptr;
+       void*   iptr;
+
+       // ---- SInew ----------------
+       ptr = SInew( 100 );                             // invalid block type should return nil
+       errors += fail_not_nil( ptr, "memory: sinew did not return nil when given a valid struct type" );
+       SItrash( 100, NULL );                           // drive trash for coverage
+
+       iptr = SInew( IOQ_BLK );
+       errors += fail_if_nil( iptr, "memory: sinew returned nil when given ioq request" );
+       iptr = SInew( IOQ_BLK );
+       SItrash(  IOQ_BLK, iptr );
+
+       ptr = SInew( TP_BLK );
+       errors += fail_if_nil( ptr, "memory: sinew returned nil when given tpblk request" );
+       if( ptr ) {
+               ((struct tp_blk *)ptr)->squeue = iptr;
+               SItrash(  TP_BLK, ptr );
+       }
+       
+       ptr = SInew( GI_BLK );
+       errors += fail_if_nil( ptr, "memory: sinew returned nil when given giblk request" );
+       SItrash(  GI_BLK, ptr );
+
+
+       return errors;
+}
+
+void*  si_ctx = NULL;                  // a global context might be useful
+
+/*
+       Test initialisation related things
+*/
+static int init() {
+       int             errors = 0;
+
+       si_ctx = SIinitialise( 0 );
+       errors += fail_if_nil( si_ctx, "init: siinit returned a nil pointer" );
+
+       SIclr_tflags( si_ctx, 0x00 );           // drive for coverage; no return value from these
+       SIset_tflags( si_ctx, 0x03 );
+
+       return errors;
+}
+
+/*
+       Drive tests...
+*/
+int main() {
+       int errors = 0;
+
+       rmr_set_vlevel( 5 );                    // enable all debugging
+
+       fprintf( stderr, "\n<INFO> starting SI95 tests\n" );
+
+       errors += init();
+       errors += memory();
+
+       if( errors == 0 ) {
+               fprintf( stderr, "<PASS> all tests were OK\n\n" );
+       } else {
+               fprintf( stderr, "<FAIL> %d errors in SI95 core code\n\n", errors );
+       }
+
+       return !!errors;
+}
index 7cabffa..25d2cca 100644 (file)
@@ -49,6 +49,7 @@ static int worm_test( ) {
        uta_ctx_t* ctx;                 // context needed to test load static rt
        char    wbuf[1024];
        int errors = 0;                 // number errors found
+       int             state = 0;
        int     i;
        void* p;
 
@@ -115,6 +116,7 @@ static int worm_test( ) {
        }
        fail_if_nil( mbuf, "wh_send_msg returned a nil message buffer when given a nil context"  );
 
+
        while( mbuf ) {
                if( !(mbuf = rmr_wh_send_msg( ctx, 50, mbuf )) ) {              // test for coverage
                        errors += fail_if_nil( mbuf, "send didn't return an mbuf (skip rest of send tests)" );
@@ -133,7 +135,25 @@ static int worm_test( ) {
                break;
        }
 
+       // ---- wormhole state -----------
+       state = rmr_wh_state( NULL, 0 );
+       errors += fail_if_equal( state, RMR_OK, "wh_state with bad context did not return error" );
+
+       state = rmr_wh_state( ctx, -1 );
+       errors += fail_if_equal( state, RMR_OK, "wh_state with bad whid did not return error" );
+
+       whid = rmr_wh_open( ctx, "localhost:9219" );
+       if( ! fail_if_equal( whid, -1, "skipping some wh_state tests: no whid returned" ) ) {
+               state = rmr_wh_state( ctx, whid );
+               errors += fail_not_equal( state, RMR_OK, "wh_state on an open wh did not return OK" );
+
+               rmr_wh_close( ctx, whid );
+               state = rmr_wh_state( ctx, whid );
+               errors += fail_if_equal( state, RMR_OK, "wh_state on a closed wh returned OK" );
+               whid = -1;
+       }
 
+       // -----------------------------------------------------------------------
        // WARNING:  these tests destroy the context, so they MUST be last
        if( mbuf ) {                    // only if we got an mbuf
                errno = 0;