Phonet: provide MAC header operations
authorRemi Denis-Courmont <remi.denis-courmont@nokia.com>
Tue, 23 Sep 2008 03:08:04 +0000 (20:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 23 Sep 2008 03:08:04 +0000 (20:08 -0700)
Signed-off-by: RĂ©mi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/if_phonet.h
net/phonet/af_phonet.c

index 22df25fbc4e2fc4b25453a83a21add7d4710518e..7e989216ec17e334922728f32cbab41ac9f38470 100644 (file)
@@ -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
index e6771d3961cf9af2cc55677ca8dab2a79de16cf4..51397ff308bd58d38e3aa1ac812422b86dc17936 100644 (file)
@@ -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.
  */