2
* RADIUS tlv construction and parsing utilites
3
* Copyright (c) 2012, Painless Security, LLC
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation.
9
* Alternatively, this software may be distributed under the terms of BSD
12
* See README and COPYING for more details.
15
#ifndef RADIUS_UTILS_H
16
#define RADIUS_UTILS_H
19
struct radius_parser_struct;
20
typedef struct radius_parser_struct *radius_parser;
27
* Simple utility to add a single type-length-value attribute to a buffer.
28
* Currently, there is no dictionary support: 'type' and 'len' are always
29
* assumed to be octets, and data is placed directly into buf untranslated
30
* for byte order. If vendor is zero, len should be no greater than 253
31
* otherwise, no greater than 247.
32
* returns 0 on success, -1 on failure (allocation failure or len too large)
34
int radius_add_tlv(struct wpabuf **buf, u32 type, u32 vendor, u8 *data,
38
* simple radius parser
39
* Could be made considerably simpler by dropping support for parsing multiple
40
* sub-attributes from a vsa.
44
* create parser object
46
radius_parser radius_parser_start(void *tlvdata, size_t len);
50
* There is no dictionary support; if the tlv is a vsa (attribute 26),
51
* sub-attributes are not immediately parsed: instead, the raw data is returned
53
* returns 0 on success, -1 on failure (malformed buffer or end of buffer)
55
int radius_parser_parse_tlv(radius_parser parser, u8 *type, u32 *vendor_id,
56
void **value, size_t *len);
59
* parse a single sub-attribute of a vsa: assumes octets for
61
* returns 0 on success, -1 on failure (malformed buffer or end of buffer)
63
int radius_parser_parse_vendor_specific(radius_parser parser, u8 *vendor_type,
64
void **value, size_t *len);
67
* destroy parser object
69
void radius_parser_finish(radius_parser parser);
75
#endif /* RADIUS_UTILS_H */
b'\\ No newline at end of file'