onsend.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2005 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. * History:
  29. * -------
  30. * 2005-12-11 created by andrei
  31. */
  32. #ifndef onsend_h
  33. #define onsend_h
  34. #include "ip_addr.h"
  35. #include "action.h"
  36. #include "route.h"
  37. struct onsend_info{
  38. union sockaddr_union* to;
  39. struct socket_info* send_sock;
  40. char* buf;
  41. int len;
  42. };
  43. extern struct onsend_info* p_onsend;
  44. #define get_onsend_info() (p_onsend)
  45. /*
  46. * returns: 0 drop the message, >= ok, <0 error (but forward the message)
  47. * WARNING: buf must be 0 terminated (to allow regex matches on it) */
  48. static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
  49. char* buf, int len)
  50. {
  51. struct onsend_info onsnd_info;
  52. int ret;
  53. struct run_act_ctx ra_ctx;
  54. ret=1;
  55. if (onsend_rt.rlist[DEFAULT_RT]){
  56. onsnd_info.to=&dst->to;
  57. onsnd_info.send_sock=dst->send_sock;
  58. onsnd_info.buf=buf;
  59. onsnd_info.len=len;
  60. p_onsend=&onsnd_info;
  61. init_run_actions_ctx(&ra_ctx);
  62. ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
  63. p_onsend=0; /* reset it */
  64. }
  65. return ret;
  66. }
  67. #endif