Syntax:
(request [get | get-blob]
option-request)
where
option-request is:
- An optional relay message
selector for IPv6 -
relay [n]
- One or more option clauses
(more than one is only supported for IPv6) -
option
name |
id [vendor
name |
enterprise-id
name |
id] [instance
n]
- Followed by zero or more
suboption clauses -
name |
id [vendor
name |
enterprise-id
name | id] [instance
n]
- Followed by an optional
clause - [instance-count |
count |
index
n]
Description:
Returns the value
of the option from the packet. The keywords are:
- get —Optional and assumed if omitted.
- get-blob —Returns the data as a blob, providing
direct access to the option bytes.
- relay —Applies to IPv6 packets only, otherwise
returns an error. Requests a relay option instead of a client option. The
n
indicates the
n th
closest relay agent to the client; if omitted, 0 (the relay agent nearest to
the client) is assumed.
- option — Options (and suboptions) are specified
with an
id or
name
argument, which must evaluate to an integer or a string. If it does not
evaluate to one of these, the function does not convert it and returns an
error. Valid string values for the name specifier are the same as those used
for extensions.
- enterprise-id —After an option or suboption,
selects the instance of the option or suboption with the specified
enterprise-id. The enterprise-id can be specified as an
id or
name
argument, which must evaluate to an integer or string.
- vendor —After an option or suboption, requests that
the vendor custom option definition be used for decoding the data in the
option. Does not apply to DHCPv6 options. Note that if no definition exists for
the specified vendor string, no error is issued and the standard definition of
an option is used (or, if none, it is assumed to be a blob).
- instance —Selects the
n th
instance of the preceding option or suboption. Instances start at 0. (You
cannot use the instance and instance-count together in a single request
function.)
- instance-count —Returns the number of instances of
the preceding option or suboption, and is usually used to loop through all
instances of it. Returns 0 if the option or suboption does not exist.
- index —Selects the n th value in an option that contains multiple values (that is, array of addresses or integer values). Indexes start at 0.
For example, index
0 returns the first value and index
1 returns the second value.
- count —Returns the number of relevant data items in
the preceding option, and is usually used with the
index keyword
to loop through all data values for an option or suboption.
The only
string-valued suboption names defined for the
subopt
(suboption) specifier are for the relay-agent-info option (82) and are listed
in the
DHCPv4 and BOOTP
Options table of the
Decoded DHCP Packet Data Items
section.
The
request
option function returns a value with a datatype
depending on the option requested. This shows how the datatypes in the table
correspond to the datatypes returned by the
request
function:
Table 2. Datatypes Returned by the request Function
Option
Data Type
|
Returned Data Type
|
blob
|
blob
|
IP
address
|
4-byte
blob
|
string
|
string
|
8-bit
unsigned integer
|
uint
|
16-bit
unsigned integer
|
uint
|
32-bit
unsigned integer
|
uint
|
integer
|
sint
|
byte-valued boolean
|
sint=1
if true, null if false
|
Examples:
(request
option
82) returns the relay-agent-info option as a blob
(request
option
82
1) returns just the circuit-id (1) suboption
(request
option
82
"circuit-id")
is the equivalent
(request
option
82
1)
(request
option
"domain-name- servers")
returns the first IP address from the domain-name-servers
option
(request
option
6
index
0) is the equivalent
(request
option
6
count) returns the number of IP addresses
(request
get-blob
option
"dhcp-class-identifier")
returns the value as a blob, not a string
(request
option
"IA-NA"
instance
2
option
"IAADDR"
instance
3) returns the third instance of the IA-NA option,
and the fourth instance of the IAADDR option encapsulated in the IA-NA option
(request
get-blob
option
"vendor-opts"
enterprise-id
1234) returns a blob of the option data for
enterprise-id 1234
(request
option
"vendor-opts"
enterprise-id
1234
3) returns suboption 3 from the requested vendor
option data
DHCPv6 Option 16
Vendor-Class (contains length delimited fields):
Data in the DHCPv6
Message:
00:10:00:11:00:00:00:7b:00:04:01:02:03:04:00:05:68:65:6c:6c:6f
^ ^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | +--- field 0 ---+ +-- field 1 -------+
| | | | | |
| | | | +---------+ enterprise-id 123(10)
| | +---+ length 17
+---+ Option 16 Vendor-Class
(request option 16
enterprise-id 123) -> Type: blob Value: '01:02:03:04'
(request option 16
enterprise-id 456) -> Type: unset Value: 'null'
(request get-blob option 16
enterprise-id 123) -> Type: blob Value:
'00:00:00:7b:00:04:01:02:03:04:00:05:68:65:6c:6c:6f'
(request option 16
enterprise-id 123 index 0) -> Type: blob Value: '01:02:03:04'
(request option 16
enterprise-id 123 index 1) -> Type: blob Value: '68:65:6c:6c:6f'
Note |
DHCPv6 Option
15, User-Class, operates identically.
|
DHCPv6 Option 17
Vendor Opts (contains sub-options):
Data in the
DHCPv6 Message:
00:11:00:12:00:00:01:c8:00:01:00:04:0a:0b:0c:0d:00:05:00:02:01:02
^ ^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | +---- suboption 1 ----+ +- suboption 5 -+
| | | | | |
| | | | +---------+ enterprise-id 456(10),1c8(16)
| | +---+ length 18
+---+ Option 17 Vendor-Opts
(request option 17
enterprise-id 456)
-> Type: blob Value:
'00:00:01:c8:00:01:00:04:0a:0b:0c:0d:00:05:00:02:01:02'
(request option 17
enterprise-id 0x1c8) -> Type: blob Value:
'00:00:01:c8:00:01:00:04:0a:0b:0c:0d:00:05:00:02:01:02'
(request option 17
enterprise-id 123) -> Type: unset Value: 'null'
(request option 17
enterprise-id 456 index 0)
-> Type: blob Value:
'00:00:01:c8:00:01:00:04:0a:0b:0c:0d:00:05:00:02:01:02'
(request option 17
enterprise-id 456 1) -> Type: blob Value: '0a:0b:0c:0d'
(request option 17
enterprise-id 456 2)
-> Type: unset Value: 'null'
(request option
17 enterprise-id 456 5) -> Type: blob Value: '01:02'
__________________________________________________________________________________________________________________________________________