api.h 1.8 KB

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