memcpy (morep->tx_buffer + 16, (void *) &msglen, 2);
VERBOSE (morep, DEBUG, PRINTF ("sent preamble: "); int i; for (i = 0; i < 18; i++) printf ("%02x:", morep->tx_buffer[i]); printf ("\n"));
- int rc = sendto (morep->sock, morep->tx_buffer, len + 18, 0, NULL, 0);
+ int txlen = len + 18;
+ if (txlen < 64) {
+ VERBOSE (morep, DEBUG, PRINTF ("need padding: %d bytes\n", 64 - txlen));
+ memset (morep->tx_buffer + txlen, 0, 64 - txlen);
+ txlen = 64;
+ }
+ int rc = sendto (morep->sock, morep->tx_buffer, txlen, 0, NULL, 0);
return (rc < 18) ? -1 : seqnum;
}
uint16_t msglen = 0;
memcpy ((void *) &msglen, morep->rx_buffer + 16, 2);
morep->rxlen = htons (msglen);
- if (morep->rxlen != len - 18) {
+ if (morep->rxlen < 64 - 18) {
+ VERBOSE (morep, DEBUG, PRINTF ("padding of %d bytes\n", 64 - 18 - morep->rxlen));
+ VERBOSE (morep, DEBUG, int i; for (i = morep->rxlen + 18; i < 64; i++) if (morep->rx_buffer[i] != 0) { VERBOSE (morep, WARNING, PRINTF ("incorrect padding\n")); break; });
+ } else if (morep->rxlen != len - 18) {
VERBOSE (morep, WARNING, PRINTF ("incorrect size (%d/%d)\n", morep->rxlen, len - 18));
morep->rxlen = len - 18;
}
return 0;
}
-/* vi:set tabstop=4 expandtab shiftwidth=4: this line set vi mode*/
+/* vim: set ts=4 sw=4 et: */