Annotation of embedaddon/quagga/ospfd/ospf_interface.h, revision 1.1.1.2

1.1       misho       1: /*
                      2:  * OSPF Interface functions.
                      3:  * Copyright (C) 1999 Toshiaki Takada
                      4:  *
                      5:  * This file is part of GNU Zebra.
                      6:  * 
                      7:  * GNU Zebra is free software; you can redistribute it and/or modify
                      8:  * it under the terms of the GNU General Public License as published
                      9:  * by the Free Software Foundation; either version 2, or (at your
                     10:  * option) any later version.
                     11:  *
                     12:  * GNU Zebra is distributed in the hope that it will be useful, but
                     13:  * WITHOUT ANY WARRANTY; without even the implied warranty of
                     14:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     15:  * General Public License for more details.
                     16:  *
                     17:  * You should have received a copy of the GNU General Public License
                     18:  * along with GNU Zebra; see the file COPYING.  If not, write to the
                     19:  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
                     20:  * Boston, MA 02111-1307, USA.
                     21:  */
                     22: 
                     23: #ifndef _ZEBRA_OSPF_INTERFACE_H
                     24: #define _ZEBRA_OSPF_INTERFACE_H
                     25: 
                     26: #include "ospfd/ospf_packet.h"
                     27: #include "ospfd/ospf_spf.h"
                     28: 
                     29: #define IF_OSPF_IF_INFO(I) ((struct ospf_if_info *)((I)->info))
                     30: #define IF_DEF_PARAMS(I) (IF_OSPF_IF_INFO (I)->def_params)
                     31: #define IF_OIFS(I)  (IF_OSPF_IF_INFO (I)->oifs)
                     32: #define IF_OIFS_PARAMS(I) (IF_OSPF_IF_INFO (I)->params)
                     33:                            
                     34: #define OSPF_IF_PARAM_CONFIGURED(S, P) ((S) && (S)->P##__config)
                     35: #define OSPF_IF_PARAM(O, P) \
                     36:         (OSPF_IF_PARAM_CONFIGURED ((O)->params, P)?\
                     37:                         (O)->params->P:IF_DEF_PARAMS((O)->ifp)->P)
                     38: 
                     39: #define DECLARE_IF_PARAM(T, P) T P; u_char P##__config:1
                     40: #define UNSET_IF_PARAM(S, P) ((S)->P##__config) = 0
                     41: #define SET_IF_PARAM(S, P) ((S)->P##__config) = 1
                     42: 
                     43: struct ospf_if_params
                     44: {
                     45:   DECLARE_IF_PARAM (u_int32_t, transmit_delay); /* Interface Transmisson Delay */
                     46:   DECLARE_IF_PARAM (u_int32_t, output_cost_cmd);/* Command Interface Output Cost */
                     47:   DECLARE_IF_PARAM (u_int32_t, retransmit_interval); /* Retransmission Interval */
                     48:   DECLARE_IF_PARAM (u_char, passive_interface);      /* OSPF Interface is passive: no sending or receiving (no need to join multicast groups) */
                     49:   DECLARE_IF_PARAM (u_char, priority);               /* OSPF Interface priority */
                     50:   DECLARE_IF_PARAM (u_char, type);                   /* type of interface */
                     51: #define OSPF_IF_ACTIVE                  0
                     52: #define OSPF_IF_PASSIVE                        1
                     53: 
                     54: #define OSPF_IF_PASSIVE_STATUS(O) \
                     55:        (OSPF_IF_PARAM_CONFIGURED((O)->params, passive_interface) ? \
                     56:          (O)->params->passive_interface : \
                     57:          (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS((O)->ifp), passive_interface) ? \
                     58:            IF_DEF_PARAMS((O)->ifp)->passive_interface : \
                     59:            (O)->ospf->passive_interface_default))
                     60:   
                     61:   DECLARE_IF_PARAM (u_int32_t, v_hello);             /* Hello Interval */
                     62:   DECLARE_IF_PARAM (u_int32_t, v_wait);              /* Router Dead Interval */
                     63: 
                     64:   /* MTU mismatch check (see RFC2328, chap 10.6) */ 
                     65:   DECLARE_IF_PARAM (u_char, mtu_ignore);
                     66:   
                     67:   /* Fast-Hellos */
                     68:   DECLARE_IF_PARAM (u_char, fast_hello);
                     69:   
                     70:   /* Authentication data. */
                     71:   u_char auth_simple[OSPF_AUTH_SIMPLE_SIZE + 1];       /* Simple password. */
                     72:   u_char auth_simple__config:1;
                     73:   
                     74:   DECLARE_IF_PARAM (struct list *, auth_crypt);    /* List of Auth cryptographic data. */
                     75:   DECLARE_IF_PARAM (int, auth_type);               /* OSPF authentication type */
                     76:   
                     77:   /* Other, non-configuration state */
                     78:   u_int32_t network_lsa_seqnum;                /* Network LSA seqnum */
                     79: };
                     80: 
                     81: enum
                     82: {
                     83:   MEMBER_ALLROUTERS = 0,
                     84:   MEMBER_DROUTERS,
                     85:   MEMBER_MAX,
                     86: };
                     87: 
                     88: struct ospf_if_info
                     89: {
                     90:   struct ospf_if_params *def_params;
                     91:   struct route_table *params;
                     92:   struct route_table *oifs;
                     93:   unsigned int membership_counts[MEMBER_MAX];  /* multicast group refcnts */
                     94: };
                     95: 
                     96: struct ospf_interface;
                     97: 
                     98: struct ospf_vl_data
                     99: {
                    100:   struct in_addr    vl_peer;      /* Router-ID of the peer for VLs. */
                    101:   struct in_addr    vl_area_id;           /* Transit area for this VL. */
                    102:   int format;                      /* area ID format */
                    103:   struct ospf_interface *vl_oi;           /* Interface data structure for the VL. */
                    104:   struct vertex_nexthop nexthop;   /* Nexthop router and oi to use */
                    105:   struct in_addr    peer_addr;    /* Address used to reach the peer. */
                    106:   u_char flags;
                    107: };
                    108: 
                    109: 
                    110: #define OSPF_VL_MAX_COUNT 256
                    111: #define OSPF_VL_MTU      1500
                    112: 
                    113: #define OSPF_VL_FLAG_APPROVED 0x01
                    114: 
                    115: struct crypt_key
                    116: {
                    117:   u_char key_id;
                    118:   u_char auth_key[OSPF_AUTH_MD5_SIZE + 1];
                    119: };
                    120: 
                    121: /* OSPF interface structure. */
                    122: struct ospf_interface
                    123: {
                    124:   /* This interface's parent ospf instance. */
                    125:   struct ospf *ospf;
                    126: 
                    127:   /* OSPF Area. */
                    128:   struct ospf_area *area;
                    129: 
1.1.1.2 ! misho     130:   /* Position range in Router LSA */
        !           131:   uint16_t lsa_pos_beg; /* inclusive, >= */
        !           132:   uint16_t lsa_pos_end; /* exclusive, <  */
        !           133: 
1.1       misho     134:   /* Interface data from zebra. */
                    135:   struct interface *ifp;
                    136:   struct ospf_vl_data *vl_data;                /* Data for Virtual Link */
                    137:   
                    138:   /* Packet send buffer. */
                    139:   struct ospf_fifo *obuf;              /* Output queue */
                    140: 
                    141:   /* OSPF Network Type. */
                    142:   u_char type;
                    143: #define OSPF_IFTYPE_NONE               0
                    144: #define OSPF_IFTYPE_POINTOPOINT                1
                    145: #define OSPF_IFTYPE_BROADCAST          2
                    146: #define OSPF_IFTYPE_NBMA               3
                    147: #define OSPF_IFTYPE_POINTOMULTIPOINT   4
                    148: #define OSPF_IFTYPE_VIRTUALLINK                5
                    149: #define OSPF_IFTYPE_LOOPBACK            6
                    150: #define OSPF_IFTYPE_MAX                        7
                    151: 
                    152:   /* State of Interface State Machine. */
                    153:   u_char state;
                    154: 
                    155:   /* To which multicast groups do we currently belong? */
                    156:   u_char multicast_memberships;
                    157: #define OI_MEMBER_FLAG(M) (1 << (M))
                    158: #define OI_MEMBER_COUNT(O,M) (IF_OSPF_IF_INFO(oi->ifp)->membership_counts[(M)])
                    159: #define OI_MEMBER_CHECK(O,M) \
                    160:     (CHECK_FLAG((O)->multicast_memberships, OI_MEMBER_FLAG(M)))
                    161: #define OI_MEMBER_JOINED(O,M) \
                    162:   do { \
                    163:     SET_FLAG ((O)->multicast_memberships, OI_MEMBER_FLAG(M)); \
                    164:     IF_OSPF_IF_INFO((O)->ifp)->membership_counts[(M)]++; \
                    165:   } while (0)
                    166: #define OI_MEMBER_LEFT(O,M) \
                    167:   do { \
                    168:     UNSET_FLAG ((O)->multicast_memberships, OI_MEMBER_FLAG(M)); \
                    169:     IF_OSPF_IF_INFO((O)->ifp)->membership_counts[(M)]--; \
                    170:   } while (0)
                    171: 
                    172:   struct prefix *address;              /* Interface prefix */
                    173:   struct connected *connected;          /* Pointer to connected */ 
                    174: 
                    175:   /* Configured varables. */
                    176:   struct ospf_if_params *params;
                    177:   
                    178:   u_int32_t crypt_seqnum;              /* Cryptographic Sequence Number */ 
                    179:   u_int32_t output_cost;               /* Acutual Interface Output Cost */
                    180: 
                    181:   /* Neighbor information. */
                    182:   struct route_table *nbrs;             /* OSPF Neighbor List */
                    183:   struct ospf_neighbor *nbr_self;      /* Neighbor Self */
                    184: #define DR(I)                  ((I)->nbr_self->d_router)
                    185: #define BDR(I)                 ((I)->nbr_self->bd_router)
                    186: #define OPTIONS(I)             ((I)->nbr_self->options)
                    187: #define PRIORITY(I)            ((I)->nbr_self->priority)
                    188: 
                    189:   /* List of configured NBMA neighbor. */
                    190:   struct list *nbr_nbma;
                    191: 
                    192:   /* self-originated LSAs. */
                    193:   struct ospf_lsa *network_lsa_self;   /* network-LSA. */
                    194: #ifdef HAVE_OPAQUE_LSA
                    195:   struct list *opaque_lsa_self;                        /* Type-9 Opaque-LSAs */
                    196: #endif /* HAVE_OPAQUE_LSA */
                    197: 
                    198:   struct route_table *ls_upd_queue;
                    199: 
                    200:   struct list *ls_ack;                 /* Link State Acknowledgment list. */
                    201:   
                    202:   struct
                    203:   {
                    204:     struct list *ls_ack;
                    205:     struct in_addr dst;
                    206:   } ls_ack_direct;
                    207: 
                    208:   /* Timer values. */
                    209:   u_int32_t v_ls_ack;                  /* Delayed Link State Acknowledgment */
                    210: 
                    211:   /* Threads. */
                    212:   struct thread *t_hello;               /* timer */
                    213:   struct thread *t_wait;                /* timer */
                    214:   struct thread *t_ls_ack;              /* timer */
                    215:   struct thread *t_ls_ack_direct;       /* event */
                    216:   struct thread *t_ls_upd_event;        /* event */
                    217: #ifdef HAVE_OPAQUE_LSA
                    218:   struct thread *t_opaque_lsa_self;     /* Type-9 Opaque-LSAs */
                    219: #endif /* HAVE_OPAQUE_LSA */
                    220: 
                    221:   int on_write_q;
                    222:   
                    223:   /* Statistics fields. */
                    224:   u_int32_t hello_in;          /* Hello message input count. */
                    225:   u_int32_t hello_out;         /* Hello message output count. */
                    226:   u_int32_t db_desc_in;         /* database desc. message input count. */
                    227:   u_int32_t db_desc_out;        /* database desc. message output count. */
                    228:   u_int32_t ls_req_in;          /* LS request message input count. */
                    229:   u_int32_t ls_req_out;         /* LS request message output count. */
                    230:   u_int32_t ls_upd_in;          /* LS update message input count. */
                    231:   u_int32_t ls_upd_out;         /* LS update message output count. */
                    232:   u_int32_t ls_ack_in;          /* LS Ack message input count. */
                    233:   u_int32_t ls_ack_out;         /* LS Ack message output count. */
                    234:   u_int32_t discarded;         /* discarded input count by error. */
                    235:   u_int32_t state_change;      /* Number of status change. */
                    236: 
                    237:   u_int32_t full_nbrs;
                    238: };
                    239: 
                    240: /* Prototypes. */
                    241: extern char *ospf_if_name (struct ospf_interface *);
                    242: extern struct ospf_interface *ospf_if_new (struct ospf *, struct interface *,
                    243:                                           struct prefix *);
                    244: extern void ospf_if_cleanup (struct ospf_interface *);
                    245: extern void ospf_if_free (struct ospf_interface *);
                    246: extern int ospf_if_up (struct ospf_interface *);
                    247: extern int ospf_if_down (struct ospf_interface *);
                    248: 
                    249: extern int ospf_if_is_up (struct ospf_interface *);
                    250: extern struct ospf_interface *ospf_if_exists (struct ospf_interface *);
1.1.1.2 ! misho     251: extern struct ospf_interface *ospf_if_lookup_by_lsa_pos (struct ospf_area *,
        !           252:                                                         int);
1.1       misho     253: extern struct ospf_interface *ospf_if_lookup_by_local_addr (struct ospf *,
                    254:                                                            struct interface
                    255:                                                            *,
                    256:                                                            struct in_addr);
                    257: extern struct ospf_interface *ospf_if_lookup_by_prefix (struct ospf *,
                    258:                                                        struct prefix_ipv4 *);
                    259: extern struct ospf_interface *ospf_if_table_lookup (struct interface *,
                    260:                                                    struct prefix *);
                    261: extern struct ospf_interface *ospf_if_addr_local (struct in_addr);
                    262: extern struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *,
                    263:                                                      struct in_addr,
                    264:                                                      struct interface *);
                    265: extern struct ospf_interface *ospf_if_is_configured (struct ospf *,
                    266:                                                     struct in_addr *);
                    267: 
                    268: extern struct ospf_if_params *ospf_lookup_if_params (struct interface *,
                    269:                                                     struct in_addr);
                    270: extern struct ospf_if_params *ospf_get_if_params (struct interface *,
                    271:                                                  struct in_addr);
                    272: extern void ospf_del_if_params (struct ospf_if_params *);
                    273: extern void ospf_free_if_params (struct interface *, struct in_addr);
                    274: extern void ospf_if_update_params (struct interface *, struct in_addr);
                    275: 
                    276: extern int ospf_if_new_hook (struct interface *);
                    277: extern void ospf_if_init (void);
                    278: extern void ospf_if_stream_set (struct ospf_interface *);
                    279: extern void ospf_if_stream_unset (struct ospf_interface *);
                    280: extern void ospf_if_reset_variables (struct ospf_interface *);
                    281: extern int ospf_if_is_enable (struct ospf_interface *);
                    282: extern int ospf_if_get_output_cost (struct ospf_interface *);
                    283: extern void ospf_if_recalculate_output_cost (struct interface *);
                    284: 
                    285: /* Simulate down/up on the interface. */
                    286: extern void ospf_if_reset (struct interface *);
                    287: 
                    288: extern struct ospf_interface *ospf_vl_new (struct ospf *,
                    289:                                           struct ospf_vl_data *);
                    290: extern struct ospf_vl_data *ospf_vl_data_new (struct ospf_area *,
                    291:                                              struct in_addr);
                    292: extern struct ospf_vl_data *ospf_vl_lookup (struct ospf *, struct ospf_area *,
                    293:                                            struct in_addr);
                    294: extern void ospf_vl_data_free (struct ospf_vl_data *);
                    295: extern void ospf_vl_add (struct ospf *, struct ospf_vl_data *);
                    296: extern void ospf_vl_delete (struct ospf *, struct ospf_vl_data *);
                    297: extern void ospf_vl_up_check (struct ospf_area *, struct in_addr,
                    298:                              struct vertex *);
                    299: extern void ospf_vl_unapprove (struct ospf *);
                    300: extern void ospf_vl_shut_unapproved (struct ospf *);
                    301: extern int ospf_full_virtual_nbrs (struct ospf_area *);
                    302: extern int ospf_vls_in_area (struct ospf_area *);
                    303: 
                    304: extern struct crypt_key *ospf_crypt_key_lookup (struct list *, u_char);
                    305: extern struct crypt_key *ospf_crypt_key_new (void);
                    306: extern void ospf_crypt_key_add (struct list *, struct crypt_key *);
                    307: extern int ospf_crypt_key_delete (struct list *, u_char);
                    308: 
                    309: extern u_char ospf_default_iftype (struct interface *ifp);
                    310: 
                    311: /* Set all multicast memberships appropriately based on the type and
                    312:    state of the interface. */
                    313: extern void ospf_if_set_multicast (struct ospf_interface *);
                    314: 
                    315: #endif /* _ZEBRA_OSPF_INTERFACE_H */

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