sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
pppol2tp.h
Go to the documentation of this file.
1
7
8
/*
9
* Redistribution and use in source and binary forms, with or without modification,
10
* are permitted provided that the following conditions are met:
11
*
12
* 1. Redistributions of source code must retain the above copyright notice,
13
* this list of conditions and the following disclaimer.
14
* 2. Redistributions in binary form must reproduce the above copyright notice,
15
* this list of conditions and the following disclaimer in the documentation
16
* and/or other materials provided with the distribution.
17
* 3. The name of the author may not be used to endorse or promote products
18
* derived from this software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
21
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
23
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
25
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
29
* OF SUCH DAMAGE.
30
*
31
* This file is part of the lwIP TCP/IP stack.
32
*
33
*/
34
35
#include "
netif/ppp/ppp_opts.h
"
36
#if PPP_SUPPORT && PPPOL2TP_SUPPORT
/* don't build if not configured for use in lwipopts.h */
37
38
#ifndef PPPOL2TP_H
39
#define PPPOL2TP_H
40
41
#include "
ppp.h
"
42
43
#ifdef __cplusplus
44
extern
"C"
{
45
#endif
46
47
/* Timeout */
48
#define PPPOL2TP_CONTROL_TIMEOUT (5*1000)
/* base for quick timeout calculation */
49
#define PPPOL2TP_SLOW_RETRY (60*1000)
/* persistent retry interval */
50
51
#define PPPOL2TP_MAXSCCRQ 4
/* retry SCCRQ four times (quickly) */
52
#define PPPOL2TP_MAXICRQ 4
/* retry IRCQ four times */
53
#define PPPOL2TP_MAXICCN 4
/* retry ICCN four times */
54
55
/* L2TP header flags */
56
#define PPPOL2TP_HEADERFLAG_CONTROL 0x8000
57
#define PPPOL2TP_HEADERFLAG_LENGTH 0x4000
58
#define PPPOL2TP_HEADERFLAG_SEQUENCE 0x0800
59
#define PPPOL2TP_HEADERFLAG_OFFSET 0x0200
60
#define PPPOL2TP_HEADERFLAG_PRIORITY 0x0100
61
#define PPPOL2TP_HEADERFLAG_VERSION 0x0002
62
63
/* Mandatory bits for control: Control, Length, Sequence, Version 2 */
64
#define PPPOL2TP_HEADERFLAG_CONTROL_MANDATORY (PPPOL2TP_HEADERFLAG_CONTROL|PPPOL2TP_HEADERFLAG_LENGTH|PPPOL2TP_HEADERFLAG_SEQUENCE|PPPOL2TP_HEADERFLAG_VERSION)
65
/* Forbidden bits for control: Offset, Priority */
66
#define PPPOL2TP_HEADERFLAG_CONTROL_FORBIDDEN (PPPOL2TP_HEADERFLAG_OFFSET|PPPOL2TP_HEADERFLAG_PRIORITY)
67
68
/* Mandatory bits for data: Version 2 */
69
#define PPPOL2TP_HEADERFLAG_DATA_MANDATORY (PPPOL2TP_HEADERFLAG_VERSION)
70
71
/* AVP (Attribute Value Pair) header */
72
#define PPPOL2TP_AVPHEADERFLAG_MANDATORY 0x8000
73
#define PPPOL2TP_AVPHEADERFLAG_HIDDEN 0x4000
74
#define PPPOL2TP_AVPHEADERFLAG_LENGTHMASK 0x03ff
75
76
/* -- AVP - Message type */
77
#define PPPOL2TP_AVPTYPE_MESSAGE 0
/* Message type */
78
79
/* Control Connection Management */
80
#define PPPOL2TP_MESSAGETYPE_SCCRQ 1
/* Start Control Connection Request */
81
#define PPPOL2TP_MESSAGETYPE_SCCRP 2
/* Start Control Connection Reply */
82
#define PPPOL2TP_MESSAGETYPE_SCCCN 3
/* Start Control Connection Connected */
83
#define PPPOL2TP_MESSAGETYPE_STOPCCN 4
/* Stop Control Connection Notification */
84
#define PPPOL2TP_MESSAGETYPE_HELLO 6
/* Hello */
85
/* Call Management */
86
#define PPPOL2TP_MESSAGETYPE_OCRQ 7
/* Outgoing Call Request */
87
#define PPPOL2TP_MESSAGETYPE_OCRP 8
/* Outgoing Call Reply */
88
#define PPPOL2TP_MESSAGETYPE_OCCN 9
/* Outgoing Call Connected */
89
#define PPPOL2TP_MESSAGETYPE_ICRQ 10
/* Incoming Call Request */
90
#define PPPOL2TP_MESSAGETYPE_ICRP 11
/* Incoming Call Reply */
91
#define PPPOL2TP_MESSAGETYPE_ICCN 12
/* Incoming Call Connected */
92
#define PPPOL2TP_MESSAGETYPE_CDN 14
/* Call Disconnect Notify */
93
/* Error reporting */
94
#define PPPOL2TP_MESSAGETYPE_WEN 15
/* WAN Error Notify */
95
/* PPP Session Control */
96
#define PPPOL2TP_MESSAGETYPE_SLI 16
/* Set Link Info */
97
98
/* -- AVP - Result code */
99
#define PPPOL2TP_AVPTYPE_RESULTCODE 1
/* Result code */
100
#define PPPOL2TP_RESULTCODE 1
/* General request to clear control connection */
101
102
/* -- AVP - Protocol version (!= L2TP Header version) */
103
#define PPPOL2TP_AVPTYPE_VERSION 2
104
#define PPPOL2TP_VERSION 0x0100
/* L2TP Protocol version 1, revision 0 */
105
106
/* -- AVP - Framing capabilities */
107
#define PPPOL2TP_AVPTYPE_FRAMINGCAPABILITIES 3
/* Bearer capabilities */
108
#define PPPOL2TP_FRAMINGCAPABILITIES 0x00000003
/* Async + Sync framing */
109
110
/* -- AVP - Bearer capabilities */
111
#define PPPOL2TP_AVPTYPE_BEARERCAPABILITIES 4
/* Bearer capabilities */
112
#define PPPOL2TP_BEARERCAPABILITIES 0x00000003
/* Analog + Digital Access */
113
114
/* -- AVP - Tie breaker */
115
#define PPPOL2TP_AVPTYPE_TIEBREAKER 5
116
117
/* -- AVP - Host name */
118
#define PPPOL2TP_AVPTYPE_HOSTNAME 7
/* Host name */
119
#define PPPOL2TP_HOSTNAME "lwIP"
/* FIXME: make it configurable */
120
121
/* -- AVP - Vendor name */
122
#define PPPOL2TP_AVPTYPE_VENDORNAME 8
/* Vendor name */
123
#define PPPOL2TP_VENDORNAME "lwIP"
/* FIXME: make it configurable */
124
125
/* -- AVP - Assign tunnel ID */
126
#define PPPOL2TP_AVPTYPE_TUNNELID 9
/* Assign Tunnel ID */
127
128
/* -- AVP - Receive window size */
129
#define PPPOL2TP_AVPTYPE_RECEIVEWINDOWSIZE 10
/* Receive window size */
130
#define PPPOL2TP_RECEIVEWINDOWSIZE 8
/* FIXME: make it configurable */
131
132
/* -- AVP - Challenge */
133
#define PPPOL2TP_AVPTYPE_CHALLENGE 11
/* Challenge */
134
135
/* -- AVP - Cause code */
136
#define PPPOL2TP_AVPTYPE_CAUSECODE 12
/* Cause code*/
137
138
/* -- AVP - Challenge response */
139
#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE 13
/* Challenge response */
140
#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE_SIZE 16
141
142
/* -- AVP - Assign session ID */
143
#define PPPOL2TP_AVPTYPE_SESSIONID 14
/* Assign Session ID */
144
145
/* -- AVP - Call serial number */
146
#define PPPOL2TP_AVPTYPE_CALLSERIALNUMBER 15
/* Call Serial Number */
147
148
/* -- AVP - Framing type */
149
#define PPPOL2TP_AVPTYPE_FRAMINGTYPE 19
/* Framing Type */
150
#define PPPOL2TP_FRAMINGTYPE 0x00000001
/* Sync framing */
151
152
/* -- AVP - TX Connect Speed */
153
#define PPPOL2TP_AVPTYPE_TXCONNECTSPEED 24
/* TX Connect Speed */
154
#define PPPOL2TP_TXCONNECTSPEED 100000000
/* Connect speed: 100 Mbits/s */
155
156
/* L2TP Session state */
157
#define PPPOL2TP_STATE_INITIAL 0
158
#define PPPOL2TP_STATE_SCCRQ_SENT 1
159
#define PPPOL2TP_STATE_ICRQ_SENT 2
160
#define PPPOL2TP_STATE_ICCN_SENT 3
161
#define PPPOL2TP_STATE_DATA 4
162
163
#define PPPOL2TP_OUTPUT_DATA_HEADER_LEN 6
/* Our data header len */
164
165
/*
166
* PPPoL2TP interface control block.
167
*/
168
typedef
struct
pppol2tp_pcb_s pppol2tp_pcb;
169
struct
pppol2tp_pcb_s {
170
ppp_pcb *ppp;
/* PPP PCB */
171
u8_t phase;
/* L2TP phase */
172
struct
udp_pcb *udp;
/* UDP L2TP Socket */
173
struct
netif *netif;
/* Output interface, used as a default route */
174
ip_addr_t remote_ip;
/* LNS IP Address */
175
u16_t remote_port;
/* LNS port */
176
#if PPPOL2TP_AUTH_SUPPORT
177
const
u8_t *secret;
/* Secret string */
178
u8_t secret_len;
/* Secret string length */
179
u8_t secret_rv[16];
/* Random vector */
180
u8_t challenge_hash[16];
/* Challenge response */
181
u8_t send_challenge;
/* Boolean whether the next sent packet should contains a challenge response */
182
#endif
/* PPPOL2TP_AUTH_SUPPORT */
183
184
u16_t tunnel_port;
/* Tunnel port */
185
u16_t our_ns;
/* NS to peer */
186
u16_t peer_nr;
/* NR from peer */
187
u16_t peer_ns;
/* Expected NS from peer */
188
u16_t source_tunnel_id;
/* Tunnel ID assigned by peer */
189
u16_t remote_tunnel_id;
/* Tunnel ID assigned to peer */
190
u16_t source_session_id;
/* Session ID assigned by peer */
191
u16_t remote_session_id;
/* Session ID assigned to peer */
192
193
u8_t sccrq_retried;
/* number of SCCRQ retries already done */
194
u8_t icrq_retried;
/* number of ICRQ retries already done */
195
u8_t iccn_retried;
/* number of ICCN retries already done */
196
};
197
198
199
/* Create a new L2TP session. */
200
ppp_pcb *pppol2tp_create(
struct
netif
*pppif,
201
struct
netif
*
netif
,
const
ip_addr_t *ipaddr, u16_t port,
202
const
u8_t *secret, u8_t secret_len,
203
ppp_link_status_cb_fn link_status_cb,
void
*ctx_cb);
204
205
#ifdef __cplusplus
206
}
207
#endif
208
209
#endif
/* PPPOL2TP_H */
210
#endif
/* PPP_SUPPORT && PPPOL2TP_SUPPORT */
ppp.h
ppp_opts.h
netif
Definition
tcpip.h:1271
core
ps2ip
include
lwip_include
netif
ppp
pppol2tp.h
Generated by
1.18.0