blob: e50b2b99d4b450e929688bcd36dd1704f073bbdf [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/**************************************************************************
2*
3* Copyright (c) 2012 ZTE Corporation.
4*
5***************************************************************************
6* Ä£ ¿é Ãû : P98D_PPPOE
7* ÎÄ ¼þ Ãû : pppoe_fnc.h
8* Ïà¹ØÎļþ :
9* ʵÏÖ¹¦ÄÜ : PPPoEÄ£¿é½Ó¿Ú·â×°
10* ×÷ Õß : liuzhengxuan
11* °æ ±¾ : V1.0
12* Íê³ÉÈÕÆÚ : 2012-08-03
13* ÆäËü˵Ã÷ :
14**************************************************************************/
15
16/**************************************************************************
17* Ð޸ļǼ
18**************************************************************************/
19/**************************************************************************
20* Ð޸ıàºÅ : 0001
21* ÐÞ ¸Ä ÈË : liuzhengxuan
22* ÐÞ¸ÄÈÕÆÚ : 2012-06-18
23* ÐÞ¸ÄÄÚÈÝ : EC
24* 1)617001563315 »º´æµÄ¹ÜÀí´Óoss_api.hÎļþÄÚÒÆ³ö£¬·ÅÈëpsbuf.h
25* ÎļþÄÚ
26*
27**************************************************************************/
28#ifndef _PPPOE_FNC_H
29#define _PPPOE_FNC_H
30
31/**************************************************************************
32* #includeÇø
33**************************************************************************/
34#include "oss_api.h"
35#include "oss_ppp.h"
36#include "drvs_serial_device.h"
37#include "zpsi_api.h"
38/* P98D-LZX-0001 2012/06/18 EC:617001563315 »º´æµÄ¹ÜÀí´Óoss_api.hÎļþÄÚÒÆ³ö£¬·ÅÈëpsbuf.hÎļþÄÚ BEGIN */
39#include "psbuf.h"
40/* P98D-LZX-0001 2012/06/18 EC:617001563315 »º´æµÄ¹ÜÀí´Óoss_api.hÎļþÄÚÒÆ³ö£¬·ÅÈëpsbuf.hÎļþÄÚ END */
41
42#ifdef __cplusplus
43extern "C"
44{
45#endif
46
47/**************************************************************************
48* ³£Á¿¶¨ÒåÇø
49**************************************************************************/
50/* PPPoEÖ¡½á¹¹Ì峤¶È */
51#define ZOSS_PPPOE_MAC_SIZE 6
52#define ZOSS_PPPOE_ETHER_FRAMETYPE_SIZE 2
53#define ZOSS_PPPOE_ETHER_FRAMEHEAD_SIZE (ZOSS_PPPOE_MAC_SIZE * 2 + ZOSS_PPPOE_ETHER_FRAMETYPE_SIZE)
54#define ZOSS_PPPOE_ETHER_FRAMEVERIFY_SIZE 0
55
56#define ZOSS_PPPOE_HEAD_SIZE 6 /* ¸ù¾ÝЭÒé: 4λ°æ±¾ + 4λÀàÐÍ + 8λ´úÂë + 16λ»á»°ID + 16볤¶È */
57#define ZOSS_PPPOE_SESSIONID_SIZE 2
58#define ZOSS_PPPOE_PURELOAD_LEN_SIZE 2
59
60#define ZOSS_PPPOE_TAG_TYPE_SIZE 2
61#define ZOSS_PPPOE_TAG_LEN_SIZE 2
62
63#define ZOSS_PPPOE_PPP_PROTOCOL_LEN 2
64#define ZOSS_PPPOE_PPP_VERIFY_LEN 2
65
66/* ·ÃÎʼ¯ÖÐÆ÷µÄÃû×Ö */
67#define ZOSS_PPPOE_ACNAME "ZTE-P98D-LTE"
68
69/* ÒÔϸù¾Ýʵ¼ÊÇé¿ö¶¨Òå */
70#define ZOSS_PPPOE_MAX_BYTE_VALUE 255
71#define ZOSS_PPPOE_MAX_IPDATA_LEN 65535
72#define ZOSS_PPPOE_MAX_PPPOEDATA_LEN (65535 - 6) /* PPPoEÊý¾Ý×î´ó³¤¶ÈµÈÓÚPPP×î´ó³¤¶È¼õÈ¥PPPoEµÄÍ·³¤¶È */
73#define ZOSS_PPPOE_MAX_ACNAME_LEN 20
74#define ZOSS_PPPOE_MAX_SERVICENAME_LEN 20
75#define ZOSS_PPPOE_MAX_RUNTIME_PROPERTY 20
76#define ZOSS_PPPOE_MAX_COMMON_TAG_LEN 250
77#define ZOSS_PPPOE_MAX_TAG_INC_LEN 50
78
79/* PPPoEµÄÖ¡ÀàÐÍ */
80#define PPPOE_ETHER_DISCOVER 0x8863
81#define PPPOE_ETHER_SESSION 0x8864
82
83/**************************************************************************
84* Êý¾Ý½á¹¹¶¨ÒåÇø
85**************************************************************************/
86typedef enum
87{
88 PPPOE_STATE_NULL,
89 PPPOE_STATE_DISCOVERY,
90 PPPOE_STATE_SESSION
91}T_zOss_PPPoEState;
92
93typedef enum
94{
95 PPPOE_PPP_FRAMETYPE_INVLID = 0,
96 PPPOE_PPP_FRAMETYPE_IP = 0x0021,
97 PPPOE_PPP_FRAMETYPE_IPV6 = 0x0057,
98 PPPOE_PPP_FRAMETYPE_LCP = 0xC021,
99 PPPOE_PPP_FRAMETYPE_NCP = 0x8021
100}T_zOss_PPPoEPPPFrameType;
101
102typedef enum
103{
104 PPPOE_TAGTYPE_END_OF_LIST = 0x0000,
105 PPPOE_TAGTYPE_SERVICE_NAME = 0x0101,
106 PPPOE_TAGTYPE_AC_NAME = 0x0102,
107 PPPOE_TAGTYPE_HOST_UNIQ = 0x0103,
108 PPPOE_TAGTYPE_AC_COOKIE = 0x0104,
109 PPPOE_TAGTYPE_VERDOR_SPECOFIC = 0x0105,
110 PPPOE_TAGTYPE_RELAY_SESSION_ID = 0x0110,
111 PPPOE_TAGTYPE_SERVICE_NAME_ERROR = 0x0201,
112 PPPOE_TAGTYPE_AC_SYSTEM_ERROR = 0x0202,
113 PPPOE_TAGTYPE_GENERIC_ERROR = 0x0203
114}T_zOss_PPPoETagType;
115
116typedef enum
117{
118 PPPOE_CODETYPE_PADI = 0x09,
119 PPPOE_CODETYPE_PADO = 0x07,
120 PPPOE_CODETYPE_PADR = 0x19,
121 PPPOE_CODETYPE_PADS = 0x65,
122 PPPOE_CODETYPE_SESSION = 0x00,
123 PPPOE_CODETYPE_PADT = 0xa7,
124 PPPOE_CODETYPE_INVALID = 0xff
125}T_zOss_PPPoEFrameType;
126
127typedef struct
128{
129 UINT8 tagType[ZOSS_PPPOE_TAG_TYPE_SIZE];
130 UINT8 tapLen[ZOSS_PPPOE_TAG_LEN_SIZE];
131}T_zOss_PPPoETagHead;
132
133typedef struct
134{
135 T_zOss_PPPoETagType tagType;
136 UINT16 tagLen;
137 UINT8 *pTagContent;
138}T_zOss_PPPoETag;
139
140typedef enum
141{
142 PPPOE_RST_EXTRMOD_ERR = -3,
143 PPPOE_RST_PARAM_ERR,
144 PPPOE_RST_RUN_ERR,
145 PPPOE_RST_SUCESS,
146 PPPOE_RST_OVER,
147 PPPOP_RST_EXIT,
148 PPPOP_RST_NOTSUPT,
149 PPPOE_RST_TURN
150}T_zOss_PPPoERst;
151
152typedef struct
153{
154 UINT8 atiCh;
155 UINT32 sioFd;
156 BOOL (*GetPdpIpAddr)(VOID *pPppIpAddrs, UINT8 iChnelId);
157 VOID (*upData)(UINT32 pppOprId, T_z_UpLink_Sdu *ipPacket, SINT32 len, UINT8 chID);
158 SINT32 (*sioRead)(UINT32 uiFd, T_ZDrv_BufNode *pBuf);
159 SINT32 (*sioWrite)(UINT32 uiFd, T_ZDrv_BufNode *pBuf);
160 SINT32 (*sio_free_read_buffer)(UINT32 uiFd);
161 SINT32 (*sio_get_write_buffer)(UINT32 uiFd, T_ZDrv_BufNode *pBuf);
162 VOID (*sioReadUnblock)(UINT32 fd);
163 VOID (*sioReadBlock)(UINT32 fd);
164 T_z_UpLink_Sdu* (*getUpLinkSdu)(VOID);
165 VOID (*freeUpLinkSdu)(T_z_UpLink_Sdu *pSdu);
166 T_z_DownLink_Sdu* (*getDownLinkSdu)(VOID);
167 VOID (*freeDownLinkSdu)(T_z_DownLink_Sdu *pSdu);
168 VOID (*free_upLinkSdu)(T_z_DownLink_Sdu *pSdu);
169 VOID (*get_downLinkSdu)(VOID);
170 VOID (*PPPoEStateCB)(UINT32 PPPoE_ID, UINT8 chID, T_zOss_PPPoEState serState, VOID *inputArg);
171}T_ZOss_PPPoESerEnvir;
172
173typedef struct
174{
175 UINT8 clientMAC[ZOSS_PPPOE_MAC_SIZE];
176 T_zOss_PPPoEFrameType lastFrameType;
177 T_zOss_PPPoETag runTimeTag[ZOSS_PPPOE_MAX_RUNTIME_PROPERTY];
178}T_zOss_PPPoERunTime;
179
180typedef struct
181{
182 T_zOss_PPPoEState serState;
183 UINT8 pppId;
184 UINT16 sessonid;
185 T_zOss_PPPoERunTime runTime;
186 T_ZOss_PPPoESerEnvir serEnvir;
187}T_zOss_PPPoEContext;
188
189typedef struct
190{
191 UINT8 acName[ZOSS_PPPOE_MAX_ACNAME_LEN + 1];
192 UINT8 maxPPPoECount;
193 T_zOss_PPPoEContext *pPPPoEContext;
194}T_zOss_PPPoEModContext;
195
196typedef struct
197{
198 UINT8 destMAC[ZOSS_PPPOE_MAC_SIZE];
199 UINT8 srcMAC[ZOSS_PPPOE_MAC_SIZE];
200 UINT16 frameType;
201}T_zOss_PPPoEEtherFrameHead;
202
203typedef struct
204{
205 UINT8 version : 4;
206 UINT8 type : 4;
207 UINT8 code;
208 UINT16 sessionID;
209 UINT16 pureLoadLen;
210}T_zOss_PPPoEFrameHead;
211
212typedef struct
213{
214 UINT8 protocol[ZOSS_PPPOE_PPP_PROTOCOL_LEN];
215 UINT8 *pData;
216 UINT32 dataSize;
217 UINT8 verify[ZOSS_PPPOE_PPP_VERIFY_LEN];
218}T_zOss_PPPoEPPPdata;
219
220typedef struct
221{
222 UINT8 *data;
223 UINT32 dataSize;
224}T_zOss_DataHook;
225
226typedef T_zOss_PPPoERst (*T_zOssPPPoEReceiveTag)(const T_zOss_PPPoETag *pTag, T_zOss_PPPoEContext *pPPPoECtontext);
227
228typedef struct
229{
230 T_zOss_PPPoETagType tagType;
231 T_zOssPPPoEReceiveTag tagHanle;
232}T_zOss_PPPoEReceiveTagMap;
233
234typedef T_zOss_PPPoERst (*T_zOssPPPoERespondTag)(const T_zOss_PPPoETag *pTag,
235 T_zOss_PPPoEContext *pPPPoECtontext,
236 T_zOss_PPPoETag *pResTag);
237
238typedef struct
239{
240 T_zOss_PPPoETagType tagType;
241 T_zOssPPPoERespondTag tagHanle;
242}T_zOss_PPPoERespondTagMap;
243
244/**************************************************************************
245* º¯ÊýÉùÃ÷Çø
246**************************************************************************/
247BOOL zOss_InitPPPoE(UINT8 maxPPPoECount);
248UINT32 zOss_PPPoEInitPPP(VOID);
249UINT32 zOss_OpenPPPoE(T_ZOss_PPPoESerEnvir *PPPoESio);
250T_zOss_PPPoERst zOss_RunPPPoE(UINT32 PPPoE_ID);
251BOOL zOss_WriteDataToPPPoE(UINT32 PPPoE_ID, UINT8 *buff, UINT32 buffSize);
252SINT32 zOss_ClosePPPoE(UINT32 PPPoE_ID);
253T_zOss_PPPoERst zOss_CancelPPPoE(UINT32 PPPoE_ID);
254
255/**************************************************************************
256* È«¾Ö±äÁ¿ÉùÃ÷Çø
257**************************************************************************/
258
259#ifdef __cplusplus
260}
261#endif
262
263#endif /* _PPPOE_FNC_H */
264