示例#1
0
文件: querier.cpp 项目: Tilka/mcproxy
void querier::receive_record(const std::shared_ptr<proxy_msg>& msg)
{
    HC_LOG_TRACE("");

    if (msg->get_type() != proxy_msg::GROUP_RECORD_MSG) {
        HC_LOG_ERROR("wrong proxy message, it musst be be a GROUP_RECORD_MS");
        return;
    }

    auto gr = std::static_pointer_cast<group_record_msg>(msg);

    auto db_info_it = m_db.group_info.find(gr->get_gaddr());

    if (db_info_it == end(m_db.group_info)) {
        //add an empty neutral record  to membership database
        HC_LOG_DEBUG("gaddr not found");
        db_info_it = m_db.group_info.insert(gaddr_pair(gr->get_gaddr(), gaddr_info(m_db.querier_version_mode))).first;
    }

    //backwards compatibility coordination
    if (!is_newest_version(gr->get_grp_mem_proto()) && is_older_or_equal_version(gr->get_grp_mem_proto(), m_db.querier_version_mode) ) {
        db_info_it->second.compatibility_mode_variable = gr->get_grp_mem_proto();
        auto ohpt = std::make_shared<older_host_present_timer_msg>(m_if_index, db_info_it->first, m_timers_values.get_older_host_present_interval());
        db_info_it->second.older_host_present_timer = ohpt;
        m_timing->add_time(m_timers_values.get_older_host_present_interval(), m_msg_worker, ohpt);
    }

    //section 8.3.2. In the Presence of MLDv1 Multicast Address Listeners
    //MLDv2 BLOCK messages are ignored, as are source-lists in TO_EX()
    //messages (i.e., any TO_EX() message is treated as TO_EX( {} )).
    if (db_info_it->second.is_in_backward_compatibility_mode()) {
        if (gr->get_record_type() == CHANGE_TO_EXCLUDE_MODE) {
            gr->get_slist() = {};
        } else if (gr->get_record_type() == BLOCK_OLD_SOURCES){
            return;     
        }
    }

    switch (db_info_it->second.filter_mode) {
    case  INCLUDE_MODE:
        receive_record_in_include_mode(gr->get_record_type(), gr->get_gaddr(), gr->get_slist(), db_info_it->second);

        //if the new created group is not used delete it
        if (db_info_it->second.filter_mode == INCLUDE_MODE && db_info_it->second.include_requested_list.empty()) {
            m_db.group_info.erase(db_info_it);
        }

        break;
    case EXCLUDE_MODE:
        receive_record_in_exclude_mode(gr->get_record_type(), gr->get_gaddr(), gr->get_slist(), db_info_it->second);
        break;
    default :
        HC_LOG_ERROR("wrong filter mode: " << db_info_it->second.filter_mode);
        break;
    }

}
示例#2
0
int 
dimeRecord::getRecordType(const int group_code)
{
  static int first = 1;
  static int translation[1072];
  if (first) {
    first = 0;
    for (int i = 0; i < 1072; i++) {
      translation[i] = get_record_type(i);
    }
  }
  if (group_code < 0 || group_code >= 1072)
    return dimeBase::dimeStringRecordType;
  else return translation[group_code];
}
示例#3
0
Type const*
Elaborator::elaborate(Id_type const* t)
{
  Scope::Binding const* b = stack.lookup(t->symbol());
  if (!b) {
    std::stringstream ss;
    ss << "no matching declaration for '" << *t->symbol() << '\'';
    throw Lookup_error(locs.get(t), ss.str());
  }

  // Determine if the name is a type declaration.
  Decl* d = b->second;
  if (Record_decl* r = as<Record_decl>(d)) {
    return get_record_type(r);
  }
  else {
    std::stringstream ss;
    ss << '\'' << *t->symbol() << "' does not name a type";
    throw Lookup_error(locs.get(t), ss.str());
  }
}