/*====================================================================* * * ether.h - Ethernet definitions and declarations; * * include or exclude various ethernet related definitions based * platform and environment; * *. Qualcomm Atheros HomePlug AV Powerline Toolkit *: Copyright (c) 2009-2013 by Qualcomm Atheros Inc. ALL RIGHTS RESERVED; *; For demonstration and evaluation only; Not for production use. * *--------------------------------------------------------------------*/ #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__) || defined (__NetBSD__) # include # include # include # include # include # include # include # include #elif defined (__FreeBSD__) # include # include # include # include # include # include # include # include #elif defined (WIN32) # if defined (WINPCAP) # include # include # endif # include # include #elif defined (__CYGWIN__) # error "Cygwin in 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; /*====================================================================* * ethertypes; *--------------------------------------------------------------------*/ #define ETH_P_HP10 0x887B #define ETH_P_HCP 0x88B7 #define ETH_P_LLDP 0x88CC #define ETH_P_HPAV 0x88E1 #define ETH_P_1905 0x893A /*====================================================================* * 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