blob: 5db65b6a96ff423198e34798602f47d2d1de7cf2 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/**************************************************************************
2*
3* Copyright (c) 2012 ZTE Corporation.
4*
5***************************************************************************
6* Ä£ ¿é Ãû : P98C_PPP
7* ÎÄ ¼þ Ãû : ppp_api.h
8* Ïà¹ØÎļþ :
9* ʵÏÖ¹¦ÄÜ : pppÄ£¿é¶ÔÍâÍ·Îļþ
10* ×÷ Õß : zhangpeirong
11* °æ ±¾ : V1.0
12* Íê³ÉÈÕÆÚ : 2012-08-06
13* ÆäËü˵Ã÷ :
14**************************************************************************/
15
16/**************************************************************************
17* Ð޸ļǼ
18**************************************************************************/
19/**************************************************************************
20* Ð޸ıàºÅ : 0001
21* ÐÞ ¸Ä ÈË : zpr
22* ÐÞ¸ÄÈÕÆÚ : 2012-06-20
23* ÐÞ¸ÄÄÚÈÝ : EC:617001563315,PSBUFλÖøüÐÂ
24**************************************************************************/
25#ifndef _PPP_API_H
26#define _PPP_API_H
27
28/**************************************************************************
29* #includeÇø
30**************************************************************************/
31#include "oss_api.h"
32#include "psbuf.h"
33
34
35#ifdef __cplusplus
36extern "C"
37{
38#endif
39
40/**************************************************************************
41* ³£Á¿¶¨ÒåÇø
42**************************************************************************/
43/* zPpp_Ctrl commands */
44#define ZPPP_CTRL_GET_PDP_TYPE 100 /* »ñÈ¡PPPÁ´Â·ÏÖÔÚÖ§³ÖPDP ÀàÐÍ */
45#define ZPPP_CTRL_SET_PDP_TYPE 101 /* ÉèÖÃPPPÁ´Â·ÏÖÔÚÖ§³ÖPDP ÀàÐÍ */
46#define ZPPP_CTRL_GET_MRU 102 /* »ñÈ¡pppÁ´Â·×î´óµÄ½ÓÊÕµ¥Ôª */
47#define ZPPP_CTRL_SET_MRU 103 /* ÉèÖÃpppÁ´Â·×î´óµÄ½ÓÊÕµ¥Ôª */
48#define ZPPP_CTRL_SET_PPPOE_INPUTPACKET_CB 104 /* ÉèÖÃPPPOE»Øµ÷ */
49#define ZPPP_CTRL_SET_ATI_IPADDRS_CB 105 /* ÉèÖõȴýATI·µ»ØIP µØÖ·¼°DNS»Øµ÷ */
50#define ZPPP_CTRL_SET_ATI_NOTREADY 106 /* ÉèÖÃÉèÖÃATI NOTREADY */
51#define ZPPP_CTRL_GET_AUTH_TYPE 107 /* »ñÈ¡PPPÁ´Â·ÏÖÔÚÐè½øÐеÄÈÏÖ¤ÀàÐÍ */
52#define ZPPP_CTRL_SET_AUTH_TYPE 108 /* ÉèÖÃPPPÁ´Â·ÏÖÔÚÐè½øÐеÄÈÏÖ¤ÀàÐÍ */
53
54/* Error codes */
55#define ZPPP_OPEN_SUCC 1 /* MBBÐèÇó£¬ppp ЭÉÌokºóµ½open̬֪ͨ */
56#define ZPPP_ERR_NONE 0 /* No error. */
57#define ZPPP_ERR_PARAM -1 /* Invalid parameter. */
58#define ZPPP_ERR_OPEN -2 /* Unable to open PPP session. */
59#define ZPPP_ERR_DEVICE -3 /* Invalid I/O device for PPP. */
60#define ZPPP_ERR_ALLOC -4 /* Unable to allocate resources. */
61#define ZPPP_ERR_USER -5 /* User interrupt. ´Ëʱ¿Í»§¶ËÏß³ÌÒ²»áÍ˳ö */
62#define ZPPP_ERR_CONNECT -6 /* Connection lost. */
63#define ZPPP_ERR_AUTHFAIL -7 /* Failed authentication challenge. */
64#define ZPPP_ERR_PROTOCOL -8 /* Failed to meet protocol. */
65#define ZPPP_ERR_RECVATEND -9 /* set errocode when receive ATH or +++. */
66#define ZPPP_ERR_EXITPPP -10 /* exit from ppp mode */
67
68/**************************************************************************
69* Êý¾Ý½á¹¹¶¨ÒåÇø
70**************************************************************************/
71typedef struct
72{
73 SSIZE_T addr;
74}T_ZOss_IpAddr;
75
76typedef struct
77{
78 UINT32 addr[4];
79}T_ZOss_IPv6Addr;
80
81typedef enum
82{
83 TCPIP_ADDR_IPV4 = 0,
84 TCPIP_ADDR_IPV6
85}T_ZOss_IPType;
86
87typedef enum
88{
89 ZPPP_PPPOE_DOING, /* ЭÉÌ̬ */
90 ZPPP_PPPOE_SUCCESS, /* ЭÉÌÍê³É */
91 ZPPP_PPPOE_FAIL, /* ЭÉÌʧ°Ü */
92 ZPPP_PPPOE_IPPACKET, /* IP°ü»Ø´« */
93 ZPPP_PPPOE_UNKNOWPACKET_ERROR /* ²»Ê¶±ðµÄ°ü */
94}T_zPpp_PppoeStatus;
95
96typedef enum
97{
98 ZPPP_AUTH_NEED_NULL, /* ²»ÐèÒªÈÏÖ¤ */
99 ZPPP_AUTH_NEED_PAP, /* ÐèÒªPAPÈÏÖ¤ */
100 ZPPP_AUTH_NEED_CHAP /* ÐèÒªCHAPÈÏÖ¤ */
101}T_zPpp_AuthNeed;
102
103typedef enum
104{
105 ZPPP_PDP_ALL_SUPPORT, /* Ö§³ÖIPV4V6 */
106 ZPPP_PDP_IPV4_ONLY, /* ½öÖ§³ÖIPV4 */
107 ZPPP_PDP_IPV6_ONLY /* ½öÖ§³ÖIPV6 */
108}T_zPpp_PdpTypeSupport;
109
110/* PPP´®¿ÚÅäÖÃÏà¹Ø½á¹¹Ìå */
111typedef struct
112{
113 UINT32 sioFd; /* ´®¿Úfd */
114 SINT32 (*sioRead)(UINT32 fd, UINT8 *pBuf, UINT32 length); /* ´®¿Ú¶Áº¯Êý */
115 SINT32 (*sioWrite)(UINT32 fd, UINT8 *pBuf, UINT32 length); /* ´®¿Úдº¯Êý */
116 VOID (*sioReadUnblock)(UINT32 fd); /* ʹ´®¿Ú´Ó×èÈû̬ת»»³É·Ç×èÈû̬ */
117 VOID (*sioReadBlock)(UINT32 fd);
118 VOID (*sioPPPDisconnect)(UINT32 fd);
119 VOID (*sioPPPConnect)(UINT32 fd);
120 T_z_UpLink_Sdu* (*getUpLinkSdu)(VOID);
121 VOID (*freeUpLinkSdu)(T_z_UpLink_Sdu *pSdu);
122 T_z_DownLink_Sdu* (*getDownLinkSdu)(VOID);
123 VOID (*freeDownLinkSdu)(T_z_DownLink_Sdu *pSdu);
124}T_zPpp_Sio;
125
126/* PPP IPCPЭÉÌPCOÏà¹Ø½á¹¹Ìå */
127typedef struct
128{
129 UINT8 pdpType; /* 0x01-PPP * 0x21-IPv4 * 0x57-IPv6 */
130 T_ZOss_IpAddr ourIpAddr;
131 T_ZOss_IpAddr hisIpAddr;
132 T_ZOss_IpAddr snmask; /* ×ÓÍøÑÚÂë */
133 T_ZOss_IpAddr dns1;
134 T_ZOss_IpAddr dns2;
135 T_ZOss_IPv6Addr ipv6Addr; /* ½Ó¿ÚID64λ */
136 T_ZOss_IPv6Addr v6dns1; /* IPv6 DNS server addresses 1 */
137 T_ZOss_IPv6Addr v6dns2; /* IPv6 DNS server addresses 2 */
138}T_zPpp_IpAddrs;
139
140/* PPPÁ´Â·¿ØÖÆÏà¹Ø½á¹¹Ìå */
141typedef struct
142{
143 VOID (*PppLinkCtrl_CB)(UINT32 pppNum, VOID *linkStatusCtx, SINT32 error_code, VOID *arg);
144 VOID (*InputUpLinkData_CB)(UINT32 pppNum, T_z_UpLink_Sdu *ip_packet, SINT32 length, UINT8 channelId);
145 VOID (*InputUpLinkDataV6_CB)(UINT32 pppNum, T_z_UpLink_Sdu *ip_packet, SINT32 length, UINT8 channelId);
146 T_zPpp_IpAddrs *pIpAddrs;
147 UINT8 channelId;
148}T_zPpp_LinkCtrl;
149
150/* ¶¨Òå֪ͨ¹¤¾ß·µ»ØIP°ü»Øµ÷µÄº¯ÊýÀàÐÍ */
151typedef BOOL (*T_zPpp_OutputPacket_CB)(UINT32 pppNum, VOID *pPacket, UINT32 packetSize, UINT8 flag);
152
153/* ¶¨Òå֪ͨATI2¼¤»îpdp»á»° ²¢ÌîдIP DNS»Øµ÷µÄº¯ÊýÀàÐÍ */
154//typedef BOOL (*T_zPpp_GetIpAddrsFromAti2_CB)(UINT32 pppNum, VOID *addr, SINT32 length);
155
156//typedef BOOL (*T_zPpp_GetIpAddrsFromAti_CB)(UINT8 iChnelId, T_ZAti_SmIpDnsInfo *pAddr);
157
158/* ¶¨Òå֪ͨPPPOE·µ»ØLCPºÍNCPЭÉÌÏìÓ¦»Øµ÷µÄº¯ÊýÀàÐÍ */
159typedef SINT32 (*T_zPpp_InputPacketToPppoe_CB)(UINT32 pppNum, VOID *packet, SINT32 packetLen, T_zPpp_PppoeStatus status);
160
161
162/**************************************************************************
163* º¯ÊýÉùÃ÷Çø
164**************************************************************************/
165UINT32 zPpp_Init(VOID);
166UINT32 zPpp_Open(T_zPpp_Sio *pPppSio, T_zPpp_LinkCtrl *pPppCtrl, BOOL isPppoe);
167SINT32 zPpp_PcoAuth_AtRecv(UINT32 dev_fd, const UINT8 *data, UINT16 dataLen, UINT32 extData);
168UINT32 zPpp_Close(UINT32 pppNum);
169UINT32 zPpp_Start(UINT32 pppNum);
170UINT32 zPpp_WriteIp(UINT32 pppNum, const UINT8 *pIpPacket, SINT32 length);
171UINT32 zPpp_InputDataFromPppoe(UINT32 pppNum, T_z_UpLink_Sdu *pDestSduBuffer);
172UINT32 zPpp_Ctrl(UINT32 pppNum, SINT32 cmd, VOID *pArg);
173UINT32 zPpp_RegOutputPppPacketCb(T_zPpp_OutputPacket_CB recvFunc);
174
175/**************************************************************************
176* È«¾Ö±äÁ¿ÉùÃ÷Çø
177**************************************************************************/
178
179#ifdef __cplusplus
180}
181#endif
182
183#endif /* _PPP_API_H */
184