summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2004-06-06 17:05:25 +0000
committerOndrej Filip <feela@network.cz>2004-06-06 17:05:25 +0000
commit41c8976e29bbf2986b063d1a8c5c8b386fae500e (patch)
tree129af3a1bde01335521a831a988472c4c963f3b1
parentcd09226078471cf9a2db4e755fbd5f6f137137c9 (diff)
Test old instance of BIRD.
-rw-r--r--sysdep/config.h20
-rw-r--r--sysdep/unix/io.c20
-rw-r--r--sysdep/unix/main.c2
-rw-r--r--sysdep/unix/unix.h2
4 files changed, 39 insertions, 5 deletions
diff --git a/sysdep/config.h b/sysdep/config.h
index 4e2e8e75..95b20d4b 100644
--- a/sysdep/config.h
+++ b/sysdep/config.h
@@ -36,12 +36,22 @@ typedef u16 word;
#endif
/* Path to configuration file */
-#ifdef DEBUGGING
-#define PATH_CONFIG "bird.conf"
-#define PATH_CONTROL_SOCKET "bird.ctl"
+#ifdef IPV6
+# ifdef DEBUGGING
+# define PATH_CONFIG "bird-6.conf"
+# define PATH_CONTROL_SOCKET "bird-6.ctl"
+# else
+# define PATH_CONFIG PATH_CONFIG_DIR "/bird-6.conf"
+# define PATH_CONTROL_SOCKET PATH_CONTROL_SOCKET_DIR "/bird-6.ctl"
+# endif
#else
-#define PATH_CONFIG PATH_CONFIG_DIR "/bird.conf"
-#define PATH_CONTROL_SOCKET PATH_CONTROL_SOCKET_DIR "/bird.ctl"
+# ifdef DEBUGGING
+# define PATH_CONFIG "bird.conf"
+# define PATH_CONTROL_SOCKET "bird.ctl"
+# else
+# define PATH_CONFIG PATH_CONFIG_DIR "/bird.conf"
+# define PATH_CONTROL_SOCKET PATH_CONTROL_SOCKET_DIR "/bird.ctl"
+# endif
#endif
#endif
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 4030b86b..ed5b89fa 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -1194,3 +1194,23 @@ io_loop(void)
}
}
}
+
+void
+test_old_bird(char *path)
+{
+ int fd;
+ struct sockaddr_un sa;
+
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+
+ if (fd < 0)
+ die("Cannot create socket: %m");
+ bzero(&sa, sizeof(sa));
+ sa.sun_family = AF_UNIX;
+ strcpy(sa.sun_path, path);
+ if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == 0)
+ die("I found another BIRD running.");
+ close(fd);
+}
+
+
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index ec8802bd..335f42a1 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -412,6 +412,8 @@ main(int argc, char **argv)
log_init_debug("");
log_init(debug_flag, 1);
+ test_old_bird(path_control_socket);
+
DBG("Initializing.\n");
resource_init();
olock_init();
diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h
index 72b6ef56..997a4088 100644
--- a/sysdep/unix/unix.h
+++ b/sysdep/unix/unix.h
@@ -46,6 +46,8 @@ void fill_in_sockaddr(sockaddr *sa, ip_addr a, unsigned port);
void get_sockaddr(sockaddr *sa, ip_addr *a, unsigned *port, int check);
int sk_open_unix(struct birdsock *s, char *name);
void *tracked_fopen(struct pool *, char *name, char *mode);
+void test_old_bird(char *path);
+
/* krt.c bits */