1
2/*
3 * Copyright (c) 2002 Apple Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25#ifndef _EAP8021X_DIAMETERAVP_H
26#define _EAP8021X_DIAMETERAVP_H
27
28/*
29 * DiameterAVP.h
30 * - definitions for Diameter AVP's
31 */
32
33/*
34 * Modification History
35 *
36 * October 11, 2002	Dieter Siegmund (dieter@apple)
37 * - created
38 */
39typedef struct {
40    u_int32_t	AVP_code;
41    u_int32_t	AVP_flags_length;
42    u_char	AVP_data[0];
43} DiameterAVP;
44
45typedef struct {
46    u_int32_t	AVPV_code;
47    u_int32_t	AVPV_flags_length;
48    u_int32_t	AVPV_vendor;
49    u_char	AVPV_data[0];
50} DiameterVendorAVP;
51
52typedef enum {
53    kDiameterFlagsVendorSpecific = 0x80,
54    kDiameterFlagsMandatory = 0x40,
55} DiameterFlags;
56
57#define DIAMETER_LENGTH_MASK	0xffffff
58
59static __inline__ u_int32_t
60DiameterAVPMakeFlagsLength(u_int8_t flags, u_int32_t length)
61{
62    u_int32_t flags_length;
63
64    flags_length = (length & DIAMETER_LENGTH_MASK) | (flags << 24);
65    return (flags_length);
66}
67
68static __inline__ u_int32_t
69DiameterAVPLengthFromFlagsLength(u_int32_t flags_length)
70{
71    return (flags_length & DIAMETER_LENGTH_MASK);
72}
73
74static __inline__ u_int8_t
75DiameterAVPFlagsFromFlagsLength(u_int32_t flags_length)
76{
77    return (flags_length >> 24);
78}
79
80#endif /* _EAP8021X_DIAMETERAVP_H */
81