3df9750d38
The result of the memcmp that checks whether the OUI is all zeroes was the reverse of what it should have been. This checkin also removes the masking of the least signficant bit from SAP checks, since it's not need for checking SNAP. Thanks to Masa and Brandon for catching this.
33 lines
631 B
C
33 lines
631 B
C
#ifndef SNAP_H
|
|
#define SNAP_H 1
|
|
|
|
#include <linux/llc.h>
|
|
|
|
#define SNAP_OUI_LEN 3
|
|
|
|
|
|
struct snap_hdr
|
|
{
|
|
uint8_t dsap; /* Always 0xAA */
|
|
uint8_t ssap; /* Always 0xAA */
|
|
uint8_t ctrl;
|
|
uint8_t oui[SNAP_OUI_LEN];
|
|
uint16_t ethertype;
|
|
} __attribute__ ((packed));
|
|
|
|
static inline int snap_get_ethertype(struct sk_buff *skb, uint16_t *ethertype)
|
|
{
|
|
struct snap_hdr *sh = (struct snap_hdr *)(skb->data
|
|
+ sizeof(struct ethhdr));
|
|
if ((sh->dsap != LLC_SAP_SNAP)
|
|
|| (sh->ssap != LLC_SAP_SNAP)
|
|
|| (memcmp(sh->oui, "\0\0\0", SNAP_OUI_LEN)))
|
|
return -EINVAL;
|
|
|
|
*ethertype = sh->ethertype;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#endif /* snap.h */
|