nonsip_hooks.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2006 iptelorg GmbH
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser 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. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27. /*
  28. * non-sip callbacks, called whenever a message with protocol != SIP/2.0
  29. * is received (the message must have at least a sip like first line or
  30. * else they will be dropped before this callbacks are called
  31. */
  32. /*
  33. * History:
  34. * --------
  35. * 2006-11-29 created by andrei
  36. */
  37. #ifndef _nonsip_hooks_h
  38. #define _nonsip_hooks_h
  39. #include "parser/msg_parser.h" /* sip_msg */
  40. #define MAX_NONSIP_HOOKS 1
  41. enum nonsip_msg_returns{ NONSIP_MSG_ERROR=-1, NONSIP_MSG_DROP=0,
  42. NONSIP_MSG_PASS, NONSIP_MSG_ACCEPT };
  43. struct nonsip_hook{
  44. char* name; /* must be !=0, it has only "debugging" value */
  45. /* called each time a sip like request (from the first line point of view)
  46. * with protocol/version != SIP/2.0 is received
  47. * return: 0 - drop message immediately, >0 - continue with other hooks,
  48. * <0 - error (drop message)
  49. */
  50. int (*on_nonsip_req)(struct sip_msg* msg);
  51. /* called before ser shutdown (last minute cleanups) */
  52. void (*destroy)(void);
  53. };
  54. int init_nonsip_hooks(void);
  55. void destroy_nonsip_hooks(void);
  56. int register_nonsip_msg_hook(struct nonsip_hook *h);
  57. int nonsip_msg_run_hooks(struct sip_msg* msg);
  58. #endif