/[pengfork]/pengfork/src/p3/check.c
ViewVC logotype

Diff of /pengfork/src/p3/check.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by chupa, Fri Nov 29 15:17:45 2002 UTC revision 1.14 by chupa, Sun Dec 1 01:19:07 2002 UTC
# Line 36  p3_check_header (header) Line 36  p3_check_header (header)
36  {  {
37    
38    /* Check sequence number */    /* Check sequence number */
39    if ( header->type == TYPE_DATA &&    if (header->type == TYPE_DATA &&
40         (header->seq < PACKET_MIN_SEQ || header->seq > PACKET_MAX_SEQ))        (header->seq < PACKET_MIN_SEQ || header->seq > PACKET_MAX_SEQ))
41      {      {
42        debug (2, "P3 - Bad header received\n");        debug (2, "P3 - Bad header received\n");
43        debug (3,"\tbad sequence: %02x\n", header->seq);        debug (3, "\tbad sequence: %02x\n", header->seq);
44        return 0;        return 0;
45      }      }
46    
# Line 48  p3_check_header (header) Line 48  p3_check_header (header)
48    if (header->ack < PACKET_MIN_SEQ || header->ack > PACKET_MAX_SEQ)    if (header->ack < PACKET_MIN_SEQ || header->ack > PACKET_MAX_SEQ)
49      {      {
50        debug (2, "P3 - Bad header received\n");        debug (2, "P3 - Bad header received\n");
51        debug (3,"\tbad ack: %02x\n", header->ack);        debug (3, "\tbad ack: %02x\n", header->ack);
52        return 0;        return 0;
53      }      }
54    
# Line 57  p3_check_header (header) Line 57  p3_check_header (header)
57        ntohs (header->size) < P3_SIZE_OFFSET)        ntohs (header->size) < P3_SIZE_OFFSET)
58      {      {
59        debug (2, "P3 - Bad header received\n");        debug (2, "P3 - Bad header received\n");
60        debug (3,"\tbad size: %d\n", ntohs (header->size));        debug (3, "\tbad size: %d\n", ntohs (header->size));
61        return 0;        return 0;
62      }      }
63    
# Line 65  p3_check_header (header) Line 65  p3_check_header (header)
65    if (header->type < TYPE_DATA || header->type > TYPE_PING)    if (header->type < TYPE_DATA || header->type > TYPE_PING)
66      {      {
67        debug (2, "P3 - Bad header received\n");        debug (2, "P3 - Bad header received\n");
68        debug (3,"\tbad type: %02x\n", header->type);        debug (3, "\tbad type: %02x\n", header->type);
69        return 0;        return 0;
70      }      }
71    
# Line 86  p3_check_packet (header, data, data_size Line 86  p3_check_packet (header, data, data_size
86    /* Check packet is 0x0d terminated */    /* Check packet is 0x0d terminated */
87    if (p[data_size] != P3_STOP)    if (p[data_size] != P3_STOP)
88      {      {
89        debug (1,"P3 - Bad packet received:\n");        debug (1, "P3 - Bad packet received:\n");
90        debug (1,"\tnot 0x0d terminated\n");        debug (1, "\tnot 0x0d terminated\n");
91        p3_send_nack (header);        p3_send_nack (header);
92        return 0;        return 0;
93      }      }
94    
95    /* Check client bit */    /* Check client bit */
96    if(header->client)    if (header->client)
97      {      {
98        debug (1,"P3 - Bad packet received:\n");        debug (1, "P3 - Bad packet received:\n");
99        debug (1,"\tthis is a client packet!\n");        debug (1, "\tthis is a client packet!\n");
100        p3_send_nack (header);        p3_send_nack (header);
101        return 0;        return 0;
102      }      }
# Line 105  p3_check_packet (header, data, data_size Line 105  p3_check_packet (header, data, data_size
105    crc = htons (p3_crc16 ((char *) &header->size, data_size + 5));    crc = htons (p3_crc16 ((char *) &header->size, data_size + 5));
106    if (crc != header->checksum)    if (crc != header->checksum)
107      {      {
108        debug (1,"P3 - Bad packet received:\n");        debug (1, "P3 - Bad packet received:\n");
109        debug (1,"\tbad CRC checksum\n");        debug (1, "\tbad CRC checksum\n");
110        p3_send_nack (header);        p3_send_nack (header);
111        return 0;        return 0;
112      }      }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26