ieee802154: introduce wpan_dev_header_ops
The current header_ops callback structure of net device are used mostly from 802.15.4 upper-layers. Because this callback structure is a very generic one, which is also used by e.g. DGRAM AF_PACKET sockets, we can't make this callback structure 802.15.4 specific which is currently is. I saw the smallest "constraint" for calling this callback with dev_hard_header/dev_parse_header by AF_PACKET which assign a 8 byte array for address void pointers. Currently 802.15.4 specific protocols like af802154 and 6LoWPAN will assign the "struct ieee802154_addr" as these parameters which is greater than 8 bytes. The current callback implementation for header_ops.create assumes always a complete "struct ieee802154_addr" which AF_PACKET can't never handled and is greater than 8 bytes. For that reason we introduce now a "generic" create/parse header_ops callback which allows handling with intra-pan extended addresses only. This allows a small use-case with AF_PACKET to send "somehow" a valid dataframe over DGRAM. To keeping the current dev_hard_header behaviour we introduce a similar callback structure "wpan_dev_header_ops" which contains 802.15.4 specific upper-layer header creation functionality, which can be called by wpan_dev_hard_header. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
committed by
Marcel Holtmann
parent
a1da67b811
commit
838b83d63d
@@ -167,6 +167,26 @@ struct wpan_phy {
|
||||
char priv[0] __aligned(NETDEV_ALIGN);
|
||||
};
|
||||
|
||||
struct ieee802154_addr {
|
||||
u8 mode;
|
||||
__le16 pan_id;
|
||||
union {
|
||||
__le16 short_addr;
|
||||
__le64 extended_addr;
|
||||
};
|
||||
};
|
||||
|
||||
struct wpan_dev_header_ops {
|
||||
/* TODO create callback currently assumes ieee802154_mac_cb inside
|
||||
* skb->cb. This should be changed to give these information as
|
||||
* parameter.
|
||||
*/
|
||||
int (*create)(struct sk_buff *skb, struct net_device *dev,
|
||||
const struct ieee802154_addr *daddr,
|
||||
const struct ieee802154_addr *saddr,
|
||||
unsigned int len);
|
||||
};
|
||||
|
||||
struct wpan_dev {
|
||||
struct wpan_phy *wpan_phy;
|
||||
int iftype;
|
||||
@@ -175,6 +195,8 @@ struct wpan_dev {
|
||||
struct list_head list;
|
||||
struct net_device *netdev;
|
||||
|
||||
const struct wpan_dev_header_ops *header_ops;
|
||||
|
||||
/* lowpan interface, set when the wpan_dev belongs to one lowpan_dev */
|
||||
struct net_device *lowpan_dev;
|
||||
|
||||
@@ -205,6 +227,17 @@ struct wpan_dev {
|
||||
|
||||
#define to_phy(_dev) container_of(_dev, struct wpan_phy, dev)
|
||||
|
||||
static inline int
|
||||
wpan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
|
||||
const struct ieee802154_addr *daddr,
|
||||
const struct ieee802154_addr *saddr,
|
||||
unsigned int len)
|
||||
{
|
||||
struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
|
||||
|
||||
return wpan_dev->header_ops->create(skb, dev, daddr, saddr, len);
|
||||
}
|
||||
|
||||
struct wpan_phy *
|
||||
wpan_phy_new(const struct cfg802154_ops *ops, size_t priv_size);
|
||||
static inline void wpan_phy_set_dev(struct wpan_phy *phy, struct device *dev)
|
||||
|
||||
@@ -50,15 +50,6 @@ struct ieee802154_sechdr {
|
||||
};
|
||||
};
|
||||
|
||||
struct ieee802154_addr {
|
||||
u8 mode;
|
||||
__le16 pan_id;
|
||||
union {
|
||||
__le16 short_addr;
|
||||
__le64 extended_addr;
|
||||
};
|
||||
};
|
||||
|
||||
struct ieee802154_hdr_fc {
|
||||
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
||||
u16 type:3,
|
||||
|
||||
Reference in New Issue
Block a user