Unpack Module
The unpack
module unpacks binary data from octets type attributes
into individual attributes.
It is used when vendors put multiple fields into one attribute of type "octets".
The module is useful only for xlat .
|
Syntax
To use it, add it to the raddb/mods-enabled/
directory. Then,
use it on the right-hand side of a variable assignment.
%unpack(<data>, <offset>, <data_type>[, <repeat>])
The arguments are three or four fields:
- data
-
Either
octets
orstring
type data, literal or expanded attributes. Ifstring
type data contains a representation of hex data, e.g. 0xabcdef that is first converted tooctets
. - offset
-
The offset into the string from which it starts unpacking. The offset starts at zero, for the first attribute.
- data_type
-
the data type to unpack at that offset. e.g.
integer
,ipaddr
,byte
,short
, etc. - repeat
-
How many instances of the data type should be unpacked. This optional argument must either be an integer or the special value of
'*'
to extract as many instances as can be from the input data.