summaryrefslogtreecommitdiff
path: root/kermit.c.diff
blob: ec0121379457d3a170ed76d919376832a841da59 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
*** ../../ek16/kermit.c	2011-03-30 12:40:09.705176000 -0400
--- kermit.c	2011-06-06 16:24:13.034202000 -0400
***************
*** 1,8 ****
  #define KERMIT_C
  /*
    Embedded Kermit protocol module
!   Version: 1.6
!   Most Recent Update: Wed Mar 30 12:39:11 2011
  
    No stdio or other runtime library calls, no system calls, no system 
    includes, no static data, and no global variables in this module.
--- 1,8 ----
  #define KERMIT_C
  /*
    Embedded Kermit protocol module
!   Version: 1.7
!   Most Recent Update: Mon Jun  6 15:36:26 2011
  
    No stdio or other runtime library calls, no system calls, no system 
    includes, no static data, and no global variables in this module.
***************
*** 98,104 ****
  
      int i, j, rc;			/* Workers */
      int datalen;                        /* Length of packet data field */
-     int bctu;				/* Block check type for this packet */
      UCHAR *p;                           /* Pointer to packet data field */
      UCHAR *q;                           /* Pointer to data to be checked */
      UCHAR *s;				/* Worker string pointer */
--- 98,103 ----
***************
*** 313,319 ****
          }
  	debug(DB_MSG,"HDR CHKSUM OK",0,0);
          p[2] = c;                       /* Put checksum back */
!         datalen = xunchar(p[0])*95 + xunchar(p[1]) - k->bct; /* Data length */
          p += 3;                         /* Fix data pointer */
          k->ipktinfo[r_slot].dat = p;	/* Permanent record of data pointer */
      } else {                            /* Regular packet */
--- 312,319 ----
          }
  	debug(DB_MSG,"HDR CHKSUM OK",0,0);
          p[2] = c;                       /* Put checksum back */
! 	/* Data length */
!         datalen = xunchar(p[0])*95 + xunchar(p[1]) - ((k->bctf) ? 3 : k->bct);
          p += 3;                         /* Fix data pointer */
          k->ipktinfo[r_slot].dat = p;	/* Permanent record of data pointer */
      } else {                            /* Regular packet */
***************
*** 323,334 ****
--- 323,342 ----
      }
  #endif /* F_LP */
  #ifdef F_CRC
+     if (k->bctf) {			/* FORCE 3 */
+ 	chklen = 3;
+     } else {
  	if (t == 'S' || k->state == S_INIT) { /* S-packet was retransmitted? */
+ 	    if (q[10] == '5') {		/* Block check type requested is 5 */
+ 		k->bctf = 1;		/* FORCE 3 */
+ 		chklen = 3;
+ 	    }
  	    chklen = 1;			/* Block check is always type 1 */
  	    datalen = k->ipktinfo[r_slot].len - 3; /* Data length */
  	} else {
  	    chklen = k->bct;
  	}
+     }
  #else
      chklen = 1;				/* Block check is always type 1 */
      datalen = k->ipktinfo[r_slot].len - 3; /* Data length */
***************
*** 1031,1036 ****
--- 1039,1045 ----
          if ((k->bct < 1) || (k->bct > 3))
  #endif /* F_CRC */
  	  k->bct = 1;
+ 	if (k->bctf) k->bct = 3;
      }
      if (datalen >= 9) {                 /* Repeat counts */
          if ((s[9] > 32 && s[9] < 63) || (s[9] > 95 && s[9] < 127)) {
***************
*** 1120,1126 ****
        d[ 6] = k->ebq = '&';           /* I need to request it */
      else                                /* else just agree with other Kermit */
        d[ 6] = k->ebq;
!     d[ 7] = k->bct + '0';               /* Block check type */
      d[ 8] = k->rptq;			/* Repeat prefix */
      d[ 9] = tochar(k->capas);           /* Capability bits */
      d[10] = tochar(k->window);          /* Window size */
--- 1129,1138 ----
        d[ 6] = k->ebq = '&';           /* I need to request it */
      else                                /* else just agree with other Kermit */
        d[ 6] = k->ebq;
!     if (k->bctf)			/* Block check type */
!       d[7] = '5';			/* FORCE 3 */
!     else
!       d[7] = k->bct + '0';		/* Normal */
      d[ 8] = k->rptq;			/* Repeat prefix */
      d[ 9] = tochar(k->capas);           /* Capability bits */
      d[10] = tochar(k->window);          /* Window size */
***************
*** 1136,1143 ****
--- 1148,1157 ----
  #endif /* F_LP */
  
  #ifdef F_CRC
+     if (!(k->bctf)) {			/* Unless FORCE 3 */
  	b = k->bct;
  	k->bct = 1;			/* Always use block check type 1 */
+     }
  #endif /* F_CRC */
      switch (type) {
        case 'Y':				/* This is an ACK for packet 0 */
***************
*** 1150,1156 ****
--- 1164,1172 ----
  	rc = -1;
      }
  #ifdef F_CRC
+     if (!(k->bctf)) {			/* Unless FORCE 3 */
  	k->bct = b;
+     }
  #endif /* F_CRC */
      return(rc);                         /* Pass along return code. */
  }
***************
*** 1510,1516 ****
--- 1526,1534 ----
  
  STATIC void
  epkt(char * msg, struct k_data * k) {
+     if (!(k->bctf)) {			/* Unless FORCE 3 */
  	k->bct = 1;
+     }
      (void) spkt('E', 0, -1, (UCHAR *) msg, k);
  }