diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-03-22 03:10:55 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-03-22 03:10:55 +0100 |
commit | f6e36cf6d78ce8c5bed2e6d698928a89a9fbcc6f (patch) | |
tree | 69e2df2be718d891e68196052443c93ebcc74056 /src/shell.c | |
parent | 2e715f6c73505b8721d3d48e7c93598448699075 (diff) | |
download | fastd-f6e36cf6d78ce8c5bed2e6d698928a89a9fbcc6f.tar fastd-f6e36cf6d78ce8c5bed2e6d698928a89a9fbcc6f.zip |
First work towards multi-interface support
Diffstat (limited to 'src/shell.c')
-rw-r--r-- | src/shell.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/shell.c b/src/shell.c index 90102a2..3a617be 100644 --- a/src/shell.c +++ b/src/shell.c @@ -75,6 +75,13 @@ void fastd_shell_env_free(fastd_shell_env_t *env) { free(env); } +void fastd_shell_env_set_iface(fastd_shell_env_t *env, const fastd_iface_t *iface) { + if (iface) + fastd_shell_env_set(env, "INTERFACE", iface->name); + else + fastd_shell_env_set(env, "INTERFACE", NULL); +} + /** Applies a shell environment to the current process */ static void shell_command_setenv(pid_t pid, const fastd_shell_env_t *env) { char buf[20]; @@ -84,21 +91,6 @@ static void shell_command_setenv(pid_t pid, const fastd_shell_env_t *env) { snprintf(buf, sizeof(buf), "%u", (unsigned)pid); setenv("FASTD_PID", buf, 1); - if (ctx.ifname) { - setenv("INTERFACE", ctx.ifname, 1); - } - else if (conf.ifname) { - char ifname[IF_NAMESIZE]; - - strncpy(ifname, conf.ifname, sizeof(ifname)-1); - ifname[sizeof(ifname)-1] = 0; - - setenv("INTERFACE", ifname, 1); - } - else { - unsetenv("INTERFACE"); - } - snprintf(buf, sizeof(buf), "%u", conf.mtu); setenv("INTERFACE_MTU", buf, 1); |