case-statement regex

O'Connell, Ryan ryan.oconnell at viasat.com
Thu Jan 7 04:09:46 CET 2016


Using version 3.0.10.  Can’t seem to implement regex matching with case statements.  The request always results in “def” even though the string in the request contains “abc".

switch DHCP-Subscriber-Id {
	case "/(abc)$/" {
		update control {
			&Pool-Name := “abc"
		}
	}
	case {
		update control {
			&Pool-Name := “def"
		}
	}
        }


I have tried a bunch of different variations of the “case” without success.  If I use the entire string in the case statement then I get the intended result “abc”.

switch DHCP-Subscriber-Id {
	case 001122334455 at abc {
		update control {
			&Pool-Name := “abc"
		}
	}
	case {
		update control {
			&Pool-Name := “def"
		}
	}
}


Does anyone have a suggestion on how to implement this?  I haven’t been able to find examples in the documentation or google about doing this specifically.  The same logic implemented with if/else works fine but I was hoping to use switch/case for performance.

if (&DHCP-Subscriber-Id =~ /(abc)$/){
	update control {
		&Pool-Name := “abc"
	}
}
else {
	update control {
		&Pool-Name := “def"
	}
}


Thanks,
Ryan



More information about the Freeradius-Users mailing list