updates.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 6 May 2001 13:24:11 +0000 (13:24 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 6 May 2001 13:24:11 +0000 (13:24 +0000)
23 files changed:
CHANGES
TODO
apps/silcd/command.c
apps/silcd/idlist.c
apps/silcd/packet_receive.c
apps/silcd/packet_send.c
apps/silcd/packet_send.h
apps/silcd/route.c
apps/silcd/server.c
apps/silcd/serverid.c
lib/silcclient/client.c
lib/silcclient/client_channel.c
lib/silcclient/client_notify.c
lib/silcclient/client_prvmsg.c
lib/silcclient/command.c
lib/silcclient/command_reply.c
lib/silccore/id.c
lib/silccore/id.h
lib/silccore/idcache.c
lib/silccore/silcauth.c
lib/silccore/silcpayload.c
lib/silcutil/silcutil.c
prepare

diff --git a/CHANGES b/CHANGES
index 373cc2e64d0c8a95818b3fb6ca3a47c8c644fc6b..e41102a9e28fde8f8c6324d4058bd0090a8e2681 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,21 @@
+Sun May  6 13:59:48 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added new SilcIDIP structure into the lib/silccore/id.h and
+         replaced the old `ip' fields from all SILC ID's to that type.
+         This is a step towards IPv6 support.
+
+         The silc_id_get_len takes now the ID as an extra argument.
+         Added new function silc_id_compare into lib/silccore/id.[ch].
+         The silc_id_id2str, silc_id_str2id and silc_id_dup now supports
+         both IPv4 and IPv6 based ID's.
+
+         The affected files are lib/silccore/id.[ch] and other files
+         around the tree using these routines.
+
+       * Removed the ID length arguments in server from various 
+         silc_server_send_notify_* routines -> they are not needed 
+         anymore.
+
 Sat May  5 13:56:33 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Fixed memory leak in silc_encode_pem_file in the file
 Sat May  5 13:56:33 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Fixed memory leak in silc_encode_pem_file in the file
diff --git a/TODO b/TODO
index 266b3f52cfc20e674d7a8aa7b61c9c09709fb4fa..2c685800acb73747392a527500c715b9ae217e57 100644 (file)
--- a/TODO
+++ b/TODO
@@ -57,7 +57,13 @@ TODO/bugs In SILC Server
 TODO/bugs In SILC Libraries
 ===========================
 
 TODO/bugs In SILC Libraries
 ===========================
 
- o IPv6 support for ID's and into the code.
+ o silc_server_get_users_on_channel does not support IPv6 based Client
+   ID's.
+
+ o silc_server_route_get and the route code in general supports only
+   IPv4.
+
+ o silcd/serverid.c and its routines supports only IPv4.
 
  o Compression routines are missing.  The protocol supports packet
    compression thus it must be implemented.  SILC Comp API must be
 
  o Compression routines are missing.  The protocol supports packet
    compression thus it must be implemented.  SILC Comp API must be
index 554fbb942b3a6b0c30b4f5f21776093f8d214e34..a961f6c9ec52399c720128987452f77786c841e8 100644 (file)
@@ -1761,7 +1761,7 @@ SILC_SERVER_CMD_FUNC(nick)
     silc_server_send_notify_nick_change(server, server->router->connection, 
                                        server->server_type == SILC_SERVER ? 
                                        FALSE : TRUE, client->id,
     silc_server_send_notify_nick_change(server, server->router->connection, 
                                        server->server_type == SILC_SERVER ? 
                                        FALSE : TRUE, client->id,
-                                       new_id, SILC_ID_CLIENT_LEN);
+                                       new_id);
 
   /* Remove old cache entry */
   silc_idcache_del_by_id(server->local_list->clients, SILC_ID_CLIENT, 
 
   /* Remove old cache entry */
   silc_idcache_del_by_id(server->local_list->clients, SILC_ID_CLIENT, 
@@ -1770,10 +1770,8 @@ SILC_SERVER_CMD_FUNC(nick)
   oidp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
 
   /* Free old ID */
   oidp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
 
   /* Free old ID */
-  if (client->id) {
-    memset(client->id, 0, SILC_ID_CLIENT_LEN);
+  if (client->id)
     silc_free(client->id);
     silc_free(client->id);
-  }
 
   /* Save the nickname as this client is our local client */
   if (client->nickname)
 
   /* Save the nickname as this client is our local client */
   if (client->nickname)
@@ -2071,7 +2069,7 @@ SILC_SERVER_CMD_FUNC(topic)
       silc_server_send_notify_topic_set(server, server->router->connection,
                                        server->server_type == SILC_ROUTER ?
                                        TRUE : FALSE, channel, client->id,
       silc_server_send_notify_topic_set(server, server->router->connection,
                                        server->server_type == SILC_ROUTER ?
                                        TRUE : FALSE, channel, client->id,
-                                       SILC_ID_CLIENT_LEN, channel->topic);
+                                       channel->topic);
 
     idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
 
 
     idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
 
@@ -2302,8 +2300,7 @@ SILC_SERVER_CMD_FUNC(invite)
     silc_server_send_notify_invite(server, server->router->connection,
                                   server->server_type == SILC_ROUTER ?
                                   TRUE : FALSE, channel,
     silc_server_send_notify_invite(server, server->router->connection,
                                   server->server_type == SILC_ROUTER ?
                                   TRUE : FALSE, channel,
-                                  sender->id, SILC_ID_CLIENT_LEN,
-                                  add, del);
+                                  sender->id, add, del);
 
   /* Send command reply */
   tmp = silc_argument_get_arg_type(cmd->args, 1, &len);
 
   /* Send command reply */
   tmp = silc_argument_get_arg_type(cmd->args, 1, &len);
@@ -2471,15 +2468,13 @@ SILC_SERVER_CMD_FUNC(kill)
   /* Send KILLED notify to primary route */
   if (!server->standalone)
     silc_server_send_notify_killed(server, server->router->connection, TRUE,
   /* Send KILLED notify to primary route */
   if (!server->standalone)
     silc_server_send_notify_killed(server, server->router->connection, TRUE,
-                                  remote_client->id, SILC_ID_CLIENT_LEN,
-                                  comment);
+                                  remote_client->id, comment);
 
   /* Send KILLED notify to the client directly */
   silc_server_send_notify_killed(server, remote_client->connection ? 
                                 remote_client->connection : 
                                 remote_client->router->connection, FALSE,
 
   /* Send KILLED notify to the client directly */
   silc_server_send_notify_killed(server, remote_client->connection ? 
                                 remote_client->connection : 
                                 remote_client->router->connection, FALSE,
-                                remote_client->id, SILC_ID_CLIENT_LEN,
-                                comment);
+                                remote_client->id, comment);
 
   /* Remove the client from all channels. This generates new keys to the
      channels as well. */
 
   /* Remove the client from all channels. This generates new keys to the
      channels as well. */
@@ -2684,7 +2679,7 @@ SILC_SERVER_CMD_FUNC(ping)
   if (!id)
     goto out;
 
   if (!id)
     goto out;
 
-  if (!SILC_ID_SERVER_COMPARE(id, server->id)) {
+  if (SILC_ID_SERVER_COMPARE(id, server->id)) {
     /* Send our reply */
     silc_server_command_send_status_reply(cmd, SILC_COMMAND_PING,
                                          SILC_STATUS_OK);
     /* Send our reply */
     silc_server_command_send_status_reply(cmd, SILC_COMMAND_PING,
                                          SILC_STATUS_OK);
@@ -2906,8 +2901,7 @@ static void silc_server_command_join_channel(SilcServer server,
     if (!server->standalone)
       silc_server_send_notify_join(server, server->router->connection,
                                   server->server_type == SILC_ROUTER ?
     if (!server->standalone)
       silc_server_send_notify_join(server, server->router->connection,
                                   server->server_type == SILC_ROUTER ?
-                                  TRUE : FALSE, channel, client->id,
-                                  SILC_ID_CLIENT_LEN);
+                                  TRUE : FALSE, channel, client->id);
   }
 
   silc_buffer_free(reply);
   }
 
   silc_buffer_free(reply);
@@ -2984,7 +2978,7 @@ SILC_SERVER_CMD_FUNC(join)
        be same as the client's ID. */
     if (cmd->sock->type == SILC_SOCKET_TYPE_CLIENT) {
       SilcClientEntry entry = (SilcClientEntry)cmd->sock->user_data;
        be same as the client's ID. */
     if (cmd->sock->type == SILC_SOCKET_TYPE_CLIENT) {
       SilcClientEntry entry = (SilcClientEntry)cmd->sock->user_data;
-      if (SILC_ID_CLIENT_COMPARE(entry->id, client_id)) {
+      if (!SILC_ID_CLIENT_COMPARE(entry->id, client_id)) {
        silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN,
                                        SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
        goto out;
        silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN,
                                        SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
        goto out;
@@ -3317,8 +3311,7 @@ SILC_SERVER_CMD_FUNC(umode)
   /* Send UMODE change to primary router */
   if (!server->standalone)
     silc_server_send_notify_umode(server, server->router->connection, TRUE,
   /* Send UMODE change to primary router */
   if (!server->standalone)
     silc_server_send_notify_umode(server, server->router->connection, TRUE,
-                                 client->id, SILC_ID_CLIENT_LEN,
-                                 client->mode);
+                                 client->id, client->mode);
 
   /* Send command reply to sender */
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_UMODE,
 
   /* Send command reply to sender */
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_UMODE,
@@ -3727,7 +3720,6 @@ SILC_SERVER_CMD_FUNC(cmode)
                                  server->server_type == SILC_ROUTER ? 
                                  TRUE : FALSE, channel,
                                  mode_mask, client->id, SILC_ID_CLIENT,
                                  server->server_type == SILC_ROUTER ? 
                                  TRUE : FALSE, channel,
                                  mode_mask, client->id, SILC_ID_CLIENT,
-                                 SILC_ID_CLIENT_LEN,
                                  cipher, hmac);
 
   /* Send command reply to sender */
                                  cipher, hmac);
 
   /* Send command reply to sender */
@@ -3975,9 +3967,8 @@ SILC_SERVER_CMD_FUNC(cumode)
                                     server->server_type == SILC_ROUTER ? 
                                     TRUE : FALSE, channel,
                                     target_mask, client->id, 
                                     server->server_type == SILC_ROUTER ? 
                                     TRUE : FALSE, channel,
                                     target_mask, client->id, 
-                                    SILC_ID_CLIENT, SILC_ID_CLIENT_LEN,
-                                    target_client->id, 
-                                    SILC_ID_CLIENT_LEN);
+                                    SILC_ID_CLIENT,
+                                    target_client->id);
   }
 
   /* Send command reply to sender */
   }
 
   /* Send command reply to sender */
@@ -4136,8 +4127,7 @@ SILC_SERVER_CMD_FUNC(kick)
     silc_server_send_notify_kicked(server, server->router->connection,
                                   server->server_type == SILC_ROUTER ?
                                   TRUE : FALSE, channel,
     silc_server_send_notify_kicked(server, server->router->connection,
                                   server->server_type == SILC_ROUTER ?
                                   TRUE : FALSE, channel,
-                                  target_client->id, SILC_ID_CLIENT_LEN,
-                                  comment);
+                                  target_client->id, comment);
 
   if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
     /* Re-generate channel key */
 
   if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
     /* Re-generate channel key */
@@ -4216,8 +4206,7 @@ SILC_SERVER_CMD_FUNC(oper)
   /* Send UMODE change to primary router */
   if (!server->standalone)
     silc_server_send_notify_umode(server, server->router->connection, TRUE,
   /* Send UMODE change to primary router */
   if (!server->standalone)
     silc_server_send_notify_umode(server, server->router->connection, TRUE,
-                                 client->id, SILC_ID_CLIENT_LEN,
-                                 client->mode);
+                                 client->id, client->mode);
 
   /* Send reply to the sender */
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_OPER,
 
   /* Send reply to the sender */
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_OPER,
@@ -4292,8 +4281,7 @@ SILC_SERVER_CMD_FUNC(silcoper)
   /* Send UMODE change to primary router */
   if (!server->standalone)
     silc_server_send_notify_umode(server, server->router->connection, TRUE,
   /* Send UMODE change to primary router */
   if (!server->standalone)
     silc_server_send_notify_umode(server, server->router->connection, TRUE,
-                                 client->id, SILC_ID_CLIENT_LEN,
-                                 client->mode);
+                                 client->id, client->mode);
 
   /* Send reply to the sender */
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_SILCOPER,
 
   /* Send reply to the sender */
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_SILCOPER,
@@ -4639,8 +4627,7 @@ SILC_SERVER_CMD_FUNC(leave)
   if (!server->standalone)
     silc_server_send_notify_leave(server, server->router->connection,
                                  server->server_type == SILC_ROUTER ?
   if (!server->standalone)
     silc_server_send_notify_leave(server, server->router->connection,
                                  server->server_type == SILC_ROUTER ?
-                                 TRUE : FALSE, channel, id_entry->id,
-                                 SILC_ID_CLIENT_LEN);
+                                 TRUE : FALSE, channel, id_entry->id);
 
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_LEAVE,
                                        SILC_STATUS_OK);
 
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_LEAVE,
                                        SILC_STATUS_OK);
index 6785ab452d0cc815c532ddbc1ebfa5e98cfa1ec5..e6f79f3c3bd8838b3b01fcdd89d370ee8c933263 100644 (file)
@@ -458,7 +458,7 @@ silc_idlist_find_client_by_hash(SilcIDList id_list, char *nickname,
   while (id_cache) {
     client = (SilcClientEntry)id_cache->context;
     
   while (id_cache) {
     client = (SilcClientEntry)id_cache->context;
     
-    if (client && !SILC_ID_COMPARE_HASH(client->id, hash))
+    if (client && SILC_ID_COMPARE_HASH(client->id, hash))
       break;
 
     id_cache = NULL;
       break;
 
     id_cache = NULL;
@@ -532,7 +532,7 @@ silc_idlist_replace_client_id(SilcIDList id_list, SilcClientID *old_id,
 
   /* If the old ID Cache data was the hash value of the old Client ID
      replace it with the hash of new Client ID */
 
   /* If the old ID Cache data was the hash value of the old Client ID
      replace it with the hash of new Client ID */
-  if (id_cache->data && !SILC_ID_COMPARE_HASH(old_id, id_cache->data)) {
+  if (id_cache->data && SILC_ID_COMPARE_HASH(old_id, id_cache->data)) {
     silc_free(id_cache->data);
     id_cache->data = silc_calloc(sizeof(new_id->hash), sizeof(unsigned char));
     memcpy(id_cache->data, new_id->hash, sizeof(new_id->hash));
     silc_free(id_cache->data);
     id_cache->data = silc_calloc(sizeof(new_id->hash), sizeof(unsigned char));
     memcpy(id_cache->data, new_id->hash, sizeof(new_id->hash));
index 9f1e4ccc2654c27786c2cde062f3b28716e479e7..b325fd6a894e356f70dd5760b4a97cada1f28985 100644 (file)
@@ -526,8 +526,7 @@ void silc_server_notify(SilcServer server,
        silc_server_send_notify_cumode(server, sock, FALSE, channel,
                                       (mode & (~SILC_CHANNEL_UMODE_CHANFO)),
                                       server->id, SILC_ID_SERVER, 
        silc_server_send_notify_cumode(server, sock, FALSE, channel,
                                       (mode & (~SILC_CHANNEL_UMODE_CHANFO)),
                                       server->id, SILC_ID_SERVER, 
-                                      SILC_ID_SERVER_LEN,
-                                      client->id, SILC_ID_CLIENT_LEN);
+                                      client->id);
        silc_free(channel_id);
 
        /* Change the mode back if we changed it */
        silc_free(channel_id);
 
        /* Change the mode back if we changed it */
@@ -1139,7 +1138,7 @@ void silc_server_command_reply(SilcServer server,
 
   if (packet->dst_id_type == SILC_ID_SERVER) {
     /* For now this must be for us */
 
   if (packet->dst_id_type == SILC_ID_SERVER) {
     /* For now this must be for us */
-    if (SILC_ID_SERVER_COMPARE(packet->dst_id, server->id_string)) {
+    if (memcmp(packet->dst_id, server->id_string, packet->dst_id_len)) {
       SILC_LOG_ERROR(("Cannot process command reply to unknown server"));
       return;
     }
       SILC_LOG_ERROR(("Cannot process command reply to unknown server"));
       return;
     }
@@ -1216,7 +1215,7 @@ void silc_server_channel_message(SilcServer server,
   if (packet->src_id_type == SILC_ID_CLIENT) {
     silc_list_start(channel->user_list);
     while ((chl = silc_list_get(channel->user_list)) != SILC_LIST_END) {
   if (packet->src_id_type == SILC_ID_CLIENT) {
     silc_list_start(channel->user_list);
     while ((chl = silc_list_get(channel->user_list)) != SILC_LIST_END) {
-      if (chl->client && !SILC_ID_CLIENT_COMPARE(chl->client->id, sender)) {
+      if (chl->client && SILC_ID_CLIENT_COMPARE(chl->client->id, sender)) {
        sender_entry = chl->client;
        break;
       }
        sender_entry = chl->client;
        break;
       }
@@ -1280,6 +1279,7 @@ SilcClientEntry silc_server_new_client(SilcServer server,
   SilcBuffer reply;
   SilcIDListData idata;
   char *username = NULL, *realname = NULL, *id_string;
   SilcBuffer reply;
   SilcIDListData idata;
   char *username = NULL, *realname = NULL, *id_string;
+  uint32 id_len;
   int ret;
 
   SILC_LOG_DEBUG(("Creating new client"));
   int ret;
 
   SILC_LOG_DEBUG(("Creating new client"));
@@ -1337,6 +1337,7 @@ SilcClientEntry silc_server_new_client(SilcServer server,
   client->username = username;
   client->userinfo = realname ? realname : strdup(" ");
   client->id = client_id;
   client->username = username;
   client->userinfo = realname ? realname : strdup(" ");
   client->id = client_id;
+  id_len = silc_id_get_len(client_id, SILC_ID_CLIENT);
 
   /* Update the cache entry */
   cache->id = (void *)client_id;
 
   /* Update the cache entry */
   cache->id = (void *)client_id;
@@ -1350,16 +1351,16 @@ SilcClientEntry silc_server_new_client(SilcServer server,
     silc_server_send_new_id(server, (SilcSocketConnection) 
                            server->router->connection, 
                            server->server_type == SILC_ROUTER ? TRUE : FALSE,
     silc_server_send_new_id(server, (SilcSocketConnection) 
                            server->router->connection, 
                            server->server_type == SILC_ROUTER ? TRUE : FALSE,
-                           client->id, SILC_ID_CLIENT, SILC_ID_CLIENT_LEN);
+                           client->id, SILC_ID_CLIENT, id_len);
   
   /* Send the new client ID to the client. */
   id_string = silc_id_id2str(client->id, SILC_ID_CLIENT);
   
   /* Send the new client ID to the client. */
   id_string = silc_id_id2str(client->id, SILC_ID_CLIENT);
-  reply = silc_buffer_alloc(2 + 2 + SILC_ID_CLIENT_LEN);
+  reply = silc_buffer_alloc(2 + 2 + id_len);
   silc_buffer_pull_tail(reply, SILC_BUFFER_END(reply));
   silc_buffer_format(reply,
                     SILC_STR_UI_SHORT(SILC_ID_CLIENT),
   silc_buffer_pull_tail(reply, SILC_BUFFER_END(reply));
   silc_buffer_format(reply,
                     SILC_STR_UI_SHORT(SILC_ID_CLIENT),
-                    SILC_STR_UI_SHORT(SILC_ID_CLIENT_LEN),
-                    SILC_STR_UI_XNSTRING(id_string, SILC_ID_CLIENT_LEN),
+                    SILC_STR_UI_SHORT(id_len),
+                    SILC_STR_UI_XNSTRING(id_string, id_len),
                     SILC_STR_END);
   silc_server_packet_send(server, sock, SILC_PACKET_NEW_ID, 0, 
                          reply->data, reply->len, FALSE);
                     SILC_STR_END);
   silc_server_packet_send(server, sock, SILC_PACKET_NEW_ID, 0, 
                          reply->data, reply->len, FALSE);
@@ -1508,7 +1509,7 @@ SilcServerEntry silc_server_new_server(SilcServer server,
       server->router->connection != sock)
     silc_server_send_new_id(server, server->router->connection,
                            TRUE, new_server->id, SILC_ID_SERVER, 
       server->router->connection != sock)
     silc_server_send_new_id(server, server->router->connection,
                            TRUE, new_server->id, SILC_ID_SERVER, 
-                           SILC_ID_SERVER_LEN);
+                           silc_id_get_len(server_id, SILC_ID_SERVER));
 
   if (server->server_type == SILC_ROUTER)
     server->stat.cell_servers++;
 
   if (server->server_type == SILC_ROUTER)
     server->stat.cell_servers++;
@@ -1624,7 +1625,7 @@ static void silc_server_new_id_real(SilcServer server,
 
   case SILC_ID_SERVER:
     /* If the ID is mine, ignore it. */
 
   case SILC_ID_SERVER:
     /* If the ID is mine, ignore it. */
-    if (!SILC_ID_SERVER_COMPARE(id, server->id)) {
+    if (SILC_ID_SERVER_COMPARE(id, server->id)) {
       SILC_LOG_DEBUG(("Ignoring my own ID as new ID"));
       break;
     }
       SILC_LOG_DEBUG(("Ignoring my own ID as new ID"));
       break;
     }
@@ -1834,14 +1835,12 @@ void silc_server_new_channel(SilcServer server,
       if (!channel->id)
        channel_id = silc_id_dup(channel_id, SILC_ID_CHANNEL);
 
       if (!channel->id)
        channel_id = silc_id_dup(channel_id, SILC_ID_CHANNEL);
 
-      if (SILC_ID_CHANNEL_COMPARE(channel_id, channel->id)) {
+      if (!SILC_ID_CHANNEL_COMPARE(channel_id, channel->id)) {
        /* They don't match, send CHANNEL_CHANGE notify to the server to
           force the ID change. */
        SILC_LOG_DEBUG(("Forcing the server to change Channel ID"));
        silc_server_send_notify_channel_change(server, sock, FALSE, 
        /* They don't match, send CHANNEL_CHANGE notify to the server to
           force the ID change. */
        SILC_LOG_DEBUG(("Forcing the server to change Channel ID"));
        silc_server_send_notify_channel_change(server, sock, FALSE, 
-                                              channel_id,
-                                              channel->id, 
-                                              SILC_ID_CHANNEL_LEN);
+                                              channel_id, channel->id);
       }
 
       /* If the mode is different from what we have then enforce the
       }
 
       /* If the mode is different from what we have then enforce the
@@ -1851,7 +1850,7 @@ void silc_server_new_channel(SilcServer server,
        SILC_LOG_DEBUG(("Forcing the server to change channel mode"));
        silc_server_send_notify_cmode(server, sock, FALSE, channel,
                                      channel->mode, server->id,
        SILC_LOG_DEBUG(("Forcing the server to change channel mode"));
        silc_server_send_notify_cmode(server, sock, FALSE, channel,
                                      channel->mode, server->id,
-                                     SILC_ID_SERVER, SILC_ID_SERVER_LEN,
+                                     SILC_ID_SERVER,
                                      channel->cipher, channel->hmac_name);
       }
 
                                      channel->cipher, channel->hmac_name);
       }
 
index 814758b82a4806190b4805b4d2bcf4f8c8657f98..dc0d84a1905b919268e4cad24a88d9bb9aa5e9db 100644 (file)
@@ -129,14 +129,14 @@ void silc_server_packet_send_dest(SilcServer server,
 
   if (dst_id) {
     dst_id_data = silc_id_id2str(dst_id, dst_id_type);
 
   if (dst_id) {
     dst_id_data = silc_id_id2str(dst_id, dst_id_type);
-    dst_id_len = silc_id_get_len(dst_id_type);
+    dst_id_len = silc_id_get_len(dst_id, dst_id_type);
   }
 
   /* Set the packet context pointers */
   packetdata.type = type;
   packetdata.flags = flags;
   packetdata.src_id = silc_id_id2str(server->id, server->id_type);
   }
 
   /* Set the packet context pointers */
   packetdata.type = type;
   packetdata.flags = flags;
   packetdata.src_id = silc_id_id2str(server->id, server->id_type);
-  packetdata.src_id_len = SILC_ID_SERVER_LEN;
+  packetdata.src_id_len = silc_id_get_len(server->id, server->id_type);
   packetdata.src_id_type = server->id_type;
   packetdata.dst_id = dst_id_data;
   packetdata.dst_id_len = dst_id_len;
   packetdata.src_id_type = server->id_type;
   packetdata.dst_id = dst_id_data;
   packetdata.dst_id_len = dst_id_len;
@@ -220,12 +220,12 @@ void silc_server_packet_send_srcdest(SilcServer server,
 
   if (dst_id) {
     dst_id_data = silc_id_id2str(dst_id, dst_id_type);
 
   if (dst_id) {
     dst_id_data = silc_id_id2str(dst_id, dst_id_type);
-    dst_id_len = silc_id_get_len(dst_id_type);
+    dst_id_len = silc_id_get_len(dst_id, dst_id_type);
   }
 
   if (src_id) {
     src_id_data = silc_id_id2str(src_id, src_id_type);
   }
 
   if (src_id) {
     src_id_data = silc_id_id2str(src_id, src_id_type);
-    src_id_len = silc_id_get_len(src_id_type);
+    src_id_len = silc_id_get_len(src_id, src_id_type);
   }
 
   /* Set the packet context pointers */
   }
 
   /* Set the packet context pointers */
@@ -298,7 +298,7 @@ void silc_server_packet_broadcast(SilcServer server,
   /* If the packet is originated from our primary route we are
      not allowed to send the packet. */
   id = silc_id_str2id(packet->src_id, packet->src_id_len, packet->src_id_type);
   /* If the packet is originated from our primary route we are
      not allowed to send the packet. */
   id = silc_id_str2id(packet->src_id, packet->src_id_len, packet->src_id_type);
-  if (id && SILC_ID_SERVER_COMPARE(id, server->router->id)) {
+  if (id && !SILC_ID_SERVER_COMPARE(id, server->router->id)) {
     idata = (SilcIDListData)sock->user_data;
 
     silc_buffer_push(buffer, buffer->data - buffer->head);
     idata = (SilcIDListData)sock->user_data;
 
     silc_buffer_push(buffer, buffer->data - buffer->head);
@@ -431,11 +431,11 @@ void silc_server_packet_send_to_channel(SilcServer server,
   packetdata.flags = 0;
   packetdata.type = type;
   packetdata.src_id = silc_id_id2str(server->id, SILC_ID_SERVER);
   packetdata.flags = 0;
   packetdata.type = type;
   packetdata.src_id = silc_id_id2str(server->id, SILC_ID_SERVER);
-  packetdata.src_id_len = SILC_ID_SERVER_LEN;
+  packetdata.src_id_len = silc_id_get_len(server->id, SILC_ID_SERVER);
   packetdata.src_id_type = SILC_ID_SERVER;
   packetdata.dst_id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
   packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
   packetdata.src_id_type = SILC_ID_SERVER;
   packetdata.dst_id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
   packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
-  packetdata.dst_id_type = SILC_ID_CHANNEL;
+  packetdata.dst_id_type = silc_id_get_len(channel->id, SILC_ID_CHANNEL);
   packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN + 
     packetdata.src_id_len + packetdata.dst_id_len;
   packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
   packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN + 
     packetdata.src_id_len + packetdata.dst_id_len;
   packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
@@ -611,11 +611,11 @@ void silc_server_packet_relay_to_channel(SilcServer server,
   packetdata.flags = 0;
   packetdata.type = SILC_PACKET_CHANNEL_MESSAGE;
   packetdata.src_id = silc_id_id2str(sender, sender_type);
   packetdata.flags = 0;
   packetdata.type = SILC_PACKET_CHANNEL_MESSAGE;
   packetdata.src_id = silc_id_id2str(sender, sender_type);
-  packetdata.src_id_len = silc_id_get_len(sender_type);
+  packetdata.src_id_len = silc_id_get_len(sender, sender_type);
   packetdata.src_id_type = sender_type;
   packetdata.dst_id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
   packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
   packetdata.src_id_type = sender_type;
   packetdata.dst_id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
   packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
-  packetdata.dst_id_type = SILC_ID_CHANNEL;
+  packetdata.dst_id_type = silc_id_get_len(channel->id, SILC_ID_CHANNEL);
   packetdata.padlen = SILC_PACKET_PADLEN((SILC_PACKET_HEADER_LEN +
                                          packetdata.src_id_len +
                                          packetdata.dst_id_len));
   packetdata.padlen = SILC_PACKET_PADLEN((SILC_PACKET_HEADER_LEN +
                                          packetdata.src_id_len +
                                          packetdata.dst_id_len));
@@ -662,7 +662,7 @@ void silc_server_packet_relay_to_channel(SilcServer server,
 
       /* If sender is one on the channel do not send it the packet. */
       if (!found && sender_type == SILC_ID_CLIENT &&
 
       /* If sender is one on the channel do not send it the packet. */
       if (!found && sender_type == SILC_ID_CLIENT &&
-         !SILC_ID_CLIENT_COMPARE(client->id, sender)) {
+         SILC_ID_CLIENT_COMPARE(client->id, sender)) {
        found = TRUE;
        continue;
       }
        found = TRUE;
        continue;
       }
@@ -674,7 +674,7 @@ void silc_server_packet_relay_to_channel(SilcServer server,
 
        /* Sender maybe server as well so we want to make sure that
           we won't send the message to the server it came from. */
 
        /* Sender maybe server as well so we want to make sure that
           we won't send the message to the server it came from. */
-       if (!found && !SILC_ID_SERVER_COMPARE(client->router->id, sender)) {
+       if (!found && SILC_ID_SERVER_COMPARE(client->router->id, sender)) {
          found = TRUE;
          continue;
        }
          found = TRUE;
          continue;
        }
@@ -963,8 +963,7 @@ void silc_server_send_notify_channel_change(SilcServer server,
                                            SilcSocketConnection sock,
                                            int broadcast,
                                            SilcChannelID *old_id,
                                            SilcSocketConnection sock,
                                            int broadcast,
                                            SilcChannelID *old_id,
-                                           SilcChannelID *new_id,
-                                           uint32 id_len)
+                                           SilcChannelID *new_id)
 {
   SilcBuffer idp1, idp2;
 
 {
   SilcBuffer idp1, idp2;
 
@@ -985,8 +984,7 @@ void silc_server_send_notify_nick_change(SilcServer server,
                                         SilcSocketConnection sock,
                                         int broadcast,
                                         SilcClientID *old_id,
                                         SilcSocketConnection sock,
                                         int broadcast,
                                         SilcClientID *old_id,
-                                        SilcClientID *new_id,
-                                        uint32 id_len)
+                                        SilcClientID *new_id)
 {
   SilcBuffer idp1, idp2;
 
 {
   SilcBuffer idp1, idp2;
 
@@ -1007,8 +1005,7 @@ void silc_server_send_notify_join(SilcServer server,
                                  SilcSocketConnection sock,
                                  int broadcast,
                                  SilcChannelEntry channel,
                                  SilcSocketConnection sock,
                                  int broadcast,
                                  SilcChannelEntry channel,
-                                 SilcClientID *client_id,
-                                 uint32 client_id_len)
+                                 SilcClientID *client_id)
 {
   SilcBuffer idp1, idp2;
 
 {
   SilcBuffer idp1, idp2;
 
@@ -1028,8 +1025,7 @@ void silc_server_send_notify_leave(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcChannelEntry channel,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcChannelEntry channel,
-                                  SilcClientID *client_id,
-                                  uint32 client_id_len)
+                                  SilcClientID *client_id)
 {
   SilcBuffer idp;
 
 {
   SilcBuffer idp;
 
@@ -1050,7 +1046,6 @@ void silc_server_send_notify_cmode(SilcServer server,
                                   SilcChannelEntry channel,
                                   uint32 mode_mask,
                                   void *id, SilcIdType id_type,
                                   SilcChannelEntry channel,
                                   uint32 mode_mask,
                                   void *id, SilcIdType id_type,
-                                  uint32 id_len,
                                   char *cipher, char *hmac)
 {
   SilcBuffer idp;
                                   char *cipher, char *hmac)
 {
   SilcBuffer idp;
@@ -1078,9 +1073,7 @@ void silc_server_send_notify_cumode(SilcServer server,
                                    SilcChannelEntry channel,
                                    uint32 mode_mask,
                                    void *id, SilcIdType id_type,
                                    SilcChannelEntry channel,
                                    uint32 mode_mask,
                                    void *id, SilcIdType id_type,
-                                   uint32 id_len,
-                                   SilcClientID *target,
-                                   uint32 target_len)
+                                   SilcClientID *target)
 {
   SilcBuffer idp1, idp2;
   unsigned char mode[4];
 {
   SilcBuffer idp1, idp2;
   unsigned char mode[4];
@@ -1108,7 +1101,6 @@ void silc_server_send_notify_signoff(SilcServer server,
                                     SilcSocketConnection sock,
                                     int broadcast,
                                     SilcClientID *client_id,
                                     SilcSocketConnection sock,
                                     int broadcast,
                                     SilcClientID *client_id,
-                                    uint32 client_id_len,
                                     char *message)
 {
   SilcBuffer idp;
                                     char *message)
 {
   SilcBuffer idp;
@@ -1131,7 +1123,6 @@ void silc_server_send_notify_topic_set(SilcServer server,
                                       int broadcast,
                                       SilcChannelEntry channel,
                                       SilcClientID *client_id,
                                       int broadcast,
                                       SilcChannelEntry channel,
                                       SilcClientID *client_id,
-                                      uint32 client_id_len,
                                       char *topic)
 {
   SilcBuffer idp;
                                       char *topic)
 {
   SilcBuffer idp;
@@ -1155,7 +1146,6 @@ void silc_server_send_notify_kicked(SilcServer server,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
-                                   uint32 client_id_len,
                                    char *comment)
 {
   SilcBuffer idp;
                                    char *comment)
 {
   SilcBuffer idp;
@@ -1176,7 +1166,6 @@ void silc_server_send_notify_killed(SilcServer server,
                                    SilcSocketConnection sock,
                                    int broadcast,
                                    SilcClientID *client_id,
                                    SilcSocketConnection sock,
                                    int broadcast,
                                    SilcClientID *client_id,
-                                   uint32 client_id_len,
                                    char *comment)
 {
   SilcBuffer idp;
                                    char *comment)
 {
   SilcBuffer idp;
@@ -1197,7 +1186,6 @@ void silc_server_send_notify_umode(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcClientID *client_id,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcClientID *client_id,
-                                  uint32 client_id_len,
                                   uint32 mode_mask)
 {
   SilcBuffer idp;
                                   uint32 mode_mask)
 {
   SilcBuffer idp;
@@ -1244,7 +1232,6 @@ void silc_server_send_notify_invite(SilcServer server,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
-                                   uint32 client_id_len,
                                    char *add, char *del)
 {
   SilcBuffer idp, idp2;
                                    char *add, char *del)
 {
   SilcBuffer idp, idp2;
@@ -1354,7 +1341,7 @@ void silc_server_send_notify_on_channels(SilcServer server,
   packetdata.flags = 0;
   packetdata.type = SILC_PACKET_NOTIFY;
   packetdata.src_id = silc_id_id2str(server->id, SILC_ID_SERVER);
   packetdata.flags = 0;
   packetdata.type = SILC_PACKET_NOTIFY;
   packetdata.src_id = silc_id_id2str(server->id, SILC_ID_SERVER);
-  packetdata.src_id_len = SILC_ID_SERVER_LEN;
+  packetdata.src_id_len = silc_id_get_len(server->id, SILC_ID_SERVER);
   packetdata.src_id_type = SILC_ID_SERVER;
 
   silc_list_start(client->channels);
   packetdata.src_id_type = SILC_ID_SERVER;
 
   silc_list_start(client->channels);
@@ -1392,7 +1379,7 @@ void silc_server_send_notify_on_channels(SilcServer server,
        idata = (SilcIDListData)c->router;
        
        packetdata.dst_id = silc_id_id2str(c->router->id, SILC_ID_SERVER);
        idata = (SilcIDListData)c->router;
        
        packetdata.dst_id = silc_id_id2str(c->router->id, SILC_ID_SERVER);
-       packetdata.dst_id_len = SILC_ID_SERVER_LEN;
+       packetdata.dst_id_len = silc_id_get_len(c->router->id, SILC_ID_SERVER);
        packetdata.dst_id_type = SILC_ID_SERVER;
        packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN + 
          packetdata.src_id_len + packetdata.dst_id_len;
        packetdata.dst_id_type = SILC_ID_SERVER;
        packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN + 
          packetdata.src_id_len + packetdata.dst_id_len;
@@ -1428,7 +1415,7 @@ void silc_server_send_notify_on_channels(SilcServer server,
        idata = (SilcIDListData)c;
        
        packetdata.dst_id = silc_id_id2str(c->id, SILC_ID_CLIENT);
        idata = (SilcIDListData)c;
        
        packetdata.dst_id = silc_id_id2str(c->id, SILC_ID_CLIENT);
-       packetdata.dst_id_len = SILC_ID_CLIENT_LEN;
+       packetdata.dst_id_len = silc_id_get_len(c->id, SILC_ID_CLIENT);
        packetdata.dst_id_type = SILC_ID_CLIENT;
        packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN + 
          packetdata.src_id_len + packetdata.dst_id_len;
        packetdata.dst_id_type = SILC_ID_CLIENT;
        packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN + 
          packetdata.src_id_len + packetdata.dst_id_len;
@@ -1543,7 +1530,9 @@ void silc_server_send_channel_key(SilcServer server,
  
   /* Encode channel key packet */
   tmp_len = strlen(channel->channel_key->cipher->name);
  
   /* Encode channel key packet */
   tmp_len = strlen(channel->channel_key->cipher->name);
-  packet = silc_channel_key_payload_encode(SILC_ID_CHANNEL_LEN, chid, tmp_len,
+  packet = silc_channel_key_payload_encode(silc_id_get_len(channel->id,
+                                                          SILC_ID_CHANNEL),
+                                          chid, tmp_len,
                                            channel->channel_key->cipher->name,
                                            channel->key_len / 8, channel->key);
  
                                            channel->channel_key->cipher->name,
                                            channel->key_len / 8, channel->key);
  
index 944284cf1d577f33b41c4a66011952185780d778..5a18523329e62e1455e46fa1e67708806f2d8075 100644 (file)
@@ -108,33 +108,28 @@ void silc_server_send_notify_channel_change(SilcServer server,
                                            SilcSocketConnection sock,
                                            int broadcast,
                                            SilcChannelID *old_id,
                                            SilcSocketConnection sock,
                                            int broadcast,
                                            SilcChannelID *old_id,
-                                           SilcChannelID *new_id,
-                                           uint32 id_len);
+                                           SilcChannelID *new_id);
 void silc_server_send_notify_nick_change(SilcServer server,
                                         SilcSocketConnection sock,
                                         int broadcast,
                                         SilcClientID *old_id,
 void silc_server_send_notify_nick_change(SilcServer server,
                                         SilcSocketConnection sock,
                                         int broadcast,
                                         SilcClientID *old_id,
-                                        SilcClientID *new_id,
-                                        uint32 id_len);
+                                        SilcClientID *new_id);
 void silc_server_send_notify_join(SilcServer server,
                                  SilcSocketConnection sock,
                                  int broadcast,
                                  SilcChannelEntry channel,
 void silc_server_send_notify_join(SilcServer server,
                                  SilcSocketConnection sock,
                                  int broadcast,
                                  SilcChannelEntry channel,
-                                 SilcClientID *client_id,
-                                 uint32 client_id_len);
+                                 SilcClientID *client_id);
 void silc_server_send_notify_leave(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcChannelEntry channel,
 void silc_server_send_notify_leave(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcChannelEntry channel,
-                                  SilcClientID *client_id,
-                                  uint32 client_id_len);
+                                  SilcClientID *client_id);
 void silc_server_send_notify_cmode(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcChannelEntry channel,
                                   uint32 mode_mask,
                                   void *id, SilcIdType id_type,
 void silc_server_send_notify_cmode(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcChannelEntry channel,
                                   uint32 mode_mask,
                                   void *id, SilcIdType id_type,
-                                  uint32 id_len,
                                   char *cipher, char *hmac);
 void silc_server_send_notify_cumode(SilcServer server,
                                    SilcSocketConnection sock,
                                   char *cipher, char *hmac);
 void silc_server_send_notify_cumode(SilcServer server,
                                    SilcSocketConnection sock,
@@ -142,40 +137,33 @@ void silc_server_send_notify_cumode(SilcServer server,
                                    SilcChannelEntry channel,
                                    uint32 mode_mask,
                                    void *id, SilcIdType id_type,
                                    SilcChannelEntry channel,
                                    uint32 mode_mask,
                                    void *id, SilcIdType id_type,
-                                   uint32 id_len,
-                                   SilcClientID *target,
-                                   uint32 target_len);
+                                   SilcClientID *target);
 void silc_server_send_notify_signoff(SilcServer server,
                                     SilcSocketConnection sock,
                                     int broadcast,
                                     SilcClientID *client_id,
 void silc_server_send_notify_signoff(SilcServer server,
                                     SilcSocketConnection sock,
                                     int broadcast,
                                     SilcClientID *client_id,
-                                    uint32 client_id_len,
                                     char *message);
 void silc_server_send_notify_topic_set(SilcServer server,
                                       SilcSocketConnection sock,
                                       int broadcast,
                                       SilcChannelEntry channel,
                                       SilcClientID *client_id,
                                     char *message);
 void silc_server_send_notify_topic_set(SilcServer server,
                                       SilcSocketConnection sock,
                                       int broadcast,
                                       SilcChannelEntry channel,
                                       SilcClientID *client_id,
-                                      uint32 client_id_len,
                                       char *topic);
 void silc_server_send_notify_kicked(SilcServer server,
                                    SilcSocketConnection sock,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
                                       char *topic);
 void silc_server_send_notify_kicked(SilcServer server,
                                    SilcSocketConnection sock,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
-                                   uint32 client_id_len,
                                    char *comment);
 void silc_server_send_notify_killed(SilcServer server,
                                    SilcSocketConnection sock,
                                    int broadcast,
                                    SilcClientID *client_id,
                                    char *comment);
 void silc_server_send_notify_killed(SilcServer server,
                                    SilcSocketConnection sock,
                                    int broadcast,
                                    SilcClientID *client_id,
-                                   uint32 client_id_len,
                                    char *comment);
 void silc_server_send_notify_umode(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcClientID *client_id,
                                    char *comment);
 void silc_server_send_notify_umode(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcClientID *client_id,
-                                  uint32 client_id_len,
                                   uint32 mode_mask);
 void silc_server_send_notify_ban(SilcServer server,
                                 SilcSocketConnection sock,
                                   uint32 mode_mask);
 void silc_server_send_notify_ban(SilcServer server,
                                 SilcSocketConnection sock,
@@ -187,7 +175,6 @@ void silc_server_send_notify_invite(SilcServer server,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
-                                   uint32 client_id_len,
                                    char *add, char *del);
 void silc_server_send_notify_dest(SilcServer server,
                                  SilcSocketConnection sock,
                                    char *add, char *del);
 void silc_server_send_notify_dest(SilcServer server,
                                  SilcSocketConnection sock,
index f166075aaf1781857ab1dd8fb8e26f7c43c89c49..eac09e64d42c27a03b350c79178b290170e11247 100644 (file)
@@ -72,9 +72,10 @@ SilcSocketConnection silc_server_route_get(SilcServer server, void *id,
                                           SilcIdType id_type)
 {
   if (server->server_type == SILC_ROUTER) {
                                           SilcIdType id_type)
 {
   if (server->server_type == SILC_ROUTER) {
-    uint32 dest;
-    uint16 port;
+    uint32 dest = 0;
+    uint16 port = 0;
     SilcServerEntry router = NULL;
     SilcServerEntry router = NULL;
+#if 0
 
     switch(id_type) {
     case SILC_ID_CLIENT:
 
     switch(id_type) {
     case SILC_ID_CLIENT:
@@ -93,6 +94,8 @@ SilcSocketConnection silc_server_route_get(SilcServer server, void *id,
       return NULL;
     }
 
       return NULL;
     }
 
+#endif
+
     router = silc_server_route_check(dest, port);
     if (!router)
       return (SilcSocketConnection)server->id_entry->router->connection;
     router = silc_server_route_check(dest, port);
     if (!router)
       return (SilcSocketConnection)server->id_entry->router->connection;
index eaa5eaf4f7abd23e0cdcfafe8ef2c89948eae861..e6a896000fe0f0c18b6fa4207414853a8b4528d0 100644 (file)
@@ -216,7 +216,7 @@ int silc_server_init(SilcServer server)
     
     server->id = id;
     server->id_string = silc_id_id2str(id, SILC_ID_SERVER);
     
     server->id = id;
     server->id_string = silc_id_id2str(id, SILC_ID_SERVER);
-    server->id_string_len = silc_id_get_len(SILC_ID_SERVER);
+    server->id_string_len = silc_id_get_len(id, SILC_ID_SERVER);
     server->id_type = SILC_ID_SERVER;
     server->server_name = server->config->server_info->server_name;
 
     server->id_type = SILC_ID_SERVER;
     server->server_name = server->config->server_info->server_name;
 
@@ -828,6 +828,7 @@ SILC_TASK_CALLBACK(silc_server_connect_to_router_final)
   SilcBuffer packet;
   SilcServerHBContext hb_context;
   unsigned char *id_string;
   SilcBuffer packet;
   SilcServerHBContext hb_context;
   unsigned char *id_string;
+  uint32 id_len;
   SilcIDListData idata;
 
   SILC_LOG_DEBUG(("Start"));
   SilcIDListData idata;
 
   SILC_LOG_DEBUG(("Start"));
@@ -856,12 +857,12 @@ SILC_TASK_CALLBACK(silc_server_connect_to_router_final)
   /* Send NEW_SERVER packet to the router. We will become registered
      to the SILC network after sending this packet. */
   id_string = silc_id_id2str(server->id, SILC_ID_SERVER);
   /* Send NEW_SERVER packet to the router. We will become registered
      to the SILC network after sending this packet. */
   id_string = silc_id_id2str(server->id, SILC_ID_SERVER);
-  packet = silc_buffer_alloc(2 + 2 + SILC_ID_SERVER_LEN + 
-                            strlen(server->server_name));
+  id_len = silc_id_get_len(server->id, SILC_ID_SERVER);
+  packet = silc_buffer_alloc(2 + 2 + id_len + strlen(server->server_name));
   silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
   silc_buffer_format(packet,
   silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
   silc_buffer_format(packet,
-                    SILC_STR_UI_SHORT(SILC_ID_SERVER_LEN),
-                    SILC_STR_UI_XNSTRING(id_string, SILC_ID_SERVER_LEN),
+                    SILC_STR_UI_SHORT(id_len),
+                    SILC_STR_UI_XNSTRING(id_string, id_len),
                     SILC_STR_UI_SHORT(strlen(server->server_name)),
                     SILC_STR_UI_XNSTRING(server->server_name,
                                          strlen(server->server_name)),
                     SILC_STR_UI_SHORT(strlen(server->server_name)),
                     SILC_STR_UI_XNSTRING(server->server_name,
                                          strlen(server->server_name)),
@@ -1538,7 +1539,7 @@ SILC_TASK_CALLBACK(silc_server_packet_parse_real)
     if (client && client->id) {
       void *id = silc_id_str2id(packet->src_id, packet->src_id_len,
                                packet->src_id_type);
     if (client && client->id) {
       void *id = silc_id_str2id(packet->src_id, packet->src_id_len,
                                packet->src_id_type);
-      if (!id || SILC_ID_CLIENT_COMPARE(client->id, id)) {
+      if (!id || !SILC_ID_CLIENT_COMPARE(client->id, id)) {
        silc_free(id);
        goto out;
       }
        silc_free(id);
        goto out;
       }
@@ -1552,7 +1553,7 @@ SILC_TASK_CALLBACK(silc_server_packet_parse_real)
     if (!(packet->flags & SILC_PACKET_FLAG_BROADCAST) &&
        packet->dst_id_type == SILC_ID_SERVER && 
        sock->type != SILC_SOCKET_TYPE_CLIENT &&
     if (!(packet->flags & SILC_PACKET_FLAG_BROADCAST) &&
        packet->dst_id_type == SILC_ID_SERVER && 
        sock->type != SILC_SOCKET_TYPE_CLIENT &&
-       SILC_ID_SERVER_COMPARE(packet->dst_id, server->id_string)) {
+       memcmp(packet->dst_id, server->id_string, packet->dst_id_len)) {
       
       /* Route the packet to fastest route for the destination ID */
       void *id = silc_id_str2id(packet->dst_id, packet->dst_id_len, 
       
       /* Route the packet to fastest route for the destination ID */
       void *id = silc_id_str2id(packet->dst_id, packet->dst_id_len, 
@@ -2179,8 +2180,7 @@ void silc_server_free_client_data(SilcServer server,
   if (notify && !server->standalone && server->router)
     silc_server_send_notify_signoff(server, server->router->connection,
                                    server->server_type == SILC_SERVER ?
   if (notify && !server->standalone && server->router)
     silc_server_send_notify_signoff(server, server->router->connection,
                                    server->server_type == SILC_SERVER ?
-                                   FALSE : TRUE, client->id, 
-                                   SILC_ID_CLIENT_LEN, signoff);
+                                   FALSE : TRUE, client->id, signoff);
 
   /* Remove client from all channels */
   if (notify)
 
   /* Remove client from all channels */
   if (notify)
@@ -2806,7 +2806,8 @@ SilcChannelEntry silc_server_create_new_channel(SilcServer server,
      to our primary route. */
   if (broadcast && server->standalone == FALSE)
     silc_server_send_new_channel(server, server->router->connection, TRUE, 
      to our primary route. */
   if (broadcast && server->standalone == FALSE)
     silc_server_send_new_channel(server, server->router->connection, TRUE, 
-                                channel_name, entry->id, SILC_ID_CHANNEL_LEN,
+                                channel_name, entry->id, 
+                                silc_id_get_len(entry->id, SILC_ID_CHANNEL),
                                 entry->mode);
 
   server->stat.my_channels++;
                                 entry->mode);
 
   server->stat.my_channels++;
@@ -2864,7 +2865,8 @@ silc_server_create_new_channel_with_id(SilcServer server,
      to our primary route. */
   if (broadcast && server->standalone == FALSE)
     silc_server_send_new_channel(server, server->router->connection, TRUE, 
      to our primary route. */
   if (broadcast && server->standalone == FALSE)
     silc_server_send_new_channel(server, server->router->connection, TRUE, 
-                                channel_name, entry->id, SILC_ID_CHANNEL_LEN,
+                                channel_name, entry->id, 
+                                silc_id_get_len(entry->id, SILC_ID_CHANNEL),
                                 entry->mode);
 
   server->stat.my_channels++;
                                 entry->mode);
 
   server->stat.my_channels++;
@@ -3312,6 +3314,7 @@ void silc_server_announce_get_channels(SilcServer server,
   SilcIDCacheEntry id_cache;
   SilcChannelEntry channel;
   unsigned char *cid;
   SilcIDCacheEntry id_cache;
   SilcChannelEntry channel;
   unsigned char *cid;
+  uint32 id_len;
   uint16 name_len;
   int len;
 
   uint16 name_len;
   int len;
 
@@ -3325,9 +3328,10 @@ void silc_server_announce_get_channels(SilcServer server,
        channel = (SilcChannelEntry)id_cache->context;
        
        cid = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
        channel = (SilcChannelEntry)id_cache->context;
        
        cid = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
+       id_len = silc_id_get_len(channel->id, SILC_ID_CHANNEL);
        name_len = strlen(channel->channel_name);
 
        name_len = strlen(channel->channel_name);
 
-       len = 4 + name_len + SILC_ID_CHANNEL_LEN + 4;
+       len = 4 + name_len + id_len + 4;
        *channels = 
          silc_buffer_realloc(*channels, 
                              (*channels ? (*channels)->truelen + len : len));
        *channels = 
          silc_buffer_realloc(*channels, 
                              (*channels ? (*channels)->truelen + len : len));
@@ -3337,8 +3341,8 @@ void silc_server_announce_get_channels(SilcServer server,
                           SILC_STR_UI_SHORT(name_len),
                           SILC_STR_UI_XNSTRING(channel->channel_name, 
                                                name_len),
                           SILC_STR_UI_SHORT(name_len),
                           SILC_STR_UI_XNSTRING(channel->channel_name, 
                                                name_len),
-                          SILC_STR_UI_SHORT(SILC_ID_CHANNEL_LEN),
-                          SILC_STR_UI_XNSTRING(cid, SILC_ID_CHANNEL_LEN),
+                          SILC_STR_UI_SHORT(id_len),
+                          SILC_STR_UI_XNSTRING(cid, id_len),
                           SILC_STR_UI_INT(channel->mode),
                           SILC_STR_END);
        silc_buffer_pull(*channels, len);
                           SILC_STR_UI_INT(channel->mode),
                           SILC_STR_END);
        silc_buffer_pull(*channels, len);
@@ -3456,6 +3460,8 @@ void silc_server_get_users_on_channel(SilcServer server,
   SilcBuffer idp;
   uint32 list_count = 0;
 
   SilcBuffer idp;
   uint32 list_count = 0;
 
+  /* XXX rewrite - this does not support IPv6 based Client ID's. */
+
   client_id_list = silc_buffer_alloc((SILC_ID_CLIENT_LEN + 4) * 
                                     silc_list_count(channel->user_list));
   client_mode_list = silc_buffer_alloc(4 * 
   client_id_list = silc_buffer_alloc((SILC_ID_CLIENT_LEN + 4) * 
                                     silc_list_count(channel->user_list));
   client_mode_list = silc_buffer_alloc(4 * 
@@ -3519,7 +3525,7 @@ void silc_server_save_users_on_channel(SilcServer server,
     SILC_GET32_MSB(mode, mode_list->data);
     silc_buffer_pull(mode_list, 4);
 
     SILC_GET32_MSB(mode, mode_list->data);
     silc_buffer_pull(mode_list, 4);
 
-    if (noadd && !SILC_ID_CLIENT_COMPARE(client_id, noadd)) {
+    if (noadd && SILC_ID_CLIENT_COMPARE(client_id, noadd)) {
       silc_free(client_id);
       continue;
     }
       silc_free(client_id);
       continue;
     }
@@ -3660,6 +3666,7 @@ SilcBuffer silc_server_get_client_channel_list(SilcServer server,
   SilcChannelEntry channel;
   SilcChannelClientEntry chl;
   unsigned char *cid;
   SilcChannelEntry channel;
   SilcChannelClientEntry chl;
   unsigned char *cid;
+  uint32 id_len;
   uint16 name_len;
   int len;
 
   uint16 name_len;
   int len;
 
@@ -3671,9 +3678,10 @@ SilcBuffer silc_server_get_client_channel_list(SilcServer server,
       continue;
 
     cid = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
       continue;
 
     cid = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
+    id_len = silc_id_get_len(channel->id, SILC_ID_CHANNEL);
     name_len = strlen(channel->channel_name);
     
     name_len = strlen(channel->channel_name);
     
-    len = 4 + name_len + SILC_ID_CHANNEL_LEN + 4;
+    len = 4 + name_len + id_len + 4;
     buffer = silc_buffer_realloc(buffer, 
                                 (buffer ? (buffer)->truelen + len : len));
     silc_buffer_pull_tail(buffer, ((buffer)->end - (buffer)->data));
     buffer = silc_buffer_realloc(buffer, 
                                 (buffer ? (buffer)->truelen + len : len));
     silc_buffer_pull_tail(buffer, ((buffer)->end - (buffer)->data));
@@ -3681,8 +3689,8 @@ SilcBuffer silc_server_get_client_channel_list(SilcServer server,
                       SILC_STR_UI_SHORT(name_len),
                       SILC_STR_UI_XNSTRING(channel->channel_name, 
                                            name_len),
                       SILC_STR_UI_SHORT(name_len),
                       SILC_STR_UI_XNSTRING(channel->channel_name, 
                                            name_len),
-                      SILC_STR_UI_SHORT(SILC_ID_CHANNEL_LEN),
-                      SILC_STR_UI_XNSTRING(cid, SILC_ID_CHANNEL_LEN),
+                      SILC_STR_UI_SHORT(id_len),
+                      SILC_STR_UI_XNSTRING(cid, id_len),
                       SILC_STR_UI_INT(chl->mode), /* Client's mode */
                       SILC_STR_END);
     silc_buffer_pull(buffer, len);
                       SILC_STR_UI_INT(chl->mode), /* Client's mode */
                       SILC_STR_END);
     silc_buffer_pull(buffer, len);
index d4061dd45bfb6d7c80f3795da96d5cddb0ea0a4e..42a5afe53712bb588b7336c344ba1482404b7263 100644 (file)
@@ -44,7 +44,8 @@ void silc_id_create_server_id(int sock, SilcRng rng, SilcServerID **new_id)
   }
 
   /* Create the ID */
   }
 
   /* Create the ID */
-  (*new_id)->ip = server.sin_addr;
+  SILC_PUT32_MSB(server.sin_addr.s_addr, (*new_id)->ip.data);
+  (*new_id)->ip.data_len = 4;
   (*new_id)->port = server.sin_port;
   (*new_id)->rnd = silc_rng_get_rn16(rng);
 
   (*new_id)->port = server.sin_port;
   (*new_id)->rnd = silc_rng_get_rn16(rng);
 
@@ -67,7 +68,8 @@ void silc_id_create_client_id(SilcServerID *server_id, SilcRng rng,
   silc_hash_make(md5hash, nickname, strlen(nickname), hash);
 
   /* Create the ID */
   silc_hash_make(md5hash, nickname, strlen(nickname), hash);
 
   /* Create the ID */
-  (*new_id)->ip.s_addr = server_id->ip.s_addr;
+  memcpy((*new_id)->ip.data, server_id->ip.data, server_id->ip.data_len);
+  (*new_id)->ip.data_len = server_id->ip.data_len;
   (*new_id)->rnd = silc_rng_get_byte(rng);
   memcpy((*new_id)->hash, hash, CLIENTID_HASH_LEN);
 
   (*new_id)->rnd = silc_rng_get_byte(rng);
   memcpy((*new_id)->hash, hash, CLIENTID_HASH_LEN);
 
@@ -84,7 +86,8 @@ void silc_id_create_channel_id(SilcServerID *router_id, SilcRng rng,
   *new_id = silc_calloc(1, sizeof(**new_id));
 
   /* Create the ID */
   *new_id = silc_calloc(1, sizeof(**new_id));
 
   /* Create the ID */
-  (*new_id)->ip.s_addr = router_id->ip.s_addr;
+  memcpy((*new_id)->ip.data, router_id->ip.data, router_id->ip.data_len);
+  (*new_id)->ip.data_len = router_id->ip.data_len;
   (*new_id)->port = router_id->port;
   (*new_id)->rnd = silc_rng_get_rn16(rng);
 
   (*new_id)->port = router_id->port;
   (*new_id)->rnd = silc_rng_get_rn16(rng);
 
index f870a2a35d1dc7b773d5488e8c3eda5ac3203808..1609cbe118ad53c679d0216f548cba2116f925c2 100644 (file)
@@ -553,7 +553,7 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final)
   /* Save remote ID. */
   conn->remote_id = ctx->dest_id;
   conn->remote_id_data = silc_id_id2str(ctx->dest_id, SILC_ID_SERVER);
   /* Save remote ID. */
   conn->remote_id = ctx->dest_id;
   conn->remote_id_data = silc_id_id2str(ctx->dest_id, SILC_ID_SERVER);
-  conn->remote_id_data_len = SILC_ID_SERVER_LEN;
+  conn->remote_id_data_len = silc_id_get_len(ctx->dest_id, SILC_ID_SERVER);
 
   /* Register re-key timeout */
   conn->rekey->timeout = 3600; /* XXX hardcoded */
 
   /* Register re-key timeout */
   conn->rekey->timeout = 3600; /* XXX hardcoded */
@@ -1088,15 +1088,19 @@ void silc_client_packet_send(SilcClient client,
   packetdata.flags = 0;
   packetdata.type = type;
   if (sock->user_data && 
   packetdata.flags = 0;
   packetdata.type = type;
   if (sock->user_data && 
-      ((SilcClientConnection)sock->user_data)->local_id_data)
+      ((SilcClientConnection)sock->user_data)->local_id_data) {
     packetdata.src_id = ((SilcClientConnection)sock->user_data)->local_id_data;
     packetdata.src_id = ((SilcClientConnection)sock->user_data)->local_id_data;
-  else 
+    packetdata.src_id_len = 
+      silc_id_get_len(((SilcClientConnection)sock->user_data)->local_id,
+                     SILC_ID_CLIENT);
+  } else { 
     packetdata.src_id = silc_calloc(SILC_ID_CLIENT_LEN, sizeof(unsigned char));
     packetdata.src_id = silc_calloc(SILC_ID_CLIENT_LEN, sizeof(unsigned char));
-  packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+    packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+  }
   packetdata.src_id_type = SILC_ID_CLIENT;
   if (dst_id) {
     packetdata.dst_id = silc_id_id2str(dst_id, dst_id_type);
   packetdata.src_id_type = SILC_ID_CLIENT;
   if (dst_id) {
     packetdata.dst_id = silc_id_id2str(dst_id, dst_id_type);
-    packetdata.dst_id_len = silc_id_get_len(dst_id_type);
+    packetdata.dst_id_len = silc_id_get_len(dst_id, dst_id_type);
     packetdata.dst_id_type = dst_id_type;
   } else {
     packetdata.dst_id = NULL;
     packetdata.dst_id_type = dst_id_type;
   } else {
     packetdata.dst_id = NULL;
@@ -1185,15 +1189,19 @@ void silc_client_packet_send_flush(SilcClient client,
   packetdata.flags = 0;
   packetdata.type = type;
   if (sock->user_data && 
   packetdata.flags = 0;
   packetdata.type = type;
   if (sock->user_data && 
-      ((SilcClientConnection)sock->user_data)->local_id_data)
+      ((SilcClientConnection)sock->user_data)->local_id_data) {
     packetdata.src_id = ((SilcClientConnection)sock->user_data)->local_id_data;
     packetdata.src_id = ((SilcClientConnection)sock->user_data)->local_id_data;
-  else 
+    packetdata.src_id_len = 
+      silc_id_get_len(((SilcClientConnection)sock->user_data)->local_id,
+                     SILC_ID_CLIENT);
+  } else { 
     packetdata.src_id = silc_calloc(SILC_ID_CLIENT_LEN, sizeof(unsigned char));
     packetdata.src_id = silc_calloc(SILC_ID_CLIENT_LEN, sizeof(unsigned char));
-  packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+    packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+  }
   packetdata.src_id_type = SILC_ID_CLIENT;
   if (dst_id) {
     packetdata.dst_id = silc_id_id2str(dst_id, dst_id_type);
   packetdata.src_id_type = SILC_ID_CLIENT;
   if (dst_id) {
     packetdata.dst_id = silc_id_id2str(dst_id, dst_id_type);
-    packetdata.dst_id_len = silc_id_get_len(dst_id_type);
+    packetdata.dst_id_len = silc_id_get_len(dst_id, dst_id_type);
     packetdata.dst_id_type = dst_id_type;
   } else {
     packetdata.dst_id = NULL;
     packetdata.dst_id_type = dst_id_type;
   } else {
     packetdata.dst_id = NULL;
index 62396c5f0dda0a4e98acb598ddb8526ebbf2049d..f3dff85b6bd5a9d2f2d5b195d195b8500eb47d1d 100644 (file)
@@ -109,10 +109,10 @@ void silc_client_send_channel_message(SilcClient client,
   packetdata.flags = 0;
   packetdata.type = SILC_PACKET_CHANNEL_MESSAGE;
   packetdata.src_id = conn->local_id_data;
   packetdata.flags = 0;
   packetdata.type = SILC_PACKET_CHANNEL_MESSAGE;
   packetdata.src_id = conn->local_id_data;
-  packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+  packetdata.src_id_len = silc_id_get_len(conn->local_id, SILC_ID_CLIENT);
   packetdata.src_id_type = SILC_ID_CLIENT;
   packetdata.dst_id = id_string;
   packetdata.src_id_type = SILC_ID_CLIENT;
   packetdata.dst_id = id_string;
-  packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
+  packetdata.dst_id_len = silc_id_get_len(channel->id, SILC_ID_CHANNEL);
   packetdata.dst_id_type = SILC_ID_CHANNEL;
   packetdata.truelen = payload->len + SILC_PACKET_HEADER_LEN + 
     packetdata.src_id_len + packetdata.dst_id_len;
   packetdata.dst_id_type = SILC_ID_CHANNEL;
   packetdata.truelen = payload->len + SILC_PACKET_HEADER_LEN + 
     packetdata.src_id_len + packetdata.dst_id_len;
@@ -222,7 +222,7 @@ void silc_client_channel_message(SilcClient client,
   /* Find client entry */
   silc_list_start(channel->clients);
   while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
   /* Find client entry */
   silc_list_start(channel->clients);
   while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
-    if (!SILC_ID_CLIENT_COMPARE(chu->client->id, client_id)) {
+    if (SILC_ID_CLIENT_COMPARE(chu->client->id, client_id)) {
       found = TRUE;
       break;
     }
       found = TRUE;
       break;
     }
index 2bd0aeb695d992758fece77a7d64433fdef91c20..109fb0a7b1e64298afe08380e6d4e07accfe193b 100644 (file)
@@ -365,7 +365,7 @@ void silc_client_notify_by_server(SilcClient client,
       goto out;
 
     /* Ignore my ID */
       goto out;
 
     /* Ignore my ID */
-    if (!SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
+    if (SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
       break;
 
     /* Find old Client entry */
       break;
 
     /* Find old Client entry */
index cc0155b225c833c65a068204096b06b806fbf731..2df8325de8ec5e46c3c53587c48222ed0a780e97 100644 (file)
@@ -74,10 +74,10 @@ void silc_client_send_private_message(SilcClient client,
   packetdata.flags = SILC_PACKET_FLAG_PRIVMSG_KEY;
   packetdata.type = SILC_PACKET_PRIVATE_MESSAGE;
   packetdata.src_id = conn->local_id_data;
   packetdata.flags = SILC_PACKET_FLAG_PRIVMSG_KEY;
   packetdata.type = SILC_PACKET_PRIVATE_MESSAGE;
   packetdata.src_id = conn->local_id_data;
-  packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+  packetdata.src_id_len = silc_id_get_len(conn->local_id, SILC_ID_CLIENT);
   packetdata.src_id_type = SILC_ID_CLIENT;
   packetdata.dst_id = silc_id_id2str(client_entry->id, SILC_ID_CLIENT);
   packetdata.src_id_type = SILC_ID_CLIENT;
   packetdata.dst_id = silc_id_id2str(client_entry->id, SILC_ID_CLIENT);
-  packetdata.dst_id_len = SILC_ID_CLIENT_LEN;
+  packetdata.dst_id_len = silc_id_get_len(client_entry->id, SILC_ID_CLIENT);
   packetdata.dst_id_type = SILC_ID_CLIENT;
   packetdata.truelen = buffer->len + SILC_PACKET_HEADER_LEN + 
     packetdata.src_id_len + packetdata.dst_id_len;
   packetdata.dst_id_type = SILC_ID_CLIENT;
   packetdata.truelen = buffer->len + SILC_PACKET_HEADER_LEN + 
     packetdata.src_id_len + packetdata.dst_id_len;
@@ -181,7 +181,7 @@ void silc_client_private_message(SilcClient client,
      sender with the set away message. */
   if (conn->away && conn->away->away) {
     /* If it's me, ignore */
      sender with the set away message. */
   if (conn->away && conn->away->away) {
     /* If it's me, ignore */
-    if (!SILC_ID_CLIENT_COMPARE(remote_id, conn->local_id))
+    if (SILC_ID_CLIENT_COMPARE(remote_id, conn->local_id))
       goto out;
 
     /* Send the away message */
       goto out;
 
     /* Send the away message */
index ffa55d5c744dce2481e7d41348d4c6268bcb1dc0..0ad1e136aa4322ee5ef97ebc5cab813af65d7ecb 100644 (file)
@@ -862,7 +862,8 @@ SILC_CLIENT_CMD_FUNC(ping)
   /* Send the command */
   buffer = silc_command_payload_encode_va(SILC_COMMAND_PING, 0, 1, 
                                          1, conn->remote_id_data, 
   /* Send the command */
   buffer = silc_command_payload_encode_va(SILC_COMMAND_PING, 0, 1, 
                                          1, conn->remote_id_data, 
-                                         SILC_ID_SERVER_LEN);
+                                         silc_id_get_len(conn->remote_id,
+                                                         SILC_ID_SERVER));
   silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL, 
                          0, NULL, NULL, buffer->data, buffer->len, TRUE);
   silc_buffer_free(buffer);
   silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL, 
                          0, NULL, NULL, buffer->data, buffer->len, TRUE);
   silc_buffer_free(buffer);
index d91710fae7f754b10c49adbf03dcca6ff63e5072..8029eefbc1de77c12e62e81f3a34616cecd6d54b 100644 (file)
@@ -874,7 +874,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(ping)
   }
 
   for (i = 0; i < conn->ping_count; i++) {
   }
 
   for (i = 0; i < conn->ping_count; i++) {
-    if (!SILC_ID_SERVER_COMPARE(conn->ping[i].dest_id, id)) {
+    if (SILC_ID_SERVER_COMPARE(conn->ping[i].dest_id, id)) {
       diff = curtime - conn->ping[i].start_time;
       cmd->client->ops->say(cmd->client, conn, 
                            "Ping reply from %s: %d second%s", 
       diff = curtime - conn->ping[i].start_time;
       cmd->client->ops->say(cmd->client, conn, 
                            "Ping reply from %s: %d second%s", 
index f39783ced657afcde45f2f086eb459fda5dc4927..51c95d95fe829d6ddfad10a40ae636b15d85ab7a 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
 
 
   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
 
-  Copyright (C) 1997 - 2000 Pekka Riikonen
+  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
 
   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
 /* $Id$ */
 
 #include "silcincludes.h"
 /* $Id$ */
 
 #include "silcincludes.h"
+#include "id.h"
+
+/* ID lengths (in bytes) without the IP address part */
+#define ID_SERVER_LEN_PART      4
+#define ID_CLIENT_LEN_PART      CLIENTID_HASH_LEN + 1
+#define ID_CHANNEL_LEN_PART     4
 
 /* Converts ID to string. */
 
 
 /* Converts ID to string. */
 
@@ -29,28 +35,29 @@ unsigned char *silc_id_id2str(void *id, SilcIdType type)
   SilcServerID *server_id;
   SilcClientID *client_id;
   SilcChannelID *channel_id;
   SilcServerID *server_id;
   SilcClientID *client_id;
   SilcChannelID *channel_id;
+  uint32 id_len = silc_id_get_len(id, type);
 
   switch(type) {
   case SILC_ID_SERVER:
     server_id = (SilcServerID *)id;
 
   switch(type) {
   case SILC_ID_SERVER:
     server_id = (SilcServerID *)id;
-    ret_id = silc_calloc(8, sizeof(unsigned char));
-    SILC_PUT32_MSB(server_id->ip.s_addr, ret_id);
+    ret_id = silc_calloc(id_len, sizeof(unsigned char));
+    memcpy(ret_id, server_id->ip.data, server_id->ip.data_len);
     SILC_PUT16_MSB(server_id->port, &ret_id[4]);
     SILC_PUT16_MSB(server_id->rnd, &ret_id[6]);
     return ret_id;
     break;
   case SILC_ID_CLIENT:
     client_id = (SilcClientID *)id;
     SILC_PUT16_MSB(server_id->port, &ret_id[4]);
     SILC_PUT16_MSB(server_id->rnd, &ret_id[6]);
     return ret_id;
     break;
   case SILC_ID_CLIENT:
     client_id = (SilcClientID *)id;
-    ret_id = silc_calloc(16, sizeof(unsigned char));
-    SILC_PUT32_MSB(client_id->ip.s_addr, ret_id);
+    ret_id = silc_calloc(id_len, sizeof(unsigned char));
+    memcpy(ret_id, client_id->ip.data, client_id->ip.data_len);
     ret_id[4] = client_id->rnd;
     memcpy(&ret_id[5], client_id->hash, CLIENTID_HASH_LEN);
     return ret_id;
     break;
   case SILC_ID_CHANNEL:
     channel_id = (SilcChannelID *)id;
     ret_id[4] = client_id->rnd;
     memcpy(&ret_id[5], client_id->hash, CLIENTID_HASH_LEN);
     return ret_id;
     break;
   case SILC_ID_CHANNEL:
     channel_id = (SilcChannelID *)id;
-    ret_id = silc_calloc(8, sizeof(unsigned char));
-    SILC_PUT32_MSB(channel_id->ip.s_addr, ret_id);
+    ret_id = silc_calloc(id_len, sizeof(unsigned char));
+    memcpy(ret_id, channel_id->ip.data, channel_id->ip.data_len);
     SILC_PUT16_MSB(channel_id->port, &ret_id[4]);
     SILC_PUT16_MSB(channel_id->rnd, &ret_id[6]);
     return ret_id;
     SILC_PUT16_MSB(channel_id->port, &ret_id[4]);
     SILC_PUT16_MSB(channel_id->rnd, &ret_id[6]);
     return ret_id;
@@ -70,11 +77,14 @@ void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type)
     {
       SilcServerID *server_id;
 
     {
       SilcServerID *server_id;
 
-      if (id_len != SILC_ID_SERVER_LEN)
+      if (id_len != ID_SERVER_LEN_PART + 4 &&
+         id_len != ID_SERVER_LEN_PART + 16)
        return NULL;
 
       server_id = silc_calloc(1, sizeof(*server_id));
        return NULL;
 
       server_id = silc_calloc(1, sizeof(*server_id));
-      SILC_GET32_MSB(server_id->ip.s_addr, id);
+      memcpy(server_id->ip.data, id, (id_len > ID_SERVER_LEN_PART + 4 ?
+                                     16 : 4));
+      server_id->ip.data_len = (id_len > ID_SERVER_LEN_PART + 4 ? 16 : 4);
       SILC_GET16_MSB(server_id->port, &id[4]);
       SILC_GET16_MSB(server_id->rnd, &id[6]);
       return server_id;
       SILC_GET16_MSB(server_id->port, &id[4]);
       SILC_GET16_MSB(server_id->rnd, &id[6]);
       return server_id;
@@ -84,11 +94,14 @@ void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type)
     {
       SilcClientID *client_id;
 
     {
       SilcClientID *client_id;
 
-      if (id_len != SILC_ID_CLIENT_LEN)
+      if (id_len != ID_CLIENT_LEN_PART + 4 &&
+         id_len != ID_CLIENT_LEN_PART + 16)
        return NULL;
 
       client_id = silc_calloc(1, sizeof(*client_id));
        return NULL;
 
       client_id = silc_calloc(1, sizeof(*client_id));
-      SILC_GET32_MSB(client_id->ip.s_addr, id);
+      memcpy(client_id->ip.data, id, (id_len > ID_CLIENT_LEN_PART + 4 ?
+                                     16 : 4));
+      client_id->ip.data_len = (id_len > ID_CLIENT_LEN_PART + 4 ? 16 : 4);
       client_id->rnd = id[4];
       memcpy(client_id->hash, &id[5], CLIENTID_HASH_LEN);
       return client_id;
       client_id->rnd = id[4];
       memcpy(client_id->hash, &id[5], CLIENTID_HASH_LEN);
       return client_id;
@@ -98,11 +111,14 @@ void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type)
     {
       SilcChannelID *channel_id;
 
     {
       SilcChannelID *channel_id;
 
-      if (id_len != SILC_ID_CHANNEL_LEN)
+      if (id_len != ID_CHANNEL_LEN_PART + 4 &&
+         id_len != ID_CHANNEL_LEN_PART + 16)
        return NULL;
 
       channel_id = silc_calloc(1, sizeof(*channel_id));
        return NULL;
 
       channel_id = silc_calloc(1, sizeof(*channel_id));
-      SILC_GET32_MSB(channel_id->ip.s_addr, id);
+      memcpy(channel_id->ip.data, id, (id_len > ID_CHANNEL_LEN_PART + 4 ?
+                                      16 : 4));
+      channel_id->ip.data_len = (id_len > ID_CHANNEL_LEN_PART + 4 ? 16 : 4);
       SILC_GET16_MSB(channel_id->port, &id[4]);
       SILC_GET16_MSB(channel_id->rnd, &id[6]);
       return channel_id;
       SILC_GET16_MSB(channel_id->port, &id[4]);
       SILC_GET16_MSB(channel_id->rnd, &id[6]);
       return channel_id;
@@ -115,17 +131,26 @@ void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type)
 
 /* Returns length of the ID */
 
 
 /* Returns length of the ID */
 
-uint32 silc_id_get_len(SilcIdType type)
+uint32 silc_id_get_len(void *id, SilcIdType type)
 {
   switch(type) {
   case SILC_ID_SERVER:
 {
   switch(type) {
   case SILC_ID_SERVER:
-    return SILC_ID_SERVER_LEN;
+    {
+      SilcServerID *server_id = (SilcServerID *)id;
+      return ID_SERVER_LEN_PART + server_id->ip.data_len;
+    }
     break;
   case SILC_ID_CLIENT:
     break;
   case SILC_ID_CLIENT:
-    return SILC_ID_CLIENT_LEN;
+    {
+      SilcClientID *client_id = (SilcClientID *)id;
+      return ID_CLIENT_LEN_PART + client_id->ip.data_len;
+    }
     break;
   case SILC_ID_CHANNEL:
     break;
   case SILC_ID_CHANNEL:
-    return SILC_ID_CHANNEL_LEN;
+    {
+      SilcChannelID *channel_id = (SilcChannelID *)id;
+      return ID_CHANNEL_LEN_PART + channel_id->ip.data_len;
+    }
     break;
   }
 
     break;
   }
 
@@ -136,8 +161,84 @@ uint32 silc_id_get_len(SilcIdType type)
 
 void *silc_id_dup(void *id, SilcIdType type)
 {
 
 void *silc_id_dup(void *id, SilcIdType type)
 {
-  int len = silc_id_get_len(type);
-  void *new = silc_calloc(1, len);
-  memcpy(new, id, len);
-  return new;
+  switch(type) {
+  case SILC_ID_SERVER:
+    {
+      SilcServerID *server_id = (SilcServerID *)id, *new;
+      new = silc_calloc(1, sizeof(*server_id));
+      memcpy(&new->ip, &server_id->ip, sizeof(server_id->ip)); 
+      new->port = server_id->port;
+      new->rnd = server_id->rnd;
+      return new;
+    }
+    break;
+  case SILC_ID_CLIENT:
+    {
+      SilcClientID *client_id = (SilcClientID *)id, *new;
+      new = silc_calloc(1, sizeof(*client_id));
+      memcpy(&new->ip, &client_id->ip, sizeof(client_id->ip)); 
+      new->rnd = client_id->rnd;
+      memcpy(new->hash, client_id->hash, CLIENTID_HASH_LEN);
+      return new;
+    }
+    break;
+  case SILC_ID_CHANNEL:
+    {
+      SilcChannelID *channel_id = (SilcChannelID *)id, *new;
+      new = silc_calloc(1, sizeof(*channel_id));
+      memcpy(&new->ip, &channel_id->ip, sizeof(channel_id->ip)); 
+      new->port = channel_id->port;
+      new->rnd = channel_id->rnd;
+      return new;
+    }
+    break;
+  }
+
+  return NULL;
+}
+
+/* Returns TRUE if the `id2' is equal to `id1'. */
+
+bool silc_id_compare(void *id1, void *id2, SilcIdType type)
+{
+  switch(type) {
+  case SILC_ID_SERVER:
+    {
+      SilcServerID *server_id1 = (SilcServerID *)id1;
+      SilcServerID *server_id2 = (SilcServerID *)id2;
+      if (!memcmp(server_id1->ip.data, server_id2->ip.data, 
+                 server_id1->ip.data_len) &&
+         server_id1->port == server_id2->port &&
+         server_id1->rnd == server_id2->rnd)
+       return TRUE;
+      return FALSE;
+    }
+    break;
+  case SILC_ID_CLIENT:
+    {
+      SilcClientID *client_id1 = (SilcClientID *)id1;
+      SilcClientID *client_id2 = (SilcClientID *)id2;
+      if (!memcmp(client_id1->ip.data, client_id2->ip.data, 
+                 client_id1->ip.data_len) &&
+         client_id1->rnd == client_id2->rnd &&
+         !memcmp(client_id1->hash, client_id2->hash, CLIENTID_HASH_LEN))
+       return TRUE;
+      return FALSE;
+    }
+    break;
+  case SILC_ID_CHANNEL:
+    {
+      SilcChannelID *channel_id1 = (SilcChannelID *)id1;
+      SilcChannelID *channel_id2 = (SilcChannelID *)id2;
+      if (!memcmp(channel_id1->ip.data, channel_id2->ip.data, 
+                 channel_id1->ip.data_len) &&
+         channel_id1->port == channel_id2->port &&
+         channel_id1->rnd == channel_id2->rnd)
+       return TRUE;
+      return FALSE;
+    }
+    break;
+  }
+
+  return FALSE;
 }
 }
index 8fe79ad377deead9d10100c9cd302ce4f68570af..a024a25d6a38cfd0be83e72aa6f4963a380d682c 100644 (file)
    packet sending and reception. However, client never creates these
    but it receives the correct ID's from server. Clients, servers and
    channels are identified by the these ID's.
    packet sending and reception. However, client never creates these
    but it receives the correct ID's from server. Clients, servers and
    channels are identified by the these ID's.
-
-   Note that these are currently IPv4 specific, although adding IPv6
-   support is not a bad task and SILC protocol already supports IPv6.
 */
 
 #ifndef ID_H
 #define ID_H
 
 */
 
 #ifndef ID_H
 #define ID_H
 
-#define SILC_ID_SERVER_LEN     (64 / 8)
-#define SILC_ID_CLIENT_LEN     (128 / 8)
-#define SILC_ID_CHANNEL_LEN    (64 / 8)
-#define CLIENTID_HASH_LEN       (88 / 8) /* Client ID's 88 bit MD5 hash */
-
-/* SILC ID Types */
+/* The SILC ID Types */
 #define SILC_ID_NONE 0
 #define SILC_ID_SERVER 1
 #define SILC_ID_CLIENT 2
 #define SILC_ID_NONE 0
 #define SILC_ID_SERVER 1
 #define SILC_ID_CLIENT 2
 /* Type definition for the ID types. */
 typedef uint16 SilcIdType;
 
 /* Type definition for the ID types. */
 typedef uint16 SilcIdType;
 
+/* The ID Lenghts. These are IPv4 based and should be noted if used directly
+   that these cannot be used with IPv6. */
+#define SILC_ID_SERVER_LEN     (64 / 8)
+#define SILC_ID_CLIENT_LEN     (128 / 8)
+#define SILC_ID_CHANNEL_LEN    (64 / 8)
+
+#define CLIENTID_HASH_LEN       (88 / 8) /* Client ID's 88 bit MD5 hash */
+
+/*
+   SILC ID IP structure.
+
+   Generic IP address structure to indicate either IPv4 or IPv6 address.
+   This structure is used inside all SILC ID's. The true length of the
+   ID depends of the length of the IP address.
+*/
+typedef struct {
+  unsigned char data[16];      /* IP data */
+  uint8 data_len;              /* Length of the data (4 or 16) */
+} SilcIDIP;
+
 /* 
 /* 
-   64 bit SilcServerID structure:
+   64 or 160 bit SilcServerID structure:
    
    
-   32 bit IP address
+    n bit IP address
    16 bit port
    16 bit random number
 */
 typedef struct {
    16 bit port
    16 bit random number
 */
 typedef struct {
-  struct in_addr ip;                           /* 32 bit IP */
-  uint16 port;                         /* 16 bit port */
-  uint16 rnd;                          /* 16 bit random number */
+  SilcIDIP ip;                 /* n bit IP address */
+  uint16 port;                 /* 16 bit port */
+  uint16 rnd;                  /* 16 bit random number */
 } SilcServerID;
 
 /* 
 } SilcServerID;
 
 /* 
-   128 bit SilcClientID structure:
+   128 or 224 bit SilcClientID structure:
 
 
-   32 bit ServerID IP address [bits 1-32]
+    n bit ServerID IP address [bits 1-32 or bits 1-128]
     8 bit random number
    88 bit hash value from nickname
 */
 typedef struct {
     8 bit random number
    88 bit hash value from nickname
 */
 typedef struct {
-  struct in_addr ip;                           /* 32 bit IP */
+  SilcIDIP ip;                                 /* n bit IP address */
   unsigned char rnd;                           /* 8 bit random number */
   unsigned char hash[CLIENTID_HASH_LEN];       /* 88 bit MD5 hash */
 } SilcClientID;
 
 /* 
   unsigned char rnd;                           /* 8 bit random number */
   unsigned char hash[CLIENTID_HASH_LEN];       /* 88 bit MD5 hash */
 } SilcClientID;
 
 /* 
-   64 bit SilcChannel ID structure:
+   64 or 160 bit SilcChannel ID structure:
 
 
-   32 bit Router's ServerID IP address [bits 1-32]
-   16 bit Router's ServerID port [bits 33-48]
+    n bit Router's ServerID IP address [bits 1-32 or bits 1-128]
+   16 bit Router's ServerID port [bits 33-48 or bits 129-144]
    16 bit random number
 */
 typedef struct {
    16 bit random number
 */
 typedef struct {
-  struct in_addr ip;                           /* 32 bit IP */
-  uint16 port;                         /* 16 bit port */
-  uint16 rnd;                          /* 16 bit random number */
+  SilcIDIP ip;                                 /* n bit IP address */
+  uint16 port;                                 /* 16 bit port */
+  uint16 rnd;                                  /* 16 bit random number */
 } SilcChannelID;
 
 /* Macros */
 
 } SilcChannelID;
 
 /* Macros */
 
-/* Compares two ID's */
-#define SILC_ID_COMPARE(id1, id2, len) (memcmp(id1, id2, len))
-
-/* Compares Channel ID's */
-#define SILC_ID_CHANNEL_COMPARE(id1, id2) \
-  SILC_ID_COMPARE(id1, id2, SILC_ID_CHANNEL_LEN)
-
 /* Compares Client ID's */
 /* Compares Client ID's */
-#define SILC_ID_CLIENT_COMPARE(id1, id2) \
-  SILC_ID_COMPARE(id1, id2, SILC_ID_CLIENT_LEN)
+#define SILC_ID_CLIENT_COMPARE(id1, id2)               \
+  silc_id_compare(id1, id2, SILC_ID_CLIENT)
 
 /* Compares Server ID's */
 
 /* Compares Server ID's */
-#define SILC_ID_SERVER_COMPARE(id1, id2) \
-  SILC_ID_COMPARE(id1, id2, SILC_ID_SERVER_LEN)
+#define SILC_ID_SERVER_COMPARE(id1, id2)               \
+  silc_id_compare(id1, id2, SILC_ID_SERVER)
 
 /* Compares Channel ID's */
 
 /* Compares Channel ID's */
-#define SILC_ID_CHANNEL_COMPARE(id1, id2) \
-  SILC_ID_COMPARE(id1, id2, SILC_ID_CHANNEL_LEN)
-
-/* Compares IP addresses from the ID's. */
-#define SILC_ID_COMPARE_IP(id1, id2) \
-  SILC_ID_COMPARE(id1, id2, 4)
+#define SILC_ID_CHANNEL_COMPARE(id1, id2)                      \
+  silc_id_compare(id1, id2, SILC_ID_CHANNEL)
 
 /* Compare nickname hash from Client ID */
 #define SILC_ID_COMPARE_HASH(id, _hash) \
 
 /* Compare nickname hash from Client ID */
 #define SILC_ID_COMPARE_HASH(id, _hash) \
@@ -115,7 +116,8 @@ typedef struct {
 /* Prototypes */
 unsigned char *silc_id_id2str(void *id, SilcIdType type);
 void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type);
 /* Prototypes */
 unsigned char *silc_id_id2str(void *id, SilcIdType type);
 void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type);
-uint32 silc_id_get_len(SilcIdType type);
+uint32 silc_id_get_len(void *id, SilcIdType type);
 void *silc_id_dup(void *id, SilcIdType type);
 void *silc_id_dup(void *id, SilcIdType type);
+bool silc_id_compare(void *id1, void *id2, SilcIdType type);
 
 #endif
 
 #endif
index caf6549fc45319a3e7be78c80ff78b0c3cb025d8..164d15153d979ffac8936ef804d2ee217ef4fd93 100644 (file)
@@ -316,19 +316,17 @@ int silc_idcache_find_by_data_loose(SilcIDCache cache, unsigned char *data,
 int silc_idcache_find_by_id(SilcIDCache cache, void *id, SilcIdType type,
                            SilcIDCacheList *ret)
 {
 int silc_idcache_find_by_id(SilcIDCache cache, void *id, SilcIdType type,
                            SilcIDCacheList *ret)
 {
-  int i, id_len;
+  int i;
   SilcIDCacheList list;
 
   if (!cache || !cache->cache || !id)
     return FALSE;
 
   SilcIDCacheList list;
 
   if (!cache || !cache->cache || !id)
     return FALSE;
 
-  id_len = silc_id_get_len(type);
-
   list = silc_idcache_list_alloc();
 
   if (id != SILC_ID_CACHE_ANY) {
     for (i = 0; i < cache->cache_count; i++)
   list = silc_idcache_list_alloc();
 
   if (id != SILC_ID_CACHE_ANY) {
     for (i = 0; i < cache->cache_count; i++)
-      if (cache->cache[i].id && !memcmp(cache->cache[i].id, id, id_len))
+      if (cache->cache[i].id && silc_id_compare(cache->cache[i].id, id, type))
        silc_idcache_list_add(list, &(cache->cache[i]));
   } else {
     for (i = 0; i < cache->cache_count; i++)
        silc_idcache_list_add(list, &(cache->cache[i]));
   } else {
     for (i = 0; i < cache->cache_count; i++)
@@ -354,15 +352,13 @@ int silc_idcache_find_by_id(SilcIDCache cache, void *id, SilcIdType type,
 int silc_idcache_find_by_id_one(SilcIDCache cache, void *id, SilcIdType type, 
                                SilcIDCacheEntry *ret)
 {
 int silc_idcache_find_by_id_one(SilcIDCache cache, void *id, SilcIdType type, 
                                SilcIDCacheEntry *ret)
 {
-  int i, id_len;
+  int i;
 
   if (!cache || !cache->cache || !id)
     return FALSE;
 
 
   if (!cache || !cache->cache || !id)
     return FALSE;
 
-  id_len = silc_id_get_len(type);
-
   for (i = 0; i < cache->cache_count; i++)
   for (i = 0; i < cache->cache_count; i++)
-    if (cache->cache[i].id && !memcmp(cache->cache[i].id, id, id_len)) {
+    if (cache->cache[i].id && silc_id_compare(cache->cache[i].id, id, type)) {
       if (ret)
        *ret = &(cache->cache[i]);
       return TRUE;
       if (ret)
        *ret = &(cache->cache[i]);
       return TRUE;
@@ -481,15 +477,13 @@ int silc_idcache_del_by_data(SilcIDCache cache, unsigned char *data)
 
 int silc_idcache_del_by_id(SilcIDCache cache, SilcIdType type, void *id)
 {
 
 int silc_idcache_del_by_id(SilcIDCache cache, SilcIdType type, void *id)
 {
-  int i, id_len;
+  int i;
 
   if (!cache || !cache->cache || !id)
     return FALSE;
 
 
   if (!cache || !cache->cache || !id)
     return FALSE;
 
-  id_len = silc_id_get_len(type);
-
   for (i = 0; i < cache->cache_count; i++)
   for (i = 0; i < cache->cache_count; i++)
-    if (cache->cache[i].id && !memcmp(cache->cache[i].id, id, id_len)) {
+    if (cache->cache[i].id && silc_id_compare(cache->cache[i].id, id, type)) {
       cache->cache[i].id = NULL;
       cache->cache[i].data = NULL;
       cache->cache[i].type = 0;
       cache->cache[i].id = NULL;
       cache->cache[i].data = NULL;
       cache->cache[i].type = 0;
index 285def35c555b7443b36edbbdd9b990e9d2b2f4e..a06246fdc201716608f190afcd3daa055d9f4506 100644 (file)
@@ -178,7 +178,7 @@ silc_auth_public_key_encode_data(SilcPublicKey public_key,
     silc_free(pk);
     return NULL;
   }
     silc_free(pk);
     return NULL;
   }
-  id_len = silc_id_get_len(type);
+  id_len = silc_id_get_len(id, type);
 
   buf = silc_buffer_alloc(random_len + id_len + pk_len);
   silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
 
   buf = silc_buffer_alloc(random_len + id_len + pk_len);
   silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
index e3104ada8515d5e4d1cd6a8fbb1093131c2cf8f4..1dc8f830c5d805d6be6614523074b946183d3ffd 100644 (file)
@@ -175,7 +175,7 @@ SilcBuffer silc_id_payload_encode(void *id, SilcIdType type)
                  type == SILC_ID_SERVER ? "Server" : "Channel"));
 
   id_data = silc_id_id2str(id, type);
                  type == SILC_ID_SERVER ? "Server" : "Channel"));
 
   id_data = silc_id_id2str(id, type);
-  len = silc_id_get_len(type);
+  len = silc_id_get_len(id, type);
 
   buffer = silc_buffer_alloc(4 + len);
   silc_buffer_pull_tail(buffer, SILC_BUFFER_END(buffer));
 
   buffer = silc_buffer_alloc(4 + len);
   silc_buffer_pull_tail(buffer, SILC_BUFFER_END(buffer));
index 8867c717e0e03c6b1f08006ba2d2913ce21fc52c..6b118ee8a07a0bf2e6dbfd5d723880ba340520d1 100644 (file)
@@ -487,7 +487,15 @@ char *silc_id_render(void *id, uint16 type)
   case SILC_ID_SERVER:
     {
       SilcServerID *server_id = (SilcServerID *)id;
   case SILC_ID_SERVER:
     {
       SilcServerID *server_id = (SilcServerID *)id;
-      strcat(rid, inet_ntoa(server_id->ip));
+      struct in_addr ipv4;
+
+      if (server_id->ip.data_len > 4) {
+
+      } else {
+       SILC_GET32_MSB(ipv4.s_addr, server_id->ip.data);
+       strcat(rid, inet_ntoa(ipv4));
+      }
+
       memset(tmp, 0, sizeof(tmp));
       snprintf(tmp, sizeof(tmp), ",%d,", ntohs(server_id->port));
       strcat(rid, tmp);
       memset(tmp, 0, sizeof(tmp));
       snprintf(tmp, sizeof(tmp), ",%d,", ntohs(server_id->port));
       strcat(rid, tmp);
@@ -500,7 +508,15 @@ char *silc_id_render(void *id, uint16 type)
   case SILC_ID_CLIENT:
     {
       SilcClientID *client_id = (SilcClientID *)id;
   case SILC_ID_CLIENT:
     {
       SilcClientID *client_id = (SilcClientID *)id;
-      strcat(rid, inet_ntoa(client_id->ip));
+      struct in_addr ipv4;
+
+      if (client_id->ip.data_len > 4) {
+
+      } else {
+       SILC_GET32_MSB(ipv4.s_addr, client_id->ip.data);
+       strcat(rid, inet_ntoa(ipv4));
+      }
+
       memset(tmp, 0, sizeof(tmp));
       snprintf(tmp, sizeof(tmp), ",%02x,", client_id->rnd);
       strcat(rid, tmp);
       memset(tmp, 0, sizeof(tmp));
       snprintf(tmp, sizeof(tmp), ",%02x,", client_id->rnd);
       strcat(rid, tmp);
@@ -514,7 +530,15 @@ char *silc_id_render(void *id, uint16 type)
   case SILC_ID_CHANNEL:
     {
       SilcChannelID *channel_id = (SilcChannelID *)id;
   case SILC_ID_CHANNEL:
     {
       SilcChannelID *channel_id = (SilcChannelID *)id;
-      strcat(rid, inet_ntoa(channel_id->ip));
+      struct in_addr ipv4;
+
+      if (channel_id->ip.data_len > 4) {
+
+      } else {
+       SILC_GET32_MSB(ipv4.s_addr, channel_id->ip.data);
+       strcat(rid, inet_ntoa(ipv4));
+      }
+
       memset(tmp, 0, sizeof(tmp));
       snprintf(tmp, sizeof(tmp), ",%d,", ntohs(channel_id->port));
       strcat(rid, tmp);
       memset(tmp, 0, sizeof(tmp));
       snprintf(tmp, sizeof(tmp), ",%d,", ntohs(channel_id->port));
       strcat(rid, tmp);
diff --git a/prepare b/prepare
index cfe5f9cc78669a39cdd980b4ab7545fa9ccee66b..9810f48fddd7997c885f3007ba52e5d2cf9b3279 100755 (executable)
--- a/prepare
+++ b/prepare
@@ -25,7 +25,7 @@
 # temporary files (including these prepare* scripts) are removed.
 #
 
 # temporary files (including these prepare* scripts) are removed.
 #
 
-SILC_VERSION=0.2.1
+SILC_VERSION=0.2.2
 
 version=$1
 if test "$version" = ""; then
 
 version=$1
 if test "$version" = ""; then