Annotation of embedaddon/bird2/proto/rip/rip.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  *     BIRD -- Routing Information Protocol (RIP)
        !             3:  *
        !             4:  *     (c) 1998--1999 Pavel Machek <pavel@ucw.cz>
        !             5:  *     (c) 2004--2013 Ondrej Filip <feela@network.cz>
        !             6:  *     (c) 2009--2015 Ondrej Zajicek <santiago@crfreenet.org>
        !             7:  *     (c) 2009--2015 CZ.NIC z.s.p.o.
        !             8:  *
        !             9:  *     Can be freely distributed and used under the terms of the GNU GPL.
        !            10:  */
        !            11: 
        !            12: #ifndef _BIRD_RIP_H_
        !            13: #define _BIRD_RIP_H_
        !            14: 
        !            15: #include "nest/bird.h"
        !            16: #include "nest/cli.h"
        !            17: #include "nest/iface.h"
        !            18: #include "nest/protocol.h"
        !            19: #include "nest/route.h"
        !            20: #include "nest/password.h"
        !            21: #include "nest/locks.h"
        !            22: #include "nest/bfd.h"
        !            23: #include "lib/lists.h"
        !            24: #include "lib/resource.h"
        !            25: #include "lib/socket.h"
        !            26: #include "lib/string.h"
        !            27: #include "lib/timer.h"
        !            28: 
        !            29: 
        !            30: #define RIP_V1                 1
        !            31: #define RIP_V2                 2
        !            32: 
        !            33: #define RIP_PORT               520     /* RIP for IPv4 */
        !            34: #define RIP_NG_PORT            521     /* RIPng */
        !            35: 
        !            36: #define RIP_MAX_PKT_LENGTH     532     /* 512 + IP4_HEADER_LENGTH */
        !            37: #define RIP_AUTH_TAIL_LENGTH   4       /* Without auth_data */
        !            38: 
        !            39: #define RIP_DEFAULT_ECMP_LIMIT 16
        !            40: #define RIP_DEFAULT_INFINITY   16
        !            41: #define RIP_DEFAULT_UPDATE_TIME          (30 S_)
        !            42: #define RIP_DEFAULT_TIMEOUT_TIME (180 S_)
        !            43: #define RIP_DEFAULT_GARBAGE_TIME (120 S_)
        !            44: 
        !            45: 
        !            46: struct rip_config
        !            47: {
        !            48:   struct proto_config c;
        !            49:   list patt_list;                      /* List of iface configs (struct rip_iface_config) */
        !            50: 
        !            51:   u8 rip2;                             /* RIPv2 (IPv4) or RIPng (IPv6) */
        !            52:   u8 ecmp;                             /* Maximum number of nexthops in ECMP route, or 0 */
        !            53:   u8 infinity;                         /* Maximum metric value, representing infinity */
        !            54: 
        !            55:   btime min_timeout_time;              /* Minimum of interface timeout_time */
        !            56:   btime max_garbage_time;              /* Maximum of interface garbage_time */
        !            57: };
        !            58: 
        !            59: struct rip_iface_config
        !            60: {
        !            61:   struct iface_patt i;
        !            62:   ip_addr address;                     /* Configured dst address */
        !            63:   u16 port;                            /* Src+dst port */
        !            64:   u8 metric;                           /* Incoming metric */
        !            65:   u8 mode;                             /* Interface mode (RIP_IM_*) */
        !            66:   u8 passive;                          /* Passive iface - no packets are sent */
        !            67:   u8 version;                          /* RIP version used for outgoing packets */
        !            68:   u8 version_only;     /* FIXXX */
        !            69:   u8 split_horizon;                    /* Split horizon is used in route updates */
        !            70:   u8 poison_reverse;                   /* Poisoned reverse is used in route updates */
        !            71:   u8 check_zero;                       /* Validation of RIPv1 reserved fields */
        !            72:   u8 ecmp_weight;                      /* Weight for ECMP routes*/
        !            73:   u8 auth_type;                                /* Authentication type (RIP_AUTH_*) */
        !            74:   u8 ttl_security;                     /* bool + 2 for TX only (send, but do not check on RX) */
        !            75:   u8 check_link;                       /* Whether iface link change is used */
        !            76:   u8 bfd;                              /* Use BFD on iface */
        !            77:   u16 rx_buffer;                       /* RX buffer size, 0 for MTU */
        !            78:   u16 tx_length;                       /* TX packet length limit (including headers), 0 for MTU */
        !            79:   int tx_tos;
        !            80:   int tx_priority;
        !            81:   btime update_time;                   /* Periodic update interval */
        !            82:   btime timeout_time;                  /* Route expiration timeout */
        !            83:   btime garbage_time;                  /* Unreachable entry GC timeout */
        !            84:   list *passwords;                     /* Passwords for authentication */
        !            85: };
        !            86: 
        !            87: struct rip_proto
        !            88: {
        !            89:   struct proto p;
        !            90:   struct fib rtable;                   /* Internal routing table */
        !            91:   list iface_list;                     /* List of interfaces (struct rip_iface) */
        !            92:   slab *rte_slab;                      /* Slab for internal routes (struct rip_rte) */
        !            93:   timer *timer;                                /* Main protocol timer */
        !            94: 
        !            95:   u8 rip2;                             /* RIPv2 (IPv4) or RIPng (IPv6) */
        !            96:   u8 ecmp;                             /* Maximum number of nexthops in ECMP route, or 0 */
        !            97:   u8 infinity;                         /* Maximum metric value, representing infinity */
        !            98:   u8 triggered;                                /* Logical AND of interface want_triggered values */
        !            99:   u8 rt_reload;                                /* Route reload is scheduled */
        !           100: 
        !           101:   struct tbf log_pkt_tbf;              /* TBF for packet messages */
        !           102:   struct tbf log_rte_tbf;              /* TBF for RTE messages */
        !           103: };
        !           104: 
        !           105: struct rip_iface
        !           106: {
        !           107:   node n;
        !           108:   struct rip_proto *rip;
        !           109:   struct iface *iface;                 /* Underyling core interface */
        !           110:   struct rip_iface_config *cf;         /* Related config, must be updated in reconfigure */
        !           111:   struct object_lock *lock;            /* Interface lock */
        !           112:   timer *timer;                                /* Interface timer */
        !           113:   sock *sk;                            /* UDP socket */
        !           114: 
        !           115:   u8 up;                               /* Interface is active */
        !           116:   u8 csn_ready;                                /* Nonzero CSN can be used */
        !           117:   u16 tx_plen;                         /* Max TX packet data length */
        !           118:   u32 csn;                             /* Last used crypto sequence number */
        !           119:   ip_addr addr;                                /* Destination multicast/broadcast address */
        !           120:   list neigh_list;                     /* List of iface neighbors (struct rip_neighbor) */
        !           121: 
        !           122:   /* Update scheduling */
        !           123:   btime next_regular;                  /* Next time when regular update should be called */
        !           124:   btime next_triggered;                        /* Next time when triggerd update may be called */
        !           125:   btime want_triggered;                        /* Nonzero if triggered update is scheduled */
        !           126: 
        !           127:   /* Active update */
        !           128:   int tx_active;                       /* Update session is active */
        !           129:   ip_addr tx_addr;                     /* Update session destination address */
        !           130:   btime tx_changed;                    /* Minimal changed time for triggered update */
        !           131:   struct fib_iterator tx_fit;          /* FIB iterator in RIP routing table (p.rtable) */
        !           132: };
        !           133: 
        !           134: struct rip_neighbor
        !           135: {
        !           136:   node n;
        !           137:   struct rip_iface *ifa;               /* Associated interface, may be NULL if stale */
        !           138:   struct neighbor *nbr;                        /* Associaded core neighbor, may be NULL if stale */
        !           139:   struct bfd_request *bfd_req;         /* BFD request, if BFD is used */
        !           140:   btime last_seen;                     /* Time of last received and accepted message */
        !           141:   u32 uc;                              /* Use count, number of routes linking the neighbor */
        !           142:   u32 csn;                             /* Last received crypto sequence number */
        !           143: };
        !           144: 
        !           145: struct rip_entry
        !           146: {
        !           147:   struct rip_rte *routes;              /* List of incoming routes */
        !           148: 
        !           149:   u8 valid;                            /* Entry validity state (RIP_ENTRY_*) */
        !           150:   u8 metric;                           /* Outgoing route metric */
        !           151:   u16 tag;                             /* Outgoing route tag */
        !           152:   struct iface *from;                  /* Outgoing route from, NULL if from  proto */
        !           153:   struct iface *iface;                 /* Outgoing route iface (for next hop) */
        !           154:   ip_addr next_hop;                    /* Outgoing route next hop */
        !           155: 
        !           156:   btime changed;                       /* Last time when the outgoing route metric changed */
        !           157: 
        !           158:   struct fib_node n;
        !           159: };
        !           160: 
        !           161: struct rip_rte
        !           162: {
        !           163:   struct rip_rte *next;
        !           164: 
        !           165:   struct rip_neighbor *from;           /* Advertising router */
        !           166:   ip_addr next_hop;                    /* Route next hop (iface is from->nbr->iface) */
        !           167:   u16 metric;                          /* Route metric (after increase) */
        !           168:   u16 tag;                             /* Route tag */
        !           169: 
        !           170:   btime expires;                       /* Time of route expiration */
        !           171: };
        !           172: 
        !           173: 
        !           174: #define RIP_AUTH_NONE          0
        !           175: #define RIP_AUTH_PLAIN         2
        !           176: #define RIP_AUTH_CRYPTO                3
        !           177: 
        !           178: #define RIP_IM_MULTICAST       1
        !           179: #define RIP_IM_BROADCAST       2
        !           180: 
        !           181: #define RIP_ENTRY_DUMMY                0       /* Only used to store list of incoming routes */
        !           182: #define RIP_ENTRY_VALID                1       /* Valid outgoing route */
        !           183: #define RIP_ENTRY_STALE                2       /* Stale outgoing route, waiting for GC */
        !           184: 
        !           185: #define EA_RIP_METRIC          EA_CODE(PROTOCOL_RIP, 0)
        !           186: #define EA_RIP_TAG             EA_CODE(PROTOCOL_RIP, 1)
        !           187: 
        !           188: static inline int rip_is_v2(struct rip_proto *p)
        !           189: { return p->rip2; }
        !           190: 
        !           191: static inline int rip_is_ng(struct rip_proto *p)
        !           192: { return ! p->rip2; }
        !           193: 
        !           194: static inline void
        !           195: rip_reset_tx_session(struct rip_proto *p, struct rip_iface *ifa)
        !           196: {
        !           197:   if (ifa->tx_active)
        !           198:   {
        !           199:     FIB_ITERATE_UNLINK(&ifa->tx_fit, &p->rtable);
        !           200:     ifa->tx_active = 0;
        !           201:   }
        !           202: }
        !           203: 
        !           204: /* rip.c */
        !           205: void rip_update_rte(struct rip_proto *p, net_addr *n, struct rip_rte *new);
        !           206: void rip_withdraw_rte(struct rip_proto *p, net_addr *n, struct rip_neighbor *from);
        !           207: struct rip_neighbor * rip_get_neighbor(struct rip_proto *p, ip_addr *a, struct rip_iface *ifa);
        !           208: void rip_update_bfd(struct rip_proto *p, struct rip_neighbor *n);
        !           209: void rip_show_interfaces(struct proto *P, char *iff);
        !           210: void rip_show_neighbors(struct proto *P, char *iff);
        !           211: 
        !           212: /* packets.c */
        !           213: void rip_send_request(struct rip_proto *p, struct rip_iface *ifa);
        !           214: void rip_send_table(struct rip_proto *p, struct rip_iface *ifa, ip_addr addr, btime changed);
        !           215: int rip_open_socket(struct rip_iface *ifa);
        !           216: 
        !           217: 
        !           218: #endif

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