bundle.h revision 36467
139092Srnordier/*- 239092Srnordier * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 339092Srnordier * All rights reserved. 439092Srnordier * 539092Srnordier * Redistribution and use in source and binary forms, with or without 639092Srnordier * modification, are permitted provided that the following conditions 739092Srnordier * are met: 839092Srnordier * 1. Redistributions of source code must retain the above copyright 939092Srnordier * notice, this list of conditions and the following disclaimer. 1039092Srnordier * 2. Redistributions in binary form must reproduce the above copyright 1139092Srnordier * notice, this list of conditions and the following disclaimer in the 1239092Srnordier * documentation and/or other materials provided with the distribution. 1339092Srnordier * 1439092Srnordier * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1539092Srnordier * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1639092Srnordier * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1739092Srnordier * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1839092Srnordier * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1939092Srnordier * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2039092Srnordier * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2139092Srnordier * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2239092Srnordier * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2339092Srnordier * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2439092Srnordier * SUCH DAMAGE. 2539092Srnordier * 2650479Speter * $Id: bundle.h,v 1.4 1998/05/28 23:17:33 brian Exp $ 2739092Srnordier */ 2839092Srnordier 2955416Smarcel#define PHASE_DEAD 0 /* Link is dead */ 30130927Sobrien#define PHASE_ESTABLISH 1 /* Establishing link */ 3155416Smarcel#define PHASE_AUTHENTICATE 2 /* Being authenticated */ 3239092Srnordier#define PHASE_NETWORK 3 /* We're alive ! */ 3339092Srnordier#define PHASE_TERMINATE 4 /* Terminating link */ 3439092Srnordier 3539092Srnordier/* cfg.opt bit settings */ 3639092Srnordier#define OPT_IDCHECK 0x01 3739092Srnordier#define OPT_LOOPBACK 0x02 3839092Srnordier#define OPT_PASSWDAUTH 0x04 3939092Srnordier#define OPT_PROXY 0x08 4039092Srnordier#define OPT_SROUTES 0x10 4139092Srnordier#define OPT_THROUGHPUT 0x20 4239092Srnordier#define OPT_UTMP 0x40 4339092Srnordier 4439092Srnordier#define MAX_ENDDISC_CLASS 5 4539092Srnordier 4639092Srnordier#define Enabled(b, o) ((b)->cfg.opt & (o)) 47130927Sobrien 48130927Sobrienstruct sockaddr_un; 49130927Sobrienstruct datalink; 50130927Sobrienstruct physical; 51130927Sobrienstruct link; 52130927Sobrienstruct server; 5339092Srnordierstruct prompt; 54130927Sobrien 55130927Sobrienstruct bundle { 56130927Sobrien struct descriptor desc; /* really all our datalinks */ 57130927Sobrien int unit; /* The device/interface unit number */ 58130927Sobrien const char **argv; /* From main() */ 59130927Sobrien 6039092Srnordier struct { 6139092Srnordier char Name[20]; /* The /dev/XXXX name */ 6239092Srnordier int fd; /* The /dev/XXXX descriptor */ 63130927Sobrien } dev; 64130927Sobrien 65130927Sobrien struct { 66130927Sobrien u_long Speed; /* struct tuninfo speed */ 67130927Sobrien int Index; /* The interface index */ 68130927Sobrien char *Name; /* The interface name */ 69130927Sobrien } ifp; 70130927Sobrien 7139092Srnordier int routing_seq; /* The current routing sequence number */ 7239092Srnordier u_int phase; /* Curent phase */ 73130927Sobrien int phys_type; /* Union of all physical::type's */ 74130927Sobrien 75130927Sobrien unsigned CleaningUp : 1; /* Going to exit.... */ 76130927Sobrien 77130927Sobrien struct fsm_parent fsm; /* Our callback functions */ 78130927Sobrien struct datalink *links; /* Our data links */ 79130927Sobrien 80130927Sobrien struct { 8139092Srnordier int idle_timeout; /* NCP Idle timeout value */ 8239092Srnordier struct { 8339092Srnordier char name[50]; /* PAP/CHAP system name */ 8439092Srnordier char key[50]; /* PAP/CHAP key */ 85130927Sobrien } auth; 8639092Srnordier unsigned opt; /* Uses OPT_ bits from above */ 8739092Srnordier char label[50]; /* last thing `load'ed */ 88130927Sobrien u_short mtu; /* Interface mtu */ 89130927Sobrien 9039092Srnordier struct { /* We need/don't need another link when */ 9139092Srnordier struct { /* more/less than */ 92130927Sobrien int packets; /* this number of packets are queued for */ 93130927Sobrien int timeout; /* this number of seconds */ 94130927Sobrien } max, min; 9539092Srnordier } autoload; 96130927Sobrien } cfg; 9739092Srnordier 9839092Srnordier struct { 9939092Srnordier struct ipcp ipcp; /* Our IPCP FSM */ 100130927Sobrien struct mp mp; /* Our MP */ 101130927Sobrien } ncp; 102130927Sobrien 103130927Sobrien struct { 104130927Sobrien struct filter in; /* incoming packet filter */ 105130927Sobrien struct filter out; /* outgoing packet filter */ 106130927Sobrien struct filter dial; /* dial-out packet filter */ 10739092Srnordier struct filter alive; /* keep-alive packet filter */ 108130927Sobrien } filter; 10939092Srnordier 11039092Srnordier struct { 11139092Srnordier struct pppTimer timer; /* timeout after cfg.idle_timeout */ 112130927Sobrien time_t done; 113130927Sobrien } idle; 114130927Sobrien 115130927Sobrien struct { 116130927Sobrien int fd; /* write status here */ 117130927Sobrien } notify; 118130927Sobrien 11939092Srnordier struct { 120130927Sobrien struct pppTimer timer; 12139092Srnordier time_t done; 12239092Srnordier unsigned running : 1; 12339092Srnordier unsigned comingup : 1; 12439092Srnordier } autoload; 12539092Srnordier}; 126 127#define descriptor2bundle(d) \ 128 ((d)->type == BUNDLE_DESCRIPTOR ? (struct bundle *)(d) : NULL) 129 130extern struct bundle *bundle_Create(const char *, int, const char **); 131extern void bundle_Destroy(struct bundle *); 132extern const char *bundle_PhaseName(struct bundle *); 133#define bundle_Phase(b) ((b)->phase) 134extern void bundle_NewPhase(struct bundle *, u_int); 135extern int bundle_LinkIsUp(const struct bundle *); 136extern int bundle_SetRoute(struct bundle *, int, struct in_addr, 137 struct in_addr, struct in_addr, int); 138extern void bundle_Close(struct bundle *, const char *, int); 139extern void bundle_Down(struct bundle *); 140extern void bundle_Open(struct bundle *, const char *, int); 141extern void bundle_LinkClosed(struct bundle *, struct datalink *); 142 143extern int bundle_FillQueues(struct bundle *); 144extern int bundle_ShowLinks(struct cmdargs const *); 145extern int bundle_ShowStatus(struct cmdargs const *); 146extern void bundle_StartIdleTimer(struct bundle *); 147extern void bundle_SetIdleTimer(struct bundle *, int); 148extern void bundle_StopIdleTimer(struct bundle *); 149extern int bundle_IsDead(struct bundle *); 150extern struct datalink *bundle2datalink(struct bundle *, const char *); 151 152extern void bundle_RegisterDescriptor(struct bundle *, struct descriptor *); 153extern void bundle_UnRegisterDescriptor(struct bundle *, struct descriptor *); 154 155extern void bundle_SetTtyCommandMode(struct bundle *, struct datalink *); 156 157extern int bundle_DatalinkClone(struct bundle *, struct datalink *, 158 const char *); 159extern void bundle_DatalinkRemove(struct bundle *, struct datalink *); 160extern void bundle_CleanDatalinks(struct bundle *); 161extern void bundle_SetLabel(struct bundle *, const char *); 162extern const char *bundle_GetLabel(struct bundle *); 163extern void bundle_SendDatalink(struct datalink *, int, struct sockaddr_un *); 164extern void bundle_ReceiveDatalink(struct bundle *, int, struct sockaddr_un *); 165extern int bundle_SetMode(struct bundle *, struct datalink *, int); 166extern int bundle_RenameDatalink(struct bundle *, struct datalink *, 167 const char *); 168extern void bundle_setsid(struct bundle *, int); 169