Change silc_buffer_*len macros to inline functions.
12 files changed:
+typedef struct SilcClientStatsStruct {
SilcUInt32 starttime; /* SILC server start time */
SilcUInt32 uptime; /* SILC server uptime*/
SilcUInt32 my_clients; /* Number of clients in the server */
SilcUInt32 starttime; /* SILC server start time */
SilcUInt32 uptime; /* SILC server uptime*/
SilcUInt32 my_clients; /* Number of clients in the server */
+typedef struct SilcPrivateMessageKeysStruct {
SilcClientEntry client_entry; /* The remote client entry */
char *cipher; /* The cipher name */
unsigned char *key; /* The original key, If the appliation
SilcClientEntry client_entry; /* The remote client entry */
char *cipher; /* The cipher name */
unsigned char *key; /* The original key, If the appliation
+typedef struct SilcClientOperationsStruct {
/* Message sent to the application by library. `conn' associates the
message to a specific connection. `conn', however, may be NULL.
The `type' indicates the type of the message sent by the library.
/* Message sent to the application by library. `conn' associates the
message to a specific connection. `conn', however, may be NULL.
The `type' indicates the type of the message sent by the library.
+typedef struct SilcClientParamsStruct {
/* If this boolean is set to TRUE then the client library will use
threads. Any of the callback functions in the SilcClientOperations
and other callbacks may be called at any time in a thread. The
/* If this boolean is set to TRUE then the client library will use
threads. Any of the callback functions in the SilcClientOperations
and other callbacks may be called at any time in a thread. The
+typedef struct SilcClientConnectionParamsStruct {
/* If this is provided the user's nickname in the network will be the
string given here. If it is given, it must be UTF-8 encoded. If this
string is not given, the user's username by default is used as nickname.
/* If this is provided the user's nickname in the network will be the
string given here. If it is given, it must be UTF-8 encoded. If this
string is not given, the user's username by default is used as nickname.
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 - 2006 Pekka Riikonen
+ Copyright (C) 2001 - 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
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
* of freeing the contents of the structure and the structure itself.
*
***/
* of freeing the contents of the structure and the structure itself.
*
***/
+typedef struct SilcArgumentDecodedListStruct {
void *argument; /* Decoded argument, caller must know its type */
SilcUInt32 arg_type; /* Argument type number from the payload */
} *SilcArgumentDecodedList;
void *argument; /* Decoded argument, caller must know its type */
SilcUInt32 arg_type; /* Argument type number from the payload */
} *SilcArgumentDecodedList;
+typedef struct SilcIDIPStruct {
unsigned char data[16]; /* IP data (in MSB first order) */
SilcUInt8 data_len; /* Length of the data (4 or 16) */
} SilcIDIP;
unsigned char data[16]; /* IP data (in MSB first order) */
SilcUInt8 data_len; /* Length of the data (4 or 16) */
} SilcIDIP;
+typedef struct SilcServerIDStruct {
SilcIDIP ip; /* n bit IP address */
SilcUInt16 port; /* 16 bit port */
SilcUInt16 rnd; /* 16 bit random number */
SilcIDIP ip; /* n bit IP address */
SilcUInt16 port; /* 16 bit port */
SilcUInt16 rnd; /* 16 bit random number */
+typedef struct SilcClientIDStruct {
SilcIDIP ip; /* n bit IP address */
unsigned char rnd; /* 8 bit random number */
unsigned char hash[CLIENTID_HASH_LEN]; /* 88 bit MD5 hash */
SilcIDIP ip; /* n bit IP address */
unsigned char rnd; /* 8 bit random number */
unsigned char hash[CLIENTID_HASH_LEN]; /* 88 bit MD5 hash */
+typedef struct SilcChannelIDStruct {
SilcIDIP ip; /* n bit IP address */
SilcUInt16 port; /* 16 bit port */
SilcUInt16 rnd; /* 16 bit random number */
SilcIDIP ip; /* n bit IP address */
SilcUInt16 port; /* 16 bit port */
SilcUInt16 rnd; /* 16 bit random number */
+typedef struct SilcIDStruct {
union {
SilcServerID server_id;
SilcChannelID channel_id;
union {
SilcServerID server_id;
SilcChannelID channel_id;
/* Export PKCS algorithm public key */
if (pkcs->export_public_key)
pk = pkcs->export_public_key(silc_pubkey->public_key, &pk_len);
/* Export PKCS algorithm public key */
if (pkcs->export_public_key)
pk = pkcs->export_public_key(silc_pubkey->public_key, &pk_len);
+ if (!pk) {
+ SILC_LOG_ERROR(("Error exporting PKCS algorithm key"));
silc_buffer_set(&alg_key, pk, pk_len);
/* Encode identifier */
silc_buffer_set(&alg_key, pk, pk_len);
/* Encode identifier */
silc_pubkey->identifier.org,
silc_pubkey->identifier.country,
silc_pubkey->identifier.version);
silc_pubkey->identifier.org,
silc_pubkey->identifier.country,
silc_pubkey->identifier.version);
+ if (!identifier) {
+ SILC_LOG_ERROR(("Error encoding SILC public key identifier"));
asn1 = silc_asn1_alloc();
if (!asn1)
asn1 = silc_asn1_alloc();
if (!asn1)
- SILC_LOG_DEBUG(("Unsupported PKCS algorithm"));
+ SILC_LOG_ERROR(("Unsupported PKCS algorithm: %s", pkcs->name));
+typedef struct SilcPublicKeyIdentifierObject {
char *username;
char *host;
char *realname;
char *username;
char *host;
char *realname;
+typedef struct SilcSILCPublicKeyStruct {
SilcPublicKeyIdentifierStruct identifier;
const SilcPKCSAlgorithm *pkcs; /* PKCS algorithm */
void *public_key; /* PKCS algorithm specific public key */
SilcPublicKeyIdentifierStruct identifier;
const SilcPKCSAlgorithm *pkcs; /* PKCS algorithm */
void *public_key; /* PKCS algorithm specific public key */
+typedef struct SilcSILCPrivateKeyStruct {
const SilcPKCSAlgorithm *pkcs; /* PKCS algorithm */
void *private_key; /* PKCS algorithm specific private key */
} *SilcSILCPrivateKey;
const SilcPKCSAlgorithm *pkcs; /* PKCS algorithm */
void *private_key; /* PKCS algorithm specific private key */
} *SilcSILCPrivateKey;
+typedef struct SilcPublicKeyStruct {
const SilcPKCSObject *pkcs; /* PKCS */
void *public_key; /* PKCS specific public key */
} *SilcPublicKey;
const SilcPKCSObject *pkcs; /* PKCS */
void *public_key; /* PKCS specific public key */
} *SilcPublicKey;
+typedef struct SilcPrivateKeyStruct {
const SilcPKCSObject *pkcs; /* PKCS */
void *private_key; /* PKCS specific private key */
} *SilcPrivateKey;
const SilcPKCSObject *pkcs; /* PKCS */
void *private_key; /* PKCS specific private key */
} *SilcPrivateKey;
* server, and by server to return file attributes to the client.
*
***/
* server, and by server to return file attributes to the client.
*
***/
+typedef struct SilcSFTPAttributesObject {
SilcUInt32 flags; /* Flags to indicate present attributes */
SilcUInt64 size; /* Sife of the file in bytes */
SilcUInt32 uid; /* Unix user ID */
SilcUInt32 flags; /* Flags to indicate present attributes */
SilcUInt64 size; /* Sife of the file in bytes */
SilcUInt32 uid; /* Unix user ID */
* example when reading the contents of a directory.
*
***/
* example when reading the contents of a directory.
*
***/
+typedef struct SilcSFTPNameObject {
char **filename;
char **long_filename;
SilcSFTPAttributes *attrs;
char **filename;
char **long_filename;
SilcSFTPAttributes *attrs;
+typedef struct SilcSFTPMonitorDataObject {
SilcSFTPVersion version; /* _INIT */
char *name; /* _OPEN, _REMOVE, _RENAME, _MKDIR,
_RMDIR, _OPENDIR, _STAT, _LSTAT,
SilcSFTPVersion version; /* _INIT */
char *name; /* _OPEN, _REMOVE, _RENAME, _MKDIR,
_RMDIR, _OPENDIR, _STAT, _LSTAT,
+typedef struct SilcSFTPFilesystemStruct {
SilcSFTPFilesystemOps fs;
void *fs_context;
} *SilcSFTPFilesystem;
SilcSFTPFilesystemOps fs;
void *fs_context;
} *SilcSFTPFilesystem;
+typedef struct SilcSKESecurityPropertiesStruct {
SilcSKESecurityPropertyFlag flags; /* Flags */
SilcSKEDiffieHellmanGroup group; /* Selected Diffie Hellman group */
SilcCipher cipher; /* Selected cipher */
SilcSKESecurityPropertyFlag flags; /* Flags */
SilcSKEDiffieHellmanGroup group; /* Selected Diffie Hellman group */
SilcCipher cipher; /* Selected cipher */
+typedef struct SilcSKEKeyMaterialStruct {
unsigned char *send_iv;
unsigned char *receive_iv;
SilcUInt32 iv_len;
unsigned char *send_iv;
unsigned char *receive_iv;
SilcUInt32 iv_len;
+typedef struct SilcSKERekeyMaterialStruct {
unsigned char *send_enc_key;
char *hash;
unsigned int enc_key_len : 23;
unsigned char *send_enc_key;
char *hash;
unsigned int enc_key_len : 23;
+typedef struct SilcSKEParamsObject {
/* The SKE version string that is sent to the remote end. This field
must be set. Caller must free the pointer. */
char *version;
/* The SKE version string that is sent to the remote end. This field
must be set. Caller must free the pointer. */
char *version;
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1998 - 2006 Pekka Riikonen
+ Copyright (C) 1998 - 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
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
+typedef struct SilcBufferObject {
unsigned char *head;
unsigned char *data;
unsigned char *tail;
unsigned char *head;
unsigned char *data;
unsigned char *tail;
-/****d* silcutil/SilcBufferAPI/silc_buffer_truelen
+/****f* silcutil/SilcBufferAPI/silc_buffer_data
- * SilcUInt32 silc_buffer_truelen(SilcBuffer sb)
+ * unsigned char *silc_buffer_data(SilcBuffer sb)
- * Returns the true length of the buffer.
+ * Returns pointer to the data area of the buffer.
-#define silc_buffer_truelen(x) (SilcUInt32)((x)->end - (x)->head)
+#define silc_buffer_data(x) (x)->data
-/****d* silcutil/SilcBufferAPI/silc_buffer_len
+/****f* silcutil/SilcBufferAPI/silc_buffer_datalen
- * SilcUInt32 silc_buffer_len(SilcBuffer sb)
+ * #define silc_buffer_datalen ...
- * Returns the current length of the data area of the buffer.
+ * Macro that can be used in function argument list to give the data
+ * pointer and the data length, instead of calling both silc_buffer_data
+ * and silc_buffer_len separately.
+ *
+ * EXAMPLE
+ *
+ * // Following are the same thing
+ * silc_foo_function(foo, silc_buffer_datalen(buf));
+ * silc_foo_function(foo, silc_buffer_data(buf), silc_buffer_len(buf));
-#define silc_buffer_len(x) (SilcUInt32)((x)->tail - (x)->data)
+#define silc_buffer_datalen(x) (x) ? silc_buffer_data((x)) : NULL, \
+ (x) ? silc_buffer_len((x)) : 0
-/****d* silcutil/SilcBufferAPI/silc_buffer_headlen
+/* Inline functions */
+
+/****d* silcutil/SilcBufferAPI/silc_buffer_truelen
- * SilcUInt32 silc_buffer_headlen(SilcBuffer sb)
+ * SilcUInt32 silc_buffer_truelen(SilcBuffer sb)
- * Returns the current length of the head data area of the buffer.
+ * Returns the true length of the buffer.
- * SOURCE
- */
-#define silc_buffer_headlen(x) (SilcUInt32)((x)->data - (x)->head)
-/***/
+ ***/
+static inline
+SilcUInt32 silc_buffer_truelen(SilcBuffer x)
+{
+ return (SilcUInt32)(x->end - x->head);
+}
-/****d* silcutil/SilcBufferAPI/silc_buffer_taillen
+/****d* silcutil/SilcBufferAPI/silc_buffer_len
- * SilcUInt32 silc_buffer_taillen(SilcBuffer sb)
+ * SilcUInt32 silc_buffer_len(SilcBuffer sb)
- * Returns the current length of the tail data area of the buffer.
+ * Returns the current length of the data area of the buffer.
- * SOURCE
- */
-#define silc_buffer_taillen(x) (SilcUInt32)((x)->end - (x)->tail)
-/***/
+ ***/
+static inline
+SilcUInt32 silc_buffer_len(SilcBuffer x)
+{
+ return (SilcUInt32)(x->tail - x->data);
+}
-/****f* silcutil/SilcBufferAPI/silc_buffer_data
+/****d* silcutil/SilcBufferAPI/silc_buffer_headlen
- * unsigned char *silc_buffer_data(SilcBuffer sb)
+ * SilcUInt32 silc_buffer_headlen(SilcBuffer sb)
- * Returns pointer to the data area of the buffer.
+ * Returns the current length of the head data area of the buffer.
- * SOURCE
- */
-#define silc_buffer_data(x) (x)->data
-/***/
+ ***/
+static inline
+SilcUInt32 silc_buffer_headlen(SilcBuffer x)
+{
+ return (SilcUInt32)(x->data - x->head);
+}
-/****f* silcutil/SilcBufferAPI/silc_buffer_datalen
+/****d* silcutil/SilcBufferAPI/silc_buffer_taillen
- * #define silc_buffer_datalen ...
+ * SilcUInt32 silc_buffer_taillen(SilcBuffer sb)
- * Macro that can be used in function argument list to give the data
- * pointer and the data length, instead of calling both silc_buffer_data
- * and silc_buffer_len separately.
- *
- * EXAMPLE
- *
- * // Following are the same thing
- * silc_foo_function(foo, silc_buffer_datalen(buf));
- * silc_foo_function(foo, silc_buffer_data(buf), silc_buffer_len(buf));
+ * Returns the current length of the tail data area of the buffer.
- * SOURCE
- */
-#define silc_buffer_datalen(x) (x) ? silc_buffer_data((x)) : NULL, \
- (x) ? silc_buffer_len((x)) : 0
-/***/
-
-/* Inline functions */
+ ***/
+static inline
+SilcUInt32 silc_buffer_taillen(SilcBuffer x)
+{
+ return (SilcUInt32)(x->end - x->tail);
+}
/****f* silcutil/SilcBufferAPI/silc_buffer_alloc
*
/****f* silcutil/SilcBufferAPI/silc_buffer_alloc
*
* function silc_list_init.
*
***/
* function silc_list_init.
*
***/
+typedef struct SilcListStruct {
void *head; /* Start of the list */
void *tail; /* End of the list */
void *current; /* Current pointer in list */
void *head; /* Start of the list */
void *tail; /* End of the list */
void *current; /* Current pointer in list */
+typedef struct SilcTimeObject {
unsigned int year : 15; /* Year, 0 - 32768 */
unsigned int month : 4; /* Month, 1 - 12 */
unsigned int day : 5; /* Day, 1 - 31 */
unsigned int year : 15; /* Year, 0 - 32768 */
unsigned int month : 4; /* Month, 1 - 12 */
unsigned int day : 5; /* Day, 1 - 31 */
- * Compares `t1' and `t2' time structures and returns less than zero,
+ * Compares `t1' and `t2' time structures and returns less than zero,
* zero or more than zero when `t1' is smaller, equal or bigger than
* `t2', respectively.
*
* zero or more than zero when `t1' is smaller, equal or bigger than
* `t2', respectively.
*