Search code examples
c++libpcappacket-snifferswifi

Error with attribute in libpcap


I'm using the code from here to for 802.11 sniffing in monitor mode.

#define ETH_HEADER_SIZE 14
#define AVS_HEADER_SIZE 64                 /* AVS capture header size */
#define DATA_80211_FRAME_SIZE 24           /* header for 802.11 data packet */
#define LLC_HEADER_SIZE 8                  /* LLC frame for encapsulation */
/* SNAP LLC header format */
struct snap_header           
{
  u_int8_t dsap; 
  u_int8_t ssap;
  u_int8_t ctl;
  u_int16_t org; 
  u_int8_t org2;
  u_int16_t ether_type;          /* ethernet type */              
} __attribute__ ((__packed_  _));

I'm not quite an expert about c++, and I'm getting this error:

error: expected ‘)’ before ‘_’ warning: ‘__packed_’ attribute  
directive ignored [-Wattributes]  } __attribute__ ((__packed_  _));

Solution

  • The page where you got that code added some bogus spaces to the __attribute__ ((__packed__)) declaration. It should be exactly as I wrote it there, with no spaces between any of the the underscores.