Example #1
0
void bronco::serverconnection::process_type(const size_t type)
{
    protocol::Confirm confirm;
    protocol::Config config;
    protocol::Peers peers;

    /* Perform operation determined by message type */
    switch (type) {
        case protocol::confirmtype:
            deserialize(confirm);
            process_message(confirm);
            break;

        case protocol::configtype:
            deserialize(config);
            process_message(config);
            break;

        case protocol::peerstype:
            deserialize(peers);
            process_message(peers);
            break;

        default:
            throw std::runtime_error("Unknown message type received");
            break;
    }
}
void pad_message(sha *op)
{
    int i;
    if(op->sub_count == 4)
    {
        ++(op->count);
        op->message[op->count] = 0x80000000;
    }
    else

    if(op->sub_count == 0)
        op->message[op->count] = 0x80000000;

    else
    {
        op->message[op->count] = ((op->message[op->count])<<8) | 0x80 ;
        ++(op->sub_count);
        while(op->sub_count!=4)
        {
            op->message[op->count] = ((op->message[op->count])<<8);
            ++(op->sub_count);
        }
    }


    if(op->count >13)
    {
        while(!((op->count == 15)&&(op->sub_count == 4)))
        {
            if((op->sub_count == 4)&&(op->count<15))
            {
                op->message[++(op->count)] = 0;
            }
            else
            {
                op->message[op->count] = (op->message[op->count]) << 8;
                ++(op->sub_count);
            }
        }
        process_message(op);

        for(i=0;i<16;++i)
            op->message[i] = 0;
    }

    op->message[14] = op->higher_count;
    op->message[15] = op->lower_count;

    process_message(op);
    op->completed = 1;
}
Example #3
0
static void
authentication_task (void *parameter)
{
	TBouncerEnvelope Bouncer;
	(void) parameter;
	memset (&authentication_state, 0, sizeof (authentication_state));
	authentication_state.state = AUTHENTICATION_IDLE;
	
	
	while(1) {
		if (nRFCMD_WaitRx (10)) {
			
			do {
				vLedSetRed (1);
				// read packet from nRF chip
				nRFCMD_RegReadBuf (RD_RX_PLOAD, (unsigned char *) &Bouncer, sizeof (Bouncer));
				
				process_message(&Bouncer);
				
				vLedSetRed (0);
			} while ((nRFAPI_GetFifoStatus () & FIFO_RX_EMPTY) == 0);
			
			nRFAPI_GetFifoStatus();
		}
		nRFAPI_ClearIRQ (MASK_IRQ_FLAGS);
	}
}
static void wrt_recv_cb(mrp_transport_t *t, void *data, void *user_data)
{
    pep_proxy_t *proxy = (pep_proxy_t *)user_data;
    char        *name  = proxy && proxy->name ? proxy->name : "<unknown>";
    msg_t       *msg;
    int          seqno;

    MRP_UNUSED(t);

    /*
      mrp_log_info("Message from WRT client %p:", proxy);
    */

    msg = json_decode_message(data);

    if (msg != NULL) {
        process_message(proxy, msg);
        msg_free_message(msg);
    }
    else {
        if (!mrp_json_get_integer(data, "seq", &seqno))
            seqno = 0;
        mrp_log_error("Failed to decode message from %s.", name);
        msg_send_nak(proxy, seqno, 1, "failed to decode message");
    }
}
	bool DisplayMessageQueue_X11::process(int timeout_ms)
	{
		auto end_time = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeout_ms);

		while (true)
		{
			process_message();
			process_queued_events(); // What is this? If its related to Event then it should be removed
			process_window_sockets(); // Same for this thing

			if (end_time <= std::chrono::steady_clock::now())
				break;

			int x11_handle = ConnectionNumber(display);

			struct timeval tv;
			if (timeout_ms > 0)
			{
				tv.tv_sec = timeout_ms / 1000;
				tv.tv_usec = (timeout_ms % 1000) * 1000;
			}
			else if (timeout_ms == 0)
			{
				tv.tv_sec = 0;
				tv.tv_usec = 0;
			}
			else
			{
				tv.tv_sec = 0x7FFFFFFF;
				tv.tv_usec = 0;
			}

			fd_set rfds;
			FD_ZERO(&rfds);

			FD_SET(x11_handle, &rfds);
			FD_SET(async_work_event.read_fd(), &rfds);
			FD_SET(exit_event.read_fd(), &rfds);

			int result = select(std::max(std::max(async_work_event.read_fd(), x11_handle), exit_event.read_fd()) + 1, &rfds, nullptr, nullptr, &tv);
			if (result > 0)
			{
				if (FD_ISSET(async_work_event.read_fd(), &rfds))
				{
					async_work_event.reset();
					process_async_work();
				}
				if (FD_ISSET(exit_event.read_fd(), &rfds))
				{
					exit_event.reset();
					return false;
				}
			}
			else
			{
				break;
			}
		}
		return true;
	}
Example #6
0
static void process_frame(const char * const body)
{
   jsmn_parser parser;
   qword elapsed = time_ms();
   
   jsmn_init(&parser);
   int r = jsmn_parse(&parser, body, tokens, NUM_TOKENS);
   if(r != 0) 
   {
      _log(MAJOR, "Parser result %d.  Message discarded.", r);
      stats[NotRecog]++;
   }
   else
   {
      size_t messages, i, index;
      // Is it an array?
      if(tokens[0].type == JSMN_ARRAY)
      {
         messages = tokens[0].size;
         index = 1;
         _log(DEBUG, "STOMP message is array of %d TD messages.", messages);
      }
      else
      {
         messages = 1;
         index = 0;
         _log(DEBUG, "STOMP message contains a single TD message.");
      }

      for(i=0; i < messages && run; i++)
      {
         char area_id[4];
         word describer;
         jsmn_find_extract_token(body, tokens, index, "area_id", area_id, sizeof(area_id));

         stats[GoodMessage]++;
         message_count++;

         for(describer = 0; describer < DESCRIBERS; describer++)
         {
            if(!strcasecmp(area_id, describers[describer]))
            {
               process_message(describer, body, index);
               stats[RelMessage]++;
               message_count_rel++;
               describer = DESCRIBERS;
            }
         }
         
         size_t message_ends = tokens[index].end;
          do  index++; 
         while ( tokens[index].start < message_ends && tokens[index].start >= 0 && index < NUM_TOKENS);
      }
   }
   elapsed = time_ms() - elapsed;
   if(debug || elapsed > 2500)
   {
      _log(MINOR, "Frame took %s ms to process.", commas_q(elapsed));
   }
}
void t_adventure_map_window::run_object_mover( t_counted_ptr<t_army_mover> mover,
											   bool allow_cancel )
{
	// a little paranoid self-reference if this window is closed during the move.
	t_window_ptr					ref = this;
	t_counted_ptr<t_adventure_map>	map = m_map;

	clear_spell_targeter();
	m_object_mover = mover;
	m_frame->reset_pathfinder();

	// override all the game's input
	// any mouse or key press will abort the move
	t_override_input input_handler;

	if (allow_cancel)
	{
		// override all the game's input
		// any mouse or key press will abort the move
		t_handler cancel_handler = bound_handler( *mover, &t_army_mover::cancel_move );

		input_handler.set_input_handler( cancel_handler );
	}
	// run one cycle before anything else happens.
	mover->on_idle();
	while ( !map->is_game_over() && !mover->is_done()) 
	{
		process_message();
	}
}
// Check if there's a handler for this message and call it, else
// discard message.
void sac_dispatch::operator()(meta_message_ptr& in)
{
	/** __no__ authentication at this point */

	uint mid = in->mid();

	log(1, "(sac) dispatching message with mid: ", mid);
	//
	// no thread safety because insertion should __only__ be made
	// on MIHF initialization
	//
	std::map<uint, handler_t>::iterator it;
	it = _callbacks.find(mid);

	if(it != _callbacks.end()) {
		handler_t process_message = it->second;
		meta_message_ptr out(new meta_message);

		out->tid(in->tid());
		// send response if it was generated
		if (process_message(in, out))
		 	_transmit(out);
        } else {
		log(1, "(sac) (warning) message with mid: ", mid,
		    " unknown, discarding.");
	}
}
Example #9
0
/* returns error */
int DEFAULT_CC
my_trans_data_in(struct trans *trans)
{
    struct stream *s = (struct stream *)NULL;
    int id = 0;
    int size = 0;
    int error = 0;

    if (trans == 0)
    {
        return 0;
    }

    if (trans != g_con_trans)
    {
        return 1;
    }

    LOGM((LOG_LEVEL_DEBUG, "my_trans_data_in:"));
    s = trans_get_in_s(trans);
    in_uint32_le(s, id);
    in_uint32_le(s, size);
    error = trans_force_read(trans, size - 8);

    if (error == 0)
    {
        /* here, the entire message block is read in, process it */
        error = process_message();
    }

    return error;
}
Example #10
0
/* check if there's a message from the server */
void get_server_message () {
  int nr_active_sock, reclen, startptr = 0, msglen;

try_again:
  nr_active_sock = SDLNet_CheckSockets (theset, 1);
  if (nr_active_sock == 0) return;
  if (!SDLNet_SocketReady (thesock)) return;

  reclen = get_packet ();
  if (reclen == -1) return;
  if (reclen <= 0) {
    log_error ("Disconnected by the server!\n");
    exit_connection (EXIT_ALL);
    exit (1);
  }

  msglen = *((short *) (msgbuf + startptr + 1));
  msglen += 2;
  if (process_message(msgbuf+startptr, msglen) == 0) {
    /* something went wrong when processing our message. Log out. */
    exit_connection (EXIT_ALL);
    log_error ("Unable to process message");
    exit (1);
  }

  goto try_again;
}
Example #11
0
//-----------------------------------------------------------------------------
static void client_read(TcpClient * socket, char *buf, int len)
{
	TcpClientState *state = tcpclient_get_user_data(socket);	
	
	int i = 0;
	while (i != len) {
		/* reading new msg */
		if (state->msg_size == 0) {
			state->msg_type = buf[i++];													
			state->msg_size = *(uint32_t*)(buf + i);				
			state->read_buf = realloc(state->read_buf, state->msg_size);
			state->num_read_bytes = 0;
			i += sizeof(uint32_t);				
		}
		
		int nbytes = state->msg_size - state->num_read_bytes;		
		int rbytes = (len - i) < nbytes ? (len - i) : nbytes;
		memcpy(state->read_buf + state->num_read_bytes, buf + i, rbytes);		
		i += rbytes;
		state->num_read_bytes += rbytes;		
			
		if (state->msg_type != TCP_MSG_NONE && state->num_read_bytes == state->msg_size) {						
			process_message(state);
			state->msg_size = 0;
			if (i != len) {
				printf("warning: more than one message per buffer (%d bytes).\n", len - i);				
			}
		}
	}		
}
Example #12
0
int main(int argc, char **argv)
{
    option_define_bool("version", OPT_OPTIONAL, 0, NULL, version_cb, VERSION);
    option_define_bool("verbose", OPT_OPTIONAL, 0, &verbose, NULL, "verbose output (to stderr)");
    option_define_str("blacklist_fields", OPT_OPTIONAL, NULL, NULL, parse_blacklisted_fields, "comma separated list of fields to remove");
    option_define_str("encrypted_fields", OPT_OPTIONAL, NULL, NULL, parse_encrypted_fields, "comma separated list of fields to encrypt");
    option_define_str("expected_key", OPT_OPTIONAL, NULL, &expected_key, NULL, "key to expect in messages before echoing to clients");
    option_define_str("expected_value", OPT_OPTIONAL, NULL, &expected_value, NULL, "value to expect in --expected-key field in messages before echoing to clients");
    
    if (!option_parse_command_line(argc, argv)) {
        return 1;
    }
    
    if ( !!expected_key ^ !!expected_value ) {
        fprintf(stderr, "--expected-key and --expected-value must be used together\n");
        exit(1);
    }
    
    while (fgets(buf, BUF_SZ, stdin)) {
        msgRecv++;
        process_message(buf);
    }
    
    fprintf(stderr, "processed %lu lines, failed to parse %lu of them\n", msgRecv, msgFail);
    free_options();
    free_fields(blacklisted_fields, num_blacklisted_fields);
    free_fields(encrypted_fields, num_encrypted_fields);
    
    return 0;
}
/// Implement its svc() hook method to perform the "half-sync"
int Echo_Task::svc(void)
{
  ACE_DEBUG((LM_INFO,
	     ACE_TEXT("(%t) Echo_task::svc\n")));

  while (1)
    {
      // Dequeueing messages (ACE_Message_Blocks obtained via ACE_Task::getq()) 
      // containing the client input that was put into its synchronized request queue
      ACE_Message_Block *mb = NULL;
      if (this->getq(mb) == -1)
	{
	  ACE_DEBUG((LM_INFO,
		     ACE_TEXT("(%t) Shutting down\n")));
	  break;
	}

      ACE_DEBUG((LM_INFO, 
		 ACE_TEXT("(%t) Call process_message\n")));

      process_message(mb);
    }

  return 0;
}
// Listing 1
// Listing 2 code/ch16
int
LF_ThreadPool::svc (void)
{
  ACE_TRACE (ACE_TEXT ("LF_ThreadPool::svc"));
  while (!done ())
    {
      become_leader ();  // Block until this thread is the leader.

      ACE_Message_Block *mb = NULL;
      ACE_Time_Value tv (LONG_TIME);
      tv += ACE_OS::gettimeofday ();

      // Get a message, elect new leader, then process message.
      if (this->getq (mb, &tv) < 0)
        {
          if (elect_new_leader () == 0)
            break;
          continue;
        }

      elect_new_leader ();
      process_message (mb);
    }

  return 0;
}
Example #15
0
static DBusHandlerResult generic_message(DBusConnection *connection,
					DBusMessage *message, void *user_data)
{
	struct generic_data *data = user_data;
	struct interface_data *iface;
	const GDBusMethodTable *method;
	const char *interface;

	interface = dbus_message_get_interface(message);

	iface = find_interface(data->interfaces, interface);
	if (iface == NULL)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

	for (method = iface->methods; method &&
			method->name && method->function; method++) {
		if (dbus_message_is_method_call(message, iface->name,
							method->name) == FALSE)
			continue;

		if (dbus_message_has_signature(message,
						method->signature) == FALSE)
			continue;

		if (check_privilege(connection, message, method,
						iface->user_data) == TRUE)
			return DBUS_HANDLER_RESULT_HANDLED;

		return process_message(connection, message, method,
							iface->user_data);
	}

	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
	bool DisplayMessageQueue_Win32::process(int timeout_ms)
	{
		auto end_time = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeout_ms);

		while (true)
		{
			while (true)
			{
				MSG msg;
				BOOL result = PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
				if (result)
				{
					if (!process_message(msg))
						return false;
				}
				else
				{
					break;
				}
			}

			if (end_time <= std::chrono::steady_clock::now())
				break;

			if (MsgWaitForMultipleObjects(0, 0, FALSE, timeout_ms, QS_ALLEVENTS | QS_SENDMESSAGE | QS_RAWINPUT) == WAIT_TIMEOUT)
				break;
		}

		return true;
	}
Example #17
0
bool tchatbox::process_network_data(const ::config& data)
{
	if(const ::config& c = data.child("message")) {
		process_message(c);
	} else if(const ::config& c = data.child("whisper")) {
		process_message(c, true);
	} else if(const ::config& c = data.child("room_join")) {
		process_room_join(c);
	} else if(const ::config& c = data.child("room_part")) {
		process_room_part(c);
	} else if(const ::config& c = data.child("room_query_response")) {
		process_room_query_response(c);
	}

	return false;
}
Example #18
0
bool chatbox::process_network_data(const ::config& data)
{
	if(const ::config& message = data.child("message")) {
		process_message(message);
	} else if(const ::config& whisper = data.child("whisper")) {
		process_message(whisper, true);
	} else if(const ::config& room_join = data.child("room_join")) {
		process_room_join(room_join);
	} else if(const ::config& room_part = data.child("room_part")) {
		process_room_part(room_part);
	} else if(const ::config& room_query_response = data.child("room_query_response")) {
		process_room_query_response(room_query_response);
	}

	return false;
}
Example #19
0
  virtual int svc (void)
  {
    ACE_Thread_ID id;
    thread_id_ = id;
    while (1)
      {
        ACE_Message_Block *mb = 0;
        if (this->getq (mb) == -1)
          ACE_ERROR_BREAK
            ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("getq")));
        if (mb->msg_type () == ACE_Message_Block::MB_HANGUP)
          {
            ACE_DEBUG ((LM_INFO,
                        ACE_TEXT ("(%t) Shutting down\n")));
            mb->release ();
            break;
          }
        // Process the message.
        process_message (mb);
        // Return to work.
        this->manager_->return_to_work (this);
      }

    return 0;
  }
void calculate(sha *op, unsigned char c)
{
    int i;
    if(op->sub_count == 4)
    {
        ++(op->count);
        op->sub_count = 0;
    }
    op->message[op->count] = ((op->message[op->count])<<8)| c;
    ++(op->sub_count);


    op->lower_count += 8;
    if(op->lower_count==0)
    {
        ++(op->higher_count);
        if(op->higher_count==0)
        {
            printf("\nSize of input file exceeded the limit\n");
            exit(0);
        }
    }

    if((op->count == 15)&&(op->sub_count == 4))
    {
        process_message(op);
        op->count = 0;
        op->sub_count = 0;
        for(i=0;i<16;++i)
            op->message[i] = 0;
    }
}
Example #21
0
void TCSoapRunnable::run()
{
    struct soap soap;
    soap_init(&soap);
    soap_set_imode(&soap, SOAP_C_UTFSTRING);
    soap_set_omode(&soap, SOAP_C_UTFSTRING);

    // check every 3 seconds if world ended
    soap.accept_timeout = 3;
    soap.recv_timeout = 5;
    soap.send_timeout = 5;
    if (!soap_valid_socket(soap_bind(&soap, _host.c_str(), _port, 100)))
    {
        TC_LOG_ERROR("network.soap", "Couldn't bind to %s:%d", _host.c_str(), _port);
        exit(-1);
    }

    TC_LOG_INFO("network.soap", "Bound to http://%s:%d", _host.c_str(), _port);

    while (!World::IsStopped())
    {
        if (!soap_valid_socket(soap_accept(&soap)))
            continue;   // ran into an accept timeout

        TC_LOG_DEBUG("network.soap", "Accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF);
        struct soap* thread_soap = soap_copy(&soap);// make a safe copy

        ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*));
        ACE_OS::memcpy(mb->wr_ptr(), &thread_soap, sizeof(struct soap*));
        process_message(mb);
    }

    soap_done(&soap);
}
Example #22
0
void TCSoapThread(const std::string& host, uint16 port)
{
    struct soap soap;
    soap_init(&soap);
    soap_set_imode(&soap, SOAP_C_UTFSTRING);
    soap_set_omode(&soap, SOAP_C_UTFSTRING);

    // check every 3 seconds if world ended
    soap.accept_timeout = 3;
    soap.recv_timeout = 5;
    soap.send_timeout = 5;
    if (!soap_valid_socket(soap_bind(&soap, host.c_str(), port, 100)))
    {
        TC_LOG_ERROR("network.soap", "Couldn't bind to %s:%d", host.c_str(), port);
        exit(-1);
    }

    TC_LOG_INFO("network.soap", "Bound to http://%s:%d", host.c_str(), port);

    while (!World::IsStopped())
    {
        if (!soap_valid_socket(soap_accept(&soap)))
            continue;   // ran into an accept timeout

        TC_LOG_DEBUG("network.soap", "Accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF);
        struct soap* thread_soap = soap_copy(&soap);// make a safe copy
        process_message(thread_soap);
    }

    soap_done(&soap);
}
Example #23
0
/* returns error */
	int DEFAULT_CC
my_trans_data_in(struct trans* trans)
{
	struct stream* s;
	int id;
	int size;
	int error;

	if (trans == 0)
	{
		return 0;
	}
	if (trans != g_con_trans)
	{
		return 1;
	}
	log_message(&log_conf, LOG_LEVEL_DEBUG, "chansrv[my_trans_data_in]: "
			"my_trans_data_in:");
	s = trans_get_in_s(trans);
	in_uint32_le(s, id);
	in_uint32_le(s, size);
	error = trans_force_read(trans, size - 8);
	if (error == 0)
	{
		/* here, the entire message block is read in, process it */
		error = process_message();
	}
	return error;
}
Example #24
0
int lsb_heka_pm_input(lsb_heka_sandbox *hsb,
                      double cp_numeric,
                      const char *cp_string,
                      bool profile)
{
  if (!hsb || hsb->type != 'i') {
    return 1;
  }

  lsb_err_value ret = lsb_pcall_setup(hsb->lsb, pm_func_name);
  if (ret) {
    if (ret != LSB_ERR_TERMINATED) {
      char err[LSB_ERROR_SIZE];
      snprintf(err, LSB_ERROR_SIZE, "%s() function was not found",
               pm_func_name);
      lsb_terminate(hsb->lsb, err);
    }
    return 1;
  }

  lua_State *lua = lsb_get_lua(hsb->lsb);
  if (!lua) return 1;

  if (!isnan(cp_numeric)) {
    lua_pushnumber(lua, cp_numeric);
  } else if (cp_string) {
    lua_pushstring(lua, cp_string);
  } else {
    lua_pushnil(lua);
  }
  return process_message(hsb, NULL, lua, 1, profile);
}
Example #25
0
int main () {
    GC_init();
    int sock = CHECK(socket, AF_INET, SOCK_STREAM, 0);
    sockaddr_in listen_addr = any_addr();
    printf("bind...\n");
    CHECK(bind, sock, (sockaddr*)&listen_addr, sizeof(listen_addr));
    printf("listen...\n");
    CHECK(listen, sock, SOMAXCONN);
    sockaddr_in client_addr;
    socklen_t client_addr_len;
    int new_sock;
    printf("accept...\n");
    do {
        new_sock = CHECK(accept, sock, (sockaddr*)&client_addr, &client_addr_len);
        char* message = recv_string(new_sock);
        puts(message);
        const char* response = process_message((const char*)message);
        puts("Response generated.");
        CHECK(send, new_sock, response, strlen(response) + 1, 0);
        puts("Response sent.\n");
//        char endbuf [MAX_BUFFER];
//        CHECK(recv, new_sock, endbuf, MAX_BUFFER, 0);
//        puts("Close request recieved.");
        CHECK(close, new_sock);
    } while (0);
    CHECK(close, sock);
    return 0;
}
Example #26
0
    void socket_readable()
    {
        m_pac.reserve_buffer(1024);

        ssize_t count =
            read(m_sock, m_pac.buffer(), m_pac.buffer_capacity());

        if(count <= 0) {
            if(count == 0) {
                throw std::runtime_error("connection closed");
            }
            if(errno == EAGAIN || errno == EINTR) {
                return;
            }
            throw std::runtime_error(strerror(errno));
        }

        m_pac.buffer_consumed(count);

        msgpack::unpacked result;
        while (m_pac.next(&result)) {
            msgpack::object msg = result.get();
            unique_zone& life = result.zone();
            process_message(msg, life);
        }

        if(m_pac.message_size() > 10*1024*1024) {
            throw std::runtime_error("message is too large");
        }
    }
Example #27
0
void process_packet( MarSystem * root_system, const char * data, size_t size )
{
  osc::ReceivedPacket packet( data, size );
  if( packet.IsBundle() )
      process_bundle( root_system, osc::ReceivedBundle(packet) );
  else
      process_message( root_system, osc::ReceivedMessage(packet) );
}
/**
 * Check if there's a handler for this message and call it, else
 * discard message.
 *
 * @param in The input message.
 * @param out The output message.
 */
bool sac_process_message(meta_message_ptr& in, meta_message_ptr& out)
{
	// discard messages that this MIHF broadcasted to itself
	// discard messages that are not destined to this MIHF or if
	// multicast messages are not supported
	if(in->source() == mihfid) {
		ODTONE_LOG(1, "(sac) Discarding message! Reason: ",
					  "message was broadcasted to itself");
		return false;
	}

	if(!utils::this_mihf_is_destination(in) && !utils::is_multicast(in)) {
		ODTONE_LOG(1, "(sac) Discarding message! Reason: ",
					  "this is not the message destination");
		return false;
	}

	/** __no__ authentication at this point */

	uint mid = in->mid();

	//
	// no thread safety because insertion should __only__ be made
	// on MIHF initialization
	//
	std::map<uint, handler_t>::iterator it;
	it = _callbacks.find(mid);

	if(it != _callbacks.end()) {
		handler_t process_message = it->second;

		bool rsp;

		try {

			rsp = process_message(in, out);

		} catch(mih::bad_tlv) {
			ODTONE_LOG(1, "Discarding malformed message.");
			return false;
		}

		// set ip and port of response message
		out->ip(in->ip());
		out->scope(in->scope());
		out->port(in->port());

		// response message must have the same tid
		out->tid(in->tid());

		return rsp;
	} else {
		ODTONE_LOG(1, "(sac) (warning) message with mid: ", mid,
		    " unknown, discarding.");
	}

	return false;
}
Example #29
0
void linux_unicast_router::do_dump(int id) {
    rt_dumping = true;

    dump_request(id);

    while (process_message() > 0);

    rt_dumping = false;
}
Example #30
0
static void process_messages(po_message_iterator_t it)
{
	po_message_t m = po_next_message(it);
	while(m)
	{
		process_message(m);
		m = po_next_message(it);
	}
}