blob: db84fbd7d8e449c018b4563f6f029036ee6118ce [file] [log] [blame]
Brian Waters13d96012017-12-08 16:53:31 -06001/*********************************************************************************************************
2* Software License Agreement (BSD License) *
3* Author: Sebastien Decugis <sdecugis@freediameter.net> *
4* *
5* Copyright (c) 2011, WIDE Project and NICT *
6* All rights reserved. *
7* *
8* Redistribution and use of this software in source and binary forms, with or without modification, are *
9* permitted provided that the following conditions are met: *
10* *
11* * Redistributions of source code must retain the above *
12* copyright notice, this list of conditions and the *
13* following disclaimer. *
14* *
15* * Redistributions in binary form must reproduce the above *
16* copyright notice, this list of conditions and the *
17* following disclaimer in the documentation and/or other *
18* materials provided with the distribution. *
19* *
20* * Neither the name of the WIDE Project or NICT nor the *
21* names of its contributors may be used to endorse or *
22* promote products derived from this software without *
23* specific prior written permission of WIDE Project and *
24* NICT. *
25* *
26* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
27* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
28* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
29* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
30* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
31* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
32* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
33* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
34*********************************************************************************************************/
35
36/* RADIUS translation plugin, to handle specific RADIUS attributes by either caching them and
37adding them to a corresponding RADIUS reply, or just dropping the attributes (no conversion to Diameter) */
38/* This extension is a kind of swiss army-knife for interoperability, must be used with care.
39 All attribute behaviors are specified through the configuration file of the extension
40 */
41
42#include "rgw_common.h"
43
44/* Action associated with an attribute */
45#define ACT_ECHO 1
46#define ACT_DROP 2
47
48/* Result of configuration parsing */
49struct rgwp_config {
50 /* list of attributes and associated actions */
51 struct fd_list attributes;
52
53 /* Handler to store the echo'ed attributes values */
54 struct session_handler * sess_hdl;
55};
56
57/* An item of the attribute list */
58struct ed_conf_attribute {
59 struct fd_list chain; /* link in the list */
60
61 struct {
62 unsigned action :2; /* ACT_ECHO or ACT_DROP */
63 unsigned vsa :1; /* Interpret as Vendor-Specific, and match the vendor id in addition to the code */
64 unsigned tlv :1; /* Interpret as Vendor-Specific with TLV format, and match the type also */
65 unsigned ext :1; /* Interpret as radius extended attribute, and match the ext-type also */
66 };
67
68 uint32_t vendor_id; /* vendor id to match when vsa = 1 */
69 uint16_t extype; /* Ext-Type value to match if ext = 1 */
70 uint8_t type; /* Type value to match if tlv = 1; */
71
72 uint8_t code; /* The attribute code, the list is ordered by this value */
73};
74
75/* For ECHO items, we save a list of these in the session */
76struct ed_saved_attribute {
77 struct fd_list chain;
78 struct radius_attr_hdr attr; /* copy of the attribute */
79 /* The data of the attribute follows ... */
80};
81
82
83/* The yacc parser */
84int ed_conffile_parse(char * conffile, struct rgwp_config *cs);