123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #ifndef EncodingScheme_H
- #define EncodingScheme_H
- #include "benc/Object.h"
- #include "memory/Allocator.h"
- #include "util/Linker.h"
- Linker_require("switch/EncodingScheme.c")
- #include <stdint.h>
- #include <stdbool.h>
- struct EncodingScheme_Form
- {
-
-
- uint16_t bitCount;
- uint16_t prefixLen;
- uint32_t prefix;
- };
- struct EncodingScheme
- {
- struct EncodingScheme_Form* forms;
- int count;
- };
- #define EncodingScheme_getFormNum_INVALID -1
- int EncodingScheme_getFormNum(struct EncodingScheme* scheme, uint64_t routeLabel);
- #define EncodingScheme_convertLabel_convertTo_CANNONICAL (-5000)
- #define EncodingScheme_convertLabel_INVALID (~((uint64_t)0))
- uint64_t EncodingScheme_convertLabel(struct EncodingScheme* scheme,
- uint64_t routeLabel,
- int convertTo);
- bool EncodingScheme_isSane(struct EncodingScheme* scheme);
- String* EncodingScheme_serialize(struct EncodingScheme* list,
- struct Allocator* alloc);
- struct EncodingScheme* EncodingScheme_deserialize(String* data,
- struct Allocator* alloc);
- struct EncodingScheme* EncodingScheme_defineFixedWidthScheme(int bitCount, struct Allocator* alloc);
- struct EncodingScheme* EncodingScheme_defineDynWidthScheme(struct EncodingScheme_Form* forms,
- int formCount,
- struct Allocator* alloc);
- #define EncodingScheme_clone(scheme, alloc) \
- EncodingScheme_defineDynWidthScheme((scheme)->forms, (scheme)->count, (alloc))
- static inline int EncodingScheme_formSize(const struct EncodingScheme_Form* form)
- {
- return form->bitCount + form->prefixLen;
- }
- int EncodingScheme_compare(struct EncodingScheme* a, struct EncodingScheme* b);
- #define EncodingScheme_equals(a,b) (!EncodingScheme_compare(a,b))
- struct EncodingScheme* EncodingScheme_fromList(List* scheme, struct Allocator* alloc);
- List* EncodingScheme_asList(struct EncodingScheme* list, struct Allocator* alloc);
- int EncodingScheme_isSelfRoute(struct EncodingScheme* scheme, uint64_t routeLabel);
- int EncodingScheme_isOneHop(struct EncodingScheme* scheme, uint64_t routeLabel);
- #define EncodingScheme_parseDirector_INVALID -1
- int EncodingScheme_parseDirector(struct EncodingScheme* scheme, uint64_t label);
- uint64_t EncodingScheme_serializeDirector(struct EncodingScheme* scheme, int number, int formNum);
- bool EncodingScheme_is358(struct EncodingScheme* scheme);
- #endif
|