Annotation of embedaddon/mpd/src/link.h, revision 1.1.1.2
1.1 misho 1:
2: /*
3: * link.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 _LINK_H_
11: #define _LINK_H_
12:
13: #include "defs.h"
14: #include "proto.h"
15: #include "lcp.h"
16: #include "ip.h"
17: #include "mp.h"
18: #include "vars.h"
19: #include "auth.h"
20: #include "fsm.h"
21: #include "mbuf.h"
22: #include "phys.h"
23: #include "vars.h"
24: #include <netgraph/ng_ppp.h>
25: #include <regex.h>
26:
27: /*
28: * DEFINITIONS
29: */
30:
31: /* Bounds */
32: /* Default bundle-layer FSM retry timeout */
33: #define LINK_DEFAULT_RETRY 2
34:
35: /* Default latency and bandwidth */
36: #define LINK_DEFAULT_BANDWIDTH 64000 /* 64k */
37: #define LINK_DEFAULT_LATENCY 2000 /* 2ms */
38:
39: enum {
40: LINK_ACTION_FORWARD,
41: LINK_ACTION_BUNDLE,
42: LINK_ACTION_DROP
43: };
44:
45: struct linkaction {
46: int action;
47: char regex[128];
48: regex_t regexp;
49: char arg[LINK_MAX_NAME]; /* Link/Bundle template name */
50: SLIST_ENTRY(linkaction) next;
51: };
52:
53: /* Configuration options */
54: enum {
55: LINK_CONF_PAP,
56: LINK_CONF_CHAPMD5,
57: LINK_CONF_CHAPMSv1,
58: LINK_CONF_CHAPMSv2,
59: LINK_CONF_EAP,
60: LINK_CONF_INCOMING,
61: LINK_CONF_ACFCOMP,
62: LINK_CONF_PROTOCOMP,
63: LINK_CONF_MSDOMAIN,
64: LINK_CONF_MAGICNUM,
65: LINK_CONF_PASSIVE,
66: LINK_CONF_CHECK_MAGIC,
67: LINK_CONF_RINGBACK,
68: LINK_CONF_NO_ORIG_AUTH,
69: LINK_CONF_CALLBACK,
70: LINK_CONF_MULTILINK, /* multi-link */
71: LINK_CONF_SHORTSEQ, /* multi-link short sequence numbers */
72: LINK_CONF_TIMEREMAIN, /* Send LCP Time-Remain if known */
73: LINK_CONF_PEER_AS_CALLING,
1.1.1.2 ! misho 74: LINK_CONF_REPORT_MAC,
! 75: LINK_CONF_REMOVE_TEE /* Remove ng_tee from the resulting chain */
1.1 misho 76: };
77:
78: /* Configuration for a link */
79: struct linkconf {
80: u_short mtu; /* Initial MTU value */
81: u_short mru; /* Initial MRU value */
82: uint16_t mrru; /* Initial MRRU value */
83: uint32_t accmap; /* Initial ACCMAP value */
84: short retry_timeout; /* FSM timeout for retries */
85: short max_redial; /* Max failed connect attempts */
86: short redial_delay; /* Failed connect retry time */
87: char *ident; /* LCP ident string */
88: struct optinfo options; /* Configured options */
89: int max_children; /* Maximal number of children */
90: };
91:
92: struct linkbm {
93: struct ng_ppp_link_stat
94: idleStats; /* Link management stats */
95: };
96: typedef struct linkbm *LinkBm;
97:
98: /* Values for link origination (must fit in 2 bits) */
99: #define LINK_ORIGINATE_UNKNOWN 0
100: #define LINK_ORIGINATE_LOCAL 1
101: #define LINK_ORIGINATE_REMOTE 2
102:
103: #define LINK_ORIGINATION(o) ((o) == LINK_ORIGINATE_LOCAL ? "local" : \
104: (o) == LINK_ORIGINATE_REMOTE ? "remote" : \
105: "unknown")
106:
107: /* Total state of a link */
108: struct linkst {
109: char name[LINK_MAX_NAME]; /* Human readable name */
110: int id; /* Index of this link in gLinks */
111: u_char tmpl; /* This is template, not an instance */
112: u_char stay; /* Must not disappear */
113: u_char state; /* Device current state */
114: u_char joined_bund; /* Link successfully joined bundle */
115: u_char originate; /* Who originated the connection */
116: u_char die; /* LCP agreed to die */
117: u_char dead; /* Dead flag (shutted down) */
118: Bund bund; /* My bundle */
119: Rep rep; /* Rep connected to the device */
120: int bundleIndex; /* Link number in bundle */
121: int parent; /* Index of the parent in gLinks */
122: int children; /* Number of children */
123: int refs; /* Number of references */
124: char hook[NG_HOOKSIZ]; /* session hook name */
125: ng_ID_t nodeID; /* ID of the tee node */
126: MsgHandler msgs; /* Link events */
127: SLIST_HEAD(, linkaction) actions;
128:
129: /* State info */
130: struct linkconf conf; /* Link configuration */
131: struct lcpstate lcp; /* LCP state info */
132: struct linkbm bm; /* Link bandwidth mgmt info */
133: struct ng_ppp_link_stat64 stats; /* Link statistics */
134: #ifndef NG_PPP_STATS64
135: struct ng_ppp_link_stat oldStats; /* Previous stats for 64bit emulation */
136: #endif
137:
138: /* Link properties */
139: short num_redial; /* Counter for retry attempts */
140: u_char upReasonValid;
141: u_char downReasonValid;
1.1.1.2 ! misho 142: u_char tee_removed;
1.1 misho 143: char *upReason; /* Reason for link going up */
144: char *downReason; /* Reason for link going down */
145: int bandwidth; /* Bandwidth in bits per second */
146: int latency; /* Latency in microseconds */
147: time_t last_up; /* Time this link last got up */
148: char msession_id[AUTH_MAX_SESSIONID]; /* a uniq msession-id */
149: char session_id[AUTH_MAX_SESSIONID]; /* a uniq session-id */
150:
151: PhysType type; /* Device type descriptor */
152: void *info; /* Type specific info */
153: MsgHandler pmsgs; /* Message channel */
154: struct pppTimer openTimer; /* Open retry timer */
155: };
156:
157:
158: /*
159: * VARIABLES
160: */
161:
162: extern const struct cmdtab LinkSetCmds[];
163:
164: extern int gLinksCsock; /* Socket node control socket */
165: extern int gLinksDsock; /* Socket node data socket */
166:
167: /*
168: * FUNCTIONS
169: */
170: extern int LinksInit(void);
171: extern void LinksShutdown(void);
172:
173: extern void LinkUp(Link l);
174: extern void LinkDown(Link l);
175: extern void LinkOpen(Link l);
176: extern void LinkClose(Link l);
177: extern int LinkOpenCmd(Context ctx);
178: extern int LinkCloseCmd(Context ctx);
179:
180: extern int LinkCreate(Context ctx, int ac, char *av[], void *arg);
181: extern int LinkDestroy(Context ctx, int ac, char *av[], void *arg);
182: extern Link LinkInst(Link lt, char *name, int tmpl, int stay);
183: extern void LinkShutdownCheck(Link l, short state);
184: extern void LinkShutdown(Link l);
185: extern int LinkNgInit(Link l);
186: extern int LinkNgJoin(Link l);
187: extern int LinkNgToRep(Link l);
188: extern int LinkNgLeave(Link l);
189: extern void LinkNgShutdown(Link l);
190: extern int LinkNuke(Link link);
191: extern int LinkStat(Context ctx, int ac, char *av[], void *arg);
192: extern void LinkUpdateStats(Link l);
193: extern void LinkResetStats(Link l);
194: extern Link LinkFind(const char *name);
195: extern int LinkCommand(Context ctx, int ac, char *av[], void *arg);
196: extern int SessionCommand(Context ctx, int ac, char *av[], void *arg);
197: extern int AuthnameCommand(Context ctx, int ac, char *av[], void *arg);
198: extern void RecordLinkUpDownReason(Bund b, Link l, int up, const char *fmt,
199: const char *arg, ...);
200:
201: extern const char *LinkMatchAction(Link l, int stage, char *login);
202:
203: #endif
204:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>