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>
pull/131/head
Oleksij Rempel 2019-03-13 06:27:50 +01:00 committed by Oleksij Rempel
parent 83667e822c
commit a505085b71
1 changed files with 11 additions and 3 deletions

14
jacd.c
View File

@ -195,7 +195,7 @@ static int open_socket(const char *device, uint64_t name)
.can_addr.j1939 = {
.name = name,
.addr = J1939_IDLE_ADDR,
.pgn = 0x0ee00,
.pgn = J1939_NO_PGN,
},
.can_ifindex = if_nametoindex(s.intf),
};
@ -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 = 0x0ee00,
.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;
@ -260,7 +268,7 @@ static int claim_address(int sock, uint64_t name, int sa)
.can_addr.j1939 = {
.name = name,
.addr = sa,
.pgn = 0x0ee00,
.pgn = J1939_NO_PGN,
},
.can_ifindex = if_nametoindex(s.intf),
};