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

📄 mppp.h

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 H
📖 第 1 页 / 共 2 页
字号:
   /* variables for character IO */
   PACKET   inpkt;               /* packet for received bytes */
   u_short  sc_fcs;              /* FCS so far (input) */
   u_short  sc_outfcs;           /* FCS so far for output packet */
   ip_addr  last_ip_src;         /* IP info for last IP packet sent */
   ip_addr  last_ip_dest;        /* IP info for last IP packet sent */
   u_short  last_ip_id;          /* IP info for last IP packet sent */
#endif   /* PPP_CHARIO */

#ifdef USE_PPPOE
   struct poe_line * poeline;    /* pointer to PPPoE line struct, if any */
#endif   /* USE_PPPOE */

#ifdef PAP_SUPPORT
   upap_state     upap;          /* include UPAP state info */
#endif  /* PAP_SUPPORT */

#ifdef CHAP_SUPPORT
   chap_state     chap;          /* include CHAP state info */
#endif  /* CHAP_SUPPORT */

#ifdef PPP_VJC
   struct slcompress sc_comp;    /* vjc control buffer */
#endif   /* PPP_VJC */

};


extern M_PPP ppp_list;      /* master list of PPP links */


/* bit definition for mppp->pppflags. These flags are cleared at the
 * start of each new link session.
 */
#define  PPP_SERVER     0x0001   /* Set if this link is server */
#define  IPCP_IPADDR    0x0002   /* IPCP set current IP address */
#define  IPCP_ROUTE     0x0004   /* IPCP set route to IP address */
#define  IPCP_DHCP      0x0008   /* start DHCP client when IPCP comes up */
#define  PPP_SENDING    0x0010   /* set when sending data */
#define  ML_LCP         0x0020   /* This mppp is an ML bundle link */
#define  ML_IPCP        0x0040   /* This mppp is an ML bundle master */
#define  ALLOW_ML       0x0080   /* allow ML or not */
#define  ALLOW_VJ       0x0100   /* allow VJ neg. ML or not */
#define  SEND_REJECT    0x0200   /* next NAK/REJ is a REJECT */
#define  IDENT_SENT     0x0400   /* Sent PPP identification already */


/* indexes into mppp.states[] array */
#define  LCP_STATE   0
#define  IPCP_STATE  1
#define  AUTH_STATE  2     /* Doing CHAP or PAP */

/* bits for sc_flags mask */
#define  SC_FLUSH       0x0001      /* flush input until next PPP_FLAG */
#define  SC_ESCAPED     0x0002      /* next char in stream is escaped */
#define  SC_REJ_COMP_AC 0x0004      /* reject compression of AC bytes */
#define  SC_COMP_TCP    0x0008      /* agreed to VJ compression */
#define  SC_NO_TCP_CCID 0x0010      /* VJ option??? */


/* Each Protocol is handled by the following set of routines. Note
 * that any routine may be NULL for a particular protocol.
 */
typedef struct prot_callbacks 
{
   void  (*resetci)(M_PPP);      /* Reset Configuration Info (CI) */
   int   (*addci)(M_PPP);        /* build confreq option string */
   /* routines to process received CI pkts */
   int   (*ackci)(M_PPP, u_char *, int);     /* ACK Configuration Info */
   int   (*nakci)(M_PPP, u_char *, int);     /* NAK Configuration Info */
   int   (*rejci)(M_PPP, u_char *, int);     /* Reject CI pkt */
   int   (*reqci)(M_PPP, u_char *, int *, int); /* Request peer's CI */
   int   (*extcode)(M_PPP, u_char, u_char, u_char *, int);  /* Called when unknown code received */
   void  (*up)(M_PPP);           /* Called when fsm reaches OPENED state */
   void  (*down)(M_PPP);         /* Called when fsm leaves OPENED state */
   void  (*starting)(M_PPP);     /* Called when we want the lower layer */
   void  (*finished)(M_PPP);     /* Called when we don't want the lower layer */
   char *   proto_name;          /* String name for protocol (for messages) */
} prot_funcs;

/* protocol callback table */
extern prot_funcs prot_func_tabs[MAX_PPP_PROTS];


/* externally overridable PPP globals. Application code can set
 * these with new values prior to initiating Connections
 */
extern   int      ppp_maxnaks;      /* NAK loop limit */
extern   u_long   allow_asyncmap;   /* async mapping we (dis)allow */
extern   int      ppp_retry_secs;   /* seconds between retrys */
extern   int      ppp_default_type; /* eg. LN_UART or LN_PORTSET */
extern   unsigned ppp_mru;          /* default MRU */
extern   unsigned ppp_mtu;          /* default MTU */
extern   int      ppp_static;       /* number fo static PPP links */
extern   int      ppp_allow_ml;     /* allow multilink neg. by default */
extern   int      ppp_hexmax;       /* length of debug hexdumps */

#define  PPP_IP         0x0021   /* Internet Protocol */
#define  PPP_XNS        0x0025   /* Xerox NS */
#define  PPP_VJC_COMP   0x002d   /* VJ compressed TCP */
#define  PPP_VJC_UNCOMP 0x002f   /* VJ uncompressed TCP */
#define  PPP_ML         0x003d   /* Multilink fragment header */
#define  PPP_LCP        0xc021   /* Link Control Protocol */
#define  PPP_IPCP       0x8021   /* IP Control Packet */
#define  PPP_UPAP       0xc023   /* User/Password Authentication Protocol */
#define  PPP_CHAP       0xc223   /* Cryptographic Handshake Protocol */
#define  PPP_LQR        0xc025   /* Link Quality Report protocol */

/* (yaxon modify) */
/* Macros to configure PPP if INCLUDE_NVPARMS is NOT USED */
#define  PPP_CONSOLE_LOG_STAT    /*1*/                  1
#define  PPP_FILE_LOG_STAT       /*0*/                  0
#define  PPP_KEEP_ALIVE_SECS     /*120*/                0
#define  PPP_CLIENT_TMO_SECS     /*120*/                120
#ifdef PPP_VJC
#define  PPP_REQUEST_VJ_STAT     /*1*/                  1
#endif   /* PPP_VJC */
#ifdef   CHAP_SUPPORT   /* from ppp_port.h */
#define  CHAP_SECRET_STRING      /*"chap_secret"*/      ""
#define  REQURE_CHAP_STAT        /*0*/                  0
#endif   /* CHAP_SUPPORT */
#ifdef PAP_SUPPORT
#define  REQUIRE_PAP_STAT        /*0*/                  0
#endif   /* PAP_SUPPORT */
#define  PPP_USERNAME            /*"your_username"*/    ""
#define  PPP_PASSWORD            /*"your_password"*/    ""
#define  PPP_LINE_TMO_SECS       /*600*/                600
#define  PPP_LOGIN_FILE_NAME     /*"\0"*/               "\0"
#define  PPP_SERVE_FILE_NAME     /*"\0"*/               "\0"

/* Struct contaning all configuration global params for PPP */
struct PPPCfg
{

   /* PPP options: */
   int      ppp_ConsoleLog;   /* bool - Log Modem & PPP events to console */
   int      ppp_FileLog;      /* bool - Log Modem & PPP events to file */
   unshort  ppp_keepalive;    /* seconds between PPP echos, 0=disable */
   unshort  ppp_client_tmo;   /* timeout for connects as client */
#ifdef PPP_VJC
   int      ppp_request_vj;   /* bool - request that the other side do VJ compression */
#endif   /* PPP_VJC */
#ifdef   CHAP_SUPPORT   /* from ppp_port.h */
   char     secret[MAX_NVSTRING];   /* secret for CHAP/MD5 hashing */
   int      require_chap;     /* bool - require CHAP from PPP connections */
#endif   /* CHAP_SUPPORT */
#ifdef PAP_SUPPORT
   int      require_pap;
#endif   /* PAP_SUPPORT */
   char     username[MAX_NVSTRING];
   char     password[MAX_NVSTRING];
   unshort  line_tmo;   /* idle modem line timeout, 0=infinite */
   char     loginfile[MAX_NVSTRING];   /* path/name of file with login script */
   char     logservefile[MAX_NVSTRING];   /* login server script */
};

extern struct PPPCfg pppcfg;

#ifndef PPP_MTU   /* might be set in ppp_port.h */
#define  PPP_MTU     1514  /* Default MTU (max transmit unit) */
#endif
#ifndef PPP_MRU   /* might be set in ppp_port.h */
#define  PPP_MRU     1514  /* Default MRU (max receive unit) */
#endif

#ifdef CONPRINTF_DPRINTF
#define ConPrintf dprintf
#endif   /* CONPRINTF_DPRINTF */

#define _PPP_PORT_C     1       /* (yaxon add) */
#ifndef _PPP_PORT_C
void  ConPrintf(const char * format, ...);
#endif   /* _PPP_PORT_CF  */

int   ppp_line_init(M_PPP, int type);  /* init newly created M_PPP */
void  ppp_fsm_init(M_PPP mppp);        /* (re)init M_PPP for new link */


/* routines to handle/initiate state changes */

void  ppp_lowerup(M_PPP, int pcode);
void  ppp_lowerdown(M_PPP, int pcode);
void  ppp_open(M_PPP, int pcode);
void  ppp_close(M_PPP, int pcode);

/* internal */
void  ppp_fsm(M_PPP mppp, unsigned pcode, int event, u_char * inp, int plen);


/* routines to put/get various values into character buffers */

u_short     ppp_getshort(u_char * cp);
u_long      ppp_getlong( u_char * cp);
u_char *    ppp_putshort(u_char * cp, u_short value);
u_char *    ppp_putlong( u_char * cp, u_long  value);

u_long      ppp_magic(M_PPP);   /* get a session "magic number" */

int ppp_sendctl(M_PPP mppp, int pcode, u_char code,
         u_char * data, int len, u_char Id);


/* IP interface setup "signal" callback routines */

extern int  ppp_ifup(M_PPP);
extern int  ppp_setaddr(M_PPP, ip_addr ouraddr);
extern int  ppp_authaddr(M_PPP, ip_addr);
extern int  ppp_setroute(M_PPP, ip_addr);
extern int  ppp_setproxyarp(M_PPP, ip_addr);
extern int  ppp_setdnsaddr(M_PPP, ip_addr);
extern int  ppp_cleardnsaddr(M_PPP, ip_addr);
extern void ppp_auth_failed(M_PPP mppp, int who);
extern int  ppp_ifdown(M_PPP);
extern int  ppp_clearaddr(M_PPP);

/* hexdump a data block (e.g PPP packet)  */
extern void ppp_hexdump(u_char * b, int length);


/* routine to pass received pkts into PPP (pkt in mppp->inpkt) */
void     ppp_inpkt(M_PPP mppp, PACKET pkt);

/* PPP character receive routine */
void     ppp_inchar(M_PPP mppp, int c);

/* internal routine to send queued output packets */
int      ppp_allpktsend(M_PPP mppp);

/* Interal routine for HDLC-ish send of all the chars in a pkt */
int   ppp_sendchars(M_PPP mppp, PACKET pkt);

/* lowest level pkt oriented send routine. ML can use this to send fragments */
int   ppp_lower_send(M_PPP mppp, PACKET pkt);
 
/* Interal routines to set/clear retry timers */
void  ppp_settimer(M_PPP mppp, void (*func)(M_PPP, long), int secs, long arg);
void  ppp_cleartimer(M_PPP mppp);

void  ppp_lowerup_ipcp(M_PPP mppp);

M_PPP new_lcp(void);    /* constructor for lcp-only M_PPP object */
M_PPP new_ipcp(void);   /* constructor for full M_PPP object */
M_PPP new_mlppp(NET ifp, int linetype);   /* constructor - ML link */

void  del_ppp(M_PPP mppp); /* M_PPP all-purpose destructor */

void  ppp_fsm_init(M_PPP mppp);

/* FSM timer callback */
void  ppp_fsm_tmo(M_PPP mppp, long parm);

#ifdef PPP_MULTILINK
int   pppml_link(M_PPP mppp);
void  pppml_unlink(M_PPP mppp);
M_PPP pppml_search(M_PPP mppp);
int   pppml_sendpkt(M_PPP mppp, PACKET wholepkt);
void  pppml_rcv(M_PPP link_mp, PACKET pkt);
void  pppml_delfrag(struct ml_reasm * reasm);
#endif /* PPP_MULTILINK */

#ifdef LB_XOVER      /* Crossover Loopback device exports */
#define MAX_LBXOVERS 6
extern   M_PPP lb_mppps[MAX_LBXOVERS];
extern   M_PPP lb_otherend[MAX_LBXOVERS];
extern int   pl_lookup(M_PPP mppp);
#endif   /* LB_XOVER */

#ifdef PPP_VJC
#define  VJC_HDR_OFFSET 128
#else    /* not supporting VJC */
#define  VJC_HDR_OFFSET 0
#endif   /* PPP_VJC */

#ifdef PPP_DHCP_CLIENT
/* dhcp over PPP entry point: */
extern void    ppp_start_dhcp(M_PPP mppp);
extern void    dhcp_qclean(NET ifp);
#endif   /* PPP_DHCP_CLIENT */

#ifdef USE_PPPOE
extern M_PPP (* pppoe_svr_callback)(NET);
#endif   /* USE_PPPOE */

#endif   /* _MPPP_H_ */


⌨️ 快捷键说明

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