diff options
Diffstat (limited to 'libosmocore/include/osmocore/tlv.h')
-rw-r--r-- | libosmocore/include/osmocore/tlv.h | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/libosmocore/include/osmocore/tlv.h b/libosmocore/include/osmocore/tlv.h index 4ae9f6c49..14c9910df 100644 --- a/libosmocore/include/osmocore/tlv.h +++ b/libosmocore/include/osmocore/tlv.h @@ -1,7 +1,7 @@ #ifndef _TLV_H #define _TLV_H -#include <sys/types.h> +#include <stdint.h> #include <string.h> #include <osmocore/msgb.h> @@ -26,7 +26,7 @@ #define TVLV_MAX_ONEBYTE 0x7f -static inline u_int16_t TVLV_GROSS_LEN(u_int16_t len) +static inline uint16_t TVLV_GROSS_LEN(uint16_t len) { if (len <= TVLV_MAX_ONEBYTE) return TLV_GROSS_LEN(len); @@ -36,16 +36,16 @@ static inline u_int16_t TVLV_GROSS_LEN(u_int16_t len) /* TLV generation */ -static inline u_int8_t *lv_put(u_int8_t *buf, u_int8_t len, - const u_int8_t *val) +static inline uint8_t *lv_put(uint8_t *buf, uint8_t len, + const uint8_t *val) { *buf++ = len; memcpy(buf, val, len); return buf + len; } -static inline u_int8_t *tlv_put(u_int8_t *buf, u_int8_t tag, u_int8_t len, - const u_int8_t *val) +static inline uint8_t *tlv_put(uint8_t *buf, uint8_t tag, uint8_t len, + const uint8_t *val) { *buf++ = tag; *buf++ = len; @@ -53,8 +53,8 @@ static inline u_int8_t *tlv_put(u_int8_t *buf, u_int8_t tag, u_int8_t len, return buf + len; } -static inline u_int8_t *tlv16_put(u_int8_t *buf, u_int8_t tag, u_int8_t len, - const u_int16_t *val) +static inline uint8_t *tlv16_put(uint8_t *buf, uint8_t tag, uint8_t len, + const uint16_t *val) { *buf++ = tag; *buf++ = len; @@ -62,8 +62,8 @@ static inline u_int8_t *tlv16_put(u_int8_t *buf, u_int8_t tag, u_int8_t len, return buf + len*2; } -static inline u_int8_t *tl16v_put(u_int8_t *buf, u_int8_t tag, u_int16_t len, - const u_int8_t *val) +static inline uint8_t *tl16v_put(uint8_t *buf, uint8_t tag, uint16_t len, + const uint8_t *val) { *buf++ = tag; *buf++ = len >> 8; @@ -72,10 +72,10 @@ static inline u_int8_t *tl16v_put(u_int8_t *buf, u_int8_t tag, u_int16_t len, return buf + len*2; } -static inline u_int8_t *tvlv_put(u_int8_t *buf, u_int8_t tag, u_int16_t len, - const u_int8_t *val) +static inline uint8_t *tvlv_put(uint8_t *buf, uint8_t tag, uint16_t len, + const uint8_t *val) { - u_int8_t *ret; + uint8_t *ret; if (len <= TVLV_MAX_ONEBYTE) { ret = tlv_put(buf, tag, len, val); @@ -86,30 +86,30 @@ static inline u_int8_t *tvlv_put(u_int8_t *buf, u_int8_t tag, u_int16_t len, return ret; } -static inline u_int8_t *msgb_tlv16_put(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int16_t *val) +static inline uint8_t *msgb_tlv16_put(struct msgb *msg, uint8_t tag, uint8_t len, const uint16_t *val) { - u_int8_t *buf = msgb_put(msg, TLV16_GROSS_LEN(len)); + uint8_t *buf = msgb_put(msg, TLV16_GROSS_LEN(len)); return tlv16_put(buf, tag, len, val); } -static inline u_int8_t *msgb_tl16v_put(struct msgb *msg, u_int8_t tag, u_int16_t len, - const u_int8_t *val) +static inline uint8_t *msgb_tl16v_put(struct msgb *msg, uint8_t tag, uint16_t len, + const uint8_t *val) { - u_int8_t *buf = msgb_put(msg, TL16V_GROSS_LEN(len)); + uint8_t *buf = msgb_put(msg, TL16V_GROSS_LEN(len)); return tl16v_put(buf, tag, len, val); } -static inline u_int8_t *msgb_tvlv_put(struct msgb *msg, u_int8_t tag, u_int16_t len, - const u_int8_t *val) +static inline uint8_t *msgb_tvlv_put(struct msgb *msg, uint8_t tag, uint16_t len, + const uint8_t *val) { - u_int8_t *buf = msgb_put(msg, TVLV_GROSS_LEN(len)); + uint8_t *buf = msgb_put(msg, TVLV_GROSS_LEN(len)); return tvlv_put(buf, tag, len, val); } -static inline u_int8_t *msgb_l16tv_put(struct msgb *msg, u_int16_t len, u_int8_t tag, - const u_int8_t *val) +static inline uint8_t *msgb_l16tv_put(struct msgb *msg, uint16_t len, uint8_t tag, + const uint8_t *val) { - u_int8_t *buf = msgb_put(msg, L16TV_GROSS_LEN(len)); + uint8_t *buf = msgb_put(msg, L16TV_GROSS_LEN(len)); *buf++ = len >> 8; *buf++ = len & 0xff; @@ -118,14 +118,14 @@ static inline u_int8_t *msgb_l16tv_put(struct msgb *msg, u_int16_t len, u_int8_t return buf + len; } -static inline u_int8_t *v_put(u_int8_t *buf, u_int8_t val) +static inline uint8_t *v_put(uint8_t *buf, uint8_t val) { *buf++ = val; return buf; } -static inline u_int8_t *tv_put(u_int8_t *buf, u_int8_t tag, - u_int8_t val) +static inline uint8_t *tv_put(uint8_t *buf, uint8_t tag, + uint8_t val) { *buf++ = tag; *buf++ = val; @@ -133,8 +133,8 @@ static inline u_int8_t *tv_put(u_int8_t *buf, u_int8_t tag, } /* 'val' is still in host byte order! */ -static inline u_int8_t *tv16_put(u_int8_t *buf, u_int8_t tag, - u_int16_t val) +static inline uint8_t *tv16_put(uint8_t *buf, uint8_t tag, + uint16_t val) { *buf++ = tag; *buf++ = val >> 8; @@ -142,59 +142,59 @@ static inline u_int8_t *tv16_put(u_int8_t *buf, u_int8_t tag, return buf; } -static inline u_int8_t *msgb_lv_put(struct msgb *msg, u_int8_t len, const u_int8_t *val) +static inline uint8_t *msgb_lv_put(struct msgb *msg, uint8_t len, const uint8_t *val) { - u_int8_t *buf = msgb_put(msg, LV_GROSS_LEN(len)); + uint8_t *buf = msgb_put(msg, LV_GROSS_LEN(len)); return lv_put(buf, len, val); } -static inline u_int8_t *msgb_tlv_put(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int8_t *val) +static inline uint8_t *msgb_tlv_put(struct msgb *msg, uint8_t tag, uint8_t len, const uint8_t *val) { - u_int8_t *buf = msgb_put(msg, TLV_GROSS_LEN(len)); + uint8_t *buf = msgb_put(msg, TLV_GROSS_LEN(len)); return tlv_put(buf, tag, len, val); } -static inline u_int8_t *msgb_tv_put(struct msgb *msg, u_int8_t tag, u_int8_t val) +static inline uint8_t *msgb_tv_put(struct msgb *msg, uint8_t tag, uint8_t val) { - u_int8_t *buf = msgb_put(msg, 2); + uint8_t *buf = msgb_put(msg, 2); return tv_put(buf, tag, val); } -static inline u_int8_t *msgb_v_put(struct msgb *msg, u_int8_t val) +static inline uint8_t *msgb_v_put(struct msgb *msg, uint8_t val) { - u_int8_t *buf = msgb_put(msg, 1); + uint8_t *buf = msgb_put(msg, 1); return v_put(buf, val); } -static inline u_int8_t *msgb_tv16_put(struct msgb *msg, u_int8_t tag, u_int16_t val) +static inline uint8_t *msgb_tv16_put(struct msgb *msg, uint8_t tag, uint16_t val) { - u_int8_t *buf = msgb_put(msg, 3); + uint8_t *buf = msgb_put(msg, 3); return tv16_put(buf, tag, val); } -static inline u_int8_t *msgb_tlv_push(struct msgb *msg, u_int8_t tag, u_int8_t len, const u_int8_t *val) +static inline uint8_t *msgb_tlv_push(struct msgb *msg, uint8_t tag, uint8_t len, const uint8_t *val) { - u_int8_t *buf = msgb_push(msg, TLV_GROSS_LEN(len)); + uint8_t *buf = msgb_push(msg, TLV_GROSS_LEN(len)); return tlv_put(buf, tag, len, val); } -static inline u_int8_t *msgb_tv_push(struct msgb *msg, u_int8_t tag, u_int8_t val) +static inline uint8_t *msgb_tv_push(struct msgb *msg, uint8_t tag, uint8_t val) { - u_int8_t *buf = msgb_push(msg, 2); + uint8_t *buf = msgb_push(msg, 2); return tv_put(buf, tag, val); } -static inline u_int8_t *msgb_tv16_push(struct msgb *msg, u_int8_t tag, u_int16_t val) +static inline uint8_t *msgb_tv16_push(struct msgb *msg, uint8_t tag, uint16_t val) { - u_int8_t *buf = msgb_push(msg, 3); + uint8_t *buf = msgb_push(msg, 3); return tv16_put(buf, tag, val); } /* TLV parsing */ struct tlv_p_entry { - u_int16_t len; - const u_int8_t *val; + uint16_t len; + const uint8_t *val; }; enum tlv_type { @@ -209,7 +209,7 @@ enum tlv_type { struct tlv_def { enum tlv_type type; - u_int8_t fixed_len; + uint8_t fixed_len; }; struct tlv_definition { @@ -222,11 +222,11 @@ struct tlv_parsed { extern struct tlv_definition tvlv_att_def; -int tlv_parse_one(u_int8_t *o_tag, u_int16_t *o_len, const u_int8_t **o_val, +int tlv_parse_one(uint8_t *o_tag, uint16_t *o_len, const uint8_t **o_val, const struct tlv_definition *def, - const u_int8_t *buf, int buf_len); + const uint8_t *buf, int buf_len); int tlv_parse(struct tlv_parsed *dec, const struct tlv_definition *def, - const u_int8_t *buf, int buf_len, u_int8_t lv_tag, u_int8_t lv_tag2); + const uint8_t *buf, int buf_len, uint8_t lv_tag, uint8_t lv_tag2); /* take a master (src) tlvdev and fill up all empty slots in 'dst' */ void tlv_def_patch(struct tlv_definition *dst, const struct tlv_definition *src); |