# -*- text -*-
#
#  $Id: 665dd2aca16b9498a4d2b8a91e41d27741185738 $

#
#  This module is useful only for 'xlat'.  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 1 integer}"
#
#  The arguments are three fields:
#
#	data
#		Either &Attribute-Name
#		the name of the attribute to unpack.
#		MUST be a "string" or "octets" type.
#
#		or 0xabcdef
#		e.g. hex data.
#
#	1
#		The offset into the string from which
#		it starts unpacking.  The offset starts
#		at zero, for the first attribute.
#
#	integer
#		the data type to unpack at that offset.
#		e.g. integer, ipaddr, byte, short, etc.
#
#  e.g. if we have Class = 0x0000000102030405, then
#
#	%{unpack:&Class 4 short}
#
#  will unpack octets 4 and 5 as a "short", which has
#  value 0x0304.
#
#  This module is used when vendors put multiple fields
#  into one attribute of type "octets".
#
#  The module can also be used to unpack substrings, by specifing a
#  data type of "string(len)" or "octets(len)".  Where "len" is an
#  actual number.  For example:
#
#	%{unpack:&User-Name 1 string(2)}
#
#  When given a User-Name of "hello", it will start taking the
#  substring at offset 1 (i.e. "e"), and it will take two characters
#  from that offset, i.e. "el".
#
#  When "octets(len)" is used, the output is printed as hex.  e.g. for
#  the above example with Class:
#
#	%{unpack:&Class 4 octets(4)}
#
#  Will return the hex string "02030405"
#
unpack {
}
