blob: 09c40b4ee09f4b9a9941dd19026d6600e08b33ba [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*************************************************************
2*
3* This Software is the property of VIA Telecom, Inc. and may only be used pursuant to a license from VIA Telecom, Inc.
4*
5* Any unauthorized use inconsistent with the terms of such license is strictly prohibited.
6*
7* Copyright (c) 2002-2010 VIA Telecom, Inc. All rights reserved.
8*
9*************************************************************/
10/*************************************************************************
11 *
12 * File Name: pppapi.h
13 * Project: PPP
14 *
15 * Original Author: Steve Pye
16 * Creation Date:
17 *
18 * Description: Header File for the PPP Application Programming Interface
19 * Restrictions:
20 * Dependencies:
21 *
22 *************************************************************************
23 *
24 * This Software is the property of ISOTEL Research Ltd.
25 * Unauthorized use is prohibited.
26 *
27 * ISOTEL Research Ltd.
28 * Suite 340, 525 - 28th Street S.E.
29 * Calgary, Alberta, Canada T2A 6W9
30 * Tel: (403)275-0041 Fax: (403)274-3598
31 *
32 *
33 *************************************************************************
34 *
35 * RCS Log Information
36 *
37 * removed!
38 *
39 * removed!
40 *
41 * removed!
42 * removed!
43 * removed!
44 *
45 * removed!
46 * removed!
47 * removed!
48 *
49 * removed!
50 * removed!
51 * removed!
52 * removed!
53 * removed!
54 * removed!
55 * removed!
56 * removed!
57 * removed!
58 * removed!
59 * removed!
60 * removed!
61 * removed!
62 * removed!
63 * removed!
64 * removed!
65 * removed!
66 * removed!
67 * removed!
68 * removed!
69 * removed!
70 * removed!
71 * removed!
72 * removed!
73 *
74 * removed!
75 * removed!
76 *
77 * removed!
78 * removed!
79 *
80 * removed!
81 * removed!
82 *
83 * removed!
84 * removed!
85 *
86 * removed!
87 * removed!
88 *
89 * removed!
90 * removed!
91 *
92 * removed!
93 * removed!
94 *
95 * removed!
96 * removed!
97 *
98 * removed!
99 * removed!
100 *
101 * removed!
102 * removed!
103 * removed!
104 * removed!
105 *
106 * removed!
107 * removed!
108 * removed!
109 *
110 * removed!
111 * removed!
112 *
113 * removed!
114 * removed!
115 *
116 * removed!
117 * removed!
118 * removed!
119 *
120 * removed!
121 * removed!
122 *
123 *
124 ************************************************************************/
125
126#ifndef _PPPAPI_H_
127#define _PPPAPI_H_ 1
128
129/* Standard type definitions */
130#include "7074CUST.H"
131#include "IP_PROC.H"
132
133#ifdef SYS_OPTION_DATA_RAM_INUSE
134#define PPP_NPORTS 4
135#else
136#define PPP_NPORTS 1
137#endif
138
139
140#ifdef SYS_OPTION_DATA_RAM_INUSE
141#define PPP_DATASIZE 1500
142#else
143#define PPP_DATASIZE 1
144#endif
145
146/* Macros to store a 16-bit integer LS byte first */
147#if ( HOST_ENDIAN == BIG_ENDIAN )
148#define LSBYTE_FIRST(i) (kal_uint16)( (((kal_uint16)(i) << 8) & 0xff00)| \
149 (((kal_uint16)(i) >> 8) & 0x00ff) \
150 )
151
152#define LSBYTE_FIRST_32(i) (kal_uint32)( (((kal_uint32)(i) << 24) & 0xff000000)| \
153 (((kal_uint32)(i) << 8) & 0x00ff0000)| \
154 (((kal_uint32)(i) >> 8) & 0x0000ff00)| \
155 (((kal_uint32)(i) >> 24) & 0x000000ff) \
156 )
157#else /* HOST_ENDIAN = LITTLE_ENDIAN */
158#define LSBYTE_FIRST(i) (kal_uint16)(i)
159#define LSBYTE_FIRST_32(i) (kal_uint32)(i)
160#endif /* HOST_ENDIAN */
161
162/* IE_xxx Status Codes -- others may be already defined elsewhere! */
163/* #define IE_SUCCESS 0 */ /* Let user_api.h define it. */
164
165#define IE_NOMOREPORTS 100
166#define IE_OPENPORTFAIL 101
167#define IE_INVALIDPPPPORT 102
168#define IE_PORTNOTOPEN 103
169#define IE_INVALIDEVENT 104
170#define IE_INVALIDTIMER 105
171#define IE_INVALID_AUTHPROT 106
172
173#define IE_RESTARTTIMER 110
174#define IE_MAXTERMINATE 111
175#define IE_MAXCONFIGURE 112
176#define IE_MAXFAILURE 113
177#define IE_BUFFERSIZE 114
178#define IE_NUMSLOTS 115
179#define IE_AUTHRETRYTIMER 116
180#define IE_AUTHMAXTRIES 117
181
182#define IE_NORXBUFFER 120
183#define IE_RXBUFFERFULL 121
184#define IE_NORXDATA 122
185#define IE_SENDINPROGRESS 123
186
187/* PPP/LCP Protocol Numbers */
188#define PRO_IP 0x0021 /* Internet Protocol */
189#define PRO_IPV6 0x0057 /* Internet Protocol Version 6 */
190#define PRO_TCPIP_VJ 0x002d /* Van Jacobson Compressed TCP/IP */
191#define PRO_TCPIP_UC 0x002f /* Uncompressed TCP/IP */
192
193#define PRO_IPCP 0x8021 /* NCP: IP Control Protocol */
194#define PRO_IPV6CP 0x8057 /* NCP: IPV6 Control Protocol */
195#define PRO_CCP 0x80fd /* Compression Control Protocol */
196
197#define PRO_LCP 0xc021 /* Link Control Protocol */
198#define PRO_PAP 0xc023 /* Password Authentication */
199#define PRO_LQR 0xc025 /* Link Quality Report */
200#define PRO_CHAP 0xc223 /* Challenge Handshake Authentication */
201#ifdef CBP7_EHRPD
202#define PRO_EAP 0xc227 /* Extensible Authentication Protocol */
203#endif
204
205#define PRO_MNRP 0x4003 /* MNRP CDPD registration protocol */
206#define PRO_VSNCP 0x805b /* Vendor-Specific Net Ctrl Protocol */
207#define PRO_VSNP 0x005b /* Vendor-Specific Network Protocol */
208#define PRO_IPV6 0x0057 /* IPv6 over PPP */
209#define PRO_CDP 0x8207 /* Cisco Discovery Protocol Control */
210
211
212/* PPP Configuration Vector */
213typedef struct config
214{
215 /* PPP-LCP Parameters */
216 kal_uint16 restart; /* restart timer */
217 kal_uint16 mconfigs; /* max LCP Configure-REQ */
218 kal_uint16 mterms; /* max LCP Terminate-REQ */
219 kal_uint16 mfails; /* max LCP Configure-NAK */
220 kal_uint16 termRestart; /* termination timer */
221
222 /* PPP-NCP Parameters */
223 kal_uint16 ncpRestart; /* restart timer */
224 kal_uint16 ncpMconfigs; /* max NCP Configure-REQ */
225 kal_uint16 ncpMterms; /* max NCP Terminate-REQ */
226 kal_uint16 ncpMfails; /* max NCP Configure-NAK */
227 kal_uint16 ncpTermRestart; /* termination timer */
228
229 /* LCP Options */
230 kal_uint32 accm; /* Async Control-Character Map */
231 kal_bool UseQual; /* Use Link Quality Reporting? */
232 kal_bool UseMagic; /* Use Magic-Number? */
233 kal_bool UsePcomp; /* Use Protocol Compression? */
234 kal_bool UseAcomp; /* Use Address/Control Compression? */
235
236 /* Authentication Options */
237 char* userName; /* User Name */
238 char* password; /* PAP:password, CHAP:secret */
239 kal_uint8 lenPassword;
240 kal_uint16 authRetryTimer; /* Auth-Rqst/Challenge retry timer */
241 kal_uint16 authMaxTries; /* Auth-Rqst/Challenge max tries */
242
243 /* LQR Options */
244 kal_uint16 LqrPeriod; /* LQR Reporting Period (sec) */
245
246 /* NCP (IPCP) Options */
247 kal_uint32 LocIPAddr; /* IP Address: Local */
248 kal_uint32 RmtIPAddr; /* IP Address: Remote (peer) */
249 kal_uint32 PriDNSAddr; /* IP Address: Primary DNS Server */
250 kal_uint32 SecDNSAddr; /* IP Address: Secondary DNS Server */
251 kal_bool txUseVJC; /* Van Jacobson Compression (peer) */
252 kal_bool rxUseVJC; /* Van Jacobson Compression */
253 kal_uint8 NumSlots; /* Number of Slots */
254 kal_bool UseScomp; /* Use Slot ID Compression? */
255 kal_bool UseDNSPri; /* Use DNS Primary? */
256 kal_bool UseDNSSec; /* Use DNS Secondary? */
257
258 /* Peer's options available to Network App */
259 kal_uint16 PeerMRU; /* The peer's Maximum Receive Unit */
260} CONFIG;
261
262/* Defaults for Configuration Vector */
263#define DEFL_LOCAL_RM_IP 0x0a000001
264#define DEFL_REMOTE_RM_IP 0x0a000070
265
266
267#ifdef CBP7_EHRPD
268#define DFLT_RESTART_EHRPD 2000
269#endif
270
271#define DFLT_RESTART 3000
272#define DFLT_MCONFIGS 10
273#define DFLT_MFAILS 10
274#define DFLT_MTERMS 2
275#define DFLT_TERM_TMO 3000
276#define DFLT_NCP_RESTART 3000
277#define DFLT_NCP_MCONFIGS 10
278#define DFLT_NCP_MFAILS 10
279#define DFLT_NCP_MTERMS 2
280#define DFLT_NCP_TERM_TMO 3000
281#define DFLT_MCONFIGS_SHORT 3
282
283#define DFLT_ACCM 0xffffffffL
284#define DFLT_USELQR KAL_FALSE
285#define DFLT_LQRPERIOD 120
286#ifdef MTK_PLT_ON_PC_UT
287#define DFLT_USEMAGIC KAL_FALSE
288#else
289#define DFLT_USEMAGIC KAL_TRUE /* for India */
290#endif
291#define DFLT_PCOMP KAL_FALSE
292#define DFLT_ACOMP KAL_FALSE
293
294#define DFLT_AUTH_TIMER 3000
295#define DFLT_AUTH_MAXTRIES 5
296
297#define DFLT_IPADDRESS 0x00000000L
298#define DFLT_NUMSLOTS 16
299#define DFLT_COMPSLOTID KAL_FALSE
300#define DFLT_DNSPRI KAL_TRUE
301#define DFLT_DNSSEC KAL_TRUE
302
303/* Maximum values for Configuration Vector */
304#define MAX_RESTART 10000
305#define MAX_MCONFIGS 20
306#define MAX_MTERMS 5
307#define MAX_MFAILS 20
308
309/* Max/Min values for Configuration Vector */
310#define MAX_NUMSLOTS DFLT_NUMSLOTS
311#define MIN_NUMSLOTS 2
312#if (MAX_NUMSLOTS < MIN_NUMSLOTS)
313#error [pppapi.h] MAX_NUMSLOTS < MIN_NUMSLOTS
314#endif
315
316/* Counter structure used for Link Quality Reporting (LQR) */
317typedef struct lqr_counts
318{
319 kal_uint32 LastOutLQRs;
320 kal_uint32 LastOutPackets;
321 kal_uint32 LastOutOctets;
322 kal_uint32 PeerInLQRs;
323 kal_uint32 PeerInPackets;
324 kal_uint32 PeerInDiscards;
325 kal_uint32 PeerInErrors;
326 kal_uint32 PeerInOctets;
327 kal_uint32 PeerOutLQRs;
328 kal_uint32 PeerOutPackets;
329 kal_uint32 PeerOutOctets;
330
331} LQR_COUNTS;
332
333#define NUM_LQR_COUNTS ( sizeof(LQR_COUNTS) / sizeof(kal_uint32) )
334
335/* LQR counters "logically appended" by PPP to a received LQR packet */
336typedef struct lqr_appends
337{
338 kal_uint32 SaveInLQRs;
339 kal_uint32 SaveInPackets;
340 kal_uint32 SaveInDiscards;
341 kal_uint32 SaveInErrors;
342 kal_uint32 SaveInOctets;
343
344} LQR_APPENDS;
345
346#define NUM_LQR_APPENDS ( sizeof(LQR_APPENDS) / sizeof(kal_uint32) )
347
348/* LQR Rx Packet data format (as delivered by PPP) */
349typedef struct lqr_rxdata
350{
351 /* LQR fields received from the peer */
352 LQR_COUNTS counts;
353
354 /* LQR fields "logically appended" by PPP to received LQR data */
355 LQR_APPENDS appends;
356
357} LQR_RXDATA;
358
359/* PPP Connection Communication Statistics */
360typedef struct ppp_stats
361{
362 kal_uint32 packets_sent;
363 kal_uint32 bytes_sent;
364 kal_uint32 packets_rcvd;
365 kal_uint32 bytes_rcvd;
366 kal_uint32 packets_dropped;
367 kal_uint32 overrun_errors;
368 kal_uint32 recvfcs_errors;
369 kal_uint32 lqrpackets_sent;
370
371} PPP_STATS;
372
373/* LCP Statistics */
374typedef struct lcp_stats
375{
376 kal_uint32 illegal_ups;
377 kal_uint32 illegal_downs;
378
379} LCP_STATS;
380
381/* PPP Event types -> NET */
382enum netEvents
383{
384 PPE_ILLEGAL = 0, /* Illegal Event occurred */
385 PPE_LOOPBACK, /* Connection is looped back to itself */
386
387 PPE_CONNECT_LCP, /* Connect -> Can carry traffic */
388 PPE_CONNECT_IPCP, /* Connect -> Can carry IP traffic */
389 PPE_DISCONNECT, /* Disconnect -> Link Dead */
390
391 PPE_RXDATA, /* Datagram Received */
392 PPE_SENDCOMPLETE, /* Datagram Send Completed */
393
394 /* This one must always be last! */
395 netNUMEVENTS
396};
397
398/* PPP Internal Event types -> Link Manager */
399enum pEvents
400{
401 pNONE = 0, /* Switch-Kicker */
402
403 pUP, /* Up */
404 pDOWN, /* Down */
405 pOPEN, /* Open */
406 pCLOSE, /* Close */
407 pTIMEOUT, /* TO+, TO- */
408
409 pSENDDATA, /* Send Data */
410
411 /* COM Layer -> Link Manager */
412 pCOMUP, /* COM Layer Up */
413 pCOMDOWN, /* COM Layer Down */
414 pRXPACKET, /* Received Raw HDLC Packet */
415 pTXDONE, /* Transmit Complete */
416
417 /* LCP -> Link Manager */
418 pTLU, /* This Layer Up */
419 pTLD, /* This Layer Down */
420
421 /* SYS -> AUTH */
422 pREMOTE_AUTH_TMO, /* Peer: PAP Auth-Request retry or
423 * CHAP Response-Retry timeout */
424 pLOCAL_AUTH_TMO, /* Auth: CHAP Challenge retry timeout */
425
426 /* AUTH -> Link Manager */
427 pAUTH_DONE, /* All Authentication complete */
428
429 /* SYS -> MNRP */
430 pMNRP_TMO, /* MNRP timeout of configuration timer */
431 pMNRP_DONE, /* MNRP finished registration */
432
433#ifdef PPP_RECONNECT
434 pREOPEN, /* ppp Re-Open */
435#endif
436
437 pDORMANT_RECONNECT,
438 /* This one must be last! */
439 pNUMEVENTS
440};
441
442/* NET-to-PPP Function Prototypes */
443kal_uint16 PPP_Initialize(void);
444kal_uint16 PPP_Open (kal_uint8 appType, kal_uint8 *buffer, kal_uint16 buflen, kal_uint16 *port, kal_uint16 authProt, kal_bool mnrp);
445kal_uint16 PPP_GetConfig(kal_uint16 port, CONFIG *r);
446kal_uint16 PPP_SetConfig(kal_uint16 port, CONFIG *r);
447kal_uint16 PPP_Connect(kal_uint16 port);
448kal_uint16 PPP_Send(kal_uint16 port, kal_uint16 prot, kal_uint8 *data, kal_uint16 len, kal_uint8 PdnId);
449kal_uint16 PPP_Receive(kal_uint16 port, kal_uint16 *prot, kal_uint8 **data, kal_uint16 *len,
450 kal_bool copy);
451kal_uint16 PPP_Disconnect(kal_uint16 port);
452kal_uint16 PPP_Close(kal_uint16 port);
453kal_uint16 PPP_Init(kal_uint16 port);
454kal_uint16 PPP_GetStatus(kal_uint16 port, PPP_STATS *status);
455
456#ifdef PPP_RECONNECT
457kal_uint16 PPP_ReConnect(kal_uint16 port);
458#endif
459
460/* PPP-to-PPP Function Prototypes */
461void PPP_Timeout(hlp_timer_enum timer_id);
462kal_uint16 PPP_PostEvent(kal_uint16 port, kal_uint8 type);
463void PPP_SetState(kal_uint16 port, kal_uint8 state);
464
465/* PPP-to-NET Function Prototypes */
466void PPP_SendNetEvent(kal_uint16 port, kal_uint8 type);
467
468/* Interface between Browser and Async for supporting Browser_on_Async mode */
469void Browser_Close_Async(kal_bool graceful);
470
471#endif /* _PPPAPI_H_ */
472