136285Sbrian/*- 236285Sbrian * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 336285Sbrian * All rights reserved. 436285Sbrian * 536285Sbrian * Redistribution and use in source and binary forms, with or without 636285Sbrian * modification, are permitted provided that the following conditions 736285Sbrian * are met: 836285Sbrian * 1. Redistributions of source code must retain the above copyright 936285Sbrian * notice, this list of conditions and the following disclaimer. 1036285Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1136285Sbrian * notice, this list of conditions and the following disclaimer in the 1236285Sbrian * documentation and/or other materials provided with the distribution. 1336285Sbrian * 1436285Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1536285Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1636285Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1736285Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1836285Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1936285Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2036285Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2136285Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2236285Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2336285Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2436285Sbrian * SUCH DAMAGE. 2536285Sbrian * 2650479Speter * $FreeBSD: releng/11.0/usr.sbin/ppp/link.h 131327 2004-06-30 12:24:56Z brian $ 2736285Sbrian * 2836285Sbrian */ 2936285Sbrian 3036285Sbrian 3146686Sbrian#define PHYSICAL_LINK 1 3246686Sbrian#define LOGICAL_LINK 2 3336285Sbrian 3436285Sbrian#define NPROTOSTAT 13 3536285Sbrian 3636285Sbrianstruct bundle; 3736285Sbrianstruct prompt; 3847211Sbrianstruct cmdargs; 3936285Sbrian 4036285Sbrianstruct link { 4136285Sbrian int type; /* _LINK type */ 4236312Sbrian const char *name; /* Points to datalink::name */ 4336285Sbrian int len; /* full size of parent struct */ 4464652Sbrian struct { 4564652Sbrian unsigned gather : 1; /* Gather statistics ourself ? */ 4664652Sbrian struct pppThroughput total; /* Link throughput statistics */ 4764652Sbrian struct pppThroughput *parent; /* MP link throughput statistics */ 4864652Sbrian } stats; 4950867Sbrian struct mqueue Queue[2]; /* Our output queue of mbufs */ 5036285Sbrian 5136285Sbrian u_long proto_in[NPROTOSTAT]; /* outgoing protocol stats */ 5236285Sbrian u_long proto_out[NPROTOSTAT]; /* incoming protocol stats */ 5336285Sbrian 5436285Sbrian struct lcp lcp; /* Our line control FSM */ 5536285Sbrian struct ccp ccp; /* Our compression FSM */ 5646686Sbrian 5746686Sbrian struct layer const *layer[LAYER_MAX]; /* i/o layers */ 5846686Sbrian int nlayers; 5936285Sbrian}; 6036285Sbrian 6150867Sbrian#define LINK_QUEUES(link) (sizeof (link)->Queue / sizeof (link)->Queue[0]) 6250867Sbrian#define LINK_HIGHQ(link) ((link)->Queue + LINK_QUEUES(link) - 1) 6350867Sbrian 6436285Sbrianextern void link_SequenceQueue(struct link *); 6538544Sbrianextern void link_DeleteQueue(struct link *); 6654912Sbrianextern size_t link_QueueLen(struct link *); 6754912Sbrianextern size_t link_QueueBytes(struct link *); 68131327Sbrianextern void link_PendingLowPriorityData(struct link *, size_t *, size_t *); 6936285Sbrianextern struct mbuf *link_Dequeue(struct link *); 7036285Sbrian 7146686Sbrianextern void link_PushPacket(struct link *, struct mbuf *, struct bundle *, 7246686Sbrian int, u_short); 7346686Sbrianextern void link_PullPacket(struct link *, char *, size_t, struct bundle *); 7446686Sbrianextern int link_Stack(struct link *, struct layer *); 7546686Sbrianextern void link_EmptyStack(struct link *); 7646686Sbrian 7736285Sbrian#define PROTO_IN 1 /* third arg to link_ProtocolRecord */ 7836285Sbrian#define PROTO_OUT 2 7936285Sbrianextern void link_ProtocolRecord(struct link *, u_short, int); 8036285Sbrianextern void link_ReportProtocolStatus(struct link *, struct prompt *); 8147211Sbrianextern int link_ShowLayers(struct cmdargs const *); 82