domain.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Header file for domain table relates functions
  3. *
  4. * Copyright (C) 2002-2003 Juha Heinanen
  5. *
  6. * This file is part of sip-router, a free SIP server.
  7. *
  8. * sip-router is free software; you can redistribute it and/or modify it under
  9. * the terms of the GNU General Public License as published by the Free
  10. * Software Foundation; either version 2 of the License, or (at your option)
  11. * any later version
  12. *
  13. * sip-router is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef _DOMAIN_H
  23. #define _DOMAIN_H
  24. #include <time.h>
  25. #include <stdio.h>
  26. #include "../../str.h"
  27. #include "../../usr_avp.h"
  28. /*
  29. * Flags stored in flags column and their meaning
  30. */
  31. enum domain_flags {
  32. DOMAIN_DISABLED = (1 << 0), /* Domain has been disabled and should not be
  33. * loaded from the database */
  34. DOMAIN_CANONICAL = (1 << 1) /* Canonical domain name (to be used in user
  35. * interfaces a.s.o.) */
  36. };
  37. /*
  38. * This structure represents a virtual domain within SER Each virtual domain
  39. * is identified by unique domain ID. Each domain can have several domain
  40. * names (also called aliases
  41. */
  42. typedef struct domain {
  43. str did; /* Unique domain ID */
  44. int n; /* Number of domain names */
  45. str* domain; /* Array of all domains associated with did */
  46. unsigned int* flags; /* Flags of each domain in the domain array */
  47. avp_list_t attrs; /* List of domain attributes */
  48. struct domain* next; /* Next domain in the list */
  49. } domain_t;
  50. /*
  51. * Create domain list from domain table
  52. */
  53. int load_domains(domain_t** dest);
  54. /*
  55. * Load domain attributes from database
  56. */
  57. int db_load_domain_attrs(domain_t* dest);
  58. /*
  59. * Release all memory allocated for entire domain list
  60. */
  61. void free_domain_list(domain_t* list);
  62. typedef int (*domain_get_did_t)(str* did, str* domain);
  63. /* Retrieve did directly from database, without using memory cache. Use 0 as
  64. * the value of first parameter if you only want to know whether the entry is
  65. * in the database. The function returns 1 if there is such entry, 0 if not,
  66. * and -1 on error. The result is allocated using pkg_malloc and must be
  67. * freed.
  68. */
  69. int db_get_did(str* did, str* domain);
  70. /* Check if the domain name given in the parameter is one
  71. * of the locally configured domain names.
  72. * Returns 1 if yes and -1 otherwise
  73. */
  74. typedef int (*is_domain_local_f)(str* domain);
  75. int is_domain_local(str* domain);
  76. #endif /* _DOMAIN_H */