Minor fix.
[yaz-moved-to-github.git] / rfc1006 / rfct.c
index b857cd2..b79e6a2 100644 (file)
@@ -4,7 +4,31 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rfct.c,v $
- * Revision 1.1  1995-03-30 14:03:17  quinn
+ * Revision 1.9  1996-02-23 10:01:00  quinn
+ * Smallish
+ *
+ * Revision 1.8  1995/11/01  13:54:52  quinn
+ * Minor adjustments
+ *
+ * Revision 1.7  1995/06/16  10:46:48  quinn
+ * *** empty log message ***
+ *
+ * Revision 1.6  1995/06/15  07:45:11  quinn
+ * Moving to v3.
+ *
+ * Revision 1.5  1995/05/31  08:29:35  quinn
+ * Nothing significant.
+ *
+ * Revision 1.4  1995/05/18  13:02:07  quinn
+ * Smallish.
+ *
+ * Revision 1.3  1995/05/16  09:37:18  quinn
+ * Fixed bug
+ *
+ * Revision 1.2  1995/05/02  08:53:09  quinn
+ * Trying in vain to fix comm with ISODE
+ *
+ * Revision 1.1  1995/03/30  14:03:17  quinn
  * Added RFC1006 as separate library
  *
  * Revision 1.15  1995/03/30  10:54:43  quinn
 
 /*
  * Simple implementation of XTI/TP0/RFC1006/Sockets.
- * Note: This is neither complete nor robust. It just has to tick us over
- * until mr. Furniss finishes his own implementation.
+ * Note: There is still some work to do in here, but basically it works.
  *
  * TODO: Asynchronous mode needs a lot of little adjustments to various
- * return values and error codes, etc.
+ * return values and error codes, etc. Formally, we should probably hold
+ * this up against the protocol state tables, and see if it's correct.
  *
  * Check if addressing info is returned correctly by all calls.
  */
 #ifdef __linux__
 #include <linux/limits.h>
 #endif
-#include <dmalloc.h>  /* project memory debugging - delete if you don't have it */
 
 #ifdef TRACE_TRANSPORT
 #define TRC(x) x
@@ -243,18 +266,18 @@ int t_open(char *name, int oflag, struct t_info *info)
        cnt->oci[i] = -1;
 
     /*
-     * RFC1006 sets a higher than standard default max TPDU size, but the
+     * RFC1006 sets a higher than standard (TP) default max TPDU size, but the
      * Isode seems to like to negotiate it down. We'll keep it here to be
-     * safe. Not that there's no harm in jumping it up. If it's higher
+     * safe. Note that there's no harm in jumping it up. If it's higher
      * than 2048, t_connect won't try to negotiate.
      */
-    cnt->tsize = 128;
+    cnt->tsize = 2048;
 
     if (info)
     {
        info->addr = TSEL_MAXLEN + sizeof(struct sockaddr_in) + 1;
        info->options = 1024;
-       info->tsdu = -1;
+       info->tsdu = -1; /* is this right? */
        info->etsdu = 0;
        info->connect = -2;
        info->discon = -2;
@@ -707,6 +730,8 @@ int _t_rcv(int fd, char *buf, unsigned nbytes, int *flags)
     return got;
 }
 
+#if 1
+
 int t_rcv(int fd, char *buf, unsigned nbytes, int *flags)
 {
     int res;
@@ -724,6 +749,8 @@ int t_rcv(int fd, char *buf, unsigned nbytes, int *flags)
     return total;
 }
 
+#endif
+
 int t_close(int fd)
 {
     struct rfct_control *cnt = control[fd];
@@ -771,6 +798,12 @@ static int t_look_wait(int fd, int wait)
        return T_LISTEN; /* the only possible type of event */
     if ((res = read_n(fd, (char*) &head, 6)) < 0)
        return -1;
+    if (res == 0)
+    {
+       TRC(fprintf(stderr, "Network disconnect\n"));
+       return cnt->event = T_DISCONNECT;
+    }
+    TRC(fprintf(stderr, "t_look got %d bytes\n", res));
     if (head.version != RFC_VERSION)
     {
        TRC(fprintf(stderr, "Got bad RFC1006 version in t_look: %d.\n",
@@ -1264,7 +1297,8 @@ int t_listen(int fd, struct t_call *call)
  */
 int t_unbind(int fd)
 {
-    fprintf(stderr, "T_UNBIND [not supported by transport implementation]\n");
+    TRC(fprintf(stderr,
+       "T_UNBIND [not supported by transport implementation]\n"));
     t_errno = TNOTSUPPORT;
     return -1;
 }    
@@ -1356,7 +1390,7 @@ int t_accept(int fd, int resfd, struct t_call *call)
     for (i = 7; i <= 11 && (1 << i) < res->tsize; i++) ; /* encode TPDU size */
     parm[2] = i;
     /* give our TSEL. ## Must we echo theirs, if given? check spec */
-    /* I think it was ok to give an empty TSEL. Does it have semantic sig? */
+    /* I thought it was ok to give an empty TSEL. Does it have semantic sig? */
     parm[3] = TPDU_PARM_CLDID;
     parm[4] = res->ltsel_len; 
     if (res->ltsel_len)