ul_db_handle.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* sp-ul_db module
  2. *
  3. * Copyright (C) 2007 1&1 Internet AG
  4. *
  5. * This file is part of Kamailio, a free SIP server.
  6. *
  7. * Kamailio is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version
  11. *
  12. * Kamailio is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "ul_check.h"
  22. #include "../../str.h"
  23. #include "../../lib/srdb1/db.h"
  24. #ifndef SP_P_USRLOC_UL_DB_HANDLE_H
  25. #define SP_P_USRLOC_UL_DB_HANDLE_H
  26. #define DB_NUM 2
  27. #define DB_OFF 0
  28. #define DB_ON 1
  29. #define DB_INACTIVE 2
  30. #define UL_DB_URL_LEN 260
  31. typedef struct str2s {
  32. char s[UL_DB_URL_LEN];
  33. int len;
  34. } str2;
  35. typedef struct ul_db {
  36. str2 url;
  37. int no;
  38. time_t failover_time;
  39. time_t retry;
  40. int errors;
  41. int status;
  42. int spare;
  43. int rg;
  44. db1_con_t * dbh;
  45. db_func_t dbf;
  46. }ul_db_t;
  47. typedef struct ul_db_handle {
  48. unsigned int id;
  49. struct check_data * check;
  50. int working;
  51. time_t expires;
  52. int active;
  53. ul_db_t db[DB_NUM];
  54. }ul_db_handle_t;
  55. typedef struct ul_db_handle_list {
  56. ul_db_handle_t * handle;
  57. struct ul_db_handle_list * next;
  58. }ul_db_handle_list_t;
  59. void destroy_handles(void);
  60. int refresh_handles(db_func_t * dbf, db1_con_t * dbh);
  61. int load_location_number(db_func_t * dbf, db1_con_t * dbh, int*);
  62. int load_handles(db_func_t * dbf, db1_con_t * dbh);
  63. ul_db_handle_t * get_handle(db_func_t * dbf, db1_con_t * dbh, str * first, str * second);
  64. int load_data(db_func_t * dbf, db1_con_t * dbh, ul_db_handle_t * handle, int id);
  65. int refresh_handle(ul_db_handle_t * handle, ul_db_handle_t * new_data, int error_handling);
  66. ul_db_t * get_db_by_num(ul_db_handle_t * handle, int no);
  67. int check_handle(db_func_t * dbf, db1_con_t * dbh, ul_db_handle_t * handle);
  68. #endif