updates. New data types.
[silc.git] / lib / silccore / silcpacket.h
index afa6e4f73c45f3ed48b4b85175caab1195f7971e..7bc8a8a9d9724baeb59cdd919fec094f6923fa3b 100644 (file)
@@ -94,14 +94,14 @@ typedef unsigned char SilcPacketFlags;
        Packet flags. Flags are defined above.
 
    unsigned char *src_id
-   unsigned short src_id_len
+   uint16 src_id_len
    unsigned char src_id_type
 
        Source ID, its length and type. On packet reception retuned ID's
        are always the hash values of the ID's from the packet.
 
   unsigned char *dst_id;
-  unsigned short dst_id_len;
+  uint16 dst_id_len;
   unsigned char src_id_type;
 
        Destination ID, its length and type. On packet reception retuned
@@ -119,18 +119,15 @@ typedef struct {
   SilcPacketFlags flags;
 
   unsigned char *src_id;
-  unsigned short src_id_len;
+  uint16 src_id_len;
   unsigned char src_id_type;
 
   unsigned char *dst_id;
-  unsigned short dst_id_len;
+  uint16 dst_id_len;
   unsigned char dst_id_type;
 
-  unsigned short truelen;
-  unsigned short padlen;
-
-  /* For padding generation */
-  SilcRng rng;
+  uint16 truelen;
+  uint16 padlen;
 
   /* Back pointers */
   void *context;
@@ -189,6 +186,11 @@ typedef struct {
 typedef void (*SilcPacketParserCallback)(SilcPacketParserContext 
                                         *parse_context);
 
+/* The packet check callback in decryption phase */
+typedef int (*SilcPacketCheckDecrypt)(SilcPacketType packet_type,
+                                     SilcBuffer buffer,
+                                     SilcPacketContext *packet,
+                                     void *context);
 
 /* SILC Packet types. */
 #define SILC_PACKET_NONE                0       /* NULL, never sent */
@@ -216,6 +218,8 @@ typedef void (*SilcPacketParserCallback)(SilcPacketParserContext
 #define SILC_PACKET_REKEY                22      /* Re-key start */
 #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_PRIVATE              200     /* Private range start  */
 #define SILC_PACKET_MAX                  255     /* RESERVED */
@@ -238,16 +242,18 @@ do {                                                                           \
 int silc_packet_write(int sock, SilcBuffer src);
 int silc_packet_send(SilcSocketConnection sock, int force_send);
 void silc_packet_encrypt(SilcCipher cipher, SilcHmac hmac, 
-                        SilcBuffer buffer, unsigned int len);
+                        SilcBuffer buffer, uint32 len);
 void silc_packet_assemble(SilcPacketContext *ctx);
 void silc_packet_send_prepare(SilcSocketConnection sock,
-                             unsigned int header_len,
-                             unsigned int padlen,
-                             unsigned int data_len);
+                             uint32 header_len,
+                             uint32 padlen,
+                             uint32 data_len);
 int silc_packet_read(int sock, SilcBuffer dest);
 int silc_packet_receive(SilcSocketConnection sock);
 int silc_packet_decrypt(SilcCipher cipher, SilcHmac hmac,
-                       SilcBuffer buffer, SilcPacketContext *packet);
+                       SilcBuffer buffer, SilcPacketContext *packet,
+                       SilcPacketCheckDecrypt check_packet,
+                       void *context);
 void silc_packet_receive_process(SilcSocketConnection sock,
                                 SilcCipher cipher, SilcHmac hmac,
                                 SilcPacketParserCallback parser,