00001 /* 00002 * Header file for domain table relates functions 00003 * 00004 * Copyright (C) 2002-2003 Juha Heinanen 00005 * 00006 * This file is part of sip-router, a free SIP server. 00007 * 00008 * sip-router is free software; you can redistribute it and/or modify it under 00009 * the terms of the GNU General Public License as published by the Free 00010 * Software Foundation; either version 2 of the License, or (at your option) 00011 * any later version 00012 * 00013 * sip-router is distributed in the hope that it will be useful, but WITHOUT 00014 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00016 * more details. 00017 * 00018 * You should have received a copy of the GNU General Public License along 00019 * with this program; if not, write to the Free Software Foundation, Inc., 00020 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 #ifndef _DOMAIN_H 00023 #define _DOMAIN_H 00024 00025 #include <time.h> 00026 #include <stdio.h> 00027 #include "../../str.h" 00028 #include "../../usr_avp.h" 00029 00030 00031 /* 00032 * Flags stored in flags column and their meaning 00033 */ 00034 enum domain_flags { 00035 DOMAIN_DISABLED = (1 << 0), /* Domain has been disabled and should not be 00036 * loaded from the database */ 00037 DOMAIN_CANONICAL = (1 << 1) /* Canonical domain name (to be used in user 00038 * interfaces a.s.o.) */ 00039 }; 00040 00041 00042 /* 00043 * This structure represents a virtual domain within SER Each virtual domain 00044 * is identified by unique domain ID. Each domain can have several domain 00045 * names (also called aliases 00046 */ 00047 typedef struct domain { 00048 str did; /* Unique domain ID */ 00049 int n; /* Number of domain names */ 00050 str* domain; /* Array of all domains associated with did */ 00051 unsigned int* flags; /* Flags of each domain in the domain array */ 00052 avp_list_t attrs; /* List of domain attributes */ 00053 struct domain* next; /* Next domain in the list */ 00054 } domain_t; 00055 00056 00057 /* 00058 * Create domain list from domain table 00059 */ 00060 int load_domains(domain_t** dest); 00061 00062 /* 00063 * Load domain attributes from database 00064 */ 00065 int db_load_domain_attrs(domain_t* dest); 00066 00067 00068 /* 00069 * Release all memory allocated for entire domain list 00070 */ 00071 void free_domain_list(domain_t* list); 00072 00073 typedef int (*domain_get_did_t)(str* did, str* domain); 00074 00075 00076 /* Retrieve did directly from database, without using memory cache. Use 0 as 00077 * the value of first parameter if you only want to know whether the entry is 00078 * in the database. The function returns 1 if there is such entry, 0 if not, 00079 * and -1 on error. The result is allocated using pkg_malloc and must be 00080 * freed. 00081 */ 00082 int db_get_did(str* did, str* domain); 00083 00084 /* Check if the domain name given in the parameter is one 00085 * of the locally configured domain names. 00086 * Returns 1 if yes and -1 otherwise 00087 */ 00088 typedef int (*is_domain_local_f)(str* domain); 00089 int is_domain_local(str* domain); 00090 00091 00092 #endif /* _DOMAIN_H */
1.7.1