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

📄 myppp.h

📁 PPPoE协议在Psos中的实现源代码
💻 H
字号:
/************************************************************************//*                                                                      *//*   MODULE:  ppp.h                                                     *//*   PRODUCT: pNA+,  OpEN TCP/IP PPP driver                             *//*   PURPOSE: PPP module                                                *//*   DATE:    28 February, 1996                                         *//*                                                                      *//*----------------------------------------------------------------------*//*                                                                      *//*              Copyright 1996, Integrated Systems, Inc.                *//*                      ALL RIGHTS RESERVED                             *//*                                                                      *//*   Permission is hereby granted to licensees of Integrated Systems,   *//*   Inc. products to use or abstract this computer program for the     *//*   sole purpose of implementing a product based on Integrated         *//*   Systems, Inc. products.   No other rights to reproduce, use,       *//*   or disseminate this computer program, whether in part or in        *//*   whole, are granted.                                                *//*                                                                      *//*   Integrated Systems, Inc. makes no representation or warranties     *//*   with respect to the performance of this computer program, and      *//*   specifically disclaims any responsibility for any damages,         *//*   special or consequential, connected with the use of this program.  *//*                                                                      *//************************************************************************/#ifndef __PPP_H__#define __PPP_H__#include <string.h> /*for size_t*/#include "ppptypes.h"#include "pppdefs.h"#include "ppp_conf.h"#include "bsp.h"#include "disi.h"#include "mygenif.h"#include "pppmisc.h"#define MAXNAMELEN      256 /* max length of hostname or name for auth */#define MAXSECRETLEN    256 /* max length of password or secret */typedef struct mib_stat {    char   *ifDescr;    long   ifadminstatus;    long   ifoperstatus;    long   starttime;    long   mtu;    long   speed;    long   inoctets;    long   inucastpkts;    long   innucastpkts;    long   indiscards;    long   inerrors;    long   inunknownprotos;    long   outoctets;    long   outucastpkts;    long   outnucastpkts;    long   outdiscards;    long   outerrors;    long   ifoutqlen;    long   badaddress;    long   badcontrols;    long   packettoolongs;    long   badfcs;    long   localmru;    long   remotemru;    long   sendaccmap;    long   recvaccmap;    long   sendpcomp;    long   recvpcomp;    long   sendaccomp;    long   recvaccomp;} mib_stat;/*----------------------------------------------------------------------*//* Configuration structure for PPP                                      *//*----------------------------------------------------------------------*/struct ppp_cfg {    IFentrypoint *ifinfo;    void         *IFconfig;    long pppmode;                /* Mode for the PPP channel  */    long dialmode;               /* Dial mode for the channel */    long xfermode;               /* SYNC or ASYNC */    char *user;                  /* User */    char *passwd;                /* Password */    unsigned long mru;           /* MRU of the channel */    unsigned long asyncmap;      /*             */    unsigned long lcp_options;   /* Various LCP options */    unsigned long auth_options;  /* Various Auth Options */    unsigned long local_ip;      /* Local IP address of the channel */    unsigned long peer_ip;       /* Peer IP address */    unsigned long ipcp_options;  /* Various IPCP options */};#define NEGMRU          0x1     /* Negotiate MRU */#define NEGASYNCMAP     0x2     /* Negotiate async map */#define NEGMAGIC        0x4     /* Negotiate magic number */#define NEGPROTOCOMP    0x8     /* Negotiate protocol comp */#define NEGACCOMP       0x10    /* Negotiate address/control comp */#define REQUPAP         0x1    /* Negotiate PAP */#define REQCHAP         0x2    /* Negotiate CHAP */#define NOUPAP          0x4    /* Dont allow PAP authentication */#define NOCHAP          0x8    /* Dont allow CHAP authentication */#define NEGADDR         0x1    /* Negotiate IPCP addr compression */#define NEGIPCOMP       0x2    /* Negotiate IPCP compression */#define NEGADDR_OLD     0x1    /* Neg. OLD addr comp. (RFC1172)*/#define NEGADDR_NEW     0x2    /* Neg. New addr. comp. (RFC1332) */#define IPCPADDR        NEGADDR_NEW#define VJMODE_RFC1172_TYPO 0x1    /* Neg. 1172 compression with typo */#define VJMODE_RFC1172      0x2    /* Neg. RFC 1172 compression */#define VJMODE_RFC1332      0x3    /* Neg. RFC 1332 comrpession */#define IPCPVJCOMPMODE      VJMODE_RFC1332#define PPP_DIRECT      0x1#define PPP_DIALUP      0x2#define PPP_DEMANDDIAL  0x3#define PPPMODE_ACTIVE  1          /* We start the negotiation */#define PPPMODE_PASSIVE 0#define PPP_ASYNC       0          /* Compute & check FCS      */#define PPP_SYNC        1          /* Disregard FCS            *//* * PPP Data Link Layer "protocol" table. * One entry per supported protocol. */struct protent {    u_short protocol;    void (*init)(int);    void (*input)(int, unsigned char *, int);    void (*protrej)(int);    int  (*printpkt)(unsigned char *, int,		       void (*) __P((void *, char *, ...)), void *);    void (*datainput)(void);    char *name;};/*----------------------------------------------------------------------*//* PPP password structure                                               *//*----------------------------------------------------------------------*/struct passwdentry {    char *user;    char *passwd;    char  *msg;};/*----------------------------------------------------------------------*//* PPP secret table entry                                               *//*----------------------------------------------------------------------*/struct secretentry {    char *hostname;    char *secret;};/*----------------------------------------------------------------------*//* Async control structure                                              *//*----------------------------------------------------------------------*/struct  ppp_async_info {    u_int pai_flags;#define PAI_FLAGS_ESCAPED   0x1    u_long pai_asyncmap;        /* current outgoing asyncmap */    u_short pai_fcs;            /* the current fcs */};typedef struct ppp_async_info   PAI;/* * Status of PPP link */#define PSNEGOTIATING 1       /* negotiating */#define PSUP       2       /* PPP has come up */#define PSDOWN     3       /* negotiation has failed *//*----------------------------------------------------------------------*//* Message Types for PPP deamon processing                              *//*----------------------------------------------------------------------*/#define MSG_INIT     1               /* Init channel message */#define MSG_INPUT    2               /* Input from Serial port */#define MSG_RAWINPUT 3               /* Raw Input from Serial port (modem) */#define MSG_OUTPUT   4               /* Output message for demand dial */#define MSG_FREE     5#define MSG_LINKUP   6               /* synchronise with pppd */#define MSG_LINKCLOSE  7             /* synchronise with pppd */#define MSG_LINKDOWN   8             /* synchronise with pppd *//*----------------------------------------------------------------------*//* Events for PPP daemon processing                                     *//*----------------------------------------------------------------------*/#define PEV_QEVENT  0x00000001      /* Message in PPP queue */#define PEV_TIMER   0x00000002      /* Time event */#define DORMANT     "12345"         /* up-not-running */#define PDS_SETUP   0x0010/* * Inline versions of get/put char/short/long. * Pointer is advanced; we assume that both arguments * are lvalues and will already be in registers. * cp MUST be u_char *. */#define GETCHAR(c, cp) ((c) = *(cp)++)#define PUTCHAR(c, cp) (*(cp)++ = (u_char) (c))#define GETSHORT(s, cp) \  ((s) = *(cp)++ << 8, (s) |= *(cp)++)#define PUTSHORT(s, cp) \  (*(cp)++ = (u_char) ((s) >> 8), \   *(cp)++ = (u_char) (s))#define GETLONG(l, cp) \   ((l) = *(cp)++ << 8, \    (l) |= *(cp)++, (l) <<= 8, \    (l) |= *(cp)++, (l) <<= 8, \    (l) |= *(cp)++)#define PUTLONG(l, cp) \   (*(cp)++ = (u_char) ((l) >> 24), \    *(cp)++ = (u_char) ((l) >> 16), \    *(cp)++ = (u_char) ((l) >> 8), \    *(cp)++ = (u_char) (l))#define INCPTR(n, cp)   ((cp) += (n))#define DECPTR(n, cp)   ((cp) -= (n))#ifndef MIN#define MIN(a, b)   ((a) < (b)? (a): (b))#endif#if 0#ifndef MAX#define MAX(a, b)   ((a) > (b)? (a): (b))#endif#endif/* * System dependent definitions for user-level 4.3BSD UNIX implementation. */#define DEMUXPROTREJ(u, p)  demuxprotrej(u, p)#define TIMEOUT(r, f, t)    ppp_timeout((r), (f), (t))#define UNTIMEOUT(r, f)     ppp_untimeout((r), (f))#define EXIT(u)         ppp_exit()#define quit()          ((void) 0)#define PRINTMSG(m, l) \    ((m) [l] = '\0', syslog (LOG_INFO, "Remote message: %s", m))/* * MAKEHEADER - Add Header fields to a packet. */#define MAKEHEADER(p, t) \    (PUTCHAR(PPP_ALLSTATIONS, p), \    PUTCHAR(PPP_UI, p), \    PUTSHORT(t, p))#define output(add, c, buf, len, isdis) async_send((char *) (addr), (u_long) (c), buf, (u_long) (len), (u_long) (isdis))#ifdef DEBUG#define DEBUGMAIN   1#define DEBUGFSM    1#define DEBUGLCP    1#define DEBUGIPCP   1#define DEBUGUPAP   1#define DEBUGCHAP   1#define DEBUGDISCOVERY 1#endif#ifdef DEBUGMAIN#define MAINDEBUG(x)    (debug? syslog x: (void) 0)#else#define MAINDEBUG(x)#endif#ifdef DEBUGFSM#define FSMDEBUG(x)     (debug? syslog x: (void) 0)#else#define FSMDEBUG(x)#endif#ifdef DEBUGLCP#define LCPDEBUG(x)     (debug? syslog x: (void) 0)#else#define LCPDEBUG(x)#endif#ifdef DEBUGIPCP#define IPCPDEBUG(x)    (debug? syslog x: (void) 0)#else#define IPCPDEBUG(x)#endif#ifdef DEBUGUPAP#define UPAPDEBUG(x)    (debug? syslog x: (void) 0)#else#define UPAPDEBUG(x)#endif#ifdef DEBUGCHAP#define CHAPDEBUG(x)    (debug? syslog x: (void) 0)#else#define CHAPDEBUG(x)#endif#ifdef DEBUGDISCOVERY#define DISCOVERYDEBUG(x)    (debug? syslog x: (void) 0)#else#define DISCOVERYDEBUG(x)#endifextern int debug, pppunit;extern u_long Tid;extern u_long Qid;extern Lid lowerid[];extern int peer_mru[];extern u_long msgbuf[4];extern char *hostname;  /* Our hostname */extern mblk_t *PPPoEHdPool;extern int lcp_echo_fails;  /* Tolerance to unanswered echo-requests */extern int lcp_echo_interval; /* Interval between LCP echo-requests */extern u_char outpacket_buf[]; /* Buffer for outgoing packets */extern struct protent prottbl[];extern struct ppp_cfg pppcfgtab[];extern void demuxprotrej(int unit, unsigned short protocol);extern int pindex(u_short protocol);extern unsigned long async_send(char *addr, u_long unit, u_char *buf, u_long len, u_long isdiscovery);extern u_int32_t GetMask(u_int32_t);extern void pppassert(int);extern int interfaceinit(int);extern int ppp_init(void);extern void ppp_exit(int unit);extern void SetupLink(int unit);extern void CloseLink(int unit);extern void link_down(int unit);extern void link_required(int);extern void link_terminated(int);extern void link_established(int unit);extern void network_phase(int unit);extern int auth_ip_addr(int , u_int32_t );extern void auth_peer_fail(int unit, int protocol);extern void auth_peer_success(int unit, int protocol);extern void auth_withpeer_fail(int unit, int protocol);extern void auth_withpeer_success(int unit, int protocol);extern void (*ppp_error_callout)(unsigned long unit, unsigned long error);extern void sifdown(int);extern int sifup(int);extern void signal_lowerup(int);extern void signal_lowerdown(int);extern void cifproxyarp(int , u_int32_t );extern int sifproxyarp(int , u_int32_t );extern int cifdefaultroute(int , u_int32_t );extern int sifdefaultroute(int , u_int32_t );extern int sifaddr(int , u_int32_t , u_int32_t , u_int32_t );extern void cifaddr(int , u_int32_t , u_int32_t );extern void sifvjcomp(int , int , u_char , u_char );extern void ppp_set_xaccm(int , u_int32_t *);extern void ppp_send_config(int ,int ,int ,int , int );extern void ppp_recv_config(int ,int ,int ,int , int );extern u_short MAX(u_short , u_short );extern void print_string(u_char *, int,                           void (*)(void *, char *, ...), void *);#endif /* __PPP_H__ */

⌨️ 快捷键说明

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