l2tpd_packet: add avpp_val_u8()

to complete api for avpp
This commit is contained in:
Alexander Couzens 2016-10-25 15:58:42 +02:00 committed by Harald Welte
parent 7471a6c65d
commit 500c6cd750
1 changed files with 13 additions and 0 deletions

View File

@ -141,6 +141,19 @@ int avpp_val_u16(struct avps_parsed *avps, uint16_t vendor_id, uint16_t type,
return 0;
}
int avpp_val_u8(struct avps_parsed *avps, uint16_t vendor_id, uint16_t type,
uint8_t *u8)
{
struct avp_parsed *avp = avps_parsed_find(avps, vendor_id, type);
if (!avp)
return -ENODEV;
if (avp->data_len < sizeof(*u8))
return -EINVAL;
*u8 = *((uint8_t *)avp->data);
return 0;
}
/* store an AVP at the end of the msg */
static int msgb_avp_put(struct msgb *msg, uint16_t vendor_id, uint16_t type,
const uint8_t *data, uint16_t data_len, bool m_flag)