2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
23 * @file abd/abd_serialization.h
24 * @brief API to serialize and deserialize delegation chains
26 * @author Martin Schanzenbach
28 #ifndef ABD_SERIALIZATION_H
29 #define ABD_SERIALIZATION_H
32 #include "gnunet_util_lib.h"
33 #include "gnunet_constants.h"
34 #include "gnunet_abd_service.h"
37 * Calculate how many bytes we will need to serialize
38 * the given delegation record
40 * @param ds_count number of delegation chain entries
41 * @param dsr array of #GNUNET_ABD_Delegation
42 * @return the required size to serialize
45 GNUNET_ABD_delegation_set_get_size (
46 unsigned int ds_count,
47 const struct GNUNET_ABD_DelegationSet *dsr);
50 * Serizalize the given delegation record entries
52 * @param d_count number of delegation chain entries
53 * @param dsr array of #GNUNET_ABD_Delegation
54 * @param dest_size size of the destination
55 * @param dest where to store the result
56 * @return the size of the data, -1 on failure
59 GNUNET_ABD_delegation_set_serialize (
61 const struct GNUNET_ABD_DelegationSet *dsr,
67 * Deserialize the given destination
69 * @param len size of the serialized delegation recird
70 * @param src the serialized data
71 * @param d_count the number of delegation chain entries
72 * @param dsr where to put the delegation chain entries
73 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
76 GNUNET_ABD_delegation_set_deserialize (
80 struct GNUNET_ABD_DelegationSet *dsr);
83 * Calculate how many bytes we will need to serialize
84 * the given delegation chain and abd
86 * @param d_count number of delegation chain entries
87 * @param dd array of #GNUNET_ABD_Delegation
88 * @param c_count number of abd entries
89 * @param cd a #GNUNET_ABD_Delegate
90 * @return the required size to serialize
93 GNUNET_ABD_delegation_chain_get_size (
95 const struct GNUNET_ABD_Delegation *dd,
97 const struct GNUNET_ABD_Delegate *cd);
100 * Serizalize the given delegation chain entries and abd
102 * @param d_count number of delegation chain entries
103 * @param dd array of #GNUNET_ABD_Delegation
104 * @param c_count number of abd entries
105 * @param cd a #GNUNET_ABD_Delegate
106 * @param dest_size size of the destination
107 * @param dest where to store the result
108 * @return the size of the data, -1 on failure
111 GNUNET_ABD_delegation_chain_serialize (
112 unsigned int d_count,
113 const struct GNUNET_ABD_Delegation *dd,
114 unsigned int c_count,
115 const struct GNUNET_ABD_Delegate *cd,
121 * Deserialize the given destination
123 * @param len size of the serialized delegation chain and cred
124 * @param src the serialized data
125 * @param d_count the number of delegation chain entries
126 * @param dd where to put the delegation chain entries
127 * @param c_count number of abd entries
128 * @param cd where to put the abd data
129 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
132 GNUNET_ABD_delegation_chain_deserialize (
135 unsigned int d_count,
136 struct GNUNET_ABD_Delegation *dd,
137 unsigned int c_count,
138 struct GNUNET_ABD_Delegate *cd);
141 GNUNET_ABD_delegates_get_size (
142 unsigned int c_count,
143 const struct GNUNET_ABD_Delegate *cd);
146 GNUNET_ABD_delegates_serialize (
147 unsigned int c_count,
148 const struct GNUNET_ABD_Delegate *cd,
154 GNUNET_ABD_delegates_deserialize (size_t len,
156 unsigned int c_count,
157 struct GNUNET_ABD_Delegate *cd);
160 GNUNET_ABD_delegate_serialize (struct GNUNET_ABD_Delegate *cred,
163 struct GNUNET_ABD_Delegate *
164 GNUNET_ABD_delegate_deserialize (const char *data, size_t data_size);
167 /* end of abd_serialization.h */