int lxl_dns_core_init(lxl_cycle_t *cycle) { lxl_dns_pool = lxl_create_pool(LXL_DEFAULT_POOL_SIZE); if (lxl_dns_pool == NULL) { return -1; } lxl_dns_root_zone = lxl_palloc(lxl_dns_pool, sizeof(lxl_dns_zone_t)); if (lxl_dns_root_zone == NULL) { return -1; } lxl_log_error(LXL_LOG_INFO, 0, "dns init zone hash"); if (lxl_hash_init(&lxl_dns_hash, lxl_dns_pool, 1024000, lxl_hash_key) == -1) { lxl_log_error(LXL_LOG_ERROR, 0, "dns init hash failed"); return -1; } lxl_list_init(&lxl_dns_root_zone->rrset_list); lxl_dns_root_zone->update_sec = lxl_current_sec; lxl_log_error(LXL_LOG_INFO, 0, "dns load named root path conf/named.root"); lxl_dns_load_named_root("conf/named.root"); lxl_log_error(LXL_LOG_INFO, 0, "dns add root zone"); if (lxl_dns_zone_add(LXL_DNS_ROOT_LABEL, LXL_DNS_ROOT_LEN, lxl_dns_root_zone) == -1) { lxl_log_error(LXL_LOG_ERROR, 0, "dns add root zone failed"); return -1; } return 0; }
int lxl_dns_core_init(lxl_cycle_t *cycle) { lxl_connection_t *c; lxl_dns_pool = lxl_create_pool(LXL_DEFAULT_POOL_SIZE); if (lxl_dns_pool == NULL) { return -1; } lxl_dns_root_zone = lxl_palloc(lxl_dns_pool, sizeof(lxl_dns_zone_t)); if (lxl_dns_root_zone == NULL) { return -1; } lxl_log_error(LXL_LOG_INFO, 0, "dns init zone hash"); if (lxl_hash_init(&lxl_dns_hash, lxl_dns_pool, 1024000, lxl_hash_key) == -1) { lxl_log_error(LXL_LOG_ERROR, 0, "dns init hash failed"); return -1; } lxl_list_init(&lxl_dns_root_zone->rrset_list); lxl_dns_root_zone->update_sec = lxl_current_sec; lxl_log_error(LXL_LOG_INFO, 0, "dns load named root path conf/named.root"); if (lxl_dns_load_named_root("conf/named.root") == -1) { lxl_log_error(LXL_LOG_ERROR, 0, "dns load named root path conf/named.root failed"); return -1; } lxl_log_error(LXL_LOG_INFO, 0, "dns add root zone"); if (lxl_dns_zone_add(LXL_DNS_ROOT_LABEL, LXL_DNS_ROOT_LEN, lxl_dns_root_zone) == -1) { lxl_log_error(LXL_LOG_ERROR, 0, "dns add root zone failed"); return -1; } c = lxl_get_connection(-1); if (c == NULL) { return -1; } memset(&lxl_dns_event, 0x00, sizeof(lxl_event_t)); lxl_dns_event.data = c; lxl_dns_event.handler = lxl_dns_data_rebuild_handler; lxl_add_timer(&lxl_dns_event, 86400*1000); #if 0 char *t; memcpy(t, "lxl coredump test", 1000); #endif return 0; }