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