Commit 75ceb38e authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement -t and -T.

parent 6898efa1
......@@ -193,6 +193,16 @@ main(int argc, char **argv)
link_detect = 1;
} else if(strcmp(*arg, "-w") == 0) {
all_wireless = 1;
} else if(strcmp(*arg, "-t") == 0) {
SHIFTE();
export_table = atoi(*arg);
if(export_table < 0 || export_table > 0xFFFF)
goto syntax;
} else if(strcmp(*arg, "-T") == 0) {
SHIFTE();
import_table = atoi(*arg);
if(import_table < 0 || import_table > 0xFFFF)
goto syntax;
} else {
goto syntax;
}
......@@ -626,7 +636,9 @@ main(int argc, char **argv)
" "
"[-u update] [-k metric] [-4] [-s] [-P] [-c cost] [-l] [-w]\n"
" "
"[-d level] [-x net cost] [-X net cost]... id interface...\n",
"[-d level] [-t table] [-T table] [-x net cost] [-X net cost]\n"
" "
"id interface...\n",
argv[0]);
exit(1);
......
......@@ -34,6 +34,8 @@ struct kernel_route {
#define ROUTE_ADD 1
#define ROUTE_MODIFY 2
extern int export_table, import_table;
int kernel_setup(int setup, int ipv4);
int kernel_setup_socket(int setup);
int kernel_setup_interface(int setup, const char *ifname, int ifindex);
......
......@@ -48,6 +48,8 @@ THE SOFTWARE.
#include "kernel.h"
#include "util.h"
int export_table = -1, import_table = -1;
static int old_forwarding = -1;
static int old_ipv4_forwarding = -1;
static int old_accept_redirects = -1;
......@@ -391,6 +393,12 @@ kernel_setup(int setup, int ipv4)
int rc;
if(setup) {
if(export_table < 0)
export_table = RT_TABLE_MAIN;
if(import_table < 0)
import_table = RT_TABLE_MAIN;
dgram_socket = socket(PF_INET, SOCK_DGRAM, 0);
if(dgram_socket < 0)
return -1;
......@@ -697,7 +705,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
rtm = NLMSG_DATA(&buf.nh);
rtm->rtm_family = ipv4 ? AF_INET : AF_INET6;
rtm->rtm_dst_len = ipv4 ? plen - 96 : plen;
rtm->rtm_table = RT_TABLE_MAIN;
rtm->rtm_table = export_table;
rtm->rtm_scope = RT_SCOPE_UNIVERSE;
if(metric < KERNEL_INFINITY)
rtm->rtm_type = RTN_UNICAST;
......@@ -800,7 +808,7 @@ parse_kernel_route_rta(struct rtmsg *rtm, int len, struct kernel_route *route)
}
#undef COPY_ADDR
if(table != RT_TABLE_MAIN)
if(table != import_table)
return -1;
return 0;
......
......@@ -45,6 +45,8 @@ THE SOFTWARE.
#include "kernel.h"
#include "util.h"
int export_table = -1, import_table = -1;
/* KAME said : "Following two macros are highly depending on KAME Release" */
#define IN6_LINKLOCAL_IFINDEX(a) ((a).s6_addr[2] << 8 | (a).s6_addr[3])
#define SET_IN6_LINKLOCAL_IFINDEX(a, i) \
......
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