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