From b8a2fa319a57adc909c4e785e800ff2f4d014807 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Wed, 13 Mar 2019 06:27:50 +0100 Subject: [PATCH] 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 Signed-off-by: Marc Kleine-Budde --- jacd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jacd.c b/jacd.c index aa5898f..0f4d5e5 100644 --- a/jacd.c +++ b/jacd.c @@ -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;