tlv.h File Reference
`#include <gwenhywfar/buffer.h>`
`#include <gwenhywfar/misc.h>`
`#include <gwenhywfar/db.h>`

Go to the source code of this file.

## Typedefs

typedef struct GWEN_TLV | GWEN_TLV

## Functions

GWENHYWFAR_API int | GWEN_TLV_Buffer_To_DB (GWEN_DB_NODE *dbRecord, GWEN_BUFFER *mbuf, int len)
GWENHYWFAR_API GWEN_TLV * | GWEN_TLV_create (unsigned int tagType, unsigned int tagMode, const void *p, unsigned int dlen, int isBerTlv)
GWENHYWFAR_API int | GWEN_TLV_DirectlyToBuffer (unsigned int tagType, unsigned int tagMode, const void *tagData, int tagLength, int isBerTlv, GWEN_BUFFER *mbuf)
GWENHYWFAR_API void | GWEN_TLV_free (GWEN_TLV *tlv)
GWENHYWFAR_API GWEN_TLV * | GWEN_TLV_fromBuffer (GWEN_BUFFER *mbuf, int isBerTlv)
GWENHYWFAR_API unsigned int | GWEN_TLV_GetClass (const GWEN_TLV *tlv)
GWENHYWFAR_API const void * | GWEN_TLV_GetTagData (const GWEN_TLV *tlv)
GWENHYWFAR_API unsigned int | GWEN_TLV_GetTagLength (const GWEN_TLV *tlv)
GWENHYWFAR_API unsigned int | GWEN_TLV_GetTagSize (const GWEN_TLV *tlv)
GWENHYWFAR_API unsigned int | GWEN_TLV_GetTagType (const GWEN_TLV *tlv)
GWENHYWFAR_API int | GWEN_TLV_IsBerTlv (const GWEN_TLV *tlv)
GWENHYWFAR_API int | GWEN_TLV_IsContructed (const GWEN_TLV *tlv)
GWENHYWFAR_API GWEN_TLV * | GWEN_TLV_new (void)
GWENHYWFAR_API uint32_t | GWEN_TLV_ParseLength (GWEN_BUFFER *mbuf, uint32_t *tag_len_len)
GWENHYWFAR_API int | GWEN_TLV_ReadHeader (GWEN_TLV *tlv, const uint8_t *p, uint32_t size, int isBerTlv)
GWENHYWFAR_API int | GWEN_TLV_toBuffer (GWEN_TLV *tlv, GWEN_BUFFER *mbuf)
GWENHYWFAR_API int | GWEN_TLV_WriteHeader (unsigned int tagType, unsigned int tagMode, uint64_t tagLength, int isBerTlv, GWEN_BUFFER *mbuf)

## Typedef Documentation

## GWEN_TLV

typedef struct GWEN_TLV GWEN_TLV

Definition at line 19 of file tlv.h.

## Function Documentation

## GWEN_TLV_Buffer_To_DB()

GWENHYWFAR_API int GWEN_TLV_Buffer_To_DB | ( | GWEN_DB_NODE * | dbRecord,
|  | GWEN_BUFFER * | mbuf,
|  | int | len )

Directly parses a BER-TLV structure do a DB.

Returns
  number of bytes parsed

Parameters

  dbRecord | GWEN_DB database with the parsed TLV structure
  mbuf | buffer holding the TLV data
  len | length of the data in the buffer

References GWENHYWFAR_API.

## GWEN_TLV_create()

GWENHYWFAR_API GWEN_TLV * GWEN_TLV_create | ( | unsigned int | tagType,
|  | unsigned int | tagMode,
|  | const void * | p,
|  | unsigned int | dlen,
|  | int | isBerTlv )

References GWENHYWFAR_API.

## GWEN_TLV_DirectlyToBuffer()

GWENHYWFAR_API int GWEN_TLV_DirectlyToBuffer | ( | unsigned int | tagType,
|  | unsigned int | tagMode,
|  | const void * | tagData,
|  | int | tagLength,
|  | int | isBerTlv,
|  | GWEN_BUFFER * | mbuf )

References GWENHYWFAR_API.

## GWEN_TLV_free()

GWENHYWFAR_API void GWEN_TLV_free | ( | GWEN_TLV * | tlv | ) |

References GWENHYWFAR_API.

## GWEN_TLV_fromBuffer()

GWENHYWFAR_API GWEN_TLV * GWEN_TLV_fromBuffer | ( | GWEN_BUFFER * | mbuf,
|  | int | isBerTlv )

References GWENHYWFAR_API.

## GWEN_TLV_GetClass()

GWENHYWFAR_API unsigned int GWEN_TLV_GetClass | ( | const GWEN_TLV * | tlv | ) |

References GWENHYWFAR_API.

## GWEN_TLV_GetTagData()

GWENHYWFAR_API const void * GWEN_TLV_GetTagData | ( | const GWEN_TLV * | tlv | ) |

References GWENHYWFAR_API.

## GWEN_TLV_GetTagLength()

GWENHYWFAR_API unsigned int GWEN_TLV_GetTagLength | ( | const GWEN_TLV * | tlv | ) |

References GWENHYWFAR_API.

## GWEN_TLV_GetTagSize()

GWENHYWFAR_API unsigned int GWEN_TLV_GetTagSize | ( | const GWEN_TLV * | tlv | ) |

References GWENHYWFAR_API.

## GWEN_TLV_GetTagType()

GWENHYWFAR_API unsigned int GWEN_TLV_GetTagType | ( | const GWEN_TLV * | tlv | ) |

References GWENHYWFAR_API.

## GWEN_TLV_IsBerTlv()

GWENHYWFAR_API int GWEN_TLV_IsBerTlv | ( | const GWEN_TLV * | tlv | ) |

References GWENHYWFAR_API.

## GWEN_TLV_IsContructed()

GWENHYWFAR_API int GWEN_TLV_IsContructed | ( | const GWEN_TLV * | tlv | ) |

References GWENHYWFAR_API.

## GWEN_TLV_new()

GWENHYWFAR_API GWEN_TLV * GWEN_TLV_new | ( | void |  | ) |

References GWENHYWFAR_API.

## GWEN_TLV_ParseLength()

GWENHYWFAR_API uint32_t GWEN_TLV_ParseLength | ( | GWEN_BUFFER * | mbuf,
|  | uint32_t * | tag_len_len )

Parses length of a BER-TLV structure.

Returns
  number of bytes including the tag itself

Parameters

  mbuf | buffer holding the TLV data
  tag_len_len | number of bytes used for tag identifier octets and length octets

## GWEN_TLV_ReadHeader()

GWENHYWFAR_API int GWEN_TLV_ReadHeader | ( | GWEN_TLV * | tlv,
|  | const uint8_t * | p,
|  | uint32_t | size,
|  | int | isBerTlv )

Reads a TLV header from a buffer (tag and length) and returns the number of bytes used by the header.

Returns
  number of bytes used to specify tag and length (i.e. TLV size without the data part)

Parameters

  tlv | TLV to read the header into
  p | pointer to a buffer containing at least the header
  size | siez of the buffer pointed to by p
  isBerTlv | if !=0 then the TLV is supposed to be a BER-TLV object

References GWENHYWFAR_API.

## GWEN_TLV_toBuffer()

GWENHYWFAR_API int GWEN_TLV_toBuffer | ( | GWEN_TLV * | tlv,
|  | GWEN_BUFFER * | mbuf )

References GWENHYWFAR_API.

## GWEN_TLV_WriteHeader()

GWENHYWFAR_API int GWEN_TLV_WriteHeader | ( | unsigned int | tagType,
|  | unsigned int | tagMode,
|  | uint64_t | tagLength,
|  | int | isBerTlv,
|  | GWEN_BUFFER * | mbuf )

Directly writes a TLV header (tag and length) to the given buffer.

Returns
  0 if ok, error code otherwise

Parameters

  tagType | tag id
  tagMode | bits 5, 6 and 7 of the first TLV byte (bits 6/7: class, bit 5: constructed)
  tagLength | length of the data part introduced by the TLV header
  isBerTlv | if !=0 then the TLV is supposed to be a BER-TLV object
  mbuf | buffer to receive the TLV header

References GWENHYWFAR_API.