summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
ae8e63b)
Change-Id: I05a1cd543ba0603446244122337276028e199382
Signed-off-by: E. Scott Daniels <daniels@research.att.com>
38 files changed:
// :vim ts=4 sw=4 noet:
/*
==================================================================================
// :vim ts=4 sw=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
int main( int argc, char** argv ) {
int main( int argc, char** argv ) {
- void* mrc; // msg router context
+ void* mrc; // msg router context
- rmr_mbuf_t* msg = NULL; // message received
+ rmr_mbuf_t* msg = NULL; // message received
int stat_freq = 10; // write stats after reciving this many messages
int i;
char* listen_port;
int stat_freq = 10; // write stats after reciving this many messages
int i;
char* listen_port;
fprintf( stderr, "<DEMO> listening on port: %s\n", listen_port );
fprintf( stderr, "<DEMO> stats will be reported every %d messages\n", stat_freq );
fprintf( stderr, "<DEMO> listening on port: %s\n", listen_port );
fprintf( stderr, "<DEMO> stats will be reported every %d messages\n", stat_freq );
- mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE ); // start your engines!
+ mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE ); // start your engines!
if( mrc == NULL ) {
fprintf( stderr, "<DEMO> ABORT: unable to initialise RMr\n" );
exit( 1 );
if( mrc == NULL ) {
fprintf( stderr, "<DEMO> ABORT: unable to initialise RMr\n" );
exit( 1 );
}
fprintf( stderr, "<DEMO> rmr now shows ready\n" );
}
fprintf( stderr, "<DEMO> rmr now shows ready\n" );
- while( 1 ) { // forever; ctl-c, kill -15, etc to end
+ while( 1 ) { // forever; ctl-c, kill -15, etc to end
msg = rmr_rcv_msg( mrc, msg ); // block until one arrives
if( msg ) {
msg = rmr_rcv_msg( mrc, msg ); // block until one arrives
if( msg ) {
fprintf( stderr, "<DEMO> total msg received: %lld errors: %lld empty: %lld\n", count, bad, empty );
}
fprintf( stderr, "<DEMO> total msg received: %lld errors: %lld empty: %lld\n", count, bad, empty );
}
// :vim ts=4 sw=4 noet:
/*
==================================================================================
// :vim ts=4 sw=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
#include <rmr/rmr.h>
int main( int argc, char** argv ) {
#include <rmr/rmr.h>
int main( int argc, char** argv ) {
- void* mrc; //msg router context
- struct epoll_event events[1]; // list of events to give to epoll
- struct epoll_event epe; // event definition for event to listen to
- int ep_fd = -1; // epoll's file des (given to epoll_wait)
- int rcv_fd; // file des that NNG tickles -- give this to epoll to listen on
+ void* mrc; //msg router context
+ struct epoll_event events[1]; // list of events to give to epoll
+ struct epoll_event epe; // event definition for event to listen to
+ int ep_fd = -1; // epoll's file des (given to epoll_wait)
+ int rcv_fd; // file des that NNG tickles -- give this to epoll to listen on
int nready; // number of events ready for receive
rmr_mbuf_t* sbuf; // send buffer
rmr_mbuf_t* rbuf; // received buffer
int nready; // number of events ready for receive
rmr_mbuf_t* sbuf; // send buffer
rmr_mbuf_t* rbuf; // received buffer
fprintf( stderr, "<DEMO> listen port: %s; mtype: %d; delay: %d\n", listen_port, mtype, delay );
fprintf( stderr, "<DEMO> listen port: %s; mtype: %d; delay: %d\n", listen_port, mtype, delay );
- if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) {
+ if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) {
fprintf( stderr, "<DEMO> unable to initialise RMr\n" );
exit( 1 );
}
fprintf( stderr, "<DEMO> unable to initialise RMr\n" );
exit( 1 );
}
- rcv_fd = rmr_get_rcvfd( mrc ); // set up epoll things, start by getting the FD from MRr
+ rcv_fd = rmr_get_rcvfd( mrc ); // set up epoll things, start by getting the FD from MRr
if( rcv_fd < 0 ) {
fprintf( stderr, "<DEMO> unable to set up polling fd\n" );
exit( 1 );
if( rcv_fd < 0 ) {
fprintf( stderr, "<DEMO> unable to set up polling fd\n" );
exit( 1 );
fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno );
exit( 1 );
}
fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno );
exit( 1 );
}
- epe.events = EPOLLIN;
- epe.data.fd = rcv_fd;
+ epe.events = EPOLLIN;
+ epe.data.fd = rcv_fd;
- if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 ) {
+ if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 ) {
fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
exit( 1 );
}
fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
exit( 1 );
}
fprintf( stderr, "<DEMO> rmr is ready\n" );
fprintf( stderr, "<DEMO> rmr is ready\n" );
- while( 1 ) { // send messages until the cows come home
+ while( 1 ) { // send messages until the cows come home
snprintf( sbuf->payload, 200, "count=%d received= %d ts=%lld %d stand up and cheer!", // create the payload
count, rcvd_count, (long long) time( NULL ), rand() );
snprintf( sbuf->payload, 200, "count=%d received= %d ts=%lld %d stand up and cheer!", // create the payload
count, rcvd_count, (long long) time( NULL ), rand() );
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
int sub_id; // subscription id
// these things are off limits to the user application
int sub_id; // subscription id
// these things are off limits to the user application
- void* tp_buf; // underlying transport allocated pointer (e.g. nng message)
+ void* tp_buf; // underlying transport allocated pointer (e.g. nng message)
void* header; // internal message header (whole buffer: header+payload)
unsigned char* id; // if we need an ID in the message separate from the xaction id
int flags; // various MFL_ (private) flags as needed
void* header; // internal message header (whole buffer: header+payload)
unsigned char* id; // if we need an ID in the message separate from the xaction id
int flags; // various MFL_ (private) flags as needed
#ifdef UTA_COMPAT
#pragma message( "use of UTA_COMPAT is deprecated and soon to be removed" )
#ifdef UTA_COMPAT
#pragma message( "use of UTA_COMPAT is deprecated and soon to be removed" )
-#define UTA_MAX_XID RMR_MAX_XID
-#define UTA_MAX_SID RMR_MAX_SID
-#define UTA_MAX_SRC RMR_MAX_SRC
-#define UTA_MAX_RCV_BYTES RMR_MAX_RCV_BYTES
+#define UTA_MAX_XID RMR_MAX_XID
+#define UTA_MAX_SID RMR_MAX_SID
+#define UTA_MAX_SRC RMR_MAX_SRC
+#define UTA_MAX_RCV_BYTES RMR_MAX_RCV_BYTES
-#define UTAFL_NONE RMRFL_NONE
-#define UTAFL_AUTO_ALLOC RMRFL_AUTO_ALLOC
+#define UTAFL_NONE RMRFL_NONE
+#define UTAFL_AUTO_ALLOC RMRFL_AUTO_ALLOC
-#define UTA_DEF_SIZE RMRFL_AUTO_ALLOC
+#define UTA_DEF_SIZE RMRFL_AUTO_ALLOC
-#define UTA_OK RMR_OK
-#define UTA_ERR_BADARG RMR_ERR_BADARG
-#define UTA_ERR_NOENDPT RMR_ERR_NOENDPT
+#define UTA_OK RMR_OK
+#define UTA_ERR_BADARG RMR_ERR_BADARG
+#define UTA_ERR_NOENDPT RMR_ERR_NOENDPT
#define UTA_ERR_EMPTY RMR_ERR_EMPTY
#define UTA_ERR_EMPTY RMR_ERR_EMPTY
-#define UTA_ERR_NOHDR RMR_ERR_NOHDR
-#define UTA_ERR_SENDFAILED RMR_ERR_SENDFAILED
-#define UTA_ERR_CALLFAILED RMR_ERR_CALLFAILED
+#define UTA_ERR_NOHDR RMR_ERR_NOHDR
+#define UTA_ERR_SENDFAILED RMR_ERR_SENDFAILED
+#define UTA_ERR_CALLFAILED RMR_ERR_CALLFAILED
#define uta_mbuf_t rmr_mbuf_t
#define uta_mbuf_t rmr_mbuf_t
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
#define RMR_MSG_VER 2 // message version this code was designed to handle
// environment variable names we'll suss out
#define RMR_MSG_VER 2 // message version this code was designed to handle
// environment variable names we'll suss out
-#define ENV_BIND_IF "RMR_BIND_IF" // the interface to bind to for both normal comma and RTG (0.0.0.0 if missing)
+#define ENV_BIND_IF "RMR_BIND_IF" // the interface to bind to for both normal comma and RTG (0.0.0.0 if missing)
#define ENV_RTG_PORT "RMR_RTG_SVC" // the port we'll listen on for rtg connections
#define ENV_SEED_RT "RMR_SEED_RT" // where we expect to find the name of the seed route table
#define ENV_RTG_RAW "RMR_RTG_ISRAW" // if > 0 we expect route table gen messages as raw (not sent from an RMr application)
#define ENV_RTG_PORT "RMR_RTG_SVC" // the port we'll listen on for rtg connections
#define ENV_SEED_RT "RMR_SEED_RT" // where we expect to find the name of the seed route table
#define ENV_RTG_RAW "RMR_RTG_ISRAW" // if > 0 we expect route table gen messages as raw (not sent from an RMr application)
struct timespec ts; // timestamp ???
// V2 extension
struct timespec ts; // timestamp ???
// V2 extension
- int32_t flags; // HFL_* constants
+ int32_t flags; // HFL_* constants
int32_t len0; // length of the RMr header data
int32_t len1; // length of the tracing data
int32_t len2; // length of data 1 (d1)
int32_t len0; // length of the RMr header data
int32_t len1; // length of the tracing data
int32_t len2; // length of data 1 (d1)
- A wormhole is a direct connection between two endpoints that the user app can
+ A wormhole is a direct connection between two endpoints that the user app can
send to without message type based routing.
*/
typedef struct {
send to without message type based routing.
*/
typedef struct {
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
- Abstract: These are common functions which work only on the mbuf and
- thus (because they do not touch an endpoint or context)
+ Abstract: These are common functions which work only on the mbuf and
+ thus (because they do not touch an endpoint or context)
can be agnostic to the underlying transport.
Author: E. Scott Daniels
can be agnostic to the underlying transport.
Author: E. Scott Daniels
// ---------- some wrappers need explicit copy-in functions, also header field setters -----
/*
// ---------- some wrappers need explicit copy-in functions, also header field setters -----
/*
- Allow the user programme to set the meid in the header. The meid is a fixed
+ Allow the user programme to set the meid in the header. The meid is a fixed
length buffer in the header and thus we must ensure it is not overrun. If
the user gives a source buffer that is too large, we truncate. The return
value is the number of bytes copied, or -1 for absolute failure (bad pointer
etc.). Errno is set:
EINVAL id poitner, buf or buf header are bad.
EOVERFLOW if the bytes given would have overrun
length buffer in the header and thus we must ensure it is not overrun. If
the user gives a source buffer that is too large, we truncate. The return
value is the number of bytes copied, or -1 for absolute failure (bad pointer
etc.). Errno is set:
EINVAL id poitner, buf or buf header are bad.
EOVERFLOW if the bytes given would have overrun
*/
extern int rmr_bytes2meid( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
uta_mhdr_t* hdr;
*/
extern int rmr_bytes2meid( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
uta_mhdr_t* hdr;
errno = EOVERFLOW;
return RMR_ERR_OVERFLOW;
}
errno = EOVERFLOW;
return RMR_ERR_OVERFLOW;
}
rmr_bytes2meid( mbuf, str, len+1 );
return RMR_OK;
}
rmr_bytes2meid( mbuf, str, len+1 );
return RMR_OK;
}
/*
This will copy n bytes from source into the payload. If len is larger than
/*
This will copy n bytes from source into the payload. If len is larger than
- the payload only the bytes which will fit are copied, The user should
+ the payload only the bytes which will fit are copied, The user should
check errno on return to determine success or failure.
*/
extern void rmr_bytes2payload( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
check errno on return to determine success or failure.
*/
extern void rmr_bytes2payload( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
etc.). Errno is set:
EINVAL id poitner, buf or buf header are bad.
EOVERFLOW if the bytes given would have overrun
etc.). Errno is set:
EINVAL id poitner, buf or buf header are bad.
EOVERFLOW if the bytes given would have overrun
*/
extern int rmr_bytes2xact( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
uta_mhdr_t* hdr;
*/
extern int rmr_bytes2xact( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
uta_mhdr_t* hdr;
errno = EOVERFLOW;
return RMR_ERR_OVERFLOW;
}
errno = EOVERFLOW;
return RMR_ERR_OVERFLOW;
}
rmr_bytes2xact( mbuf, str, len+1 );
return RMR_OK;
}
rmr_bytes2xact( mbuf, str, len+1 );
return RMR_OK;
}
// ------------------- trace related access functions --------------------------------------
/*
// ------------------- trace related access functions --------------------------------------
/*
- The set_trace function will copy the supplied data for size bytes into the
+ The set_trace function will copy the supplied data for size bytes into the
header. If the header trace area is not large enough, a new one will be allocated
which will cause a payload copy based on the msg->len value (if 0 no payload
data is copied).
header. If the header trace area is not large enough, a new one will be allocated
which will cause a payload copy based on the msg->len value (if 0 no payload
data is copied).
if( size <= 0 ) {
return 0;
}
if( size <= 0 ) {
return 0;
}
hdr = (uta_mhdr_t *) msg->header;
len = RMR_TR_LEN( hdr );
hdr = (uta_mhdr_t *) msg->header;
len = RMR_TR_LEN( hdr );
}
memcpy( TRACE_ADDR( hdr ), data, size );
}
memcpy( TRACE_ADDR( hdr ), data, size );
- Copies the trace bytes from the message header into the buffer provided by
+ Copies the trace bytes from the message header into the buffer provided by
the user. If the trace data in the header is less than size, then only
that number of bytes are copied, else exactly size bytes are copied. The
number actually copied is returned.
the user. If the trace data in the header is less than size, then only
that number of bytes are copied, else exactly size bytes are copied. The
number actually copied is returned.
// :vi sw=4 ts=4 noet:
/*
==================================================================================
// :vi sw=4 ts=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
*/
/*
Mnemonic: ring_static.c
*/
/*
Mnemonic: ring_static.c
- Abstract: Implements a ring of information (probably to act as a
+ Abstract: Implements a ring of information (probably to act as a
message queue).
Author: E. Scott Daniels
Date: 31 August 2017
message queue).
Author: E. Scott Daniels
Date: 31 August 2017
// :vi sw=4 ts=4 noet:
/*
==================================================================================
// :vi sw=4 ts=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
Mnemonic: rt_generic_static.c
/*
Mnemonic: rt_generic_static.c
- Abstract: These are route table functions which are not specific to the
+ Abstract: These are route table functions which are not specific to the
underlying protocol. rtable_static, and rtable_nng_static
have transport provider specific code.
This file must be included before the nng/nano specific file as
underlying protocol. rtable_static, and rtable_nng_static
have transport provider specific code.
This file must be included before the nng/nano specific file as
Author: E. Scott Daniels
Date: 5 February 2019
Author: E. Scott Daniels
Date: 5 February 2019
- Passed to a symtab foreach callback to construct a list of pointers from
+ Passed to a symtab foreach callback to construct a list of pointers from
a current symtab.
*/
typedef struct thing_list {
a current symtab.
*/
typedef struct thing_list {
/*
Parse a single record recevied from the route table generator, or read
/*
Parse a single record recevied from the route table generator, or read
- from a static route table file. Start records cause a new table to
+ from a static route table file. Start records cause a new table to
be started (if a partial table was received it is discarded. Table
be started (if a partial table was received it is discarded. Table
- entry records are added to the currenly 'in progress' table, and an
+ entry records are added to the currenly 'in progress' table, and an
end record causes the in progress table to be finalised and the
currently active table is replaced.
*/
end record causes the in progress table to be finalised and the
currently active table is replaced.
*/
if( ctx->new_rtable != NULL ) { // one in progress? this forces it out
if( DEBUG > 1 || (vlevel > 1) ) fprintf( stderr, "[DBUG] new table; dropping incomplete table\n" );
uta_rt_drop( ctx->new_rtable );
if( ctx->new_rtable != NULL ) { // one in progress? this forces it out
if( DEBUG > 1 || (vlevel > 1) ) fprintf( stderr, "[DBUG] new table; dropping incomplete table\n" );
uta_rt_drop( ctx->new_rtable );
if( ctx->rtable ) {
ctx->new_rtable = uta_rt_clone( ctx->rtable ); // create by cloning endpoint entries from active table
if( ctx->rtable ) {
ctx->new_rtable = uta_rt_clone( ctx->rtable ); // create by cloning endpoint entries from active table
if( ((tok = strchr( tokens[1], ',' )) == NULL ) || // no sender names
(uta_has_str( tokens[1], ctx->my_name, ',', 127) >= 0) || // our name isn't in the list
if( ((tok = strchr( tokens[1], ',' )) == NULL ) || // no sender names
(uta_has_str( tokens[1], ctx->my_name, ',', 127) >= 0) || // our name isn't in the list
- has_myip( tokens[1], ctx->ip_list, ',', 127 ) ) { // the list has one of our IP addresses
+ has_myip( tokens[1], ctx->ip_list, ',', 127 ) ) { // the list has one of our IP addresses
if( DEBUG > 1 || (vlevel > 1) ) fprintf( stderr, "[DBUG] create rte for mtype=%s\n", tokens[1] );
if( DEBUG > 1 || (vlevel > 1) ) fprintf( stderr, "[DBUG] create rte for mtype=%s\n", tokens[1] );
if( (ngtoks = uta_tokenise( tokens[2], gtokens, 64, ';' )) > 0 ) { // split last field by groups first
rte = uta_add_rte( ctx->new_rtable, atoi( tokens[1] ), ngtoks ); // get/create entry for message type
for( grp = 0; grp < ngtoks; grp++ ) {
if( (ngtoks = uta_tokenise( tokens[2], gtokens, 64, ';' )) > 0 ) { // split last field by groups first
rte = uta_add_rte( ctx->new_rtable, atoi( tokens[1] ), ngtoks ); // get/create entry for message type
for( grp = 0; grp < ngtoks; grp++ ) {
- if( DEBUG || (vlevel > 2) )
+ if( DEBUG || (vlevel > 2) )
fprintf( stderr, "entry not included, sender not matched: %s\n", tokens[1] );
}
fprintf( stderr, "entry not included, sender not matched: %s\n", tokens[1] );
}
This function attempts to open a static route table in order to create a 'seed'
table during initialisation. The environment variable RMR_SEED_RT is expected
to contain the necessary path to the file. If missing, or if the file is empty,
This function attempts to open a static route table in order to create a 'seed'
table during initialisation. The environment variable RMR_SEED_RT is expected
to contain the necessary path to the file. If missing, or if the file is empty,
- no route table will be available until one is received from the generator.
+ no route table will be available until one is received from the generator.
- This function is probably most useful for testing situations, or extreme
+ This function is probably most useful for testing situations, or extreme
cases where the routes are static.
*/
static void read_static_rt( uta_ctx_t* ctx, int vlevel ) {
cases where the routes are static.
*/
static void read_static_rt( uta_ctx_t* ctx, int vlevel ) {
- Called to delete a route table entry struct. We delete the array of endpoint
- pointers, but NOT the endpoints referenced as those are referenced from
+ Called to delete a route table entry struct. We delete the array of endpoint
+ pointers, but NOT the endpoints referenced as those are referenced from
multiple entries.
*/
static void del_rte( void* st, void* entry, char const* name, void* thing, void* data ) {
multiple entries.
*/
static void del_rte( void* st, void* entry, char const* name, void* thing, void* data ) {
off_t nread; // number of bytes read
int fd;
char* buf; // input buffer
off_t nread; // number of bytes read
int fd;
char* buf; // input buffer
if( (fd = open( fname, O_RDONLY )) >= 0 ) {
if( fstat( fd, &stats ) >= 0 ) {
if( stats.st_size <= 0 ) { // empty file
if( (fd = open( fname, O_RDONLY )) >= 0 ) {
if( fstat( fd, &stats ) >= 0 ) {
if( stats.st_size <= 0 ) { // empty file
the context.
*/
static route_table_t* uta_rt_clone( route_table_t* srt ) {
the context.
*/
static route_table_t* uta_rt_clone( route_table_t* srt ) {
- endpoint_t* ep; // an endpoint
+ endpoint_t* ep; // an endpoint
route_table_t* nrt; // new route table
route_table_t* art; // active route table
void* sst; // source symtab
route_table_t* nrt; // new route table
route_table_t* art; // active route table
void* sst; // source symtab
nst = nrt->hash;
rmr_sym_foreach_class( sst, 1, collect_things, &things ); // collect the named endpoints in the active table
nst = nrt->hash;
rmr_sym_foreach_class( sst, 1, collect_things, &things ); // collect the named endpoints in the active table
for( i = 0; i < things.nused; i++ ) {
ep = (endpoint_t *) things.things[i];
rmr_sym_put( nst, ep->name, 1, ep ); // slam this one into the new table
for( i = 0; i < things.nused; i++ ) {
ep = (endpoint_t *) things.things[i];
rmr_sym_put( nst, ep->name, 1, ep ); // slam this one into the new table
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
char* port; // a port number we listen/connect to
char* fport; // pointer to the real buffer to free
size_t buf_size; // nng needs var pointer not just size?
char* port; // a port number we listen/connect to
char* fport; // pointer to the real buffer to free
size_t buf_size; // nng needs var pointer not just size?
- char* nextr; // pointer at next record in the message
+ char* nextr; // pointer at next record in the message
char* curr; // current record
int i;
long blabber = 0; // time of last blabber so we don't flood if rtg goes bad
char* curr; // current record
int i;
long blabber = 0; // time of last blabber so we don't flood if rtg goes bad
}
if( (eptr = getenv( ENV_VERBOSE_FILE )) != NULL ) {
}
if( (eptr = getenv( ENV_VERBOSE_FILE )) != NULL ) {
- vfd = open( eptr, O_RDONLY );
+ vfd = open( eptr, O_RDONLY );
if( vfd >= 0 ) {
wbuf[0] = 0;
lseek( vfd, 0, 0 );
if( vfd >= 0 ) {
wbuf[0] = 0;
lseek( vfd, 0, 0 );
ntoks = uta_tokenise( port, tokens, 120, ':' ); // assume tcp:port, but it could be port or old style host:port
switch( ntoks ) {
ntoks = uta_tokenise( port, tokens, 120, ':' ); // assume tcp:port, but it could be port or old style host:port
switch( ntoks ) {
port = tokens[0]; // just the port
break;
port = tokens[0]; // just the port
break;
curr = pbuf;
while( curr ) { // loop over each record in the buffer
nextr = strchr( curr, '\n' ); // allow multiple newline records, find end of current and mark
curr = pbuf;
while( curr ) { // loop over each record in the buffer
nextr = strchr( curr, '\n' ); // allow multiple newline records, find end of current and mark
if( nextr ) {
*(nextr++) = 0;
}
if( nextr ) {
*(nextr++) = 0;
}
if( vlevel > 1 ) {
fprintf( stderr, "[DBUG] rmr_rtc: processing (%s)\n", curr );
}
parse_rt_rec( ctx, curr, vlevel ); // parse record and add to in progress table
if( vlevel > 1 ) {
fprintf( stderr, "[DBUG] rmr_rtc: processing (%s)\n", curr );
}
parse_rt_rec( ctx, curr, vlevel ); // parse record and add to in progress table
if( ctx->shutdown ) { // mostly for testing, but allows user app to close us down if rmr_*() function sets this
break;
}
if( ctx->shutdown ) { // mostly for testing, but allows user app to close us down if rmr_*() function sets this
break;
}
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
------------------------------------------------------------------------------
Mnemonic: symtab.c
Abstract: Symbol table -- slightly streamlined from it's original 2000 version
------------------------------------------------------------------------------
Mnemonic: symtab.c
Abstract: Symbol table -- slightly streamlined from it's original 2000 version
- (a part of the {X}fm opensource code), though we must retain the
+ (a part of the {X}fm opensource code), though we must retain the
original copyright.
Things changed for the Ric Msg implemention (Nov 2018):
- no concept of copy/free of the user data (functions removed)
- add ability to support an integer key (class 0)
- externally visible names given a rmr_ extension as it's being
original copyright.
Things changed for the Ric Msg implemention (Nov 2018):
- no concept of copy/free of the user data (functions removed)
- add ability to support an integer key (class 0)
- externally visible names given a rmr_ extension as it's being
- incorporated into the RIC msg routing library and will be
+ incorporated into the RIC msg routing library and will be
available to user applications.
Date: 11 Feb 2000
available to user applications.
Date: 11 Feb 2000
void *val; /* user data associated with name */
unsigned long mcount; /* modificaitons to value */
unsigned long rcount; /* references to symbol */
void *val; /* user data associated with name */
unsigned long mcount; /* modificaitons to value */
unsigned long rcount; /* references to symbol */
unsigned int class; /* helps divide things up and allows for duplicate names */
} Sym_ele;
unsigned int class; /* helps divide things up and allows for duplicate names */
} Sym_ele;
Sym_ele **symlist; /* pointer to list of element pointerss */
long inhabitants; /* number of active residents */
long deaths; /* number of deletes */
Sym_ele **symlist; /* pointer to list of element pointerss */
long inhabitants; /* number of active residents */
long deaths; /* number of deletes */
} Sym_tab;
// -------------------- internal ------------------------------------------------------------------
} Sym_tab;
// -------------------- internal ------------------------------------------------------------------
eptr->next->prev = eptr->prev;
if( eptr->class && eptr->name ) { // class 0 entries are numeric, so name is NOT a pointer
eptr->next->prev = eptr->prev;
if( eptr->class && eptr->name ) { // class 0 entries are numeric, so name is NOT a pointer
- free( (void *) eptr->name ); // and if free fails, what? panic?
+ free( (void *) eptr->name ); // and if free fails, what? panic?
Generic routine to put something into the table
called by sym_map or sym_put since the logic for each is pretty
much the same.
*/
static int putin( Sym_tab *table, const char *name, unsigned int class, void *val ) {
Generic routine to put something into the table
called by sym_map or sym_put since the logic for each is pretty
much the same.
*/
static int putin( Sym_tab *table, const char *name, unsigned int class, void *val ) {
- Sym_ele *eptr; /* pointer into hash table */
- Sym_ele **sym_tab; /* pointer into hash table */
+ Sym_ele *eptr; /* pointer into hash table */
+ Sym_ele **sym_tab; /* pointer into hash table */
int hv; /* hash value */
int rc = 0; /* assume it existed */
unsigned int nkey = 0; // numeric key if class == 0
int hv; /* hash value */
int rc = 0; /* assume it existed */
unsigned int nkey = 0; // numeric key if class == 0
if( ! eptr ) { // not found above, so add
rc++;
table->inhabitants++;
if( ! eptr ) { // not found above, so add
rc++;
table->inhabitants++;
eptr = (Sym_ele *) malloc( sizeof( Sym_ele) );
if( ! eptr ) {
fprintf( stderr, "[FAIL] symtab/putin: out of memory\n" );
return -1;
eptr = (Sym_ele *) malloc( sizeof( Sym_ele) );
if( ! eptr ) {
fprintf( stderr, "[FAIL] symtab/putin: out of memory\n" );
return -1;
eptr->prev = NULL;
eptr->class = class;
eptr->prev = NULL;
eptr->class = class;
{
Sym_tab *table;
Sym_ele **sym_tab;
{
Sym_tab *table;
Sym_ele **sym_tab;
table = (Sym_tab *) vtable;
sym_tab = table->symlist;
for( i = 0; i < table->size; i++ )
table = (Sym_tab *) vtable;
sym_tab = table->symlist;
for( i = 0; i < table->size; i++ )
del_ele( table, i, sym_tab[i] );
}
del_ele( table, i, sym_tab[i] );
}
extern void rmr_sym_dump( void *vtable )
{
Sym_tab *table;
extern void rmr_sym_dump( void *vtable )
{
Sym_tab *table;
Sym_ele *eptr;
Sym_ele **sym_tab;
Sym_ele *eptr;
Sym_ele **sym_tab;
for( i = 0; i < table->size; i++ )
{
if( sym_tab[i] )
for( i = 0; i < table->size; i++ )
{
if( sym_tab[i] )
- for( eptr = sym_tab[i]; eptr; eptr = eptr->next )
+ for( eptr = sym_tab[i]; eptr; eptr = eptr->next )
{
if( eptr->val && eptr->class ) {
fprintf( stderr, "key=%s val@=%p\n", eptr->name, eptr->val );
{
if( eptr->val && eptr->class ) {
fprintf( stderr, "key=%s val@=%p\n", eptr->name, eptr->val );
memset( table, 0, sizeof( *table ) );
memset( table, 0, sizeof( *table ) );
- if((table->symlist = (Sym_ele **) malloc( sizeof( Sym_ele *) * size )))
+ if((table->symlist = (Sym_ele **) malloc( sizeof( Sym_ele *) * size )))
{
memset( table->symlist, 0, sizeof( Sym_ele *) * size );
table->size = size;
{
memset( table->symlist, 0, sizeof( Sym_ele *) * size );
table->size = size;
return (void *) table; /* user might want to know what the size is */
}
return (void *) table; /* user might want to know what the size is */
}
Delete an element given name/class or numeric key (class 0).
*/
extern void rmr_sym_del( void *vtable, const char *name, unsigned int class )
{
Sym_tab *table;
Sym_ele **sym_tab;
Delete an element given name/class or numeric key (class 0).
*/
extern void rmr_sym_del( void *vtable, const char *name, unsigned int class )
{
Sym_tab *table;
Sym_ele **sym_tab;
- Sym_ele *eptr; /* pointer into hash table */
+ Sym_ele *eptr; /* pointer into hash table */
int hv; /* hash value */
unsigned int nkey; // class 0, name points to integer not string
int hv; /* hash value */
unsigned int nkey; // class 0, name points to integer not string
return rmr_sym_get( vtable, (const char *) &key, 0 );
}
return rmr_sym_get( vtable, (const char *) &key, 0 );
}
Put an element with a string key into the table. Replaces the element
if it was already there. Class must be >0 and if not 1 will be forced.
(class 0 keys are numeric).
Put an element with a string key into the table. Replaces the element
if it was already there. Class must be >0 and if not 1 will be forced.
(class 0 keys are numeric).
return putin( table, name, class, val );
}
return putin( table, name, class, val );
}
Add a new entry assuming that the key is an unsigned integer.
Add a new entry assuming that the key is an unsigned integer.
- Returns 1 if new, 0 if existed
+ Returns 1 if new, 0 if existed
*/
extern int rmr_sym_map( void *vtable, unsigned int key, void *val ) {
Sym_tab *table;
*/
extern int rmr_sym_map( void *vtable, unsigned int key, void *val ) {
Sym_tab *table;
return putin( table, (const char *) &key, 0, val );
}
return putin( table, (const char *) &key, 0, val );
}
-/*
- Dump some statistics to stderr dev. Higher level is the more info dumpped
+/*
+ Dump some statistics to stderr dev. Higher level is the more info dumpped
*/
extern void rmr_sym_stats( void *vtable, int level )
{
*/
extern void rmr_sym_stats( void *vtable, int level )
{
ch_count = 0;
if( sym_tab[i] )
{
ch_count = 0;
if( sym_tab[i] )
{
- for( eptr = sym_tab[i]; eptr; eptr = eptr->next )
+ for( eptr = sym_tab[i]; eptr; eptr = eptr->next )
{
ch_count++;
if( level > 3 ) {
{
ch_count++;
if( level > 3 ) {
- if( ch_count > max_chain )
+ if( ch_count > max_chain )
{
max_chain = ch_count;
maxi = i;
{
max_chain = ch_count;
maxi = i;
- fprintf( stderr, "sym:%ld(size) %ld(inhab) %ld(occupied) %ld(dead) %ld(maxch) %d(>2per)\n",
+ fprintf( stderr, "sym:%ld(size) %ld(inhab) %ld(occupied) %ld(dead) %ld(maxch) %d(>2per)\n",
table->size, table->inhabitants, table->size - empty, table->deaths, max_chain, twoper );
}
table->size, table->inhabitants, table->size - empty, table->deaths, max_chain, twoper );
}
// :vi sw=4 ts=4 noet:
/*
==================================================================================
// :vi sw=4 ts=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
- Looks for the environment variable RMR_RTG_SVC which we assume to be name[:port], and
+ Looks for the environment variable RMR_RTG_SVC which we assume to be name[:port], and
does a dns lookup on the name. If the env does not have such a variable, we default to
"rtg" and a port of 5656.
does a dns lookup on the name. If the env does not have such a variable, we default to
"rtg" and a port of 5656.
return ctx->rtg_addr != NULL;
}
return ctx->rtg_addr != NULL;
}
/*
Expects a buffer of 'sep' separated tokens and looks to see if
/*
Expects a buffer of 'sep' separated tokens and looks to see if
- the given string is one of those tokens. Returns the token
+ the given string is one of those tokens. Returns the token
index (0 - n-1) if the string is found; -1 otherwise. The max
parameter supplies the maximum number of tokens to search in
the buffer.
On failure (-1) errno will be set in cases where memory cannot
be alocated (is this even possible any more?). If errno is 0
index (0 - n-1) if the string is found; -1 otherwise. The max
parameter supplies the maximum number of tokens to search in
the buffer.
On failure (-1) errno will be set in cases where memory cannot
be alocated (is this even possible any more?). If errno is 0
- and failure is returned, then the caller should assume that
+ and failure is returned, then the caller should assume that
the token isn't in the list, or the list had no elements.
*/
static int uta_has_str( char const* buf, char const* str, char sep, int max ) {
the token isn't in the list, or the list had no elements.
*/
static int uta_has_str( char const* buf, char const* str, char sep, int max ) {
for( i = 0; rc < 0 && i < ntokens; i++ ) {
if( tokens[i] ) {
if( strcmp( tokens[i], str ) == 0 ) {
for( i = 0; rc < 0 && i < ntokens; i++ ) {
if( tokens[i] ) {
if( strcmp( tokens[i], str ) == 0 ) {
char* fmt;
char* envp; // at the environment var if there
char* fmt;
char* envp; // at the environment var if there
if( (l = (if_addrs_t *) malloc( sizeof( if_addrs_t ) )) == NULL ) {
return NULL;
if( (l = (if_addrs_t *) malloc( sizeof( if_addrs_t ) )) == NULL ) {
return NULL;
Check the address:port passed in and return true if it matches
one of the addresses we saw when we built the list. Right now
this isn't a speed intensive part of our processing, so we just
Check the address:port passed in and return true if it matches
one of the addresses we saw when we built the list. Right now
this isn't a speed intensive part of our processing, so we just
- do a straight search through the list. We don't expect this to
+ do a straight search through the list. We don't expect this to
ever be a higly driven functions so not bothering to optimise.
*/
int is_this_myip( if_addrs_t* l, char* addr ) {
ever be a higly driven functions so not bothering to optimise.
*/
int is_this_myip( if_addrs_t* l, char* addr ) {
if( max < 2 ) {
return 0;
}
if( max < 2 ) {
return 0;
}
if( buf == NULL ) {
return 0;
}
if( buf == NULL ) {
return 0;
}
for( i = 0; ! rc && i < ntokens; i++ ) {
if( tokens[i] ) {
if( is_this_myip( list, tokens[i] ) ) {
for( i = 0; ! rc && i < ntokens; i++ ) {
if( tokens[i] ) {
if( is_this_myip( list, tokens[i] ) ) {
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
This function returns true if the current application is permitted to open a wormhole
/*
This function returns true if the current application is permitted to open a wormhole
This is a place holder for future functionality.
*/
This is a place holder for future functionality.
*/
}
if( whm->eps[i] == ep ) {
}
if( whm->eps[i] == ep ) {
- return i; // we're already pointing to it, just send it back again
+ return i; // we're already pointing to it, just send it back again
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
- Context describing our world. Should be returned to user programme on
+ Context describing our world. Should be returned to user programme on
call to initialise, and passed as first parm on all calls to other
visible functions.
call to initialise, and passed as first parm on all calls to other
visible functions.
route_table_t* new_rtable; // route table under construction
if_addrs_t* ip_list; // list manager of the IP addresses that are on our known interfaces
void* mring; // ring where msgs are queued while waiting for a call response msg
route_table_t* new_rtable; // route table under construction
if_addrs_t* ip_list; // list manager of the IP addresses that are on our known interfaces
void* mring; // ring where msgs are queued while waiting for a call response msg
char* rtg_addr; // addr/port of the route table generation publisher
int rtg_port; // the port that the rtg listens on
char* rtg_addr; // addr/port of the route table generation publisher
int rtg_port; // the port that the rtg listens on
// :vi sw=4 ts=4 noet:
/*
==================================================================================
// :vi sw=4 ts=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
the older nanomsg messaging transport mehhanism.
To "hide" internal functions the choice was made to implement them
the older nanomsg messaging transport mehhanism.
To "hide" internal functions the choice was made to implement them
- all as static functions. This means that we include nearly
+ all as static functions. This means that we include nearly
all of our modules here as 90% of the library is not visible to
all of our modules here as 90% of the library is not visible to
Author: E. Scott Daniels
Date: 28 November 2018
Author: E. Scott Daniels
Date: 28 November 2018
time = time * 1000; // assume seconds, nn wants ms
}
time = time * 1000; // assume seconds, nn wants ms
}
return nn_setsockopt( ctx->nn_sock, NN_SOL_SOCKET, NN_SNDTIMEO, &time, sizeof( time ) );
}
return nn_setsockopt( ctx->nn_sock, NN_SOL_SOCKET, NN_SNDTIMEO, &time, sizeof( time ) );
}
Returns the size of the payload (bytes) that the msg buffer references.
Len in a message is the number of bytes which were received, or should
be transmitted, however, it is possible that the mbuf was allocated
Returns the size of the payload (bytes) that the msg buffer references.
Len in a message is the number of bytes which were received, or should
be transmitted, however, it is possible that the mbuf was allocated
- with a larger payload space than the payload length indicates; this
+ with a larger payload space than the payload length indicates; this
function returns the absolute maximum space that the user has available
in the payload. On error (bad msg buffer) -1 is returned and errno should
indicate the rason.
function returns the absolute maximum space that the user has available
in the payload. On error (bad msg buffer) -1 is returned and errno should
indicate the rason.
free( mbuf->header );
}
}
free( mbuf->header );
}
}
- Accept a message and send it to an endpoint based on message type.
+ Accept a message and send it to an endpoint based on message type.
Allocates a new message buffer for the next send. If a message type has
more than one group of endpoints defined, then the message will be sent
Allocates a new message buffer for the next send. If a message type has
more than one group of endpoints defined, then the message will be sent
- in round robin fashion to one endpoint in each group.
+ in round robin fashion to one endpoint in each group.
CAUTION: this is a non-blocking send. If the message cannot be sent, then
it will return with an error and errno set to eagain. If the send is
CAUTION: this is a non-blocking send. If the message cannot be sent, then
it will return with an error and errno set to eagain. If the send is
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
errno = EINVAL; // must ensure it's not eagain
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
errno = EINVAL; // must ensure it's not eagain
while( send_again ) {
nn_sock = uta_epsock_rr( ctx->rtable, msg->mtype, group, &send_again ); // round robin select endpoint; again set if mult groups
while( send_again ) {
nn_sock = uta_epsock_rr( ctx->rtable, msg->mtype, group, &send_again ); // round robin select endpoint; again set if mult groups
- if( DEBUG ) fprintf( stderr, "[DBUG] send msg: type=%d again=%d group=%d socket=%d len=%d\n",
+ if( DEBUG ) fprintf( stderr, "[DBUG] send msg: type=%d again=%d group=%d socket=%d len=%d\n",
msg->mtype, send_again, group, nn_sock, msg->len );
group++;
msg->mtype, send_again, group, nn_sock, msg->len );
group++;
/*
if( msg ) {
// error do we need to count successes/errors, how to report some success, esp if last fails?
/*
if( msg ) {
// error do we need to count successes/errors, how to report some success, esp if last fails?
*/
msg = clone_m; // clone will be the next to send
*/
msg = clone_m; // clone will be the next to send
- Return to sender allows a message to be sent back to the endpoint where it originated.
+ Return to sender allows a message to be sent back to the endpoint where it originated.
The source information in the message is used to select the socket on which to write
The source information in the message is used to select the socket on which to write
- the message rather than using the message type and round-robin selection. This
+ the message rather than using the message type and round-robin selection. This
should return a message buffer with the state of the send operation set. On success
(state is RMR_OK, the caller may use the buffer for another receive operation), and on
error it can be passed back to this function to retry the send if desired. On error,
should return a message buffer with the state of the send operation set. On success
(state is RMR_OK, the caller may use the buffer for another receive operation), and on
error it can be passed back to this function to retry the send if desired. On error,
errno = EINVAL; // if msg is null, this is their clue
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
errno = EINVAL; // if msg is null, this is their clue
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
Normally, a message struct pointer is returned and msg->state must be checked for RMR_OK
to ensure that no error was encountered. If the state is UTA_BADARG, then the message
Normally, a message struct pointer is returned and msg->state must be checked for RMR_OK
to ensure that no error was encountered. If the state is UTA_BADARG, then the message
- may be resent (likely the context pointer was nil). If the message is sent, but no
+ may be resent (likely the context pointer was nil). If the message is sent, but no
response is received, a nil message is returned with errno set to indicate the likley
issue:
ETIMEDOUT -- too many messages were queued before reciving the expected response
response is received, a nil message is returned with errno set to indicate the likley
issue:
ETIMEDOUT -- too many messages were queued before reciving the expected response
if( (ctx = (uta_ctx_t *) vctx) == NULL || msg == NULL ) { // bad stuff, bail fast
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL || msg == NULL ) { // bad stuff, bail fast
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( old_msg != NULL ) {
old_msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( old_msg != NULL ) {
old_msg->state = RMR_ERR_BADARG;
errno = EINVAL;
return old_msg;
}
errno = EINVAL;
return old_msg;
}
- Receive with a timeout. This is a convenience function when sitting on top of
- nanomsg as it just sets the rcv timeout and calls rmr_rcv_msg().
+ Receive with a timeout. This is a convenience function when sitting on top of
+ nanomsg as it just sets the rcv timeout and calls rmr_rcv_msg().
*/
extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
uta_ctx_t* ctx;
*/
extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
uta_ctx_t* ctx;
/*
This blocks until the message with the 'expect' ID is received. Messages which are received
/*
This blocks until the message with the 'expect' ID is received. Messages which are received
- before the expected message are queued onto the message ring. The function will return
+ before the expected message are queued onto the message ring. The function will return
a nil message and set errno to ETIMEDOUT if allow2queue messages are received before the
expected message is received. If the queued message ring fills a nil pointer is returned
and errno is set to ENOBUFS.
a nil message and set errno to ETIMEDOUT if allow2queue messages are received before the
expected message is received. If the queued message ring fills a nil pointer is returned
and errno is set to ENOBUFS.
- Generally this will be invoked only by the call() function as it waits for a response, but
+ Generally this will be invoked only by the call() function as it waits for a response, but
it is exposed to the user application as three is no reason not to.
*/
extern rmr_mbuf_t* rmr_rcv_specific( void* vctx, rmr_mbuf_t* msg, char* expect, int allow2queue ) {
uta_ctx_t* ctx;
int queued = 0; // number we pushed into the ring
int exp_len = 0; // length of expected ID
it is exposed to the user application as three is no reason not to.
*/
extern rmr_mbuf_t* rmr_rcv_specific( void* vctx, rmr_mbuf_t* msg, char* expect, int allow2queue ) {
uta_ctx_t* ctx;
int queued = 0; // number we pushed into the ring
int exp_len = 0; // length of expected ID
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
errno = EINVAL;
return msg;
}
errno = EINVAL;
return msg;
}
char* proto = "tcp"; // pointer into the proto/port string user supplied
char* port;
char* proto_port;
char* proto = "tcp"; // pointer into the proto/port string user supplied
char* port;
char* proto_port;
- char wbuf[1024]; // work buffer
+ char wbuf[1024]; // work buffer
char* tok; // pointer at token in a buffer
int state;
char* interface = NULL; // interface to bind to pulled from RMR_BIND_IF if set
char* tok; // pointer at token in a buffer
int state;
char* interface = NULL; // interface to bind to pulled from RMR_BIND_IF if set
- fprintf( stderr, "[INFO] ric message routing library on nanomsg (%s %s.%s.%s built: %s)\n",
+ fprintf( stderr, "[INFO] ric message routing library on nanomsg (%s %s.%s.%s built: %s)\n",
QUOTE_DEF(GIT_ID), QUOTE_DEF(MAJOR_VER), QUOTE_DEF(MINOR_VER), QUOTE_DEF(PATCH_VER), __DATE__ );
errno = 0;
QUOTE_DEF(GIT_ID), QUOTE_DEF(MAJOR_VER), QUOTE_DEF(MINOR_VER), QUOTE_DEF(PATCH_VER), __DATE__ );
errno = 0;
uta_lookup_rtg( ctx ); // attempt to fill in rtg info; rtc will handle missing values/errors
uta_lookup_rtg( ctx ); // attempt to fill in rtg info; rtc will handle missing values/errors
- ctx->nn_sock = nn_socket( AF_SP, NN_PULL ); // our 'listen' socket should allow multiple senders to connect
+ ctx->nn_sock = nn_socket( AF_SP, NN_PULL ); // our 'listen' socket should allow multiple senders to connect
if( ctx->nn_sock < 0 ) {
fprintf( stderr, "[CRIT] rmr_init: unable to initialise nanomsg listen socket: %d\n", errno );
free_ctx( ctx );
if( ctx->nn_sock < 0 ) {
fprintf( stderr, "[CRIT] rmr_init: unable to initialise nanomsg listen socket: %d\n", errno );
free_ctx( ctx );
interface = "0.0.0.0";
}
snprintf( bind_info, sizeof( bind_info ), "%s://%s:%s", proto, interface, port );
interface = "0.0.0.0";
}
snprintf( bind_info, sizeof( bind_info ), "%s://%s:%s", proto, interface, port );
- if( nn_bind( ctx->nn_sock, bind_info ) < 0) { // bind and automatically accept client sessions
+ if( nn_bind( ctx->nn_sock, bind_info ) < 0) { // bind and automatically accept client sessions
fprintf( stderr, "[CRIT] rmr_init: unable to bind nanomsg listen socket for %s: %s\n", bind_info, strerror( errno ) );
nn_close( ctx->nn_sock );
free_ctx( ctx );
fprintf( stderr, "[CRIT] rmr_init: unable to bind nanomsg listen socket for %s: %s\n", bind_info, strerror( errno ) );
nn_close( ctx->nn_sock );
free_ctx( ctx );
/*
Publicly facing initialisation function. Wrapper for the init() funcion above
/*
Publicly facing initialisation function. Wrapper for the init() funcion above
- as it needs to ensure internal flags are masked off before calling the
+ as it needs to ensure internal flags are masked off before calling the
real workhorse.
*/
extern void* rmr_init( char* uproto_port, int max_msg_size, int flags ) {
real workhorse.
*/
extern void* rmr_init( char* uproto_port, int max_msg_size, int flags ) {
- Provides a non-fatal (compile) interface for the nng only function.
+ Provides a non-fatal (compile) interface for the nng only function.
Not supported on top of nano, so this always returns -1.
*/
extern int rmr_get_rcvfd( void* vctx ) {
Not supported on top of nano, so this always returns -1.
*/
extern int rmr_get_rcvfd( void* vctx ) {
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
return;
}
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
return;
}
nn_close( ctx->nn_sock );
}
nn_close( ctx->nn_sock );
}
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
- nn_sock = nn_socket( AF_SP, NN_PUSH ); // the socket we'll use to connect to the target
+ nn_sock = nn_socket( AF_SP, NN_PUSH ); // the socket we'll use to connect to the target
if( nn_sock < 0 ) {
fprintf( stderr, "[WARN] rmr: link2: unable to create socket for link to target: %s: %d\n", target, errno );
return -1;
}
snprintf( conn_info, sizeof( conn_info ), "tcp://%s", target );
if( nn_sock < 0 ) {
fprintf( stderr, "[WARN] rmr: link2: unable to create socket for link to target: %s: %d\n", target, errno );
return -1;
}
snprintf( conn_info, sizeof( conn_info ), "tcp://%s", target );
- if( nn_connect( nn_sock, conn_info ) < 0 ) { // connect failed
+ if( nn_connect( nn_sock, conn_info ) < 0 ) { // connect failed
fprintf( stderr, "[WARN] rmr: link2: unable to create link to target: %s: %d\n", target, errno );
nn_close( nn_sock );
return -1;
fprintf( stderr, "[WARN] rmr: link2: unable to create link to target: %s: %d\n", target, errno );
nn_close( nn_sock );
return -1;
- Add an endpoint to a route table entry for the group given. If the endpoint isn't in the
+ Add an endpoint to a route table entry for the group given. If the endpoint isn't in the
hash we add it and create the endpoint struct.
The caller must supply the specific route table (we assume it will be pending, but they
hash we add it and create the endpoint struct.
The caller must supply the specific route table (we assume it will be pending, but they
entry. Returns the nanomsg socket number if there is a rte for the message
type, and group is defined, else returns -1.
entry. Returns the nanomsg socket number if there is a rte for the message
type, and group is defined, else returns -1.
- The group is the group number to select from.
+ The group is the group number to select from.
The user supplied integer 'more' will be set if there are additional groups
defined to the matching route table entry which have a higher group number.
The user supplied integer 'more' will be set if there are additional groups
defined to the matching route table entry which have a higher group number.
nn_sock = rrg->epts[0]->nn_sock;
ep = rrg->epts[0];
break;
nn_sock = rrg->epts[0]->nn_sock;
ep = rrg->epts[0];
break;
default: // need to pick one and adjust rr counts
ep = rrg->epts[rrg->ep_idx];
nn_sock = rrg->epts[rrg->ep_idx++]->nn_sock;
default: // need to pick one and adjust rr counts
ep = rrg->epts[rrg->ep_idx];
nn_sock = rrg->epts[rrg->ep_idx++]->nn_sock;
// :vi sw=4 ts=4 noet:
/*
==================================================================================
// :vi sw=4 ts=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
memcpy( hdr, old_msg->header, sizeof( uta_mhdr_t ) ); // ONLY copy the header portion; trace and data offsets might have changed
if( RMR_D1_LEN( hdr ) ) {
memcpy( DATA1_ADDR( hdr ), DATA1_ADDR( old_msg->header ), RMR_D1_LEN( hdr ) ); // copy data1 and data2 if necessary
memcpy( hdr, old_msg->header, sizeof( uta_mhdr_t ) ); // ONLY copy the header portion; trace and data offsets might have changed
if( RMR_D1_LEN( hdr ) ) {
memcpy( DATA1_ADDR( hdr ), DATA1_ADDR( old_msg->header ), RMR_D1_LEN( hdr ) ); // copy data1 and data2 if necessary
}
if( RMR_D2_LEN( hdr ) ) {
memcpy( DATA2_ADDR( hdr ), DATA2_ADDR( old_msg->header ), RMR_D2_LEN( hdr ) ); // copy data1 and data2 if necessary
}
if( RMR_D2_LEN( hdr ) ) {
memcpy( DATA2_ADDR( hdr ), DATA2_ADDR( old_msg->header ), RMR_D2_LEN( hdr ) ); // copy data1 and data2 if necessary
nm->payload = PAYLOAD_ADDR( hdr ); // reference user payload
break;
}
nm->payload = PAYLOAD_ADDR( hdr ); // reference user payload
break;
}
// --- these are all version agnostic -----------------------------------
nm->mtype = old_msg->mtype;
nm->sub_id = old_msg->sub_id;
// --- these are all version agnostic -----------------------------------
nm->mtype = old_msg->mtype;
nm->sub_id = old_msg->sub_id;
msg->flags |= MFL_ADDSRC; // turn on so if user app tries to send this buffer we reset src
msg->payload = PAYLOAD_ADDR( msg->header );
msg->xaction = &hdr->xid[0]; // provide user with ref to fixed space xaction id
msg->flags |= MFL_ADDSRC; // turn on so if user app tries to send this buffer we reset src
msg->payload = PAYLOAD_ADDR( msg->header );
msg->xaction = &hdr->xid[0]; // provide user with ref to fixed space xaction id
- if( DEBUG > 1 ) fprintf( stderr, "[DBUG] rcv_msg: got something: type=%d state=%d len=%d diff=%ld\n",
+ if( DEBUG > 1 ) fprintf( stderr, "[DBUG] rcv_msg: got something: type=%d state=%d len=%d diff=%ld\n",
msg->mtype, msg->state, msg->len, msg->payload - (unsigned char *) msg->header );
} else {
msg->len = 0;
msg->mtype, msg->state, msg->len, msg->payload - (unsigned char *) msg->header );
} else {
msg->len = 0;
/*
Receives a 'raw' message from a non-RMr sender (no header expected). The returned
/*
Receives a 'raw' message from a non-RMr sender (no header expected). The returned
- message buffer cannot be used to send, and the length information may or may
+ message buffer cannot be used to send, and the length information may or may
not be correct (it is set to the length received which might be more than the
bytes actually in the payload).
*/
not be correct (it is set to the length received which might be more than the
bytes actually in the payload).
*/
/*
This does the hard work of actually sending the message to the given socket. On success,
/*
This does the hard work of actually sending the message to the given socket. On success,
- a new message struct is returned. On error, the original msg is returned with the state
- set to a reasonable value. If the message being sent as MFL_NOALLOC set, then a new
+ a new message struct is returned. On error, the original msg is returned with the state
+ set to a reasonable value. If the message being sent as MFL_NOALLOC set, then a new
buffer will not be allocated and returned (mostly for call() interal processing since
the return message from call() is a received buffer, not a new one).
buffer will not be allocated and returned (mostly for call() interal processing since
the return message from call() is a received buffer, not a new one).
} else {
if( (state = nn_send( nn_sock, msg->header, sizeof( uta_mhdr_t ) + msg->len, NN_DONTWAIT )) < 0 ) {
msg->state = state;
} else {
if( (state = nn_send( nn_sock, msg->header, sizeof( uta_mhdr_t ) + msg->len, NN_DONTWAIT )) < 0 ) {
msg->state = state;
}
// future: if nano sends bytes, but less than mlen, then what to do?
}
// future: if nano sends bytes, but less than mlen, then what to do?
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Epoll information needed for the rmr_torcv_msg() funciton
*/
typedef struct epoll_stuff {
Epoll information needed for the rmr_torcv_msg() funciton
*/
typedef struct epoll_stuff {
- struct epoll_event events[1]; // wait on 10 possible events
- struct epoll_event epe; // event definition for event to listen to
+ struct epoll_event events[1]; // wait on 10 possible events
+ struct epoll_event epe; // event definition for event to listen to
int ep_fd; // file des from nng
int nng_fd; // fd from nng
} epoll_stuff_t;
/*
int ep_fd; // file des from nng
int nng_fd; // fd from nng
} epoll_stuff_t;
/*
- Context describing our world. Should be returned to user programme on
+ Context describing our world. Should be returned to user programme on
call to initialise, and passed as first parm on all calls to other
visible functions.
call to initialise, and passed as first parm on all calls to other
visible functions.
route_table_t* new_rtable; // route table under construction
if_addrs_t* ip_list; // list manager of the IP addresses that are on our known interfaces
void* mring; // ring where msgs are queued while waiting for a call response msg
route_table_t* new_rtable; // route table under construction
if_addrs_t* ip_list; // list manager of the IP addresses that are on our known interfaces
void* mring; // ring where msgs are queued while waiting for a call response msg
char* rtg_addr; // addr/port of the route table generation publisher
int rtg_port; // the port that the rtg listens on
char* rtg_addr; // addr/port of the route table generation publisher
int rtg_port; // the port that the rtg listens on
wh_mgt_t* wormholes; // management of user opened wormholes
epoll_stuff_t* eps; // epoll information needed for the rcv with timeout call
wh_mgt_t* wormholes; // management of user opened wormholes
epoll_stuff_t* eps; // epoll information needed for the rcv with timeout call
- Static prototypes for functions located here. All common protos are in the
+ Static prototypes for functions located here. All common protos are in the
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
- Abstract: This is the compile point for the nng version of the rmr
+ Abstract: This is the compile point for the nng version of the rmr
library (formarly known as uta, so internal function names
are likely still uta_*)
library (formarly known as uta, so internal function names
are likely still uta_*)
- With the exception of the symtab portion of the library,
- RMr is built with a single compile so as to "hide" the
+ With the exception of the symtab portion of the library,
+ RMr is built with a single compile so as to "hide" the
internal functions as statics. Because they interdepend
on each other, and CMake has issues with generating two
different wormhole objects from a single source, we just
pull it all together with a centralised comple using
internal functions as statics. Because they interdepend
on each other, and CMake has issues with generating two
different wormhole objects from a single source, we just
pull it all together with a centralised comple using
Future: the API functions at this point can be separated
into a common source module.
Future: the API functions at this point can be separated
into a common source module.
Returns the size of the payload (bytes) that the msg buffer references.
Len in a message is the number of bytes which were received, or should
be transmitted, however, it is possible that the mbuf was allocated
Returns the size of the payload (bytes) that the msg buffer references.
Len in a message is the number of bytes which were received, or should
be transmitted, however, it is possible that the mbuf was allocated
- with a larger payload space than the payload length indicates; this
+ with a larger payload space than the payload length indicates; this
function returns the absolute maximum space that the user has available
in the payload. On error (bad msg buffer) -1 is returned and errno should
indicate the rason.
function returns the absolute maximum space that the user has available
in the payload. On error (bad msg buffer) -1 is returned and errno should
indicate the rason.
free( mbuf );
}
/*
send message with maximum timeout.
free( mbuf );
}
/*
send message with maximum timeout.
- Accept a message and send it to an endpoint based on message type.
+ Accept a message and send it to an endpoint based on message type.
If NNG reports that the send attempt timed out, or should be retried,
RMr will retry for approximately max_to microseconds; rounded to the next
higher value of 10.
Allocates a new message buffer for the next send. If a message type has
more than one group of endpoints defined, then the message will be sent
If NNG reports that the send attempt timed out, or should be retried,
RMr will retry for approximately max_to microseconds; rounded to the next
higher value of 10.
Allocates a new message buffer for the next send. If a message type has
more than one group of endpoints defined, then the message will be sent
- in round robin fashion to one endpoint in each group.
+ in round robin fashion to one endpoint in each group.
CAUTION: this is a non-blocking send. If the message cannot be sent, then
it will return with an error and errno set to eagain. If the send is
a limited fanout, then the returned status is the status of the last
send attempt.
CAUTION: this is a non-blocking send. If the message cannot be sent, then
it will return with an error and errno set to eagain. If the send is
a limited fanout, then the returned status is the status of the last
send attempt.
*/
extern rmr_mbuf_t* rmr_mtosend_msg( void* vctx, rmr_mbuf_t* msg, int max_to ) {
nng_socket nn_sock; // endpoint socket for send
*/
extern rmr_mbuf_t* rmr_mtosend_msg( void* vctx, rmr_mbuf_t* msg, int max_to ) {
nng_socket nn_sock; // endpoint socket for send
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
errno = EINVAL; // must ensure it's not eagain
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
errno = EINVAL; // must ensure it's not eagain
while( send_again ) {
sock_ok = uta_epsock_rr( ctx->rtable, msg->mtype, group, &send_again, &nn_sock ); // round robin sel epoint; again set if mult groups
while( send_again ) {
sock_ok = uta_epsock_rr( ctx->rtable, msg->mtype, group, &send_again, &nn_sock ); // round robin sel epoint; again set if mult groups
- if( DEBUG ) fprintf( stderr, "[DBUG] send msg: type=%d again=%d group=%d len=%d sock_ok=%d\n",
+ if( DEBUG ) fprintf( stderr, "[DBUG] send msg: type=%d again=%d group=%d len=%d sock_ok=%d\n",
msg->mtype, send_again, group, msg->len, sock_ok );
group++;
msg->mtype, send_again, group, msg->len, sock_ok );
group++;
/*
if( msg ) {
// error do we need to count successes/errors, how to report some success, esp if last fails?
/*
if( msg ) {
// error do we need to count successes/errors, how to report some success, esp if last fails?
*/
msg = clone_m; // clone will be the next to send
*/
msg = clone_m; // clone will be the next to send
- Send with default max timeout as is set in the context.
+ Send with default max timeout as is set in the context.
See rmr_mtosend_msg() for more details on the parameters.
See rmr_stimeout() for info on setting the default timeout.
*/
See rmr_mtosend_msg() for more details on the parameters.
See rmr_stimeout() for info on setting the default timeout.
*/
- Return to sender allows a message to be sent back to the endpoint where it originated.
+ Return to sender allows a message to be sent back to the endpoint where it originated.
The source information in the message is used to select the socket on which to write
The source information in the message is used to select the socket on which to write
- the message rather than using the message type and round-robin selection. This
+ the message rather than using the message type and round-robin selection. This
should return a message buffer with the state of the send operation set. On success
(state is RMR_OK, the caller may use the buffer for another receive operation), and on
error it can be passed back to this function to retry the send if desired. On error,
should return a message buffer with the state of the send operation set. On success
(state is RMR_OK, the caller may use the buffer for another receive operation), and on
error it can be passed back to this function to retry the send if desired. On error,
errno = EINVAL; // if msg is null, this is their clue
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
errno = EINVAL; // if msg is null, this is their clue
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
Normally, a message struct pointer is returned and msg->state must be checked for RMR_OK
to ensure that no error was encountered. If the state is UTA_BADARG, then the message
Normally, a message struct pointer is returned and msg->state must be checked for RMR_OK
to ensure that no error was encountered. If the state is UTA_BADARG, then the message
- may be resent (likely the context pointer was nil). If the message is sent, but no
+ may be resent (likely the context pointer was nil). If the message is sent, but no
response is received, a nil message is returned with errno set to indicate the likley
issue:
ETIMEDOUT -- too many messages were queued before reciving the expected response
response is received, a nil message is returned with errno set to indicate the likley
issue:
ETIMEDOUT -- too many messages were queued before reciving the expected response
if( (ctx = (uta_ctx_t *) vctx) == NULL || msg == NULL ) { // bad stuff, bail fast
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL || msg == NULL ) { // bad stuff, bail fast
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( old_msg != NULL ) {
old_msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( old_msg != NULL ) {
old_msg->state = RMR_ERR_BADARG;
errno = EINVAL;
return old_msg;
}
errno = EINVAL;
return old_msg;
}
- This implements a receive with a timeout via epoll. Mostly this is for
- wrappers as native C applications can use epoll directly and will not have
+ This implements a receive with a timeout via epoll. Mostly this is for
+ wrappers as native C applications can use epoll directly and will not have
to depend on this.
*/
extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
to depend on this.
*/
extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( old_msg != NULL ) {
old_msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( old_msg != NULL ) {
old_msg->state = RMR_ERR_BADARG;
errno = EINVAL;
return old_msg;
}
errno = EINVAL;
return old_msg;
}
}
if( (eps = ctx->eps) == NULL ) { // set up epoll on first call
}
if( (eps = ctx->eps) == NULL ) { // set up epoll on first call
- eps = malloc( sizeof *eps );
+ eps = malloc( sizeof *eps );
- if( (eps->ep_fd = epoll_create1( 0 )) < 0 ) {
- fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno );
+ if( (eps->ep_fd = epoll_create1( 0 )) < 0 ) {
+ fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno );
free( eps );
return NULL;
free( eps );
return NULL;
eps->nng_fd = rmr_get_rcvfd( ctx );
eps->epe.events = EPOLLIN;
eps->nng_fd = rmr_get_rcvfd( ctx );
eps->epe.events = EPOLLIN;
- eps->epe.data.fd = eps->nng_fd;
+ eps->epe.data.fd = eps->nng_fd;
- if( epoll_ctl( eps->ep_fd, EPOLL_CTL_ADD, eps->nng_fd, &eps->epe ) != 0 ) {
- fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
+ if( epoll_ctl( eps->ep_fd, EPOLL_CTL_ADD, eps->nng_fd, &eps->epe ) != 0 ) {
+ fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
free( eps );
return NULL;
free( eps );
return NULL;
/*
This blocks until the message with the 'expect' ID is received. Messages which are received
/*
This blocks until the message with the 'expect' ID is received. Messages which are received
- before the expected message are queued onto the message ring. The function will return
+ before the expected message are queued onto the message ring. The function will return
a nil message and set errno to ETIMEDOUT if allow2queue messages are received before the
expected message is received. If the queued message ring fills a nil pointer is returned
and errno is set to ENOBUFS.
a nil message and set errno to ETIMEDOUT if allow2queue messages are received before the
expected message is received. If the queued message ring fills a nil pointer is returned
and errno is set to ENOBUFS.
- Generally this will be invoked only by the call() function as it waits for a response, but
+ Generally this will be invoked only by the call() function as it waits for a response, but
it is exposed to the user application as three is no reason not to.
*/
extern rmr_mbuf_t* rmr_rcv_specific( void* vctx, rmr_mbuf_t* msg, char* expect, int allow2queue ) {
uta_ctx_t* ctx;
int queued = 0; // number we pushed into the ring
int exp_len = 0; // length of expected ID
it is exposed to the user application as three is no reason not to.
*/
extern rmr_mbuf_t* rmr_rcv_specific( void* vctx, rmr_mbuf_t* msg, char* expect, int allow2queue ) {
uta_ctx_t* ctx;
int queued = 0; // number we pushed into the ring
int exp_len = 0; // length of expected ID
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
if( msg != NULL ) {
msg->state = RMR_ERR_BADARG;
errno = EINVAL;
return msg;
}
errno = EINVAL;
return msg;
}
// CAUTION: these are not supported as they must be set differently (between create and open) in NNG.
// until those details are worked out, these generate a warning.
/*
// CAUTION: these are not supported as they must be set differently (between create and open) in NNG.
// until those details are worked out, these generate a warning.
/*
- Set send timeout. The value time is assumed to be microseconds. The timeout is the
+ Set send timeout. The value time is assumed to be microseconds. The timeout is the
rough maximum amount of time that RMr will block on a send attempt when the underlying
mechnism indicates eagain or etimeedout. All other error conditions are reported
without this delay. Setting a timeout of 0 causes no retries to be attempted in
RMr code. Setting a timeout of 1 causes RMr to spin up to 10K retries before returning,
rough maximum amount of time that RMr will block on a send attempt when the underlying
mechnism indicates eagain or etimeedout. All other error conditions are reported
without this delay. Setting a timeout of 0 causes no retries to be attempted in
RMr code. Setting a timeout of 1 causes RMr to spin up to 10K retries before returning,
- but without issuing a sleep. If timeout is > 1, then RMr will issue a sleep (1us)
+ but without issuing a sleep. If timeout is > 1, then RMr will issue a sleep (1us)
after every 10K send attempts until the time value is reached. Retries are abandoned
if NNG returns anything other than NNG_AGAIN or NNG_TIMEDOUT.
after every 10K send attempts until the time value is reached. Retries are abandoned
if NNG returns anything other than NNG_AGAIN or NNG_TIMEDOUT.
/*
This is the actual init workhorse. The user visible function meerly ensures that the
/*
This is the actual init workhorse. The user visible function meerly ensures that the
- calling programme does NOT set any internal flags that are supported, and then
+ calling programme does NOT set any internal flags that are supported, and then
invokes this. Internal functions (the route table collector) which need additional
invokes this. Internal functions (the route table collector) which need additional
- open ports without starting additional route table collectors, will invoke this
+ open ports without starting additional route table collectors, will invoke this
directly with the proper flag.
*/
static void* init( char* uproto_port, int max_msg_size, int flags ) {
directly with the proper flag.
*/
static void* init( char* uproto_port, int max_msg_size, int flags ) {
char* port;
char* interface = NULL; // interface to bind to (from RMR_BIND_IF, 0.0.0.0 if not defined)
char* proto_port;
char* port;
char* interface = NULL; // interface to bind to (from RMR_BIND_IF, 0.0.0.0 if not defined)
char* proto_port;
- char wbuf[1024]; // work buffer
+ char wbuf[1024]; // work buffer
char* tok; // pointer at token in a buffer
int state;
if( ! announced ) {
char* tok; // pointer at token in a buffer
int state;
if( ! announced ) {
- fprintf( stderr, "[INFO] ric message routing library on NNG mv=%d (%s %s.%s.%s built: %s)\n",
+ fprintf( stderr, "[INFO] ric message routing library on NNG mv=%d (%s %s.%s.%s built: %s)\n",
RMR_MSG_VER, QUOTE_DEF(GIT_ID), QUOTE_DEF(MAJOR_VER), QUOTE_DEF(MINOR_VER), QUOTE_DEF(PATCH_VER), __DATE__ );
announced = 1;
}
RMR_MSG_VER, QUOTE_DEF(GIT_ID), QUOTE_DEF(MAJOR_VER), QUOTE_DEF(MINOR_VER), QUOTE_DEF(PATCH_VER), __DATE__ );
announced = 1;
}
Flags:
No user flags supported (needed) at the moment, but this provides for extension
Flags:
No user flags supported (needed) at the moment, but this provides for extension
- without drastically changing anything. The user should invoke with RMRFL_NONE to
+ without drastically changing anything. The user should invoke with RMRFL_NONE to
avoid any misbehavour as there are internal flags which are suported
*/
extern void* rmr_init( char* uproto_port, int max_msg_size, int flags ) {
avoid any misbehavour as there are internal flags which are suported
*/
extern void* rmr_init( char* uproto_port, int max_msg_size, int flags ) {
/*
This sets the default trace length which will be added to any message buffers
/*
This sets the default trace length which will be added to any message buffers
- allocated. It can be set at any time, and if rmr_set_trace() is given a
+ allocated. It can be set at any time, and if rmr_set_trace() is given a
trace len that is different than the default allcoated in a message, the message
will be resized.
trace len that is different than the default allcoated in a message, the message
will be resized.
- Returns a file descriptor which can be used with epoll() to signal a receive
- pending. The file descriptor should NOT be read from directly, nor closed, as NNG
- does not support this.
+ Returns a file descriptor which can be used with epoll() to signal a receive
+ pending. The file descriptor should NOT be read from directly, nor closed, as NNG
+ does not support this.
*/
extern int rmr_get_rcvfd( void* vctx ) {
uta_ctx_t* ctx;
*/
extern int rmr_get_rcvfd( void* vctx ) {
uta_ctx_t* ctx;
Clean up things.
There isn't an nng_flush() per se, but we can pause, generate
Clean up things.
There isn't an nng_flush() per se, but we can pause, generate
- a context switch, which should allow the last sent buffer to
+ a context switch, which should allow the last sent buffer to
flow. There isn't exactly an nng_term/close either, so there
isn't much we can do.
*/
flow. There isn't exactly an nng_term/close either, so there
isn't much we can do.
*/
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
nng_close( *nn_sock );
return FALSE;
}
nng_close( *nn_sock );
return FALSE;
}
nng_dialer_setopt_ms( *dialer, NNG_OPT_RECONNMAXT, 2000 ); // cap backoff on retries to reasonable amount (2s)
nng_dialer_setopt_ms( *dialer, NNG_OPT_RECONNMINT, 100 ); // start retry 100m after last failure with 2s cap
nng_dialer_setopt_ms( *dialer, NNG_OPT_RECONNMAXT, 2000 ); // cap backoff on retries to reasonable amount (2s)
nng_dialer_setopt_ms( *dialer, NNG_OPT_RECONNMINT, 100 ); // start retry 100m after last failure with 2s cap
- Add an endpoint to a route table entry for the group given. If the endpoint isn't in the
+ Add an endpoint to a route table entry for the group given. If the endpoint isn't in the
hash we add it and create the endpoint struct.
The caller must supply the specific route table (we assume it will be pending, but they
hash we add it and create the endpoint struct.
The caller must supply the specific route table (we assume it will be pending, but they
} else {
*nn_sock = ep->nn_sock;
state = TRUE;
} else {
*nn_sock = ep->nn_sock;
state = TRUE;
//if( DEBUG ) fprintf( stderr, ">>>> _rr returning socket with one choice in group \n" );
state = TRUE;
break;
//if( DEBUG ) fprintf( stderr, ">>>> _rr returning socket with one choice in group \n" );
state = TRUE;
break;
default: // need to pick one and adjust rr counts
ep = rrg->epts[rrg->ep_idx++]; // select next endpoint
//if( DEBUG ) fprintf( stderr, ">>>> _rr returning socket with multiple choices in group idx=%d \n", rrg->ep_idx );
default: // need to pick one and adjust rr counts
ep = rrg->epts[rrg->ep_idx++]; // select next endpoint
//if( DEBUG ) fprintf( stderr, ">>>> _rr returning socket with multiple choices in group idx=%d \n", rrg->ep_idx );
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
Mnemonic: sr_nng_static.c
/*
Mnemonic: sr_nng_static.c
- Abstract: These are static send/receive primatives which (sadly)
+ Abstract: These are static send/receive primatives which (sadly)
differ based on the underlying protocol (nng vs nanomsg).
Split from rmr_nng.c for easier wormhole support.
differ based on the underlying protocol (nng vs nanomsg).
Split from rmr_nng.c for easier wormhole support.
state = RMR_ERR_RETRY;
errno = EAGAIN;
break;
state = RMR_ERR_RETRY;
errno = EAGAIN;
break;
case NNG_ETIMEDOUT:
state = RMR_ERR_RETRY;
errno = EAGAIN;
case NNG_ETIMEDOUT:
state = RMR_ERR_RETRY;
errno = EAGAIN;
errno = EBADFD; // file des not in a good state for the operation
state = def_state;
break;
errno = EBADFD; // file des not in a good state for the operation
state = def_state;
break;
default:
errno = EBADE;
state = def_state;
default:
errno = EBADE;
state = def_state;
- Allocates only the mbuf and does NOT allocate an underlying transport buffer since
+ Allocates only the mbuf and does NOT allocate an underlying transport buffer since
NNG receive must allocate that on its own.
*/
static rmr_mbuf_t* alloc_mbuf( uta_ctx_t* ctx, int state ) {
NNG receive must allocate that on its own.
*/
static rmr_mbuf_t* alloc_mbuf( uta_ctx_t* ctx, int state ) {
/*
This accepts a message with the assumption that only the tp_buf pointer is valid. It
sets all of the various header/payload/xaction pointers in the mbuf to the proper
/*
This accepts a message with the assumption that only the tp_buf pointer is valid. It
sets all of the various header/payload/xaction pointers in the mbuf to the proper
- spot in the transport layer buffer. The len in the header is assumed to be the
+ spot in the transport layer buffer. The len in the header is assumed to be the
allocated len (a receive buffer that nng created);
The alen parm is the assumed allocated length; assumed because it's a value likely
allocated len (a receive buffer that nng created);
The alen parm is the assumed allocated length; assumed because it's a value likely
msg->header = nng_msg_body( msg->tp_buf ); // header is the start of the transport buffer
v1hdr = (uta_v1mhdr_t *) msg->header; // v1 will always allow us to suss out the version
msg->header = nng_msg_body( msg->tp_buf ); // header is the start of the transport buffer
v1hdr = (uta_v1mhdr_t *) msg->header; // v1 will always allow us to suss out the version
- if( v1hdr->rmr_ver == 1 ) { // bug in verion 1 didn't encode the version in network byte order
+ if( v1hdr->rmr_ver == 1 ) { // bug in verion 1 didn't encode the version in network byte order
ver = 1;
v1hdr->rmr_ver = htonl( 1 ); // save it correctly in case we clone the message
} else {
ver = 1;
v1hdr->rmr_ver = htonl( 1 ); // save it correctly in case we clone the message
} else {
msg->flags |= MFL_ZEROCOPY; // this is a zerocopy sendable message
msg->mtype = ntohl( hdr->mtype ); // capture and convert from network order to local order
msg->sub_id = ntohl( hdr->sub_id );
msg->flags |= MFL_ZEROCOPY; // this is a zerocopy sendable message
msg->mtype = ntohl( hdr->mtype ); // capture and convert from network order to local order
msg->sub_id = ntohl( hdr->sub_id );
- hlen = RMR_HDR_LEN( hdr ); // len to use for truncated check later
+ hlen = RMR_HDR_LEN( hdr ); // len to use for truncated check later
nm->payload = PAYLOAD_ADDR( hdr ); // at user payload
break;
}
nm->payload = PAYLOAD_ADDR( hdr ); // at user payload
break;
}
// --- these are all version agnostic -----------------------------------
nm->mtype = old_msg->mtype;
nm->sub_id = old_msg->sub_id;
// --- these are all version agnostic -----------------------------------
nm->mtype = old_msg->mtype;
nm->sub_id = old_msg->sub_id;
if( RMR_D1_LEN( hdr ) ) {
coffset = DATA1_OFFSET( hdr ); // offset to d1
memcpy( hdr + coffset, old_msg->header + coffset, RMR_D1_LEN( hdr ) ); // copy data1 and data2 if necessary
if( RMR_D1_LEN( hdr ) ) {
coffset = DATA1_OFFSET( hdr ); // offset to d1
memcpy( hdr + coffset, old_msg->header + coffset, RMR_D1_LEN( hdr ) ); // copy data1 and data2 if necessary
}
if( RMR_D2_LEN( hdr ) ) {
coffset = DATA2_OFFSET( hdr ); // offset to d2
}
if( RMR_D2_LEN( hdr ) ) {
coffset = DATA2_OFFSET( hdr ); // offset to d2
SET_HDR_TR_LEN( hdr, tr_len ); // do NOT copy old trace data, just set the new header
break;
}
SET_HDR_TR_LEN( hdr, tr_len ); // do NOT copy old trace data, just set the new header
break;
}
// --- these are all version agnostic -----------------------------------
nm->mtype = old_msg->mtype;
nm->sub_id = old_msg->sub_id;
// --- these are all version agnostic -----------------------------------
nm->mtype = old_msg->mtype;
nm->sub_id = old_msg->sub_id;
In the NNG msg world it must allocate the receive buffer rather
In the NNG msg world it must allocate the receive buffer rather
- than accepting one that we allocated from their space and could
+ than accepting one that we allocated from their space and could
reuse. They have their reasons I guess. Thus, we will free
the old transport buffer if user passes the message in; at least
reuse. They have their reasons I guess. Thus, we will free
the old transport buffer if user passes the message in; at least
- our mbuf will be reused.
+ our mbuf will be reused.
*/
static rmr_mbuf_t* rcv_msg( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
int state;
*/
static rmr_mbuf_t* rcv_msg( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
int state;
hdr = (uta_mhdr_t *) msg->header;
msg->flags |= MFL_ADDSRC; // turn on so if user app tries to send this buffer we reset src
hdr = (uta_mhdr_t *) msg->header;
msg->flags |= MFL_ADDSRC; // turn on so if user app tries to send this buffer we reset src
- if( DEBUG > 1 ) fprintf( stderr, "[DBUG] rcv_msg: got something: type=%d state=%d len=%d diff=%ld\n",
+ if( DEBUG > 1 ) fprintf( stderr, "[DBUG] rcv_msg: got something: type=%d state=%d len=%d diff=%ld\n",
msg->mtype, msg->state, msg->len, msg->payload - (unsigned char *) msg->header );
} else {
msg->state = RMR_ERR_EMPTY;
msg->mtype, msg->state, msg->len, msg->payload - (unsigned char *) msg->header );
} else {
msg->state = RMR_ERR_EMPTY;
/*
Receives a 'raw' message from a non-RMr sender (no header expected). The returned
/*
Receives a 'raw' message from a non-RMr sender (no header expected). The returned
- message buffer cannot be used to send, and the length information may or may
+ message buffer cannot be used to send, and the length information may or may
not be correct (it is set to the length received which might be more than the
bytes actually in the payload).
not be correct (it is set to the length received which might be more than the
bytes actually in the payload).
- Mostly this supports the route table collector, but could be extended with an
+ Mostly this supports the route table collector, but could be extended with an
API external function.
*/
static void* rcv_payload( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
API external function.
*/
static void* rcv_payload( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
/*
This does the hard work of actually sending the message to the given socket. On success,
/*
This does the hard work of actually sending the message to the given socket. On success,
- a new message struct is returned. On error, the original msg is returned with the state
- set to a reasonable value. If the message being sent as MFL_NOALLOC set, then a new
+ a new message struct is returned. On error, the original msg is returned with the state
+ set to a reasonable value. If the message being sent as MFL_NOALLOC set, then a new
buffer will not be allocated and returned (mostly for call() interal processing since
the return message from call() is a received buffer, not a new one).
buffer will not be allocated and returned (mostly for call() interal processing since
the return message from call() is a received buffer, not a new one).
if( (state = nng_send( nn_sock, msg->header, sizeof( uta_mhdr_t ) + msg->len, nng_flags )) != 0 ) {
msg->state = state;
//if( DEBUG ) fprintf( stderr, ">>>>> copy buffer send failed: %s\n", nng_strerror( state ) );
if( (state = nng_send( nn_sock, msg->header, sizeof( uta_mhdr_t ) + msg->len, nng_flags )) != 0 ) {
msg->state = state;
//if( DEBUG ) fprintf( stderr, ">>>>> copy buffer send failed: %s\n", nng_strerror( state ) );
// :vim ts=4 sw=4 noet:
/*
==================================================================================
// :vim ts=4 sw=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
ck1 ck2|<msg text><nil>
ck1 is a simple checksum of the message text (NOT including the
ck1 ck2|<msg text><nil>
ck1 is a simple checksum of the message text (NOT including the
- nil at the end of the string.
+ nil at the end of the string.
ck2 is a simple checksum of the trace data which for the purposes
of testing is assumed to have a terminating nil to keep this simple.
Good messages are messages where both computed checksums match
ck2 is a simple checksum of the trace data which for the purposes
of testing is assumed to have a terminating nil to keep this simple.
Good messages are messages where both computed checksums match
- the ck1 and ck2 values.
+ the ck1 and ck2 values.
The receiver will send an 'ack' message back to the sender for
all type 5 messages received.
The sender and receiver can be run on the same host/container
The receiver will send an 'ack' message back to the sender for
all type 5 messages received.
The sender and receiver can be run on the same host/container
- or on different hosts. The route table is the key to setting
+ or on different hosts. The route table is the key to setting
things up properly. See the sender code for rt information.
Define these environment variables to have some control:
things up properly. See the sender code for rt information.
Define these environment variables to have some control:
/*
Split the message at the first sep and return a pointer to the first
/*
Split the message at the first sep and return a pointer to the first
*/
static char* split( char* str, char sep ) {
char* s;
*/
static char* split( char* str, char sep ) {
char* s;
}
int main( int argc, char** argv ) {
}
int main( int argc, char** argv ) {
- void* mrc; // msg router context
- rmr_mbuf_t* msg = NULL; // message received
+ void* mrc; // msg router context
+ rmr_mbuf_t* msg = NULL; // message received
int i;
int state;
int errors = 0;
int i;
int state;
int errors = 0;
if( argc > 2 ) {
listen_port = argv[2];
}
if( argc > 2 ) {
listen_port = argv[2];
}
fprintf( stderr, "<RCVR> listening on port: %s for a max of %d messages\n", listen_port, nmsgs );
fprintf( stderr, "<RCVR> listening on port: %s for a max of %d messages\n", listen_port, nmsgs );
- mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE ); // start your engines!
+ mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE ); // start your engines!
if( mrc == NULL ) {
fprintf( stderr, "<RCVR> ABORT: unable to initialise RMr\n" );
exit( 1 );
if( mrc == NULL ) {
fprintf( stderr, "<RCVR> ABORT: unable to initialise RMr\n" );
exit( 1 );
fprintf( stderr, "<RCVR> rmr now shows ready, listening begins\n" );
timeout = time( NULL ) + 20;
fprintf( stderr, "<RCVR> rmr now shows ready, listening begins\n" );
timeout = time( NULL ) + 20;
- while( count < nmsgs ) {
+ while( count < nmsgs ) {
msg = rmr_torcv_msg( mrc, msg, 1000 ); // wait for about 1s so that if sender never starts we eventually escape
msg = rmr_torcv_msg( mrc, msg, 1000 ); // wait for about 1s so that if sender never starts we eventually escape
if( msg ) {
if( msg->state == RMR_OK ) {
if( (data = split( msg->payload, '|' )) != NULL ) {
if( msg ) {
if( msg->state == RMR_OK ) {
if( (data = split( msg->payload, '|' )) != NULL ) {
fprintf( stderr, "<RCVR> [%s] %ld messages; good=%ld acked=%ld bad=%ld bad-trace=%ld\n", !!(errors + bad + bad_tr) ? "FAIL" : "PASS", count, good, ack_count, bad, bad_tr );
sleep( 2 ); // let any outbound acks flow before closing
fprintf( stderr, "<RCVR> [%s] %ld messages; good=%ld acked=%ld bad=%ld bad-trace=%ld\n", !!(errors + bad + bad_tr) ? "FAIL" : "PASS", count, good, ack_count, bad, bad_tr );
sleep( 2 ); // let any outbound acks flow before closing
// :vim ts=4 sw=4 noet:
/*
==================================================================================
// :vim ts=4 sw=4 noet:
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
- Abstract: This is a simple sender which will send a series of messages.
+ Abstract: This is a simple sender which will send a series of messages.
It is expected that the first attempt(s) will fail if the receiver
is not up and this does not start decrementing the number to
It is expected that the first attempt(s) will fail if the receiver
is not up and this does not start decrementing the number to
- send until it has a good send.
+ send until it has a good send.
The process will check the receive queue and list received messages
but pass/fail is not dependent on what comes back.
If the receiver(s) do not become connectable in 20 sec this process
The process will check the receive queue and list received messages
but pass/fail is not dependent on what comes back.
If the receiver(s) do not become connectable in 20 sec this process
Message types will vary between 1 and 10, so the route table must
Message types will vary between 1 and 10, so the route table must
- be set up to support those message types.
+ be set up to support those message types.
Message format is:
ck1 ck2|<msg-txt><nil>
Ck1 is the simple check sum of the msg-text (NOT includeing <nil>)
Ck2 is the simple check sum of the trace data which is a nil terminated
Message format is:
ck1 ck2|<msg-txt><nil>
Ck1 is the simple check sum of the msg-text (NOT includeing <nil>)
Ck2 is the simple check sum of the trace data which is a nil terminated
Parms: argv[1] == nmsgs; argv[2] == delay; argv[3] == listen port
Parms: argv[1] == nmsgs; argv[2] == delay; argv[3] == listen port
}
int main( int argc, char** argv ) {
}
int main( int argc, char** argv ) {
- void* mrc; // msg router context
- struct epoll_event events[1]; // list of events to give to epoll
- struct epoll_event epe; // event definition for event to listen to
- int ep_fd = -1; // epoll's file des (given to epoll_wait)
- int rcv_fd; // file des that NNG tickles -- give this to epoll to listen on
+ void* mrc; // msg router context
+ struct epoll_event events[1]; // list of events to give to epoll
+ struct epoll_event epe; // event definition for event to listen to
+ int ep_fd = -1; // epoll's file des (given to epoll_wait)
+ int rcv_fd; // file des that NNG tickles -- give this to epoll to listen on
int nready; // number of events ready for receive
rmr_mbuf_t* sbuf; // send buffer
rmr_mbuf_t* rbuf; // received buffer
int nready; // number of events ready for receive
rmr_mbuf_t* sbuf; // send buffer
rmr_mbuf_t* rbuf; // received buffer
fprintf( stderr, "<SNDR> listen port: %s; sending %d messages; delay=%d\n", listen_port, nmsgs, delay );
fprintf( stderr, "<SNDR> listen port: %s; sending %d messages; delay=%d\n", listen_port, nmsgs, delay );
- if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) {
+ if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) {
fprintf( stderr, "<SNDR> unable to initialise RMr\n" );
exit( 1 );
}
fprintf( stderr, "<SNDR> unable to initialise RMr\n" );
exit( 1 );
}
- if( (rcv_fd = rmr_get_rcvfd( mrc )) >= 0 ) { // epoll only available from NNG -- skip receive later if not NNG
+ if( (rcv_fd = rmr_get_rcvfd( mrc )) >= 0 ) { // epoll only available from NNG -- skip receive later if not NNG
if( rcv_fd < 0 ) {
fprintf( stderr, "<SNDR> unable to set up polling fd\n" );
exit( 1 );
if( rcv_fd < 0 ) {
fprintf( stderr, "<SNDR> unable to set up polling fd\n" );
exit( 1 );
fprintf( stderr, "<SNDR> [FAIL] unable to create epoll fd: %d\n", errno );
exit( 1 );
}
fprintf( stderr, "<SNDR> [FAIL] unable to create epoll fd: %d\n", errno );
exit( 1 );
}
- epe.events = EPOLLIN;
- epe.data.fd = rcv_fd;
+ epe.events = EPOLLIN;
+ epe.data.fd = rcv_fd;
- if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 ) {
+ if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 ) {
fprintf( stderr, "<SNDR> [FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
exit( 1 );
}
fprintf( stderr, "<SNDR> [FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
exit( 1 );
}
}
}
fprintf( stderr, "<SNDR> rmr is ready; starting to send\n" );
}
}
fprintf( stderr, "<SNDR> rmr is ready; starting to send\n" );
timeout = time( NULL ) + 20;
timeout = time( NULL ) + 20;
- while( count < nmsgs ) { // we send 10 messages after the first message is successful
+ while( count < nmsgs ) { // we send 10 messages after the first message is successful
snprintf( trace, 100, "%lld", (long long) time( NULL ) );
rmr_set_trace( sbuf, trace, strlen( trace ) + 1 );
snprintf( wbuf, 200, "count=%d tr=%s %d stand up and cheer!", count, trace, rand() );
snprintf( trace, 100, "%lld", (long long) time( NULL ) );
rmr_set_trace( sbuf, trace, strlen( trace ) + 1 );
snprintf( wbuf, 200, "count=%d tr=%s %d stand up and cheer!", count, trace, rand() );
if( delay > 0 ) {
usleep( delay );
}
if( delay > 0 ) {
usleep( delay );
}
timeout = time( NULL ) + 2; // allow 2 seconds for the pipe to drain from the receiver
while( time( NULL ) < timeout );
if( rcv_fd >= 0 ) {
timeout = time( NULL ) + 2; // allow 2 seconds for the pipe to drain from the receiver
while( time( NULL ) < timeout );
if( rcv_fd >= 0 ) {
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
rmr_bytes2payload( mbuf, src_buf, 8192 ); // bust the limit
errors += fail_if( mbuf->state == RMR_OK, "huge buf copy to payload returned good state in mbuf" );
errors += fail_if( errno == 0, "huge buf copy to payload returned good state in errno" );
rmr_bytes2payload( mbuf, src_buf, 8192 ); // bust the limit
errors += fail_if( mbuf->state == RMR_OK, "huge buf copy to payload returned good state in mbuf" );
errors += fail_if( errno == 0, "huge buf copy to payload returned good state in errno" );
snprintf( src_buf, sizeof( src_buf ), "This is some text in the buffer" );
rmr_str2payload( mbuf, src_buf ); // this uses bytes2payload, so only one invocation needed
snprintf( src_buf, sizeof( src_buf ), "This is some text in the buffer" );
rmr_str2payload( mbuf, src_buf ); // this uses bytes2payload, so only one invocation needed
c = rmr_get_meid( NULL, NULL );
errors += fail_if( c != NULL, "get meid with nil message buffer" );
errors += fail_if( errno == 0, "(errno bad) get meid with nil msg buffer" );
c = rmr_get_meid( NULL, NULL );
errors += fail_if( c != NULL, "get meid with nil message buffer" );
errors += fail_if( errno == 0, "(errno bad) get meid with nil msg buffer" );
c = rmr_get_meid( mbuf, NULL ); // should allocate and return c
errors += fail_if( c == NULL, "get meid with nil dest pointer (did not allocate a buffer)" );
errors += fail_if( strcmp( c, "test-meid" ) != 0, "did not get expected meid from mbuffer" );
c = rmr_get_meid( mbuf, NULL ); // should allocate and return c
errors += fail_if( c == NULL, "get meid with nil dest pointer (did not allocate a buffer)" );
errors += fail_if( strcmp( c, "test-meid" ) != 0, "did not get expected meid from mbuffer" );
state = rmr_get_trlen( NULL ); // coverage test on nil check
errors += fail_not_equal( state, 0, "get trace length with nil msg didn't return expected 0 status" );
state = rmr_get_trlen( NULL ); // coverage test on nil check
errors += fail_not_equal( state, 0, "get trace length with nil msg didn't return expected 0 status" );
src_buf[0] = 0;
state = rmr_set_trace( mbuf, "foo bar was here", 17 ); // should force a realloc
errors += fail_not_equal( state, 17, "bytes copied to trace (a) did not match expected size (b)" );
src_buf[0] = 0;
state = rmr_set_trace( mbuf, "foo bar was here", 17 ); // should force a realloc
errors += fail_not_equal( state, 17, "bytes copied to trace (a) did not match expected size (b)" );
buf = rmr_get_src( mbuf, src_buf );
errors += fail_not_equal( buf, src_buf, "rmr_get_src didn't return expexted buffer pointer" );
buf = rmr_get_src( mbuf, src_buf );
errors += fail_not_equal( buf, src_buf, "rmr_get_src didn't return expexted buffer pointer" );
return errors > 0; // overall exit code bad if errors
}
return errors > 0; // overall exit code bad if errors
}
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Mnemonic: mbuf_api_test.c
Abstract: Unit tests for the mbuf common API functions.
To allow the mbuf functions to be tested without the bulk of the
Mnemonic: mbuf_api_test.c
Abstract: Unit tests for the mbuf common API functions.
To allow the mbuf functions to be tested without the bulk of the
- RMr mechanics, we dummy up a couple of functions that are in
- rmr[_nng].c.
+ RMr mechanics, we dummy up a couple of functions that are in
+ rmr[_nng].c.
Author: E. Scott Daniels
Date: 2 April 2019
Author: E. Scott Daniels
Date: 2 April 2019
we actually pulled in the sr static set.
WARNING: this is NOT a complete realloc. We assume that we are testing
we actually pulled in the sr static set.
WARNING: this is NOT a complete realloc. We assume that we are testing
- just the trace length adjustment portion of the set_trace()
+ just the trace length adjustment portion of the set_trace()
API and are not striving to test the real realloc function. That
will be tested when the mbuf_api_static_test code is used by the
more generic RMr test. So, not all fields in the realloc'd buffer
API and are not striving to test the real realloc function. That
will be tested when the mbuf_api_static_test code is used by the
more generic RMr test. So, not all fields in the realloc'd buffer
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
Mmemonic: ring_static_test.c
Abstract: Test the ring funcitons. These are meant to be included at compile
/*
Mmemonic: ring_static_test.c
Abstract: Test the ring funcitons. These are meant to be included at compile
- time by the test driver.
+ time by the test driver.
Author: E. Scott Daniels
Date: 3 April 2019
Author: E. Scott Daniels
Date: 3 April 2019
- Conduct a series of interleaved tests inserting i-factor
+ Conduct a series of interleaved tests inserting i-factor
values before beginning to pull values (i-factor must be
values before beginning to pull values (i-factor must be
- size - 2 smaller than the ring.
+ size - 2 smaller than the ring.
Returns 0 on success, 1 on insert failure and 2 on pull failure.
*/
static int ie_test( void* r, int i_factor, long inserts ) {
Returns 0 on success, 1 on insert failure and 2 on pull failure.
*/
static int ie_test( void* r, int i_factor, long inserts ) {
if( *dp != i ) {
fprintf( stderr, "<FAIL> data at i=% isnt right; expected %d got %d\n", i, i, *dp );
if( *dp != i ) {
fprintf( stderr, "<FAIL> data at i=% isnt right; expected %d got %d\n", i, i, *dp );
return 1;
}
fprintf( stderr, "<OK> extracted values were sane, got: %d\n", i-1 );
return 1;
}
fprintf( stderr, "<OK> extracted values were sane, got: %d\n", i-1 );
uta_ring_free( NULL ); // ensure this doesn't blow up
uta_ring_free( r );
for( i = 2; i < 15; i++ ) {
uta_ring_free( NULL ); // ensure this doesn't blow up
uta_ring_free( r );
for( i = 2; i < 15; i++ ) {
fprintf( stderr, "<FAIL> ie test for 66K inserts didn't return 0\n" );
return 1;
}
fprintf( stderr, "<FAIL> ie test for 66K inserts didn't return 0\n" );
return 1;
}
uta_ring_free( r );
}
fprintf( stderr, "<OK> all large insert/exctract tests pass ring size=%d\n", size );
uta_ring_free( r );
}
fprintf( stderr, "<OK> all large insert/exctract tests pass ring size=%d\n", size );
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
- Abstract: This is a stand alone test driver for the ring module. It
+ Abstract: This is a stand alone test driver for the ring module. It
includes the static tests after setting up the environment
then invokes it.
includes the static tests after setting up the environment
then invokes it.
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Abstract: Specific tests related to the API functions in rmr_nng.c/rmr.c.
This should be included by a driver, but only the main RMr
driver and there likely not be a specific stand alone driver
Abstract: Specific tests related to the API functions in rmr_nng.c/rmr.c.
This should be included by a driver, but only the main RMr
driver and there likely not be a specific stand alone driver
- for just this small set of tests because of the depth of the
+ for just this small set of tests because of the depth of the
library needed to test at this level.
The message buffer specific API tests are in a different static
library needed to test at this level.
The message buffer specific API tests are in a different static
} else {
errors += fail_if( v < 0, "rmr_payload_size returned invalid size for good message" );
}
} else {
errors += fail_if( v < 0, "rmr_payload_size returned invalid size for good message" );
}
v = rmr_get_rcvfd( NULL );
errors += fail_if( v >= 0, "rmr_get_rcvfd returned a valid file descriptor when given nil context" );
v = rmr_get_rcvfd( rmc );
v = rmr_get_rcvfd( NULL );
errors += fail_if( v >= 0, "rmr_get_rcvfd returned a valid file descriptor when given nil context" );
v = rmr_get_rcvfd( rmc );
}
errors += fail_if( i >= 16, "did not find expected message on queue" );
}
errors += fail_if( i >= 16, "did not find expected message on queue" );
if( ! msg ) {
msg = rmr_alloc_msg( rmc, 2048 ); // something buggered above; get a new one
}
if( ! msg ) {
msg = rmr_alloc_msg( rmc, 2048 ); // something buggered above; get a new one
}
errors += fail_not_equal( state, 17, "len of trace data (a) returned after msg allocation was not expected size (b)" );
state = strcmp( wbuf, "1904308620110417" );
errors += fail_not_equal( state, 0, "trace data returned after tralloc was not correct" );
errors += fail_not_equal( state, 17, "len of trace data (a) returned after msg allocation was not expected size (b)" );
state = strcmp( wbuf, "1904308620110417" );
errors += fail_not_equal( state, 0, "trace data returned after tralloc was not correct" );
em_send_failures = 1;
send_n_msgs( rmc, 30 ); // send 30 messages with emulation failures
em_send_failures = 0;
em_send_failures = 1;
send_n_msgs( rmc, 30 ); // send 30 messages with emulation failures
em_send_failures = 0;
rmr_close( NULL ); // drive for coverage
rmr_close( rmc ); // no return to check; drive for coverage
rmr_close( NULL ); // drive for coverage
rmr_close( rmc ); // no return to check; drive for coverage
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
Mmemonic: sr_nng_static_test.c
Abstract: Test the send/receive funcitons. These are meant to be included at compile
/*
Mmemonic: sr_nng_static_test.c
Abstract: Test the send/receive funcitons. These are meant to be included at compile
- time by the test driver.
+ time by the test driver.
Author: E. Scott Daniels
Date: 3 April 2019
Author: E. Scott Daniels
Date: 3 April 2019
int fd;
char* rt_stuff; // strings for the route table
int fd;
char* rt_stuff; // strings for the route table
- rt_stuff =
- "newrt|start\n" // false start to drive detection
+ rt_stuff =
+ "newrt|start\n" // false start to drive detection
"xxx|badentry to drive default case"
"newrt|start\n"
"xxx|badentry to drive default case"
"newrt|start\n"
- "rte|0|localhost:4560,localhost:4562\n"
- "rte|1|localhost:4562;localhost:4561,localhost:4569\n"
- "rte|2|localhost:4562\n"
+ "rte|0|localhost:4560,localhost:4562\n"
+ "rte|1|localhost:4562;localhost:4561,localhost:4569\n"
+ "rte|2|localhost:4562\n"
"rte|4|localhost:4561\n"
"rte|5|localhost:4563\n"
"rte|4|localhost:4561\n"
"rte|5|localhost:4563\n"
- "rte|6|localhost:4562\n"
+ "rte|6|localhost:4562\n"
"newrt|end\n";
fd = open( "utesting.rt", O_WRONLY | O_CREAT, 0600 );
"newrt|end\n";
fd = open( "utesting.rt", O_WRONLY | O_CREAT, 0600 );
Send and receive functions are indirectly exercised from the rmr_nng_static_test
module as it tests the user facing send/receive/call/rts functions. These tests
Send and receive functions are indirectly exercised from the rmr_nng_static_test
module as it tests the user facing send/receive/call/rts functions. These tests
- should exercise specific cases for the internal functions as they will not
+ should exercise specific cases for the internal functions as they will not
specifically be driven elsewhere.
*/
static int sr_nng_test() {
specifically be driven elsewhere.
*/
static int sr_nng_test() {
errors += fail_not_equal( mbuf->flags, mb2->flags, "clone did not duplicate flags" );
errors += fail_not_equal( mbuf->alloc_len, mb2->alloc_len, "clone did not dup alloc-len" );
errors += fail_not_equal( mbuf->state, mb2->state, "clone did not dup state" );
errors += fail_not_equal( mbuf->flags, mb2->flags, "clone did not duplicate flags" );
errors += fail_not_equal( mbuf->alloc_len, mb2->alloc_len, "clone did not dup alloc-len" );
errors += fail_not_equal( mbuf->state, mb2->state, "clone did not dup state" );
mbuf = rmr_send_msg( NULL, mbuf );
errors += fail_if_nil( mbuf, "send with nil context but buffere didn't return buffer" );
mbuf = rmr_send_msg( NULL, mbuf );
errors += fail_if_nil( mbuf, "send with nil context but buffere didn't return buffer" );
ctx->shutdown = 1; // should force rtc to quit on first pass
rtc( NULL ); // coverage test with nil pointer
rtc( ctx );
ctx->shutdown = 1; // should force rtc to quit on first pass
rtc( NULL ); // coverage test with nil pointer
rtc( ctx );
/*
==================================================================================
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
Mnemonic: symtab_static_test.c
/*
Mnemonic: symtab_static_test.c
- Abstract: This is the static function that should be included by
+ Abstract: This is the static function that should be included by
any test that wants to test the symbol table. It must
be included in the compile, and not built to object.
any test that wants to test the symbol table. It must
be included in the compile, and not built to object.
#include "test_support.c"
#include "test_support.c"
#define GOOD 0
#define BAD 1
#endif
#define GOOD 0
#define BAD 1
#endif
if( !expected ) {
symtab_state = BAD;
}
if( !expected ) {
symtab_state = BAD;
}
} else {
fprintf( stderr, "<%s> string key st_fetch return nil\n", expected ? "FAIL" : "OK" );
if( expected ) {
} else {
fprintf( stderr, "<%s> string key st_fetch return nil\n", expected ? "FAIL" : "OK" );
if( expected ) {
}
static int symtab_test( ) {
}
static int symtab_test( ) {
- void* st;
- char* foo = "foo";
- char* bar = "bar";
+ void* st;
+ char* foo = "foo";
+ char* bar = "bar";
char* goo = "goo"; // name not in symtab
int i;
int class = 1;
char* goo = "goo"; // name not in symtab
int i;
int class = 1;
- st = rmr_sym_alloc( 10 ); // alloc with small value to force adjustment inside
+ st = rmr_sym_alloc( 10 ); // alloc with small value to force adjustment inside
errors += fail_if_nil( st, "symtab pointer" );
errors += fail_if_nil( st, "symtab pointer" );
- s = rmr_sym_put( st, foo, class, bar ); // add entry with string key; returns 1 if it was inserted
+ s = rmr_sym_put( st, foo, class, bar ); // add entry with string key; returns 1 if it was inserted
errors += fail_if_false( s, "insert foo existed" );
errors += fail_if_false( s, "insert foo existed" );
- s = rmr_sym_put( st, foo, class+1, bar ); // add to table with a different class
+ s = rmr_sym_put( st, foo, class+1, bar ); // add to table with a different class
errors += fail_if_false( s, "insert foo existed" );
errors += fail_if_false( s, "insert foo existed" );
- s = rmr_sym_put( st, foo, class, bar ); // inserted above, should return not inserted (0)
+ s = rmr_sym_put( st, foo, class, bar ); // inserted above, should return not inserted (0)
errors += fail_if_true( s, "insert foo existed" );
st_fetch( st, foo, class, 1 );
st_fetch( st, goo, class, 0 ); // st_fetch non existant
errors += fail_if_true( s, "insert foo existed" );
st_fetch( st, foo, class, 1 );
st_fetch( st, goo, class, 0 ); // st_fetch non existant
- rmr_sym_stats( st, 4 ); // early stats at verbose level 4 so chatter is minimised
+ rmr_sym_stats( st, 4 ); // early stats at verbose level 4 so chatter is minimised
rmr_sym_dump( st );
for( i = 2000; i < 3000; i++ ) { // bunch of dummy things to force chains in the table
rmr_sym_map( st, i, foo ); // add entry with unsigned integer key
}
rmr_sym_dump( st );
for( i = 2000; i < 3000; i++ ) { // bunch of dummy things to force chains in the table
rmr_sym_map( st, i, foo ); // add entry with unsigned integer key
}
- rmr_sym_stats( st, 0 ); // just the small facts to verify the 1000 we stuffed in
+ rmr_sym_stats( st, 0 ); // just the small facts to verify the 1000 we stuffed in
rmr_sym_ndel( st, 2001 ); // force a numeric key delete
rmr_sym_ndel( st, 12001 ); // delete numeric key not there
rmr_sym_ndel( st, 2001 ); // force a numeric key delete
rmr_sym_ndel( st, 12001 ); // delete numeric key not there
st_nfetch( st, 1234, 1 );
st_nfetch( st, 2345, 1 );
st_nfetch( st, 1234, 1 );
st_nfetch( st, 2345, 1 );
- rmr_sym_del( st, foo, 0 ); // drive for coverage
- rmr_sym_stats( st, 0 );
+ rmr_sym_del( st, foo, 0 ); // drive for coverage
+ rmr_sym_stats( st, 0 );
rmr_sym_free( NULL ); // ensure it doesn't barf when given a nil pointer
rmr_sym_free( st );
rmr_sym_free( NULL ); // ensure it doesn't barf when given a nil pointer
rmr_sym_free( st );
- return !!( errors + symtab_state );
+ return !!( errors + symtab_state );
/*
==================================================================================
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
Mnemonic: symtab_test.c
Abstract: This is the unit test module that will drive tests against
/*
Mnemonic: symtab_test.c
Abstract: This is the unit test module that will drive tests against
- the symbol table portion of RMr. Run with:
+ the symbol table portion of RMr. Run with:
ksh unit_test.ksh symtab_test.c
Date: 1 April 2019
Author: E. Scott Daniels
ksh unit_test.ksh symtab_test.c
Date: 1 April 2019
Author: E. Scott Daniels
if( !expected ) {
state = BAD;
}
if( !expected ) {
state = BAD;
}
} else {
fprintf( stderr, "[%s] string key fetch return nil\n", expected ? "FAIL" : "OK" );
if( expected ) {
} else {
fprintf( stderr, "[%s] string key fetch return nil\n", expected ? "FAIL" : "OK" );
if( expected ) {
- void* st;
- char* foo = "foo";
- char* bar = "bar";
+ void* st;
+ char* foo = "foo";
+ char* bar = "bar";
char* goo = "goo"; // name not in symtab
int i;
int class = 1;
int s;
void* p;
char* goo = "goo"; // name not in symtab
int i;
int class = 1;
int s;
void* p;
- st = rmr_sym_alloc( 10 ); // alloc with small value to force adjustment inside
+ st = rmr_sym_alloc( 10 ); // alloc with small value to force adjustment inside
fail_if_nil( st, "symtab pointer" );
fail_if_nil( st, "symtab pointer" );
- s = rmr_sym_put( st, foo, class, bar ); // add entry with string key; returns 1 if it was inserted
+ s = rmr_sym_put( st, foo, class, bar ); // add entry with string key; returns 1 if it was inserted
fail_if_false( s, "insert foo existed" );
fail_if_false( s, "insert foo existed" );
- s = rmr_sym_put( st, foo, class+1, bar ); // add to table with a different class
+ s = rmr_sym_put( st, foo, class+1, bar ); // add to table with a different class
fail_if_false( s, "insert foo existed" );
fail_if_false( s, "insert foo existed" );
- s = rmr_sym_put( st, foo, class, bar ); // inserted above, should return not inserted (0)
+ s = rmr_sym_put( st, foo, class, bar ); // inserted above, should return not inserted (0)
fail_if_true( s, "insert foo existed" );
fetch( st, foo, class, 1 );
fetch( st, goo, class, 0 ); // fetch non existant
fail_if_true( s, "insert foo existed" );
fetch( st, foo, class, 1 );
fetch( st, goo, class, 0 ); // fetch non existant
- rmr_sym_stats( st, 4 ); // early stats at verbose level 4 so chatter is minimised
+ rmr_sym_stats( st, 4 ); // early stats at verbose level 4 so chatter is minimised
rmr_sym_dump( st );
for( i = 2000; i < 3000; i++ ) { // bunch of dummy things to force chains in the table
rmr_sym_map( st, i, foo ); // add entry with unsigned integer key
}
rmr_sym_dump( st );
for( i = 2000; i < 3000; i++ ) { // bunch of dummy things to force chains in the table
rmr_sym_map( st, i, foo ); // add entry with unsigned integer key
}
- rmr_sym_stats( st, 0 ); // just the small facts to verify the 1000 we stuffed in
+ rmr_sym_stats( st, 0 ); // just the small facts to verify the 1000 we stuffed in
rmr_sym_ndel( st, 2001 ); // force a numeric key delete
rmr_sym_ndel( st, 12001 ); // delete numeric key not there
rmr_sym_ndel( st, 2001 ); // force a numeric key delete
rmr_sym_ndel( st, 12001 ); // delete numeric key not there
- rmr_sym_del( st, foo, 0 );
+ rmr_sym_del( st, foo, 0 );
- rmr_sym_stats( st, 0 );
+ rmr_sym_stats( st, 0 );
rmr_sym_free( NULL ); // ensure it doesn't barf when given a nil pointer
rmr_sym_free( st );
rmr_sym_free( NULL ); // ensure it doesn't barf when given a nil pointer
rmr_sym_free( st );
/*
==================================================================================
/*
==================================================================================
- Copyright (c) 2019 Nokia
+ Copyright (c) 2019 Nokia
Copyright (c) 2018-2019 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
Copyright (c) 2018-2019 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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
Mnemonic: test_nng_em.c
/*
Mnemonic: test_nng_em.c
- Abstract: A nano/NNG message emulator for testing without needing to
+ Abstract: A nano/NNG message emulator for testing without needing to
actually have nanomsg, nng, or external processes.
We also emulate the epoll_wait() function for controlled
poll related testing.
actually have nanomsg, nng, or external processes.
We also emulate the epoll_wait() function for controlled
poll related testing.
// ----------- epoll emulation ---------------------------------------------
// ----------- epoll emulation ---------------------------------------------
-// CAUTION: sys/epoll.h must be included before this define and function will properly compile.
+// CAUTION: sys/epoll.h must be included before this define and function will properly compile.
#define epoll_wait em_wait
/*
#define epoll_wait em_wait
/*
- Every other call returns 1 ready; alternate calls return 0 ready.
- Mostly for testing the timeout receive call. First call should return
+ Every other call returns 1 ready; alternate calls return 0 ready.
+ Mostly for testing the timeout receive call. First call should return
something ready and the second should return nothing ready so we can
something ready and the second should return nothing ready so we can
*/
static int em_wait( int fd, void* events, int n, int to ) {
static int ready = 0;
*/
static int em_wait( int fd, void* events, int n, int to ) {
static int ready = 0;
static int em_nng_foo() {
fprintf( stderr, "emulated functions in play" );
static int em_nng_foo() {
fprintf( stderr, "emulated functions in play" );
- v2 message; should be able to use it for everything that is set up here as
+ v2 message; should be able to use it for everything that is set up here as
we don't add a payload even if setting a v1 type.
*/
#define ALT_MSG_VER 1 // alternate every so often
we don't add a payload even if setting a v1 type.
*/
#define ALT_MSG_VER 1 // alternate every so often
unsigned char meid[32]; // managed element id.
struct timespec ts; // timestamp ???
unsigned char meid[32]; // managed element id.
struct timespec ts; // timestamp ???
- // V2 extension
- int32_t flags; // HFL_* constants
- int32_t len0; // length of the RMr header data
- int32_t len1; // length of the tracing data
- int32_t len2; // length of data 1 (d1)
- int32_t len3; // length of data 2 (d2)
+ // V2 extension
+ int32_t flags; // HFL_* constants
+ int32_t len0; // length of the RMr header data
+ int32_t len1; // length of the tracing data
+ int32_t len2; // length of data 1 (d1)
+ int32_t len3; // length of data 2 (d2)
/*
Emulate sending a message. If the global em_send_failures is set,
/*
Emulate sending a message. If the global em_send_failures is set,
- then every so often we fail with an EAGAIN to drive that part
+ then every so often we fail with an EAGAIN to drive that part
of the code in RMr.
*/
static int em_sendmsg( nng_socket s, nng_msg* m, int i ) {
of the code in RMr.
*/
static int em_sendmsg( nng_socket s, nng_msg* m, int i ) {
// nng redefines some of these to point directly to various 'versions' of the function (ugg, function versions, really?)
// nng redefines some of these to point directly to various 'versions' of the function (ugg, function versions, really?)
-#undef nng_recvmsg
-#undef nng_free
-#undef nng_pull_open
-#undef nng_pull0_open
-#undef nng_listen
-#undef nng_close
-#undef nng_getopt_int
-#undef nng_push0_open
-#undef nng_dial
-#undef nng_setopt
-#undef nng_sub_open
-#undef nng_sub0_open
-#undef nng_recv
-#undef nng_alloc
+#undef nng_recvmsg
+#undef nng_free
+#undef nng_pull_open
+#undef nng_pull0_open
+#undef nng_listen
+#undef nng_close
+#undef nng_getopt_int
+#undef nng_push0_open
+#undef nng_dial
+#undef nng_setopt
+#undef nng_sub_open
+#undef nng_sub0_open
+#undef nng_recv
+#undef nng_alloc
#define nng_msg_alloc em_nng_msg_alloc
#define nng_recvmsg em_nng_recvmsg
#define nng_msg_alloc em_nng_msg_alloc
#define nng_recvmsg em_nng_recvmsg
#define nn_socket em_nn_socket
#define nn_close em_nn_close
#define nn_setsockopt em_nn_setsockopt
#define nn_socket em_nn_socket
#define nn_close em_nn_close
#define nn_setsockopt em_nn_setsockopt
#define nn_sendmsg em_nn_sendmsg
#define nn_recvmsg em_nn_recvmsg
#define nn_sendmsg em_nn_sendmsg
#define nn_recvmsg em_nn_recvmsg
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Setup all of the signal handling for signals that we want to force a clean exit:
term, intr, hup, quit, usr1/2 alarm, etc. All others we'll let default.
*/
Setup all of the signal handling for signals that we want to force a clean exit:
term, intr, hup, quit, usr1/2 alarm, etc. All others we'll let default.
*/
int sig_list[] = { SIGINT, SIGQUIT, SIGILL, SIGALRM, SIGTERM, SIGUSR1 , SIGUSR2 };
int i;
int nele; // number of elements in the list
int sig_list[] = { SIGINT, SIGQUIT, SIGILL, SIGALRM, SIGTERM, SIGUSR1 , SIGUSR2 };
int i;
int nele; // number of elements in the list
nele = (int) ( sizeof( sig_list )/sizeof( int ) ); // convert raw size to the number of elements
for( i = 0; i < nele; i ++ ) {
memset( &sa, 0, sizeof( sa ) );
nele = (int) ( sizeof( sig_list )/sizeof( int ) ); // convert raw size to the number of elements
for( i = 0; i < nele; i ++ ) {
memset( &sa, 0, sizeof( sa ) );
new_msg->payload = new_msg->header + PAYLOAD_OFFSET( hdr );
new_msg->alloc_len = alen;
new_msg->len = 0;
new_msg->payload = new_msg->header + PAYLOAD_OFFSET( hdr );
new_msg->alloc_len = alen;
new_msg->len = 0;
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
uta_ctx_t ctx; // context for uta_lookup test
void* if_list;
uta_ctx_t ctx; // context for uta_lookup test
void* if_list;
// ------------------ tokenise tests -----------------------------------------------------------
dbuf = strdup( buf );
i = uta_tokenise( dbuf, tokens, 127, ',' );
// ------------------ tokenise tests -----------------------------------------------------------
dbuf = strdup( buf );
i = uta_tokenise( dbuf, tokens, 127, ',' );
j = uta_has_str( buf, "Mrs. Slate", ',', 27 );
errors += fail_if_true( j >= 0, "has string not found Mrs. Slate" );
j = uta_has_str( buf, "Mrs. Slate", ',', 27 );
errors += fail_if_true( j >= 0, "has string not found Mrs. Slate" );
// ------------ host name 2 ip tests ---------------------------------------------------------
hname = uta_h2ip( "192.168.1.2" );
errors += fail_not_equal( strcmp( hname, "192.168.1.2" ), 0, "h2ip did not return IP address when given address" );
// ------------ host name 2 ip tests ---------------------------------------------------------
hname = uta_h2ip( "192.168.1.2" );
errors += fail_not_equal( strcmp( hname, "192.168.1.2" ), 0, "h2ip did not return IP address when given address" );
// ------------ rtg lookup test -------------------------------------------------------------
ctx.rtg_port = 0;
ctx.rtg_addr = NULL;
// ------------ rtg lookup test -------------------------------------------------------------
ctx.rtg_port = 0;
ctx.rtg_addr = NULL;
i = uta_lookup_rtg( NULL ); // ensure it handles a nil context
errors += fail_if_true( i, "rtg lookup returned that it found something when not expected to (nil context)" );
i = uta_lookup_rtg( NULL ); // ensure it handles a nil context
errors += fail_if_true( i, "rtg lookup returned that it found something when not expected to (nil context)" );
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
route_table_t* new_rtable; // route table under construction
if_addrs_t* ip_list; // list manager of the IP addresses that are on our known interfaces
void* mring; // ring where msgs are queued while waiting for a call response msg
route_table_t* new_rtable; // route table under construction
if_addrs_t* ip_list; // list manager of the IP addresses that are on our known interfaces
void* mring; // ring where msgs are queued while waiting for a call response msg
char* rtg_addr; // addr/port of the route table generation publisher
int rtg_port; // the port that the rtg listens on
char* rtg_addr; // addr/port of the route table generation publisher
int rtg_port; // the port that the rtg listens on
wh_mgt_t* wormholes; // management of user opened wormholes
//epoll_stuff_t* eps; // epoll information needed for the rcv with timeout call
wh_mgt_t* wormholes; // management of user opened wormholes
//epoll_stuff_t* eps; // epoll information needed for the rcv with timeout call
uta_ctx_t ctx; // context for uta_lookup test
void* if_list;
uta_ctx_t ctx; // context for uta_lookup test
void* if_list;
// ------------------ tokenise tests -----------------------------------------------------------
dbuf = strdup( buf );
i = uta_tokenise( dbuf, tokens, 127, ',' );
// ------------------ tokenise tests -----------------------------------------------------------
dbuf = strdup( buf );
i = uta_tokenise( dbuf, tokens, 127, ',' );
j = uta_has_str( buf, "Mrs. Slate", ',', 27 );
errors += fail_if_true( j >= 0, "has string not found Mrs. Slate" );
j = uta_has_str( buf, "Mrs. Slate", ',', 27 );
errors += fail_if_true( j >= 0, "has string not found Mrs. Slate" );
// ------------ host name 2 ip tests ---------------------------------------------------------
hname = uta_h2ip( "192.168.1.2" );
errors += fail_not_equal( strcmp( hname, "192.168.1.2" ), 0, "h2ip did not return IP address when given address" );
// ------------ host name 2 ip tests ---------------------------------------------------------
hname = uta_h2ip( "192.168.1.2" );
errors += fail_not_equal( strcmp( hname, "192.168.1.2" ), 0, "h2ip did not return IP address when given address" );
// ------------ rtg lookup test -------------------------------------------------------------
ctx.rtg_port = 0;
ctx.rtg_addr = NULL;
// ------------ rtg lookup test -------------------------------------------------------------
ctx.rtg_port = 0;
ctx.rtg_addr = NULL;
i = uta_lookup_rtg( NULL ); // ensure it handles a nil context
errors += fail_if_true( i, "rtg lookup returned that it found something when not expected to (nil context)" );
i = uta_lookup_rtg( NULL ); // ensure it handles a nil context
errors += fail_if_true( i, "rtg lookup returned that it found something when not expected to (nil context)" );
// : vi ts=4 sw=4 noet :
/*
==================================================================================
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 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
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
+ 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,
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
Note that the last tests in this function destroy the context and message so
/*
Note that the last tests in this function destroy the context and message so
- any tests added MUST be ahead of those tests.
+ any tests added MUST be ahead of those tests.
*/
static int worm_test( ) {
uta_ctx_t* ctx; // context needed to test load static rt
*/
static int worm_test( ) {
uta_ctx_t* ctx; // context needed to test load static rt