X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcsockconn.h;h=e8f3356cdae300e1c8ae6ea39c0f51461a8808c8;hb=7431bd61b7149a1b25ccd969cfbb05316ff9fa59;hp=6507e269f913833ee3a8ba88d7a68662f017ad0c;hpb=9b47b4cbecca281ab183fa2cf4c590848c0ce9cc;p=silc.git diff --git a/lib/silcutil/silcsockconn.h b/lib/silcutil/silcsockconn.h index 6507e269..e8f3356c 100644 --- a/lib/silcutil/silcsockconn.h +++ b/lib/silcutil/silcsockconn.h @@ -67,6 +67,31 @@ typedef struct SilcSocketConnectionStruct *SilcSocketConnection; ***/ typedef struct SilcSocketConnectionHBStruct *SilcSocketConnectionHB; +/****s* silcutil/SilcSocketConnectionAPI/SilcSocketConnectionQos + * + * NAME + * + * typedef struct SilcSocketConnectionQosStruct *SilcSocketConnectionQos; + * + * DESCRIPTION + * + * This structure is "Quality of Service" structure for the socket + * connection and is set with silc_socket_set_qos function for a + * socket context. + * + ***/ +typedef struct SilcSocketConnectionQosStruct { + SilcUInt16 read_limit_bytes; /* Max read bytes */ + SilcUInt16 read_rate; /* Max read rate/second */ + SilcUInt16 limit_sec; /* Limit seconds */ + SilcUInt32 limit_usec; /* Limit microseconds */ + SilcSchedule schedule; + struct timeval next_limit; + unsigned int cur_rate : 31; + unsigned int applied : 1; + SilcUInt32 data_len; +} *SilcSocketConnectionQos; + /****d* silcutil/SilcSocketConnectionAPI/SilcSocketType * * NAME @@ -183,6 +208,7 @@ struct SilcSocketConnectionStruct { int users; SilcSocketConnectionHB hb; + SilcSocketConnectionQos qos; SilcBuffer inbuf; SilcBuffer outbuf; @@ -383,6 +409,38 @@ void silc_socket_set_heartbeat(SilcSocketConnection sock, SilcSocketConnectionHBCb hb_callback, SilcSchedule schedule); +/****f* silcutil/SilcSocketConnectionAPI/silc_socket_set_qos + * + * SYNOPSIS + * + * void silc_socket_set_qos(SilcSocketConnection sock, + * SilcUInt32 read_rate, + * SilcUInt32 read_limit_bytes, + * SilcUInt32 limit_sec, + * SilcUInt32 limit_usec, + * SilcSchedule schedule) + * + * DESCRIPTION + * + * Sets a "Quality of Service" settings for socket connection `sock'. + * The `read_rate' specifies the maximum read operations per second. + * If more read operations are executed the limit will be applied for + * the reading. The `read_limit_bytes' specifies the maximum data + * that is read. It is guaranteed that silc_socket_read never returns + * more that `read_limit_bytes' of data. If more is read the limit + * will be applied for the reading. The `limit_sec' and `limit_usec' + * specifies the limit that is applied if `read_rate' and/or + * `read_limit_bytes' is reached. The `schedule' is the application's + * scheduler. + * + ***/ +void silc_socket_set_qos(SilcSocketConnection sock, + SilcUInt32 read_rate, + SilcUInt32 read_limit_bytes, + SilcUInt32 limit_sec, + SilcUInt32 limit_usec, + SilcSchedule schedule); + /****f* silcutil/SilcSocketConnectionAPI/SilcSocketHostLookupCb * * SYNOPSIS