summaryrefslogtreecommitdiff
path: root/src/validators/allowed-vlan
blob: 11389390b25e549842d55503238d0c1ce9a3db30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /usr/bin/python3

import sys
import re

if __name__ == '__main__':
    if len(sys.argv)>1:
        allowed_vlan = sys.argv[1]
        if re.search('[0-9]{1,4}-[0-9]{1,4}', allowed_vlan):
            for tmp in allowed_vlan.split('-'):
                if int(tmp) not in range(1, 4095):
                    sys.exit(1)
        else:
            if int(allowed_vlan) not in range(1, 4095):
                sys.exit(1)
    else:
        sys.exit(2)
    
    sys.exit(0)