Annotation of embedaddon/mpd/src/link.h, revision 1.1.1.3

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

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