Re: [PATCH 2/7] CAN: Add PF_CAN core module

Oliver Hartkopp
2007-10-02T16:09:40Z

Arnaldo Carvalho de Melo wrote:
> Em Tue, Oct 02, 2007 at 03:10:08PM +0200, Urs Thuermann escreveu:
>
>> +
>> +/**
>> + * struct sockaddr_can - the sockaddr structure for CAN sockets
>> + * @can_family: address family number AF_CAN.
>> + * @can_ifindex: CAN network interface index.
>> + * @can_addr: transport protocol specific address, mostly CAN IDs.
>> + */
>> +struct sockaddr_can {
>> + sa_family_t can_family;
>> + int can_ifindex;
>> + union {
>> + struct { canid_t rx_id, tx_id; } tp16;
>> + struct { canid_t rx_id, tx_id; } tp20;
>> + struct { canid_t rx_id, tx_id; } mcnet;
>> + struct { canid_t rx_id, tx_id; } isotp;
>> + } can_addr;
>>
>
> Again being curious, what is the value of this union of all its members
> have the same definition? Backward source code compatibility?
>
>

Yes. You're right here. It is a prerequisite for a CAN transportprotocol
like the standardized ISO-TP i plan to submit here until december.

Indeed the union should be replaced by something like

struct sockaddr_can {
sa_family_t can_family;
int can_ifindex;
union {
struct { canid_t rx_id, tx_id; } tp;
} can_addr;
};

The union was the idea, if there is any other protocol for CAN that
need's other adressing information. I personally do not know any
protocol. Maybe CANOpen has different addressing requirements here. And
in that case a new protocol could just could add things to the union to
meet it's own needs.

>
> You have been thru many iterations already, sigh, I should have looked
> at this before :-\
>
>

Yeah :-) I thought, you were just done last time.

Btw. Thanks for your review and your good feedback.

Regards,
Oliver