예제 #1
0
 void seed(Generator & gen)
 {
   uniform_01<Generator, FloatType> gen01(gen);
   // I could have used std::generate_n, but it takes "gen" by value
   for(unsigned int j = 0; j < long_lag; ++j)
     x[j] = gen01();
   i = long_lag;
 }
예제 #2
0
float UnsyncedRNG::RandFloat()
{
#ifdef USE_BOOST_RNG
	return gen01();
#else
	randSeed = (randSeed * 214013L + 2531011L);
	return float((randSeed >> 16) & RANDINT_MAX) / RANDINT_MAX;
#endif
}
void DiameterXMLConfigParser::Load(AAA_Task &task, char *cfgfile)
{
    DiameterDataRoot &root = *DIAMETER_CFG_ROOT();

    OD_Utl_XML_SaxParser parser;
    diameter_unsigned32_t m_unused;

    // Root marker
    OD_Utl_XML_UInt32Element marker01(m_unused, "configuration", parser);

    // General Section    
    OD_Utl_XML_StringElement gen01(root.general.product, 
                                   "product", parser);
    OD_Utl_XML_UInt32Element gen02(root.general.version, 
                                   "version", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlVendorIdConv>
                                  gen03(m_unused, "vendor_id", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlAcctAppIdConv> 
                                  gen04(m_unused, "acct_application_id", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlAuthAppIdConv> 
                                  gen05(m_unused, "auth_application_id", parser);
    DiameterXmlUInt32ListElement gen06(root.general.supportedVendorIdLst,
                                   "supported_vendor_id", parser);
    DiameterXmlVendorAppIdParser gen07(root.general.vendorSpecificId, parser);

    // Parser Section
    OD_Utl_XML_StringElement parser01(root.parser.dictionary, 
                                   "dictionary", parser);

    // Transport Section
    OD_Utl_XML_StringElement trans01(root.transport.identity, 
                                   "identity", parser);
    OD_Utl_XML_UInt32Element trans02(root.transport.tcp_listen_port,
                                   "tcp_listen_port", parser);
    OD_Utl_XML_UInt32Element trans03(root.transport.sctp_listen_port,
                                   "sctp_listen_port", parser);
    OD_Utl_XML_UInt32Element trans04(root.transport.use_ipv6,
                                   "use_ipv6", parser);
    OD_Utl_XML_UInt32Element trans05(root.transport.watchdog_timeout, 
                                   "watchdog_timeout", parser);
    OD_Utl_XML_UInt32Element trans06(root.transport.reconnect_interval, 
                                   "reconnect_interval", parser);
    OD_Utl_XML_UInt32Element trans07(root.transport.reconnect_max,
                                   "reconnect_max", parser);
    OD_Utl_XML_UInt32Element trans08(root.transport.retx_interval, 
                                   "request_retransmission_interval", parser);
    OD_Utl_XML_UInt32Element trans09(root.transport.retx_max_count, 
                                   "max_request_retransmission_count", parser);
    OD_Utl_XML_UInt32Element trans10(root.transport.rx_buffer_size, 
                                   "receive_buffer_size", parser);
    DiameterXmlStringListElement trans11(root.transport.advertised_hostname,
                                   "advertised_hostname", parser);

    // Peer table
    OD_Utl_XML_UInt32Element trans12((ACE_UINT32&)DIAMETER_PEER_TABLE()->ExpirationTime(), 
                                   "expiration_time", parser);
    DiameterXmlPeerEntryParser trans13(task, parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlHostnameConv> 
               trans14(m_unused, "hostname", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlUseSctpConv> 
               trans15(m_unused, "use_sctp", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlPortConv> 
               trans16(m_unused, "port", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlTlsEnabledConv> 
               trans17(m_unused, "tls_enabled", parser);

    // Route table
    ACE_UINT32 transp_01 = 0;
    OD_Utl_XML_UInt32Element trans18(transp_01, "expire_time", parser);
    DiameterXmlRouteParser trans19("route", parser);
    DiameterXmlRouteParser trans20("default_route", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlRoleConv> 
               trans21(m_unused, "role", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlRealmConv> 
               trans22(m_unused, "realm", parser);

    // Application table
    DiameterXmlRouteApplicationParser trans23(parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlRteApplicationIdConv> 
               trans24(m_unused, "application_id", parser);

   // Server entry
   DiameterXmlRouteServerEntryParser trans25(parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlRteServerConv> 
               trans26(m_unused, "server", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlRteServerMetricConv> 
               trans27(m_unused, "metric", parser);

    // Session management
    OD_Utl_XML_UInt32Element sess01(root.session.maxSessions,
                                   "max_sessions", parser);
    OD_Utl_XML_UInt32Element sess02(root.session.authSessions.stateful,
                                   "stateful", parser);
    OD_Utl_XML_UInt32Element sess03(root.session.authSessions.lifetimeTm,
                                   "lifetime_timeout", parser);
    OD_Utl_XML_UInt32Element sess04(root.session.authSessions.graceTm,
                                   "grace_period_timeout", parser);
    OD_Utl_XML_UInt32Element sess05(root.session.authSessions.abortRetryTm,
                                   "abort_retry_timeout", parser);
    OD_Utl_XML_UInt32Element sess06(root.session.acctSessions.recIntervalTm,
                                   "interim_interval", parser);
    OD_Utl_XML_UInt32Element sess07(root.session.acctSessions.realtime,
                                   "realtime", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  DiameterXmlSessionTimeoutConv> 
               sess08(m_unused, "session_timeout", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  
                          OD_Utl_XML_ContentConvNull<diameter_unsigned32_t> > 
               sess09(m_unused, "auth_sessions", parser);
    OD_Utl_XML_RegisteredElement<diameter_unsigned32_t,  
                          OD_Utl_XML_ContentConvNull<diameter_unsigned32_t> > 
               sess10(m_unused, "acct_sessions", parser);

    // logs
    std::string lgp01, lgp02, lgp03, lgp04, lgp05;
    OD_Utl_XML_StringElement log01(lgp01, "debug", parser);
    OD_Utl_XML_StringElement log02(lgp02, "trace", parser);
    OD_Utl_XML_StringElement log03(lgp03, "info", parser);
    OD_Utl_XML_StringElement log04(lgp04, "console", parser);
    OD_Utl_XML_StringElement log05(lgp05, "syslog", parser);

    try {    
        parser.Load(cfgfile);

        // post setup for routing
        DIAMETER_ROUTE_TABLE()->ExpireTime(transp_01);

        // post parsing setup for logs
        root.log.flags.reserved = 0;
        root.log.flags.debug = (lgp01 == std::string("enabled")) ? 1 : 0;
        root.log.flags.trace = (lgp02 == std::string("enabled")) ? 1 : 0;
        root.log.flags.info = (lgp03 == std::string("enabled")) ? 1 : 0;

        root.log.targets.reserved = 0;
        root.log.targets.console = (lgp04 == std::string("enabled")) ? 1 : 0;
        root.log.targets.syslog = (lgp05 == std::string("enabled")) ? 1 : 0;

        // post parsing setup for tx retries
        if (root.transport.retx_interval &&
            (root.transport.retx_interval > DIAMETER_ROUTER_MIN_RETX_INTERVAL)) {
             root.transport.retx_interval = DIAMETER_ROUTER_MIN_RETX_INTERVAL;
        }
        if (root.transport.retx_max_count &&
            (root.transport.retx_max_count > DIAMETER_ROUTER_MAX_RETX_COUNT)) {
             root.transport.retx_max_count = DIAMETER_ROUTER_MAX_RETX_COUNT;
        }

        // buffer size validation
        if (root.transport.rx_buffer_size < MSG_COLLECTOR_MAX_MSG_LENGTH) {
            root.transport.rx_buffer_size = MSG_COLLECTOR_MAX_MSG_LENGTH;
        }
        else if (root.transport.rx_buffer_size >
            (MSG_COLLECTOR_MAX_MSG_LENGTH * MSG_COLLECTOR_MAX_MSG_BLOCK)) {
            root.transport.rx_buffer_size = MSG_COLLECTOR_MAX_MSG_LENGTH * (MSG_COLLECTOR_MAX_MSG_BLOCK/2);
        }

        if (! root.session.authSessions.stateful) {
            root.session.authSessions.stateful = DIAMETER_SESSION_STATE_MAINTAINED;
        }
        else {
            root.session.authSessions.stateful = DIAMETER_SESSION_NO_STATE_MAINTAINED;
        }

        this->dump();
    }
    catch (OD_Utl_XML_SaxException &e) {
        e.Print();
        throw;
    }
    catch (...) {
        throw;
    }
}