Annotation of embedaddon/mpd/src/bund.h, revision 1.1.1.2
1.1 misho 1:
2: /*
3: * bund.h
4: *
5: * Written by Archie Cobbs <archie@freebsd.org>
6: * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
7: * See ``COPYRIGHT.whistle''
8: */
9:
10: #ifndef _BUND_H_
11: #define _BUND_H_
12:
13: #include "defs.h"
14: #include "ip.h"
15: #include "mp.h"
1.1.1.2 ! misho 16: #include "iface.h"
1.1 misho 17: #include "ipcp.h"
18: #include "ipv6cp.h"
19: #include "chap.h"
20: #include "ccp.h"
21: #include "ecp.h"
22: #include "msg.h"
23: #include "auth.h"
24: #include "command.h"
25: #include <netgraph/ng_message.h>
26:
27: /*
28: * DEFINITIONS
29: */
30:
31: /* Configuration options */
32: enum {
33: BUND_CONF_IPCP, /* IPCP */
34: BUND_CONF_IPV6CP, /* IPV6CP */
35: BUND_CONF_COMPRESSION, /* compression */
36: BUND_CONF_ENCRYPTION, /* encryption */
37: BUND_CONF_CRYPT_REQD, /* encryption is required */
38: BUND_CONF_BWMANAGE, /* dynamic bandwidth */
39: BUND_CONF_ROUNDROBIN /* round-robin MP scheduling */
40: };
41:
42: /* Default bundle-layer FSM retry timeout */
43: #define BUND_DEFAULT_RETRY 2
44:
45: enum {
46: NCP_NONE = 0,
47: NCP_IPCP,
48: NCP_IPV6CP,
49: NCP_ECP,
50: NCP_CCP
51: };
52:
53: /*
54:
55: Bundle bandwidth management
56:
57: We treat the first link as different from the rest. It connects
58: immediately when there is (qualifying) outgoing traffic. The
59: idle timeout applies globally, no matter how many links are up.
60:
61: Additional links are connected/disconnected according to a simple
62: algorithm that uses the following constants:
63:
64: S Sampling interval. Number of seconds over which we average traffic.
65:
66: N Number of sub-intervals we chop the S seconds into (granularity).
67:
68: Hi Hi water mark: if traffic is more than H% of total available
69: bandwidth, averaged over S seconds, time to add the second link.
70:
71: Lo Low water mark: if traffic is less than L% of total available
72: bandwidth during all N sub-intervals, time to hang up the second link.
73:
74: Mc Minimum amount of time after connecting a link before
75: connecting next.
76:
77: Md Minimum amount of time after disconnecting any link before
78: disconnecting next.
79:
80: We treat incoming and outgoing traffic separately when comparing
81: against Hi and Lo.
82:
83: */
84:
85: #define BUND_BM_DFL_S 60 /* Length of sampling interval (secs) */
86: #define BUND_BM_DFL_Hi 80 /* High water mark % */
87: #define BUND_BM_DFL_Lo 20 /* Low water mark % */
88: #define BUND_BM_DFL_Mc 30 /* Min connect period (secs) */
89: #define BUND_BM_DFL_Md 90 /* Min disconnect period (secs) */
90:
91: #define BUND_BM_N 6 /* Number of sampling intervals */
92:
93: struct bundbm {
94: u_int traffic[2][BUND_BM_N]; /* Traffic deltas */
95: u_int avail[BUND_BM_N]; /* Available traffic deltas */
96: u_char wasUp[BUND_BM_N]; /* Sub-intervals link was up */
97: time_t last_open; /* Time we last open any link */
98: time_t last_close; /* Time we last closed any link */
99: struct pppTimer bmTimer; /* Bandwidth mgmt timer */
100: u_int total_bw; /* Total bandwidth available */
101: };
102: typedef struct bundbm *BundBm;
103:
104: /* Configuration for a bundle */
105: struct bundconf {
106: short retry_timeout; /* Timeout for retries */
107: u_short bm_S; /* Bandwidth mgmt constants */
108: u_short bm_Hi;
109: u_short bm_Lo;
110: u_short bm_Mc;
111: u_short bm_Md;
112: struct optinfo options; /* Configured options */
113: char linkst[NG_PPP_MAX_LINKS][LINK_MAX_NAME]; /* Link names for DoD */
114: };
115:
116: #define BUND_STATS_UPDATE_INTERVAL 65 * SECONDS
117:
118: /* Total state of a bundle */
119: struct bundle {
120: char name[LINK_MAX_NAME]; /* Name of this bundle */
121: int id; /* Index of this bundle in gBundles */
122: u_char tmpl; /* This is template, not an instance */
123: u_char stay; /* Must not disappear */
124: u_char dead; /* Dead flag */
125: Link links[NG_PPP_MAX_LINKS]; /* Real links in this bundle */
126: u_short n_links; /* Number of links in bundle */
127: u_short n_up; /* Number of links joined the bundle */
128: ng_ID_t nodeID; /* ID of ppp node */
129: char hook[NG_HOOKSIZ]; /* session hook name */
130: MsgHandler msgs; /* Bundle events */
131: int refs; /* Number of references */
132:
133: /* PPP node config */
134: struct ng_ppp_node_conf pppConfig;
135:
136: /* Data chunks */
137: char msession_id[AUTH_MAX_SESSIONID]; /* a uniq session-id */
138: u_int16_t peer_mrru; /* MRRU set by peer, or zero */
139: struct discrim peer_discrim; /* Peer's discriminator */
140: struct bundbm bm; /* Bandwidth management state */
141: struct bundconf conf; /* Configuration for this bundle */
142: struct ng_ppp_link_stat64 stats; /* Statistics for this bundle */
143: #ifndef NG_PPP_STATS64
144: struct ng_ppp_link_stat oldStats; /* Previous stats for 64bit emulation */
145: struct pppTimer statsUpdateTimer; /* update Timer */
146: #endif
147: time_t last_up; /* Time first link got up */
148: struct ifacestate iface; /* IP state info */
149: struct ipcpstate ipcp; /* IPCP state info */
150: struct ipv6cpstate ipv6cp; /* IPV6CP state info */
151: struct ccpstate ccp; /* CCP state info */
152: struct ecpstate ecp; /* ECP state info */
153: u_int ncpstarted; /* Bitmask of active NCPs wich is sufficient to keep bundle open */
154:
155: /* Link management stuff */
156: struct pppTimer bmTimer; /* Bandwidth mgmt timer */
157: struct pppTimer reOpenTimer; /* Re-open timer */
158:
159: /* Boolean variables */
160: u_char open; /* In the open state */
161: u_char originate; /* Who originated the connection */
162:
163: struct authparams params; /* params to pass to from auth backend */
164: };
165:
166: /*
167: * VARIABLES
168: */
169:
170: extern struct discrim self_discrim; /* My discriminator */
171: extern const struct cmdtab BundSetCmds[];
172:
173: /*
174: * FUNCTIONS
175: */
176:
177: extern void BundOpen(Bund b);
178: extern void BundClose(Bund b);
179: extern int BundOpenCmd(Context ctx);
180: extern int BundCloseCmd(Context ctx);
1.1.1.2 ! misho 181: extern int BundStat(Context ctx, int ac, const char *const av[], const void *arg);
1.1 misho 182: extern void BundUpdateParams(Bund b);
1.1.1.2 ! misho 183: extern int BundCommand(Context ctx, int ac, const char *const av[], const void *arg);
! 184: extern int MSessionCommand(Context ctx, int ac, const char *const av[], const void *arg);
! 185: extern int IfaceCommand(Context ctx, int ac, const char *const av[], const void *arg);
! 186: extern int BundCreate(Context ctx, int ac, const char *const av[], const void *arg);
! 187: extern int BundDestroy(Context ctx, int ac, const char *const av[], const void *arg);
! 188: extern Bund BundInst(Bund bt, const char *name, int tmpl, int stay);
1.1 misho 189: extern Bund BundFind(const char *name);
190: extern void BundShutdown(Bund b);
191: extern void BundUpdateStats(Bund b);
192: extern void BundUpdateStatsTimer(void *cookie);
193: extern void BundResetStats(Bund b);
194:
195: extern int BundJoin(Link l);
196: extern void BundLeave(Link l);
197: extern void BundNcpsJoin(Bund b, int proto);
198: extern void BundNcpsLeave(Bund b, int proto);
199: extern void BundNcpsStart(Bund b, int proto);
200: extern void BundNcpsFinish(Bund b, int proto);
201: extern void BundOpenLinks(Bund b);
202: extern void BundCloseLinks(Bund b);
203: extern int BundCreateOpenLink(Bund b, int n);
204: extern void BundOpenLink(Link l);
205:
206: extern void BundNcpsOpen(Bund b);
207: extern void BundNcpsClose(Bund b);
208:
209: extern void BundShowLinks(Context ctx, Bund sb);
210:
211: #endif
212:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>