Statistics
| Branch: | Revision:

iof-bird-daemon / nest / iface.h @ bcbd8cc3

History | View | Annotate | Download (3.11 KB)

1
/*
2
 *        BIRD Internet Routing Daemon -- Network Interfaces
3
 *
4
 *        (c) 1998--1999 Martin Mares <mj@ucw.cz>
5
 *
6
 *        Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
#ifndef _BIRD_IFACE_H_
10
#define _BIRD_IFACE_H_
11

    
12
#include "lib/lists.h"
13

    
14
extern list iface_list;
15

    
16
struct proto;
17

    
18
struct iface {
19
  node n;
20
  char name[16];
21
  unsigned flags;
22
  unsigned mtu;
23
  unsigned index;                        /* OS-dependent interface index */
24
  ip_addr ip;                                /* IP address of this host (0=unset) */
25
  ip_addr prefix;                        /* Network prefix */
26
  unsigned pxlen;                        /* Prefix length */
27
  ip_addr brd;                                /* Broadcast address */
28
  ip_addr opposite;                        /* Opposite end of a point-to-point link */
29
  struct neighbor *neigh;                /* List of neighbors on this interface */
30
};
31

    
32
#define IF_UP 1                                /* IF_LINK_UP, not IF_IGNORE and IP address known */
33
#define IF_MULTIACCESS 2
34
#define IF_UNNUMBERED 4
35
#define IF_BROADCAST 8
36
#define IF_MULTICAST 16
37
#define IF_TUNNEL 32
38
#define IF_ADMIN_DOWN 64
39
#define IF_LOOPBACK 128
40
#define IF_IGNORE 256
41
#define IF_LINK_UP 512
42
#define IF_UPDATED 0x40000000                /* Touched in last scan */
43

    
44
/* Interface change events */
45

    
46
#define IF_CHANGE_UP 1
47
#define IF_CHANGE_DOWN 2
48
#define IF_CHANGE_FLAGS 4                /* Can be converted to down/up internally */
49
#define IF_CHANGE_MTU 8
50
#define IF_CHANGE_CREATE 16                /* Seen this interface for the first time */
51

    
52
void if_init(void);
53
void if_dump(struct iface *);
54
void if_dump_all(void);
55
void if_update(struct iface *);
56
void if_end_update(void);
57
void if_feed_baby(struct proto *);
58

    
59
/*
60
 *        Neighbor Cache. We hold (direct neighbor, protocol) pairs we've seen
61
 *        along with pointer to protocol-specific data.
62
 *
63
 *        The primary goal of this cache is to quickly validate all incoming
64
 *        packets if their have been sent by our neighbors and to notify
65
 *        protocols about lost neighbors when an interface goes down.
66
 *
67
 *        Anyway, it can also contain `sticky' entries for currently unreachable
68
 *        addresses which cause notification when the address becomes a neighbor.
69
 */
70

    
71
typedef struct neighbor {
72
  node n;                                /* Node in global neighbor list */
73
  ip_addr addr;                                /* Address of the neighbor */
74
  struct iface *iface;                        /* Interface it's connected to */
75
  struct neighbor *sibling;                /* Next in per-device chain */
76
  struct proto *proto;                        /* Protocol this belongs to */
77
  void *data;                                /* Protocol-specific data */
78
  unsigned flags;
79
} neighbor;
80

    
81
#define NEF_STICKY 1
82

    
83
/*
84
 * Find neighbor or return NULL if it doesn't exist.
85
 * If you specify flags == NEF_STICKY, a sticky entry is created if the
86
 * address is not a neighbor, but NULL can still be returned if the address
87
 * given is invalid.
88
 */
89
neighbor *neigh_find(struct proto *, ip_addr *, unsigned flags);
90

    
91
void neigh_dump(neighbor *);
92
void neigh_dump_all(void);
93
void neigh_prune(void);
94

    
95
/*
96
 *        Interface Pattern Lists
97
 */
98

    
99
struct iface_patt {
100
  node n;
101
  byte *pattern;                        /* Interface name pattern */
102

    
103
  /* Protocol-specific data follow, but keep them like this:
104
     struct rip_iface_patt {
105
        struct iface_patt i;
106
        whatever you (need);
107
     }
108
   */
109
};
110

    
111
struct iface_patt *iface_patt_match(list *, struct iface *);
112
int iface_patts_equal(list *, list *, int (*)(struct iface_patt *, struct iface_patt *));
113

    
114
#endif