X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Fserverid.c;h=73641c65dd13449a7dce351be999dab4db56f420;hb=52e57c880aba9c5e89f59d962eb9af75670b76e0;hp=3d4ea8e0970aedbde57203aa4ef8ab332ea2e64c;hpb=8fd8212bcd16f2b53fbedff2a9b9a4e8c15b9695;p=silc.git diff --git a/apps/silcd/serverid.c b/apps/silcd/serverid.c index 3d4ea8e0..73641c65 100644 --- a/apps/silcd/serverid.c +++ b/apps/silcd/serverid.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2005 Pekka Riikonen + Copyright (C) 1997 - 2007 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 @@ -43,7 +43,7 @@ void silc_id_create_server_id(const char *ip, SilcUInt16 port, SilcRng rng, (*new_id)->ip.data_len = silc_net_is_ip4(ip) ? 4 : 16; (*new_id)->port = SILC_SWAB_16(port); - (*new_id)->rnd = silc_rng_get_rn16(rng); + (*new_id)->rnd = 0xff; SILC_LOG_DEBUG(("New ID (%s)", silc_id_render(*new_id, SILC_ID_SERVER))); } @@ -54,14 +54,14 @@ void silc_id_create_server_id(const char *ip, SilcUInt16 port, SilcRng rng, caller must recall the function with different nickname. If this returns TRUE the new ID was created successfully. */ -bool silc_id_create_client_id(SilcServer server, - SilcServerID *server_id, SilcRng rng, - SilcHash md5hash, - unsigned char *nickname, SilcUInt32 nick_len, - SilcClientID **new_id) +SilcBool silc_id_create_client_id(SilcServer server, + SilcServerID *server_id, SilcRng rng, + SilcHash md5hash, + unsigned char *nickname, SilcUInt32 nick_len, + SilcClientID **new_id) { unsigned char hash[16]; - bool finding = FALSE; + SilcBool finding = FALSE; SILC_LOG_DEBUG(("Creating new Client ID")); @@ -107,11 +107,11 @@ bool silc_id_create_client_id(SilcServer server, /* Creates Channel ID */ -bool silc_id_create_channel_id(SilcServer server, - SilcServerID *router_id, SilcRng rng, - SilcChannelID **new_id) +SilcBool silc_id_create_channel_id(SilcServer server, + SilcServerID *router_id, SilcRng rng, + SilcChannelID **new_id) { - bool finding = TRUE; + SilcBool finding = TRUE; SILC_LOG_DEBUG(("Creating new Channel ID")); @@ -148,16 +148,19 @@ bool silc_id_create_channel_id(SilcServer server, /* Checks whether the `server_id' is valid. It must be based to the IP address provided in the `remote' socket connection. */ -bool silc_id_is_valid_server_id(SilcServer server, - SilcServerID *server_id, - SilcSocketConnection remote) +SilcBool silc_id_is_valid_server_id(SilcServer server, + SilcServerID *server_id, + SilcPacketStream remote) { unsigned char ip[16]; + const char *remote_ip; + SilcStream stream = silc_packet_stream_get_stream(remote); - if (!silc_net_addr2bin(remote->ip, ip, sizeof(ip))) + silc_socket_stream_get_info(stream, NULL, NULL, &remote_ip, NULL); + if (!silc_net_addr2bin(remote_ip, ip, sizeof(ip))) return FALSE; - if (silc_net_is_ip4(remote->ip)) { + if (silc_net_is_ip4(remote_ip)) { if (!memcmp(server_id->ip.data, ip, 4)) return TRUE; } else {