Annotation of embedaddon/mpd/src/link.h, revision 1.1.1.1
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,
74: LINK_CONF_REPORT_MAC
75: };
76:
77: /* Configuration for a link */
78: struct linkconf {
79: u_short mtu; /* Initial MTU value */
80: u_short mru; /* Initial MRU value */
81: uint16_t mrru; /* Initial MRRU value */
82: uint32_t accmap; /* Initial ACCMAP value */
83: short retry_timeout; /* FSM timeout for retries */
84: short max_redial; /* Max failed connect attempts */
85: short redial_delay; /* Failed connect retry time */
86: char *ident; /* LCP ident string */
87: struct optinfo options; /* Configured options */
88: int max_children; /* Maximal number of children */
89: };
90:
91: struct linkbm {
92: struct ng_ppp_link_stat
93: idleStats; /* Link management stats */
94: };
95: typedef struct linkbm *LinkBm;
96:
97: /* Values for link origination (must fit in 2 bits) */
98: #define LINK_ORIGINATE_UNKNOWN 0
99: #define LINK_ORIGINATE_LOCAL 1
100: #define LINK_ORIGINATE_REMOTE 2
101:
102: #define LINK_ORIGINATION(o) ((o) == LINK_ORIGINATE_LOCAL ? "local" : \
103: (o) == LINK_ORIGINATE_REMOTE ? "remote" : \
104: "unknown")
105:
106: /* Total state of a link */
107: struct linkst {
108: char name[LINK_MAX_NAME]; /* Human readable name */
109: int id; /* Index of this link in gLinks */
110: u_char tmpl; /* This is template, not an instance */
111: u_char stay; /* Must not disappear */
112: u_char state; /* Device current state */
113: u_char joined_bund; /* Link successfully joined bundle */
114: u_char originate; /* Who originated the connection */
115: u_char die; /* LCP agreed to die */
116: u_char dead; /* Dead flag (shutted down) */
117: Bund bund; /* My bundle */
118: Rep rep; /* Rep connected to the device */
119: int bundleIndex; /* Link number in bundle */
120: int parent; /* Index of the parent in gLinks */
121: int children; /* Number of children */
122: int refs; /* Number of references */
123: char hook[NG_HOOKSIZ]; /* session hook name */
124: ng_ID_t nodeID; /* ID of the tee node */
125: MsgHandler msgs; /* Link events */
126: SLIST_HEAD(, linkaction) actions;
127:
128: /* State info */
129: struct linkconf conf; /* Link configuration */
130: struct lcpstate lcp; /* LCP state info */
131: struct linkbm bm; /* Link bandwidth mgmt info */
132: struct ng_ppp_link_stat64 stats; /* Link statistics */
133: #ifndef NG_PPP_STATS64
134: struct ng_ppp_link_stat oldStats; /* Previous stats for 64bit emulation */
135: #endif
136:
137: /* Link properties */
138: short num_redial; /* Counter for retry attempts */
139: u_char upReasonValid;
140: u_char downReasonValid;
141: char *upReason; /* Reason for link going up */
142: char *downReason; /* Reason for link going down */
143: int bandwidth; /* Bandwidth in bits per second */
144: int latency; /* Latency in microseconds */
145: time_t last_up; /* Time this link last got up */
146: char msession_id[AUTH_MAX_SESSIONID]; /* a uniq msession-id */
147: char session_id[AUTH_MAX_SESSIONID]; /* a uniq session-id */
148:
149: PhysType type; /* Device type descriptor */
150: void *info; /* Type specific info */
151: MsgHandler pmsgs; /* Message channel */
152: struct pppTimer openTimer; /* Open retry timer */
153: };
154:
155:
156: /*
157: * VARIABLES
158: */
159:
160: extern const struct cmdtab LinkSetCmds[];
161:
162: extern int gLinksCsock; /* Socket node control socket */
163: extern int gLinksDsock; /* Socket node data socket */
164:
165: /*
166: * FUNCTIONS
167: */
168: extern int LinksInit(void);
169: extern void LinksShutdown(void);
170:
171: extern void LinkUp(Link l);
172: extern void LinkDown(Link l);
173: extern void LinkOpen(Link l);
174: extern void LinkClose(Link l);
175: extern int LinkOpenCmd(Context ctx);
176: extern int LinkCloseCmd(Context ctx);
177:
178: extern int LinkCreate(Context ctx, int ac, char *av[], void *arg);
179: extern int LinkDestroy(Context ctx, int ac, char *av[], void *arg);
180: extern Link LinkInst(Link lt, char *name, int tmpl, int stay);
181: extern void LinkShutdownCheck(Link l, short state);
182: extern void LinkShutdown(Link l);
183: extern int LinkNgInit(Link l);
184: extern int LinkNgJoin(Link l);
185: extern int LinkNgToRep(Link l);
186: extern int LinkNgLeave(Link l);
187: extern void LinkNgShutdown(Link l);
188: extern int LinkNuke(Link link);
189: extern int LinkStat(Context ctx, int ac, char *av[], void *arg);
190: extern void LinkUpdateStats(Link l);
191: extern void LinkResetStats(Link l);
192: extern Link LinkFind(const char *name);
193: extern int LinkCommand(Context ctx, int ac, char *av[], void *arg);
194: extern int SessionCommand(Context ctx, int ac, char *av[], void *arg);
195: extern int AuthnameCommand(Context ctx, int ac, char *av[], void *arg);
196: extern void RecordLinkUpDownReason(Bund b, Link l, int up, const char *fmt,
197: const char *arg, ...);
198:
199: extern const char *LinkMatchAction(Link l, int stage, char *login);
200:
201: #endif
202:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>