190
FINS/TCP Method Section 7-4
192 }
193
194 printf("FINS/TCP header receive length %d¥n",recvlen);
195 recvlen = fins_tcp_header[6];
196 recvlen <<=8;
197 recvlen += fins_tcp_header[7];
198 recvlen -=
8; /* SUBTRACT LENGTH OF COMMAND & ERROR CODE OF FINS/TCP HEADER*/
199 printf("FINS/TCP frame receive length %d¥n",recvlen);
200 }
201 else
202 {
203 err_exit("TCP receive error");
204 }
205
206 /* RECEIVE FINS RESPONSE FRAME*/
207 if (tcp_recv(sockfd, fins_resp, recvlen) == recvlen)
208 {
209 alarm(0); /*
210 printf("recv length %d¥n",recvlen);
211
212 if (recvlen < 14) /*
213 err_exit("FINS length error");
214 if ((fins_cmnd[3] != fins_resp[6]) || (fins_cmnd[4] != fins_resp[7]) ||
215 (fins_cmnd[5] != fins_resp[8]) )
216 {
217 /*
218 err_exit("illegal source address error");
219 }
220
221 if(fins_cmnd[9] != fins_resp[9]) /* SID CHECK */
222 err_exit("illegal SID error");
223 }
224 else
225 {
226 alarm(0); /*
227 err_exit("receive error");
228 }
229
230
231 /* */
232 close(sockfd);
233
234}
235
236
237/*
238* TCP
239*/
240int tcp_recv(sockfd, buf, len)
241int sockfd;
242unsigned char *buf;
243int len;
244{
STOP RESPONSE MONITOR TIMER*/
ILLEGAL RESPONSE LENGTH CHECK*/
DESTINATION ADDRESS CHECK*/
STOP RESPONSE MONITOR TIMER
CLOSE SOCKET
RECEIVE PROCESSING (RECEIVE REPEATED UP TO THE SPECIFIED NUMBER OF BYTES)