isotp[send|recv]: support PDU sizes greater than 4095
Allow PDU sizes greater than 4095 to be able to check the correct implementation of the kernel socket API error handlings. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>pull/1/head
parent
0c61f2ac4c
commit
2fa9b0005b
|
|
@ -56,6 +56,7 @@
|
|||
#include <linux/can/isotp.h>
|
||||
|
||||
#define NO_CAN_ID 0xFFFFFFFFU
|
||||
#define BUFSIZE 5000 /* size > 4095 to check socket API internal checks */
|
||||
|
||||
void print_usage(char *prg)
|
||||
{
|
||||
|
|
@ -87,7 +88,7 @@ int main(int argc, char **argv)
|
|||
__u32 force_rx_stmin = 0;
|
||||
int loop = 0;
|
||||
|
||||
unsigned char msg[4096];
|
||||
unsigned char msg[BUFSIZE];
|
||||
int nbytes;
|
||||
|
||||
addr.can_addr.tp.tx_id = addr.can_addr.tp.rx_id = NO_CAN_ID;
|
||||
|
|
@ -194,8 +195,8 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
do {
|
||||
nbytes = read(s, msg, 4096);
|
||||
if (nbytes > 0 && nbytes < 4096)
|
||||
nbytes = read(s, msg, BUFSIZE);
|
||||
if (nbytes > 0 && nbytes < BUFSIZE)
|
||||
for (i=0; i < nbytes; i++)
|
||||
printf("%02X ", msg[i]);
|
||||
printf("\n");
|
||||
|
|
|
|||
15
isotpsend.c
15
isotpsend.c
|
|
@ -56,6 +56,7 @@
|
|||
#include <linux/can/isotp.h>
|
||||
|
||||
#define NO_CAN_ID 0xFFFFFFFFU
|
||||
#define BUFSIZE 5000 /* size > 4095 to check socket API internal checks */
|
||||
|
||||
void print_usage(char *prg)
|
||||
{
|
||||
|
|
@ -81,8 +82,9 @@ int main(int argc, char **argv)
|
|||
int opt;
|
||||
extern int optind, opterr, optopt;
|
||||
__u32 force_tx_stmin = 0;
|
||||
unsigned char buf[4096];
|
||||
unsigned char buf[BUFSIZE];
|
||||
int buflen = 0;
|
||||
int retval = 0;
|
||||
|
||||
addr.can_addr.tp.tx_id = addr.can_addr.tp.rx_id = NO_CAN_ID;
|
||||
|
||||
|
|
@ -174,10 +176,17 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
while (buflen < 4096 && scanf("%hhx", &buf[buflen]) == 1)
|
||||
while (buflen < BUFSIZE && scanf("%hhx", &buf[buflen]) == 1)
|
||||
buflen++;
|
||||
|
||||
write(s, buf, buflen);
|
||||
retval = write(s, buf, buflen);
|
||||
if (retval < 0) {
|
||||
perror("write");
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (retval != buflen)
|
||||
fprintf(stderr, "wrote only %d from %d byte\n", retval, buflen);
|
||||
|
||||
/*
|
||||
* due to a Kernel internal wait queue the PDU is sent completely
|
||||
|
|
|
|||
Loading…
Reference in New Issue