File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / quagga / ospf6d / ospf6_intra.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Nov 2 10:09:11 2016 UTC (7 years, 8 months ago) by misho
Branches: quagga, MAIN
CVS tags: v1_0_20160315, HEAD
quagga 1.0.20160315

    1: /*
    2:  * Copyright (C) 2003 Yasuhiro Ohara
    3:  *
    4:  * This file is part of GNU Zebra.
    5:  *
    6:  * GNU Zebra is free software; you can redistribute it and/or modify it
    7:  * under the terms of the GNU General Public License as published by the
    8:  * Free Software Foundation; either version 2, or (at your option) any
    9:  * later version.
   10:  *
   11:  * GNU Zebra is distributed in the hope that it will be useful, but
   12:  * WITHOUT ANY WARRANTY; without even the implied warranty of
   13:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14:  * General Public License for more details.
   15:  *
   16:  * You should have received a copy of the GNU General Public License
   17:  * along with GNU Zebra; see the file COPYING.  If not, write to the 
   18:  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
   19:  * Boston, MA 02111-1307, USA.  
   20:  */
   21: 
   22: #ifndef OSPF6_INTRA_H
   23: #define OSPF6_INTRA_H
   24: 
   25: /* Debug option */
   26: extern unsigned char conf_debug_ospf6_brouter;
   27: extern u_int32_t conf_debug_ospf6_brouter_specific_router_id;
   28: extern u_int32_t conf_debug_ospf6_brouter_specific_area_id;
   29: #define OSPF6_DEBUG_BROUTER_SUMMARY         0x01
   30: #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02
   31: #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA   0x04
   32: #define OSPF6_DEBUG_BROUTER_ON() \
   33:   (conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SUMMARY)
   34: #define OSPF6_DEBUG_BROUTER_OFF() \
   35:   (conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SUMMARY)
   36: #define IS_OSPF6_DEBUG_BROUTER \
   37:   (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SUMMARY)
   38: 
   39: #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id)             \
   40:   do {                                                                \
   41:     conf_debug_ospf6_brouter_specific_router_id = (router_id);        \
   42:     conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER;  \
   43:   } while (0)
   44: #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF()                     \
   45:   do {                                                                \
   46:     conf_debug_ospf6_brouter_specific_router_id = 0;                  \
   47:     conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
   48:   } while (0)
   49: #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER                        \
   50:   (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER)
   51: #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(router_id)          \
   52:   (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER &&                          \
   53:    conf_debug_ospf6_brouter_specific_router_id == (router_id))
   54: 
   55: #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id)                 \
   56:   do {                                                                \
   57:     conf_debug_ospf6_brouter_specific_area_id = (area_id);            \
   58:     conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA;    \
   59:   } while (0)
   60: #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF()                       \
   61:   do {                                                                \
   62:     conf_debug_ospf6_brouter_specific_area_id = 0;                    \
   63:     conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA;   \
   64:   } while (0)
   65: #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA                          \
   66:   (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_AREA)
   67: #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(area_id)              \
   68:   (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA &&                            \
   69:    conf_debug_ospf6_brouter_specific_area_id == (area_id))
   70: 
   71: /* Router-LSA */
   72: #define OSPF6_ROUTER_LSA_MIN_SIZE              4U
   73: struct ospf6_router_lsa
   74: {
   75:   u_char bits;
   76:   u_char options[3];
   77:   /* followed by ospf6_router_lsdesc(s) */
   78: };
   79: 
   80: /* Link State Description in Router-LSA */
   81: #define OSPF6_ROUTER_LSDESC_FIX_SIZE          16U
   82: struct ospf6_router_lsdesc
   83: {
   84:   u_char    type;
   85:   u_char    reserved;
   86:   u_int16_t metric;                /* output cost */
   87:   u_int32_t interface_id;
   88:   u_int32_t neighbor_interface_id;
   89:   u_int32_t neighbor_router_id;
   90: };
   91: 
   92: #define OSPF6_ROUTER_LSDESC_POINTTOPOINT       1
   93: #define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK    2
   94: #define OSPF6_ROUTER_LSDESC_STUB_NETWORK       3
   95: #define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK       4
   96: 
   97: enum stub_router_mode
   98:   {
   99:     OSPF6_NOT_STUB_ROUTER,
  100:     OSPF6_IS_STUB_ROUTER,
  101:     OSPF6_IS_STUB_ROUTER_V6,
  102:   };
  103: 
  104: #define ROUTER_LSDESC_IS_TYPE(t,x)                         \
  105:   ((((struct ospf6_router_lsdesc *)(x))->type ==           \
  106:    OSPF6_ROUTER_LSDESC_ ## t) ? 1 : 0)
  107: #define ROUTER_LSDESC_GET_METRIC(x)                        \
  108:   (ntohs (((struct ospf6_router_lsdesc *)(x))->metric))
  109: #define ROUTER_LSDESC_GET_IFID(x)                          \
  110:   (ntohl (((struct ospf6_router_lsdesc *)(x))->interface_id))
  111: #define ROUTER_LSDESC_GET_NBR_IFID(x)                      \
  112:   (ntohl (((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id))
  113: #define ROUTER_LSDESC_GET_NBR_ROUTERID(x)                  \
  114:   (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id)
  115: 
  116: /* Network-LSA */
  117: #define OSPF6_NETWORK_LSA_MIN_SIZE             4U
  118: struct ospf6_network_lsa
  119: {
  120:   u_char reserved;
  121:   u_char options[3];
  122:   /* followed by ospf6_netowrk_lsd(s) */
  123: };
  124: 
  125: /* Link State Description in Router-LSA */
  126: #define OSPF6_NETWORK_LSDESC_FIX_SIZE          4U
  127: struct ospf6_network_lsdesc
  128: {
  129:   u_int32_t router_id;
  130: };
  131: #define NETWORK_LSDESC_GET_NBR_ROUTERID(x)                  \
  132:   (((struct ospf6_network_lsdesc *)(x))->router_id)
  133: 
  134: /* Link-LSA */
  135: #define OSPF6_LINK_LSA_MIN_SIZE               24U /* w/o 1st IPv6 prefix */
  136: struct ospf6_link_lsa
  137: {
  138:   u_char          priority;
  139:   u_char          options[3];
  140:   struct in6_addr linklocal_addr;
  141:   u_int32_t       prefix_num;
  142:   /* followed by ospf6 prefix(es) */
  143: };
  144: 
  145: /* Intra-Area-Prefix-LSA */
  146: #define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE       12U /* w/o 1st IPv6 prefix */
  147: struct ospf6_intra_prefix_lsa
  148: {
  149:   u_int16_t prefix_num;
  150:   u_int16_t ref_type;
  151:   u_int32_t ref_id;
  152:   u_int32_t ref_adv_router;
  153:   /* followed by ospf6 prefix(es) */
  154: };
  155: 
  156: 
  157: #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
  158:   do { \
  159:     if (! (oa)->thread_router_lsa \
  160:         && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
  161:       (oa)->thread_router_lsa = \
  162:         thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \
  163:   } while (0)
  164: #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
  165:   do { \
  166:     if (! (oi)->thread_network_lsa \
  167:         && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
  168:       (oi)->thread_network_lsa = \
  169:         thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \
  170:   } while (0)
  171: #define OSPF6_LINK_LSA_SCHEDULE(oi) \
  172:   do { \
  173:     if (! (oi)->thread_link_lsa \
  174:         && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
  175:       (oi)->thread_link_lsa = \
  176:         thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \
  177:   } while (0)
  178: #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
  179:   do { \
  180:     if (! (oa)->thread_intra_prefix_lsa \
  181:         && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
  182:       (oa)->thread_intra_prefix_lsa = \
  183:         thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
  184:                           oa, 0); \
  185:   } while (0)
  186: #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
  187:   do { \
  188:     if (! (oi)->thread_intra_prefix_lsa \
  189:         && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
  190:       (oi)->thread_intra_prefix_lsa = \
  191:         thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
  192:                           oi, 0); \
  193:   } while (0)
  194: 
  195: #define OSPF6_NETWORK_LSA_EXECUTE(oi) \
  196:   do { \
  197:     THREAD_OFF ((oi)->thread_network_lsa); \
  198:     thread_execute (master, ospf6_network_lsa_originate, oi, 0); \
  199:   } while (0)
  200: #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
  201:   do { \
  202:     THREAD_OFF ((oi)->thread_intra_prefix_lsa); \
  203:     thread_execute (master, ospf6_intra_prefix_lsa_originate_transit, oi, 0); \
  204:   } while (0)
  205: 
  206: 
  207: /* Function Prototypes */
  208: extern char *ospf6_router_lsdesc_lookup (u_char type, u_int32_t interface_id,
  209:                                          u_int32_t neighbor_interface_id,
  210:                                          u_int32_t neighbor_router_id,
  211:                                          struct ospf6_lsa *lsa);
  212: extern char *ospf6_network_lsdesc_lookup (u_int32_t router_id,
  213:                                           struct ospf6_lsa *lsa);
  214: 
  215: extern int ospf6_router_is_stub_router (struct ospf6_lsa *lsa);
  216: extern int ospf6_router_lsa_originate (struct thread *);
  217: extern int ospf6_network_lsa_originate (struct thread *);
  218: extern int ospf6_link_lsa_originate (struct thread *);
  219: extern int ospf6_intra_prefix_lsa_originate_transit (struct thread *);
  220: extern int ospf6_intra_prefix_lsa_originate_stub (struct thread *);
  221: extern void ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa);
  222: extern void ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa);
  223: 
  224: extern void ospf6_intra_route_calculation (struct ospf6_area *oa);
  225: extern void ospf6_intra_brouter_calculation (struct ospf6_area *oa);
  226: 
  227: extern void ospf6_intra_init (void);
  228: 
  229: extern int config_write_ospf6_debug_brouter (struct vty *vty);
  230: extern void install_element_ospf6_debug_brouter (void);
  231: 
  232: #endif /* OSPF6_LSA_H */
  233: 

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