aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/ops.h
blob: d56e6ae4a2d8996cc23c34036dbe570ffd5276ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
/*
 * Copyright (c) 2017-2019 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file base.h
 * @brief Protocol-independent packet operations
 */

#ifndef HICN_OPS_H
#define HICN_OPS_H

#include <stdlib.h>

#include "error.h"
#include "header.h"
#include "name.h"

/*
 * hICN operations on packets
 *
 * All prototypes take an hicn_type_t parameter as their first argument, as this
 * decides the sequence of protocols that are being used by the different
 * operations.
 */

typedef struct hicn_ops_s
{
    /** Protocol name */
  const char *name;

    /**
     * @brief Initialize the headers of the hicn packet
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the packet
     */
  int (*init_packet_header) (hicn_type_t type, hicn_protocol_t * h);

    /**
     * @brief Retrieves an Interest locator
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Interest packet
     * @param [out] ip_address - Retrieved locator
     * @return hICN error code
     */
  int (*get_interest_locator) (hicn_type_t type, const hicn_protocol_t * h,
			       ip46_address_t * ip_address);

    /**
     * @brief Sets an Interest locator
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest packet
     * @param [in] ip_address - Locator to set
     * @return hICN error code
     */
  int (*set_interest_locator) (hicn_type_t type, hicn_protocol_t * h,
			       const ip46_address_t * ip_address);

    /**
     * @brief Retrieves an Interest name
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Interest packet
     * @param [out] name - Retrieved name
     * @return hICN error code
     */
  int (*get_interest_name) (hicn_type_t type, const hicn_protocol_t * h,
			    hicn_name_t * name);

    /**
     * @brief Sets an Interest name
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest packet
     * @param [in] name - Name to set
     * @return hICN error code
     */
  int (*set_interest_name) (hicn_type_t type, hicn_protocol_t * h,
			    const hicn_name_t * name);

    /**
     * @brief Retrieves an Interest name suffix
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Interest packet
     * @param [out] suffix - Retrieved name suffix
     * @return hICN error code
     */
  int (*get_interest_name_suffix) (hicn_type_t type,
				   const hicn_protocol_t * h,
				   hicn_name_suffix_t * suffix);

    /**
     * @brief Sets an Interest name suffix
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest packet
     * @param [in] suffix - Name suffix to set
     * @return hICN error code
     */
  int (*set_interest_name_suffix) (hicn_type_t type, hicn_protocol_t * h,
				   const hicn_name_suffix_t * suffix);

    /**
     * @brief Clear the necessary Interest fields in order to hash it
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest packet
     * @return hICN error code
     */
  int (*reset_interest_for_hash) (hicn_type_t type, hicn_protocol_t * h);

    /**
     * @brief Retrieves a Data locator
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Data packet
     * @param [out] ip_address - Retrieved locator
     * @return hICN error code
     */
  int (*get_data_locator) (hicn_type_t type, const hicn_protocol_t * h,
			   ip46_address_t * ip_address);

    /**
     * @brief Sets a Data locator
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Data packet
     * @param [in] ip_address - Locator to set
     * @return hICN error code
     */
  int (*set_data_locator) (hicn_type_t type, hicn_protocol_t * h,
			   const ip46_address_t * ip_address);

    /**
     * @brief Retrieves a Data name
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Data packet
     * @param [out] name - Retrieved name
     * @return hICN error code
     */
  int (*get_data_name) (hicn_type_t type, const hicn_protocol_t * h,
			hicn_name_t * name);

    /**
     * @brief Sets a Data name
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Data packet
     * @param [in] name - Name to set
     * @return hICN error code
     */
  int (*set_data_name) (hicn_type_t type, hicn_protocol_t * h,
			const hicn_name_t * name);

    /**
     * @brief Retrieves a Data name suffix
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Data packet
     * @param [out] suffix - Retrieved name suffix
     * @return hICN error code
     */
  int (*get_data_name_suffix) (hicn_type_t type, const hicn_protocol_t * h,
			       hicn_name_suffix_t * suffix);

    /**
     * @brief Sets a Data name suffix
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Data packet
     * @param [in] suffix - Name suffix to set
     * @return hICN error code
     */
  int (*set_data_name_suffix) (hicn_type_t type, hicn_protocol_t * h,
			       const hicn_name_suffix_t * suffix);

    /**
     * @brief Retrieves a Data pathlabel
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Data packet
     * @param [out] pathlabel - Retrieved pathlabel
     * @return hICN error code
     */
  int (*get_data_pathlabel) (hicn_type_t type, const hicn_protocol_t * h,
			     u32 * pathlabel);

    /**
     * @brief Sets a Data pathlabel
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Data packet
     * @param [in] pathlabel - Pathlabel to set
     * @return hICN error code
     */
  int (*set_data_pathlabel) (hicn_type_t type, hicn_protocol_t * h,
			     const u32 pathlabel);

    /**
     * @brief Update a Data pathlabel with a new face identifier
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Data packet
     * @param [in] pathlabel - Face identifier used to update pathlabel
     * @return hICN error code
     */
  int (*update_data_pathlabel) (hicn_type_t type, hicn_protocol_t * h,
				const hicn_faceid_t face_id);

    /**
     * @brief Clear the necessary Data fields in order to hash it
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Data packet
     * @return hICN error code
     */
  int (*reset_data_for_hash) (hicn_type_t type, hicn_protocol_t * h);

    /**
     * @brief Retrieves an Interest or Data lifetime
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Interest or Data packet
     * @param [out] pathlabel - Retrieved lifetime
     * @return hICN error code
     */
  int (*get_lifetime) (hicn_type_t type, const hicn_protocol_t * h,
		       hicn_lifetime_t * lifetime);

    /**
     * @brief Sets an Interest or Data lifetime
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest or Data packet
     * @param [in] pathlabel - Lifetime to set
     * @return hICN error code
     */
  int (*set_lifetime) (hicn_type_t type, hicn_protocol_t * h,
		       const hicn_lifetime_t lifetime);

    /**
     * @brief Update all checksums in packet headers
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the packet
     * @param [in] partial_csum - Partial checksum (set to 0, used internally to
     *   carry intermediate values from IP pseudo-header)
     * @param [in] payload_length - Payload length (can be set to 0, retrieved
     *   and used internally to carry payload length across protocol headers)
     * @return hICN error code
     */
  int (*update_checksums) (hicn_type_t type, hicn_protocol_t * h,
			   u16 partial_csum, size_t payload_length);

    /**
     * @brief Validate all checksums in packet headers
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the packet
     * @param [in] partial_csum - Partial checksum (set to 0, used internally to
     *   carry intermediate values from IP pseudo-header)
     * @param [in] payload_length - Payload length (can be set to 0, retrieved
     *   and used internally to carry payload length across protocol headers)
     * @return hICN error code
     */
  int (*verify_checksums) (hicn_type_t type, hicn_protocol_t * h,
			   u16 partial_csum, size_t payload_length);

    /**
     * @brief Rewrite an Interest packet header (locator)
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Interest packet
     * @param [in] addr_new - New locator
     * @param [in] addr_old - Old locator (set to NULL, used internally to
     *   compute incremental checksums)
     * @return hICN error code
     */
  int (*rewrite_interest) (hicn_type_t type, hicn_protocol_t * h,
			   const ip46_address_t * addr_new,
			   ip46_address_t * addr_old);

    /**
     * @brief Rewrite a Data packet header (locator + pathlabel)
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Data packet
     * @param [in] addr_new - New locator
     * @param [in] addr_old - Old locator (set to NULL, used internally to
     *   compute incremental checksums)
     * @param [in] face_id - Face identifier used to update pathlabel
     * @return hICN error code
     */
  int (*rewrite_data) (hicn_type_t type, hicn_protocol_t * h,
		       const ip46_address_t * addr_new,
		       ip46_address_t * addr_old,
		       const hicn_faceid_t face_id);

    /**
     * @brief Return the packet length
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the packet
     * @parma [out] length - Returned packet length
     * @return hICN error code
     */
  int (*get_length) (hicn_type_t type, const hicn_protocol_t * h,
		     size_t * length);

    /**
     * @brief Return the current packet header length
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the packet
     * @parma [out] header_length - Returned packet current header length
     * @return hICN error code
     */
  int (*get_current_header_length) (hicn_type_t type,
				    const hicn_protocol_t * h,
				    size_t * header_length);

    /**
     * @brief Return the packet header length
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the packet
     * @parma [out] header_length - Returned packet header length
     * @return hICN error code
     */
  int (*get_header_length) (hicn_type_t type, const hicn_protocol_t * h,
			    size_t * header_length);

    /**
     * @brief Return the packet payload length
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the packet
     * @parma [out] payload_length - Returned packet payload length
     * @return hICN error code
     */
  int (*get_payload_length) (hicn_type_t type, const hicn_protocol_t * h,
			     size_t * payload_length);

    /**
     * @brief Sets the packet paylaod length
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the packet
     * @parma [out] payload_length - Payload length to set
     * @return hICN error code
     */
  int (*set_payload_length) (hicn_type_t type, hicn_protocol_t * h,
			     size_t payload_length);

    /**
     * @brief Retrieves an Interest or Data signature size
     * @param [in] type - hICN packet type
     * @param [in] h - Buffer holding the Interest or Data packet
     * @param [out] signature_size - Retrieved signature size
     * @return hICN error code
     */
  int (*get_signature_size) (hicn_type_t type, const hicn_protocol_t * h,
			     size_t * signature_size);

    /**
     * @brief Sets an Interest or Data signature size
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest or Data packet
     * @param [in] signature_size - Signature size to set
     * @return hICN error code
     */
  int (*set_signature_size) (hicn_type_t type, hicn_protocol_t * h,
			     size_t signature_size);

    /**
     * @brief Sets the signature timestamp
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest or Data packet
     * @param [in] signature_timestamp - Signature timestamp to set
     * @return hICN error code
     */
  int (*set_signature_timestamp) (hicn_type_t type, hicn_protocol_t * h,
                 uint64_t signature_timestamp);

    /**
     * @brief Gets the signature timestamp
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest or Data packet
     * @param [out] signature_timestamp - Retrieved signature timestamp
     * @return hICN error code
     */
  int (*get_signature_timestamp) (hicn_type_t type, const hicn_protocol_t * h,
                 uint64_t *signature_timestamp);

    /**
     * @brief Sets the signature validation algorithm
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest or Data packet
     * @param [in] validation_algorithm - Validation algorithm enumeration
     * @return hICN error code
     */
  int (*set_validation_algorithm) (hicn_type_t type, hicn_protocol_t * h,
                 uint8_t validation_algorithm);

    /**
     * @brief Gets the signature validation algorithm
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest or Data packet
     * @param [out] validation_algorithm - Retrieved validation_algorithm
     * @return hICN error code
     */
  int (*get_validation_algorithm) (hicn_type_t type, const hicn_protocol_t * h,
                 uint8_t *validation_algorithm);

    /**
     * @brief Sets the key id
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest or Data packet
     * @param [in] key_id - Key id first byte address
     * @return hICN error code
     */
  int (*set_key_id) (hicn_type_t type, hicn_protocol_t * h,
                 uint8_t *key_id);

    /**
     * @brief Gets the key id
     * @param [in] type - hICN packet type
     * @param [in,out] h - Buffer holding the Interest or Data packet
     * @param [out] key_id - Retrieved key id first byte address
     * @return hICN error code
     */
  int (*get_key_id) (hicn_type_t type, hicn_protocol_t * h,
                 uint8_t **key_id, uint8_t *key_id_size);

} hicn_ops_t;

#define DECLARE_HICN_OPS(protocol)                                              \
    const hicn_ops_t hicn_ops_ ## protocol = {                                  \
        .init_packet_header       = protocol ## _init_packet_header,            \
        .get_interest_locator     = protocol ## _get_interest_locator,          \
        .set_interest_locator     = protocol ## _set_interest_locator,          \
        .get_interest_name        = protocol ## _get_interest_name,             \
        .set_interest_name        = protocol ## _set_interest_name,             \
        .get_interest_name_suffix = protocol ## _get_interest_name_suffix,      \
        .set_interest_name_suffix = protocol ## _set_interest_name_suffix,      \
        .reset_interest_for_hash  = protocol ## _reset_interest_for_hash,       \
        .get_data_locator         = protocol ## _get_data_locator,              \
        .set_data_locator         = protocol ## _set_data_locator,              \
        .get_data_name            = protocol ## _get_data_name,                 \
        .set_data_name            = protocol ## _set_data_name,                 \
        .get_data_name_suffix     = protocol ## _get_data_name_suffix,          \
        .set_data_name_suffix     = protocol ## _set_data_name_suffix,          \
        .get_data_pathlabel       = protocol ## _get_data_pathlabel,            \
        .set_data_pathlabel       = protocol ## _set_data_pathlabel,            \
        .update_data_pathlabel    = protocol ## _update_data_pathlabel,         \
        .reset_data_for_hash      = protocol ## _reset_data_for_hash,           \
        .get_lifetime             = protocol ## _get_lifetime,                  \
        .set_lifetime             = protocol ## _set_lifetime,                  \
        .update_checksums         = protocol ## _update_checksums,              \
        .verify_checksums         = protocol ## _verify_checksums,              \
        .rewrite_interest         = protocol ## _rewrite_interest,              \
        .rewrite_data             = protocol ## _rewrite_data,                  \
        .get_length               = protocol ## _get_length,                    \
        .get_current_header_length= protocol ## _get_current_header_length,     \
        .get_header_length        = protocol ## _get_header_length,             \
        .get_payload_length       = protocol ## _get_payload_length,            \
        .set_payload_length       = protocol ## _set_payload_length,            \
        .get_signature_size       = protocol ## _get_signature_size,            \
        .set_signature_size       = protocol ## _set_signature_size,            \
        .set_signature_timestamp  = protocol ## _set_signature_timestamp,       \
        .get_signature_timestamp  = protocol ## _get_signature_timestamp,       \
        .set_validation_algorithm = protocol ## _set_validation_algorithm,      \
        .get_validation_algorithm = protocol ## _get_validation_algorithm,      \
        .set_key_id               = protocol ## _set_key_id,                    \
        .get_key_id               = protocol ## _get_key_id,                    \
    }

/**
 * @brief Protocol-independent packet operations VFT
 * NOTE: The following declarations should be kept in order
 */
extern const hicn_ops_t *const hicn_ops_vft[];

/*
 * Helpers for writing recursive protocol operations on packet headers
 *
 * NOTE : we cannot use a shift operation as IPPROTO_NONE != 0 (and 0 is IPv4...)
 */
always_inline hicn_type_t
TYPE_POP (hicn_type_t type)
{
  return (hicn_type_t)
  {
    {
    .l1 = type.l2,.l2 = type.l3,.l3 = type.l4,.l4 = IPPROTO_NONE,}
  };
}

always_inline hicn_protocol_t *
PAYLOAD (hicn_type_t type, const hicn_protocol_t * h)
{
  size_t header_length;
  int rc = hicn_ops_vft[type.l1]->get_current_header_length (type, h,
							     &header_length);
  if (rc < 0)
    return NULL;
  return (hicn_protocol_t *) ((u8 *) h + header_length);
}

#define CHILD_OPS(f, type, h, ...) (hicn_ops_vft[type.l2]->f(TYPE_POP(type), PAYLOAD(type, h), ## __VA_ARGS__))

/** Shortcuts to entry points in VFT */
#define HICN_OPS4 hicn_ops_vft[IPPROTO_IP]
#define HICN_OPS6 hicn_ops_vft[IPPROTO_IPV6]

/* Helpers for simple declarations */

#define DECLARE_init_packet_header(protocol, error) \
    int protocol ## _init_packet_header(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_interest_locator(protocol, error) \
    int protocol ## _get_interest_locator(hicn_type_t type, const hicn_protocol_t * h, ip46_address_t * ip_address) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_interest_locator(protocol, error) \
    int protocol ## _set_interest_locator(hicn_type_t type, hicn_protocol_t * h, const ip46_address_t * ip_address) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_interest_name(protocol, error) \
    int protocol ## _get_interest_name(hicn_type_t type, const hicn_protocol_t * h, hicn_name_t * name) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_interest_name(protocol, error) \
    int protocol ## _set_interest_name(hicn_type_t type, hicn_protocol_t * h, const hicn_name_t * name) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_interest_name_suffix(protocol, error) \
    int protocol ## _get_interest_name_suffix(hicn_type_t type, const hicn_protocol_t * h, hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_interest_name_suffix(protocol, error) \
    int protocol ## _set_interest_name_suffix(hicn_type_t type, hicn_protocol_t * h, const hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_reset_interest_for_hash(protocol, error) \
    int protocol ## _reset_interest_for_hash(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_data_locator(protocol, error) \
    int protocol ## _get_data_locator(hicn_type_t type, const hicn_protocol_t * h, ip46_address_t * ip_address) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_data_locator(protocol, error) \
    int protocol ## _set_data_locator(hicn_type_t type, hicn_protocol_t * h, const ip46_address_t * ip_address) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_data_name(protocol, error) \
    int protocol ## _get_data_name(hicn_type_t type, const hicn_protocol_t * h, hicn_name_t * name) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_data_name(protocol, error) \
    int protocol ## _set_data_name(hicn_type_t type, hicn_protocol_t * h, const hicn_name_t * name) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_data_name_suffix(protocol, error) \
    int protocol ## _get_data_name_suffix(hicn_type_t type, const hicn_protocol_t * h, hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_data_name_suffix(protocol, error) \
    int protocol ## _set_data_name_suffix(hicn_type_t type, hicn_protocol_t * h, const hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_data_pathlabel(protocol, error) \
    int protocol ## _get_data_pathlabel(hicn_type_t type, const hicn_protocol_t * h, u32 * pathlabel) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_data_pathlabel(protocol, error) \
    int protocol ## _set_data_pathlabel(hicn_type_t type, hicn_protocol_t * h, const u32 pathlabel) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_update_data_pathlabel(protocol, error) \
    int protocol ## _update_data_pathlabel(hicn_type_t type, hicn_protocol_t * h, const hicn_faceid_t face_id) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_reset_data_for_hash(protocol, error) \
    int protocol ## _reset_data_for_hash(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_lifetime(protocol, error) \
    int protocol ## _get_lifetime(hicn_type_t type, const hicn_protocol_t * h, hicn_lifetime_t * lifetime) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_lifetime(protocol, error) \
    int protocol ## _set_lifetime(hicn_type_t type, hicn_protocol_t * h, const hicn_lifetime_t lifetime) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_update_checksums(protocol, error) \
    int protocol ## _update_checksums(hicn_type_t type, hicn_protocol_t * h, u16 partial_csum, size_t payload_length) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_verify_checksums(protocol, error) \
    int protocol ## _verify_checksums(hicn_type_t type, hicn_protocol_t * h, u16 partial_csum, size_t payload_length) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_rewrite_interest(protocol, error) \
    int protocol ## _rewrite_interest(hicn_type_t type, hicn_protocol_t * h, const ip46_address_t * addr_new, ip46_address_t * addr_old) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_rewrite_data(protocol, error) \
    int protocol ## _rewrite_data(hicn_type_t type, hicn_protocol_t * h, const ip46_address_t * addr_new, ip46_address_t * addr_old, const hicn_faceid_t face_id) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_length(protocol, error) \
    int protocol ## _get_length(hicn_type_t type, const hicn_protocol_t * h, size_t * length) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_current_header_length(protocol, error) \
    int protocol ## _get_current_header_length(hicn_type_t type, const hicn_protocol_t * h, size_t * header_length) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_header_length(protocol, error) \
    int protocol ## _get_header_length(hicn_type_t type, const hicn_protocol_t * h, size_t * header_length) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_payload_length(protocol, error) \
    int protocol ## _get_payload_length(hicn_type_t type, const hicn_protocol_t * h, size_t * payload_length) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_payload_length(protocol, error) \
    int protocol ## _set_payload_length(hicn_type_t type, hicn_protocol_t * h, size_t payload_length) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_signature_size(protocol, error) \
    int protocol ## _get_signature_size(hicn_type_t type, const hicn_protocol_t * h, size_t * signature_size) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_signature_size(protocol, error) \
    int protocol ## _set_signature_size(hicn_type_t type, hicn_protocol_t * h, size_t signature_size) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_signature_timestamp(protocol, error) \
    int protocol ## _set_signature_timestamp(hicn_type_t type, hicn_protocol_t * h, uint64_t signature_timestamp) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_signature_timestamp(protocol, error) \
    int protocol ## _get_signature_timestamp(hicn_type_t type, const hicn_protocol_t * h, uint64_t * signature_timestamp) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_validation_algorithm(protocol, error) \
    int protocol ## _set_validation_algorithm(hicn_type_t type, hicn_protocol_t * h, uint8_t validation_algorithm) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_validation_algorithm(protocol, error) \
    int protocol ## _get_validation_algorithm(hicn_type_t type, const hicn_protocol_t * h, uint8_t * validation_algorithm) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_set_key_id(protocol, error) \
    int protocol ## _set_key_id(hicn_type_t type, hicn_protocol_t * h, uint8_t * key_id) { return HICN_LIB_ERROR_ ## error ; }

#define DECLARE_get_key_id(protocol, error) \
    int protocol ## _get_key_id(hicn_type_t type, hicn_protocol_t * h, uint8_t ** key_id, uint8_t *key_id_size) { return HICN_LIB_ERROR_ ## error ; }

#endif /* HICN_OPS_H */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */