~ubuntu-branches/ubuntu/vivid/moonshot-gss-eap/vivid

« back to all changes in this revision

Viewing changes to libeap/src/utils/radius_utils.h

  • Committer: Package Import Robot
  • Author(s): Sam Hartman
  • Date: 2014-09-16 08:38:39 UTC
  • Revision ID: package-import@ubuntu.com-20140916083839-ipqco3thb1wcwvs0
Tags: upstream-0.9.2
ImportĀ upstreamĀ versionĀ 0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * RADIUS tlv construction and parsing utilites
 
3
 * Copyright (c) 2012, Painless Security, LLC
 
4
 *
 
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.
 
8
 *
 
9
 * Alternatively, this software may be distributed under the terms of BSD
 
10
 * license.
 
11
 *
 
12
 * See README and COPYING for more details.
 
13
 */
 
14
 
 
15
#ifndef RADIUS_UTILS_H
 
16
#define RADIUS_UTILS_H
 
17
 
 
18
struct wpabuf;
 
19
struct radius_parser_struct;
 
20
typedef struct radius_parser_struct *radius_parser;
 
21
 
 
22
#ifdef __cplusplus
 
23
extern "C" {
 
24
#endif
 
25
 
 
26
/*
 
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)
 
33
 */
 
34
int radius_add_tlv(struct wpabuf **buf, u32 type, u32 vendor, u8 *data,
 
35
                   size_t len);
 
36
 
 
37
/*
 
38
 * simple radius parser
 
39
 * Could be made considerably simpler by dropping support for parsing multiple
 
40
 * sub-attributes from a vsa.
 
41
 */
 
42
 
 
43
/*
 
44
 * create parser object
 
45
 */
 
46
radius_parser radius_parser_start(void *tlvdata, size_t len);
 
47
 
 
48
/*
 
49
 * parse a single tlv;
 
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
 
52
 * in 'value'.
 
53
 * returns 0 on success, -1 on failure (malformed buffer or end of buffer)
 
54
 */
 
55
int radius_parser_parse_tlv(radius_parser parser, u8 *type, u32 *vendor_id,
 
56
                            void **value, size_t *len);
 
57
 
 
58
/*
 
59
 * parse a single sub-attribute of a vsa: assumes octets for
 
60
 * vendor_type and len
 
61
 * returns 0 on success, -1 on failure (malformed buffer or end of buffer)
 
62
 */
 
63
int radius_parser_parse_vendor_specific(radius_parser parser, u8 *vendor_type,
 
64
                                        void **value, size_t *len);
 
65
 
 
66
/*
 
67
 * destroy parser object
 
68
 */
 
69
void radius_parser_finish(radius_parser parser);
 
70
 
 
71
#ifdef __cplusplus
 
72
}
 
73
#endif
 
74
 
 
75
#endif /* RADIUS_UTILS_H */
 
 
b'\\ No newline at end of file'