From: Paul Mackerras Date: Wed, 23 Feb 1994 03:49:22 +0000 (+0000) Subject: Initial revision X-Git-Tag: ppp-2-1-2a~94 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=0ae17bd9d21166d8274d4b4da594d05efd0ae87d;ds=inline Initial revision --- diff --git a/include/net/if_ppp.h b/include/net/if_ppp.h new file mode 100644 index 0000000..e519739 --- /dev/null +++ b/include/net/if_ppp.h @@ -0,0 +1,122 @@ +/* + * if_ppp.h - Point-to-Point Protocol definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Modified by Paul Mackerras (paulus@cs.anu.edu.au) + * Added PPP_MRU, sc_outm, sc_fastq, sc_bpf. + * + * if_ppp.h,v 1.2 1993/08/31 00:05:31 paulus Exp + */ + +/* Portions Copyright (C) 1990 Brad K. Clements (streams support) + (huh? there isn't any streams support in this file) +*/ + +/* + * Standard PPP header. + */ +struct ppp_header { + u_char ph_address; /* Address Field */ + u_char ph_control; /* Control Field */ + u_short ph_protocol; /* Protocol Field */ +}; + +#define PPP_HEADER_LEN 4 /* octets, must == sizeof(struct ppp_header) */ +#define PPP_FCS_LEN 2 /* octets for FCS */ + +#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ +#define PPP_UI 0x03 /* Unnumbered Information */ +#define PPP_FLAG 0x7e /* Flag Sequence */ +#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ +#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ + +/* + * Protocol types. + */ +#define PPP_IP 0x21 /* Internet Protocol */ +#define PPP_XNS 0x25 /* Xerox NS */ +#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ +#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ +#define PPP_LCP 0xc021 /* Link Control Protocol */ + +/* + * Important FCS values. + */ +#define PPP_INITFCS 0xffff /* Initial FCS value */ +#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ +#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) + +#define PPP_MTU 1500 /* Default MTU (size of Info field) */ +#define PPP_MRU 1500 /* Default MRU (max receive unit) */ +#define PPP_MAXMRU 65000 /* Largest MRU we allow */ +#define PPP_HIWAT 400 /* Don't start a new packet if HIWAT on que */ + +struct ppp_softc { + struct ifnet sc_if; /* network-visible interface */ + u_int sc_flags; /* see below */ + struct tty *sc_ttyp; /* pointer to tty structure */ + struct mbuf *sc_outm; /* mbuf chain being output currently */ + struct mbuf *sc_m; /* pointer to input mbuf chain */ + struct mbuf *sc_mc; /* pointer to current input mbuf */ + char *sc_mp; /* pointer to next char in input mbuf */ + short sc_ilen; /* length of input-packet-so-far */ + u_short sc_fcs; /* FCS so far (input) */ + u_short sc_outfcs; /* FCS so far for output packet */ + short sc_mru; /* max receive unit */ + u_long sc_asyncmap; /* async control character map */ + u_long sc_rasyncmap; /* receive async control char map */ + struct ifqueue sc_inq; /* TTY side input queue */ + struct ifqueue sc_fastq; /* IP interactive output packet queue */ +#ifdef VJC + struct slcompress sc_comp; /* vjc control buffer */ +#endif + u_int sc_bytessent; + u_int sc_bytesrcvd; + caddr_t sc_bpf; +}; + +/* flags */ +#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */ +#define SC_COMP_AC 0x00000002 /* header compression (output) */ +#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */ +#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */ +#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */ +#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */ +#define SC_MASK 0x0000ffff /* bits that user can change */ + +/* state bits */ +#define SC_ESCAPED 0x00010000 /* saw a PPP_ESCAPE */ +#define SC_FLUSH 0x00020000 /* flush input until next PPP_FLAG */ + +#define t_sc T_LINEP + +/* this stuff doesn't belong here... */ +#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ +#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ +#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */ +#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */ +#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */ +#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */ +#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */ +#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */ +#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */ + +/* old copies of PPP may have defined this */ +#if !defined(ifr_mtu) +#define ifr_mtu ifr_metric +#endif + diff --git a/include/net/ppp_str.h b/include/net/ppp_str.h new file mode 100644 index 0000000..dacea49 --- /dev/null +++ b/include/net/ppp_str.h @@ -0,0 +1,69 @@ +/* + ppp_str.h - streams version include file + + defines ioctl calls for MRU, COMPPROT and ASYNCMAP + + Copyright (C) 1990 Brad K. Clements, All Rights Reserved, + See copyright statement in NOTES +*/ + +#include + +#ifdef __STDC__ +#define SIOCSIFCOMPAC _IOW('p', 130, char) +#define SIOCSIFCOMPPROT _IOW('p', 131, char) +#define SIOCSIFMRU _IOW('p', 132, int) +#define SIOCGIFMRU _IOR('p', 133, int) +#define SIOCGIFASYNCMAP _IOR('p', 134, long) +#define SIOCSIFASYNCMAP _IOW('p', 135, long) +#define SIOCGETU _IOR('p', 136, int) /* get unit number */ +#define SIOCSIFVJCOMP _IOW('p', 137, char) /* enable/disable VJ Compression */ +#define SIOCGIFDEBUG _IOR('p', 138, int) /* get debug flags */ +#define SIOCSIFDEBUG _IOW('p', 139, int) /* set debug flags */ + +#else +/* traditional C compiler */ +#define SIOCSIFCOMPAC _IOW(p, 130, char) +#define SIOCSIFCOMPPROT _IOW(p, 131, char) +#define SIOCSIFMRU _IOW(p, 132, int) +#define SIOCGIFMRU _IOR(p, 133, int) +#define SIOCGIFASYNCMAP _IOR(p, 134, long) +#define SIOCSIFASYNCMAP _IOW(p, 135, long) +#define SIOCGETU _IOR(p, 136, int) /* get unit number */ +#define SIOCSIFVJCOMP _IOW(p, 137, char) /* enable/disable VJ Compression */ +#define SIOCGIFDEBUG _IOR(p, 138, int) /* get debug flags */ +#define SIOCSIFDEBUG _IOW(p, 139, int) /* set debug flags */ +#endif + +struct ppp_if_info { + int pii_flags; +#define PII_FLAGS_INUSE 0x1 /* in use by a stream */ +#define PII_FLAGS_COMPAC 0x2 +#define PII_FLAGS_COMPPROT 0x4 +#define PII_FLAGS_ATTACHED 0x8 /* already if_attached */ +#define PII_FLAGS_VJC_ON 0x10 /* VJ TCP header compression enabled */ + struct ifnet pii_ifnet; + queue_t *pii_writeq; /* used by ppp_output */ +#ifdef VJC + struct slcompress pii_sc_comp; /* vjc control buffer */ +#endif +#ifdef PPP_STATS + struct pppstat { + u_int ppp_ibytes; + u_int ppp_ipackets; + u_int ppp_ierrors; + u_int ppp_obytes; + u_int ppp_opackets; + u_int ppp_oerrors; + } pii_stats; +#endif +}; + +#ifdef STREAMS +/* defines for streams modules */ +#define IF_INPUT_ERROR 0xe1 +#define IF_OUTPUT_ERROR 0xe2 + +#define ALLOCBSIZE 64 /* how big of a buffer block to +allocate for each chunk of the input chain */ +#endif diff --git a/include/net/slcompress.h b/include/net/slcompress.h new file mode 100644 index 0000000..3cf9a20 --- /dev/null +++ b/include/net/slcompress.h @@ -0,0 +1,140 @@ +/* + * Definitions for tcp compression routines. + * + * $Header: /home/paulus/ppp/samba.org/ppp/include/net/slcompress.h,v 1.1 1994/02/23 03:49:22 paulus Exp $ + * + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: + * - Initial distribution. + */ + +#define MAX_STATES 16 /* must be > 2 and < 256 */ +#define MAX_HDR MLEN /* XXX 4bsd-ism: should really be 128 */ + +/* + * Compressed packet format: + * + * The first octet contains the packet type (top 3 bits), TCP + * 'push' bit, and flags that indicate which of the 4 TCP sequence + * numbers have changed (bottom 5 bits). The next octet is a + * conversation number that associates a saved IP/TCP header with + * the compressed packet. The next two octets are the TCP checksum + * from the original datagram. The next 0 to 15 octets are + * sequence number changes, one change per bit set in the header + * (there may be no changes and there are two special cases where + * the receiver implicitly knows what changed -- see below). + * + * There are 5 numbers which can change (they are always inserted + * in the following order): TCP urgent pointer, window, + * acknowlegement, sequence number and IP ID. (The urgent pointer + * is different from the others in that its value is sent, not the + * change in value.) Since typical use of SLIP links is biased + * toward small packets (see comments on MTU/MSS below), changes + * use a variable length coding with one octet for numbers in the + * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the + * range 256 - 65535 or 0. (If the change in sequence number or + * ack is more than 65535, an uncompressed packet is sent.) + */ + +/* + * Packet types (must not conflict with IP protocol version) + * + * The top nibble of the first octet is the packet type. There are + * three possible types: IP (not proto TCP or tcp with one of the + * control flags set); uncompressed TCP (a normal IP/TCP packet but + * with the 8-bit protocol field replaced by an 8-bit connection id -- + * this type of packet syncs the sender & receiver); and compressed + * TCP (described above). + * + * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and + * is logically part of the 4-bit "changes" field that follows. Top + * three bits are actual packet type. For backward compatibility + * and in the interest of conserving bits, numbers are chosen so the + * IP protocol version number (4) which normally appears in this nibble + * means "IP packet". + */ + +/* packet types */ +#define TYPE_IP 0x40 +#define TYPE_UNCOMPRESSED_TCP 0x70 +#define TYPE_COMPRESSED_TCP 0x80 +#define TYPE_ERROR 0x00 + +/* Bits in first octet of compressed packet */ +#define NEW_C 0x40 /* flag bits for what changed in a packet */ +#define NEW_I 0x20 +#define NEW_S 0x08 +#define NEW_A 0x04 +#define NEW_W 0x02 +#define NEW_U 0x01 + +/* reserved, special-case values of above */ +#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ +#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ +#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) + +#define TCP_PUSH_BIT 0x10 + + +/* + * "state" data for each active tcp conversation on the wire. This is + * basically a copy of the entire IP/TCP header from the last packet + * we saw from the conversation together with a small identifier + * the transmit & receive ends of the line use to locate saved header. + */ +struct cstate { + struct cstate *cs_next; /* next most recently used cstate (xmit only) */ + u_short cs_hlen; /* size of hdr (receive only) */ + u_char cs_id; /* connection # associated with this state */ + u_char cs_filler; + union { + char csu_hdr[MAX_HDR]; + struct ip csu_ip; /* ip/tcp hdr from most recent packet */ + } slcs_u; +}; +#define cs_ip slcs_u.csu_ip +#define cs_hdr slcs_u.csu_hdr + +/* + * all the state data for one serial line (we need one of these + * per line). + */ +struct slcompress { + struct cstate *last_cs; /* most recently used tstate */ + u_char last_recv; /* last rcvd conn. id */ + u_char last_xmit; /* last sent conn. id */ + u_short flags; +#ifndef SL_NO_STATS + int sls_packets; /* outbound packets */ + int sls_compressed; /* outbound compressed packets */ + int sls_searches; /* searches for connection state */ + int sls_misses; /* times couldn't find conn. state */ + int sls_uncompressedin; /* inbound uncompressed packets */ + int sls_compressedin; /* inbound compressed packets */ + int sls_errorin; /* inbound unknown type packets */ + int sls_tossed; /* inbound packets tossed because of error */ +#endif + struct cstate tstate[MAX_STATES]; /* xmit connection states */ + struct cstate rstate[MAX_STATES]; /* receive connection states */ +}; +/* flag values */ +#define SLF_TOSS 1 /* tossing rcvd frames because of input err */ + +extern void sl_compress_init(/* struct slcompress * */); +extern u_char sl_compress_tcp(/* struct mbuf *, struct ip *, + struct slcompress *, int compress_cid_flag */); +extern int sl_uncompress_tcp(/* u_char **, int, u_char, struct slcompress * */);