bundle.h revision 49434
1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $Id: bundle.h,v 1.23 1999/06/02 00:46:52 brian Exp $ 27 */ 28 29#define PHASE_DEAD 0 /* Link is dead */ 30#define PHASE_ESTABLISH 1 /* Establishing link */ 31#define PHASE_AUTHENTICATE 2 /* Being authenticated */ 32#define PHASE_NETWORK 3 /* We're alive ! */ 33#define PHASE_TERMINATE 4 /* Terminating link */ 34 35/* cfg.opt bit settings */ 36#define OPT_IDCHECK 0x0001 37#define OPT_IFACEALIAS 0x0002 38#define OPT_KEEPSESSION 0x0004 39#define OPT_LOOPBACK 0x0008 40#define OPT_PASSWDAUTH 0x0010 41#define OPT_PROXY 0x0020 42#define OPT_PROXYALL 0x0040 43#define OPT_SROUTES 0x0080 44#define OPT_THROUGHPUT 0x0100 45#define OPT_UTMP 0x0200 46 47#define MAX_ENDDISC_CLASS 5 48 49#define Enabled(b, o) ((b)->cfg.opt & (o)) 50 51/* AutoAdjust() values */ 52#define AUTO_UP 1 53#define AUTO_DOWN 2 54 55struct sockaddr_un; 56struct datalink; 57struct physical; 58struct link; 59struct server; 60struct prompt; 61struct iface; 62 63struct bundle { 64 struct descriptor desc; /* really all our datalinks */ 65 int unit; /* The device/interface unit number */ 66 const char **argv; /* From main() */ 67 const char *argv0; /* Original */ 68 const char *argv1; /* Original */ 69 70 struct { 71 char Name[20]; /* The /dev/XXXX name */ 72 int fd; /* The /dev/XXXX descriptor */ 73 } dev; 74 75 u_long bandwidth; /* struct tuninfo speed */ 76 struct iface *iface; /* Interface information */ 77 78 int routing_seq; /* The current routing sequence number */ 79 u_int phase; /* Curent phase */ 80 81 struct { 82 int all; /* Union of all physical::type's */ 83 int open; /* Union of all open physical::type's */ 84 } phys_type; 85 86 unsigned CleaningUp : 1; /* Going to exit.... */ 87 unsigned AliasEnabled : 1; /* Are we using libalias ? */ 88 89 struct fsm_parent fsm; /* Our callback functions */ 90 struct datalink *links; /* Our data links */ 91 92 struct { 93 int idle_timeout; /* NCP Idle timeout value */ 94 struct { 95 char name[AUTHLEN]; /* PAP/CHAP system name */ 96 char key[AUTHLEN]; /* PAP/CHAP key */ 97 } auth; 98 unsigned opt; /* Uses OPT_ bits from above */ 99 char label[50]; /* last thing `load'ed */ 100 u_short mtu; /* Interface mtu */ 101 102 struct { 103 int timeout; /* How long to leave the output queue choked */ 104 } choked; 105 } cfg; 106 107 struct { 108 struct ipcp ipcp; /* Our IPCP FSM */ 109 struct mp mp; /* Our MP */ 110 } ncp; 111 112 struct { 113 struct filter in; /* incoming packet filter */ 114 struct filter out; /* outgoing packet filter */ 115 struct filter dial; /* dial-out packet filter */ 116 struct filter alive; /* keep-alive packet filter */ 117 } filter; 118 119 struct { 120 struct pppTimer timer; /* timeout after cfg.idle_timeout */ 121 time_t done; 122 } idle; 123 124 struct { 125 int fd; /* write status here */ 126 } notify; 127 128 struct { 129 struct pppTimer timer; /* choked output queue timer */ 130 } choked; 131 132#ifndef NORADIUS 133 struct radius radius; /* Info retrieved from radius server */ 134#endif 135}; 136 137#define descriptor2bundle(d) \ 138 ((d)->type == BUNDLE_DESCRIPTOR ? (struct bundle *)(d) : NULL) 139 140extern struct bundle *bundle_Create(const char *, int, const char **); 141extern void bundle_Destroy(struct bundle *); 142extern const char *bundle_PhaseName(struct bundle *); 143#define bundle_Phase(b) ((b)->phase) 144extern void bundle_NewPhase(struct bundle *, u_int); 145extern void bundle_LinksRemoved(struct bundle *); 146extern int bundle_LinkIsUp(const struct bundle *); 147extern int bundle_SetRoute(struct bundle *, int, struct in_addr, 148 struct in_addr, struct in_addr, int, int); 149extern void bundle_Close(struct bundle *, const char *, int); 150extern void bundle_Down(struct bundle *, int); 151extern void bundle_Open(struct bundle *, const char *, int, int); 152extern void bundle_LinkClosed(struct bundle *, struct datalink *); 153 154extern int bundle_FillQueues(struct bundle *); 155extern int bundle_ShowLinks(struct cmdargs const *); 156extern int bundle_ShowStatus(struct cmdargs const *); 157extern void bundle_StartIdleTimer(struct bundle *); 158extern void bundle_SetIdleTimer(struct bundle *, int); 159extern void bundle_StopIdleTimer(struct bundle *); 160extern int bundle_IsDead(struct bundle *); 161extern struct datalink *bundle2datalink(struct bundle *, const char *); 162 163extern void bundle_RegisterDescriptor(struct bundle *, struct descriptor *); 164extern void bundle_UnRegisterDescriptor(struct bundle *, struct descriptor *); 165 166extern void bundle_SetTtyCommandMode(struct bundle *, struct datalink *); 167 168extern int bundle_DatalinkClone(struct bundle *, struct datalink *, 169 const char *); 170extern void bundle_DatalinkRemove(struct bundle *, struct datalink *); 171extern void bundle_CleanDatalinks(struct bundle *); 172extern void bundle_SetLabel(struct bundle *, const char *); 173extern const char *bundle_GetLabel(struct bundle *); 174extern void bundle_SendDatalink(struct datalink *, int, struct sockaddr_un *); 175extern void bundle_ReceiveDatalink(struct bundle *, int, struct sockaddr_un *); 176extern int bundle_SetMode(struct bundle *, struct datalink *, int); 177extern int bundle_RenameDatalink(struct bundle *, struct datalink *, 178 const char *); 179extern void bundle_setsid(struct bundle *, int); 180extern void bundle_LockTun(struct bundle *); 181extern int bundle_HighestState(struct bundle *); 182extern int bundle_Exception(struct bundle *, int); 183extern void bundle_AdjustFilters(struct bundle *, struct in_addr *, 184 struct in_addr *); 185extern void bundle_CalculateBandwidth(struct bundle *); 186extern void bundle_AutoAdjust(struct bundle *, int, int); 187extern int bundle_WantAutoloadTimer(struct bundle *); 188