home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1
/
HamRadio.cdr
/
misc
/
src0131
/
ppp.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-15
|
13KB
|
325 lines
#ifndef _PPP_H
#define _PPP_H
/*
* PPP.H
*
* 12-89 -- Katie Stevens (dkstevens@ucdavis.edu)
* UC Davis, Computing Services
* PPP.07 04-90 [ks] start with same peer addr during IPCP
* PPP.08 05-90 [ks] improve statistic and trace reporting
* PPP.09 05-90 [ks] add UPAP processing
* PPP.10 06-90 [ks] improve keybd input of UPAP password
* make ppp open/close/reset work properly
* add peerID-to-IPaddr lookup table
* add peer IP lookup pool
* PPP.13 08-90 [ks] add timestamp for PPP open
* PPP.14 08-90 [ks] change UPAP to PAP for consistency with RFC1172
* add RLSD link up/down signal handling
* add autobaud link speed message handling
* make LCP/IPCP timeouts configurable
* PPP.15 09-90 [ks] update to KA9Q NOS v900828
*/
#ifndef _GLOBAL_H
#include "global.h"
#endif
#ifndef _MBUF_H
#include "mbuf.h"
#endif
#ifndef _IFACE_H
#include "iface.h"
#endif
#ifndef _IP_H
#include "ip.h"
#endif
#ifndef _SLIP_H
#include "slip.h"
#endif
#ifndef _TIMER_H
#include "timer.h"
#endif
/* PPP definitions */
#define PPP_ALLOC 100 /* Receiver allocation increment */
/* Bit masks for escaped element of Slip[] control block */
#define PPP_BIT_BUCKET 0x01 /* Discard bytes until next frame */
#define PPP_ESCAPED 0x02 /* Un-complement next rcv char */
#define PPP_RCV_ACCOMP 0x04 /* Compress HDLC addr/ctl fields */
#define PPP_RCV_PRCOMP 0x08 /* Compress PPP protocol field */
#define PPP_XMT_ACCOMP 0x10 /* Compress HDLC addr/ctl fields */
#define PPP_XMT_PRCOMP 0x20 /* Compress PPP protocol field */
#define PPP_RCV_VJCOMPR 0x40 /* Van Jacobson TCP header compress */
#define PPP_XMT_VJCOMPR 0x80 /* VJ TCP header compression on send */
/* Table for LCP configuration requests */
struct lcpparm {
unsigned char neg_mru; /* Attempt/accept MRU negotiation */
int16 mru; /* Maximum Receive Unit value */
unsigned char neg_ctl_map; /* Attempt/accept ctl map neg */
int32 ctl_map; /* Async Control Map value */
unsigned char neg_auth_type; /* Attempt/accept auth type neg */
int16 auth_type; /* Authentication Type */
unsigned char neg_encr_type; /* Attempt/accept encrpytion neg */
int16 encr_type; /* Encryption Type */
unsigned char neg_magic_num; /* Attempt/accept magic number neg */
int32 magic_num; /* Magic number value */
unsigned char neg_keepalive; /* Attempt/accept keepalive neg */
unsigned char keepalive; /* Keepalive value */
unsigned char neg_prot_compress; /* Attempt/accept protocol compr neg */
int prot_compress; /* Protocol Compression boolean */
unsigned char neg_ac_compress; /* Attmept/accept addr/ctl compr neg */
int ac_compress; /* Addr/Ctl Compression boolean */
};
/* Default configuration option values */
#define DEF_MRU 1500 /* Max Receive Unit = 1500 bytes */
#define DEF_CTL_MAP 0xffffffff /* Async Ctl Map = esc all controls */
#define DEF_AUTH_TYPE 0x0000 /* No Authentication protocol */
#define DEF_ENCR_TYPE 0x0000 /* No Encryption protocol */
#define DEF_MAGIC_NUM 0x00000000 /* No Magic Number */
#define DEF_LINK_QUAL 0x00 /* No Link Quality Monitoring */
#define DEF_PROT_COMPR 0x00 /* No Protocol Compression */
#define DEF_AC_COMPR 0x00 /* No Addr/Ctl Compression */
/* Other configuration option values */
#define MIN_MRU 128 /* Set a lower limit */
#define PAP_AUTH_TYPE 0xc023 /* Password Auth Protocol */
/* LCP control block */
struct lcpctl {
char active; /* 0=passive open; non-0=active open */
char lcp_state; /* State of Link Control exchange */
#define LCP_CLOSED 0x00
#define LCP_LISTEN 0x01
#define LCP_REQ_SENT 0x02
#define LCP_ACK_RCVD 0x03
#define LCP_ACK_SENT 0x04
#define LCP_OPEN 0x05
#define LCP_TERMINATE 0x06
unsigned char lastid; /* ID of last REQ we sent */
struct timer lcp_tm; /* Timer against response to our REQ */
unsigned char ack_retry; /* Retry counter for timeouts */
struct lcpparm initparm; /* First request of local parameters */
struct lcpparm lclparm; /* Negotiated local parameters */
struct lcpparm remparm; /* Negotiated remote parameters */
char pap_state; /* Current state of PAP */
#define PAP_CLOSED 0x00
#define PAP_LISTEN 0x01
#define PAP_REQ_SENT 0x02
#define PAP_REQ_RCVD 0x03
#define PAP_OPEN 0x04
char *pap_user; /* Peer ID for PAP AUTH_REQ */
char *pap_pass; /* Password for PAP AUTH_REQ */
};
#define LCP_TIMEOUT 3 /* 3 sec timeout wait for response */
#define LCP_RETRY_MAX 10 /* Retry on timeout at most 10 times */
#define LCP_TERM_RETRY 2 /* Minimal retry on TERM REQ */
#define PAP_RETRY_MAX 20 /* Retry on timeout at most 20 times */
#define PAP_FAIL_MAX 4 /* At most 5 attempts at peer auth */
/* Permissions bit for use with userlogin() in FTPSERV.C */
/* Other bit values in FTPSERV.H, AX_MBX.H */
#define PPP_ACCESS_PRIV 0x0100 /* Priv bit for PPP connection */
#define PPP_PWD_LOOKUP 0x0200 /* Priv bit for peerID/pass lookup */
/* IPCP pool of addresses when remote peer requests address assignment */
struct ipcppool {
int32 peer_min; /* First IP address in pool */
int32 peer_max; /* Last IP address in pool */
int32 peer_next; /* Next address to assign */
};
#define NULLPOOL (struct ipcppool *)0
/* IPCP control block */
struct ipcpctl {
char active; /* 0=passive open; non-0=active open */
char ipcp_state; /* State of Link Control exchange */
#define IPCP_CLOSED 0x00
#define IPCP_LISTEN 0x01
#define IPCP_REQ_SENT 0x02
#define IPCP_ACK_RCVD 0x03
#define IPCP_ACK_SENT 0x04
#define IPCP_OPEN 0x05
#define IPCP_TERMINATE 0x06
unsigned char lastid; /* ID of last REQ we sent */
struct timer ipcp_tm; /* Timer against response to our REQ */
unsigned char ack_retry; /* Retry counter for timeouts */
int32 peer_addr; /* IP address of remote peer */
struct ipcppool *peer_pool; /* Pool of IP addresses for peer */
unsigned char attempt_addrs; /* 1=send a ConfigReq with our addrs */
int32 attempt_src; /* Addr to send with config request */
int32 attempt_dest; /* Addr to send with config request */
unsigned char accept_addrs; /* 1=accept addrs from remote host */
int32 accept_src; /* Src addr given by remote host */
int32 accept_dest; /* Dest addr given by remote host */
unsigned char neg_ip_compr; /* 1=negotiate IP packet compression */
int16 ip_compr_type; /* Type of IP packet compression */
unsigned char attempt_ip_compr; /* 1=we will request IP compression */
int16 lcl_ip_compr; /* Type of IP compression we want */
unsigned char accept_ip_compr; /* 1=we will accept IP compr request */
int16 rem_ip_compr; /* Type of IP compression requested */
};
#define IPCP_TIMEOUT 3 /* 3 sec timeout wait for response */
#define IPCP_RETRY_MAX 254 /* Retry for a long time */
#define IPCP_TERM_RETRY 2 /* Minimal retry on TERM REQ */
#define IPCP_VJCOMPR 0x0037 /* Van Jacobson TCP header compr */
#define DEF_IP_COMPR 0x00 /* No IP compression */
/* PPP control block */
struct pppctl {
int16 calc_fcs; /* Cummulative FCS value (rcv pkts) */
int32 ctlmap; /* Async control map (xmt pkts) */
char state; /* Overall PPP link state */
#define PPP_PL_DOWN 0x00 /* Physical Layer Down */
#define PPP_AUTOBAUD 0x01 /* Waiting for autobaud msg */
#define PPP_CLOSED 0x02 /* Idle State */
#define PPP_LCP 0x03 /* Negotiating LCP options */
#define PPP_PAP 0x04 /* Password authentication */
#define PPP_IPCP 0x05 /* Negotiating IP options */
#define PPP_OPEN 0x06 /* Link open for all traffic */
struct lcpctl lcpio; /* Control block for LCP negotiation */
struct ipcpctl ipcpio; /* Ctl block for IPCP negotiation */
#ifndef PPP_NO_STATS
int32 upsince; /* Timestamp when state is PPP_OPEN */
int32 sndpkt; /* # packets sent on PPP interface */
int16 snderr; /* # pkts with PPP error on send */
int32 rcvpkt; /* # packets rcvd on PPP interface */
int16 rcverr; /* # pkts with error */
int16 csumerr; /* # rcv pkts with bad PPP checksum */
int16 sndlcp; /* # LCP packets sent */
int16 sndpap; /* # PAP packets sent */
int16 sndipcp; /* # IPCP packets sent */
int32 sndip; /* # IP packets sent */
int16 rcvlcp; /* # LCP packets received */
int16 rcvpap; /* # PAP packets received */
int16 rcvipcp; /* # IPCP packets received */
int32 rcvip; /* # IP packets received */
int16 rcvunk; /* # unknown packets received */
#endif
};
#define NULLPPPCTL (struct pppctl *)0
struct ppphdr {
unsigned char addr; /* Address field (always 0xff) */
char control; /* Control field (always 0x03) */
int16 type; /* Protocol field (IP, IPCP, LCP, PAP) */
#define PPP_IP_TYPE 0x0021 /* DOD Internet Protocol */
#define PPP_COMPR_TYPE 0x002d /* Van Jacobson Compressed TCP/IP */
#define PPP_UNCOMP_TYPE 0x002f /* Van Jacobson Uncompressed TCP/IP */
#define PPP_IPCP_TYPE 0x8021 /* DOD Internet Protocol Control Protocol */
#define PPP_LCP_TYPE 0xc021 /* Link Control Protocol */
#define PPP_PAP_TYPE 0xc023 /* Password Authentication Protocol */
};
#define PPP_HDRLEN 4 /* Max bytes for PPP/HDLC envelope header */
/* HDLC envelope constants */
#define HDLC_ENVLEN 0x06 /* Max bytes for HDLC envelope (outgoing) */
#define HDLC_FLAG 0x7e /* HDLC async start/stop flag */
#define HDLC_ALL_ADDR 0x00ff /* HDLC all-station address flag */
#define HDLC_UI 0x03 /* HDLC Unnumbered Info control flag */
#define HDLC_ESC_ASYNC 0x7d /* HDLC transparency escape flag for async */
#define HDLC_ESC_COMPL 0x20 /* HDLC transparency bit complement mask */
#define HDLC_FCS_START 0xffff /* Starting bit string for FCS calculation */
#define HDLC_FCS_FINAL 0xf0b8 /* FCS when summed over frame and sender FCS */
/* LCP/IPCP config packet header */
struct cnfhdr {
char code;
/* LCP/IPCP config packet codes */
#define CONFIG_REQ 0x01
#define CONFIG_ACK 0x02
#define CONFIG_NAK 0x03
#define CONFIG_REJ 0x04
#define TERMINATE_REQ 0x05
#define TERMINATE_ACK 0x06
#define CODE_REJ 0x07
#define PROT_REJ 0x08
#define ECHO_REQ 0x09
#define ECHO_REPLY 0x0a
#define DISCARD_REQ 0x0b
/* PAP config packet codes */
#define AUTH_REQ 0x01
#define AUTH_ACK 0x02
#define AUTH_NAK 0x03
unsigned char id;
int16 len;
};
#define CNF_HDRLEN 4 /* Length of LCP/IPCP config packet header */
/* LCP/IPCP config option header */
struct opthdr {
char type;
/* LCP option types */
#define MAX_RCV_UNIT 0x01
#define ASYNC_CTL_MAP 0x02
#define AUTH_TYPE 0x03
#define ENCR_TYPE 0x04
#define MAGIC_NUMBER 0x05
#define LINK_QUALITY 0x06
#define PROT_COMPRESS 0x07
#define AC_COMPRESS 0x08
/* IPCP option types */
#define IP_ADDRS 0x01
#define IP_COMPR_TYPE 0x02
unsigned char len;
};
#define OPT_HDRLEN 2 /* Length of LCP/IPCP config option header */
#define NULLOPTHDR (struct opthdr *)0
/* In ppp.c: */
int ntohppp __ARGS((struct ppphdr *ppp, struct mbuf **bpp));
int ppp_send __ARGS((struct mbuf *data,struct iface *iface,int32 gateway,int prec,
int del,int tput,int rel));
int ppp_output __ARGS((struct iface *iface, char dest[], char source[],
int16 type, struct mbuf *data));
int ppp_raw __ARGS((struct iface *iface,struct mbuf *data));
void ppp_recv __ARGS((int dev,void *p1,void *p2));
void ppp_autobaud __ARGS((int dev,void *p1,void *p2));
void ppp_rlsd __ARGS((int dev,void *p1,void *p2));
int ppp_init __ARGS((int dev, char rlsd, long autospeed));
int ppp_close __ARGS((struct slip *sp, int pl_too));
void pproc __ARGS((struct iface *iface,struct mbuf *bp));
/* In ppplcp.c: */
struct mbuf *htoncnf __ARGS((struct cnfhdr *cnf, struct mbuf *data));
int ntohcnf __ARGS((struct cnfhdr *cnf, struct mbuf **bpp));
struct mbuf *htonopt __ARGS((struct opthdr *opt));
int ntohopt __ARGS((struct opthdr *opt, struct mbuf **bpp));
void lcp_init __ARGS((struct slip *sp));
int lcp_reset __ARGS((struct pppctl *pppiop));
int lcp_close __ARGS((struct slip *sp));
int lcp_start __ARGS((struct slip *sp));
void lcp_shutdown __ARGS((struct slip *sp));
void lcpproc __ARGS((struct iface *iface, struct mbuf *bp));
/* In pppipcp.c: */
void ipcp_init __ARGS((struct slip *sp));
int ipcp_reset __ARGS((struct slip *sp));
int ipcp_close __ARGS((struct slip *sp));
int ipcp_start __ARGS((struct slip *sp));
void ipcpproc __ARGS((struct iface *iface, struct mbuf *bp));
/* In ppppap.c: */
void pap_init __ARGS((struct slip *sp));
int pap_reset __ARGS((struct pppctl *pppiop));
int pap_start __ARGS((struct slip *sp));
int pap_getpass __ARGS((struct slip *sp,int mustask));
void papproc __ARGS((struct iface *iface, struct mbuf *bp));
#endif /* _PPP_H */