xref: /freebsd/usr.sbin/ppp/mp.h (revision 086760227f4a61242f39a1773af00d9299b6ad34)
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  *
2608676022SBrian Somers  *	$Id: mp.h,v 1.1.2.4 1998/04/23 21:50:13 brian Exp $
273b0f8d2eSBrian Somers  */
283b0f8d2eSBrian Somers 
292764b86aSBrian Somers struct mbuf;
302764b86aSBrian Somers struct physical;
312764b86aSBrian Somers struct bundle;
322764b86aSBrian Somers struct cmdargs;
332764b86aSBrian Somers 
3408676022SBrian Somers #define ENDDISC_NULL	0
3508676022SBrian Somers #define ENDDISC_LOCAL	1
3608676022SBrian Somers #define ENDDISC_IP	2
3708676022SBrian Somers #define ENDDISC_MAC	3
3808676022SBrian Somers #define ENDDISC_MAGIC	4
3908676022SBrian Somers #define ENDDISC_PSN	5
4008676022SBrian Somers 
413b0f8d2eSBrian Somers struct mp {
423b0f8d2eSBrian Somers   struct link link;
433b0f8d2eSBrian Somers 
443b0f8d2eSBrian Somers   unsigned active : 1;
4549052c95SBrian Somers   unsigned peer_is12bit : 1;        /* 12 / 24bit seq nos */
4649052c95SBrian Somers   unsigned local_is12bit : 1;
4749052c95SBrian Somers   u_short peer_mrru;
4849052c95SBrian Somers   u_short local_mrru;
4949052c95SBrian Somers 
5049052c95SBrian Somers   struct {
5149052c95SBrian Somers     u_char class;
5249052c95SBrian Somers     char address[50];
5349052c95SBrian Somers     int len;
5449052c95SBrian Somers   } peer_enddisc;             /* peers endpoint discriminator */
553b0f8d2eSBrian Somers 
563b0f8d2eSBrian Somers   struct {
573b0f8d2eSBrian Somers     u_int32_t out;            /* next outgoing seq */
583b0f8d2eSBrian Somers     u_int32_t min_in;         /* minimum received incoming seq */
593b0f8d2eSBrian Somers     u_int32_t next_in;        /* next incoming seq to process */
603b0f8d2eSBrian Somers   } seq;
6149052c95SBrian Somers 
6249052c95SBrian Somers   struct {
6349052c95SBrian Somers     u_short mrru;             /* Max Reconstructed Receive Unit */
6449052c95SBrian Somers     unsigned shortseq : 2;    /* I want short Sequence Numbers */
6549052c95SBrian Somers     struct {
6649052c95SBrian Somers       u_char class;
6749052c95SBrian Somers       char address[50];
6849052c95SBrian Somers       int len;
6949052c95SBrian Somers     } enddisc;                /* endpoint discriminator */
7049052c95SBrian Somers   } cfg;
7149052c95SBrian Somers 
723b0f8d2eSBrian Somers   struct mbuf *inbufs;        /* Received fragments */
733b0f8d2eSBrian Somers   struct fsm_parent fsmp;     /* Our callback functions */
7449052c95SBrian Somers   struct bundle *bundle;      /* Parent */
753b0f8d2eSBrian Somers };
763b0f8d2eSBrian Somers 
773b0f8d2eSBrian Somers struct mp_link {
783b0f8d2eSBrian Somers   u_int32_t seq;              /* 12 or 24 bit incoming seq */
793b0f8d2eSBrian Somers   int weight;                 /* bytes to send with each write */
803b0f8d2eSBrian Somers };
813b0f8d2eSBrian Somers 
823b0f8d2eSBrian Somers struct mp_header {
833b0f8d2eSBrian Somers   unsigned begin : 1;
843b0f8d2eSBrian Somers   unsigned end : 1;
853b0f8d2eSBrian Somers   u_int32_t seq;
863b0f8d2eSBrian Somers };
873b0f8d2eSBrian Somers 
883b0f8d2eSBrian Somers extern void mp_Init(struct mp *, struct bundle *);
893b0f8d2eSBrian Somers extern void mp_linkInit(struct mp_link *);
9049052c95SBrian Somers extern int mp_Up(struct mp *, u_short, u_short, int, int);
91673903ecSBrian Somers extern void mp_Down(struct mp *);
923b0f8d2eSBrian Somers extern void mp_Input(struct mp *, struct mbuf *, struct physical *);
933b0f8d2eSBrian Somers extern int mp_FillQueues(struct bundle *);
943b0f8d2eSBrian Somers extern int mp_SetDatalinkWeight(struct cmdargs const *);
9549052c95SBrian Somers extern int mp_ShowStatus(struct cmdargs const *);
9649052c95SBrian Somers extern const char *mp_Enddisc(u_char, const char *, int);
9749052c95SBrian Somers extern int mp_SetEnddisc(struct cmdargs const *);
98