xref: /freebsd/usr.sbin/ppp/mp.h (revision 673903ec42f3019f33a1221bf37205d248f26f5b)
13b0f8d2eSBrian Somers /*-
23b0f8d2eSBrian Somers  * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
33b0f8d2eSBrian Somers  * All rights reserved.
43b0f8d2eSBrian Somers  *
53b0f8d2eSBrian Somers  * Redistribution and use in source and binary forms, with or without
63b0f8d2eSBrian Somers  * modification, are permitted provided that the following conditions
73b0f8d2eSBrian Somers  * are met:
83b0f8d2eSBrian Somers  * 1. Redistributions of source code must retain the above copyright
93b0f8d2eSBrian Somers  *    notice, this list of conditions and the following disclaimer.
103b0f8d2eSBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
113b0f8d2eSBrian Somers  *    notice, this list of conditions and the following disclaimer in the
123b0f8d2eSBrian Somers  *    documentation and/or other materials provided with the distribution.
133b0f8d2eSBrian Somers  *
143b0f8d2eSBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
153b0f8d2eSBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
163b0f8d2eSBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
173b0f8d2eSBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
183b0f8d2eSBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
193b0f8d2eSBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
203b0f8d2eSBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
213b0f8d2eSBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
223b0f8d2eSBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
233b0f8d2eSBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
243b0f8d2eSBrian Somers  * SUCH DAMAGE.
253b0f8d2eSBrian Somers  *
26673903ecSBrian Somers  *	$Id: mp.h,v 1.1.2.3 1998/04/23 03:23:00 brian Exp $
273b0f8d2eSBrian Somers  */
283b0f8d2eSBrian Somers 
292764b86aSBrian Somers struct mbuf;
302764b86aSBrian Somers struct physical;
312764b86aSBrian Somers struct bundle;
322764b86aSBrian Somers struct cmdargs;
332764b86aSBrian Somers 
343b0f8d2eSBrian Somers struct mp {
353b0f8d2eSBrian Somers   struct link link;
363b0f8d2eSBrian Somers 
373b0f8d2eSBrian Somers   unsigned active : 1;
3849052c95SBrian Somers   unsigned peer_is12bit : 1;        /* 12 / 24bit seq nos */
3949052c95SBrian Somers   unsigned local_is12bit : 1;
4049052c95SBrian Somers   u_short peer_mrru;
4149052c95SBrian Somers   u_short local_mrru;
4249052c95SBrian Somers 
4349052c95SBrian Somers   struct {
4449052c95SBrian Somers     u_char class;
4549052c95SBrian Somers     char address[50];
4649052c95SBrian Somers     int len;
4749052c95SBrian Somers   } peer_enddisc;             /* peers endpoint discriminator */
483b0f8d2eSBrian Somers 
493b0f8d2eSBrian Somers   struct {
503b0f8d2eSBrian Somers     u_int32_t out;            /* next outgoing seq */
513b0f8d2eSBrian Somers     u_int32_t min_in;         /* minimum received incoming seq */
523b0f8d2eSBrian Somers     u_int32_t next_in;        /* next incoming seq to process */
533b0f8d2eSBrian Somers   } seq;
5449052c95SBrian Somers 
5549052c95SBrian Somers   struct {
5649052c95SBrian Somers     u_short mrru;             /* Max Reconstructed Receive Unit */
5749052c95SBrian Somers     unsigned shortseq : 2;    /* I want short Sequence Numbers */
5849052c95SBrian Somers     struct {
5949052c95SBrian Somers       u_char class;
6049052c95SBrian Somers       char address[50];
6149052c95SBrian Somers       int len;
6249052c95SBrian Somers     } enddisc;                /* endpoint discriminator */
6349052c95SBrian Somers   } cfg;
6449052c95SBrian Somers 
653b0f8d2eSBrian Somers   struct mbuf *inbufs;        /* Received fragments */
663b0f8d2eSBrian Somers   struct fsm_parent fsmp;     /* Our callback functions */
6749052c95SBrian Somers   struct bundle *bundle;      /* Parent */
683b0f8d2eSBrian Somers };
693b0f8d2eSBrian Somers 
703b0f8d2eSBrian Somers struct mp_link {
713b0f8d2eSBrian Somers   u_int32_t seq;              /* 12 or 24 bit incoming seq */
723b0f8d2eSBrian Somers   int weight;                 /* bytes to send with each write */
733b0f8d2eSBrian Somers };
743b0f8d2eSBrian Somers 
753b0f8d2eSBrian Somers struct mp_header {
763b0f8d2eSBrian Somers   unsigned begin : 1;
773b0f8d2eSBrian Somers   unsigned end : 1;
783b0f8d2eSBrian Somers   u_int32_t seq;
793b0f8d2eSBrian Somers };
803b0f8d2eSBrian Somers 
813b0f8d2eSBrian Somers extern void mp_Init(struct mp *, struct bundle *);
823b0f8d2eSBrian Somers extern void mp_linkInit(struct mp_link *);
8349052c95SBrian Somers extern int mp_Up(struct mp *, u_short, u_short, int, int);
84673903ecSBrian Somers extern void mp_Down(struct mp *);
853b0f8d2eSBrian Somers extern void mp_Input(struct mp *, struct mbuf *, struct physical *);
863b0f8d2eSBrian Somers extern int mp_FillQueues(struct bundle *);
873b0f8d2eSBrian Somers extern int mp_SetDatalinkWeight(struct cmdargs const *);
8849052c95SBrian Somers extern int mp_ShowStatus(struct cmdargs const *);
8949052c95SBrian Somers extern const char *mp_Enddisc(u_char, const char *, int);
9049052c95SBrian Somers extern int mp_SetEnddisc(struct cmdargs const *);
91