updates.
[silc.git] / lib / silcutil / silcsockconn.h
index 20e307403d1e4ec011a1251318343b41ea793a51..a7c23d5a90ea252e7d0fad2fd8c8de5dab0f1f8a 100644 (file)
@@ -1,24 +1,24 @@
-/****h* silcutil/silcsockconn.h
- *
- * NAME
- *
- * silcsockconn.h
- *
- * COPYRIGHT
- *
- * Author: Pekka Riikonen <priikone@silnet.org>
- *
- * Copyright (C) 1997 - 2001 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+/*
+  silcsockconn.h
+  Author: Pekka Riikonen <priikone@silnet.org>
+  Copyright (C) 1997 - 2001 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
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+*/
+
+/****h* silcutil/SilcSocketConnectionAPI
  *
  * DESCRIPTION
  *
@@ -94,11 +94,13 @@ typedef enum {
 
 /* Socket flags */
 #define SILC_SF_NONE             0
-#define SILC_SF_INBUF_PENDING    1
-#define SILC_SF_OUTBUF_PENDING   2
-#define SILC_SF_DISCONNECTING    3
-#define SILC_SF_DISCONNECTED     4
-#define SILC_SF_HOST_LOOKUP      5
+#define SILC_SF_INBUF_PENDING    1 /* data in inbound buffer */
+#define SILC_SF_OUTBUF_PENDING   2 /* data in outbound buffer */
+#define SILC_SF_DISCONNECTING    3 /* socket disconnecting */
+#define SILC_SF_DISCONNECTED     4 /* socket disconnected */
+#define SILC_SF_HOST_LOOKUP      5 /* performing host lookup for socket */
+#define SILC_SF_DISABLED         6 /* socket connection is disabled,
+                                     no data is sent or received. */
 
 /****s* silcutil/SilcSocketConnectionAPI/SilcSocketConnectionStruct
  *
@@ -177,6 +179,7 @@ struct SilcSocketConnectionStruct {
   void *user_data;
   SilcProtocol protocol;
   uint32 flags;
+  uint8 sock_error;
   int users;
 
   char *hostname;
@@ -208,11 +211,13 @@ struct SilcSocketConnectionStruct {
 #define SILC_SET_DISCONNECTING(x) SF_SET((x), SILC_SF_DISCONNECTING)
 #define SILC_SET_DISCONNECTED(x) SF_SET((x), SILC_SF_DISCONNECTED)
 #define SILC_SET_HOST_LOOKUP(x) SF_SET((x), SILC_SF_HOST_LOOKUP)
+#define SILC_SET_DISABLED(x) SF_SET((x), SILC_SF_HOST_LOOKUP)
 #define SILC_UNSET_OUTBUF_PENDING(x) SF_UNSET((x), SILC_SF_OUTBUF_PENDING)
 #define SILC_UNSET_INBUF_PENDING(x) SF_UNSET((x), SILC_SF_INBUF_PENDING)
 #define SILC_UNSET_DISCONNECTING(x) SF_UNSET((x), SILC_SF_DISCONNECTING)
 #define SILC_UNSET_DISCONNECTED(x) SF_UNSET((x), SILC_SF_DISCONNECTED)
 #define SILC_UNSET_HOST_LOOKUP(x) SF_UNSET((x), SILC_SF_HOST_LOOKUP)
+#define SILC_UNSET_DISABLED(x) SF_UNSET((x), SILC_SF_DISABLED)
 
 /* Checking for flags */
 #define SILC_IS_OUTBUF_PENDING(x) SF_IS((x), SILC_SF_OUTBUF_PENDING)
@@ -220,6 +225,7 @@ struct SilcSocketConnectionStruct {
 #define SILC_IS_DISCONNECTING(x) SF_IS((x), SILC_SF_DISCONNECTING)
 #define SILC_IS_DISCONNECTED(x) SF_IS((x), SILC_SF_DISCONNECTED)
 #define SILC_IS_HOST_LOOKUP(x) SF_IS((x), SILC_SF_HOST_LOOKUP)
+#define SILC_IS_DISABLED(x) SF_IS((x), SILC_SF_DISABLED)
 
 /* Prototypes */
 
@@ -308,6 +314,23 @@ int silc_socket_read(SilcSocketConnection sock);
  ***/
 int silc_socket_write(SilcSocketConnection sock);
 
+/****f* silcutil/SilcSocketConnectionAPI/silc_socket_get_error
+ *
+ * SYNOPSIS
+ *
+ *    bool silc_socket_get_error(SilcSocketConnection sock, char *error,
+ *                               uint32 error_len);
+ *
+ * DESCRIPTION
+ *
+ *    Returns human readable error message into the `error' buffer if
+ *    the socket is int error status.  Returns TRUE if error message was
+ *    written into the buffer and FALSE if there is not socket error.
+ *
+ ***/
+bool silc_socket_get_error(SilcSocketConnection sock, char *error,
+                          uint32 error_len);
+
 /****f* silcutil/SilcSocketConnectionAPI/SilcSocketConnectionHBCb
  *
  * SYNOPSIS
@@ -373,6 +396,7 @@ typedef void (*SilcSocketHostLookupCb)(SilcSocketConnection sock,
  * SYNOPSIS
  *
  *    void silc_socket_host_lookup(SilcSocketConnection sock,
+ *                                 bool port_lookup,
  *                                 SilcSocketHostLookupCb callback,
  *                                 void *context,
  *                                 SilcSchedule schedule);