Remove unused variables.
[l2tpns.git] / l2tpns.c
index 90ac930..dc87ad8 100644 (file)
--- a/l2tpns.c
+++ b/l2tpns.c
@@ -456,7 +456,7 @@ static void routeset(sessionidt s, in_addr_t ip, int prefixlen, in_addr_t gw, in
        req.rt.rtm_family = AF_INET;
        req.rt.rtm_dst_len = prefixlen;
        req.rt.rtm_table = RT_TABLE_MAIN;
-       req.rt.rtm_protocol = RTPROT_BOOT; // XXX
+       req.rt.rtm_protocol = 42;
        req.rt.rtm_scope = RT_SCOPE_LINK;
        req.rt.rtm_type = RTN_UNICAST;
 
@@ -469,7 +469,7 @@ static void routeset(sessionidt s, in_addr_t ip, int prefixlen, in_addr_t gw, in
                netlink_addattr(&req.nh, RTA_GATEWAY, &n_ip, sizeof(n_ip));
        }
 
-       LOG(1, s, 0, "Route %s %s/%d%s%s\n", add ? "add" : "del",
+       LOG(1, s, session[s].tunnel, "Route %s %s/%d%s%s\n", add ? "add" : "del",
            fmtaddr(htonl(ip), 0), prefixlen,
            gw ? " via" : "", gw ? fmtaddr(htonl(gw), 2) : "");
 
@@ -535,7 +535,7 @@ void route6set(sessionidt s, struct in6_addr ip, int prefixlen, int add)
        req.rt.rtm_family = AF_INET6;
        req.rt.rtm_dst_len = prefixlen;
        req.rt.rtm_table = RT_TABLE_MAIN;
-       req.rt.rtm_protocol = RTPROT_BOOT; // XXX
+       req.rt.rtm_protocol = 42;
        req.rt.rtm_scope = RT_SCOPE_LINK;
        req.rt.rtm_type = RTN_UNICAST;
 
@@ -544,7 +544,7 @@ void route6set(sessionidt s, struct in6_addr ip, int prefixlen, int add)
        metric = 1;
        netlink_addattr(&req.nh, RTA_METRICS, &metric, sizeof(metric));
 
-       LOG(1, 0, 0, "Route %s %s/%d\n",
+       LOG(1, s, session[s].tunnel, "Route %s %s/%d\n",
            add ? "add" : "del",
            inet_ntop(AF_INET6, &ip, ipv6addr, INET6_ADDRSTRLEN),
            prefixlen);
@@ -1665,7 +1665,6 @@ static void send_ipout(sessionidt s, uint8_t *buf, int len)
 {
        sessiont *sp;
        tunnelidt t;
-       in_addr_t ip;
 
        uint8_t b[MAXETHER + 20];
 
@@ -1679,8 +1678,6 @@ static void send_ipout(sessionidt s, uint8_t *buf, int len)
        buf += 4;
        len -= 4;
 
-       ip = *(in_addr_t *)(buf + 16);
-
        if (!session[s].ip)
                return;
 
@@ -4294,14 +4291,9 @@ static void initdata(int optdebug, char *optconfig)
 
        if (!*hostname)
        {
-               if (!*config->hostname)
-               {
-                       // Grab my hostname unless it's been specified
-                       gethostname(hostname, sizeof(hostname));
-                       stripdomain(hostname);
-               }
-               else
-                       strcpy(hostname, config->hostname);
+               // Grab my hostname unless it's been specified
+               gethostname(hostname, sizeof(hostname));
+               stripdomain(hostname);
        }
 
        _statistics->start_time = _statistics->last_reset = time(NULL);
@@ -4716,8 +4708,12 @@ int main(int argc, char *argv[])
        initplugins();
        initdata(optdebug, optconfig);
 
-       init_cli(hostname);
+       init_cli();
        read_config_file();
+       /* set hostname /after/ having read the config file */
+       if (*config->hostname)
+               strcpy(hostname, config->hostname);
+       cli_init_hostname(hostname);
        update_config();
        init_tbf(config->num_tbfs);