Example

This script returns the sub_profile_string and sla_profile_string, which are coded directly in the Option 82 string.

Script:

1.  import re
2.  import alc
3.  # option 82 formatted as follows:
4.  # "<subscriber Profile>-<sla-profile>”
5.  ident = str(alc.dhcp.options[82][1])
6.  alc.dhcp.sub_ident = ident
7.  tmp = re.match("(?P<sub>.+)-(?P<sla>.+)", str(ident))
8.  alc.dhcp.sub_profile_string = tmp.group("sub")
9.  alc.dhcp.sla_profile_string = tmp.group("sla")

Explanation:

Line 1-2 import the libraries ‟re” and ‟alc”. Library imports can reside anywhere in the script if the items are imported before they are used.

Line 6 assigns the full contents of the DHCP Option 82 field to the ‟sub_ident” variable.

Line 7 splits the options 82 string into two parts, separated by ‟-”.

Line 8 assigns the first part of the string to the variable ‟sub_profile_string”.

Line 9 assigns the second part of the string to the variable ‟sla_profile_string”.

If this script is run, for example, with DHCP option field:

options = \x52\x0D\x01\0x0Bmydsl-video

The following variables are returned:

sub_ident: mydsl-video 
sub_profile_string: mydsl 
sla_profile_string: video