+Fri Mar 29 21:55:41 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Made some structure optimizations. SFTP memory FS MemFSEntry
+ entry structure. Optimized SilcTask structure. Optimized
+ SilcPacketContext structure.
+
+ Affected files lib/silcsftp/sftp_fs_memory.c,
+ lib/silcutil/silcschedule.c, lib/silccore/silcpacket.h.
+
Fri Mar 29 10:41:07 EET 2002 Pekka Riikonen <priikone@silcnet.org>
* And yet again reverted back the config thing since Johnny
SILC_BUFFER_LEN macro can do the same. These would save
totally 8 bytes of memory per buffer.
- o Scheduler can be optimized for FD tasks by changing the fd_queue
- to SilcHashTable instead of using linked list. We need to do
- one-to-one mapping of FD to task and hash table is more efficient
- for this usage.
-
- Also redefine the silc_select to perhaps return a separate
- structure of the events that actually occurred, instead of
- returning the events in the fd_list which is then traversed
- in the generic code to find the changed events. This can be
- made faster by having own struct which includes only the
- changed events, thus the tarversing is faster since the whole
- fd_list is not traversed anymore (it is still traversed in the
- silc_select but at least it removes one extra tarversing later
- for the same list).
-
- Other task queues should be changed to use SilcList.
-
o Optimizations in Server
o Remove the big switch statement from the function
o Rewrite SilcProtocol to be SilcFSM (see ~/silcfsm).
+ o Do some scheduler optimizations (see ~/silcschedule).
+
o Change SILC_TASK_CALLBACK to non-static, and remove the macro
SILC_TASK_CALLBACK_GLOBAL.
o SILC RNG does not implement random seed files, and they should be
implemented.
- o Add SILC scheduler's internal routines into a table of implementation
- function pointers, that the generic code then takes as extern from
- implementation. These are the silc_schedule_internal_* routines.
-
o Cipher optimizations (asm, that this) at least for i386 would be nice.
o Add builtin SOCKS and HTTP Proxy support, well the SOCKS at least.
*
* Short description of the fields following:
*
- * SilcBuffer buffer
- *
- * The data buffer.
- *
- * SilcPacketType type
+ * SilcUInt16 truelen
*
- * Type of the packet. Types are defined below.
+ * True length of the packet. This may be set by the caller before
+ * calling any of the silc_packet_* routines. If not provided the
+ * library will calculate the values.
*
* SilcPacketFlags flags
*
* Packet flags. Flags are defined above.
*
+ * SilcPacketType type
+ *
+ * Type of the packet. Types are defined below.
+ *
* unsigned char *src_id
* SilcUInt8 src_id_len
* unsigned char src_id_type
* Destination ID, its length and type. On packet reception retuned
* ID's are always the hash values of the ID's from the packet.
*
- * SilcUInt16 truelen
* SilcUInt8 padlen
*
- * The true lenght of the packet and the padded length of the packet.
- * These may be set by the caller before calling any of the
- * silc_packet_* routines. If not provided the library will calculate
- * the values.
+ * The padded length of the packet. This may be set by the caller
+ * before calling any of the silc_packet_* routines. If not provided
+ * the library will calculate the values.
+ *
+ * unsigned int long_pad
+ *
+ * If set to TRUE the packet will include the maximum padding allowed
+ * in SILC packet, which is 128 bytes. If FALSE only the amount of
+ * padding needed will be applied.
*
- * int users;
+ * unsigned int users;
*
* Reference counter for this context. The context is freed only
* after the reference counter hits zero. The counter is added
*
* Packet sequence number.
*
+ * SilcBuffer buffer
+ *
+ * The actual packet data.
+ *
***/
typedef struct {
- SilcBuffer buffer;
-
SilcUInt16 truelen;
SilcPacketFlags flags;
SilcPacketType type;
- SilcUInt8 padlen;
unsigned char *src_id;
+ unsigned char *dst_id;
SilcUInt8 src_id_len;
SilcUInt8 src_id_type;
-
- unsigned char *dst_id;
SilcUInt8 dst_id_len;
SilcUInt8 dst_id_type;
- int users;
- bool long_pad; /* Set to TRUE to use maximum padding
- in packet (up to 256 bytes). */
+ SilcUInt8 padlen;
+ unsigned int long_pad : 1; /* Set when maximum padding in packet */
+ unsigned int users : 23; /* Reference counter */
SilcUInt32 sequence;
+ SilcBuffer buffer;
} SilcPacketContext;
/****s* silccore/SilcPacketAPI/SilcPacketParserContext
const struct SilcSFTPFilesystemOpsStruct silc_sftp_fs_memory;
-/* Memory filesystem entry */
typedef struct MemFSEntryStruct {
- char *name; /* Name of the entry */
- char *data; /* Data of the entry */
- bool directory; /* TRUE if this is directory */
- SilcSFTPFSMemoryPerm perm; /* Permissions */
struct MemFSEntryStruct **entry; /* Files and sub-directories */
- SilcUInt32 entry_count; /* Number of files and sub-directories */
+ SilcUInt32 entry_count; /* Number of files and sub-directories */
struct MemFSEntryStruct *parent; /* non-NULL if `directory' is TRUE,
includes parent directory. */
unsigned long created; /* Time of creation */
+ char *name; /* Name of the entry */
+ char *data; /* Data of the entry */
+ unsigned int directory : 1; /* Set if this is directory */
+ unsigned int perm : 7; /* Permissions */
} *MemFSEntry;
/* File handle. */
/* SILC Task object. Represents one task in the scheduler. */
struct SilcTaskStruct {
SilcUInt32 fd;
- struct timeval timeout;
- SilcTaskCallback callback;
- void *context;
- bool valid;
- SilcTaskPriority priority;
- SilcTaskType type;
+ SilcTaskCallback callback; /* Task callback */
+ void *context; /* Task callback context */
+ struct timeval timeout; /* Set for timeout tasks */
+ unsigned int valid : 1; /* Set when task is valid */
+ unsigned int priority : 2; /* Priority of the task */
+ unsigned int type : 5; /* Type of the task */
/* Pointers forming doubly linked circular list */
struct SilcTaskStruct *next;
typedef enum {
/* File descriptor task that performs some event over file descriptors.
These tasks are for example network connections. */
- SILC_TASK_FD,
+ SILC_TASK_FD = 0,
/* Timeout tasks are tasks that are executed after the specified
time has elapsed. After the task is executed the task is removed
has expired only and only when every other task with higher priority
has already been run. For non-timeout tasks this priority behaves
same way. Life is not fair for tasks with this priority. */
- SILC_TASK_PRI_LOW,
+ SILC_TASK_PRI_LOW = 0,
/* Normal priority that is used mostly in SILC. This is priority that
should always be used unless you specificly need some other priority.