📄 ppp.h
字号:
#define MAXTERMINATE 2
#define MAXCONFIGURE 10
#define PPP_TIMEOUT 0x7e //PPP timeout timer ID
#define PPPINITFCS16 0xffff /* Initial FCS value */
#define PPPGOODFCS16 0xf0b8 /* Good final FCS value */
#define BIT_ACCM 0x01
#define BIT_MRU 0x02
#define BIT_AP 0x04
#define ESC 0x7D
#define END 0x7E
#define PPP_BUFFER_SIZE 256
#define PPPTIMEROUT 500 //3 second
#define FS_START 0x01
#define FS_ESC 0x02
//Definations of phase of link
//#define DEAD 0
//#define ESTABLISH 1
//#define AUTHENTICATE 2
//#define NETWORK 3
//#define TERMINATE 4
//Definations of Code field
#define REQ 1 //Configure_Req , IPCP_Req or PAP_Req
#define ACK 2 //Configure_Ack , IPCP_Ack or PAP_Ack
#define NAK 3 //Configure_Nak , IPCP_Nak or PAP_Nak
#define REJ 4 //Configure_Rej , IPCP_Rej or PAP_Rej
#define TERMINATE 5 //Terminate_Req
#define TERMINATE_ACK 6 //Terminate_Ack
#define CODE_REJ 7 //Code_Rej
#define PROT_REJ 8 //Protocol_Rej
//Definations of Protocol field in PPP packet
//for teh reason of PIC storage -- the low byte first
#define LCP 0xC021
#define PAP 0xC023
#define CHAP 0xC223
#define IPCP 0x8021
#define IP 0x0021
#define CCP 0x80fd
//Definations of LCP Option field
//Actually we only use the 1~3 option
#define LCP_MRU 1 //Maximum Receive Unit
#define LCP_ACCM 2 //Asynchronous Control Character Map
#define LCP_AP 3 //Authentication Protocol
#define LCP_QP 4 //Quality Protocol
#define LCP_MN 5 //Magic Number
#define LCP_PFC 7 //Protocol Field Compression
#define LCP_ACFC 8 //Address and Control Field Compression
#define LCP_FCSA 9 //FCS Alternatives
//Definations of IPCP Option field
#define IPCP_IPADD 3 //IP Address
/*****************************************The State defination****************************************/
//The state is a bit different to the RFC1661. The major one is, in the RFC, when the peer want to
// terminate the link, the state of the link shall move to STOPPED. But in our application, when a
// terminate request received, the link has to be terminated and at last goto INITAIL state.
// Here the only difference between STOPPED and CLOSED is that the former one is triggered by the
// peer while the other is triggered locally.
// The idle state, no connection available
#define INITIAL 0
// Begin to establish the link, that is, the command to dial out has been sent to MODEM,
// but has not connectted yet. When the MODEM report the connection is available(UP),
// send CONFIGURE_REQ. And the state move to REQ_SENT.
#define STARTING 1
// Due to CLOSE command from upper layer, the link has been closed(an TERMINATE_ACK has
// been received). But the MODEM has not onhook. So, when the MODEM is onhook, goto
// INITIAL state
#define CLOSED 2
// The peer want to terminate the link. and all the process has been exacuted, when MODEM
// report Down event, goto INITIAL state
#define STOPPED 3
// Due to CLOSE command from upper layer, to terminate the link, the TERMINATE_REQ has been
// sent, but no TERMINATE_ACK received. When a TERMINATE_ACK received, goto CLOSED state
#define CLOSING 4
//The peer want to terminate the link. An terminate ack has been sent and timeout timer has
// been set. When the timer expire, send OnHook command to MODEM and goto STOPPED state
#define STOPPING 5
//Enter this state after we have sent a CONFIGURE_REQ.
#define REQ_SENT 6
//Enter when a ACK from the peer is received
#define ACK_RCVD 7
// As the response to CONFIGURE_REQ from peer, the CONFIGURE_ACK has been sent.
#define ACK_SENT 8
// All the negotiation is passed and link is available for network layer PDU. That is, all LCP,
// PAP and IPCP has successed.
#define OPENED 9
typedef rom struct PPPFrame_Struct{
INT16U Framing;
INT8U ProtocolH;
INT8U ProtocolL;
//
INT8U Code;
INT8U Id;
INT8U LengthHigh;
INT8U Length;
//
INT8U FirstOption;
INT8U FirstOptionLength;
INT8U Param;
INT8U Data;
} PPP_FRAME;
//////////////////////
typedef rom struct LCPOption_Struct{
INT8U Option;
INT8U Len;
INT8U Data[10]; //define a very long data region, for we only use it to define pointers
}LCPOption;
void PPPInit (void);
INT8U rom *PPPMakeHeader(INT8U rom * pBuf, INT16U Protocol);
INT8U PPPSendPacket (INT8U rom *Buffer, INT16U len);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -