xref: /freebsd/usr.sbin/ppp/link.h (revision 5d9e6103663c28d3986c674a772142f29e6584be)
18c07a7b2SBrian Somers /*-
28c07a7b2SBrian Somers  * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
38c07a7b2SBrian Somers  * All rights reserved.
48c07a7b2SBrian Somers  *
58c07a7b2SBrian Somers  * Redistribution and use in source and binary forms, with or without
68c07a7b2SBrian Somers  * modification, are permitted provided that the following conditions
78c07a7b2SBrian Somers  * are met:
88c07a7b2SBrian Somers  * 1. Redistributions of source code must retain the above copyright
98c07a7b2SBrian Somers  *    notice, this list of conditions and the following disclaimer.
108c07a7b2SBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
118c07a7b2SBrian Somers  *    notice, this list of conditions and the following disclaimer in the
128c07a7b2SBrian Somers  *    documentation and/or other materials provided with the distribution.
138c07a7b2SBrian Somers  *
148c07a7b2SBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
158c07a7b2SBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
168c07a7b2SBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
178c07a7b2SBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
188c07a7b2SBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
198c07a7b2SBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
208c07a7b2SBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
218c07a7b2SBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
228c07a7b2SBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
238c07a7b2SBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
248c07a7b2SBrian Somers  * SUCH DAMAGE.
258c07a7b2SBrian Somers  *
265d9e6103SBrian Somers  *  $Id: link.h,v 1.4 1998/08/25 17:48:42 brian Exp $
278c07a7b2SBrian Somers  *
288c07a7b2SBrian Somers  */
298c07a7b2SBrian Somers 
308c07a7b2SBrian Somers 
318c07a7b2SBrian Somers #define PHYSICAL_LINK	1
325d9e6103SBrian Somers #define LOGICAL_LINK	2
338c07a7b2SBrian Somers 
348c07a7b2SBrian Somers #define LINK_QUEUES (PRI_MAX + 1)
35ed32233cSBrian Somers #define NPROTOSTAT 13
368c07a7b2SBrian Somers 
37455aabc3SBrian Somers struct bundle;
38b6217683SBrian Somers struct prompt;
39455aabc3SBrian Somers 
408c07a7b2SBrian Somers struct link {
418c07a7b2SBrian Somers   int type;                               /* _LINK type */
4286b1f0d7SBrian Somers   const char *name;                       /* Points to datalink::name */
438c07a7b2SBrian Somers   int len;                                /* full size of parent struct */
448c07a7b2SBrian Somers   struct pppThroughput throughput;        /* Link throughput statistics */
458c07a7b2SBrian Somers   struct mqueue Queue[LINK_QUEUES];       /* Our output queue of mbufs */
468c07a7b2SBrian Somers 
478c07a7b2SBrian Somers   u_long proto_in[NPROTOSTAT];            /* outgoing protocol stats */
488c07a7b2SBrian Somers   u_long proto_out[NPROTOSTAT];           /* incoming protocol stats */
498c07a7b2SBrian Somers 
503b0f8d2eSBrian Somers   struct lcp lcp;                         /* Our line control FSM */
513b0f8d2eSBrian Somers   struct ccp ccp;                         /* Our compression FSM */
525d9e6103SBrian Somers 
535d9e6103SBrian Somers   struct layer const *layer[LAYER_MAX];   /* i/o layers */
545d9e6103SBrian Somers   int nlayers;
558c07a7b2SBrian Somers };
568c07a7b2SBrian Somers 
578c07a7b2SBrian Somers extern void link_AddInOctets(struct link *, int);
588c07a7b2SBrian Somers extern void link_AddOutOctets(struct link *, int);
598c07a7b2SBrian Somers 
608c07a7b2SBrian Somers extern void link_SequenceQueue(struct link *);
616f8e9f0aSBrian Somers extern void link_DeleteQueue(struct link *);
628c07a7b2SBrian Somers extern int link_QueueLen(struct link *);
633b0f8d2eSBrian Somers extern int link_QueueBytes(struct link *);
648c07a7b2SBrian Somers extern struct mbuf *link_Dequeue(struct link *);
655d9e6103SBrian Somers 
665d9e6103SBrian Somers extern void link_PushPacket(struct link *, struct mbuf *, struct bundle *,
675d9e6103SBrian Somers                             int, u_short);
685d9e6103SBrian Somers extern void link_PullPacket(struct link *, char *, size_t, struct bundle *);
695d9e6103SBrian Somers extern int link_Stack(struct link *, struct layer *);
705d9e6103SBrian Somers extern void link_EmptyStack(struct link *);
718c07a7b2SBrian Somers 
728c07a7b2SBrian Somers #define PROTO_IN  1                       /* third arg to link_ProtocolRecord */
738c07a7b2SBrian Somers #define PROTO_OUT 2
748c07a7b2SBrian Somers extern void link_ProtocolRecord(struct link *, u_short, int);
75b6217683SBrian Somers extern void link_ReportProtocolStatus(struct link *, struct prompt *);
76