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

Urs Thuermann
2007-10-04T11:55:47Z

Arnaldo Carvalho de Melo <acme@ghostprotocols.net> writes:

> > +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?

As Oliver already wrote, different CAN transport protocols may use
different sockaddr structures. Therefore, we have made can_addr a
union. The four we have defined already, all look the same, but
other, future protocols may define a different structure.

> > +struct can_proto {
> > + int type;
> > + int protocol;
> > + int capability;
> > + struct proto_ops *ops;
> > + struct proto *prot;
> > +};
> > +
> > +/* function prototypes for the CAN networklayer core (af_can.c) */
> > +
> > +extern int can_proto_register(struct can_proto *cp);
> > +extern void can_proto_unregister(struct can_proto *cp);
>
> We have proto registering infrastructure for bluetooth, inet and now
> CAN, have you looked at:
>
> struct inet_protosw;
> proto_{register,unregister}, etc?

Yes, I know inet_protosw and inet_{,un}register_protosw(). But we
can't use inet_register_protosw().

And can_proto_register() does use proto_register(). What exactly do
you want to suggest?

urs