Skip to content

Commit

Permalink
Phonet: provide MAC header operations
Browse files Browse the repository at this point in the history
Signed-off-by: Rémi Denis-Courmont <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Remi Denis-Courmont authored and davem330 committed Sep 23, 2008
1 parent 107d0d9 commit 5f77076
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/linux/if_phonet.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
/* 6 bytes header + 65535 bytes payload */
#define PHONET_MAX_MTU 65541
#define PHONET_DEV_MTU PHONET_MAX_MTU

#ifdef __KERNEL__
extern struct header_ops phonet_header_ops;
#endif
29 changes: 29 additions & 0 deletions net/phonet/af_phonet.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,35 @@ static struct net_proto_family phonet_proto_family = {
.owner = THIS_MODULE,
};

/* Phonet device header operations */
static int pn_header_create(struct sk_buff *skb, struct net_device *dev,
unsigned short type, const void *daddr,
const void *saddr, unsigned len)
{
u8 *media = skb_push(skb, 1);

if (type != ETH_P_PHONET)
return -1;

if (!saddr)
saddr = dev->dev_addr;
*media = *(const u8 *)saddr;
return 1;
}

static int pn_header_parse(const struct sk_buff *skb, unsigned char *haddr)
{
const u8 *media = skb_mac_header(skb);
*haddr = *media;
return 1;
}

struct header_ops phonet_header_ops = {
.create = pn_header_create,
.parse = pn_header_parse,
};
EXPORT_SYMBOL(phonet_header_ops);

/*
* Prepends an ISI header and sends a datagram.
*/
Expand Down

0 comments on commit 5f77076

Please sign in to comment.