xref: /haiku/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h (revision 220d04022750f40f8bac8f01fa551211e28d04f2)
1 /*
2  * Copyright 2003-2005, Haiku Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef _PPP_DEFS__H
7 #define _PPP_DEFS__H
8 
9 #include <SupportDefs.h>
10 
11 #include <directories.h>
12 
13 #include "net_module.h"
14 
15 
16 typedef uint32 ppp_interface_id;
17 
18 
19 // settings keys
20 #define PPP_USERNAME_KEY					"Username"
21 #define PPP_PASSWORD_KEY					"Password"
22 #define PPP_ASK_BEFORE_CONNECTING_KEY		"AskBeforeConnecting"
23 #define PPP_DISONNECT_AFTER_IDLE_SINCE_KEY	"DisonnectAfterIdleSince"
24 #define PPP_MODE_KEY						"Mode"
25 #define PPP_CONNECT_RETRIES_LIMIT_KEY		"ConnectRetriesLimit"
26 #define PPP_CONNECT_RETRY_DELAY_KEY			"ConnectRetryDelay"
27 #define PPP_AUTO_RECONNECT_KEY				"AutoReconnect"
28 #define PPP_RECONNECT_DELAY_KEY				"ReconnectDelay"
29 #define PPP_LOAD_MODULE_KEY					"LoadModule"
30 #define PPP_PROTOCOL_KEY					"Protocol"
31 #define PPP_DEVICE_KEY						"Device"
32 #define PPP_AUTHENTICATOR_KEY				"Authenticator"
33 #define PPP_MULTILINK_KEY					"Multilink-Protocol"
34 
35 // settings values
36 #define PPP_CLIENT_MODE_VALUE				"Client"
37 #define PPP_SERVER_MODE_VALUE				"Server"
38 
39 // path defines
40 #define PPP_MODULES_PATH					NETWORK_MODULES_ROOT "ppp"
41 #define PTP_INTERFACE_SETTINGS_PATH	\
42 	kUserSettingsDirectory "/kernel/drivers/ptpnet"
43 		// TODO: should be: /etc/ptpnet
44 #define PTP_SETTINGS_PATH \
45 	kUserSettingsDirectory "/kernel/drivers/ptpnet.settings"
46 		// TODO: should be: /etc/ptpnet.settings
47 
48 // built-in protocols
49 #define PPP_LCP_PROTOCOL					0xC021
50 
51 
52 #define PPP_ERROR_BASE						B_ERRORS_END + 1
53 
54 
55 // this is used when talking to the interface manager
56 enum ppp_interface_filter {
57 	PPP_ALL_INTERFACES,
58 	PPP_REGISTERED_INTERFACES,
59 	PPP_UNREGISTERED_INTERFACES
60 };
61 
62 // return values for Send()/Receive() methods in addition to B_ERROR and B_OK
63 // PPP_UNHANDLED is also used by KPPPOptionHandler
64 enum ppp_return_values {
65 	// B_ERROR means that the packet is corrupted
66 	// B_OK means the packet was handled correctly
67 
68 	// return values for KPPPProtocol
69 	PPP_UNHANDLED = PPP_ERROR_BASE,
70 		// The packet does not belong to this protocol.
71 		// Do not delete the packet when you return this!
72 
73 	// return values of KPPPInterface::Receive()
74 	PPP_DISCARDED,
75 		// packet was silently discarded
76 	PPP_REJECTED,
77 		// a protocol-reject was sent
78 
79 	PPP_NO_CONNECTION
80 		// could not send a packet because device is not connected
81 };
82 
83 //!	PFC options. Should be set by KPPPDevice.
84 enum ppp_pfc_options {
85 	PPP_REQUEST_PFC = 0x01,
86 		//!< Try requesting PFC (does not fail if not successful).
87 	PPP_ALLOW_PFC = 0x02,
88 		//!< Allow PFC if other side requests it.
89 	PPP_FORCE_PFC_REQUEST = 0x04,
90 		//!< If PFC request fails the connection attempt will terminate.
91 	PPP_FREEZE_PFC_OPTIONS = 0x80
92 		//!< Options cannot be changed if this flag is set (mainly used by KPPPDevice).
93 };
94 
95 //!	PFC state constants.
96 enum ppp_pfc_state {
97 	PPP_PFC_DISABLED,
98 		//!< PFC is disabled.
99 	PPP_PFC_ACCEPTED,
100 		//!< PFC was accepted by other side.
101 	PPP_PFC_REJECTED
102 		//!< PFC was rejected by other side. Not used for peer state.
103 };
104 
105 //!	Protocol flags.
106 enum ppp_protocol_flags {
107 	PPP_NO_FLAGS = 0x00,
108 		//!< No flags.
109 	PPP_ALWAYS_ALLOWED = 0x01,
110 		//!< Protocol may send/receive in Phase() >= PPP_ESTABLISHMENT_PHASE.
111 		// But only LCP is allowed in State() != PPP_OPENED_STATE!
112 	PPP_NOT_IMPORTANT = 0x02,
113 		//!< If this protocol fails to go up we do not disconnect.
114 
115 	/*!	\brief This protocol includes the corresponding NCP protocol (e.g.: IPCP + IP).
116 
117 		All protocol values will also be checked against Protocol() & 0x7FFF.
118 	*/
119 	PPP_INCLUDES_NCP = 0x04
120 };
121 
122 // phase when the protocol is brought up
123 enum ppp_phase {
124 	// the following may be used by protocols
125 	PPP_AUTHENTICATION_PHASE = 15,
126 	PPP_NCP_PHASE = 20,
127 	PPP_ESTABLISHED_PHASE = 25,
128 		// only use PPP_ESTABLISHED_PHASE if
129 		// you want to activate this protocol after
130 		// the normal protocols like IP (i.e., IPCP)
131 
132 	// the following must not be used by protocols!
133 	PPP_DOWN_PHASE = 0,
134 	PPP_TERMINATION_PHASE = 1,
135 		// this is the selected phase when we are GOING down
136 	PPP_ESTABLISHMENT_PHASE = 2
137 		// in this phase some protocols (with PPP_ALWAYS_ALLOWED
138 		// flag set) may be used
139 };
140 
141 // this defines the order in which the packets get encapsulated
142 enum ppp_level {
143 	PPP_DEVICE_LEVEL = 0,
144 	PPP_INTERFACE_LEVEL = 1,
145 		// only used by KPPPInterface
146 	PPP_MULTILINK_LEVEL = 2,
147 	PPP_ENCRYPTION_LEVEL = 5,
148 	PPP_COMPRESSION_LEVEL = 10,
149 	PPP_PROTOCOL_LEVEL = 1000
150 		// highest level possible; use for protocols that do not encapsulate
151 };
152 
153 // we can be a ppp client or a ppp server interface
154 enum ppp_mode {
155 	PPP_CLIENT_MODE = 0,
156 	PPP_SERVER_MODE
157 };
158 
159 // which side the protocol works for
160 enum ppp_side {
161 	PPP_NO_SIDE,
162 	PPP_LOCAL_SIDE,
163 	PPP_PEER_SIDE,
164 	PPP_BOTH_SIDES
165 };
166 
167 // authentication status
168 enum ppp_authentication_status {
169 	PPP_AUTHENTICATION_FAILED = -1,
170 	PPP_NOT_AUTHENTICATED = 0,
171 	PPP_AUTHENTICATION_SUCCESSFUL = 1,
172 	PPP_AUTHENTICATING = 0xFF
173 };
174 
175 // PPP states as defined in RFC 1661
176 enum ppp_state {
177 	PPP_INITIAL_STATE,
178 	PPP_STARTING_STATE,
179 	PPP_CLOSED_STATE,
180 	PPP_STOPPED_STATE,
181 	PPP_CLOSING_STATE,
182 	PPP_STOPPING_STATE,
183 	PPP_REQ_SENT_STATE,
184 	PPP_ACK_RCVD_STATE,
185 	PPP_ACK_SENT_STATE,
186 	PPP_OPENED_STATE
187 };
188 
189 #endif
190