tsip_header_Security_Client.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_Security_Client.h
  23. * @brief SIP header 'Security-Client' as per RFC 3329.
  24. *
  25. */
  26. #ifndef _TSIP_HEADER_SECURITY_CLIENT_H_
  27. #define _TSIP_HEADER_SECURITY_CLIENT_H_
  28. #include "tinysip_config.h"
  29. #include "tinysip/headers/tsip_header.h"
  30. #include "tnet_types.h"
  31. TSIP_BEGIN_DECLS
  32. #define TSIP_HEADER_SECURITY_CLIENT_VA_ARGS(mech, alg, prot, mod, ealg, port_c, port_s, spi_c, spi_s) tsip_header_Security_Client_def_t, (const char*)mech, (const char*)alg, (const char*)prot, (const char*)mod, (const char*)ealg, (tnet_port_t)port_c, (tnet_port_t)port_s, (uint32_t)spi_c, (uint32_t)spi_s
  33. ////////////////////////////////////////////////////////////////////////////////////////////////////
  34. ///
  35. /// @brief SIP header 'Security-Client' as per RFC 3329.
  36. ///
  37. /// @par ABNF : Security-Client = "Security-Client" HCOLON sec-mechanism *(COMMA sec-mechanism)
  38. /// sec-mechanism = mechanism-name *( SEMI mech-parameters )
  39. /// mechanism-name = ( "digest" / "tls" / "ipsec-ike" / "ipsec-man" / token )
  40. /// mech-parameters = ( preference / digest-algorithm / digest-qop / digest-verify / mech-extension )
  41. /// preference = "q" EQUAL qvalue
  42. /// digest-algorithm = "d-alg" EQUAL token
  43. /// digest-qop = "d-qop" EQUAL token
  44. /// digest-verify = "d-ver" EQUAL LDQUOT 32LHEX RDQUOT
  45. /// mech-extension = generic-param
  46. ///
  47. /// mechanism-name = ( "ipsec-3gpp" )
  48. /// mech-parameters = ( algorithm / protocol /mode /
  49. /// encrypt-algorithm / spi /
  50. /// port1 / port2 )
  51. /// algorithm = "alg" EQUAL ( "hmac-md5-96" /
  52. /// "hmac-sha-1-96" )
  53. /// protocol = "prot" EQUAL ( "ah" / "esp" )
  54. /// mode = "mod" EQUAL ( "trans" / "tun" )
  55. /// encrypt-algorithm = "ealg" EQUAL ( "des-ede3-cbc" / "null" )
  56. /// spi = "spi" EQUAL spivalue
  57. /// spivalue = 10DIGIT; 0 to 4294967295
  58. /// port1 = "port1" EQUAL port
  59. /// port2 = "port2" EQUAL port
  60. /// port = 1*DIGIT
  61. ///
  62. ///
  63. ////////////////////////////////////////////////////////////////////////////////////////////////////
  64. typedef struct tsip_header_Security_Client_s {
  65. TSIP_DECLARE_HEADER;
  66. //! sec-mechanism (e.g. "digest" / "tls" / "ipsec-3gpp")
  67. char* mech;
  68. //! algorithm (e.g. "hmac-md5-96" / "hmac-sha-1-96")
  69. char* alg;
  70. //! protocol (e.g. "ah" / "esp")
  71. char* prot;
  72. //! mode (e.g. "trans" / "tun")
  73. char* mod;
  74. //! encrypt-algorithm (e.g. "des-ede3-cbc" / "null")
  75. char* ealg;
  76. //! client port
  77. tnet_port_t port_c;
  78. //! server port
  79. tnet_port_t port_s;
  80. //! client spi
  81. uint32_t spi_c;
  82. //! server spi
  83. uint32_t spi_s;
  84. //! preference
  85. double q;
  86. }
  87. tsip_header_Security_Client_t;
  88. typedef tsk_list_t tsip_header_Security_Clients_L_t;
  89. TINYSIP_API tsip_header_Security_Client_t* tsip_header_Security_Client_create(const char* mech, const char* alg, const char* prot, const char* mod, const char* ealg, tnet_port_t port_c, tnet_port_t port_s, uint32_t spi_c, uint32_t spi_s);
  90. TINYSIP_API tsip_header_Security_Client_t* tsip_header_Security_Client_create_null();
  91. TINYSIP_API tsip_header_Security_Clients_L_t *tsip_header_Security_Client_parse(const char *data, tsk_size_t size);
  92. TINYSIP_GEXTERN const tsk_object_def_t *tsip_header_Security_Client_def_t;
  93. TSIP_END_DECLS
  94. #endif /* _TSIP_HEADER_SECURITY_CLIENT_H_ */