Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 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 Gaonker | cb122cc | 2016-05-10 10:58:34 -0700 | [diff] [blame] | 17 | #!/usr/bin/env python |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 18 | # |
| 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 | |
| 31 | RLM_MODULE_REJECT = 0 |
| 32 | RLM_MODULE_FAIL = 1 |
| 33 | RLM_MODULE_OK = 2 |
| 34 | RLM_MODULE_HANDLED = 3 |
| 35 | RLM_MODULE_INVALID = 4 |
| 36 | RLM_MODULE_USERLOCK = 5 |
| 37 | RLM_MODULE_NOTFOUND = 6 |
| 38 | RLM_MODULE_NOOP = 7 |
| 39 | RLM_MODULE_UPDATED = 8 |
| 40 | RLM_MODULE_NUMCODES = 9 |
| 41 | |
| 42 | |
| 43 | # from radiusd.h |
| 44 | L_DBG = 1 |
| 45 | L_AUTH = 2 |
| 46 | L_INFO = 3 |
| 47 | L_ERR = 4 |
| 48 | L_PROXY = 5 |
| 49 | L_CONS = 128 |
| 50 | |
| 51 | OP={ '{':2, '}':3, '(':4, ')':5, ',':6, ';':7, '+=':8, '-=':9, ':=':10, |
| 52 | '=':11, '!=':12, '>=':13, '>':14, '<=':15, '<':16, '=~':17, '!~':18, '=*':19, '!*':20, |
| 53 | '==':21 , '#':22 } |
| 54 | |
| 55 | OP_TRY = (':=', '+=', '-=', '=' ) |
| 56 | |
| 57 | def 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 |
| 68 | def radlog(level, msg): |
| 69 | import sys |
| 70 | sys.stdout.write(msg + '\n') |
| 71 | |
| 72 | level = level |
| 73 | |
| 74 | |