updates. New data types.
[silc.git] / lib / silccore / silcsockconn.h
index 9b190d1bb157cdf20bf4a4e6711546ebd647c19b..f77ea997c38d2ee8e33af7f66bc1095104716f6f 100644 (file)
@@ -80,15 +80,20 @@ typedef void (*SilcSocketConnectionHBCb)(SilcSocketConnection sock,
        Protocol object for the socket. Currently only one protocol can be
        executing at a time for a particular socket.
 
-   unsigned int flags
+   uint32 flags
 
        Socket flags that indicate the status of the socket. This can
        indicate several different status that can affect the use of the
        socket object.
 
+   int users
+
+       Reference counter. When allocated it is set to one (1) and it won't
+       be freed until it hits zero (0).
+
    char *hostname
    char *ip
-   unsigned short port
+   uint16 port
 
        Resolved hostname, IP address and port of the connection who owns
        this object.
@@ -111,11 +116,12 @@ struct SilcSocketConnectionStruct {
   SilcSocketType type;
   void *user_data;
   SilcProtocol protocol;
-  unsigned int flags;
+  uint32 flags;
+  int users;
 
   char *hostname;
   char *ip;
-  unsigned short port;
+  uint16 port;
 
   SilcBuffer inbuf;
   SilcBuffer outbuf;
@@ -125,7 +131,7 @@ struct SilcSocketConnectionStruct {
 
 /* Heartbeat context */
 struct SilcSocketConnectionHB {
-  unsigned long heartbeat;
+  uint32 heartbeat;
   SilcSocketConnectionHBCb hb_callback;
   void *hb_context;
   void *timeout_queue;
@@ -138,7 +144,7 @@ struct SilcSocketConnectionHB {
 /* Generic manipulation of flags */
 #define SF_SET(x, f) (x)->flags |= (1L << (f))
 #define SF_UNSET(x, f) (x)->flags &= ~(1L << (f))
-#define SF_IS(x, f) (x)->flags & (1L << (f))
+#define SF_IS(x, f) ((x)->flags & (1L << (f)))
 
 /* Setting/Unsetting flags */
 #define SILC_SET_OUTBUF_PENDING(x) SF_SET((x), SILC_SF_OUTBUF_PENDING)
@@ -160,8 +166,9 @@ struct SilcSocketConnectionHB {
 void silc_socket_alloc(int sock, SilcSocketType type, void *user_data,
                       SilcSocketConnection *new_socket);
 void silc_socket_free(SilcSocketConnection sock);
+SilcSocketConnection silc_socket_dup(SilcSocketConnection sock);
 void silc_socket_set_heartbeat(SilcSocketConnection sock, 
-                              unsigned long heartbeat,
+                              uint32 heartbeat,
                               void *hb_context,
                               SilcSocketConnectionHBCb hb_callback,
                               void *timeout_queue);