Annotation of embedaddon/mpd/src/bund.h, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>