1 /* 2 * Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net> 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef PPPoE__H 7 #define PPPoE__H 8 9 #include <SupportDefs.h> 10 #include <net/if.h> 11 12 #include <ethernet.h> 13 #include <ether_driver.h> 14 #include <net_stack.h> 15 16 class PPPoEDevice; 17 18 #define B_NET_FRAME_TYPE_PPPOE B_NET_FRAME_TYPE(IFT_ETHER, ETHER_TYPE_PPPOE) 19 #define B_NET_FRAME_TYPE_PPPOE_DISCOVERY B_NET_FRAME_TYPE(IFT_ETHER, ETHER_TYPE_PPPOE_DISCOVERY) 20 21 #define PPPoE_QUERY_REPORT_SIZE 2048 22 #define PPPoE_QUERY_REPORT 'PoEQ' 23 // the code value used for query reports 24 25 #define PPPoE_HEADER_SIZE 6 26 // without ethernet header 27 #define PPPoE_TIMEOUT 3000000 28 // 3 seconds 29 #define PPPoE_MAX_ATTEMPTS 2 30 // maximum number of PPPoE's connect-retries 31 32 #define PPPoE_VERSION 0x1 33 #define PPPoE_TYPE 0x1 34 35 #define PPPoE_INTERFACE_KEY "Interface" 36 #define PPPoE_AC_NAME_KEY "ACName" 37 #define PPPoE_SERVICE_NAME_KEY "ServiceName" 38 39 enum pppoe_ops { 40 PPPoE_GET_INTERFACES, 41 PPPoE_QUERY_SERVICES 42 }; 43 44 typedef struct pppoe_query_request { 45 const char *interfaceName; 46 thread_id receiver; 47 } pppoe_query_request; 48 49 extern struct core_module_info *core; 50 51 52 typedef struct pppoe_header { 53 uint8 version : 4; 54 uint8 type : 4; 55 uint8 code; 56 uint16 sessionID; 57 uint16 length; 58 uint8 data[0]; 59 } _PACKED pppoe_header; 60 61 typedef struct complete_pppoe_header { 62 struct ether_header ethernetHeader; 63 pppoe_header pppoeHeader; 64 } complete_pppoe_header; 65 66 67 // defined in pppoe.cpp 68 extern net_device *FindPPPoEInterface(const char *name); 69 extern uint32 NewHostUniq(); 70 extern void add_device(PPPoEDevice *device); 71 extern void remove_device(PPPoEDevice *device); 72 73 #if DEBUG 74 // defined in PPPoEDevice.cpp 75 extern void dump_packet(net_buffer *packet); 76 #endif // DEBUG 77 78 79 #endif 80