1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2025-present Eclipse ThreadX Contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** NetX Component */
/** */
/** PPP Over Ethernet (PPPoE) */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nx_pppoe_client.h PORTABLE C */
/* 6.4.3 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file defines the NetX PPP Over Ethernet (PPPoE) Client */
/* componet, including all data types and external references. It is */
/* assumed that nx_api.h and nx_port.h have already been included. */
/* */
/**************************************************************************/
#ifndef NX_PPPOE_CLIENT_H
#define NX_PPPOE_CLIENT_H
/* Determine if a C++ compiler is being used. If so, ensure that standard
C is used to process the API information. */
#ifdef __cplusplus
/* Yes, C++ compiler is present. Use standard C. */
extern "C" {
#endif
#include "nx_api.h"
/* Note: Prerequisite for using PPPoE.
Redefine NX_PHYSICAL_HEADER to 24 to ensure enough space for filling in physical header.
Physical header:14(Ethernet header) + 6(PPPoE header) + 2(PPP header) + 2(four-byte aligment). */
/* Define the Driver command for PPPoE packet. */
#ifndef NX_LINK_PPPOE_DISCOVERY_SEND
#define NX_LINK_PPPOE_DISCOVERY_SEND 51
#endif
#ifndef NX_LINK_PPPOE_SESSION_SEND
#define NX_LINK_PPPOE_SESSION_SEND 52
#endif
/* Define the PPPoE Client ID. */
#define NX_PPPOE_CLIENT_ID 0x504F4543UL
/* If the driver is not initialized in other module, enable the feature to initialize the driver in PPPoE module . */
/*
#define NX_PPPOE_CLIENT_INITIALIZE_DRIVER_ENABLE
*/
/* Define the PPPoE Thread time slice. */
#ifndef NX_PPPOE_CLIENT_THREAD_TIME_SLICE
#define NX_PPPOE_CLIENT_THREAD_TIME_SLICE TX_NO_TIME_SLICE
#endif
/* Define the init timeout for PADI. */
#ifndef NX_PPPOE_CLIENT_PADI_INIT_TIMEOUT
#define NX_PPPOE_CLIENT_PADI_INIT_TIMEOUT 1
#endif
/* Define the maximum number for PADI. */
#ifndef NX_PPPOE_CLIENT_PADI_COUNT
#define NX_PPPOE_CLIENT_PADI_COUNT 4
#endif
/* Define the init timeout for PADR. */
#ifndef NX_PPPOE_CLIENT_PADR_INIT_TIMEOUT
#define NX_PPPOE_CLIENT_PADR_INIT_TIMEOUT 1
#endif
/* Define the maximum number for PADR. */
#ifndef NX_PPPOE_CLIENT_PADR_COUNT
#define NX_PPPOE_CLIENT_PADR_COUNT 4
#endif
/* Define the size of pppoe AC-Name. */
#ifndef NX_PPPOE_CLIENT_MAX_AC_NAME_SIZE
#define NX_PPPOE_CLIENT_MAX_AC_NAME_SIZE 32
#endif
/* Define the size of pppoe AC-Cookie. */
#ifndef NX_PPPOE_CLIENT_MAX_AC_COOKIE_SIZE
#define NX_PPPOE_CLIENT_MAX_AC_COOKIE_SIZE 32
#endif
/* Define the size of pppoe Relay-Session-Id. */
#ifndef NX_PPPOE_CLIENT_MAX_RELAY_SESSION_ID_SIZE
#define NX_PPPOE_CLIENT_MAX_RELAY_SESSION_ID_SIZE 12
#endif
/* Define the minimum size of packet payload to avoid packet chained. Maximum Payload Size of Ethernet(1500) + Ethernet Header + CRC + Four-byte alignment. */
#ifndef NX_PPPOE_CLIENT_MIN_PACKET_PAYLOAD_SIZE
#define NX_PPPOE_CLIENT_MIN_PACKET_PAYLOAD_SIZE 1520
#endif
/* Define PPPoE ethernet header size. */
#define NX_PPPOE_CLIENT_ETHER_HEADER_SIZE 14
/* Define PPPoE ethernet types. */
#define NX_PPPOE_CLIENT_ETHER_TYPE_DISCOVERY 0x8863
#define NX_PPPOE_CLIENT_ETHER_TYPE_SESSION 0x8864
/* Define PPPoE version and type. */
#define NX_PPPOE_CLIENT_VERSION_TYPE 0x11 /* Version 1, Type 1. */
/* Define PPPoE codes. */
#define NX_PPPOE_CLIENT_CODE_ZERO 0x00
#define NX_PPPOE_CLIENT_CODE_PADI 0x09
#define NX_PPPOE_CLIENT_CODE_PADO 0x07
#define NX_PPPOE_CLIENT_CODE_PADR 0x19
#define NX_PPPOE_CLIENT_CODE_PADS 0x65
#define NX_PPPOE_CLIENT_CODE_PADT 0xa7
/* Define the PPPoE Area Offsets. */
#define NX_PPPOE_CLIENT_OFFSET_VER_TYPE 0 /* 1 byte, version + type: 0x11 */
#define NX_PPPOE_CLIENT_OFFSET_CODE 1 /* 1 byte, code: Discovery or Session */
#define NX_PPPOE_CLIENT_OFFSET_SESSION_ID 2 /* 2 bytes, session id: unique session identifieer */
#define NX_PPPOE_CLIENT_OFFSET_LENGTH 4 /* 2 bytes, length: the length of PPPoE payload */
#define NX_PPPOE_CLIENT_OFFSET_PAYLOAD 6 /* variable, payload */
/* Define the PPPoE Tag Types. */
#define NX_PPPOE_CLIENT_TAG_TYPE_END_OF_LIST 0x0000
#define NX_PPPOE_CLIENT_TAG_TYPE_SERVICE_NAME 0x0101
#define NX_PPPOE_CLIENT_TAG_TYPE_AC_NAME 0x0102
#define NX_PPPOE_CLIENT_TAG_TYPE_HOST_UNIQ 0x0103
#define NX_PPPOE_CLIENT_TAG_TYPE_AC_COOKIE 0x0104
#define NX_PPPOE_CLIENT_TAG_TYPE_VENDOR_SPECIFIC 0x0105
#define NX_PPPOE_CLIENT_TAG_TYPE_RELAY_SESSION_ID 0x0110
#define NX_PPPOE_CLIENT_TAG_TYPE_SERVICE_NAME_ERROR 0x0201
#define NX_PPPOE_CLIENT_TAG_TYPE_AC_SYSTEM_ERROR 0x0202
#define NX_PPPOE_CLIENT_TAG_TYPE_GENERIC_ERROR 0x0203
/* Define the PPPoE Error flags. */
#define NX_PPPOE_CLIENT_ERROR_SERVICE_NAME ((ULONG) 0x00000001) /* Service Name Error. */
#define NX_PPPOE_CLIENT_ERROR_AC_SYSTEM ((ULONG) 0x00000002) /* AC-System Error */
#define NX_PPPOE_CLIENT_ERROR_GENERIC ((ULONG) 0x00000004) /* Generic Error */
/* Define event flags for PPPoE thread control. */
#define NX_PPPOE_CLIENT_ALL_EVENTS ((ULONG) 0xFFFFFFFF) /* All event flags */
#define NX_PPPOE_CLIENT_PACKET_RECEIVE_EVENT ((ULONG) 0x00000001) /* PPPoE Client receive packet event */
#define NX_PPPOE_CLIENT_TIMER_PERIODIC_EVENT ((ULONG) 0x00000002) /* PPPoE CLient timer Periodic event */
#define NX_PPPOE_CLIENT_SESSION_CONNECT_CLEANUP_EVENT ((ULONG) 0x00000004) /* PPPoE Client Session cleanup event */
/* Define PPPoE Client state. */
#define NX_PPPOE_CLIENT_STATE_INITIAL 0
#define NX_PPPOE_CLIENT_STATE_PADI_SENT 1
#define NX_PPPOE_CLIENT_STATE_PADR_SENT 2
#define NX_PPPOE_CLIENT_STATE_ESTABLISHED 3
/* Define error codes from PPPoE Server operation. */
#define NX_PPPOE_CLIENT_SUCCESS 0x00 /* Success */
#define NX_PPPOE_CLIENT_PTR_ERROR 0xD1 /* Invalid input pointers */
#define NX_PPPOE_CLIENT_INVALID_INTERFACE 0xD2 /* Invalid interface */
#define NX_PPPOE_CLIENT_PACKET_PAYLOAD_ERROR 0xD3 /* Invalid payload size of packet */
#define NX_PPPOE_CLIENT_MEMORY_SIZE_ERROR 0xD4 /* Invalid memory size */
#define NX_PPPOE_CLIENT_PRIORITY_ERROR 0xD5 /* Invalid priority */
#define NX_PPPOE_CLIENT_NOT_ENABLED 0xD6 /* PPPoE is not enabled */
#define NX_PPPOE_CLIENT_INVALID_SESSION 0xD7 /* Invalid Session */
#define NX_PPPOE_CLIENT_SESSION_NOT_ESTABLISHED 0xD8 /* PPPoE Session is not established */
#define NX_PPPOE_CLIENT_SERVICE_NAME_ERROR 0xD9 /* Service name error */
#define NX_PPPOE_CLIENT_AC_NAME_ERROR 0xDA /* AC Name error */
#define NX_PPPOE_CLIENT_CLIENT_SESSION_FULL 0xDB /* Client Session full */
#define NX_PPPOE_CLIENT_CLIENT_SESSION_NOT_FOUND 0xDC /* Not found the client session */
#define NX_PPPOE_CLIENT_HOST_UNIQ_CACHE_ERROR 0xDD /* The cache is not enough to record the Host Uniq */
#define NX_PPPOE_CLIENT_RELAY_SESSION_ID_CACHE_ERROR 0xDF /* The cache is not enough to record Relay Session ID*/
/* Define the PPPoE Server Session structure containing the session id and physical address. */
typedef struct NX_PPPOE_SERVER_SESSION_STRUCT
{
USHORT nx_pppoe_session_id;
USHORT reserved;
ULONG nx_pppoe_physical_address_msw;
ULONG nx_pppoe_physical_address_lsw;
} NX_PPPOE_SERVER_SESSION;
/* Define the main PPPoE Server data structure. */
typedef struct NX_PPPOE_CLIENT_STRUCT
{
ULONG nx_pppoe_id;
UCHAR *nx_pppoe_name;
NX_IP *nx_pppoe_ip_ptr;
NX_INTERFACE *nx_pppoe_interface_ptr;
NX_PACKET_POOL *nx_pppoe_packet_pool_ptr;
TX_EVENT_FLAGS_GROUP nx_pppoe_events;
TX_THREAD nx_pppoe_thread;
TX_TIMER nx_pppoe_timer;
NX_PACKET *nx_pppoe_deferred_received_packet_head,
*nx_pppoe_deferred_received_packet_tail;
UINT nx_pppoe_state;
NX_PPPOE_SERVER_SESSION nx_pppoe_server_session;
UCHAR *nx_pppoe_service_name;
UINT nx_pppoe_service_name_length;
UCHAR *nx_pppoe_host_uniq;
UINT nx_pppoe_host_uniq_length;
UCHAR nx_pppoe_ac_name[NX_PPPOE_CLIENT_MAX_AC_NAME_SIZE];
UINT nx_pppoe_ac_name_size;
UCHAR nx_pppoe_ac_cookie[NX_PPPOE_CLIENT_MAX_AC_COOKIE_SIZE];
UINT nx_pppoe_ac_cookie_size;
UCHAR nx_pppoe_relay_session_id[NX_PPPOE_CLIENT_MAX_RELAY_SESSION_ID_SIZE];
UINT nx_pppoe_relay_session_id_size;
UINT nx_pppoe_error_flag;
/* Define the retransmit timeout and count for PADI and PADR. */
UINT nx_pppoe_rtr_timeout;
UINT nx_pppoe_rtr_count;
/* Define the Link Driver entry point. */
VOID (*nx_pppoe_link_driver_entry)(struct NX_IP_DRIVER_STRUCT *);
/* Define the function to receive PPPoE packet. */
VOID (*nx_pppoe_packet_receive)(NX_PACKET *packet_ptr);
/* Define the PPPoE session connect suspension pointer that contains the pointer to the
thread suspended attempting to establish a PPPoE session connection. */
TX_THREAD *nx_pppoe_session_connect_suspended_thread;
} NX_PPPOE_CLIENT;
#ifndef NX_PPPOE_CLIENT_SOURCE_CODE
/* Application caller is present, perform API mapping. */
/* Determine if error checking is desired. If so, map API functions
to the appropriate error checking front-ends. Otherwise, map API
functions to the core functions that actually perform the work.
Note: error checking is enabled by default. */
#ifdef NX_DISABLE_ERROR_CHECKING
/* Services without error checking. */
#define nx_pppoe_client_create _nx_pppoe_client_create
#define nx_pppoe_client_delete _nx_pppoe_client_delete
#define nx_pppoe_client_host_uniq_set _nx_pppoe_client_host_uniq_set
#define nx_pppoe_client_host_uniq_set_extended _nx_pppoe_client_host_uniq_set_extended
#define nx_pppoe_client_service_name_set _nx_pppoe_client_service_name_set
#define nx_pppoe_client_service_name_set_extended _nx_pppoe_client_service_name_set_extended
#define nx_pppoe_client_session_connect _nx_pppoe_client_session_connect
#define nx_pppoe_client_session_packet_send _nx_pppoe_client_session_packet_send
#define nx_pppoe_client_session_terminate _nx_pppoe_client_session_terminate
#define nx_pppoe_client_session_get _nx_pppoe_client_session_get
#else
/* Services with error checking. */
#define nx_pppoe_client_create _nxe_pppoe_client_create
#define nx_pppoe_client_delete _nxe_pppoe_client_delete
#define nx_pppoe_client_host_uniq_set _nxe_pppoe_client_host_uniq_set
#define nx_pppoe_client_host_uniq_set_extended _nxe_pppoe_client_host_uniq_set_extended
#define nx_pppoe_client_service_name_set _nxe_pppoe_client_service_name_set
#define nx_pppoe_client_service_name_set_extended _nxe_pppoe_client_service_name_set_extended
#define nx_pppoe_client_session_connect _nxe_pppoe_client_session_connect
#define nx_pppoe_client_session_packet_send _nxe_pppoe_client_session_packet_send
#define nx_pppoe_client_session_terminate _nxe_pppoe_client_session_terminate
#define nx_pppoe_client_session_get _nxe_pppoe_client_session_get
#endif /* NX_DISABLE_ERROR_CHECKING */
/* Define the prototypes accessible to the application software. */
UINT nx_pppoe_client_create(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *name, NX_IP *ip_ptr, UINT interface_index,
NX_PACKET_POOL *pool_ptr, VOID *stack_ptr, ULONG stack_size, UINT priority,
VOID (*pppoe_link_driver)(struct NX_IP_DRIVER_STRUCT *),
VOID (*pppoe_packet_receive)(NX_PACKET *packet_ptr));
UINT nx_pppoe_client_delete(NX_PPPOE_CLIENT *pppoe_client_ptr);
UINT nx_pppoe_client_host_uniq_set(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *host_uniq);
UINT nx_pppoe_client_host_uniq_set_extended(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *host_uniq, UINT host_uniq_length);
UINT nx_pppoe_client_service_name_set(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *service_name);
UINT nx_pppoe_client_service_name_set_extended(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *service_name, UINT service_name_length);
UINT nx_pppoe_client_session_connect(NX_PPPOE_CLIENT *pppoe_client_ptr, ULONG wait_option);
UINT nx_pppoe_client_session_packet_send(NX_PPPOE_CLIENT *pppoe_client_ptr, NX_PACKET *packet_ptr);
UINT nx_pppoe_client_session_terminate(NX_PPPOE_CLIENT *pppoe_client_ptr);
UINT nx_pppoe_client_session_get(NX_PPPOE_CLIENT *pppoe_client_ptr, ULONG *server_mac_msw, ULONG *server_mac_lsw, ULONG *session_id);
VOID _nx_pppoe_client_packet_deferred_receive(NX_PACKET *packet_ptr);
#else
UINT _nxe_pppoe_client_create(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *name, NX_IP *ip_ptr, UINT interface_index,
NX_PACKET_POOL *pool_ptr, VOID *stack_ptr, ULONG stack_size, UINT priority,
VOID (*pppoe_link_driver)(struct NX_IP_DRIVER_STRUCT *),
VOID (*pppoe_packet_receive)(NX_PACKET *packet_ptr));
UINT _nx_pppoe_client_create(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *name, NX_IP *ip_ptr, UINT interface_index,
NX_PACKET_POOL *pool_ptr, VOID *stack_ptr, ULONG stack_size, UINT priority,
VOID (*pppoe_link_driver)(struct NX_IP_DRIVER_STRUCT *),
VOID (*pppoe_packet_receive)(NX_PACKET *packet_ptr));
UINT _nxe_pppoe_client_delete(NX_PPPOE_CLIENT *pppoe_client_ptr);
UINT _nx_pppoe_client_delete(NX_PPPOE_CLIENT *pppoe_client_ptr);
UINT _nxe_pppoe_client_host_uniq_set(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *host_uniq);
UINT _nx_pppoe_client_host_uniq_set(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *host_uniq);
UINT _nxe_pppoe_client_host_uniq_set_extended(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *host_uniq, UINT host_uniq_length);
UINT _nx_pppoe_client_host_uniq_set_extended(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *host_uniq, UINT host_uniq_length);
UINT _nxe_pppoe_client_service_name_set(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *service_name);
UINT _nx_pppoe_client_service_name_set(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *service_name);
UINT _nxe_pppoe_client_service_name_set_extended(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *service_name, UINT service_name_length);
UINT _nx_pppoe_client_service_name_set_extended(NX_PPPOE_CLIENT *pppoe_client_ptr, UCHAR *service_name, UINT service_name_length);
UINT _nxe_pppoe_client_session_connect(NX_PPPOE_CLIENT *pppoe_client_ptr, ULONG wait_option);
UINT _nx_pppoe_client_session_connect(NX_PPPOE_CLIENT *pppoe_client_ptr, ULONG wait_option);
UINT _nxe_pppoe_client_session_packet_send(NX_PPPOE_CLIENT *pppoe_client_ptr, NX_PACKET *packet_ptr);
UINT _nx_pppoe_client_session_packet_send(NX_PPPOE_CLIENT *pppoe_client_ptr, NX_PACKET *packet_ptr);
UINT _nxe_pppoe_client_session_terminate(NX_PPPOE_CLIENT *pppoe_client_ptr);
UINT _nx_pppoe_client_session_terminate(NX_PPPOE_CLIENT *pppoe_client_ptr);
UINT _nxe_pppoe_client_session_get(NX_PPPOE_CLIENT *pppoe_client_ptr, ULONG *server_mac_msw, ULONG *server_mac_lsw, ULONG *session_id);
UINT _nx_pppoe_client_session_get(NX_PPPOE_CLIENT *pppoe_server_ptr, ULONG *server_mac_msw, ULONG *server_mac_lsw, ULONG *session_id);
VOID _nx_pppoe_client_packet_deferred_receive(NX_PACKET *packet_ptr);
#endif /* NX_PPPOE_CLIENT_SOURCE_CODE */
/* Determine if a C++ compiler is being used. If so, complete the standard
C conditional started above. */
#ifdef __cplusplus
}
#endif
#endif /* NX_PPPOE_CLIENT_H */
|