jacd: use sendto instead of send

Accordint to the new UAPI version, bind() with PGN set, should not be used
for destination PGN.

This change should work with new and old version of UAPI.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
pull/134/head
Oleksij Rempel 2019-03-13 06:27:50 +01:00 committed by Marc Kleine-Budde
parent 314f8a92ae
commit b8a2fa319a
1 changed files with 9 additions and 1 deletions

10
jacd.c
View File

@ -241,13 +241,21 @@ static int repeat_address(int sock, uint64_t name)
{
int ret;
uint8_t dat[8];
static const struct sockaddr_can saddr = {
.can_family = AF_CAN,
.can_addr.j1939 = {
.pgn = J1939_PGN_ADDRESS_CLAIMED,
.addr = J1939_NO_ADDR,
},
};
memcpy(dat, &name, 8);
if (!host_is_little_endian())
bswap(dat, 8);
if (s.verbose)
fprintf(stderr, "- send(, %" PRId64 ", 8, 0);\n", name);
ret = send(sock, dat, 8, 0);
ret = sendto(sock, dat, sizeof(dat), 0, (const struct sockaddr *)&saddr,
sizeof(saddr));
if (must_warn(ret))
error(1, errno, "send address claim for 0x%02x", s.last_sa);
return ret;