static int inline is_our_fd (int fd) { if ((!is_registered (&v4v_fds, fd)) && (!is_registered (&v4v_checked, fd))) { check_fd (fd); } return is_registered (&v4v_fds, fd); }
/* Notifies to each client registered to the given TAO that the TAO was created. */ void notify_tao_creation(tao* created_tao){ /* For each client interested in the TAO */ int i = 0; for (; i < created_tao->interested_clients_count; i++){ int client_pid = created_tao->interested_clients[i]; if(is_registered(client_pid) == 1){ /* Allocates the simple_message message */ auction_status* msg = (auction_status*) malloc(sizeof(auction_status)); msg->mtype = AUCTION_STATUS_MTYPE; msg->type = AUCTION_CREATED; strcpy(msg->resource, created_tao->name); msg->shm_id = created_tao->shm_id; msg->sem_id = created_tao->sem_id; msg->base_bid = created_tao->base_bid; /* Sends the message and waits for the client status */ int client_msqid = client_msqid_from_pid(client_pid); msgsnd(client_msqid, msg, sizeof(auction_status) - sizeof(long), 0600); listen_client_status(client_msqid); free(msg); } } }
void Dialog::run() { if(!is_registered()) throw std::logic_error("**Dialog::run** Can't run a not registered Dialog"); _response = NO_RESPONSE; show(); }
/////////////////////////////////////////////////////////////////////////////// // // FUNCTION NAME: try_register // // PROCESSING: // // This function attempts to register the task with the mp2 kernel module // // INPUTS: // // pid - the PID of the process // period - the period of the process // processTime - the process time of the process // // RETURN: // // bool - FALSE, if the PID is not registered (doesn't appear in the proc entry) // TRUE, if the PID is registered (appears in the proc entry) // // IMPLEMENTATION NOTES // // The try_register function uses a system call to update the /proc/mp2/status // by writing a formatted register message to the file via echo. After the call // to the kernel, the function verifies that the PID appears in the proc file // by calling is_registered. // /////////////////////////////////////////////////////////////////////////////// bool try_register(pid_t pid, long period, long processTime){ // create the string to write to the proc file char action[128]; sprintf(action, "echo \"R %d %ld %ld\" > /proc/mp2/status", pid, period, processTime); system(action); // let's check if we are a registered process return is_registered(pid); }
/** * Verification du respect des contraintes d'une trame Order: * - le joueur doit etre inscrit * * @param sock Socket du joueur ayant envoye cette trame * @param the_players Liste des joueurs ou s'effectue la verification * @return SUCCESS(1) si les contraintes sont respectees, ERROR(0) sinon */ int check_order_constraint(int sock, Players the_players) { int check = ERROR; if(is_registered(sock, the_players)) { check = SUCCESS; } return check; }
HttpGetEndpointImpl::HttpGetEndpointImpl ( const boost::property_tree::ptree &conf, std::shared_ptr<MediaPipeline> mediaPipeline, bool terminateOnEOS, std::shared_ptr<MediaProfileSpecType> mediaProfile, int disconnectionTimeout) : HttpEndpointImpl (conf, std::dynamic_pointer_cast< MediaObjectImpl > (mediaPipeline), disconnectionTimeout, FACTORY_NAME) { g_object_set ( G_OBJECT (element), "accept-eos", terminateOnEOS, NULL); switch (mediaProfile->getValue() ) { case MediaProfileSpecType::WEBM: GST_INFO ("Set WEBM profile"); g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_WEBM, NULL); break; case MediaProfileSpecType::MP4: GST_INFO ("Set MP4 profile"); g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_MP4, NULL); break; case MediaProfileSpecType::WEBM_VIDEO_ONLY: g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_WEBM_VIDEO_ONLY, NULL); GST_INFO ("Set WEBM profile"); break; case MediaProfileSpecType::WEBM_AUDIO_ONLY: g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_WEBM_AUDIO_ONLY, NULL); GST_INFO ("Set WEBM profile"); break; case MediaProfileSpecType::MP4_VIDEO_ONLY: g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_MP4_VIDEO_ONLY, NULL); GST_INFO ("Set WEBM profile"); break; case MediaProfileSpecType::MP4_AUDIO_ONLY: g_object_set ( G_OBJECT (element), "profile", KMS_RECORDING_PROFILE_MP4_AUDIO_ONLY, NULL); GST_INFO ("Set WEBM profile"); break; } register_end_point(); if (!is_registered() ) { throw KurentoException (HTTP_END_POINT_REGISTRATION_ERROR, "Cannot register HttpGetEndPoint"); } }
void abstract_actor::is_registered(bool value) { if (is_registered() == value) { return; } if (value) { detail::singletons::get_actor_registry()->inc_running(); } else { detail::singletons::get_actor_registry()->dec_running(); } set_flag(value, is_registered_flag); }
/** * The main function. */ int main() { /* Seeding random number generator */ srand( time(NULL) ); int my_pid = getpid(); unsigned int period = get_period(); unsigned int computation_time = get_comp_time(period); register_process(my_pid, period, computation_time); if(!is_registered(my_pid)) { printf("%d: I was unable to register. ;_;\n", my_pid); exit(1); } printf("%d: Registered! \n", my_pid); unsigned int iterations = get_iterations(); yield(my_pid); while(iterations > 0) { struct timeval time; gettimeofday(&time); unsigned int start_time = time.tv_usec; unsigned int time_elapsed = 0; while(time_elapsed < computation_time) { int i; for(i = 0; i < 100; i++) { factorial((i % 20)+1); } gettimeofday(&time); time_elapsed = time.tv_usec - start_time; } yield(my_pid); iterations--; } unregister(my_pid); return 0; }
/* Notifies to each client registered to the given TAO the auction result, * specifying the name of the resource, and for each client the quantity and * the unit price won by it. */ void notify_auction_result(int client_pid, char* name, int quantity, int unit_bid){ /* Allocates the simple_message message */ auction_status* msg = (auction_status*) malloc(sizeof(auction_status)); msg->mtype = AUCTION_STATUS_MTYPE; msg->type = AUCTION_RESULT; strcpy(msg->resource, name); msg->quantity = quantity; msg->unit_bid = unit_bid; /* Sends the message and waits for the client status */ int client_msqid = client_msqid_from_pid(client_pid); if(is_registered(client_pid) == 1){ msgsnd(client_msqid, msg, sizeof(auction_status) - sizeof(long), 0600); listen_client_status(client_msqid); } free(msg); }
/*! * \brief Explicitly unregisters this callback. * * Once the callback has been unregistered the function this is associated * with will no longer be called when the CallbackHandler is triggered and * this will become a null ScopedCallback. * * \throws arc::ex::IllegalActionError If this is called on a null * ScopedCallbackId. */ void unregister() { if(is_null()) { throw arc::ex::IllegalActionError( "unregister cannot be called on null ScopedCallbacks"); } // there should be at least one instance!! assert(m_ref_counter->count > 0); // unregister if it hasn't been done already if(is_registered()) { m_interface->unregister_function(m_id); m_ref_counter->early_unregister = true; } // nullify this object m_ref_counter = nullptr; m_interface = nullptr; m_id = 0; }
/////////////////////////////////////////////////////////////////////////////// // // FUNCTION NAME: try_unregister // // PROCESSING: // // This function attempts to unregister the given PID from the kernel module // task list. // // INPUTS: // // pid - the PID of the process // // RETURN: // // bool - FALSE, the /proc/mp2/status could not be opened for writing // TRUE, if the task is not registered // // IMPLEMENTATION NOTES // // The try_unregister function uses a file handle to the /proc/mp2/status // and then writes a formatted yield message to the file. It closes the file // after it has finished writing to it. // /////////////////////////////////////////////////////////////////////////////// bool try_unregister(pid_t pid){ FILE *mp2_proc; // for /proc/mp2/status file handler mp2_proc = fopen("/proc/mp2/status", "w"); if(mp2_proc == NULL){ // an error occurred when trying to read the file printf("Unable to open /proc/mp2/status for writing\n"); return false; } // create the string to write to the proc file char action[128]; sprintf(action, "D %u", pid); fputs(action, mp2_proc); // close the file fclose(mp2_proc); // let's check if we are still registered, return false if we are, true if we aren't return !is_registered(pid); }
void abstract_broker::launch(execution_unit*, bool, bool is_hidden) { // add implicit reference count held by the middleman ref(); is_registered(! is_hidden); CAF_PUSH_AID(id()); CAF_LOGF_TRACE("init and launch broker with ID " << id()); // we want to make sure initialization is executed in MM context do_become( [=](sys_atom) { CAF_LOGF_TRACE("ID " << id()); bhvr_stack_.pop_back(); // launch backends now, because user-defined initialization // might call functions like add_connection for (auto& kvp : doormen_) { kvp.second->launch(); } initialize(); }, true); enqueue(invalid_actor_addr, invalid_message_id, make_message(sys_atom::value), nullptr); }
/* returns a valid nick from the list, x is the first <nick>foo</nick> xmlnode, checks siblings */ char *con_room_nick(cnr room, cnu user, xmlnode x) { char *nick = NULL; xmlnode cur; int count = 1; if(room == NULL || user == NULL) { log_warn(NAME, "[%s] Aborting - NULL attribute found", FZONE); return NULL; } log_debug(NAME, "[%s] looking for valid nick in room %s from starter %s", FZONE, jid_full(room->id), xmlnode2str(x)); /* make-up-a-nick phase */ if(x == NULL) { nick = pmalloco(user->p, j_strlen(user->realid->user) + 10); log_debug(NAME, "[%s] Malloc: Nick = %d", FZONE, j_strlen(user->realid->user) + 10); sprintf(nick, "%s", user->realid->user); while(g_hash_table_lookup(room->local, nick) != NULL) sprintf(nick, "%s%d", user->realid->user,count++); return nick; } /* scan the list */ for(cur = x; cur != NULL; cur = xmlnode_get_nextsibling(cur)) { if(j_strcmp(xmlnode_get_name(cur),"nick") == 0 && (nick = xmlnode_get_data(cur)) != NULL) if(g_hash_table_lookup(room->local, nick) == NULL) break; } if(is_registered(room->master, jid_full(jid_user(user->realid)), nick) == -1) nick = NULL; return nick; }
~ScopedCallback() { // do nothing if this is null if(is_null()) { return; } // reference counter should be non-zero assert(m_ref_counter->count > 0); // decrement the reference counter and check if this is the last // reference if(--m_ref_counter->count == 0) { // does the callback need unregistering? if(is_registered()) { m_interface->unregister_function(m_id); } // clean up the reference counter delete m_ref_counter; } }
void register_creator( Id class_id, BaseCreator& base_creator ) { assert( !is_registered( class_id ) ); m_creators.emplace( std::make_pair( class_id, std::ref( base_creator ) ) ); }
actor_pool::actor_pool(actor_config& cfg) : monitorable_actor(cfg) { is_registered(true); }
void local_actor::cleanup(uint32_t reason) { CAF_LOG_TRACE(CAF_ARG(reason)); super::cleanup(reason); // tell registry we're done is_registered(false); }
static int w_is_registered(struct sip_msg* _m, char* _d, char* _foo) { return is_registered(_m, (udomain_t*)_d); }
int rp_bazaar_app_get_local_list(const char *dir, cJSON **json_root, ngx_pool_t *pool, int verbose) { static int once = 1; if (once) { system("bazaar idgen 0"); once = 0; } DIR *dp; struct dirent *ep; if((dp = opendir(dir)) == NULL) return rp_module_cmd_error(json_root, "Can not open apps directory", strerror(errno), pool); while((ep = readdir (dp))) { const char *app_id = ep->d_name; cJSON *info = NULL; /* check if structure is correct, we need: * <app_id>/info/info.json * <app_id>/info/icon.png * <app_id>/controllerhf.so * <app_id>/fpga.bit * And we must be able to load the application and test mandatory * functions. */ if (!is_readable(dir, app_id, "info/icon.png")) continue; if (!is_readable(dir, app_id, "fpga.conf")) continue; if (!is_controller_ok(dir, app_id, "controllerhf.so")) continue; if (!get_info(&info, dir, app_id, pool)) continue; if (info == NULL) continue; /* We have an application */ int demo = !is_registered(dir, app_id, "controllerhf.so"); if (verbose) { /* Attach whole info JSON */ cJSON_AddItemToObject(info, "type", cJSON_CreateString(demo ? "demo" : "run", pool), pool); cJSON_AddItemToObject(*json_root, app_id, info, pool); } else { /* Include version only */ cJSON *j_ver = cJSON_GetObjectItem(info, "version"); if(j_ver == NULL) { fprintf(stderr, "Cannot get version from info JSON.\n"); cJSON_Delete(info, pool); continue; } cJSON_AddItemToObject(*json_root, app_id, cJSON_CreateString(j_ver->valuestring, pool), pool); cJSON_AddItemToObject(*json_root, "type", cJSON_CreateString(demo ? "demo" : "run", pool), pool); cJSON_Delete(j_ver, pool); cJSON_Delete(info, pool); } } closedir(dp); return 0; }
bool actor_pool::filter(upgrade_lock<detail::shared_spinlock>& guard, const strong_actor_ptr& sender, message_id mid, message_view& mv, execution_unit* eu) { auto& content = mv.content(); CAF_LOG_TRACE(CAF_ARG(mid) << CAF_ARG(content)); if (content.match_elements<exit_msg>()) { // acquire second mutex as well std::vector<actor> workers; auto em = content.get_as<exit_msg>(0).reason; if (cleanup(std::move(em), eu)) { auto tmp = mv.move_content_to_message(); // send exit messages *always* to all workers and clear vector afterwards // but first swap workers_ out of the critical section upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard}; workers_.swap(workers); unique_guard.unlock(); for (auto& w : workers) anon_send(w, tmp); is_registered(false); } return true; } if (content.match_elements<down_msg>()) { // remove failed worker from pool auto& dm = content.get_as<down_msg>(0); upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard}; auto last = workers_.end(); auto i = std::find(workers_.begin(), workers_.end(), dm.source); CAF_LOG_DEBUG_IF(i == last, "received down message for an unknown worker"); if (i != last) workers_.erase(i); if (workers_.empty()) { planned_reason_ = exit_reason::out_of_workers; unique_guard.unlock(); quit(eu); } return true; } if (content.match_elements<sys_atom, put_atom, actor>()) { auto& worker = content.get_as<actor>(2); worker->attach(default_attachable::make_monitor(worker.address(), address())); upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard}; workers_.push_back(worker); return true; } if (content.match_elements<sys_atom, delete_atom, actor>()) { upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard}; auto& what = content.get_as<actor>(2); auto last = workers_.end(); auto i = std::find(workers_.begin(), last, what); if (i != last) { workers_.erase(i); } return true; } if (content.match_elements<sys_atom, get_atom>()) { auto cpy = workers_; guard.unlock(); sender->enqueue(nullptr, mid.response_id(), make_message(std::move(cpy)), eu); return true; } if (workers_.empty()) { guard.unlock(); if (sender && mid.valid()) { // tell client we have ignored this sync message by sending // and empty message back sender->enqueue(nullptr, mid.response_id(), message{}, eu); } return true; } return false; }
void actor_pool::quit(execution_unit* host) { // we can safely run our cleanup code here without holding // workers_mtx_ because abstract_actor has its own lock if (cleanup(planned_reason_, host)) is_registered(false); }
void TestsuiteClient<synckeytype>::change_state(unsigned long r) { bool change_registered = r & 1; r >>= 1; synceventset_t toggle_events = r & 15; r >>= 4; if (change_registered) { if (mRequestedRegistered && !mRequestedReady) { mRequestedRegistered = false; this->unregister_client(); } } else if (toggle_events) { mRequestedReady ^= toggle_events; mRequestedRegistered = true; this->ready(toggle_events, mRequestedReady & toggle_events); } llassert(mRequestedRegistered == is_registered()); AISyncServer* server = this->server(); if (mRequestedRegistered) { synceventset_t all_ready = synceventset_t(-1); synceventset_t any_ready = 0; int nr = 0; for (int cl = 0; cl < number_of_clients_per_syncgroup; ++cl) { switch ((synckeytype & 0xff)) { case syncgroup_test1: { if (client1ap[cl].server() == server) { if (client1ap[cl].getRequestedRegistered()) { ++nr; all_ready &= client1ap[cl].getRequestedReady(); any_ready |= client1ap[cl].getRequestedReady(); } } if (client1bp[cl].server() == server) { if (client1bp[cl].getRequestedRegistered()) { ++nr; all_ready &= client1bp[cl].getRequestedReady(); any_ready |= client1bp[cl].getRequestedReady(); } } break; } case syncgroup_test2: { if (client2ap[cl].server() == server) { if (client2ap[cl].getRequestedRegistered()) { ++nr; all_ready &= client2ap[cl].getRequestedReady(); any_ready |= client2ap[cl].getRequestedReady(); } } if (client2bp[cl].server() == server) { if (client2bp[cl].getRequestedRegistered()) { ++nr; all_ready &= client2bp[cl].getRequestedReady(); any_ready |= client2bp[cl].getRequestedReady(); } } break; } } } llassert(nr == server->getClients().size()); llassert(!!(all_ready & 1) == mActualReady1); llassert(this->server()->events_with_all_clients_ready() == all_ready); llassert(this->server()->events_with_at_least_one_client_ready() == any_ready); llassert(nr == 0 || (any_ready & all_ready) == all_ready); } llassert(mRequestedReady == this->mReadyEvents); }
~TestsuiteClient() { if (is_registered()) this->ready(mRequestedReady, (synceventset_t)0); }
actor_pool::actor_pool() : planned_reason_(caf::exit_reason::not_exited) { is_registered(true); }
void actor_pool::quit() { // we can safely run our cleanup code here without holding // workers_mtx_ because abstract_actor has its own lock cleanup(planned_reason_); is_registered(false); }
/* * register SAM/QFS on the host being called with CNS. * The key value string must contain: * sun_login * sun_password (passed as arg cl_pwd) * name * email * asset_prefix = "sam-qfs" * * The key value string may contain: * prxy_enabled * prxy_port * prxy_host * prxy_auth * prxy_user * prxy_passwd(passed as arg proxy_pwd) * * The cl_pwd byte array must contain the client password for * the sun account encrypted with the public key returned from * cns_get_public_key. * * If proxy_auth is set to true, the proxy_pwd must be * the encrypted proxy password, using the same key as above. */ int cns_register( ctx_t *ctx, /* ARGSUSED */ char *kv_string, crypt_str_t *cl_pwd, crypt_str_t *proxy_pwd, char *clnt_pub_key_hex) { char *cl_clear = NULL; unsigned char *secret = NULL; int secret_len; cl_reg_cfg_t cl; sf_prod_info_t *sf; char asset_dir[MAXPATHLEN]; int retval; Trace(TR_MISC, "csn registration entry"); /* check the mandatory parameters */ if (ISNULL(kv_string, cl_pwd, clnt_pub_key_hex)) { Trace(TR_ERR, "cns registration failed %d %s", samerrno, samerrmsg); return (-1); } memset(&cl, 0, sizeof (cl_reg_cfg_t)); if (cl_pwd->str == NULL) { samerrno = SE_NULL_PARAMETER; snprintf(samerrmsg, MAX_MSG_LEN, GetCustMsg(samerrno), "password"); Trace(TR_ERR, "cns registration failed %d %s", samerrno, samerrmsg); goto err; } if (parse_kv(kv_string, cl_reg_cfg_tokens, &cl) != 0) { Trace(TR_ERR, "cns registration failed %d %s", samerrno, samerrmsg); goto err; } /* * If there was a client registration id free it. Or it will leak. * Note that reregistration is allowed in order to change the keys * that are used for signing the telemetry data. */ if (cl.reg_id) { free(cl.reg_id); cl.reg_id = NULL; } /* Complete the last phase of key agreement */ secret_len = get_secret(clnt_pub_key_hex, &secret); if (secret_len <= 0) { set_registration_error(-1); Trace(TR_ERR, "cns registration failed:getsecret"); goto err; } /* get the password clear text */ if (decrypt_string(&cl_clear, secret, cl_pwd->str, cl_pwd->str_len) != 0) { set_registration_error(-1); Trace(TR_ERR, "cns reg failed:bad clear cl pass"); goto err; } /* add the proxy password to the cl struct */ if (proxy_pwd != NULL) { /* * proxy password should be populated if it is * present even if proxy authentication is not enabled. * This behavior is really more forward looking for * when telemetry is enabled. */ if (decrypt_string(&(cl.prxy.passwd), secret, proxy_pwd->str, proxy_pwd->str_len) != 0) { set_registration_error(-1); Trace(TR_ERR, "cns reg failed:bad clear prxy pass"); goto err; } } /* check the rest of the parameters */ if (check_cl_reg_cfg(&cl, B_TRUE) != 0) { setsamerr(SE_INVALID_REG_PARAMS); Trace(TR_ERR, "cns registration failed %d %s", samerrno, samerrmsg); goto err; } /* create the data directory for this asset */ if (cl.asset_prefix == NULL) { set_registration_error(-1); Trace(TR_ERR, "cns registration failed: %d %s", samerrno, samerrmsg); goto err; } snprintf(asset_dir, sizeof (upath_t), CNS_ASSETDIR_SPEC, cl.asset_prefix); if (create_dir(ctx, asset_dir) != 0) { Trace(TR_ERR, "cns registration failed: %d %s", samerrno, samerrmsg); goto err; } /* * generate the public and private keys for this client-asset pair */ if ((retval = regstr_generate_public_private_key(cl.asset_prefix)) != 0) { set_registration_error(retval); Trace(TR_ERR, "cns registration failed: %d %s", samerrno, samerrmsg); goto err; } strlcat(asset_dir, CNS_CLIENT_CONF, sizeof (upath_t)); if (get_samfs_type(ctx) == SAMQFS) { sf = &samqfs_swordfish_data; } else { sf = &qfs_swordfish_data; } /* * This could save the client data now so that it can be * fetched even if the registration fails. The user would still * need to enter the appropriate passwords but nothing else would * be required. The reason it is done later is that the reg_id needs * to be saved and is not yet available. */ if ((retval = regstr_postclient_regis_data(&cl, (char *)cl_clear)) != 0) { set_registration_error(retval); Trace(TR_ERR, "cns registration failed: %d %s", samerrno, samerrmsg); goto err; } /* * Only post the product registration once. The reason to * post the client registration more than once is that is how * the key pair gets changed */ if (!is_registered(&cl)) { char *addn_info; /* * If we can get additional version information about the * packages include it but ignore errors. */ if (get_associated_package_info(&addn_info) == 0) { sf->additional_info = addn_info; } if ((retval = regstr_postproduct_regis_data(sf, &cl)) != 0) { set_registration_error(retval); Trace(TR_ERR, "cns registration failed: %d %s", samerrno, samerrmsg); goto err; } cl.registered = B_TRUE; if (sf->additional_info) { free(sf->additional_info); sf->additional_info = NULL; } } if (save_client_conf(asset_dir, &cl) != 0) { Trace(TR_ERR, "cns registration failed: %d %s", samerrno, samerrmsg); goto err; } free_sensitive_buf((char **)&secret, secret_len); free_sensitive_buf(&(cl_clear), strlen(cl_clear)); if (cl.prxy.passwd) { free_sensitive_buf(&(cl.prxy.passwd), strlen(cl.prxy.passwd)); } free_cl_reg_cfg_fields(&cl); Trace(TR_MISC, "cns registration succeeded"); return (0); err: if (sf->additional_info) { free(sf->additional_info); sf->additional_info = NULL; } free_sensitive_buf((char **)&secret, secret_len); free_sensitive_buf(&(cl_clear), strlen(cl_clear)); if (cl.prxy.passwd) { free_sensitive_buf(&(cl.prxy.passwd), strlen(cl.prxy.passwd)); } free_cl_reg_cfg_fields(&cl); return (-1); }
static int inline is_our_af (int fd) { return is_registered (&v4v_afs, fd); }
std::set<port_index_type> switch_::get_targets_for(port_index_type index, boost::asio::const_buffer data) { const port_list_type::iterator source_port_entry = m_ports.find(index); if (source_port_entry != m_ports.end()) { switch (m_configuration.routing_method) { case switch_configuration::RM_HUB: { return get_targets_for(source_port_entry); } case switch_configuration::RM_SWITCH: { asiotap::osi::const_helper<asiotap::osi::ethernet_frame> ethernet_helper(data); const ethernet_address_type target_address = to_ethernet_address(ethernet_helper.target()); if (is_multicast_address(target_address)) { return get_targets_for(source_port_entry); } else { m_ethernet_address_map[to_ethernet_address(ethernet_helper.sender())] = index; // We exceeded the maximum count for entries: we delete random entries to fix it. while (m_ethernet_address_map.size() > m_max_entries) { ethernet_address_map_type::iterator entry = m_ethernet_address_map.begin(); #if BOOST_VERSION >= 104700 boost::random::mt19937 gen; std::advance(entry, boost::random::uniform_int_distribution<>(0, static_cast<int>(m_ethernet_address_map.size()) - 1)(gen)); #else boost::mt19937 gen; boost::variate_generator<boost::mt19937&, boost::uniform_int<> > vgen(gen, boost::uniform_int<>(0, m_ethernet_address_map.size() - 1)); std::advance(entry, vgen()); #endif m_ethernet_address_map.erase(entry); } // We look in the ethernet address map const ethernet_address_map_type::iterator target_entry = m_ethernet_address_map.find(target_address); if (target_entry == m_ethernet_address_map.end()) { // No target entry: we send the message to everybody. return get_targets_for(source_port_entry); } const port_index_type target_port_index = target_entry->second; if (!is_registered(target_port_index)) { // The port does not exist: we delete the entry and send to everybody. m_ethernet_address_map.erase(target_entry); return get_targets_for(source_port_entry); } std::set<port_index_type> targets; targets.insert(target_port_index); return targets; } } } } return std::set<port_index_type>(); }