18c07a7b2SBrian Somers /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 31de7b4b8SPedro F. Giffuni * 48c07a7b2SBrian Somers * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 58c07a7b2SBrian Somers * All rights reserved. 68c07a7b2SBrian Somers * 78c07a7b2SBrian Somers * Redistribution and use in source and binary forms, with or without 88c07a7b2SBrian Somers * modification, are permitted provided that the following conditions 98c07a7b2SBrian Somers * are met: 108c07a7b2SBrian Somers * 1. Redistributions of source code must retain the above copyright 118c07a7b2SBrian Somers * notice, this list of conditions and the following disclaimer. 128c07a7b2SBrian Somers * 2. Redistributions in binary form must reproduce the above copyright 138c07a7b2SBrian Somers * notice, this list of conditions and the following disclaimer in the 148c07a7b2SBrian Somers * documentation and/or other materials provided with the distribution. 158c07a7b2SBrian Somers * 168c07a7b2SBrian Somers * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 178c07a7b2SBrian Somers * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 188c07a7b2SBrian Somers * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 198c07a7b2SBrian Somers * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 208c07a7b2SBrian Somers * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 218c07a7b2SBrian Somers * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 228c07a7b2SBrian Somers * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 238c07a7b2SBrian Somers * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 248c07a7b2SBrian Somers * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 258c07a7b2SBrian Somers * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 268c07a7b2SBrian Somers * SUCH DAMAGE. 278c07a7b2SBrian Somers * 288c07a7b2SBrian Somers */ 298c07a7b2SBrian Somers 308c07a7b2SBrian Somers 318c07a7b2SBrian Somers #define PHYSICAL_LINK 1 325d9e6103SBrian Somers #define LOGICAL_LINK 2 338c07a7b2SBrian Somers 34ed32233cSBrian Somers #define NPROTOSTAT 13 358c07a7b2SBrian Somers 36455aabc3SBrian Somers struct bundle; 37b6217683SBrian Somers struct prompt; 384faec430SBrian Somers struct cmdargs; 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 */ 4411572abfSBrian Somers struct { 4511572abfSBrian Somers unsigned gather : 1; /* Gather statistics ourself ? */ 4611572abfSBrian Somers struct pppThroughput total; /* Link throughput statistics */ 4711572abfSBrian Somers struct pppThroughput *parent; /* MP link throughput statistics */ 4811572abfSBrian Somers } stats; 49442f8495SBrian Somers struct mqueue Queue[2]; /* Our output queue of mbufs */ 508c07a7b2SBrian Somers 518c07a7b2SBrian Somers u_long proto_in[NPROTOSTAT]; /* outgoing protocol stats */ 528c07a7b2SBrian Somers u_long proto_out[NPROTOSTAT]; /* incoming protocol stats */ 538c07a7b2SBrian Somers 543b0f8d2eSBrian Somers struct lcp lcp; /* Our line control FSM */ 553b0f8d2eSBrian Somers struct ccp ccp; /* Our compression FSM */ 565d9e6103SBrian Somers 575d9e6103SBrian Somers struct layer const *layer[LAYER_MAX]; /* i/o layers */ 585d9e6103SBrian Somers int nlayers; 598c07a7b2SBrian Somers }; 608c07a7b2SBrian Somers 61442f8495SBrian Somers #define LINK_QUEUES(link) (sizeof (link)->Queue / sizeof (link)->Queue[0]) 62442f8495SBrian Somers #define LINK_HIGHQ(link) ((link)->Queue + LINK_QUEUES(link) - 1) 63442f8495SBrian Somers 648c07a7b2SBrian Somers extern void link_SequenceQueue(struct link *); 656f8e9f0aSBrian Somers extern void link_DeleteQueue(struct link *); 6626af0ae9SBrian Somers extern size_t link_QueueLen(struct link *); 6726af0ae9SBrian Somers extern size_t link_QueueBytes(struct link *); 68a57095e7SBrian Somers extern void link_PendingLowPriorityData(struct link *, size_t *, size_t *); 698c07a7b2SBrian Somers extern struct mbuf *link_Dequeue(struct link *); 705d9e6103SBrian Somers 715d9e6103SBrian Somers extern void link_PushPacket(struct link *, struct mbuf *, struct bundle *, 725d9e6103SBrian Somers int, u_short); 735d9e6103SBrian Somers extern void link_PullPacket(struct link *, char *, size_t, struct bundle *); 745d9e6103SBrian Somers extern int link_Stack(struct link *, struct layer *); 755d9e6103SBrian Somers extern void link_EmptyStack(struct link *); 768c07a7b2SBrian Somers 778c07a7b2SBrian Somers #define PROTO_IN 1 /* third arg to link_ProtocolRecord */ 788c07a7b2SBrian Somers #define PROTO_OUT 2 798c07a7b2SBrian Somers extern void link_ProtocolRecord(struct link *, u_short, int); 80b6217683SBrian Somers extern void link_ReportProtocolStatus(struct link *, struct prompt *); 814faec430SBrian Somers extern int link_ShowLayers(struct cmdargs const *); 82