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 * 2697d92980SPeter Wemm * $FreeBSD$ 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 */ 448c07a7b2SBrian Somers struct pppThroughput throughput; /* Link throughput statistics */ 45442f8495SBrian Somers struct mqueue Queue[2]; /* 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 57442f8495SBrian Somers #define LINK_QUEUES(link) (sizeof (link)->Queue / sizeof (link)->Queue[0]) 58442f8495SBrian Somers #define LINK_HIGHQ(link) ((link)->Queue + LINK_QUEUES(link) - 1) 59442f8495SBrian Somers 608c07a7b2SBrian Somers extern void link_AddInOctets(struct link *, int); 618c07a7b2SBrian Somers extern void link_AddOutOctets(struct link *, int); 628c07a7b2SBrian Somers 638c07a7b2SBrian Somers extern void link_SequenceQueue(struct link *); 646f8e9f0aSBrian Somers extern void link_DeleteQueue(struct link *); 6526af0ae9SBrian Somers extern size_t link_QueueLen(struct link *); 6626af0ae9SBrian Somers extern size_t link_QueueBytes(struct link *); 678c07a7b2SBrian Somers extern struct mbuf *link_Dequeue(struct link *); 685d9e6103SBrian Somers 695d9e6103SBrian Somers extern void link_PushPacket(struct link *, struct mbuf *, struct bundle *, 705d9e6103SBrian Somers int, u_short); 715d9e6103SBrian Somers extern void link_PullPacket(struct link *, char *, size_t, struct bundle *); 725d9e6103SBrian Somers extern int link_Stack(struct link *, struct layer *); 735d9e6103SBrian Somers extern void link_EmptyStack(struct link *); 748c07a7b2SBrian Somers 758c07a7b2SBrian Somers #define PROTO_IN 1 /* third arg to link_ProtocolRecord */ 768c07a7b2SBrian Somers #define PROTO_OUT 2 778c07a7b2SBrian Somers extern void link_ProtocolRecord(struct link *, u_short, int); 78b6217683SBrian Somers extern void link_ReportProtocolStatus(struct link *, struct prompt *); 794faec430SBrian Somers extern int link_ShowLayers(struct cmdargs const *); 80