Revision acc93efd

View differences:

configure.in
13 13
AC_ARG_WITH(sysconfig,[  --with-sysconfig=FILE   use specified BIRD system configuration file])
14 14
AC_ARG_WITH(protocols,[  --with-protocols=LIST   include specified routing protocols (default: all)],,[with_protocols="all"])
15 15
AC_ARG_WITH(sysinclude,[  --with-sysinclude=PATH  search for system includes on specified place])
16
AC_ARG_WITH(iproutedir,[  --with-iproutedir=PATH  path to iproute2 config files (default: /etc/iproute2)],[given_iproutedir="yes"])
16 17
AC_ARG_VAR([FLEX], [location of the Flex program]) 
17 18
AC_ARG_VAR([BISON], [location of the Bison program]) 
18 19
AC_ARG_VAR([M4], [location of the M4 program]) 
......
105 106
else
106 107
	case "$ip:$host_os" in
107 108
		ipv4:linux*)	BIRD_CHECK_LINUX_VERSION
109
				default_iproutedir="/etc/iproute2"
108 110
				case $bird_cv_sys_linux_version in
109 111
					1.*|2.0.*)	sysdesc=linux-20 ;;
110 112
					*)		sysdesc=linux-22 ;;
111 113
					esac
112 114
				;;
113 115
		ipv6:linux*)	BIRD_CHECK_LINUX_VERSION
116
				default_iproutedir="/etc/iproute2"
114 117
				case $bird_cv_sys_linux_version in
115 118
					1.*|2.0.*)	AC_MSG_ERROR([This version of Linux doesn't support IPv6.]) ;;
116 119
					*)		sysdesc=linux-v6 ;;
......
154 157
AC_MSG_RESULT($sysdep_dirs)
155 158
AC_SUBST(sysdep_dirs)
156 159

  
160
if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
161

  
162
if test -n "$given_iproutedir"
163
then iproutedir=$with_iproutedir
164
else iproutedir=$default_iproutedir
165
fi
166

  
167
AC_SUBST(iproutedir)
168

  
157 169
AC_MSG_CHECKING([protocols])
158 170
protocols=`echo "$with_protocols" | sed 's/,/ /g'`
159 171
if test "$protocols" = no ; then protocols= ; fi
......
234 246
AC_CONFIG_FILES($makefiles)
235 247
AC_OUTPUT
236 248

  
249
rm -f $objdir/sysdep/paths.h
250

  
237 251
cat >&AC_FD_MSG <<EOF
238 252

  
239 253
BIRD was configured with the following options:
240 254
	Source directory:	$srcdir
241 255
	Object directory:	$objdir
256
	Iproute2 directory:	$iproutedir
242 257
	System configuration:	$sysdesc
243 258
	Debugging:		$enable_debug
244 259
	Routing protocols:	$protocols
doc/bird.sgml
266 266
	about configuring protocols in their own chapters. You can run more than one instance of
267 267
	most protocols (like RIP or BGP). By default, no instances are configured.
268 268

  
269
	<tag>define <m/constant/ = (<m/expression/)|<m/number/|<m/IP address/</tag> Define a constant. You can use it later in every place
270
	you could use a simple integer or an IP address.
269
	<tag>define <m/constant/ = (<m/expression/)|<m/number/|<m/IP address/</tag>
270
	Define a constant. You can use it later in every place you could use a simple integer or an IP address.
271
	Besides, there are some predefined numeric constants based on /etc/iproute2/rt_* files.
272
	A list of defined constants can be seen (together with other symbols) using 'show symbols' command.
271 273

  
272 274
	<tag>router id <m/IPv4 address/</tag> Set BIRD's router ID. It's a world-wide unique identification of your router, usually one of router's IPv4 addresses. Default: in IPv4 version, the lowest IP address of a non-loopback interface. In IPv6 version, this option is mandatory. 
273 275

  
sysdep/unix/main.c
62 62
 *	Reading the Configuration
63 63
 */
64 64

  
65
#ifdef PATH_IPROUTE_DIR
66

  
67
static inline void
68
add_num_const(char *name, int val)
69
{
70
  struct symbol *s = cf_find_symbol(name);
71
  s->class = SYM_NUMBER;
72
  s->def = NULL;
73
  s->aux = val;
74
}
75

  
76
/* the code of read_iproute_table() is based on
77
   rtnl_tab_initialize() from iproute2 package */
78
static void
79
read_iproute_table(char *file, char *prefix, int max)
80
{
81
  char buf[512], namebuf[512];
82
  char *name;
83
  int val;
84
  FILE *fp;
85

  
86
  strcpy(namebuf, prefix);
87
  name = namebuf + strlen(prefix);
88

  
89
  fp = fopen(file, "r");
90
  if (!fp)
91
    return;
92

  
93
  while (fgets(buf, sizeof(buf), fp))
94
  {
95
    char *p = buf;
96

  
97
    while (*p == ' ' || *p == '\t')
98
      p++;
99

  
100
    if (*p == '#' || *p == '\n' || *p == 0)
101
      continue;
102
   
103
    if (sscanf(p, "0x%x %s\n", &val, name) != 2 &&
104
	sscanf(p, "0x%x %s #", &val, name) != 2 &&
105
	sscanf(p, "%d %s\n", &val, name) != 2 &&
106
	sscanf(p, "%d %s #", &val, name) != 2)
107
      continue;
108

  
109
    if (val < 0 || val > max)
110
      continue;
111

  
112
    for(p = name; *p; p++)
113
      if ((*p < 'a' || *p > 'z') && (*p < '0' || *p > '9') && (*p != '_'))
114
	*p = '_';
115

  
116
    add_num_const(namebuf, val);
117
  }
118

  
119
  fclose(fp);
120
}
121

  
122
#endif // PATH_IPROUTE_DIR
123

  
124

  
65 125
static int conf_fd;
66 126
static char *config_name = PATH_CONFIG;
67 127

  
......
78 138
sysdep_preconfig(struct config *c)
79 139
{
80 140
  init_list(&c->logfiles);
141

  
142
#ifdef PATH_IPROUTE_DIR
143
  // read_iproute_table(PATH_IPROUTE_DIR "/rt_protos", "ipp_", 256);
144
  read_iproute_table(PATH_IPROUTE_DIR "/rt_realms", "ipr_", 256);
145
  read_iproute_table(PATH_IPROUTE_DIR "/rt_scopes", "ips_", 256);
146
  read_iproute_table(PATH_IPROUTE_DIR "/rt_tables", "ipt_", 256);
147
#endif
81 148
}
82 149

  
83 150
int
tools/Makefile.in
50 50
	echo >sysdep/paths.h "/* Generated by Makefile, don't edit manually! */"
51 51
	echo >>sysdep/paths.h "#define PATH_CONFIG_DIR \"$(sysconfdir)\""
52 52
	echo >>sysdep/paths.h "#define PATH_CONTROL_SOCKET_DIR \"$(localstatedir)/run\""
53
	if test -n "@iproutedir@" ; then echo >>sysdep/paths.h "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
53 54

  
54 55
tags:
55 56
	cd $(srcdir) ; etags -lc `find $(static-dirs) $(addprefix $(objdir)/,$(dynamic-dirs)) $(client-dirs) -name *.[chY]`

Also available in: Unified diff