tsdp_header_O.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 tsdp_header_O.h
  23. * @brief SDP "o=" header (Origin).
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. *
  27. * @date Created: Oat Nov 8 16:54:58 2009 mdiop
  28. */
  29. #ifndef _TSDP_HEADER_O_H_
  30. #define _TSDP_HEADER_O_H_
  31. #include "tinysdp_config.h"
  32. #include "tinysdp/headers/tsdp_header.h"
  33. TSDP_BEGIN_DECLS
  34. #define TSDP_HEADER_O_VA_ARGS(username, sess_id, sess_version, nettype, addrtype, addr) tsdp_header_O_def_t, (const char*)username, (uint32_t)sess_id, (uint32_t)sess_version, (const char*)nettype, (const char*)addrtype, (const char*)addr
  35. #define TSDP_HEADER_O_VA_ARGS_DEFAULT(username, nettype, addrtype, addr) TSDP_HEADER_O_VA_ARGS(username, TSDP_HEADER_O_SESS_ID_DEFAULT, TSDP_HEADER_O_SESS_VERSION_DEFAULT, nettype, addrtype, addr)
  36. #define TSDP_HEADER_O_SESS_ID_DEFAULT 123456
  37. #define TSDP_HEADER_O_SESS_VERSION_DEFAULT 678901
  38. ////////////////////////////////////////////////////////////////////////////////////////////////////
  39. /// @struct
  40. ///
  41. /// @brief SDP "o=" header (Origin).
  42. /// The "o=" field gives the originator of the session (her username and
  43. /// the address of the user's host) plus a session identifier and version number.
  44. ///
  45. /// @par ABNF : u=username SP
  46. /// sess-id SP sess-version SP nettype SP addrtype SP unicast-address
  47. ///
  48. /// username = non-ws-string
  49. /// sess-id = 1*DIGIT
  50. /// sess-version = 1*DIGIT
  51. /// nettype = token
  52. /// addrtype = token
  53. /// unicast-address = FQDN
  54. ///
  55. ////////////////////////////////////////////////////////////////////////////////////////////////////
  56. typedef struct tsdp_header_O_s {
  57. TSDP_DECLARE_HEADER;
  58. /** <username> is the user's login on the originating host, or it is "-"
  59. if the originating host does not support the concept of user IDs.
  60. The <username> MUST NOT contain spaces.*/
  61. char* username;
  62. /** <sess-id>, <nettype>, <addrtype>, and <unicast-address> forms a
  63. globally unique identifier for the session. The method of
  64. <sess-id> allocation is up to the creating tool, but it has been
  65. suggested that a Network Time Protocol (NTP) format timestamp be
  66. used to ensure uniqueness*/
  67. uint32_t sess_id;
  68. /** <sess-version> is a version number for this session description. Its
  69. usage is up to the creating tool, so long as <sess-version> is
  70. increased when a modification is made to the session data. Again,
  71. it is RECOMMENDED that an NTP format timestamp is used.*/
  72. uint32_t sess_version;
  73. /** <nettype> is a text string giving the type of network. Initially
  74. "IN" is defined to have the meaning "Internet", but other values
  75. MAY be registered in the future (see Section 8 of RFC 4566)*/
  76. char* nettype;
  77. /**<addrtype> is a text string giving the type of the address that
  78. follows. Initially "IP4" and "IP6" are defined, but other values
  79. MAY be registered in the future (see Section 8 of RFC 4566)*/
  80. char* addrtype;
  81. /** <unicast-address> is the address of the machine from which the
  82. session was created. For an address type of IP4, this is either
  83. the fully qualified domain name of the machine or the dotted-
  84. decimal representation of the IP version 4 address of the machine.
  85. For an address type of IP6, this is either the fully qualified
  86. domain name of the machine or the compressed textual
  87. representation of the IP version 6 address of the machine. For
  88. both IP4 and IP6, the fully qualified domain name is the form that
  89. SHOULD be given unless this is unavailable, in which case the
  90. globally unique address MAY be substituted. A local IP address
  91. MUST NOT be used in any context where the SDP description might
  92. leave the scope in which the address is meaningful (for example, a
  93. local address MUST NOT be included in an application-level
  94. referral that might leave the scope)*/
  95. char* addr;
  96. }
  97. tsdp_header_O_t;
  98. TINYSDP_API tsdp_header_O_t* tsdp_header_O_create(const char* username, uint32_t sess_id, uint32_t sess_version, const char* nettype, const char* addrtype, const char* addr);
  99. TINYSDP_API tsdp_header_O_t* tsdp_header_O_create_null();
  100. TINYSDP_API tsdp_header_O_t* tsdp_header_O_create_default(const char* username, const char* nettype, const char* addrtype, const char* addr);
  101. TINYSDP_API tsdp_header_O_t *tsdp_header_O_parse(const char *data, tsk_size_t size);
  102. TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_O_def_t;
  103. TSDP_END_DECLS
  104. #endif /* _TSDP_HEADER_O_H_ */