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 * 268c07a7b2SBrian Somers * $Id$ 278c07a7b2SBrian Somers * 288c07a7b2SBrian Somers */ 298c07a7b2SBrian Somers 308c07a7b2SBrian Somers 318c07a7b2SBrian Somers #define PHYSICAL_LINK 1 328c07a7b2SBrian Somers #define MP_LINK 2 338c07a7b2SBrian Somers 348c07a7b2SBrian Somers #define LINK_QUEUES (PRI_MAX + 1) 358c07a7b2SBrian Somers #define NPROTOSTAT 11 368c07a7b2SBrian Somers 378c07a7b2SBrian Somers struct link { 388c07a7b2SBrian Somers int type; /* _LINK type */ 398c07a7b2SBrian Somers const char *name; /* unique id per link type */ 408c07a7b2SBrian Somers int len; /* full size of parent struct */ 418c07a7b2SBrian Somers struct pppThroughput throughput; /* Link throughput statistics */ 428c07a7b2SBrian Somers struct pppTimer Timer; /* inactivity timeout */ 438c07a7b2SBrian Somers struct mqueue Queue[LINK_QUEUES]; /* Our output queue of mbufs */ 448c07a7b2SBrian Somers 458c07a7b2SBrian Somers u_long proto_in[NPROTOSTAT]; /* outgoing protocol stats */ 468c07a7b2SBrian Somers u_long proto_out[NPROTOSTAT]; /* incoming protocol stats */ 478c07a7b2SBrian Somers 488c07a7b2SBrian Somers /* Implementation routines for use by link_ routines */ 498c07a7b2SBrian Somers void (*StartOutput)(struct link *); /* send the queued data */ 508c07a7b2SBrian Somers int (*IsActive)(struct link *); /* Are we active ? */ 518c07a7b2SBrian Somers void (*Close)(struct link *, int); /* Close the link */ 528c07a7b2SBrian Somers }; 538c07a7b2SBrian Somers 548c07a7b2SBrian Somers extern void link_AddInOctets(struct link *, int); 558c07a7b2SBrian Somers extern void link_AddOutOctets(struct link *, int); 568c07a7b2SBrian Somers 578c07a7b2SBrian Somers extern void link_SequenceQueue(struct link *); 588c07a7b2SBrian Somers extern int link_QueueLen(struct link *); 598c07a7b2SBrian Somers extern struct mbuf *link_Dequeue(struct link *); 608c07a7b2SBrian Somers extern void link_Write(struct link *, int, const char *, int); 618c07a7b2SBrian Somers extern void link_StartOutput(struct link *); 628c07a7b2SBrian Somers extern void link_Output(struct link *, int, struct mbuf *); 638c07a7b2SBrian Somers 648c07a7b2SBrian Somers #define PROTO_IN 1 /* third arg to link_ProtocolRecord */ 658c07a7b2SBrian Somers #define PROTO_OUT 2 668c07a7b2SBrian Somers extern void link_ProtocolRecord(struct link *, u_short, int); 678c07a7b2SBrian Somers extern void link_ReportProtocolStatus(struct link *); 688c07a7b2SBrian Somers 698c07a7b2SBrian Somers extern int link_IsActive(struct link *); 708c07a7b2SBrian Somers extern void link_Close(struct link *, int); 71