updates.
[silc.git] / lib / silccore / silcpayload.h
index 861a6008d008b268b9e2674c4d5417f2ab4fc109..e8a96f7ee75f9ca529de74e797992f1b251b8183 100644 (file)
@@ -1,24 +1,24 @@
-/****h* silccore/silcpayload.h
- *
- * NAME
- *
- * silcpayload.h
- *
- * COPYRIGHT
- *
- * Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
- *
- * Copyright (C) 2000 Pekka Riikonen
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+/*
+
+  silcpayload.h
+
+  Author: Pekka Riikonen <priikone@silcnet.org>
+
+  Copyright (C) 2000 - 2001 Pekka Riikonen
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+  
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+*/
+
+/****h* silccore/SilcGenericPayloadAPI
  *
  * DESCRIPTION
  *
  *
  * DESCRIPTION
  *
- *    This context is the actual ID Payload and is allocated
- *    by silc_id_payload_parse and given as argument usually to
- *    all silc_id_payload_* functions.  It is freed by the
- *    silc_id_payload_free function.
+ *    This context is the actual ID Payload and is allocated by
+ *    silc_id_payload_parse and given as argument usually to all
+ *    silc_id_payload_* functions.  It is freed by the function
+ *    silc_id_payload_free.
  *
  ***/
 typedef struct SilcIDPayloadStruct *SilcIDPayload;
@@ -70,7 +70,8 @@ typedef struct SilcArgumentPayloadStruct *SilcArgumentPayload;
  *
  * SYNOPSIS
  *
- *    SilcIDPayload silc_id_payload_parse(SilcBuffer buffer);
+ *    SilcIDPayload silc_id_payload_parse(const unsigned char *payload,
+ *                                        uint32 payload_len);
  *
  * DESCRIPTION
  *
@@ -78,52 +79,52 @@ typedef struct SilcArgumentPayloadStruct *SilcArgumentPayload;
  *    `buffer' is raw payload buffer.
  *
  ***/
-SilcIDPayload silc_id_payload_parse(SilcBuffer buffer);
+SilcIDPayload silc_id_payload_parse(const unsigned char *payload,
+                                   uint32 payload_len);
 
-/****f* silccore/SilcGenericPayloadAPI/silc_id_payload_parse_data
+/****f* silccore/SilcGenericPayloadAPI/silc_id_payload_parse_id
  *
  * SYNOPSIS
  *
- *    SilcIDPayload silc_id_payload_parse_data(unsigned char *data, 
- *                                             uint32 len);
+ *    void *silc_id_payload_parse_id(const unsigned char *data, uint32 len);
  *
  * DESCRIPTION
  *
- *    Parses buffer and return ID payload into payload structure. The
- *    `data' and `len' are the raw payload buffer. This is equivalent
- *    to the silc_id_payload_parse function.
+ *    Return ID directly from the raw ID Payload data buffer. The
+ *    caller must free the returned ID.
  *
  ***/
-SilcIDPayload silc_id_payload_parse_data(unsigned char *data, 
-                                        uint32 len);
+void *silc_id_payload_parse_id(const unsigned char *data, uint32 len);
 
-/****f* silccore/SilcGenericPayloadAPI/silc_id_payload_parse_id
+/****f* silccore/SilcGenericPayloadAPI/silc_id_payload_encode
  *
  * SYNOPSIS
  *
- *    void *silc_id_payload_parse_id(unsigned char *data, uint32 len);
+ *    SilcBuffer silc_id_payload_encode(const void *id, SilcIdType type);
  *
  * DESCRIPTION
  *
- *    Return ID directly from the raw ID Payload data buffer. The
- *    caller must free the returned ID.
+ *    Encodes ID Payload. The `id' is the ID of the type `type' to put
+ *    into the payload. Returns the encoded payload buffer.
  *
  ***/
-void *silc_id_payload_parse_id(unsigned char *data, uint32 len);
+SilcBuffer silc_id_payload_encode(const void *id, SilcIdType type);
 
-/****f* silccore/SilcGenericPayloadAPI/silc_id_payload_encode
+/****f* silccore/SilcGenericPayloadAPI/silc_id_payload_encode_data
  *
  * SYNOPSIS
  *
- *    SilcBuffer silc_id_payload_encode(void *id, SilcIdType type);
+ *    SilcBuffer silc_id_payload_encode_data(const unsigned char *id,
+ *                                           uin32 id_len, SilcIdType type);
  *
  * DESCRIPTION
  *
- *    Encodes ID Payload. The `id' is the ID of the type `type' to put
- *    into the payload. Returns the encoded payload buffer.
+ *    Encodes ID Payload. The `id' is raw ID data of the length of `id_len'
+ *    of type of `type'. Returns the encoded payload buffer.
  *
  ***/
-SilcBuffer silc_id_payload_encode(void *id, SilcIdType type);
+SilcBuffer silc_id_payload_encode_data(const unsigned char *id,
+                                      uint32 id_len, SilcIdType type);
 
 /****f* silccore/SilcGenericPayloadAPI/silc_id_payload_free
  *
@@ -197,8 +198,10 @@ uint32 silc_id_payload_get_len(SilcIDPayload payload);
  *
  * SYNOPSIS
  *
- *    SilcArgumentPayload silc_argument_payload_parse(SilcBuffer buffer,
- *                                                    uint32 argc);
+ *    SilcArgumentPayload 
+ *    silc_argument_payload_parse(const unsigned char *payload,
+ *                                uint32 payload_len,
+ *                                uint32 argc);
  *
  * DESCRIPTION
  *
@@ -210,7 +213,8 @@ uint32 silc_id_payload_get_len(SilcIDPayload payload);
  *    the number of the arguments.
  *
  ***/
-SilcArgumentPayload silc_argument_payload_parse(SilcBuffer buffer,
+SilcArgumentPayload silc_argument_payload_parse(const unsigned char *payload,
+                                               uint32 payload_len,
                                                uint32 argc);
 
 /****f* silccore/SilcGenericPayloadAPI/silc_argument_payload_encode