aboutsummaryrefslogtreecommitdiffstats
path: root/metis/ccnx/forwarder/metis/tlv/metis_TlvSkeleton.h
blob: 7e4eb603ee030a1e8f5a734dc44334505bbf4a04 (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
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
/*
 * Copyright (c) 2017 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 metis_TlvSkeleton.h
 * @brief The structure used to store the set of fields used by the forwarder
 *
 * The TLV skeleton is the parsed form of the packet.  It contains the TLV extents of each
 * field relevant to the forwarder.
 *
 * To use MetisTlvSkeleton, you first parse a packet in to the skeleton and can then access the various
 * TlvExtents from the getters.  The Tlv parsers use the Setters.
 *
 * The TlvSkeleton is not allocated memory (in general).  It is defined as a sized opaque struct so one
 * can use it as a member of another struct without deep allocations.  The general use is as shown in
 * the example below.
 *
 * @code
 * typedef struct my_data_s {
 *      unsigned id;
 *      MetisTlvSkeleton skeleton;
 * } MyData;
 *
 * void foo(uint8_t *packetBuffer)
 * {
 *    MyData *mydata = parcMemory_Allocate(sizeof(MyData));
 *    mydata->id = _global_id++;
 *    metisTlvSkeleton_Parse(&mydata->skeleton, packetBuffer);
 *    // now forward the packet using the data in the skeleton
 *    parcMemory_Deallocate(&mydata);
 * }
 *
 */

#ifndef Metis_metis_TlvSkeleton_h
#define Metis_metis_TlvSkeleton_h

#include <ccnx/forwarder/metis/tlv/metis_TlvExtent.h>
#include <ccnx/forwarder/metis/core/metis_Logger.h>

#define MetisTlvSkeleton_ArrayLength 12

/**
 * The MetisTlvSkeleton is an opaque object defined in the header so it
 * can be pre-allocated as part of another data structure.  The user should have
 * no direct access to any of the fields.
 */
typedef struct tlv_skeleton {
    void *field1;
    void *field2;
    void *field3;

    MetisTlvExtent array[MetisTlvSkeleton_ArrayLength];
} MetisTlvSkeleton;

// ===================================
// Setters

/**
 * Fills in the packet TLV skeleton
 *
 * Sets the skeleton's tlv operations to the correct value and sets the packet buffer.
 * Will call metisTlvSkeleton_Initialize().
 *
 * Because the MetisTlvSkeleton is meant to be allocated as part of a larger object, it does
 * not store its own reference to the logger, as there is no _Destroy or _Release method.  Therefore,
 * the caller must ensure the logger stays allocated for the lifetime of the skeleton.
 *
 * @param [in] packet Packet memory, pointing to byte 0 of the fixed header
 * @param [in] skeleton An allocated MetisTlvSkeleton to fill in
 * @param [in] logger The logger to use
 *
 * @retval true Good parse
 * @retval false Error
 *
 * Example:
 * @code
 * {
 *    MetisTlvSkeleton skeleton;
 *    bool success = metisTlvSkeleton_Parse(&skeleton, packet);
 * }
 * @endcode
 */
bool metisTlvSkeleton_Parse(MetisTlvSkeleton *skeleton, uint8_t *packet, MetisLogger *logger);

/**
 * Sets the Name extent
 *
 * Sets the name extent to the specified offset and length.
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    MetisTlvType *tlv = (MetisTlvType *) (packet + offset);
 *    uint16_t type = htons(tlv->type);
 *    uint16_t v_length = htons(tlv->length);
 *    offset += sizeof(MetisTlvType);
 *
 *    if (type == _ParserNameType) {
 *        metisTlvSkeleton_SetName(skeleton, offset, v_length);
 *    }
 * }
 * @endcode
 */
void metisTlvSkeleton_SetName(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Sets the KeyId extent
 *
 * For an Interest, the KeyId extent is the KeyIdRestriction.  For a ContentObject, it is
 * the KeyId in the Validation Algorithm.
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    MetisTlvType *tlv = (MetisTlvType *) (packet + offset);
 *    uint16_t type = htons(tlv->type);
 *    uint16_t v_length = htons(tlv->length);
 *    offset += sizeof(MetisTlvType);
 *
 *    if (type == _ParserKeyIdType) {
 *        metisTlvSkeleton_SetKeyId(skeleton, offset, v_length);
 *    }
 * }
 * @endcode
 */
void metisTlvSkeleton_SetKeyId(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/*
 * Sets the Certificate extent.
 *
 * In a ContentObject, in the Validation dependent data may contain a certificate.
 * Use this to set the extents of the certificate.
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the certificate.
 * @param [in] length The byte length of the certificate.
 */
void metisTlvSkeleton_SetCertificate(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/*
 * Sets the Public Key extent.
 *
 * In a ContentObject, in the Validation dependent data may contain a public key.
 * Use this to set the extents of the certificate.
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the public key.
 * @param [in] length The byte length of the public key.
 */
void metisTlvSkeleton_SetPublicKey(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Sets the Content Object Hash extent
 *
 * For an Interest, this is the Content Object hash restriction
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    MetisTlvType *tlv = (MetisTlvType *) (packet + offset);
 *    uint16_t type = htons(tlv->type);
 *    uint16_t v_length = htons(tlv->length);
 *    offset += sizeof(MetisTlvType);
 *
 *    if (type == _ParserKeyIdType) {
 *        metisTlvSkeleton_SetObjectHash(skeleton, offset, v_length);
 *    }
 * }
 * @endcode
 */
void metisTlvSkeleton_SetObjectHash(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Sets the Hop Limit extent
 *
 * For an Interest, the hoplimit is found in the fixed header (v1) or in a perhop header (v0)
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    // For a version 1 packet, point it to the field in the fixed header
 *    metisTlvSkeleton_SetHopLimit(skeleton, 4, 1);
 * }
 * @endcode
 */
void metisTlvSkeleton_SetHopLimit(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Sets the Interest Lifetime extent
 *
 * Sets the extent for the Interest lifetime
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    MetisTlvType *tlv = (MetisTlvType *) (packet + offset);
 *    uint16_t type = htons(tlv->type);
 *    uint16_t v_length = htons(tlv->length);
 *    offset += sizeof(MetisTlvType);
 *
 *    if (type == _ParserInterestLifetimeType) {
 *        metisTlvSkeleton_SetInterestLifetime(skeleton, offset, v_length);
 *    }
 * }
 * @endcode
 */
void metisTlvSkeleton_SetInterestLifetime(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Sets the Recommended Cache Time extent
 *
 * Sets the extent for the Recommended Cache Time for a Content Object
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    MetisTlvType *tlv = (MetisTlvType *) (packet + offset);
 *    uint16_t type = htons(tlv->type);
 *    uint16_t v_length = htons(tlv->length);
 *    offset += sizeof(MetisTlvType);
 *
 *    if (type == _ParserRecommendedCacheTimeType) {
 *        metisTlvSkeleton_SetCacheTimeHeader(skeleton, offset, v_length);
 *    }
 * }
 * @endcode
 */
void metisTlvSkeleton_SetCacheTimeHeader(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Sets the ExpiryTime extent
 *
 * Sets the extent for the Expiry Time for a Content Object
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    MetisTlvType *tlv = (MetisTlvType *) (packet + offset);
 *    uint16_t type = htons(tlv->type);
 *    uint16_t v_length = htons(tlv->length);
 *    offset += sizeof(MetisTlvType);
 *
 *    if (type == _ParserExpiryTimeType) {
 *        metisTlvSkeleton_SetExpiryTime(skeleton, offset, v_length);
 *    }
 * }
 * @endcode
 */
void metisTlvSkeleton_SetExpiryTime(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Sets the Control Plane Interface (CPI) extent
 *
 * Sets the extent for the CPI value.
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    MetisTlvType *tlv = (MetisTlvType *) (packet + offset);
 *    uint16_t type = htons(tlv->type);
 *    uint16_t v_length = htons(tlv->length);
 *    offset += sizeof(MetisTlvType);
 *
 *    if (type == _ParserControlType) {
 *        metisTlvSkeleton_SetCPI(skeleton, offset, v_length);
 *    }
 * }
 * @endcode
 */
void metisTlvSkeleton_SetCPI(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Sets the Fragment Payload extent
 *
 * This is the payload of the fragment, i.e. part of the original packet.
 *
 * @param [in] skeleton A MetisTlvSkeleton structure
 * @param [in] offset The byte offset of the beginning of the 'value'
 * @param [in] length The byte length of the 'value'
 *
 * Example:
 * @code
 * {
 *    MetisTlvType *tlv = (MetisTlvType *) (packet + offset);
 *    uint16_t type = htons(tlv->type);
 *    uint16_t v_length = htons(tlv->length);
 *    offset += sizeof(MetisTlvType);
 *
 *    if (type == _ParserFragmentPayloadType) {
 *        metisTlvSkeleton_SetFragmentPayload(skeleton, offset, v_length);
 *    }
 * }
 * @endcode
 */
void metisTlvSkeleton_SetFragmentPayload(MetisTlvSkeleton *skeleton, size_t offset, size_t length);

/**
 * Updates the HopLimit inside the packet buffer
 *
 * If the HopLimit extent is not metisTlvExtent_NotFound, it will update the specified location
 * with the new hoplimit.  The call will fail if the HopLimit extent is not exactly 1 byte.
 *
 * @param [in] skeleton A parsed MetisTlvSkeleton
 * @param [in] hoplimit The new value
 *
 * @retval true Updated
 * @retval false Not updated (likely was metisTlvExtent_NotFound)
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool metisTlvSkeleton_UpdateHopLimit(MetisTlvSkeleton *skeleton, uint8_t hoplimit);

void metisTlvSkeleton_SetPathLabel(MetisTlvSkeleton *skeleton, size_t offset, size_t length);
bool metisTlvSkeleton_UpdatePathLabel(MetisTlvSkeleton *opaque, uint8_t outFace);
bool metisTlvSkeleton_ResetPathLabel(MetisTlvSkeleton *opaque);

// ====================================
// Getters


MetisTlvExtent metisTlvSkeleton_GetPathLabel(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the Name
 *
 * Returns the previously set Name extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetName(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetName(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the KeyId
 *
 * Returns the previously set KeyId extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetKeyId(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetKeyId(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the Public Key.
 *
 * Returns the previously set Public Key extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetPublicKey(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetPublicKey(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the Certificate.
 *
 * Returns the previously set Certificate extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetCertificate(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetCertificate(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the Object Hash
 *
 * Returns the previously set Object hash extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetObjectHash(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetObjectHash(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the Hop Limit
 *
 * Returns the previously set Hop Limit extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetObjectHash(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetHopLimit(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the Interest Lifetime
 *
 * Returns the previously set Interest Lifetime extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetInterestLifetime(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetInterestLifetime(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the Recommended Cache Time
 *
 * Returns the previously set Recommended Cache Time extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetCacheTimeHeader(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetCacheTimeHeader(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the Expiry Time
 *
 * Returns the previously set Expiry Time extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetExpiryTime(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetExpiryTime(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the CPI payload
 *
 * Returns the previously set CPI payload extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetCPI(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetCPI(const MetisTlvSkeleton *skeleton);

/**
 * Returns the extent of the fragment payload
 *
 * Returns the previously set fragment payload extent or metisTlvExtent_NotFound if not set.
 *
 * @param [in] skeleton An initialized and parsed skeleton
 *
 * @retval {0,0} Not Present
 * @retval other The set value of the extent
 *
 * Example:
 * @code
 * {
 *    uint8_t *packet = // read from network
 *    MetisTlvSkeleton skeleton;
 *    if (metisTlvSkeleton_Parse(&skeleton, packet)) {
 *       MetisTlvExtent extent = metisTlvSkeleton_GetFragmentPayload(&skeleton);
 *    }
 * }
 * @endcode
 */
MetisTlvExtent metisTlvSkeleton_GetFragmentPayload(const MetisTlvSkeleton *skeleton);

/**
 * Returns the pointer to the packet buffer
 *
 * Returns pointer to byte 0 of the fixed header
 *
 * @param [in] skeleton A parsed MetisTlvSkeleton
 *
 * @retval non-null The packet buffer
 * @retval null An error
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
const uint8_t *metisTlvSkeleton_GetPacket(const MetisTlvSkeleton *skeleton);

/**
 * The total packet length based on the fixed header
 *
 * Parses the fixed header and returns the total packet length
 * Will return "0" for unknown packet version
 *
 * @param [in] packet Packet memory pointer
 *
 * @retval number Total packet length
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
size_t metisTlvSkeleton_TotalPacket(const MetisTlvSkeleton *skeleton);

/**
 * @function metisTlv_ComputeContentObjectHash
 * @abstract Computes the ContentObjectHash over a packet
 * @discussion
 *   <#Discussion#>
 *
 * @param <#param1#>
 * @return NULL if not a content object, otherwise the SHA256 hash
 */
PARCCryptoHash *metisTlvSkeleton_ComputeContentObjectHash(const MetisTlvSkeleton *skeleton);

/**
 * Determines if the packet type is Interest
 *
 * <#Paragraphs Of Explanation#>
 *
 * @param [in] packet Packet memory pointer
 *
 * @retval true It is an Interest
 * @retval false Not an Interest
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool metisTlvSkeleton_IsPacketTypeInterest(const MetisTlvSkeleton *skeleton);

/**
 * Determines if the packet type is Content Object
 *
 * <#Paragraphs Of Explanation#>
 *
 * @param [in] packet Packet memory pointer
 *
 * @retval true It is a ContentObject
 * @retval false Not a ContentObject
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool metisTlvSkeleton_IsPacketTypeContentObject(const MetisTlvSkeleton *skeleton);

/**
 * Determines if the packet type is Control
 *
 * <#Paragraphs Of Explanation#>
 *
 * @param [in] packet Packet memory pointer
 *
 * @retval true It is a Control
 * @retval false Not a Control
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool metisTlvSkeleton_IsPacketTypeControl(const MetisTlvSkeleton *skeleton);

/**
 * Determines if the packet type is InterestReturn
 *
 * <#Paragraphs Of Explanation#>
 *
 * @param [in] packet Packet memory pointer
 *
 * @retval true It is a InterestReturn
 * @retval false Not a InterestReturn
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool metisTlvSkeleton_IsPacketTypeInterestReturn(const MetisTlvSkeleton *skeleton);

/**
 * Determines if the packet type is HopByHop Fragment
 *
 * <#Paragraphs Of Explanation#>
 *
 * @param [in] packet Packet memory pointer
 *
 * @retval true It is a InterestReturn
 * @retval false Not a InterestReturn
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool metisTlvSkeleton_IsPacketTypeHopByHopFragment(const MetisTlvSkeleton *skeleton);

/**
 * Returns the logger associated with the skeleton
 *
 * Returns the logger the user passed to the skeleton, which may be NULL
 *
 * @param [in] skeleton An initialized skeleton
 *
 * @retval non-null An allocated logger
 * @retval null No logger associated with skeleton
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
MetisLogger *metisTlvSkeleton_GetLogger(const MetisTlvSkeleton *skeleton);
#endif // Metis_metis_TlvSkeleton_h