session_partition_declaration.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * ESG parser
  3. *
  4. * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr)
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #ifndef _ESG_TRANSPORT_SESSION_PARTITION_DECLARATION_H
  21. #define _ESG_TRANSPORT_SESSION_PARTITION_DECLARATION_H 1
  22. #ifdef __cplusplus
  23. extern "C"
  24. {
  25. #endif
  26. #include <libesg/types.h>
  27. /**
  28. * esg_session_field structure.
  29. */
  30. struct esg_session_field {
  31. uint16_t identifier;
  32. uint16_t encoding;
  33. uint8_t length;
  34. struct esg_session_field *_next;
  35. };
  36. /**
  37. * esg_session_ip_stream_field_value union.
  38. */
  39. union esg_session_ip_stream_field_value {
  40. uint8_t *string;
  41. uint16_t unsigned_short;
  42. };
  43. /**
  44. * esg_session_ip_stream_field structure.
  45. */
  46. struct esg_session_ip_stream_field {
  47. union esg_session_ip_stream_field_value *start_field_value;
  48. union esg_session_ip_stream_field_value *end_field_value;
  49. struct esg_session_ip_stream_field *_next;
  50. };
  51. /**
  52. * esg_session_ip_stream structure.
  53. */
  54. struct esg_session_ip_stream {
  55. uint8_t id;
  56. union esg_ip_address source_ip;
  57. union esg_ip_address destination_ip;
  58. uint16_t port;
  59. uint16_t session_id;
  60. struct esg_session_ip_stream_field *field_list;
  61. struct esg_session_ip_stream *_next;
  62. };
  63. /**
  64. * esg_session_partition_declaration structure.
  65. */
  66. struct esg_session_partition_declaration {
  67. uint8_t num_fields;
  68. uint8_t overlapping;
  69. struct esg_session_field *field_list;
  70. uint8_t n_o_ip_streams;
  71. uint8_t ip_version_6;
  72. struct esg_session_ip_stream *ip_stream_list;
  73. };
  74. /**
  75. * Process an esg_session_partition_declaration.
  76. *
  77. * @param buffer Binary buffer to decode.
  78. * @param size Binary buffer size.
  79. * @return Pointer to an esg_session_partition_declaration structure, or NULL on error.
  80. */
  81. extern struct esg_session_partition_declaration *esg_session_partition_declaration_decode(uint8_t *buffer, uint32_t size);
  82. /**
  83. * Free an esg_session_partition_declaration.
  84. *
  85. * @param esg Pointer to an esg_session_partition_declaration structure.
  86. */
  87. extern void esg_session_partition_declaration_free(struct esg_session_partition_declaration *partition);
  88. /**
  89. * Convenience iterator for field_list field of an esg_session_partition_declaration.
  90. *
  91. * @param partition The esg_session_partition_declaration pointer.
  92. * @param field Variable holding a pointer to the current esg_session_field.
  93. */
  94. #define esg_session_partition_declaration_field_list_for_each(partition, field) \
  95. for ((field) = (partition)->field_list; \
  96. (field); \
  97. (field) = (field)->_next)
  98. /**
  99. * Convenience iterator for ip_stream_list field of an esg_session_partition_declaration.
  100. *
  101. * @param partition The esg_session_partition_declaration pointer.
  102. * @param ip_stream Variable holding a pointer to the current esg_session_ip_stream.
  103. */
  104. #define esg_session_partition_declaration_ip_stream_list_for_each(partition, ip_stream) \
  105. for ((ip_stream) = (partition)->ip_stream_list; \
  106. (ip_stream); \
  107. (ip_stream) = (ip_stream)->_next)
  108. /**
  109. * Convenience iterator for field_list field of an esg_session_ip_stream.
  110. *
  111. * @param ip_stream The esg_session_ip_stream pointer.
  112. * @param field Variable holding a pointer to the current esg_session_ip_stream.
  113. */
  114. #define esg_session_ip_stream_field_list_for_each(ip_stream, field) \
  115. for ((field) = (ip_stream)->field_list; \
  116. (field); \
  117. (field) = (field)->_next)
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif