root/net/802/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 <net/datalink.h>
   4 #include <linux/mm.h>
   5 #include <linux/in.h>
   6 
   7 static struct datalink_proto *p8022_list = NULL;
   8 
   9 /*
  10  *      We don't handle the loopback SAP stuff, the extended
  11  *      802.2 command set, multicast SAP identifiers and non UI
  12  *      frames. We have the absolute minimum needed for IPX,
  13  *      IP and Appletalk phase 2.
  14  */
  15  
  16 static struct datalink_proto *
  17 find_8022_client(unsigned char type)
     /* [previous][next][first][last][top][bottom][index][help] */
  18 {
  19         struct datalink_proto   *proto;
  20 
  21         for (proto = p8022_list;
  22                 ((proto != NULL) && (*(proto->type) != type));
  23                 proto = proto->next)
  24                 ;
  25 
  26         return proto;
  27 }
  28 
  29 int
  30 p8022_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
     /* [previous][next][first][last][top][bottom][index][help] */
  31 {
  32         struct datalink_proto   *proto;
  33 
  34         proto = find_8022_client(*(skb->h.raw));
  35         if (proto != NULL) {
  36                 skb->h.raw += 3;
  37                 skb_pull(skb,3);
  38                 return proto->rcvfunc(skb, dev, pt);
  39         }
  40 
  41         skb->sk = NULL;
  42         kfree_skb(skb, FREE_READ);
  43         return 0;
  44 }
  45 
  46 static void
  47 p8022_datalink_header(struct datalink_proto *dl, 
     /* [previous][next][first][last][top][bottom][index][help] */
  48                 struct sk_buff *skb, unsigned char *dest_node)
  49 {
  50         struct device   *dev = skb->dev;
  51         unsigned long   len = skb->len;
  52         unsigned long   hard_len = dev->hard_header_len;
  53         unsigned char   *rawp;
  54 
  55         dev->hard_header(skb, dev, len - hard_len,
  56                         dest_node, NULL, len - hard_len);
  57         rawp = skb_push(skb,3);
  58         *rawp = dl->type[0];
  59         rawp++;
  60         *rawp = dl->type[0];
  61         rawp++;
  62         *rawp = 0x03;   /* UI */
  63         rawp++;
  64         skb->h.raw = rawp;
  65 }
  66 
  67 static struct packet_type p8022_packet_type = 
  68 {
  69         0,      /* MUTTER ntohs(ETH_P_IPX),*/
  70         NULL,           /* All devices */
  71         p8022_rcv,
  72         NULL,
  73         NULL,
  74 };
  75  
  76 
  77 void p8022_proto_init(struct net_proto *pro)
     /* [previous][next][first][last][top][bottom][index][help] */
  78 {
  79         p8022_packet_type.type=htons(ETH_P_802_2);
  80         dev_add_pack(&p8022_packet_type);
  81 }
  82         
  83 struct datalink_proto *
  84 register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *))
     /* [previous][next][first][last][top][bottom][index][help] */
  85 {
  86         struct datalink_proto   *proto;
  87 
  88         if (find_8022_client(type) != NULL)
  89                 return NULL;
  90 
  91         proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
  92         if (proto != NULL) {
  93                 proto->type[0] = type;
  94                 proto->type_len = 1;
  95                 proto->rcvfunc = rcvfunc;
  96                 proto->header_length = 3;
  97                 proto->datalink_header = p8022_datalink_header;
  98                 proto->string_name = "802.2";
  99                 proto->next = p8022_list;
 100                 p8022_list = proto;
 101         }
 102 
 103         return proto;
 104 }
 105 

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