bundle.h revision 116588
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: head/usr.sbin/ppp/bundle.h 116588 2003-06-19 18:55:49Z ume $ 2736285Sbrian */ 2836285Sbrian 2936285Sbrian#define PHASE_DEAD 0 /* Link is dead */ 3036285Sbrian#define PHASE_ESTABLISH 1 /* Establishing link */ 3136285Sbrian#define PHASE_AUTHENTICATE 2 /* Being authenticated */ 3236285Sbrian#define PHASE_NETWORK 3 /* We're alive ! */ 3336285Sbrian#define PHASE_TERMINATE 4 /* Terminating link */ 3436285Sbrian 3536285Sbrian/* cfg.opt bit settings */ 36112659Sbrian#define OPT_FILTERDECAP 0x0001 37112659Sbrian#define OPT_FORCE_SCRIPTS 0x0002 /* force chat scripts */ 38112659Sbrian#define OPT_IDCHECK 0x0004 39112659Sbrian#define OPT_IFACEALIAS 0x0008 4081634Sbrian#ifndef NOINET6 41112659Sbrian#define OPT_IPCP 0x0010 42112659Sbrian#define OPT_IPV6CP 0x0020 4381634Sbrian#endif 44112659Sbrian#define OPT_KEEPSESSION 0x0040 45112659Sbrian#define OPT_LOOPBACK 0x0080 46112659Sbrian#define OPT_PASSWDAUTH 0x0100 47112659Sbrian#define OPT_PROXY 0x0200 48112659Sbrian#define OPT_PROXYALL 0x0400 49112659Sbrian#define OPT_SROUTES 0x0800 50112659Sbrian#define OPT_TCPMSSFIXUP 0x1000 51112659Sbrian#define OPT_THROUGHPUT 0x2000 52112659Sbrian#define OPT_UTMP 0x4000 5336285Sbrian 5436285Sbrian#define MAX_ENDDISC_CLASS 5 5536285Sbrian 5636285Sbrian#define Enabled(b, o) ((b)->cfg.opt & (o)) 5736285Sbrian 5849434Sbrian/* AutoAdjust() values */ 5949434Sbrian#define AUTO_UP 1 6049434Sbrian#define AUTO_DOWN 2 6149434Sbrian 6236285Sbrianstruct sockaddr_un; 6336285Sbrianstruct datalink; 6436285Sbrianstruct physical; 6536285Sbrianstruct link; 6636285Sbrianstruct server; 6736285Sbrianstruct prompt; 6840561Sbrianstruct iface; 6936285Sbrian 7036285Sbrianstruct bundle { 7158040Sbrian struct fdescriptor desc; /* really all our datalinks */ 7236285Sbrian int unit; /* The device/interface unit number */ 7336285Sbrian 7436285Sbrian struct { 7536285Sbrian char Name[20]; /* The /dev/XXXX name */ 7658038Sbrian int fd; /* The /dev/XXXX descriptor */ 7756413Sbrian unsigned header : 1; /* Family header sent & received ? */ 7836285Sbrian } dev; 7936285Sbrian 8049434Sbrian u_long bandwidth; /* struct tuninfo speed */ 8140561Sbrian struct iface *iface; /* Interface information */ 8240561Sbrian 8336285Sbrian int routing_seq; /* The current routing sequence number */ 8436285Sbrian u_int phase; /* Curent phase */ 8536285Sbrian 8636928Sbrian struct { 8736928Sbrian int all; /* Union of all physical::type's */ 8836928Sbrian int open; /* Union of all open physical::type's */ 8936928Sbrian } phys_type; 9036928Sbrian 9136285Sbrian unsigned CleaningUp : 1; /* Going to exit.... */ 9250059Sbrian unsigned NatEnabled : 1; /* Are we using libalias ? */ 9336285Sbrian 9436285Sbrian struct fsm_parent fsm; /* Our callback functions */ 9536285Sbrian struct datalink *links; /* Our data links */ 9636285Sbrian 9749978Sbrian time_t upat; /* When the link came up */ 9849978Sbrian 9936285Sbrian struct { 10036285Sbrian struct { 10149978Sbrian int timeout; /* NCP Idle timeout value */ 10249978Sbrian int min_timeout; /* Don't idle out before this */ 10349978Sbrian } idle; 10449978Sbrian struct { 10543313Sbrian char name[AUTHLEN]; /* PAP/CHAP system name */ 10643313Sbrian char key[AUTHLEN]; /* PAP/CHAP key */ 10736285Sbrian } auth; 10836285Sbrian unsigned opt; /* Uses OPT_ bits from above */ 10936285Sbrian char label[50]; /* last thing `load'ed */ 11061534Sbrian u_short ifqueue; /* Interface queue size */ 11136285Sbrian 11238544Sbrian struct { 11343313Sbrian int timeout; /* How long to leave the output queue choked */ 11438544Sbrian } choked; 11536285Sbrian } cfg; 11636285Sbrian 11781634Sbrian struct ncp ncp; 11836285Sbrian 11936285Sbrian struct { 12043313Sbrian struct filter in; /* incoming packet filter */ 12143313Sbrian struct filter out; /* outgoing packet filter */ 12243313Sbrian struct filter dial; /* dial-out packet filter */ 12343313Sbrian struct filter alive; /* keep-alive packet filter */ 12436285Sbrian } filter; 12536285Sbrian 12636285Sbrian struct { 12743313Sbrian struct pppTimer timer; /* timeout after cfg.idle_timeout */ 12836285Sbrian time_t done; 12936285Sbrian } idle; 13036285Sbrian 13196153Sbrian#ifndef NORADIUS 13236285Sbrian struct { 13396153Sbrian struct pppTimer timer; 13496153Sbrian time_t done; 13596153Sbrian } session; 13696153Sbrian#endif 13796153Sbrian 13896153Sbrian struct { 13943313Sbrian int fd; /* write status here */ 14036285Sbrian } notify; 14136285Sbrian 14236285Sbrian struct { 14343313Sbrian struct pppTimer timer; /* choked output queue timer */ 14438544Sbrian } choked; 14543313Sbrian 14643313Sbrian#ifndef NORADIUS 14743313Sbrian struct radius radius; /* Info retrieved from radius server */ 14865178Sbrian struct radacct radacct; 149116588Sume#ifndef NOINET6 150116588Sume struct radacct radacct6; 15143313Sbrian#endif 152116588Sume#endif 15336285Sbrian}; 15436285Sbrian 15536285Sbrian#define descriptor2bundle(d) \ 15636285Sbrian ((d)->type == BUNDLE_DESCRIPTOR ? (struct bundle *)(d) : NULL) 15736285Sbrian 15853298Sbrianextern struct bundle *bundle_Create(const char *, int, int); 15936285Sbrianextern void bundle_Destroy(struct bundle *); 16036285Sbrianextern const char *bundle_PhaseName(struct bundle *); 16136285Sbrian#define bundle_Phase(b) ((b)->phase) 16236285Sbrianextern void bundle_NewPhase(struct bundle *, u_int); 16338174Sbrianextern void bundle_LinksRemoved(struct bundle *); 16436285Sbrianextern void bundle_Close(struct bundle *, const char *, int); 16537018Sbrianextern void bundle_Down(struct bundle *, int); 16637955Sbrianextern void bundle_Open(struct bundle *, const char *, int, int); 16736285Sbrianextern void bundle_LinkClosed(struct bundle *, struct datalink *); 16836285Sbrian 16936285Sbrianextern int bundle_ShowLinks(struct cmdargs const *); 17036285Sbrianextern int bundle_ShowStatus(struct cmdargs const *); 17162977Sbrianextern void bundle_StartIdleTimer(struct bundle *, unsigned secs); 17249978Sbrianextern void bundle_SetIdleTimer(struct bundle *, int, int); 17336285Sbrianextern void bundle_StopIdleTimer(struct bundle *); 17436285Sbrianextern int bundle_IsDead(struct bundle *); 17536285Sbrianextern struct datalink *bundle2datalink(struct bundle *, const char *); 17636285Sbrian 17796153Sbrian#ifndef NORADIUS 17896153Sbrianextern void bundle_StartSessionTimer(struct bundle *, unsigned secs); 17996153Sbrianextern void bundle_StopSessionTimer(struct bundle *); 18096153Sbrian#endif 18196153Sbrian 18258028Sbrianextern void bundle_RegisterDescriptor(struct bundle *, struct fdescriptor *); 18358028Sbrianextern void bundle_UnRegisterDescriptor(struct bundle *, struct fdescriptor *); 18436285Sbrian 18536285Sbrianextern void bundle_SetTtyCommandMode(struct bundle *, struct datalink *); 18636285Sbrian 18736285Sbrianextern int bundle_DatalinkClone(struct bundle *, struct datalink *, 18836285Sbrian const char *); 18936285Sbrianextern void bundle_DatalinkRemove(struct bundle *, struct datalink *); 19036285Sbrianextern void bundle_CleanDatalinks(struct bundle *); 19136285Sbrianextern void bundle_SetLabel(struct bundle *, const char *); 19236285Sbrianextern const char *bundle_GetLabel(struct bundle *); 19336285Sbrianextern void bundle_SendDatalink(struct datalink *, int, struct sockaddr_un *); 19453684Sbrianextern int bundle_LinkSize(void); 19553684Sbrianextern void bundle_ReceiveDatalink(struct bundle *, int); 19636285Sbrianextern int bundle_SetMode(struct bundle *, struct datalink *, int); 19736285Sbrianextern int bundle_RenameDatalink(struct bundle *, struct datalink *, 19836285Sbrian const char *); 19936452Sbrianextern void bundle_setsid(struct bundle *, int); 20036709Sbrianextern void bundle_LockTun(struct bundle *); 20140622Sbrianextern int bundle_HighestState(struct bundle *); 20241654Sbrianextern int bundle_Exception(struct bundle *, int); 20381634Sbrianextern void bundle_AdjustFilters(struct bundle *, struct ncpaddr *, 20481634Sbrian struct ncpaddr *); 20581634Sbrianextern void bundle_AdjustDNS(struct bundle *); 20649434Sbrianextern void bundle_CalculateBandwidth(struct bundle *); 20749434Sbrianextern void bundle_AutoAdjust(struct bundle *, int, int); 20849434Sbrianextern int bundle_WantAutoloadTimer(struct bundle *); 20956350Sbrianextern void bundle_ChangedPID(struct bundle *); 21059084Sbrianextern void bundle_Notify(struct bundle *, char); 21185991Sbrianextern int bundle_Uptime(struct bundle *); 212