sip_utils.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2010, Digium, Inc.
  5. *
  6. * See http://www.asterisk.org for more information about
  7. * the Asterisk project. Please do not directly contact
  8. * any of the maintainers of this project for assistance;
  9. * the project provides a web site, mailing lists and IRC
  10. * channels for your use.
  11. *
  12. * This program is free software, distributed under the terms of
  13. * the GNU General Public License Version 2. See the LICENSE file
  14. * at the top of the source tree.
  15. */
  16. /*!
  17. * \file
  18. * \brief sip utils header file
  19. */
  20. #ifndef _SIP_UTILS_H
  21. #define _SIP_UTILS_H
  22. /* wrapper macro to tell whether t points to one of the sip_tech descriptors */
  23. #define IS_SIP_TECH(t) ((t) == &sip_tech || (t) == &sip_tech_info)
  24. /*!
  25. * \brief converts ascii port to int representation.
  26. *
  27. * \arg pt[in] string that contains a port.
  28. * \arg standard[in] port to return in case the port string input is NULL
  29. * or if there is a parsing error.
  30. *
  31. * \return An integer port representation.
  32. */
  33. unsigned int port_str2int(const char *pt, unsigned int standard);
  34. /*! \brief Locate closing quote in a string, skipping escaped quotes.
  35. * optionally with a limit on the search.
  36. * start must be past the first quote.
  37. */
  38. const char *find_closing_quote(const char *start, const char *lim);
  39. /*! \brief Convert SIP hangup causes to Asterisk hangup causes */
  40. int hangup_sip2cause(int cause);
  41. /*! \brief Convert Asterisk hangup causes to SIP codes
  42. \verbatim
  43. Possible values from causes.h
  44. AST_CAUSE_NOTDEFINED AST_CAUSE_NORMAL AST_CAUSE_BUSY
  45. AST_CAUSE_FAILURE AST_CAUSE_CONGESTION AST_CAUSE_UNALLOCATED
  46. In addition to these, a lot of PRI codes is defined in causes.h
  47. ...should we take care of them too ?
  48. Quote RFC 3398
  49. ISUP Cause value SIP response
  50. ---------------- ------------
  51. 1 unallocated number 404 Not Found
  52. 2 no route to network 404 Not found
  53. 3 no route to destination 404 Not found
  54. 16 normal call clearing --- (*)
  55. 17 user busy 486 Busy here
  56. 18 no user responding 408 Request Timeout
  57. 19 no answer from the user 480 Temporarily unavailable
  58. 20 subscriber absent 480 Temporarily unavailable
  59. 21 call rejected 403 Forbidden (+)
  60. 22 number changed (w/o diagnostic) 410 Gone
  61. 22 number changed (w/ diagnostic) 301 Moved Permanently
  62. 23 redirection to new destination 410 Gone
  63. 26 non-selected user clearing 404 Not Found (=)
  64. 27 destination out of order 502 Bad Gateway
  65. 28 address incomplete 484 Address incomplete
  66. 29 facility rejected 501 Not implemented
  67. 31 normal unspecified 480 Temporarily unavailable
  68. \endverbatim
  69. */
  70. const char *hangup_cause2sip(int cause);
  71. /*! \brief Return a string describing the force_rport value for the given flags */
  72. const char *force_rport_string(struct ast_flags *flags);
  73. /*! \brief Return a string describing the comedia value for the given flags */
  74. const char *comedia_string(struct ast_flags *flags);
  75. #endif