Commit ec19de91 authored by Grégoire Henry's avatar Grégoire Henry

Ajout de kernel_setup_socket.

parent 8138dfc2
...@@ -286,6 +286,12 @@ main(int argc, char **argv) ...@@ -286,6 +286,12 @@ main(int argc, char **argv)
exit(1); exit(1);
} }
rc = kernel_setup_socket(1);
if(rc < 0) {
fprintf(stderr, "kernel_setup_socket failed.\n");
exit(1);
}
protocol_socket = babel_socket(protocol_port); protocol_socket = babel_socket(protocol_port);
if(protocol_socket < 0) { if(protocol_socket < 0) {
perror("Couldn't create link local socket"); perror("Couldn't create link local socket");
...@@ -550,6 +556,7 @@ main(int argc, char **argv) ...@@ -550,6 +556,7 @@ main(int argc, char **argv)
usleep(50000 + random() % 100000); usleep(50000 + random() % 100000);
kernel_setup_interface(0, nets[i].ifname, nets[i].ifindex); kernel_setup_interface(0, nets[i].ifname, nets[i].ifindex);
} }
kernel_setup_socket(0);
kernel_setup(0); kernel_setup(0);
fd = open(state_file, O_WRONLY | O_TRUNC | O_CREAT, 0644); fd = open(state_file, O_WRONLY | O_TRUNC | O_CREAT, 0644);
...@@ -586,6 +593,7 @@ main(int argc, char **argv) ...@@ -586,6 +593,7 @@ main(int argc, char **argv)
fail: fail:
for(i = 0; i < numnets; i++) for(i = 0; i < numnets; i++)
kernel_setup_interface(0, nets[i].ifname, nets[i].ifindex); kernel_setup_interface(0, nets[i].ifname, nets[i].ifindex);
kernel_setup_socket(0);
kernel_setup(0); kernel_setup(0);
exit(1); exit(1);
} }
......
...@@ -458,14 +458,6 @@ kernel_setup(int setup) ...@@ -458,14 +458,6 @@ kernel_setup(int setup)
return -1; return -1;
} }
rc = netlink_socket(&nl_listen, RTMGRP_IPV6_ROUTE);
if(rc < 0) {
perror("netlink_socket(RTMGRP_IPV6_ROUTE)");
return -1;
}
kernel_socket = nl_listen.sock;
old_forwarding = read_proc("/proc/sys/net/ipv6/conf/all/forwarding"); old_forwarding = read_proc("/proc/sys/net/ipv6/conf/all/forwarding");
if(old_forwarding < 0) { if(old_forwarding < 0) {
perror("Couldn't read forwarding knob."); perror("Couldn't read forwarding knob.");
...@@ -512,6 +504,30 @@ kernel_setup(int setup) ...@@ -512,6 +504,30 @@ kernel_setup(int setup)
close(nl_command.sock); close(nl_command.sock);
nl_command.sock = -1; nl_command.sock = -1;
return 1;
}
}
int
kernel_setup_socket(int setup)
{
int rc;
if(setup) {
rc = netlink_socket(&nl_listen, RTMGRP_IPV6_ROUTE);
if(rc < 0) {
perror("netlink_socket(RTMGRP_IPV6_ROUTE)");
kernel_socket = -1;
return -1;
}
kernel_socket = nl_listen.sock;
return 1;
} else {
close(nl_listen.sock); close(nl_listen.sock);
nl_listen.sock = -1; nl_listen.sock = -1;
kernel_socket = -1; kernel_socket = -1;
......
...@@ -35,6 +35,7 @@ struct kernel_route { ...@@ -35,6 +35,7 @@ struct kernel_route {
#define ROUTE_MODIFY 2 #define ROUTE_MODIFY 2
int kernel_setup(int setup); int kernel_setup(int setup);
int kernel_setup_socket(int setup);
int kernel_setup_interface(int setup, const char *ifname, int ifindex); int kernel_setup_interface(int setup, const char *ifname, int ifindex);
int kernel_interface_mtu(const char *ifname, int ifindex); int kernel_interface_mtu(const char *ifname, int ifindex);
int kernel_interface_wireless(const char *ifname, int ifindex); int kernel_interface_wireless(const char *ifname, int ifindex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment