Changeset 4333

Show
Ignore:
Timestamp:
09/04/08 18:19:46 (4 months ago)
Author:
andreas
Message:

time values in strongswan.conf can be optionally specified in days (d), hours (h), minutes (m), or seconds (s)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/charon/plugins/medcli/medcli_config.c

    r4276 r4333  
    355355     
    356356    this->db = db; 
    357     this->rekey = lib->settings->get_int(lib->settings, 
    358                                          "medcli.rekey", 20) * 60; 
    359     this->dpd = lib->settings->get_int(lib->settings, "medcli.dpd", 300); 
     357    this->rekey = lib->settings->get_time(lib->settings, "medcli.rekey", 1200); 
     358    this->dpd = lib->settings->get_time(lib->settings, "medcli.dpd", 300); 
    360359    this->ike = ike_cfg_create(FALSE, FALSE, "0.0.0.0", "0.0.0.0"); 
    361360    this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE)); 
  • trunk/src/charon/plugins/medsrv/medsrv_config.c

    r4276 r4333  
    136136     
    137137    this->db = db; 
    138     this->rekey = lib->settings->get_int(lib->settings, 
    139                                          "medsrv.rekey", 20) * 60; 
    140     this->dpd = lib->settings->get_int(lib->settings, "medsrv.dpd", 300); 
     138    this->rekey = lib->settings->get_time(lib->settings, "medsrv.rekey", 1200); 
     139    this->dpd = lib->settings->get_time(lib->settings, "medsrv.dpd", 300); 
    141140    this->ike = ike_cfg_create(FALSE, FALSE, "0.0.0.0", "0.0.0.0"); 
    142141    this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE)); 
  • trunk/src/charon/sa/ike_sa.c

    r4323 r4333  
    26222622    this->child_prf = NULL; 
    26232623    this->state = IKE_CREATED; 
    2624     this->keepalive_interval = lib->settings->get_int(lib->settings, 
     2624    this->keepalive_interval = lib->settings->get_time(lib->settings, 
    26252625                                    "charon.keep_alive", KEEPALIVE_INTERVAL); 
    26262626    this->time.inbound = this->time.outbound = time(NULL); 
  • trunk/src/libstrongswan/settings.c

    r4046 r4333  
    204204 
    205205/** 
    206  * destry a section 
    207 */ 
     206 * Implementation of settings_t.get_time. 
     207 */ 
     208static u_int32_t get_time(private_settings_t *this, char *key, u_int32_t def) 
     209
     210    char *value, *endptr; 
     211    u_int32_t timeval; 
     212     
     213    value = find(this->top, key); 
     214    if (value) 
     215    { 
     216        errno = 0; 
     217        timeval = strtol(value, &endptr, 10); 
     218        if (errno == 0 && timeval >= 0) 
     219        { 
     220            switch (*endptr) 
     221            { 
     222                case 'd':       /* time in days */ 
     223                    timeval *= 24 * 3600; 
     224                    break; 
     225                case 'h':       /* time in hours */ 
     226                    timeval *= 3600; 
     227                    break; 
     228                case 'm':       /* time in minutes */ 
     229                    timeval *= 60; 
     230                    break; 
     231                case 's':       /* time in seconds */ 
     232                    default: 
     233                    break; 
     234            } 
     235            return timeval; 
     236        } 
     237    } 
     238    return def; 
     239
     240 
     241/** 
     242 * destroy a section 
     243 */ 
    208244static void section_destroy(section_t *this) 
    209245{ 
     
    366402     
    367403    this->public.get_str = (char*(*)(settings_t*, char *key, char* def))get_str; 
    368     this->public.get_int = (int(*)(settings_t*, char *key, bool def))get_int; 
     404    this->public.get_int = (int(*)(settings_t*, char *key, int def))get_int; 
     405    this->public.get_time = (u_int32_t(*)(settings_t*, char *key, u_int32_t def))get_time; 
    369406    this->public.get_bool = (bool(*)(settings_t*, char *key, bool def))get_bool; 
    370407    this->public.destroy = (void(*)(settings_t*))destroy; 
  • trunk/src/libstrongswan/settings.h

    r3589 r4333  
    8181     * @return          value of the key 
    8282     */ 
    83     int (*get_int)(settings_t *this, char *key, bool def); 
     83    int (*get_int)(settings_t *this, char *key, int def); 
    8484     
     85    /** 
     86     * Get a time value. 
     87     * 
     88     * @param key       key including sections 
     89     * @param def       default value to return if key not found 
     90     * @return          value of the key 
     91     */ 
     92    u_int32_t (*get_time)(settings_t *this, char *key, u_int32_t def); 
     93 
    8594    /** 
    8695     * Destroy a settings instance. 
  • trunk/src/manager/main.c

    r3967 r4333  
    4343    socket = lib->settings->get_str(lib->settings, "manager.socket", NULL); 
    4444    debug = lib->settings->get_bool(lib->settings, "manager.debug", FALSE); 
    45     timeout = lib->settings->get_int(lib->settings, "manager.timeout", 900); 
     45    timeout = lib->settings->get_time(lib->settings, "manager.timeout", 900); 
    4646    threads = lib->settings->get_int(lib->settings, "manager.threads", 10); 
    4747    database = lib->settings->get_str(lib->settings, "manager.database", NULL); 
  • trunk/src/medsrv/main.c

    r4061 r4333  
    4242    socket = lib->settings->get_str(lib->settings, "medsrv.socket", NULL); 
    4343    debug = lib->settings->get_bool(lib->settings, "medsrv.debug", FALSE); 
    44     timeout = lib->settings->get_int(lib->settings, "medsrv.timeout", 900); 
     44    timeout = lib->settings->get_time(lib->settings, "medsrv.timeout", 900); 
    4545    threads = lib->settings->get_int(lib->settings, "medsrv.threads", 5); 
    4646    uri = lib->settings->get_str(lib->settings, "medsrv.database", NULL);