Example #1
0
static void*
database_service_zone_unload_thread(void *parms)
{
    database_service_zone_unload_parms_s *database_service_zone_unload_parms = (database_service_zone_unload_parms_s*)parms;
    zdb_zone *zone = database_service_zone_unload_parms->zone;
    
    u8 origin[MAX_DOMAIN_LENGTH];
    
    if(zone->origin != NULL)
    {    
        dnsname_copy(origin, zone->origin);
    }
    else
    {
        memcpy(origin, "\004NULL", 6);
    }
    
    log_debug("database-service: %{dnsname}: releasing old instance of zone", origin);
    log_debug7("database-service: %{dnsname}: rc=%i", origin, zone->rc);
    
    zdb_zone_release(zone);
    zone = NULL;
    
    zdb_zone_garbage_run();
    
    zone_release(database_service_zone_unload_parms->zone_desc);
    free(database_service_zone_unload_parms);
    
    return NULL;
}
Example #2
0
static ya_result
journal_ix_get_domain(journal *jh, u8 *out_domain)
{
    if(jh->zone != NULL)
    {   
        dnsname_copy(out_domain, jh->zone->origin);
        return SUCCESS;
    }
    
    return ERROR;
}
Example #3
0
static ya_result
rr_check_qname(char **src, u8 *dst, const u8 *origin, u8 *label)
{
    char                                                             *start;
    char                                                            *needle;

    ya_result                                              return_code = OK;
    
    size_t							  start_len;
    size_t							 origin_len;
    bool				              append_origin = FALSE;

    zassert(*src != NULL);

    if(*src == NULL)
    {
        return ZRE_NO_VALUE_FOUND;
    }

    needle = *src;

    if(isspace(*needle))		    /* re-use */
    {
        SKIP_WHSPACE(needle);
        *src = needle;

        if(*label == '\0')		    /* label !empty: only the label will be used */
        {
            if(origin == NULL)
            {
                return NO_ORIGIN_FOUND;
            }

            dnsname_copy(label, origin);    /* label empty: the origin will be added (effectively only the origin will be used) */
        }

        return dnsname_copy(dst, label);    /** @note most of the time dst already have the same content as label */
    }

    /* parse/get (and cut) the first word (the whole string if there is no spaces) */
    start = needle;
    while(!isspace(*needle) && (*needle != '\0'))
    {
        needle++;
    }
    *needle = '\0';

    start_len = needle - start;	/* start_len > 0 because we know the first char was not a space ... */

    /* If it does not ends with '.' we need to append the origin */
    append_origin = (needle[-1] != '.');

    /* cut */
    needle++;
    SKIP_WHSPACE(needle);
    *src = needle;

    if(FAIL(return_code = cstr_to_dnsname_with_check(dst, start)))
    {
        return return_code;
    }

    if(append_origin)
    {
        u8* origin_dst = dst + (return_code - 1);

        if( (origin == NULL) || ((origin_len = dnsname_len(origin)) == 0) )
        {
            return NO_ORIGIN_FOUND;
        }

        if(start_len + origin_len > MAX_DOMAIN_TEXT_LENGTH)
        {
            return ZRE_INCORRECT_DOMAIN_LEN;
        }

        return_code = dnsname_copy(origin_dst, origin);
    }

    dnsname_copy(label, dst);
    
    

    return return_code;
}