64 |
|
|
65 |
/* Check packet is 0x0d terminated */ |
/* Check packet is 0x0d terminated */ |
66 |
if (p[data_size] != P3_STOP) |
if (p[data_size] != P3_STOP) |
67 |
return 0; |
{ |
68 |
|
debug(1,"P3 - Bad packet received:\n"); |
69 |
|
debug(1,"\tnot 0x0d terminated\n"); |
70 |
|
return 0; |
71 |
|
} |
72 |
|
|
73 |
/* Check CRC */ |
/* Check CRC */ |
74 |
crc = htons (p3_crc16 ((char *) &header->size, data_size + 5)); |
crc = htons (p3_crc16 ((char *) &header->size, data_size + 5)); |
75 |
if (crc != header->checksum) |
if (crc != header->checksum) |
76 |
return 0; |
{ |
77 |
|
debug(1,"P3 - Bad packet received:\n"); |
78 |
|
debug(1,"\tbad CRC checksum\n"); |
79 |
|
return 0; |
80 |
|
} |
81 |
|
|
82 |
/* So it seems to be a valid packet */ |
/* So it seems to be a valid packet */ |
83 |
|
|
89 |
struct p3hdr *header; |
struct p3hdr *header; |
90 |
{ |
{ |
91 |
if (header->type == TYPE_DATA && header->seq != p3_next_seq (srv.lastseq)) |
if (header->type == TYPE_DATA && header->seq != p3_next_seq (srv.lastseq)) |
92 |
/* packet is data and the seq isn't what we are waiting for */ |
{ |
93 |
return 0; |
debug (1, "P3 - Bad ordering for data packet received\n"); |
94 |
if (header->type != TYPE_DATA && header->seq != srv.lastseq) |
debug (1, "\tseq received: %d\n", header->seq); |
95 |
/* packet is not data and the seq has changed */ |
debug (1, "\tseq expected: %d\n", p3_next_seq (srv.lastseq)); |
96 |
return 0; |
/* packet is data and the seq isn't what we expect */ |
97 |
|
return 0; |
98 |
|
} |
99 |
|
/*if (header->type != TYPE_DATA && header->seq != srv.lastseq) |
100 |
|
{ |
101 |
|
debug (1, "P3 - Bad ordering for packet received\n"); |
102 |
|
debug (1, "\tseq received: %d\n", header->seq); |
103 |
|
debug (1, "\tseq expected: %d\n", srv.lastseq); |
104 |
|
/* packet is not data and the seq has changed */ |
105 |
|
/*return 0; |
106 |
|
}*/ |
107 |
|
|
108 |
return 1; |
return 1; |
109 |
} |
} |