+#define SILC_STR_DATA(x, l) SILC_PARAM_UICHAR, (x), (l)
+#define SILC_STR_DATA_ALLOC(x, l) SILC_PARAM_UICHAR | SILC_PARAM_ALLOC, (x), (l)
+
+/* Deprecated */
+#define SILC_STR_UI_XNSTRING(x, l) SILC_PARAM_UICHAR, (x), (l)
+#define SILC_STR_UI_XNSTRING_ALLOC(x, l) SILC_PARAM_UICHAR | SILC_PARAM_ALLOC, (x), (l)
+
+/****d* silcutil/SilcBufferFormatAPI/SILC_STR_BUFFER
+ *
+ * NAME
+ *
+ * #define SILC_STR_BUFFER() ...
+ * #define SILC_STR_BUFFER_ALLOC() ...
+ *
+ * DESCRIPTION
+ *
+ * SilcBuffer formatting.
+ *
+ * Formatting: SILC_STR_BUFFER(SilcBuffer)
+ * Unformatting: SILC_STR_BUFFER(SilcBuffer)
+ *
+ * This type can be used to format and unformat SilcBuffer. Note that, the
+ * length of the buffer will be automatically encoded into the buffer as
+ * a 32-bit integer. In unformatting the SilcBuffer context must be
+ * pre-allocated.
+ *
+ * _ALLOC routines automatically allocates memory inside SilcBuffer in
+ * unformatting.
+ *
+ ***/
+#define SILC_STR_BUFFER(x) SILC_PARAM_BUFFER, (x)
+#define SILC_STR_BUFFER_ALLOC(x) SILC_PARAM_BUFFER | SILC_PARAM_ALLOC, (x)
+
+/****d* silcutil/SilcBufferFormatAPI/SILC_STR_FUNC
+ *
+ * NAME
+ *
+ * #define SILC_STR_FUNC() ...
+ *
+ * DESCRIPTION
+ *
+ * SilcBuffer formatting.
+ *
+ * Formatting: SILC_STR_FUNC(function, void *value, void *context)
+ * Unformatting: SILC_STR_FUNC(function, void **value, void *context)
+ *
+ * This type can be used to call the `function' of the type
+ * SilcBufferFormatFunc or SilcBufferUnformatFunc to encode or decode
+ * the `value'. In encoding the `value' will be passed to the `function'
+ * and can be encoded into the buffer. The buffer will be passed as
+ * well to the `function' at the location where SILC_STR_FUNC is placed
+ * in formatting. The `context' delivers caller specific context to
+ * the `function'
+ *
+ * In unformatting the `function' will decode the encoded type and
+ * return it to `value' pointer. The decoding function should decide
+ * itself whether to allocate or not the decoded value.
+ *
+ * The `function' does not have to encode anything and passing `value'
+ * as NULL is allowed. The `function' could for example modify the
+ * existing buffer.
+ *
+ * EXAMPLE
+ *
+ * // Encode payload, encrypt and compute MAC.
+ * silc_buffer_format(buf,
+ * SILC_STR_FUNC(foo_encode_id, id, ctx),
+ * SILC_STR_UINT16(len),
+ * SILC_STR_DATA(data, len),
+ * SILC_STR_FUNC(foo_buf_encrypt, NULL, key),
+ * SILC_STR_FUNC(foo_buf_hmac, NULL, hmac),
+ * SILC_STR_DATA(iv, iv_len);
+ * SILC_STR_END);
+ *
+ * // Check MAC, decrypt and decode payload
+ * silc_buffer_unformat(buf,
+ * SILC_STR_FUNC(foo_buf_hmac, NULL, hmac),
+ * SILC_STR_FUNC(foo_buf_decrypt, NULL, key),
+ * SILC_STR_FUNC(foo_decode_id, &id, ctx),
+ * SILC_STR_UINT16(&len),
+ * SILC_STR_END);
+ *
+ ***/
+#define SILC_STR_FUNC(func, val, context) SILC_PARAM_FUNC, \
+ func, (val), (context)