api.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Sanity Checks Module
  3. *
  4. * Copyright (C) 2006 iptelorg GbmH
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. #ifndef _SANITY_API_H_
  24. #define _SANITY_API_H_
  25. #include "../../parser/msg_parser.h"
  26. typedef int (*sanity_check_f)(struct sip_msg* msg, int msg_checks,
  27. int uri_checks);
  28. typedef int (*sanity_check_defaults_f)(struct sip_msg* msg);
  29. typedef struct sanity_api {
  30. sanity_check_f check;
  31. sanity_check_defaults_f check_defaults;
  32. } sanity_api_t;
  33. typedef int (*bind_sanity_f)(sanity_api_t* api);
  34. /**
  35. * @brief Load the Sanity API
  36. */
  37. static inline int sanity_load_api(sanity_api_t *api)
  38. {
  39. bind_sanity_f bindsanity;
  40. bindsanity = (bind_sanity_f)find_export("bind_sanity", 0, 0);
  41. if(bindsanity == 0) {
  42. LM_ERR("cannot find bind_sanity\n");
  43. return -1;
  44. }
  45. if(bindsanity(api)<0)
  46. {
  47. LM_ERR("cannot bind sanity api\n");
  48. return -1;
  49. }
  50. return 0;
  51. }
  52. #endif /* _SANITY_API_H_ */