Initial import
[sliver-openvswitch.git] / datapath / snap.h
1 #ifndef SNAP_H
2 #define SNAP_H 1
3
4 #include <linux/llc.h>
5
6 #define SNAP_OUI_LEN 3
7
8
9 struct snap_hdr
10 {
11     uint8_t  dsap;  /* Always 0xAA */
12     uint8_t  ssap;  /* Always 0xAA */
13     uint8_t  ctrl;
14     uint8_t  oui[SNAP_OUI_LEN];
15     uint16_t ethertype;
16 } __attribute__ ((packed));
17
18 static inline int snap_get_ethertype(struct sk_buff *skb, uint16_t *ethertype)
19 {
20     struct snap_hdr *sh = (struct snap_hdr *)(skb->data 
21                         + sizeof(struct ethhdr));
22     if (((sh->dsap & 0xFE) != LLC_SAP_SNAP) 
23                 || ((sh->dsap & 0xFE) != LLC_SAP_SNAP)
24                 || (!memcmp(sh->oui, "\0\0\0", SNAP_OUI_LEN)))
25         return -EINVAL;
26
27     *ethertype = sh->ethertype;
28
29     return 0;
30 }
31
32 #endif /* snap.h */