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 char   *rawp;
  52 
  53         rawp = skb_push(skb,3);
  54         *rawp++ = dl->type[0];
  55         *rawp++ = dl->type[0];
  56         *rawp = 0x03;   /* UI */
  57         dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len);
  58 }
  59 
  60 static struct packet_type p8022_packet_type = 
  61 {
  62         0,      /* MUTTER ntohs(ETH_P_8022),*/
  63         NULL,           /* All devices */
  64         p8022_rcv,
  65         NULL,
  66         NULL,
  67 };
  68  
  69 
  70 void p8022_proto_init(struct net_proto *pro)
     /* [previous][next][first][last][top][bottom][index][help] */
  71 {
  72         p8022_packet_type.type=htons(ETH_P_802_2);
  73         dev_add_pack(&p8022_packet_type);
  74 }
  75         
  76 struct datalink_proto *
  77 register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *))
     /* [previous][next][first][last][top][bottom][index][help] */
  78 {
  79         struct datalink_proto   *proto;
  80 
  81         if (find_8022_client(type) != NULL)
  82                 return NULL;
  83 
  84         proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
  85         if (proto != NULL) {
  86                 proto->type[0] = type;
  87                 proto->type_len = 1;
  88                 proto->rcvfunc = rcvfunc;
  89                 proto->header_length = 3;
  90                 proto->datalink_header = p8022_datalink_header;
  91                 proto->string_name = "802.2";
  92                 proto->next = p8022_list;
  93                 p8022_list = proto;
  94         }
  95 
  96         return proto;
  97 }
  98 

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