id.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2005 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
SilcIDPayload newp;
int ret;
- SILC_LOG_DEBUG(("Parsing ID payload"));
-
silc_buffer_set(&buffer, (unsigned char *)payload, payload_len);
newp = silc_calloc(1, sizeof(*newp));
if (!newp)
return newp;
err:
+ SILC_LOG_DEBUG(("Error parsing ID payload"));
silc_free(newp);
return NULL;
}
SILC_STR_UI_SHORT(&idlen),
SILC_STR_END);
if (ret == -1)
- return NULL;
+ goto err;
if (type > SILC_ID_CHANNEL)
- return NULL;
+ goto err;
silc_buffer_pull(&buffer, 4);
if (idlen > buffer.len || idlen > SILC_PACKET_MAX_ID_LEN)
- return NULL;
+ goto err;
ret = silc_buffer_unformat(&buffer,
SILC_STR_UI_XNSTRING(&id_data, idlen),
SILC_STR_END);
if (ret == -1)
- return NULL;
+ goto err;
id = silc_id_str2id(id_data, idlen, type);
*ret_type = type;
return id;
+
+ err:
+ SILC_LOG_DEBUG(("Error parsing ID payload"));
+ return NULL;
}
/* Encodes ID Payload */
{
SilcBuffer buffer;
- SILC_LOG_DEBUG(("Encoding %s ID payload",
- type == SILC_ID_CLIENT ? "Client" :
- type == SILC_ID_SERVER ? "Server" : "Channel"));
-
buffer = silc_buffer_alloc_size(4 + id_len);
if (!buffer)
return NULL;