You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
8.0 KiB

6 years ago
1 year ago
6 years ago
1 year ago
6 years ago
6 years ago
6 years ago
1 year ago
6 years ago
6 years ago
1 year ago
6 years ago
  1. /**
  2. * @file map_asn1.h
  3. * @brief map asn1 to pEp structs and back
  4. * @license GNU General Public License 3.0 - see LICENSE.txt
  5. */
  6. #ifndef MAP_ASN1_H
  7. #define MAP_ASN1_H
  8. #include "message.h"
  9. #include "../asn.1/PEPMessage.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * <!-- Identity_from_Struct() -->
  15. *
  16. * @brief Convert pEp_identity into ASN.1 Identity_t
  17. *
  18. * @param ident[in] pEp_identity to convert
  19. * @param result[in,out] Identity_t to update or NULL to alloc a new one
  20. *
  21. * @retval pointer to updated or allocated result
  22. *
  23. * @warning if a new struct is allocated, the ownership goes to the caller
  24. *
  25. */
  26. Identity_t *Identity_from_Struct(
  27. const pEp_identity *ident,
  28. Identity_t *result
  29. );
  30. /**
  31. * <!-- Identity_to_Struct() -->
  32. *
  33. * @brief Convert ASN.1 Identity_t into pEp_identity
  34. *
  35. * @param ident[in] Identity_t to convert
  36. * @param result[inout] pEp_identity to update or NULL to alloc a new one
  37. *
  38. * @retval pointer to updated or allocated result
  39. *
  40. * @warning if a new struct is allocated, the ownership goes to the caller
  41. *
  42. */
  43. pEp_identity *Identity_to_Struct(Identity_t *ident, pEp_identity *result);
  44. /**
  45. * <!-- IdentityList_from_identity_list() -->
  46. *
  47. * @brief Convert identity_list_t into ASN.1 IdentityList_t
  48. *
  49. * @param list[in] identity_list to convert
  50. * @param result[inout] IdentityList_t to update or NULL to alloc a new one
  51. *
  52. * @retval pointer to updated or allocated result
  53. *
  54. * @warning if a new struct is allocated, the ownership goes to the caller
  55. *
  56. */
  57. IdentityList_t *IdentityList_from_identity_list(
  58. const identity_list *list,
  59. IdentityList_t *result
  60. );
  61. /**
  62. * <!-- IdentityList_to_identity_list() -->
  63. *
  64. * @brief Convert ASN.1 IdentityList_t to identity_list_t
  65. *
  66. * @param list[in] ASN.1 IdentityList_t to convert
  67. * @param result[inout] identity_list_t to update or NULL to alloc a new one
  68. *
  69. * @retval pointer to updated or allocated result
  70. *
  71. * @warning if a new struct is allocated, the ownership goes to the caller
  72. *
  73. */
  74. identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list *result);
  75. /**
  76. * <!-- StringPair_from_Struct() -->
  77. *
  78. * @brief Convert stringpair_t into ASN.1 StringPair_t
  79. *
  80. * @param value[in] stringpair_t to convert
  81. * @param result[in,out] StringPair_t to update or NULL to alloc a new one
  82. *
  83. * @retval pointer to updated or allocated result
  84. *
  85. * @warning if a new struct is allocated, the ownership goes to the caller
  86. *
  87. */
  88. StringPair_t *StringPair_from_Struct(
  89. const stringpair_t *value,
  90. StringPair_t *result
  91. );
  92. /**
  93. * <!-- StringPair_to_Struct() -->
  94. *
  95. * @brief Convert ASN.1 StringPair_t into stringpair_t
  96. *
  97. * @param value[in] StringPair_t to convert
  98. *
  99. * @retval pointer to updated or allocated result
  100. *
  101. * @warning a new struct is allocated, the ownership goes to the caller
  102. *
  103. */
  104. stringpair_t *StringPair_to_Struct(StringPair_t *value);
  105. /**
  106. * <!-- StringPairList_from_stringpair_list() -->
  107. *
  108. * @brief Convert stringpair_list_t into ASN.1 StringPairList_t
  109. *
  110. * @param list[in] stringpair_list to convert
  111. * @param result[inout] StringPairList_t to update or NULL to alloc a new one
  112. *
  113. * @retval pointer to updated or allocated result
  114. *
  115. * @warning if a new struct is allocated, the ownership goes to the caller
  116. *
  117. */
  118. StringPairList_t *StringPairList_from_stringpair_list(
  119. const stringpair_list_t *list,
  120. StringPairList_t *result
  121. );
  122. /**
  123. * <!-- StringPairList_to_stringpair_list() -->
  124. *
  125. * @brief Convert ASN.1 StringPairList_t to stringpair_list_t
  126. *
  127. * @param list[in] ASN.1 StringPairList_t to convert
  128. * @param result[inout] stringpair_list_t to update or NULL to alloc a new one
  129. *
  130. * @retval pointer to updated or allocated result
  131. *
  132. * @warning if a new struct is allocated, the ownership goes to the caller
  133. *
  134. */
  135. stringpair_list_t *StringPairList_to_stringpair_list(
  136. StringPairList_t *list,
  137. stringpair_list_t *result
  138. );
  139. /**
  140. * <!-- PStringList_from_stringlist() -->
  141. *
  142. * @brief Convert stringlist_t into ASN.1 PStringList_t
  143. *
  144. * @param list[in] stringlist to convert
  145. * @param result[inout] PStringList_t to update or NULL to alloc a new one
  146. *
  147. * @retval pointer to updated or allocated result
  148. *
  149. * @warning if a new struct is allocated, the ownership goes to the caller
  150. *
  151. */
  152. PStringList_t *PStringList_from_stringlist(
  153. const stringlist_t *list,
  154. PStringList_t *result
  155. );
  156. /**
  157. * <!-- PStringList_to_stringlist() -->
  158. *
  159. * @brief Convert ASN.1 PStringList_t to stringlist_t
  160. *
  161. * @param list[in] ASN.1 PStringList_t to convert
  162. *
  163. * @retval pointer to updated or allocated result
  164. *
  165. * @warning a new struct is allocated, the ownership goes to the caller
  166. *
  167. */
  168. stringlist_t *PStringList_to_stringlist(PStringList_t *list);
  169. /**
  170. * <!-- BlobList_from_bloblist() -->
  171. *
  172. * @brief Convert bloblist_t into ASN.1 BlobList_t
  173. *
  174. * @param list[in] bloblist to convert
  175. * @param result[inout] BlobList_t to update or NULL to alloc a new one
  176. * @param copy copy data if true, move data otherwise
  177. * @param max_blob_size reject if sum(blob.size) > max_blob_size
  178. * to disable set to 0
  179. *
  180. * @retval pointer to updated or allocated result
  181. *
  182. * @warning if a new struct is allocated, the ownership goes to the caller
  183. *
  184. */
  185. BlobList_t *BlobList_from_bloblist(
  186. bloblist_t *list,
  187. BlobList_t *result,
  188. bool copy,
  189. size_t max_blob_size
  190. );
  191. /**
  192. * <!-- BlobList_to_bloblist() -->
  193. *
  194. * @brief Convert ASN.1 BlobList_t to bloblist_t
  195. *
  196. * @param list[in] ASN.1 BlobList_t to convert
  197. * @param result[inout] bloblist_t to update or NULL to alloc a new one
  198. * @param copy copy data if true, move data otherwise
  199. * @param max_blob_size reject if sum(blob.size) > max_blob_size
  200. * to disable set to 0
  201. *
  202. * @retval pointer to updated or allocated result
  203. *
  204. * @warning if a new struct is allocated, the ownership goes to the caller
  205. *
  206. */
  207. bloblist_t *BlobList_to_bloblist(
  208. BlobList_t *list,
  209. bloblist_t *result,
  210. bool copy,
  211. size_t max_blob_size
  212. );
  213. /**
  214. * <!-- PEPMessage_from_message() -->
  215. *
  216. * @brief Convert message into ASN.1 PEPMessage_t
  217. *
  218. * @param msg[in] message to convert
  219. * @param result[inout] PEPMessage_t to update or NULL to alloc a new one
  220. * @param copy copy data if true, move data otherwise
  221. * @param max_blob_size reject if sum(blob.size) > max_blob_size
  222. * to disable set to 0
  223. *
  224. * @retval pointer to updated or allocated result
  225. *
  226. * @warning if a new struct is allocated, the ownership goes to the caller
  227. *
  228. */
  229. PEPMessage_t *PEPMessage_from_message(
  230. message *msg,
  231. PEPMessage_t *result,
  232. bool copy,
  233. size_t max_blob_size
  234. );
  235. /**
  236. * <!-- PEPMessage_to_message() -->
  237. *
  238. * @brief Convert ASN.1 PEPMessage_t to message
  239. *
  240. * @param msg[in] ASN.1 PEPMessage_t to convert
  241. * @param result[inout] message to update or NULL to alloc a new one
  242. * @param copy copy data if true, move data otherwise
  243. * @param max_blob_size reject if sum(blob.size) > max_blob_size
  244. * to disable set to 0
  245. *
  246. * @retval pointer to updated or allocated result
  247. *
  248. * @warning if a new struct is allocated, the ownership goes to the caller
  249. *
  250. */
  251. message *PEPMessage_to_message(
  252. PEPMessage_t *msg,
  253. message *result,
  254. bool copy,
  255. size_t max_blob_size
  256. );
  257. #ifdef __cplusplus
  258. }
  259. #endif
  260. #endif