updates.
[silc.git] / lib / silccore / silcpacket.h
index e2ccc51134eb04dd5faf4cb300b52c179116b10a..c8490b0b8bfb6e5ab20c719333302041c5703071 100644 (file)
@@ -1,24 +1,23 @@
-/****h* silccore/silcpacket.h
- *
- * NAME
- *
- * silcpacket.h
- *
- * COPYRIGHT
- *
- * Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
- *
- * Copyright (C) 1997 - 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.
+/*
+
+  silcpacket.h 
+
+  Author: Pekka Riikonen <priikone@silcnet.org>
+
+  Copyright (C) 1997 - 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; version 2 of the License.
+
+  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/SilcPacketAPI
  *
  * DESCRIPTION
  *
@@ -93,7 +92,8 @@ typedef unsigned char SilcPacketType;
 #define SILC_PACKET_REKEY_DONE           23      /* Re-key done */
 #define SILC_PACKET_HEARTBEAT            24      /* Heartbeat */
 #define SILC_PACKET_KEY_AGREEMENT        25      /* Key Agreement request */
-#define SILC_PACKET_CELL_ROUTERS         26      /* Cell routers backup */
+#define SILC_PACKET_RESUME_ROUTER        26      /* Backup router resume */
+#define SILC_PACKET_FTP                  27      /* File Transfer */
 
 #define SILC_PACKET_PRIVATE              200     /* Private range start  */
 #define SILC_PACKET_MAX                  255     /* RESERVED */
@@ -192,13 +192,17 @@ typedef unsigned char SilcPacketFlags;
  *      silc_packet_* routines. If not provided the library will calculate
  *      the values.
  *
- *    in users;
+ *    int users;
  *
  *      Reference counter for this context. The context is freed only 
  *      after the reference counter hits zero. The counter is added
  *      calling silc_packet_context_dup and decreased by calling the
  *      silc_packet_context_free.
  *
+ *    uint32 sequence;
+ *
+ *      Packet sequence number.
+ *
  ***/
 typedef struct {
   SilcBuffer buffer;
@@ -221,6 +225,8 @@ typedef struct {
   SilcSocketConnection sock;
 
   int users;
+
+  uint32 sequence;
 } SilcPacketContext;
 
 /****s* silccore/SilcPacketAPI/SilcPacketParserContext
@@ -359,28 +365,11 @@ do {                                                                           \
 
 /* Prototypes */
 
-/****f* silccore/SilcPacketAPI/silc_packet_write
- *
- * SYNOPSIS
- *
- *    int silc_packet_write(int sock, SilcBuffer src);
- *
- * DESCRIPTION
- *
- *    Writes data from encrypted buffer to the socket connection. If the
- *    data cannot be written at once, it will be written later with a timeout. 
- *    The data is written from the data section of the buffer, not from head
- *    or tail section. This automatically pulls the data section towards end
- *    after writing the data.
- *
- ***/
-int silc_packet_write(int sock, SilcBuffer src);
-
 /****f* silccore/SilcPacketAPI/silc_packet_send
  *
  * SYNOPSIS
  *
- *    int silc_packet_send(SilcSocketConnection sock, int force_send);
+ *    int silc_packet_send(SilcSocketConnection sock, bool force_send);
  *
  * DESCRIPTION
  *
@@ -393,7 +382,7 @@ int silc_packet_write(int sock, SilcBuffer src);
  *    directly to the network, if FALSE, this returns -2.
  *
  ***/
-int silc_packet_send(SilcSocketConnection sock, int force_send);
+int silc_packet_send(SilcSocketConnection sock, bool force_send);
 
 /****f* silccore/SilcPacketAPI/silc_packet_encrypt
  *
@@ -492,31 +481,6 @@ void silc_packet_send_prepare(SilcSocketConnection sock,
                              uint32 padlen,
                              uint32 data_len);
 
-/****f* silccore/SilcPacketAPI/silc_packet_read
- *
- * SYNOPSIS
- *
- *    int silc_packet_read(int fd, SilcSocketConnection sock);
- *
- * DESCRIPTION
- *
- *    Reads data from the socket connection into the incoming data buffer.
- *    However, this does not parse the packet, it only reads some amount from
- *    the network. If there are more data available that can be read at a time
- *    the rest of the data will be read later with a timeout and only after
- *    that the packet is ready to be parsed. 
- *
- *    The destination buffer sent as argument must be initialized before 
- *    calling this function, and, the data section and the start of the tail
- *    section must be same. Ie. we add the read data to the tail section of
- *    the buffer hence the data section is the start of the buffer.
- *
- *    This returns amount of bytes read or -1 on error or -2 on case where
- *    all of the data could not be read at once.
- *
- ***/
-int silc_packet_read(int fd, SilcSocketConnection sock);
-
 /****f* silccore/SilcPacketAPI/silc_packet_receive
  *
  * SYNOPSIS
@@ -637,7 +601,7 @@ SilcPacketType silc_packet_parse_special(SilcPacketContext *ctx);
  *    silc_packet_context_free function.
  *
  ***/
-SilcPacketContext *silc_packet_context_alloc();
+SilcPacketContext *silc_packet_context_alloc(void);
 
 /****f* silccore/SilcPacketAPI/silc_packet_context_dup
  *