blob: e4986c6ea7ec88cdbd2e1c688678d723853e11d4 [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Chetan Gaonkercb122cc2016-05-10 10:58:34 -070017#!/usr/bin/env python
Chetan Gaonker7f4bf742016-05-04 15:56:08 -070018#
19# Definitions for RADIUS programs
20#
21# Copyright 2002 Miguel A.L. Paraz <mparaz@mparaz.com>
22#
23# This should only be used when testing modules.
24# Inside freeradius, the 'radiusd' Python module is created by the C module
25# and the definitions are automatically created.
26#
27# $Id: 02e9f237cc0df3d7be08413238e504b90bf59b1a $
28
29# from modules.h
30
31RLM_MODULE_REJECT = 0
32RLM_MODULE_FAIL = 1
33RLM_MODULE_OK = 2
34RLM_MODULE_HANDLED = 3
35RLM_MODULE_INVALID = 4
36RLM_MODULE_USERLOCK = 5
37RLM_MODULE_NOTFOUND = 6
38RLM_MODULE_NOOP = 7
39RLM_MODULE_UPDATED = 8
40RLM_MODULE_NUMCODES = 9
41
42
43# from radiusd.h
44L_DBG = 1
45L_AUTH = 2
46L_INFO = 3
47L_ERR = 4
48L_PROXY = 5
49L_CONS = 128
50
51OP={ '{':2, '}':3, '(':4, ')':5, ',':6, ';':7, '+=':8, '-=':9, ':=':10,
52 '=':11, '!=':12, '>=':13, '>':14, '<=':15, '<':16, '=~':17, '!~':18, '=*':19, '!*':20,
53 '==':21 , '#':22 }
54
55OP_TRY = (':=', '+=', '-=', '=' )
56
57def resolve(*lines):
58 tuples = []
59 for line in lines:
60 for op in OP_TRY:
61 arr = line.rsplit(op)
62 if len(arr)==2:
63 tuples.append((str(arr[0].strip()),OP[op],str(arr[1].strip())))
64 break
65 return tuple(tuples)
66
67# log function
68def radlog(level, msg):
69 import sys
70 sys.stdout.write(msg + '\n')
71
72 level = level
73
74