#endif
CONFIG("echo_timeout", echo_timeout, INT),
CONFIG("idle_echo_timeout", idle_echo_timeout, INT),
+ CONFIG("iftun_address", iftun_address, IPv4),
+ CONFIG("tundevicename", tundevicename, STRING),
#ifdef LAC
CONFIG("disable_lac_func", disable_lac_func, BOOL),
+ CONFIG("auth_tunnel_change_addr_src", auth_tunnel_change_addr_src, BOOL),
+ CONFIG("bind_address_remotelns", bind_address_remotelns, IPv4),
CONFIG("bind_portremotelns", bind_portremotelns, SHORT),
#endif
{ NULL, 0, 0, 0 },
}
// Time in milliseconds
- time_now_ms = (t.tv_sec * 1000) + (t.tv_usec/1000);
+ // TODO FOR MLPPP DEV
+ //time_now_ms = (t.tv_sec * 1000) + (t.tv_usec/1000);
return (t.tv_sec - basetime) * 10 + t.tv_usec / 100000 + 1;
}
ringbuffer->buffer[ringbuffer->tail].session = s;
ringbuffer->buffer[ringbuffer->tail].tunnel = t;
va_start(ap, format);
- vsnprintf(ringbuffer->buffer[ringbuffer->tail].message, 4095, format, ap);
+ vsnprintf(ringbuffer->buffer[ringbuffer->tail].message, MAX_LOG_LENGTH, format, ap);
va_end(ap);
}
#endif
int flags = fcntl(tunfd, F_GETFL, 0);
fcntl(tunfd, F_SETFL, flags | O_NONBLOCK);
}
+
+ if (*config->tundevicename)
+ strncpy(ifr.ifr_name, config->tundevicename, IFNAMSIZ);
+
if (ioctl(tunfd, TUNSETIFF, (void *) &ifr) < 0)
{
LOG(0, 0, 0, "Can't set tun interface: %s\n", strerror(errno));
exit(1);
}
- assert(strlen(ifr.ifr_name) < sizeof(config->tundevice) - 1);
- strncpy(config->tundevice, ifr.ifr_name, sizeof(config->tundevice));
+ assert(strlen(ifr.ifr_name) < sizeof(config->tundevicename) - 1);
+ strncpy(config->tundevicename, ifr.ifr_name, sizeof(config->tundevicename));
- tunidx = if_nametoindex(config->tundevice);
+ tunidx = if_nametoindex(config->tundevicename);
if (tunidx == 0)
{
LOG(0, 0, 0, "Can't get tun interface index\n");
req.ifmsg.ifaddr.ifa_scope = RT_SCOPE_UNIVERSE;
req.ifmsg.ifaddr.ifa_index = tunidx;
- if (config->bind_address)
- ip = config->bind_address;
+ if (config->iftun_address)
+ ip = config->iftun_address;
else
ip = 0x01010101; // 1.1.1.1
netlink_addattr(&req.nh, IFA_LOCAL, &ip, sizeof(ip));
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(config->bind_portremotelns);
+ addr.sin_addr.s_addr = config->bind_address_remotelns;
udplacfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
setsockopt(udplacfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
{
q[4] = 3; // ip address option
q[5] = 6; // option length
*(in_addr_t *) (q + 6) = config->peer_address ? config->peer_address :
- config->bind_address ? config->bind_address :
+ config->iftun_address ? config->iftun_address :
my_address; // send my IP
tunnelsend(buf, 10 + (q - buf), t); // send it
tunnelshutdown(t, "Stopped", 0, 0, 0); // Shut down cleanly
break;
case 6: // HELLO
+ LOG(3, s, t, "Received HELLO\n");
controlnull(t); // simply ACK
break;
case 7: // OCRQ
// Set multilink options before sending initial LCP packet
sess_local[s].mp_mrru = 1614;
- sess_local[s].mp_epdis = ntohl(config->bind_address ? config->bind_address : my_address);
+ sess_local[s].mp_epdis = ntohl(config->iftun_address ? config->iftun_address : my_address);
sendlcp(s, t);
change_state(s, lcp, RequestSent);
if (session[s].forwardtosession)
{
LOG(5, s, t, "Forwarding data session to session %u\n", session[s].forwardtosession);
- // Forward to LAC or Remote LNS session
- lac_session_forward(buf, len, s, proto);
+ // Forward to LAC/BAS or Remote LNS session
+ lac_session_forward(buf, len, s, proto, addr->sin_addr.s_addr, addr->sin_port);
return;
}
+ else if (config->auth_tunnel_change_addr_src)
+ {
+ if (tunnel[t].ip != ntohl(addr->sin_addr.s_addr) &&
+ tunnel[t].port == ntohs(addr->sin_port))
+ {
+ // The remotes BAS are a clustered l2tpns server and the source IP has changed
+ LOG(5, s, t, "The tunnel IP source (%s) has changed by new IP (%s)\n",
+ fmtaddr(htonl(tunnel[t].ip), 0), fmtaddr(addr->sin_addr.s_addr, 0));
+
+ tunnel[t].ip = ntohl(addr->sin_addr.s_addr);
+ }
+ }
#endif /* LAC */
if (s && !session[s].opened) // Is something wrong??
if ((s = read(tunfd, p, size_bufp)) > 0)
{
processtun(p, s);
- tun_pkts++;
+ tun_pkts++;
}
else
{
if (c >= config->multi_read_count)
{
#ifdef LAC
- LOG(3, 0, 0, "Reached multi_read_count (%d); processed %d udp, %d tun and %d cluster %d rmlns packets\n",
+ LOG(3, 0, 0, "Reached multi_read_count (%d); processed %d udp, %d tun %d cluster and %d rmlns packets\n",
config->multi_read_count, udp_pkts, tun_pkts, cluster_pkts, udplac_pkts);
#else
LOG(3, 0, 0, "Reached multi_read_count (%d); processed %d udp, %d tun and %d cluster packets\n",
"# uptime: %ld\n"
"# format: username ip qos uptxoctets downrxoctets\n",
hostname,
- fmtaddr(config->bind_address ? config->bind_address : my_address, 0),
+ fmtaddr(config->iftun_address ? config->iftun_address : my_address, 0),
now,
now - basetime);
}
exit(1);
inittun();
- LOG(1, 0, 0, "Set up on interface %s\n", config->tundevice);
+ LOG(1, 0, 0, "Set up on interface %s\n", config->tundevicename);
initudp();
initrad();
#ifdef LAC
if(!config->bind_portremotelns)
config->bind_portremotelns = L2TPLACPORT;
+ if(!config->bind_address_remotelns)
+ config->bind_address_remotelns = INADDR_ANY;
#endif
+ if(!config->iftun_address)
+ config->iftun_address = config->bind_address;
// re-initialise the random number source
initrandom(config->random_device);