root/net/inet/p8022.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. find_8022_client
  2. p8022_rcv
  3. p8022_datalink_header
  4. p8022_proto_init
  5. register_8022_client

   1 #include <linux/netdevice.h>
   2 #include <linux/skbuff.h>
   3 #include "datalink.h"
   4 #include <linux/mm.h>
   5 #include <linux/in.h>
   6 
   7 static struct datalink_proto *p8022_list = NULL;
   8 
   9 static struct datalink_proto *
  10 find_8022_client(unsigned char type)
     /* [previous][next][first][last][top][bottom][index][help] */
  11 {
  12         struct datalink_proto   *proto;
  13 
  14         for (proto = p8022_list;
  15                 ((proto != NULL) && (*(proto->type) != type));
  16                 proto = proto->next)
  17                 ;
  18 
  19         return proto;
  20 }
  21 
  22 int
  23 p8022_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
     /* [previous][next][first][last][top][bottom][index][help] */
  24 {
  25         struct datalink_proto   *proto;
  26 
  27         proto = find_8022_client(*(skb->h.raw));
  28         if (proto != NULL) {
  29                 skb->h.raw += 3;
  30                 return proto->rcvfunc(skb, dev, pt);
  31         }
  32 
  33         skb->sk = NULL;
  34         kfree_skb(skb, FREE_READ);
  35         return 0;
  36 }
  37 
  38 static void
  39 p8022_datalink_header(struct datalink_proto *dl, 
     /* [previous][next][first][last][top][bottom][index][help] */
  40                 struct sk_buff *skb, unsigned char *dest_node)
  41 {
  42         struct device   *dev = skb->dev;
  43         unsigned long   len = skb->len;
  44         unsigned long   hard_len = dev->hard_header_len;
  45         unsigned char   *rawp;
  46 
  47         dev->hard_header(skb->data, dev, len - hard_len,
  48                         dest_node, NULL, len - hard_len, skb);
  49         rawp = skb->data + hard_len;
  50         *rawp = dl->type[0];
  51         rawp++;
  52         *rawp = dl->type[0];
  53         rawp++;
  54         *rawp = 0x03;   /* UI */
  55         rawp++;
  56         skb->h.raw = rawp;
  57 }
  58 
  59 static struct packet_type p8022_packet_type = 
  60 {
  61         0,      /* MUTTER ntohs(ETH_P_IPX),*/
  62         0,              /* copy */
  63         p8022_rcv,
  64         NULL,
  65         NULL,
  66 };
  67  
  68 
  69 void p8022_proto_init(struct net_proto *pro)
     /* [previous][next][first][last][top][bottom][index][help] */
  70 {
  71         p8022_packet_type.type=htons(ETH_P_802_2);
  72         dev_add_pack(&p8022_packet_type);
  73 }
  74         
  75 struct datalink_proto *
  76 register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *))
     /* [previous][next][first][last][top][bottom][index][help] */
  77 {
  78         struct datalink_proto   *proto;
  79 
  80         if (find_8022_client(type) != NULL)
  81                 return NULL;
  82 
  83         proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
  84         if (proto != NULL) {
  85                 proto->type[0] = type;
  86                 proto->type_len = 1;
  87                 proto->rcvfunc = rcvfunc;
  88                 proto->header_length = 3;
  89                 proto->datalink_header = p8022_datalink_header;
  90 
  91                 proto->next = p8022_list;
  92                 p8022_list = proto;
  93         }
  94 
  95         return proto;
  96 }
  97 

/* [previous][next][first][last][top][bottom][index][help] */