scsl/TLV.h

49 lines
863 B
C
Raw Normal View History

2023-10-06 03:13:46 +00:00
#ifndef KIMODEM_TLV_H
#define KIMODEM_TLV_H
#include <cstdint>
#include "Arena.h"
#ifndef TLV_MAX_LEN
#define TLV_MAX_LEN 253
#endif
#define TAG_EMPTY 0
namespace TLV {
struct Record {
uint8_t Tag;
uint8_t Len;
char Val[TLV_MAX_LEN];
};
2023-10-06 06:08:35 +00:00
uint8_t *WriteToMemory(Arena &, uint8_t *, Record &);
void ReadFromMemory(Record &, uint8_t *);
void SetRecord(Record &, uint8_t, uint8_t, const char *);
void DeleteRecord(Arena &, uint8_t *);
2023-10-06 03:13:46 +00:00
2023-10-06 06:08:35 +00:00
/*
2023-10-06 03:13:46 +00:00
* returns a pointer to memory where the record was found,
2023-10-06 06:08:35 +00:00
* e.g. LocateTag(...)[0] is the tag of the found record.
* FindTag will call LocateTag and then SkipRecord if the
* tag was found.
2023-10-06 03:13:46 +00:00
*/
2023-10-06 06:08:35 +00:00
uint8_t *FindTag(Arena &, uint8_t *, Record &);
uint8_t *LocateTag(Arena &, uint8_t *, Record &);
uint8_t *FindEmpty(Arena &, uint8_t *);
uint8_t *SkipRecord(Record &, uint8_t *);
2023-10-06 03:13:46 +00:00
} // namespace TLV
#endif