⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppp.h

📁 本人亲手实现且用在一商用产品上的一个简单的ppp协议
💻 H
字号:

/***************************************************************************
File Name : PPP.h

Author : Rene Trenado

Location : Motorola Applications Lab, Baja California

Date Created : September 2000

Current Revision : 0.0

Notes : Definitions for the PPP implementation
***************************************************************************/
#ifndef __PPP_H
#define __PPP_H	1

//#include "Notation.h"
#include "stacktsk.h"
#include "ip.h"
#include "tcp.h"


#ifndef	NULL
#define NULL	0
#endif

#define LCP_ESC	0x7D
#define LCP_END	0x7E

#define	LCP_REQ             1
#define LCP_ACK             2
#define LCP_NAK             3
#define LCP_REJ             4
#define LCP_TERMINATE       5
#define LCP_TERMINATE_ACK   6
#define LCP_CODE_REJ        7
#define LCP_PROTO_REJ       8
#define LCP_ECHO_REQ        9
#define LCP_ECHO_ACK        10
#define LCP_DISCARD_REQ     11

typedef struct {
	WORD Framing;
	WORD Protocol;
	BYTE Request;
	BYTE Id;
	BYTE LengthHigh;
	BYTE Length;
	BYTE FirstOption;
	BYTE FirstOptionLength;
	BYTE Param;
	BYTE Data;
} PPPFrame;


#define PPPINITFCS16    0xffff  /* Initial FCS value */
#define PPPGOODFCS16    0xf0b8  /* Good final FCS value */

////////////// Functions to Export ////////
void PPPInit (void);
BYTE *PPPGetInputBuffer (void);
BYTE *PPPGetOutputBuffer (void);
BYTE ProcPPPReceive (BYTE c);
void ProcPPPSend (BYTE *Buffer, BYTE len);
WORD PPPGetChecksum (unsigned char *cp, int len);
void SendPAPPacket (BYTE Action, BYTE id, char* user, char* password);
void Move (BYTE *src, BYTE *dest, register numBYTEs);
void PPPEntry (void);
void PPPTerminate (void);
void PPPSendVoidLCP (void);
void pppRcv(void);
void PPPSendIPPacket (BYTE *Buffer, WORD len);
BOOL PPPLinkStatus(void);
void PPPTask(void);


extern volatile WORD PPPStatus;

#define 	IsESC       0x0001      // Previous character received was a ESC char
#define 	ReSync      0x0002      // Re Synchronize to avoid incomplete IP frame reception
#define 	IsFrame     0x0004      // A full packet
#define 	ByteRx 	    0x0008      // Receive a Byte
#define     LCP_FIN     0x0020
#define     PAP_FIN     0x0040
#define		LinkOn      0x0080      // PPP Link is On

// ppp包纯数据大小
#define PPP_PACKET_SIZE	        512     /*256*/
// 添加0x7d后ppp数据大小
#define PPP_MAX_UART_SND_SIZE   1024

#if ( (PPP_MAX_UART_SND_SIZE < (PPP_PACKET_SIZE)*2) )
#error PPP_MAX_UART_SND_SIZE should be more than double of PPP_PACKET_SIZE
#endif

// 用于TCP包头中的win字段  46=sizeof(TCP_HEADER)+sizeof(IP_HEADER)+sizeof(PPP_HEADER)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -