bundle.h revision 56413
1319780Sdim/*- 2319780Sdim * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3353358Sdim * All rights reserved. 4353358Sdim * 5353358Sdim * Redistribution and use in source and binary forms, with or without 6319780Sdim * modification, are permitted provided that the following conditions 7319780Sdim * are met: 8319780Sdim * 1. Redistributions of source code must retain the above copyright 9319780Sdim * notice, this list of conditions and the following disclaimer. 10319780Sdim * 2. Redistributions in binary form must reproduce the above copyright 11319780Sdim * notice, this list of conditions and the following disclaimer in the 12319780Sdim * documentation and/or other materials provided with the distribution. 13319780Sdim * 14319780Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15319780Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16319780Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17319780Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18319780Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19319780Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20319780Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21319780Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22319780Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23319780Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24319780Sdim * SUCH DAMAGE. 25319780Sdim * 26319780Sdim * $FreeBSD: head/usr.sbin/ppp/bundle.h 56413 2000-01-23 01:48:19Z brian $ 27319780Sdim */ 28319780Sdim 29319780Sdim#define PHASE_DEAD 0 /* Link is dead */ 30319780Sdim#define PHASE_ESTABLISH 1 /* Establishing link */ 31319780Sdim#define PHASE_AUTHENTICATE 2 /* Being authenticated */ 32319780Sdim#define PHASE_NETWORK 3 /* We're alive ! */ 33319780Sdim#define PHASE_TERMINATE 4 /* Terminating link */ 34319780Sdim 35319780Sdim/* cfg.opt bit settings */ 36319780Sdim#define OPT_IDCHECK 0x0001 37319780Sdim#define OPT_IFACEALIAS 0x0002 38319780Sdim#define OPT_KEEPSESSION 0x0004 39319780Sdim#define OPT_LOOPBACK 0x0008 40319780Sdim#define OPT_PASSWDAUTH 0x0010 41319780Sdim#define OPT_PROXY 0x0020 42319780Sdim#define OPT_PROXYALL 0x0040 43319780Sdim#define OPT_SROUTES 0x0080 44319780Sdim#define OPT_THROUGHPUT 0x0100 45319780Sdim#define OPT_UTMP 0x0200 46319780Sdim 47319780Sdim#define MAX_ENDDISC_CLASS 5 48319780Sdim 49319780Sdim#define Enabled(b, o) ((b)->cfg.opt & (o)) 50319780Sdim 51319780Sdim/* AutoAdjust() values */ 52341825Sdim#define AUTO_UP 1 53341825Sdim#define AUTO_DOWN 2 54319780Sdim 55319780Sdimstruct sockaddr_un; 56319780Sdimstruct datalink; 57319780Sdimstruct physical; 58319780Sdimstruct link; 59319780Sdimstruct server; 60319780Sdimstruct prompt; 61319780Sdimstruct iface; 62319780Sdim 63319780Sdimstruct bundle { 64319780Sdim struct descriptor desc; /* really all our datalinks */ 65319780Sdim int unit; /* The device/interface unit number */ 66319780Sdim 67319780Sdim struct { 68319780Sdim char Name[20]; /* The /dev/XXXX name */ 69319780Sdim int fd; /* The /dev/XXXX descriptor */ 70319780Sdim unsigned header : 1; /* Family header sent & received ? */ 71319780Sdim } dev; 72319780Sdim 73319780Sdim u_long bandwidth; /* struct tuninfo speed */ 74319780Sdim struct iface *iface; /* Interface information */ 75319780Sdim 76319780Sdim int routing_seq; /* The current routing sequence number */ 77319780Sdim u_int phase; /* Curent phase */ 78319780Sdim 79319780Sdim struct { 80319780Sdim int all; /* Union of all physical::type's */ 81319780Sdim int open; /* Union of all open physical::type's */ 82319780Sdim } phys_type; 83319780Sdim 84319780Sdim unsigned CleaningUp : 1; /* Going to exit.... */ 85319780Sdim unsigned NatEnabled : 1; /* Are we using libalias ? */ 86319780Sdim 87319780Sdim struct fsm_parent fsm; /* Our callback functions */ 88319780Sdim struct datalink *links; /* Our data links */ 89319780Sdim 90319780Sdim time_t upat; /* When the link came up */ 91319780Sdim 92319780Sdim struct { 93319780Sdim struct { 94319780Sdim int timeout; /* NCP Idle timeout value */ 95319780Sdim int min_timeout; /* Don't idle out before this */ 96319780Sdim } idle; 97319780Sdim struct { 98319780Sdim char name[AUTHLEN]; /* PAP/CHAP system name */ 99319780Sdim char key[AUTHLEN]; /* PAP/CHAP key */ 100319780Sdim } auth; 101319780Sdim unsigned opt; /* Uses OPT_ bits from above */ 102319780Sdim char label[50]; /* last thing `load'ed */ 103319780Sdim u_short mtu; /* Interface mtu */ 104319780Sdim 105319780Sdim struct { 106319780Sdim int timeout; /* How long to leave the output queue choked */ 107319780Sdim } choked; 108319780Sdim } cfg; 109319780Sdim 110319780Sdim struct { 111319780Sdim struct ipcp ipcp; /* Our IPCP FSM */ 112319780Sdim struct mp mp; /* Our MP */ 113319780Sdim } ncp; 114319780Sdim 115319780Sdim struct { 116319780Sdim struct filter in; /* incoming packet filter */ 117319780Sdim struct filter out; /* outgoing packet filter */ 118319780Sdim struct filter dial; /* dial-out packet filter */ 119319780Sdim struct filter alive; /* keep-alive packet filter */ 120319780Sdim } filter; 121319780Sdim 122319780Sdim struct { 123319780Sdim struct pppTimer timer; /* timeout after cfg.idle_timeout */ 124319780Sdim time_t done; 125319780Sdim } idle; 126319780Sdim 127319780Sdim struct { 128319780Sdim int fd; /* write status here */ 129319780Sdim } notify; 130319780Sdim 131319780Sdim struct { 132319780Sdim struct pppTimer timer; /* choked output queue timer */ 133319780Sdim } choked; 134319780Sdim 135319780Sdim#ifndef NORADIUS 136319780Sdim struct radius radius; /* Info retrieved from radius server */ 137319780Sdim#endif 138319780Sdim}; 139319780Sdim 140319780Sdim#define descriptor2bundle(d) \ 141319780Sdim ((d)->type == BUNDLE_DESCRIPTOR ? (struct bundle *)(d) : NULL) 142319780Sdim 143319780Sdimextern struct bundle *bundle_Create(const char *, int, int); 144319780Sdimextern void bundle_Destroy(struct bundle *); 145319780Sdimextern const char *bundle_PhaseName(struct bundle *); 146319780Sdim#define bundle_Phase(b) ((b)->phase) 147319780Sdimextern void bundle_NewPhase(struct bundle *, u_int); 148319780Sdimextern void bundle_LinksRemoved(struct bundle *); 149319780Sdimextern int bundle_LinkIsUp(const struct bundle *); 150319780Sdimextern int bundle_SetRoute(struct bundle *, int, struct in_addr, 151319780Sdim struct in_addr, struct in_addr, int, int); 152319780Sdimextern void bundle_Close(struct bundle *, const char *, int); 153320041Sdimextern void bundle_Down(struct bundle *, int); 154320041Sdimextern void bundle_Open(struct bundle *, const char *, int, int); 155320041Sdimextern void bundle_LinkClosed(struct bundle *, struct datalink *); 156320041Sdim 157320041Sdimextern int bundle_ShowLinks(struct cmdargs const *); 158320041Sdimextern int bundle_ShowStatus(struct cmdargs const *); 159320041Sdimextern void bundle_StartIdleTimer(struct bundle *); 160320041Sdimextern void bundle_SetIdleTimer(struct bundle *, int, int); 161320041Sdimextern void bundle_StopIdleTimer(struct bundle *); 162320041Sdimextern int bundle_IsDead(struct bundle *); 163320041Sdimextern struct datalink *bundle2datalink(struct bundle *, const char *); 164320041Sdim 165319780Sdimextern void bundle_RegisterDescriptor(struct bundle *, struct descriptor *); 166319780Sdimextern void bundle_UnRegisterDescriptor(struct bundle *, struct descriptor *); 167319780Sdim 168319780Sdimextern void bundle_SetTtyCommandMode(struct bundle *, struct datalink *); 169319780Sdim 170319780Sdimextern int bundle_DatalinkClone(struct bundle *, struct datalink *, 171319780Sdim const char *); 172319780Sdimextern void bundle_DatalinkRemove(struct bundle *, struct datalink *); 173319780Sdimextern void bundle_CleanDatalinks(struct bundle *); 174319780Sdimextern void bundle_SetLabel(struct bundle *, const char *); 175319780Sdimextern const char *bundle_GetLabel(struct bundle *); 176319780Sdimextern void bundle_SendDatalink(struct datalink *, int, struct sockaddr_un *); 177319780Sdimextern int bundle_LinkSize(void); 178319780Sdimextern void bundle_ReceiveDatalink(struct bundle *, int); 179319780Sdimextern int bundle_SetMode(struct bundle *, struct datalink *, int); 180319780Sdimextern int bundle_RenameDatalink(struct bundle *, struct datalink *, 181319780Sdim const char *); 182319780Sdimextern void bundle_setsid(struct bundle *, int); 183319780Sdimextern void bundle_LockTun(struct bundle *); 184319780Sdimextern int bundle_HighestState(struct bundle *); 185319780Sdimextern int bundle_Exception(struct bundle *, int); 186319780Sdimextern void bundle_AdjustFilters(struct bundle *, struct in_addr *, 187319780Sdim struct in_addr *); 188319780Sdimextern void bundle_CalculateBandwidth(struct bundle *); 189319780Sdimextern void bundle_AutoAdjust(struct bundle *, int, int); 190319780Sdimextern int bundle_WantAutoloadTimer(struct bundle *); 191319780Sdimextern void bundle_ChangedPID(struct bundle *); 192319780Sdim