/*====================================================================* * * Copyright (c) 2013 Qualcomm Atheros, Inc. * * All rights reserved. * *====================================================================*/ /*====================================================================* * * ether.h - Ethernet definitions and declarations; * * include or exclude various ethernet related definitions based * platform and environment; * *--------------------------------------------------------------------*/ #ifndef ETHER_HEADER #define ETHER_HEADER /*====================================================================* * system header files; *--------------------------------------------------------------------*/ #include #if defined (__linux__) # include # include # include #elif defined (__APPLE__) # include # include # include # include # include # include #elif defined (__OpenBSD__) # include # include # include # include # include # include # include # include #elif defined (WIN32) # if defined (WINPCAP) # include # include # endif # include # include #elif defined (__CYGWIN__) # error "Cygwin is unsupported!" #else # error "Unknown environment!" #endif /*====================================================================* * custom header files; *--------------------------------------------------------------------*/ #include "../tools/types.h" /*====================================================================* * variables; *--------------------------------------------------------------------*/ typedef struct nic { unsigned ifindex; byte ethernet [ETHER_ADDR_LEN]; byte internet [4]; char ifname [IF_NAMESIZE]; char ifdesc [255]; } NIC; /*====================================================================* * channel ethertype definitions; *--------------------------------------------------------------------*/ #if !defined (__linux__) #define ETH_P_802_2 1 #endif #define ETH_P_HP1 0x887B /* HomePlug 1.0 Powerline Networking */ #define ETH_P_HCP 0x88B7 /* IEEE 1901 Hybrid Networking */ #define ETH_P_HPAV 0x88E1 /* HomePlug AV Powerline Networking */ #define ETH_P_1905 0x893A /* IEEE 1905 Home Networking*/ #define ETH_P_LLDP 0x88CC /*====================================================================* * basic 802.2 Ethernet frame structure; *--------------------------------------------------------------------*/ #ifndef __GNUC__ #pragma pack (push, 1) #endif typedef struct ethernet_frame { byte frame_dhost [ETHER_ADDR_LEN]; byte frame_shost [ETHER_ADDR_LEN]; uint16_t frame_type; byte frame_data [ETHERMTU]; } FRAME; #ifndef __GNUC__ #pragma pack (pop) #endif /*====================================================================* * functions; *--------------------------------------------------------------------*/ char * getifname (signed number); signed gethwaddr (void * memory, char const * device); signed anynic (char buffer [], unsigned length); unsigned hostnics (struct nic list [], unsigned size); /*====================================================================* * *--------------------------------------------------------------------*/ #endif