sip_status.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * This file is part of the Sofia-SIP package
  3. *
  4. * Copyright (C) 2005 Nokia Corporation.
  5. *
  6. * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. /**@ingroup sip_status_codes
  25. * @CFILE sip_status.c
  26. *
  27. * SIP status codes and standard phrases.
  28. *
  29. * @author Pekka Pessi <Pekka.Pessi@nokia.com>.
  30. *
  31. * @date Created: Fri Aug 11 18:03:33 2000 ppessi
  32. */
  33. #include "config.h"
  34. #include <stddef.h>
  35. #include <sofia-sip/sip_status.h>
  36. char const
  37. sip_100_Trying[] = "Trying",
  38. sip_180_Ringing[] = "Ringing",
  39. sip_181_Call_is_being_forwarded[] = "Call Is Being Forwarded",
  40. sip_182_Queued[] = "Queued",
  41. sip_183_Session_progress[] = "Session Progress",
  42. sip_200_OK[] = "OK",
  43. sip_202_Accepted[] = "Accepted",
  44. sip_300_Multiple_choices[] = "Multiple Choices",
  45. sip_301_Moved_permanently[] = "Moved Permanently",
  46. sip_302_Moved_temporarily[] = "Moved Temporarily",
  47. sip_305_Use_proxy[] = "Use Proxy",
  48. sip_380_Alternative_service[] = "Alternative Service",
  49. sip_400_Bad_request[] = "Bad Request",
  50. sip_401_Unauthorized[] = "Unauthorized",
  51. sip_402_Payment_required[] = "Payment Required",
  52. sip_403_Forbidden[] = "Forbidden",
  53. sip_403_Stale_date[] = "Stale Date",
  54. sip_404_Not_found[] = "Not Found",
  55. sip_405_Method_not_allowed[] = "Method Not Allowed",
  56. sip_406_Not_acceptable[] = "Not Acceptable",
  57. sip_407_Proxy_auth_required[] = "Proxy Authentication Required",
  58. sip_408_Request_timeout[] = "Request Timeout",
  59. sip_409_Conflict[] = "Conflict",
  60. sip_410_Gone[] = "Gone",
  61. sip_411_Length_required[] = "Length Required",
  62. sip_412_Precondition_failed[] = "Precondition Failed",
  63. sip_413_Request_too_large[] = "Request Entity Too Large",
  64. sip_414_Request_uri_too_long[] = "Request-URI Too Long",
  65. sip_415_Unsupported_media[] = "Unsupported Media Type",
  66. sip_416_Unsupported_uri[] = "Unsupported URI Scheme",
  67. sip_417_Resource_priority[]= "Unknown Resource-Priority",
  68. sip_420_Bad_extension[] = "Bad Extension",
  69. sip_421_Extension_required[] = "Extension Required",
  70. sip_422_Session_timer[] = "Session Interval Too Small",
  71. sip_423_Interval_too_brief[] = "Interval Too Brief",
  72. sip_428_Use_identity_header[] = "Use Identity Header",
  73. sip_436_Bad_identity_info[] = "Bad Identity Info",
  74. sip_437_Unsupported_credential[] = "Unsupported Credential",
  75. sip_438_Invalid_identity_header[] = "Invalid Identity Header",
  76. sip_439_Stale_date[] = "Stale Date",
  77. sip_480_Temporarily_unavailable[] = "Temporarily Unavailable",
  78. sip_481_No_transaction[] = "Call/Transaction Does Not Exist",
  79. sip_482_Loop_detected[] = "Loop Detected",
  80. sip_483_Too_many_hops[] = "Too Many Hops",
  81. sip_484_Address_incomplete[] = "Address Incomplete",
  82. sip_485_Ambiguous[] = "Ambiguous",
  83. sip_486_Busy_here[] = "Busy Here",
  84. sip_487_Request_terminated[] = "Request Terminated",
  85. sip_488_Not_acceptable[] = "Not Acceptable Here",
  86. sip_489_Bad_event[] = "Bad Event",
  87. sip_490_Request_updated[] = "Request Updated",
  88. sip_491_Request_pending[] = "Request Pending",
  89. sip_493_Undecipherable[] = "Undecipherable",
  90. sip_494_Secagree_required [] = "Security Agreement Required",
  91. sip_500_Internal_server_error[] = "Internal Server Error",
  92. sip_501_Not_implemented[] = "Not Implemented",
  93. sip_502_Bad_gateway[] = "Bad Gateway",
  94. sip_503_Service_unavailable[] = "Service Unavailable",
  95. sip_504_Gateway_time_out[] = "Gateway Time-out",
  96. sip_505_Version_not_supported[] = "Version Not Supported",
  97. sip_513_Message_too_large[] = "Message Too Large",
  98. sip_580_Precondition[] = "Precondition Failure",
  99. sip_600_Busy_everywhere[] = "Busy Everywhere",
  100. sip_603_Decline[] = "Decline",
  101. sip_604_Does_not_exist_anywhere[] = "Does Not Exist Anywhere",
  102. sip_606_Not_acceptable[] = "Not Acceptable",
  103. sip_607_Unwanted[] = "Unwanted",
  104. sip_687_Dialog_terminated[] = "Dialog Terminated"
  105. ;
  106. /** Convert a SIP status code to a status phrase.
  107. *
  108. * Convert a SIP status code to a status phrase. If the status code is not
  109. * in the range 100..699, NULL is returned. If the status code is not known,
  110. * empty string "" is returned.
  111. *
  112. * @param status well-known status code in range 100..699
  113. *
  114. * @return
  115. * A response message corresponding to status code, or NULL upon an error.
  116. */
  117. char const *sip_status_phrase(int status)
  118. {
  119. if (status < 100 || status > 699)
  120. return NULL;
  121. switch (status) {
  122. case 100: return sip_100_Trying;
  123. case 180: return sip_180_Ringing;
  124. case 181: return sip_181_Call_is_being_forwarded;
  125. case 182: return sip_182_Queued;
  126. case 183: return sip_183_Session_progress;
  127. case 200: return sip_200_OK;
  128. case 202: return sip_202_Accepted;
  129. case 300: return sip_300_Multiple_choices;
  130. case 301: return sip_301_Moved_permanently;
  131. case 302: return sip_302_Moved_temporarily;
  132. case 305: return sip_305_Use_proxy;
  133. case 380: return sip_380_Alternative_service;
  134. case 400: return sip_400_Bad_request;
  135. case 401: return sip_401_Unauthorized;
  136. case 402: return sip_402_Payment_required;
  137. case 403: return sip_403_Forbidden;
  138. case 404: return sip_404_Not_found;
  139. case 405: return sip_405_Method_not_allowed;
  140. case 406: return sip_406_Not_acceptable;
  141. case 407: return sip_407_Proxy_auth_required;
  142. case 408: return sip_408_Request_timeout;
  143. case 409: return sip_409_Conflict;
  144. case 410: return sip_410_Gone;
  145. case 411: return sip_411_Length_required;
  146. case 412: return sip_412_Precondition_failed;
  147. case 413: return sip_413_Request_too_large;
  148. case 414: return sip_414_Request_uri_too_long;
  149. case 415: return sip_415_Unsupported_media;
  150. case 416: return sip_416_Unsupported_uri;
  151. case 417: return sip_417_Resource_priority;
  152. case 420: return sip_420_Bad_extension;
  153. case 421: return sip_421_Extension_required;
  154. case 422: return sip_422_Session_timer;
  155. case 423: return sip_423_Interval_too_brief;
  156. case 428: return sip_428_Use_identity_header;
  157. case 436: return sip_436_Bad_identity_info;
  158. case 437: return sip_437_Unsupported_credential;
  159. case 438: return sip_438_Invalid_identity_header;
  160. case 439: return sip_439_Stale_date;
  161. case 480: return sip_480_Temporarily_unavailable;
  162. case 481: return sip_481_No_transaction;
  163. case 482: return sip_482_Loop_detected;
  164. case 483: return sip_483_Too_many_hops;
  165. case 484: return sip_484_Address_incomplete;
  166. case 485: return sip_485_Ambiguous;
  167. case 486: return sip_486_Busy_here;
  168. case 487: return sip_487_Request_terminated;
  169. case 488: return sip_488_Not_acceptable;
  170. case 489: return sip_489_Bad_event;
  171. case 490: return sip_490_Request_updated;
  172. case 491: return sip_491_Request_pending;
  173. case 493: return sip_493_Undecipherable;
  174. case 494: return sip_494_Secagree_required;
  175. case 500: return sip_500_Internal_server_error;
  176. case 501: return sip_501_Not_implemented;
  177. case 502: return sip_502_Bad_gateway;
  178. case 503: return sip_503_Service_unavailable;
  179. case 504: return sip_504_Gateway_time_out;
  180. case 505: return sip_505_Version_not_supported;
  181. case 513: return sip_513_Message_too_large;
  182. case 580: return sip_580_Precondition;
  183. case 600: return sip_600_Busy_everywhere;
  184. case 603: return sip_603_Decline;
  185. case 604: return sip_604_Does_not_exist_anywhere;
  186. case 606: return sip_606_Not_acceptable;
  187. case 607: return sip_607_Unwanted;
  188. case 687: return sip_687_Dialog_terminated;
  189. }
  190. return "";
  191. }