1706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh/*- 2706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * All rights reserved. 4706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 5706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * Redistribution and use in source and binary forms, with or without 6706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * modification, are permitted provided that the following conditions 7706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * are met: 8706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 1. Redistributions of source code must retain the above copyright 9706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * notice, this list of conditions and the following disclaimer. 10706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 2. Redistributions in binary form must reproduce the above copyright 11706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * notice, this list of conditions and the following disclaimer in the 12706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * documentation and/or other materials provided with the distribution. 13706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 14706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * SUCH DAMAGE. 25706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 26706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * $FreeBSD: src/usr.sbin/ppp/link.h,v 1.11.34.1 2010/12/21 17:10:29 kensmith Exp $ 27706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh * 28706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh */ 29706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 30706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 31706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define PHYSICAL_LINK 1 32706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define LOGICAL_LINK 2 33706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 34706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define NPROTOSTAT 13 35706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 36706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct bundle; 37706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct prompt; 38706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct cmdargs; 39706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 40706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehstruct link { 41706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh int type; /* _LINK type */ 42706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh const char *name; /* Points to datalink::name */ 43706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh int len; /* full size of parent struct */ 44706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct { 45706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh unsigned gather : 1; /* Gather statistics ourself ? */ 46706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct pppThroughput total; /* Link throughput statistics */ 47706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct pppThroughput *parent; /* MP link throughput statistics */ 48706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh } stats; 49706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct mqueue Queue[2]; /* Our output queue of mbufs */ 50706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 51706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh u_long proto_in[NPROTOSTAT]; /* outgoing protocol stats */ 52706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh u_long proto_out[NPROTOSTAT]; /* incoming protocol stats */ 53706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 54706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct lcp lcp; /* Our line control FSM */ 55706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct ccp ccp; /* Our compression FSM */ 56706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 57706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh struct layer const *layer[LAYER_MAX]; /* i/o layers */ 58706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh int nlayers; 59706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh}; 60706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 61706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define LINK_QUEUES(link) (sizeof (link)->Queue / sizeof (link)->Queue[0]) 62706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define LINK_HIGHQ(link) ((link)->Queue + LINK_QUEUES(link) - 1) 63706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 64706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void link_SequenceQueue(struct link *); 65706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void link_DeleteQueue(struct link *); 66706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern size_t link_QueueLen(struct link *); 67706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern size_t link_QueueBytes(struct link *); 68706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void link_PendingLowPriorityData(struct link *, size_t *, size_t *); 69706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern struct mbuf *link_Dequeue(struct link *); 70706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 71706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void link_PushPacket(struct link *, struct mbuf *, struct bundle *, 72706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh int, u_short); 73706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void link_PullPacket(struct link *, char *, size_t, struct bundle *); 74706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern int link_Stack(struct link *, struct layer *); 75706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void link_EmptyStack(struct link *); 76706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh 77706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define PROTO_IN 1 /* third arg to link_ProtocolRecord */ 78706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yeh#define PROTO_OUT 2 79706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void link_ProtocolRecord(struct link *, u_short, int); 80706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern void link_ReportProtocolStatus(struct link *, struct prompt *); 81706e567fc5ff6b79738a5f470e5aa7b2cae76459Chia-chi Yehextern int link_ShowLayers(struct cmdargs const *); 82