ltm rule command ASN1 encodeΒΆ

iRule(1)		      BIG-IP TMSH Manual		      iRule(1)



ASN1::encode
       Encodes ASN.1 records.

SYNOPSIS
       ASN1::encode ('BER' | 'DER') FORMAT (VALUE)*

       ASN1::encode ('insert' | 'replace') ELEMENT OFFSET FORMAT (VALUE)*

DESCRIPTION
       This command is used to encode ASN.1 records. Data is formatted
       according to formatString.

       formatString can have the following characters:

	   a - Octet String
	   B - Bit String
	   b - Boolean
	   e - Enum
	   i - Integer
	   t - Tag of next element
	   ? - Don't output the component if the corresponding value is empty
	   ?hex-tag - Denotes that the specifier which follows is for an optional component. This is used for encoding or decoding an ASN.1 Set or Sequence which contains nested OPTIONAL or DEFAULT components. hex-tag, is a two-character hex byte of the expected tag. When used with the decode command, if the component corresponding to the optional specifier is not found, the corresponding tcl variable will be unset. This allows the iRule to use the Tcl info exists command to test the variable to determine if the component was found. See the following section for more details and examples.
	   ( - Begin Sequence. No corresponding parameter is specified. The initial sequence tag and length are skipped.
	   ) - End Sequence. No corresponding parameter is specified.
	   < - Begin Set. No corresponding parameter is specified. The initial sequence tag and length are skipped.
	   > - End Set. No corresponding parameter is specified.

       ASN1::encode encodingType formatString ?value value ...?

	    * Used to encode ASN.1 records. encodingType specifies the encoding
	      type (BER|DER). Data is provided via the listed values and
	      formatted according to formatString. Returns a byte array
	      containing the encoded data.

       ASN1::encode insert element offset formatString ?value value ...?

	    * Insert encoded data at the location specified by element and offset.
	      Prependding can be accomplished by specifying an offset of 0.
	      Returns TCL status.

       ASN1::encode replace element offset formatString ?value value ...?

	    * Replace existing encoded data at the location specified by element and offset.
	      Returns TCL status.

RETURN VALUE
VALID DURING
EXAMPLES
	# LDAP String Modify
	append base_mod $base ",dc=supercalafragalisticexpialadoshus"
	ASN1::encode replace $ele 1 "a" $base_mod

	# LDAP Encode/Rewrite - The size field is 4 elements forward from $ele
	ASN1::encode replace $ele 4 "i" [incr size 2]

	# LDAP Encode/Rewrite - The time field is 5 elements forward from $ele
	ASN1::encode replace $ele 5 "i" [expr $time + 100]

	# Encode an LDAP SearchRequest Extensible Match filter where RuleId and Type are optional,
	# matchValue is mandatory and dnAttrs is optional with a default value of FALSE
	if { $dnAttrs == 0 } {
	  # dnAttrs is 0 (False) which is the ASN.1 defined default, so set it to "" so it won't be encoded
	  set dnAttrs ""
	}
	ASN1::encode "?a?aa?b" $ruleId $type $matchValue $dnAttrs

HINTS
SEE ALSO
CHANGE LOG
       @BIGIP-11.5.0 --First introduced the command.



BIG-IP				  2017-01-31			      iRule(1)