tsip_header_Via.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO 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 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file tsip_header_Via.h
  23. * @brief SIP Via/v header as per RFC 3261 subclause 20.42.
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. *
  27. */
  28. #ifndef TINYSIP_HEADER_VIA_H
  29. #define TINYSIP_HEADER_VIA_H
  30. #include "tinysip_config.h"
  31. #include "tinysip/headers/tsip_header.h"
  32. #include "tsk_object.h"
  33. TSIP_BEGIN_DECLS
  34. #define TSIP_HEADER_VIA_VA_ARGS(proto_name, proto_version, transport, host, port) tsip_header_Via_def_t, (const char*)proto_name, (const char*)proto_version, (const char*)transport, (const char*)host, (uint16_t)port
  35. #define TSIP_HEADER_VIA_HAS_RPORT(self) ((self)->rport!=0)
  36. #define TSIP_HEADER_VIA_HAS_TTL(self) ((self)->ttl!=0)
  37. #define TSIP_HEADER_VIA_UNRELIABLE_TRANS(self) (tsk_striequals("UDP", (self)->transport))
  38. #define TSIP_HEADER_VIA_RELIABLE_TRANS(self) !(TSIP_HEADER_VIA_UNRELIABLE_TRANS(self))
  39. #define TSIP_HEADER_VIA_PROTO_NAME_DEFAULT "SIP"
  40. #define TSIP_HEADER_VIA_PROTO_VERSION_DEFAULT "2.0"
  41. ////////////////////////////////////////////////////////////////////////////////////////////////////
  42. ///
  43. /// @brief SIP Via/v header as per RFC 3261 subclause 20.42.
  44. /// ABNF: Via = ( "Via" / "v" ) HCOLON via-parm *(COMMA via-parm)
  45. /// via-parm = sent-protocol LWS sent-by *( SEMI via-params )
  46. /// via-params = via-ttl / via-maddr / via-received / via-branch / via-compression / response-port / via-extension
  47. /// via-ttl = "ttl" EQUAL ttl
  48. /// via-maddr = "maddr" EQUAL host
  49. /// via-received = "received" EQUAL (IPv4address / IPv6address)
  50. /// via-branch = "branch" EQUAL token
  51. /// via-compression = "comp" EQUAL ("sigcomp" / other-compression)
  52. /// other-compression = token
  53. /// response-port = "rport" [EQUAL 1*DIGIT]
  54. /// via-extension = generic-param
  55. /// sent-protocol = protocol-name SLASH protocol-version SLASH transport
  56. /// protocol-name = "SIP" / token
  57. /// protocol-version = token
  58. /// transport = "UDP" / "TCP" / "TLS" / "SCTP" / "TLS-SCTP" / other-transport
  59. /// sent-by = host [ COLON port ]
  60. /// ttl = 1*3DIGIT
  61. ///
  62. /// @author Mamadou
  63. /// @date 12/5/2009
  64. ////////////////////////////////////////////////////////////////////////////////////////////////////
  65. typedef struct tsip_header_Via_s {
  66. TSIP_DECLARE_HEADER;
  67. char *branch;
  68. char *host;
  69. uint16_t port;
  70. char *comp;
  71. char *sigcomp_id;
  72. char *received;
  73. char *maddr;
  74. char *proto_name;
  75. char *proto_version;
  76. char *transport;
  77. int32_t rport;
  78. int32_t ttl;
  79. }
  80. tsip_header_Via_t;
  81. typedef tsk_list_t tsip_header_Vias_L_t;
  82. TINYSIP_API tsip_header_Via_t* tsip_header_Via_create(const char* proto_name, const char* proto_version, const char* transport, const char* host, uint16_t port);
  83. TINYSIP_API tsip_header_Via_t* tsip_header_Via_create_null();
  84. TINYSIP_API tsip_header_Vias_L_t *tsip_header_Via_parse(const char *data, tsk_size_t size);
  85. TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Via_def_t;
  86. TSIP_END_DECLS
  87. #endif /* TINYSIP_HEADER_VIA_H */