On 4/5/19 11:37 AM, Kurt Van Dijck wrote: > On vr, 05 apr 2019 07:45:05 +0200, Oleksij Rempel wrote: >> Hi Kurt, >> >> On Thu, Apr 04, 2019 at 07:57:46PM +0200, Kurt Van Dijck wrote: >>> On vr, 29 mrt 2019 14:58:43 +0100, Oleksij Rempel wrote: >>>> + if (j1939_pgn_is_valid(jsk->pgn_rx_filter) && >>>> + jsk->pgn_rx_filter != skcb->addr.dst_pgn) >>>> + return false; >>> >>> I must have misunderstood the introduction of pgn_rx_filter. >>> I'd assume that the PGN used during bind() is used for transmission, >>> and the one using connect() is used for reception. >>> Did I swap, or did I get compeletely lost? >> >> Kind of :), both bind() and connect() was setting destination PGN. >> >> With bind() we configure local socket, so default receiver setting should >> be configured: source address, source name and (kind of source) PGN. >> With connect() we configure target settings: dst address, dst name and >> dst PGN. >> >> Since on the wire we have only destination PGN, source PGN can only be >> used for receiver filter. > > So I swapped my interpretation, but the way you explain it makes sense. The PGN from bind() (if given) is used to to filter incoming packets. The PGN from connect() is used as "the" pgn for outgoing packets. Thinking about this again, it _made_ sense to rename addr::pgn to addr::dst_pgn looking at the rx-path only: >>>>> + if (j1939_pgn_is_valid(jsk->pgn_rx_filter) && >>>>> + jsk->pgn_rx_filter != skcb->addr.dst_pgn) >>>>> + return false; But j1939 uses a 3 touple: sa/da/pgn in contrast to tcp/udp, which uses a 4 touple for addressing: src-IP:Port/dest-IP/Port. I think we'll revert the patch. >> I know, on CAN is every thing broadcast and in reality J1939 software in >> many cases will need to be able to receive more then one PGN. So, with >> this change you have a choice to create simple connect()ed peer to peer >> socket and use plain send()/recv(), see jcat in can-utils. Or more >> advanced socket with custom filters. In the last case, it is impossible >> to use send() and recv(). Without connect() you have to use sendto() to set the da and PGN. You can use recv(), but you don't get the addressing information, though. > but use sendto() and recvfrom(), you mean. ACK. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Attachment:
signature.asc
Description: OpenPGP digital signature