5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2005 - 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 #ifndef SILCSOCKETSTREAM_I_H
21 #define SILCSOCKETSTREAM_I_H
23 #ifndef SILCSOCKETSTREAM_H
24 #error "Do not include this header directly"
27 typedef struct SilcSocketStreamStruct *SilcSocketStream;
30 typedef struct SilcSocketQosStruct {
31 SilcUInt16 read_limit_bytes; /* Max read bytes */
32 SilcUInt16 read_rate; /* Max read rate/second */
33 SilcUInt16 limit_sec; /* Limit seconds */
34 SilcUInt32 limit_usec; /* Limit microseconds */
35 struct timeval next_limit;
36 unsigned int cur_rate : 31;
37 unsigned int applied : 1;
39 unsigned char *buffer;
40 SilcSocketStream sock;
43 /* SILC Socket Stream context */
44 struct SilcSocketStreamStruct {
45 const SilcStreamOps *ops;
46 SilcSchedule schedule;
51 SilcStreamNotifier notifier;
52 void *notifier_context;
54 unsigned int ipv6 : 1; /* UDP IPv6 */
55 unsigned int connected : 1; /* UDP connected state */
58 #define SILC_IS_SOCKET_STREAM(s) (s->ops == &silc_socket_stream_ops)
59 #define SILC_IS_SOCKET_STREAM_UDP(s) (s->ops == &silc_socket_udp_stream_ops)
61 extern const SilcStreamOps silc_socket_stream_ops;
62 extern const SilcStreamOps silc_socket_udp_stream_ops;
64 /* Backwards support */
65 #define SilcSocketStreamStatus SilcResult
66 #define silc_socket_stream_get_error(stream) silc_errno
67 #define SILC_SOCKET_OK SILC_OK
68 #define SILC_SOCKET_UNKNOWN_IP SILC_ERR_UNKNOWN_IP
69 #define SILC_SOCKET_UNKNOWN_HOST SILC_ERR_UNKNOWN_HOST
70 #define SILC_SOCKET_NO_MEMORY SILC_ERR_OUT_OF_MEMORY
71 #define SILC_SOCKET_ERROR SILC_ERR
73 #endif /* SILCSOCKETSTREAM_I_H */