1 //----------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 // 5 // Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de 6 //----------------------------------------------------------------------- 7 8 #ifndef _PPP_CONTROL__H 9 #define _PPP_CONTROL__H 10 11 #include <Drivers.h> 12 #include <driver_settings.h> 13 #include <PPPDefs.h> 14 15 16 // various constants 17 #define PPP_HANDLER_NAME_LENGTH_LIMIT 63 18 // if the name is longer than this value it will be truncated to fit the structure 19 20 // starting values and other values for control ops 21 #define PPP_RESERVE_OPS_COUNT 0xFFFF 22 #define PPP_OPS_START B_DEVICE_OP_CODES_END + 1 23 #define PPP_INTERFACE_OPS_START PPP_OPS_START + PPP_RESERVE_OPS_COUNT 24 #define PPP_DEVICE_OPS_START PPP_OPS_START + 2 * PPP_RESERVE_OPS_COUNT 25 #define PPP_PROTOCOL_OPS_START PPP_OPS_START + 3 * PPP_RESERVE_OPS_COUNT 26 #define PPP_OPTION_HANDLER_OPS_START PPP_OPS_START + 5 * PPP_RESERVE_OPS_COUNT 27 #define PPP_LCP_EXTENSION_OPS_START PPP_OPS_START + 6 * PPP_RESERVE_OPS_COUNT 28 #define PPP_COMMON_OPS_START PPP_OPS_START + 10 * PPP_RESERVE_OPS_COUNT 29 #define PPP_USER_OPS_START PPP_OPS_START + 32 * PPP_RESERVE_OPS_COUNT 30 31 32 //! These values should be used for ppp_control_info::op. 33 enum ppp_control_ops { 34 // ----------------------------------------------------- 35 // PPPManager (the PPP interface module) 36 PPPC_CONTROL_MODULE = PPP_OPS_START, 37 PPPC_CREATE_INTERFACE, 38 PPPC_CREATE_INTERFACE_WITH_NAME, 39 PPPC_DELETE_INTERFACE, 40 PPPC_BRING_INTERFACE_UP, 41 PPPC_BRING_INTERFACE_DOWN, 42 PPPC_CONTROL_INTERFACE, 43 PPPC_GET_INTERFACES, 44 PPPC_COUNT_INTERFACES, 45 PPPC_FIND_INTERFACE_WITH_SETTINGS, 46 // ----------------------------------------------------- 47 48 // ----------------------------------------------------- 49 // KPPPInterface 50 PPPC_GET_INTERFACE_INFO = PPP_INTERFACE_OPS_START, 51 PPPC_SET_MRU, 52 PPPC_SET_DIAL_ON_DEMAND, 53 PPPC_SET_AUTO_REDIAL, 54 PPPC_HAS_INTERFACE_SETTINGS, 55 PPPC_SET_PROFILE, 56 57 // handler access 58 PPPC_CONTROL_DEVICE = PPP_INTERFACE_OPS_START + 0xFF, 59 PPPC_CONTROL_PROTOCOL, 60 PPPC_CONTROL_OPTION_HANDLER, 61 PPPC_CONTROL_LCP_EXTENSION, 62 PPPC_CONTROL_CHILD, 63 // ----------------------------------------------------- 64 65 // ----------------------------------------------------- 66 // KPPPDevice 67 PPPC_GET_DEVICE_INFO = PPP_DEVICE_OPS_START, 68 // ----------------------------------------------------- 69 70 // ----------------------------------------------------- 71 // KPPPProtocol 72 PPPC_GET_PROTOCOL_INFO = PPP_PROTOCOL_OPS_START, 73 // ----------------------------------------------------- 74 75 // ----------------------------------------------------- 76 // Common/mixed ops 77 PPPC_ENABLE, 78 PPPC_GET_SIMPLE_HANDLER_INFO, 79 // KPPPOptionHandler and KPPPLCPExtension 80 81 // these two control ops use the ppp_report_request structure 82 PPPC_ENABLE_REPORTS, 83 PPPC_DISABLE_REPORTS, 84 // flags are not used for this control op 85 // ----------------------------------------------------- 86 87 PPP_CONTROL_OPS_END = B_DEVICE_OP_CODES_END + 0xFFFF 88 }; 89 90 91 //! Basic structure used for creating and searching PPP interfaces. 92 typedef struct ppp_interface_description_info { 93 union { 94 const driver_settings *settings; 95 //!< Interface settings. 96 const char *name; 97 //!< Name of interface description file. 98 } u; 99 //!< Different values for describing an interface. 100 const driver_settings *profile; 101 //!< An optional profile. If \a profile == NULL the default profile is used. 102 ppp_interface_id interface; 103 //!< The id of the found/created interface. 104 } ppp_interface_description_info; 105 106 107 //! Used to get all interface ids from the PPP interface manager. 108 typedef struct ppp_get_interfaces_info { 109 ppp_interface_id *interfaces; 110 //!< The interface ids will be written to this pointer's target. 111 int32 count; 112 //!< The \a interfaces field has enough space for \a count entries. 113 ppp_interface_filter filter; 114 //!< Only interfaces that match this filter will be returned 115 int32 resultCount; 116 //!< The number of entries that the \a interfaces field contains. 117 } ppp_get_interfaces_info; 118 119 120 //! With this structure you can refer to some handler/interface. 121 typedef struct ppp_control_info { 122 uint32 index; 123 //!< Index/id of interface/protocol/etc. 124 uint32 op; 125 //!< The Control()/ioctl() opcode. This can be any value from ppp_control_ops. 126 void *data; 127 //!< Additional data may be specified here. 128 size_t length; 129 //!< The length should always be set. 130 } ppp_control_info; 131 132 133 // ----------------------------------------------------------- 134 // structures for storing information about interface/handlers 135 // use the xxx_info_t structures when allocating memory (they 136 // reserve memory for future implementations) 137 // ----------------------------------------------------------- 138 #define _PPP_INFO_T_SIZE_ 256 139 140 typedef struct ppp_interface_info { 141 char name[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; 142 int32 if_unit; 143 // negative if not registered 144 145 ppp_mode mode; 146 ppp_state state; 147 ppp_phase phase; 148 ppp_authentication_status localAuthenticationStatus, peerAuthenticationStatus; 149 ppp_pfc_state localPFCState, peerPFCState; 150 uint8 pfcOptions; 151 152 uint32 protocolsCount, optionHandlersCount, LCPExtensionsCount, childrenCount; 153 uint32 MRU, interfaceMTU; 154 155 uint32 dialRetry, dialRetriesLimit; 156 uint32 dialRetryDelay, redialDelay; 157 uint32 idleSince, disconnectAfterIdleSince; 158 159 bool doesDialOnDemand, doesAutoRedial, hasDevice, isMultilink, hasParent; 160 } ppp_interface_info; 161 typedef struct ppp_interface_info_t { 162 ppp_interface_info info; 163 uint8 _reserved_[_PPP_INFO_T_SIZE_ - sizeof(ppp_interface_info)]; 164 } ppp_interface_info_t; 165 166 167 // devices are special handlers, so they have their own structure 168 typedef struct ppp_device_info { 169 char name[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; 170 171 uint32 MTU; 172 uint32 inputTransferRate, outputTransferRate, outputBytesCount; 173 bool isUp; 174 } ppp_device_info; 175 typedef struct ppp_device_info_t { 176 ppp_device_info info; 177 uint8 _reserved_[_PPP_INFO_T_SIZE_ - sizeof(ppp_device_info)]; 178 } ppp_device_info_t; 179 180 181 typedef struct ppp_protocol_info { 182 char name[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; 183 char type[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; 184 185 ppp_phase activationPhase; 186 int32 addressFamily, flags; 187 ppp_side side; 188 ppp_level level; 189 uint32 overhead; 190 191 ppp_phase connectionPhase; 192 // there are four possible states: 193 // PPP_ESTABLISHED_PHASE - IsUp() == true 194 // PPP_DOWN_PHASE - IsDown() == true 195 // PPP_ESTABLISHMENT_PHASE - IsGoingUp() == true 196 // PPP_TERMINATION_PHASE - IsGoingDown() == true 197 198 uint16 protocolNumber; 199 bool isEnabled; 200 bool isUpRequested; 201 } ppp_protocol_info; 202 typedef struct ppp_protocol_info_t { 203 ppp_protocol_info info; 204 uint8 _reserved_[_PPP_INFO_T_SIZE_ - sizeof(ppp_protocol_info)]; 205 } ppp_protocol_info_t; 206 207 208 typedef struct ppp_simple_handler_info { 209 char name[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; 210 211 bool isEnabled; 212 213 uint8 code; 214 // only KPPPLCPExtension 215 } ppp_simple_handler_info; 216 typedef struct ppp_simple_handler_info_t { 217 ppp_simple_handler_info info; 218 uint8 _reserved_[_PPP_INFO_T_SIZE_ - sizeof(ppp_simple_handler_info)]; 219 } ppp_simple_handler_info_t; 220 221 222 #endif 223