📄 ppp.h
字号:
/****************************************Copyright (c)**************************************************
** 广州周立功单片机发展有限公司
** 研 究 所
** 产品一部
**
** http://www.zlgmcu.com
**
**--------------文件信息--------------------------------------------------------------------------------
**文 件 名: ppp.h
**创 建 人: 陈明计
**最后修改日期: 2004年4月23日
**描 述: PPP协议头文件
**
**--------------历史版本信息----------------------------------------------------------------------------
** 创建人: 陈明计
** 版 本: 0.10b
** 日 期: 2004年4月23日
** 描 述: 原始版本
**
**--------------当前版本修订------------------------------------------------------------------------------
** 修改人:
** 日 期:
** 描 述:
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#define PPP_DRIVER_Q_BUF_LEN 4
#define PPP_DRIVER_BUF_LEN 1508
#define PPP_HARD_LENGTH 5
#define PPP_END_LENGTH 3
#define PPP_INIT_FCS16 0xffff
#define PPP_HARD_FCS16 15843
#define PPP_HARD_CHAR 0x7e
#define PPP_ADDR_CHAR 0xff
#define PPP_CTR_CHAR 0x03
#define PPP_DLE_CHAR 0x7d
#define PPP_DLE_XOR_CHAR 0x20
#define PPP_FRAM_TYPE__IP 0x0021
#define PPP_FRAM_TYPE__IPCP 0x8021
#define PPP_FRAM_TYPE__PAP 0xc023
#define PPP_FRAM_TYPE__LPC 0xC021
/* 定义PPP状态 */
#define MAX_PPP_STATE 0x0a /* 状态数 */
#define PPP_STATE_INITIAL 0x00 /* DEAD(初始化的) */
#define PPP_STATE_STARTING 0x01 /* DEAD(初始化的) */
#define PPP_STATE_CLOSED 0x02 /* DEAD(运行时的) */
#define PPP_STATE_STOPED 0x03 /* TERMINATE */
#define PPP_STATE_CLOSING 0x04 /* TERMINATE */
#define PPP_STATE_STOPPING 0x05 /* TERMINATE */
#define PPP_STATE_REQ_SENT 0x06 /* ESTABLISH */
#define PPP_STATE_ACK_REVD 0x07 /* ESTABLISH */
#define PPP_STATE_ACK_SEND 0x08 /* ESTABLISH */
#define PPP_STATE_OPEN 0x09
#define PPP_STATE_ERR 0xff
/* 定义PPP事件 */
#define MAX_PPP_EVENT 0x11 /* 事件数 */
#define PPP_EVENT_LOWER_UP 0x00 /* lower layer is Up */
#define PPP_EVENT_LOWER_DOWN 0x01 /* lower layer is Down */
#define PPP_EVENT_OPEN 0x02 /* administrative Open */
#define PPP_EVENT_CLOSE 0x03 /* administrative Close */
#define PPP_EVENT_TO_R 0x04 /* Timeout with counter > 0 */
#define PPP_EVENT_TO_E 0x05 /* Timeout with counter expired */
#define PPP_EVENT_RCR_GOOD 0x06 /* Receive-Configure-Request (Good) */
#define PPP_EVENT_RCR_BAD 0x07 /* Receive-Configure-Request (Bad) */
#define PPP_EVENT_RCA 0x08 /* Receive-Configure-Ack */
#define PPP_EVENT_RCN 0x09 /* Receive-Configure-Nak/Rej */
#define PPP_EVENT_RTR 0x0a /* Receive-Terminate-Request */
#define PPP_EVENT_RTA 0x0b /* Receive-Terminate-Ack */
#define PPP_EVENT_RUC 0x0c /* Receive-Unknown-Code */
#define PPP_EVENT_RXJ_p 0x0d /* Receive-Code-Reject (permitted) or Receive-Protocol-Reject */
#define PPP_EVENT_RXJ_C 0x0e /* Receive-Code-Reject (catastrophic) or Receive-Protocol-Reject */
#define PPP_EVENT_RXR 0x0f /* Receive-Echo-Request or Receive-Echo-Reply or Receive-Discard-Request */
#define PPP_EVENT_UP_LAYER 0x10 /* Receive-Echo-Request or Receive-Echo-Reply or Receive-Discard-Request */
#define PPP_EVENT_NONE 0xff /* 无事件 */
#ifdef IN_PPP
#define MAX_PPP_ACTIONS 0x1b /* 最大动作数 */
#define tlu 0x00 /* This-Layer-Up */
#define tld 0x01 /* This-Layer-Down */
#define tls 0x02 /* This-Layer-Started */
#define tlf 0x03 /* This-Layer-Finished */
#define irc 0x04 /* Initialize-Restart-Count */
#define zrc 0x05 /* Zero-Restart-Count */
#define scr 0x06 /* Send-Configure-Requestp */
#define sca 0x07 /* TSend-Configure-Ack */
#define scn 0x08 /* Send-Terminate-Request */
#define str 0x09 /* Send-Terminate-Request */
#define sta 0x0a /* Send-Terminate-Ack */
#define scj 0x0b /* Send-Code-Reject */
#define ser 0x0c /* Send-Echo-Reply */
#define irc_scr 0x0d /* irc + scr */
#define irc_scr_sca 0x0e /* irc + scr + sca */
#define irc_scr_scn 0x0f /* irc + scr + sca */
#define irc_str 0x10 /* irc + str */
#define irc_sca 0x11 /* irc + sca */
#define sca_tlu 0x12 /* sca + tlu */
#define irc_tlu 0x13 /* irc + tlu */
#define tld_irc_str 0x14 /* tld + irc + str */
#define tld_scr_sca 0x15 /* tld + irc + str */
#define tld_scr_scn 0x16 /* tld + irc + stn */
#define tld_scr 0x17 /* tld + scr */
#define tld_zrc_sta 0x18 /* tld + zrc + sta */
#define Uplayer 0x19 /* 高层协议处理 */
#define reset 0x1a /* 重起选项 */
#define none 0xff /* 无动作 */
#endif
typedef struct _PPP_DATA
{
OS_EVENT *Event; /* 消息队列 */
void *QBuf[PPP_DRIVER_Q_BUF_LEN]; /* 消息队列空间 */
NetHardDrivesSocket *HardDrive; /* 下一级驱动 */
uint32 OverTime; /* RestartTimer溢出时间 */
uint8 Buf[4][PPP_DRIVER_BUF_LEN]; /* 接收缓冲 */
uint16 MaxTerminate; /* RestartTimer的MaxTerminate配置值 */
uint16 MaxConfigure; /* RestartTimer的MaxConfigure配置值 */
uint16 MaxFailure; /* RestartTimer的MaxFailure配置值 */
uint16 DelayTime; /* RestartTimer等待时间 */
int8 OverTimeSum; /* RestartTimer溢出次数 */
uint8 State; /* PPP状态 */
uint8 FramID;
}PppData;
#ifndef IN_PPP
//extern uint8 *PPPReviceGetBuf(PppData *ThisPPP);
extern void PPPDriverInit(void);
/*********************************************************************************************************
** 函数名称: PPPDriverInit()
** 功能描述: PPP驱动接收初始化
** 输 入: 无
** 输 出: 无
********************************************************************************************************/
extern uint8 PPPDriveWrite(NetHardDrivesSocket *HardDrive, uint8 *Buf, uint16 Nbyte);
/*********************************************************************************************************
** 函数名称: PPPDriveWrite()
** 功能描述: 使用PPP协议发送一个数据包,调用此函数前必须调用PPPDriveGetSendBuf获取数据缓冲
** 输 入: HardDrive :发送的硬件驱动
** Buf :指向发送的数据
** NByte:发送的字节数
** 输 出: TRUE :函数调用成功
** FALSE:函数调用失败
********************************************************************************************************/
extern uint8 PPPCreate(NetHardDrivesSocket *HardDrive);
extern void PPP_irc(uint8 *DataBuf, uint8 Q);
extern void PPP_zrc(uint8 *DataBuf, uint8 Q);
extern uint8 PPPOpen(void);
extern uint8 PPPClose(void);
extern uint8 PPPGetState(void);
#endif
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -