Beispiel #1
0
Type *
TypeCheck::visit(MemberSelect *ast)
{
	FUNCLOG;
	Type *member = NULL;
	Type *t = ast->receiver->accept(this);
	if (t->actual()->is(Type::CLASS_T)) {
		ClassType *receiver = t->actual()->as<ClassType>();

		member = receiver->findMember(Symbol::symbol(ast->member->toSource()));
		//member = ast->member->accept(this);
		if (member == NULL) {
			SEMANTIC_ERROR(SE_ERROR);
		}
		DBG("member %s", member->toString().c_str());

	} else {
		assert(0);
		//TODO
	}
	
	if (member->is(Type::FIELD_T)) {
		return member->actual();
	} else {
		return member;
	}
}
Beispiel #2
0
void Stream::WriteObject(const void* object)
{
	if (object == NULL)
	{
		uint32 id = 0;
		Write(&id, 4);
		return;
	}

	map<const void*, uint32>::iterator it = m_objectmapSave.find(object);

	PerObject* perobject = GetPerObject(object);

	if (it != m_objectmapSave.end())
	{
		uint32 id = (*it).second;
		Write(&id, 4);
	}
	else
	{
		ClassType* pType = System::GetType(object);

		uint32 id = ++m_id;
		Write(&id, 4);

		m_objectmapSave.insert(map<const void*, uint32>::value_type(object, id));

		char classname[256] = {0};
		std::memcpy(classname, pType->get_QName().GetData8(), pType->get_QName().GetLength());
		Write(classname, 256);

		WriteClass((uint8*)object, pType);
	}
}
Beispiel #3
0
void* Stream::ReadObject()
{
	uint32 id;
	Read(&id, 4);
	if (id == 0)
	{
		return NULL;
	}

	map<uint32, void*>::iterator it = m_objectmapLoad.find(id);

	if (it != m_objectmapLoad.end())
	{
		return (*it).second;
	}
	else
	{
		// We don't call any constructors.. hmm.

		char classname[256] = {0};
		Read(classname, 256);

		ClassType* pType = (ClassType*)pD->LookupNamedType(classname);
		ASSERT(pType);

		uint8* object = new /*(pHeap)*/ uint8[pType->get_sizeof()];

		ReadClass(object, pType);

		return object;
	}

	return NULL;
}
Beispiel #4
0
void StrucViewItem::initState()
//-----------------------------
// if i represent a variable, i must find my type
// if the base type is a ClassType, then i am Collapsed
// else i am LeafNode
{
    bool        do_inherited = false;
    ClassType * classType;
    dr_sym_type stype = _info->symtype();

    REQUIRE( stype != DR_SYM_NOT_SYM,"strucview::initstate ack");

    if( !_initialized ) {
        if( _classNode != NULL ) {
            REQUIRE( stype == DR_SYM_CLASS,"strucview::initstate nak");
            classType = (ClassType *)_info;
            _type = _name;
        } else {
            classType = flattenTypeDesc( _info, _type );
            _name = _info->name();
        }

        if( classType ) {
            WVList kidInfos;
            FilterFlags flags = _parent->getFilter();
            if( ( flags & FILT_INHERITED ) || ( flags & FILT_ALL_INHERITED )) {
                do_inherited = true;
                FILT_RESET_INHERITED( flags );
            }

            classType->dataMembers( kidInfos, flags );
            if( kidInfos.count() != 0 ) {
                _expandState = Collapsed;
                _parent->addSeen( this );
                for( int i = 0; i < kidInfos.count(); i++ ) {
                    _kids.add( new StrucViewItem( _parent, ((Symbol *)kidInfos[i]),
                                                  _indentLevel + 1 ) );
                }
            } else {
                _expandState = LeafNode;
            }
            if( classType != _info ) {
                delete classType;
            }

            if( do_inherited ) {
                startInherited();
            }
        } else {
            _expandState = LeafNode;
        }
        _initialized = true;
    }
}
Beispiel #5
0
Type *
TypeCheck::visit(ClassSpecifier *ast)
{
	FUNCLOG;
	Symbol *name;
	if (ast->name->isTemplateId()) {
		//TODO:
		assert(0);
	} else {
		name =  ast->name->name;
	}

	ClassType *classType = new ClassType(name, ast->typeSpecId == CLASS);
	if (!SymbolTable.addType(classType, name)) {
		//duplicated class specifier
		SEMANTIC_ERROR(SE_DUPLICATE_TYPE);
	}

	ast->name->accept(this);
	if (ast->base) {
		//TODO:
		ast->base->accept(this);
	}

	if (ast->members) {
		SymbolTable.enterScope(SymbolTable::CLASS, name);

		Type *tl = ast->members->accept(this);
		assert(tl->is(Type::TYPELIST_T));
		TypeList *tlist = tl->as<TypeList>();
		List<Type*>::iterator it = tlist->list.begin();
		while (it != tlist->list.end()) {
			Type *t = *it;
			if (t->is(Type::METHOD_T)) {
				DBG("add method %s to %s", t->toString().c_str(), name->toString().c_str());
				classType->addMethod(t->as<MethodType>());
			} else if (t->is(Type::FIELD_T)) {
				DBG("add field %s to %s", t->toString().c_str(), name->toString().c_str());
				classType->addField(t->as<FieldType>());
			}
			++it;
		}

		SymbolTable.leaveScope();
	}

	return classType;
}
Beispiel #6
0
TEST_F(SymbolTest, testClassSymbol) {
  DataType* data_type = class_->getDataType();
  ASSERT_NE(nullptr, data_type);
  ASSERT_EQ(DataType::DATA_TYPE_CLASS, data_type->getType());
  ClassType* type = dynamic_cast<ClassType*>(data_type);
  ASSERT_NE(nullptr, type);
  EXPECT_EQ(class_.get(), type->getClassSymbol());

  VariableSymbol* v1 = new VariableSymbol("v1");
  v1->setDataType(DataTypeFactory::getInt32Type());
  class_->addVariable(v1);

  VariableSymbol* v2 = new VariableSymbol("v2");
  v2->setDataType(DataTypeFactory::getStringType());
  class_->addVariable(v2);
  const auto& actual_vars = class_->getVariables();
  std::vector<VariableSymbol*> expected_vars {v1, v2};
  EXPECT_EQ(expected_vars, actual_vars);

  FunctionSymbol* f = new FunctionSymbol("f");
  f->setReturnType(DataTypeFactory::getCharType());
  class_->addFunction(f);
  const auto& actual_funcs = class_->getFunctions();
  std::vector<FunctionSymbol*> expected_funcs {f};
  EXPECT_EQ(expected_funcs, actual_funcs);

  Scope* scope = class_->getScope();
  ASSERT_NE(nullptr, scope);
  EXPECT_FALSE(scope->isOwnedBySymbolTable());
  EXPECT_EQ(class_->getName(), scope->getName());

  EXPECT_EQ(4, scope->getSize());
  EXPECT_EQ(v1, scope->lookup(v1->getName()));
  EXPECT_EQ(v2, scope->lookup(v2->getName()));
  EXPECT_EQ(f, scope->lookup(f->getName()));
  EXPECT_EQ(class_.get(), scope->lookup(class_->getName()));

  ClassSymbol super_class("super");
  class_->setSuperClass(&super_class);
  EXPECT_EQ(super_class.getScope(), scope->getParent());
  EXPECT_EQ(&super_class, scope->lookup(super_class.getName()));
}
Beispiel #7
0
void DTViewClass::load()
//----------------------
{
    WVList          dataMembers;
    WVList          methods;
    WVList          friends;
    int             i;
    WString         str;
    ClassType *     cls = (ClassType *) _symbol;
    Symbol *        s;

    _members->clearAndDestroy();

    cls->dataMembers( dataMembers );
    cls->memberFunctions( methods );
    cls->friendFunctions( friends );

    for( i = 0; i < friends.count(); i += 1 ) {
        s = (Symbol *) friends[ i ];
        str.printf( "    friend %s;", s->scopedName( FALSE ) );
        _members->insert( new ClassMember( s, str.gets() ) );
    }

    for( i = 0; i < dataMembers.count(); i += 1 ) {
        s = (Symbol *) dataMembers[ i ];

        str.printf( "    %s;", s->scopedName( FALSE ) );
        _members->insert( new ClassMember( s, str.gets() ) );
    }

    for( i = 0; i < methods.count(); i += 1 ) {
        s = (Symbol *) methods[ i ];

        str.printf( "    %s;", s->scopedName( FALSE ) );
        _members->insert( new ClassMember( s, str.gets() ) );
    }

    addDescriptions();
    fillBox();
}
Beispiel #8
0
// метод характеризует класс 'base' по отношению к 'derived'
void DerivationManager::Characterize( const ClassType &base, 
							const ClassType &curCls, bool ac )
{
	register const BaseClassList &bcl = curCls.GetBaseClassList();
	for( int i = 0; i<bcl.GetBaseClassCount(); i++ )
	{
		const BaseClassCharacteristic &clh = *bcl.GetBaseClassCharacteristic(i);
		const ClassType &bcls = clh.GetPointerToClass();

		// ac учитываем доступность как предыдущих классов так и текущих
		ac = ac && clh.GetAccessSpecifier() == ClassMember::AS_PUBLIC;

		// если полученный класс является 'base', выполним операции и
		// выйдем из цикла, т.к. класс не может наследовать сам себя
		if( &base == &bcls )
		{
			baseCount++;

			// если первый класс, проверяем его на виртуальность и на доступность
			if( baseCount == 1 )
			{
				virtualDerivation = clh.IsVirtualDerivation();
				accessible = ac;
			}

			else
			{
				virtualDerivation = virtualDerivation && clh.IsVirtualDerivation();

				// из нескольких базовых классов можно выбрать самый доступный,
				// если он виртуален
				accessible = accessible || ac;
			}				   			
		}


		// иначе вызываем рекурсию двигаясь вверх по иерархии
		else
			Characterize( base, bcls, ac );
	}		
}
Beispiel #9
0
RefPtr<DebugSymbol>
lookup_child(DebugSymbol& obj, const char* name, SymSet& symset)
{
    if (!symset.insert(make_pair(obj.name(), obj.addr())).second)
    {
        return NULL;
    }
    InfiniteRecursivityGuard guard(symset, &obj);

    if (!obj.value())
    {
        obj.read(NULL);
    }

    DebugSymbolList objects;
    ClassType* klass = interface_cast<ClassType*>(obj.type());

    const size_t count = obj.enum_children(NULL);

    for (size_t n = 0; n != count; ++n)
    {
        RefPtr<DebugSymbol> child = obj.nth_child(n);

        if (!child->name())
        {
            continue;
        }
        if (child->name()->is_equal(name))
        {
            return child;
        }

        // build a list of anonymous members and base classes
        // to recurse into
        if (klass)
        {
            if (child->name()->is_equal2(unnamed_type()))
            {
                assert (interface_cast<ClassType*>(child->type()));
                objects.push_back(child);
            }
            else if (child->type()
                  && klass->lookup_base(child->type()->name(), NULL, true))
            {
                objects.push_back(child);
            }
        }
        else if (interface_cast<ClassType*>(child->type()))
        {
            objects.push_back(child);
        }
    }
    // now dive into base classes
    for (DebugSymbolList::const_iterator i = objects.begin();
         i != objects.end();
         ++i)
    {
        if (RefPtr<DebugSymbol> child = lookup_child(**i, name, symset))
        {
            return child;
        }
    }
    return NULL;
}
Beispiel #10
0
// virtual
void Properties::PropertyListener::handleEvent(System::Event* evt)
{
#if WIN32
	if (evt->get_eventPhase() != System::CAPTURING_PHASE)
	{
		if (*evt->get_type() == L"contextmenu")
		{
			evt->stopPropagation();
			UI::MouseEvent* mouseEvt = static_cast<UI::MouseEvent*>(evt);

			UI::CLXUIMenuElement* menu = new UI::CLXUIMenuElement();
		//	menu->SetRParent(m_ctledit);
			menu->SetOwnerWindow(mouseEvt->GetOwnerWindow());

			menu->addEventListener(WSTR("command"), this, false);

			if (false)
			{
				menu->AddItem(new UI::TextString(WSTR("Display As Table")), 100);
			}
			else
			{
				Type* pType = m_pProperty->get_method->m_decl->m_pType->GetFunction()->m_pReturnType;

				if (pType->get_Kind() == type_pointer && pType->GetPointerTo()->get_Kind() == type_class)
				{
					vector<ClassType*> list;
					GetDerived(pType->GetPointerTo()->GetClass(), list);

					for (int i = 0; i < list.GetSize(); i++)
					{
						ClassType* pDerived = list[i];
						if (pDerived->m_derived.GetSize() == 0)
						{
							menu->AddItem(new UI::TextString(pDerived->get_Name()->ToStringW()), (long)pDerived);
						}
					}
				}
			}

			menu->GetMenuPopup()->Popup(menu, LDraw::PointI(mouseEvt->get_ScreenX(), mouseEvt->get_ScreenY()));
		}
		else if (*evt->get_type() == L"command")
		{
			if (false)
			{
				m_bDisplayAsTable = !m_bDisplayAsTable;
			}
			else
			{
				evt->stopPropagation();
				UI::CommandInvokeEvent* cmdEvt = dynamic_cast<UI::CommandInvokeEvent*>(evt);

				long param = cmdEvt->get_Command();
				ClassType* pDerivedType = (ClassType*)param;

				void* p = newobj(pDerivedType);
				if (p)
				{
					Type* pType = m_pProperty->set_method->m_decl->m_pType->GetFunction()->m_parameters.m_parameters[0].m_pType;
					pType = pType->GetStripped();
					void* value = DynamicCast(p, pDerivedType, pType->GetPointerTo()->GetClass());

					ASSERT(0);
					void *_this = NULL;//__RTDynamicCast(m_itemVisual, 0, (void*)&typeid(m_itemVisual), (void*)m_pProperty->set_method->GetTypeInfo(), 0);

				//	StringA str_type = pType->ToString();

					ULONG_PTR func;
					if (m_pProperty->set_method->m_decl->m_offset != -1)
					{
						void* vtable = *(void**)_this;
						func = *(ULONG_PTR*)((uint8*)vtable + m_pProperty->set_method->m_decl->m_offset);
					}
					else
					{
						func = m_pProperty->set_method->m_func;
					}

					__asm
					{
						push ecx
						mov ecx,_this
						push value
						call func
						pop ecx
					}
				}
			}
		}

#if 0
		void *_this = __RTDynamicCast(m_itemVisual, 0, (void*)&typeid(m_itemVisual), (void*)put_type_info(), 0);

		cpp::Type* pType = put_decl->m_pType->m_pFunction->m_parameters[0]->m_pType;
		StringA str_type = pType->toString();
		pType = pType->GetType();

		DWORD func;
		if (put_decl->m_offset != -1)
		{
			void* vtable = *(void**)_this;
			func = *(DWORD*)((uint8*)vtable + put_decl->m_offset);
		}
		else
		{
			func = put_func;
		}

		if (*evt->get_type() == L"contextmenu")
		{
			evt->stopPropagation();
			UI::MouseEvent* mouseEvt = dynamic_cast<MouseEvent*>(evt);

			if (pType->m_type == cpp::type_pointer && pType->m_pPointerTo->m_type == cpp::type_class)
			{
				CLXUIMenuElement* menu = new CLXUIMenuElement();
				menu->SetRParent(m_ctledit);
				menu->SetOwnerWindow(m_ctledit->get_OwnerWindow());
				
				std::map<StringA, cpp::Type*>::iterator it = pD->m_namedTypes.begin();
				while (it != pD->m_namedTypes.end())
				{
					cpp::Type* pType2 = (*it).second;
					ASSERT(pType2);
					it++;

					if (pType2->m_type == cpp::type_class)
					{
						if (pType2->m_pClass->IsOfType(pType->m_pPointerTo->m_pClass))
						{
						//	pType2->m_pClass->IsOfType(pType->m_pPointerTo->m_pClass);
							menu->AddItem(new TextString(ConvertA2S(pType2->m_pClass->m_name)), (long)pType2);
						}
					}
				}

				menu->GetMenuPopup()->Popup(menu, LDraw::PointI(mouseEvt->get_ScreenX(), mouseEvt->get_ScreenY()));
			}
		}
		else if (*evt->get_type() == L"command")
		{
			evt->stopPropagation();
			CommandInvokeEvent* cmdEvt = dynamic_cast<CommandInvokeEvent*>(evt);

			long param = cmdEvt->get_Command();

			if (pType->m_type == cpp::type_enum)
			{
				__asm
				{
					push ecx
					mov ecx,_this
					push param
					call func
					pop ecx
				}
			}
			else
			{
				cpp::Type* pType2 = (cpp::Type*)param;

				void* object = newobj(pType2->m_pClass);
				Type_Info* src = (Type_Info*)pD->LookupSymbol(DecorateName(pType2->m_pClass->m_name));
				Type_Info* dst = (Type_Info*)pD->LookupSymbol(DecorateName(pType->m_pPointerTo->m_pClass->m_name));

				void* param = __RTDynamicCast(object, 0, src, dst, 0);

				__asm
				{
					push ecx
					mov ecx,_this
					push param
					call func
					pop ecx
				}
			}
		}
		else if (*evt->get_type() == L"ValueChange")
Beispiel #11
0
#include <catch/catch.hpp>

#include "BlueprintReflection/Type/ClassType.hpp"

TEST_CASE("TestClassType")
{
    using namespace blueprint::reflection;

    ClassType classType;

    SECTION("Default State")
    {
        CHECK(classType.GetBaseClasses().empty());
        CHECK(classType.GetNestedTypes().empty());
        CHECK(classType.GetMethods().empty());
        CHECK(classType.GetFields().empty());
    }

    SECTION("Base Classes")
    {
        ClassType parentA;

        classType.AddBaseClass(&parentA);
        REQUIRE(classType.GetBaseClasses().size() == 1);
        CHECK(classType.GetBaseClasses()[0] == &parentA);

        ClassType parentB;

        classType.AddBaseClass(&parentB);
        REQUIRE(classType.GetBaseClasses().size() == 2);
        CHECK(classType.GetBaseClasses()[1] == &parentB);
Beispiel #12
0
void OSSSIP::initTransportFromConfig(const boost::filesystem::path& cfgFile)
{
  ClassType config;
  config.load(OSS::boost_path(cfgFile));
  DataType root = config.self();
  DataType listeners = root["listeners"];
  

  DataType interfaces = listeners["interfaces"];
  int ifaceCount = interfaces.getElementCount();
  bool hasFoundDefault = false;
  for (int i = 0; i < ifaceCount; i++)
  {
    DataType iface = interfaces[i];
    std::string ip = iface["ip-address"];
    std::string external;
    if (iface.exists("external-address"))
    {
      external = (const char*)iface["external-address"];
    }

    bool tlsEnabled = iface.exists("tls-enabled") && (bool)iface["tls-enabled"];
    bool tcpEnabled = iface.exists("tcp-enabled") && (bool)iface["tcp-enabled"];
    bool wsEnabled = iface.exists("ws-enabled") && (bool)iface["ws-enabled"];
    
    bool udpEnabled = true;
    if (iface.exists("udp-enabled"))
      udpEnabled = (bool)iface["udp-enabled"];

    int sipPort = iface.exists("sip-port") ?  (int)iface["sip-port"] : 5060;
    int tlsPort = iface.exists("tls-port") ?  (int)iface["tls-port"] : 5061;

    if (!hasFoundDefault)
    {
      if (iface.exists("default"))
      {
        hasFoundDefault = ((bool)iface["default"]);
        bool transportEnabled = udpEnabled || tcpEnabled || wsEnabled || tlsEnabled;

        if (hasFoundDefault  && transportEnabled)
        {
          OSS::IPAddress listener;
          listener = ip;
          listener.externalAddress() = external;
          listener.setPort(sipPort);
          _fsmDispatch.transport().defaultListenerAddress() = listener;
        }
      }
    }

    if (udpEnabled)
    {
      OSS::IPAddress listener;
      listener = ip;
      listener.externalAddress() = external;
      listener.setPort(sipPort);
      _udpListeners.push_back(listener);
    }

    if (tcpEnabled)
    {
      OSS::IPAddress listener;
      listener = ip;
      listener.externalAddress() = external;
      listener.setPort(sipPort);
      _tcpListeners.push_back(listener);
    }

    if (wsEnabled)
    {
      OSS::IPAddress listener;
      listener = ip;
      listener.externalAddress() = external;
      listener.setPort(sipPort);
      _wsListeners.push_back(listener);
    }

    if (tlsEnabled)
    {
      OSS::IPAddress listener;
      listener = ip;
      listener.externalAddress() = external;
      listener.setPort(tlsPort);
      _tlsListeners.push_back(listener);
    }
  }

  if (!hasFoundDefault)
  {
    //
    // Set the default interface for the transport service the old fashioned way
    //
    if (listeners.exists("default-interface-address") &&
      listeners.exists("default-interface-port"))
    {
      hasFoundDefault = true;
      DataType defaultIface = listeners["default-interface-address"];
      DataType defaultPort = listeners["default-interface-port"];
      OSS::IPAddress defaultInterface((const char*)defaultIface);
      defaultInterface.setPort((int)defaultPort);
      _fsmDispatch.transport().defaultListenerAddress() = defaultInterface;
    }
  }

  if (!hasFoundDefault && ifaceCount > 0)
  {
    //
    // We don't have the defualt interface yet.  Lets use the first configured listener
    //
    DataType iface = interfaces[0];
    std::string ip = iface["ip-address"];
    if (iface.exists("udp-enabled") && (bool)iface["udp-enabled"])
    {
      int port = iface.exists("sip-port") ? (int)iface["sip-port"] : 5060;
      OSS::IPAddress listener;
      listener = ip;
      listener.setPort(port);
      _fsmDispatch.transport().defaultListenerAddress() = listener;
    }
    else if (iface.exists("tcp-enabled") && (bool)iface["tcp-enabled"])
    {
      int port = iface.exists("sip-port") ? (int)iface["sip-port"] : 5060;
      OSS::IPAddress listener;
      listener = ip;
      listener.setPort(port);
      _fsmDispatch.transport().defaultListenerAddress() = listener;
    }
    else if (iface.exists("ws-enabled") && (bool)iface["ws-enabled"])
    {
      int port = iface.exists("sip-port") ? (int)iface["sip-port"] : 5060;
      OSS::IPAddress listener;
      listener = ip;
      listener.setPort(port);
      _fsmDispatch.transport().defaultListenerAddress() = listener;
    }
    else if (iface.exists("tls-enabled") && (bool)iface["tls-enabled"])
    {
      int port = iface.exists("tls-port") ? (int)iface["tsl-port"] : 5061;
      OSS::IPAddress listener;
      listener = ip;
      listener.setPort(port);
      _fsmDispatch.transport().defaultListenerAddress() = listener;
    }
  }

  //
  // Set the TCP port range
  //
  if (listeners.exists("sip-tcp-port-base") && listeners.exists("sip-tcp-port-max"))
  {
    unsigned int tcpPortBase = listeners["sip-tcp-port-base"];
    unsigned int tcpPortMax = listeners["sip-tcp-port-max"];
    if (tcpPortBase < tcpPortMax && tcpPortBase > 0)
    {
      OSS_LOG_INFO("Setting TCP port range to " << tcpPortBase << "-" << tcpPortMax);
      transport().setTCPPortRange((unsigned short)tcpPortBase, (unsigned short)tcpPortMax);
    }
    else
    {
      OSS_LOG_ERROR("Unable to set TCP port base " << tcpPortBase << "-" << tcpPortMax << " Using default values.");
    }
  }

  //
  // Set the TCP port range
  //
  if (listeners.exists("sip-ws-port-base") && listeners.exists("sip-ws-port-max"))
  {
    unsigned int wsPortBase = listeners["sip-ws-port-base"];
    unsigned int wsPortMax = listeners["sip-ws-port-max"];
    if (wsPortBase < wsPortMax && wsPortBase > 0)
    {
      OSS_LOG_INFO("Setting WebSocket port range to " << wsPortBase << "-" << wsPortMax);
      transport().setWSPortRange((unsigned short)wsPortBase, (unsigned short)wsPortMax);
    }
    else
    {
      OSS_LOG_ERROR("Unable to set WebSocket port base " << wsPortBase << "-" << wsPortMax << " Using default values.");
    }
  }


  if (listeners.exists("packet-rate-ratio"))
  {
    std::string packetRateRatio = (const char*)listeners["packet-rate-ratio"];
    std::vector<std::string> tokens = OSS::string_tokenize(packetRateRatio, "/");
    if (tokens.size() == 3)
    {
      unsigned long packetsPerSecondThreshold;
      unsigned long thresholdViolationRate;
      int banLifeTime;
      thresholdViolationRate = OSS::string_to_number<unsigned long>(tokens[0].c_str());
      packetsPerSecondThreshold = OSS::string_to_number<unsigned long>(tokens[1].c_str());
      banLifeTime = OSS::string_to_number<int>(tokens[2].c_str());

      if (packetsPerSecondThreshold > thresholdViolationRate)
      {
        SIPTransportSession::rateLimit().enabled() = true;
        SIPTransportSession::rateLimit().autoBanThresholdViolators() = true;
        SIPTransportSession::rateLimit().setPacketsPerSecondThreshold(packetsPerSecondThreshold);
        SIPTransportSession::rateLimit().setThresholdViolationRate(thresholdViolationRate);
        SIPTransportSession::rateLimit().setBanLifeTime(banLifeTime);
        OSS_LOG_INFO("Enforcing packet rate limit = " << packetRateRatio);
      }

      if (listeners.exists("packet-rate-white-list"))
      {
        DataType whiteList = listeners["packet-rate-white-list"];
        int count = whiteList.getElementCount();
        for (int i = 0; i < count; i++)
        {
          DataType wl = whiteList[i];
          std::string entry;
          if (wl.exists("source-ip"))
          {
            entry = (const char*)wl["source-ip"];
            if (!entry.empty())
            {
              boost::system::error_code ec;
              boost::asio::ip::address ip = boost::asio::ip::address::from_string(entry, ec);
              if (!ec)
                SIPTransportSession::rateLimit().whiteListAddress(ip);
            }
          }
          else if (wl.exists("source-network"))
          {
            entry = (const char*)wl["source-network"];
            if (!entry.empty())
            SIPTransportSession::rateLimit().whiteListNetwork(entry);
          }
        }
      }
    }
  }

  transportInit();
}
Beispiel #13
0
ClassType * StrucViewItem::flattenTypeDesc( Symbol * sym, WString & desc )
//------------------------------------------------------------------------
{
    ClassType *     classType = NULL;
    char *          str = NULL;
    WVList          typeParts;
    Description *   entry;
    int             i;

    REQUIRE( sym != NULL, "strucview::flatten passed null symbol!" );
    dr_sym_type stype = sym->symtype();
    REQUIRE( stype != DR_SYM_NOT_SYM,"strucview::flatten bad set");

    switch( stype ) {
    case DR_SYM_VARIABLE:
        // need to find out the type of the data member
        ((VariableSym *) sym)->loadTypeInfo( typeParts );
        for( i = 0; i < typeParts.count(); i++ ) {
            entry = (Description *) typeParts[i];
            if( entry->_nameGoesHere ) {
                desc.concat( entry->u.text );
            } else {
                if( !sym->isEqual( entry->u.sym ) ){
                    if( classType == NULL ) {
                        classType = flattenTypeDesc( entry->u.sym, desc );
                    } else {
                        desc.concat( entry->u.sym->name() );
                    }
                }
            }
        }
        break;

    case DR_SYM_TYPEDEF:
    case DR_SYM_ENUM:
        sym->description( typeParts );
        for( i = 0; i < typeParts.count(); i++ ) {
            entry = (Description *) typeParts[ i ];
            if( entry->_isUserDefined ) {
                if( entry->u.sym->symtype() == DR_SYM_CLASS && classType == NULL ) {
                    classType = (ClassType *) entry->u.sym;
                }
            }
        }
        desc.concat( sym->name() );
        break;

    case DR_SYM_CLASS:
        if( _parent->isSeen( sym ) ) {
            desc.concat( sym->name() );
            classType = NULL;
        } else {
            classType = (ClassType *) sym;
            desc.concat( classType->name() );
        }
        break;

    default: {}
    }

    for( i=0; i < typeParts.count(); i++ ) {
        entry = (Description *) typeParts[ i ];
        if( entry->_isUserDefined && entry->u.sym != classType &&
            entry->u.sym != sym ) {
            delete entry->u.sym;
        }
    }
    typeParts.deleteContents();

    return classType;
}