+static int em_nn_recv (int s, void *m, size_t len, int flags ) {
+ void* b;
+ struct em_msg* msg;
+ static int count = 0; // we'll simulate a message going in by dropping an rmr-ish msg with transaction id only
+ int trace_size = 0;
+ static int counter = 0; // if timeout value is set; we return timeout (eagain) every 3 calls
+ int d1_size = 0;
+
+ if( em_timeout > 0 ) {
+ counter++;
+ if( counter % 3 == 0 ) {
+ return EAGAIN;
+ }
+ }
+
+ if( em_mtc_msgs ) {
+ d1_size = 4;
+ }
+
+ b = (void *) malloc( 2048 );
+ if( m != NULL ) { // blindly we assume this is 2k or bigger
+ memset( m, 0, 2048 );
+ msg = (struct em_msg *) m;
+ if( count % 10 == 9 ) {
+ //msg->rmr_ver = htonl( MSG_VER );
+ msg->rmr_ver = ALT_MSG_VER; // emulate the bug in RMr v1
+ } else {
+ msg->rmr_ver = htonl( MSG_VER );
+ }
+ msg->mtype = htonl( 1 );
+ msg->plen = htonl( 220 );
+ msg->len0 = htonl( sizeof( struct em_msg ) );
+ msg->len1 = htonl( trace_size );
+ msg->len2 = htonl( d1_size );
+ msg->len3 = htonl( 0 );
+ snprintf( msg->xid, 32, "%015d", count++ ); // simple transaction id so we can test receive specific and ring stuff
+ snprintf( msg->src, 64, "localhost:4562" ); // set src id (unrealistic) so that rts() can be tested
+ snprintf( msg->srcip, 64, "89.2.19.19:4562" ); // set src ip for rts testing
+ //fprintf( stderr, "<EM> returning message len=%d\n\n", ntohl( msg->plen ) );
+ } else {
+ fprintf( stderr, "<EM> message was nil\n\n" );
+ }
+
+ //fprintf( stderr, ">>> simulated received message: %s %s len=%d p=%p\n", msg->src, msg->srcip, ntohl( msg->plen ), m );
+ return 2048;