nonsip_hooks.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (C) 2006 iptelorg GmbH
  3. *
  4. * This file is part of Kamailio, a free SIP server.
  5. *
  6. * Kamailio is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. * Kamailio is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /*!
  21. * \file
  22. * \brief Kamailio core :: Non-sip callbacks
  23. * non-sip callbacks, called whenever a message with protocol != SIP/2.0
  24. * is received (the message must have at least a sip like first line or
  25. * else they will be dropped before this callbacks are called
  26. * \ingroup core
  27. * \author andrei
  28. * Module: \ref core
  29. */
  30. #ifndef _nonsip_hooks_h
  31. #define _nonsip_hooks_h
  32. #include "parser/msg_parser.h" /* sip_msg */
  33. #define MAX_NONSIP_HOOKS 1
  34. enum nonsip_msg_returns{ NONSIP_MSG_ERROR=-1, NONSIP_MSG_DROP=0,
  35. NONSIP_MSG_PASS, NONSIP_MSG_ACCEPT };
  36. struct nonsip_hook{
  37. char* name; /* must be !=0, it has only "debugging" value */
  38. /* called each time a sip like request (from the first line point of view)
  39. * with protocol/version != SIP/2.0 is received
  40. * return: 0 - drop message immediately, >0 - continue with other hooks,
  41. * <0 - error (drop message)
  42. */
  43. int (*on_nonsip_req)(struct sip_msg* msg);
  44. /* called before ser shutdown (last minute cleanups) */
  45. void (*destroy)(void);
  46. };
  47. int init_nonsip_hooks(void);
  48. void destroy_nonsip_hooks(void);
  49. int register_nonsip_msg_hook(struct nonsip_hook *h);
  50. int nonsip_msg_run_hooks(struct sip_msg* msg);
  51. #endif